diff options
Diffstat (limited to 'src/sexparse/config.py')
-rw-r--r-- | src/sexparse/config.py | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/sexparse/config.py b/src/sexparse/config.py index c4fc2ab..200af21 100644 --- a/src/sexparse/config.py +++ b/src/sexparse/config.py @@ -21,13 +21,15 @@ #(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS #SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import os -import sexparse +from sexparse.base import SexConfigBase +from sexparse.functions import * __all__ = ['SexConfig'] -class SexConfig(sexparse.SexConfigBase): + +class SexConfig(SexConfigBase): def __init__(self, filename): - sexparse.SexConfigBase.__init__(self, filename) + SexConfigBase.__init__(self, filename) self.read() def read(self): @@ -36,12 +38,23 @@ class SexConfig(sexparse.SexConfigBase): continue comment_position = line.find(self.comment) line = line[0:comment_position] - keypairs = line.split() - if not keypairs: + key = line[0:line.find(' ')] + + if not key: continue - self.pairs[keypairs[0]] = keypairs[1:] - if not keypairs: + + item = line[line.find(' '):].split(',') + + if not item: continue + + item = [ x.strip(' ') for x in item ] + item = [ convert_type(x) for x in item ] + + if len(item) == 1: + item = item[0] + + self.pairs[key] = item def write(self, filename=None): if filename is None: |