~bladernr/checkbox/1071605-cycle-resolutions-after-suspend-auto-fix

« back to all changes in this revision

Viewing changes to checkbox/parsers/udevadm.py

  • Committer: Tarmac
  • Author(s): Zygmunt Krynicki
  • Date: 2012-11-12 19:32:33 UTC
  • mfrom: (1817.1.4 launchpad/udev_resource)
  • Revision ID: tarmac-20121112193233-nhxus506avgs533c
"[r=sylvain-pineau][bug=][author=zkrynicki] * udev_resource: use simplier interfaces
* udev_resource: PEP-8 fixes
* udevadm: Allow using UdevadmParser with a string"

Show diffs side-by-side

added added

removed removed

Lines of Context:
415
415
 
416
416
    device_factory = UdevadmDevice
417
417
 
418
 
    def __init__(self, stream, bits=None):
419
 
        self.stream = stream
 
418
    def __init__(self, stream_or_string, bits=None):
 
419
        self.stream_or_string = stream_or_string
420
420
        self.bits = bits
421
421
 
422
422
    def _ignoreDevice(self, device):
455
455
        multi_pattern = re.compile(r"(?P<key>[^=]+)=(?P<value>.*)")
456
456
 
457
457
        stack = []
458
 
        output = self.stream.read()
 
458
        if isinstance(self.stream_or_string, str):
 
459
            output = self.stream_or_string
 
460
        else:
 
461
            output = self.stream_or_string.read()
459
462
        for record in re.split("\n{2,}", output):
460
463
            record = record.strip()
461
464
            if not record: