Skip to content

Commit

Permalink
Fix parsing of EDID
Browse files Browse the repository at this point in the history
See bug #19.
  • Loading branch information
phillipberndt committed Feb 17, 2015
1 parent 527c3cd commit 376005b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions autorandr.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ class XrandrOutput(object):
)? # .. but everything of the above only if the screen is in use.
).*
(?:\s*(?: # Properties of the output
Gamma: (?P<gamma>[0-9\.:\s]+) | # Gamma value
Transform: (?P<transform>[\-0-9\.\s]+) | # Transformation matrix
EDID: (?P<edid>[0-9a-f\s]+) | # EDID of the output
Gamma: (?P<gamma>[0-9\.: ]+) | # Gamma value
Transform: (?P<transform>(?:[\-0-9\.]+\s+){3}) | # Transformation matrix
EDID: (?P<edid>\s*?(?:\\n\\t\\t[0-9a-f]+)+) | # EDID of the output
(?![0-9])[^:\s][^:\n]+:.*(?:\s\\t[\\t ].+)* # Other properties
))+
\s*
Expand Down Expand Up @@ -186,6 +186,7 @@ def from_xrandr_output(cls, xrandr_output):
This method also returns a list of modes supported by the output.
"""
try:
xrandr_output = xrandr_output.replace("\r\n", "\n")
match_object = re.search(XrandrOutput.XRANDR_OUTPUT_REGEXP, xrandr_output)
except:
raise RuntimeError("Parsing XRandR output failed, there is an error in the regular expression.")
Expand All @@ -194,9 +195,8 @@ def from_xrandr_output(cls, xrandr_output):
raise RuntimeError("Parsing XRandR output failed, the regular expression did not match: %s" % debug)
remainder = xrandr_output[len(match_object.group(0)):]
if remainder:
raise RuntimeError(("Parsing XRandR output failed, %d bytes left unmatched after regular expression,"
"starting with ..'%s'.") % (len(remainder), remainder[:10]))

raise RuntimeError(("Parsing XRandR output failed, %d bytes left unmatched after regular expression, "
"starting at byte %d with ..'%s'.") % (len(remainder), len(len(match_object.group(0))), remainder[:10]))

match = match_object.groupdict()

Expand Down

0 comments on commit 376005b

Please sign in to comment.