+ return self.edid_equals(other) and self.output == other.output and self.options == other.options
+
+def xrandr_version():
+ "Return the version of XRandR that this system uses"
+ if getattr(xrandr_version, "version", False) is False:
+ version_string = os.popen("xrandr -v").read()
+ try:
+ version = re.search("xrandr program version\s+([0-9\.]+)", version_string).group(1)
+ xrandr_version.version = Version(version)
+ except AttributeError:
+ xrandr_version.version = Version("1.3.0")
+
+ return xrandr_version.version
+
+def debug_regexp(pattern, string):
+ "Use the partial matching functionality of the regex module to display debug info on a non-matching regular expression"
+ try:
+ import regex
+ bounds = ( 0, len(string) )
+ while bounds[0] != bounds[1]:
+ half = int((bounds[0] + bounds[1]) / 2)
+ if half == bounds[0]:
+ break
+ bounds = (half, bounds[1]) if regex.search(pattern, string[:half], partial=True) else (bounds[0], half - 1)
+ partial_length = bounds[0]
+ return ("Regular expression matched until position "
+ "%d, ..'%s', and did not match from '%s'.." % (partial_length, string[max(0, partial_length-20):partial_length],
+ string[partial_length:partial_length+10]))
+ except ImportError:
+ pass
+ return "Debug information available if `regex' module is installed."