Made splits more flexible.

This commit is contained in:
Jeremy Fincher 2004-01-20 17:09:57 +00:00
parent f161f9d4c7
commit 302f824fb7

View File

@ -31,6 +31,7 @@
__revision__ = "$Id$" __revision__ = "$Id$"
import re
import copy import copy
import sets import sets
import types import types
@ -57,7 +58,7 @@ def open(filename):
for (i, line) in enumerate(fd): for (i, line) in enumerate(fd):
line = line.rstrip('\r\n') line = line.rstrip('\r\n')
try: try:
(key, value) = line.split(': ', 1) (key, value) = re.split(r':\s*', line, 1)
except ValueError: except ValueError:
raise InvalidRegistryFile, 'Error unpacking line #%s' % (i+1) raise InvalidRegistryFile, 'Error unpacking line #%s' % (i+1)
_cache[key.lower()] = value _cache[key.lower()] = value
@ -177,7 +178,7 @@ class StringSurroundedBySpaces(String):
class CommaSeparatedListOfStrings(String): class CommaSeparatedListOfStrings(String):
def set(self, s): def set(self, s):
String.set(self, s) String.set(self, s)
self.setValue(map(str.strip, self.value.split(','))) self.setValue(map(str.strip, re.split(r'\s*,\s*', self.value)))
def __str__(self): def __str__(self):
return ','.join(self.value) return ','.join(self.value)