Skip to content

Commit

Permalink
Fix dynamic objects list output parsing
Browse files Browse the repository at this point in the history
- Support arbitrary whitespace field separation
- Remove unused imports
  • Loading branch information
chkp-ofer committed Aug 27, 2019
1 parent 681a25a commit 042d1ef
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions dynobj.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

import json
import logging
import os
import re
import socket
import struct
import subprocess
import sys
import tempfile


_DYNOBJ_COMMAND = 'dynamic_objects'
Expand Down Expand Up @@ -175,10 +173,10 @@ def get_objects(self):
for line in lines:
if line.startswith('object name :'):
name = line[len('object name :'):].strip()
if line.startswith('range '):
range_str = line.partition(':')[2].strip()
begin = range_str.partition('\t')[0].strip()
end = range_str.partition('\t')[2].strip()
match_obj = re.match(r'range\s+[^:]*:\s*(\S+)\s+(\S+)\s*$', line)
if match_obj:
begin = match_obj.group(1)
end = match_obj.group(2)
ranges.append((begin, end))
if line == '':
if name:
Expand Down

0 comments on commit 042d1ef

Please sign in to comment.