summaryrefslogtreecommitdiff
path: root/contrib/scripts/sip_to_pjsip/astconfigparser.py
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2016-07-28 19:18:06 -0500
committerGerrit Code Review <gerrit2@gerrit.digium.api>2016-07-28 19:18:06 -0500
commit6131d70aa8aebf73c073ff57e05a0d1b247b0906 (patch)
tree73420db289ace53ef9e4f9f1f5ca20f92e3de5f9 /contrib/scripts/sip_to_pjsip/astconfigparser.py
parentaa698770494f3e0b2263ec2673ab4add6d52bb9b (diff)
parent1e7168aee0fe34b1a99ade151ee6edd3b419da85 (diff)
Merge "astconfigparser.py: Update with realtime fixes."
Diffstat (limited to 'contrib/scripts/sip_to_pjsip/astconfigparser.py')
-rw-r--r--contrib/scripts/sip_to_pjsip/astconfigparser.py24
1 files changed, 21 insertions, 3 deletions
diff --git a/contrib/scripts/sip_to_pjsip/astconfigparser.py b/contrib/scripts/sip_to_pjsip/astconfigparser.py
index b207b0d7c..46f4fb484 100644
--- a/contrib/scripts/sip_to_pjsip/astconfigparser.py
+++ b/contrib/scripts/sip_to_pjsip/astconfigparser.py
@@ -1,3 +1,10 @@
+"""
+Copyright (C) 2016, Digium, Inc.
+
+This program is free software, distributed under the terms of
+the GNU General Public License Version 2.
+"""
+
import re
import itertools
@@ -44,6 +51,12 @@ class Section(MultiOrderedDict):
"""
return cmp(self.id, other.id)
+ def __eq__(self, other):
+ """
+ Use self.id as means of determining equality
+ """
+ return self.id == other.id
+
def get(self, key, from_self=True, from_templates=True,
from_defaults=True):
"""
@@ -184,9 +197,14 @@ def remove_comment(line, is_comment):
# otherwise it was an embedded comment so combine
return ''.join([part[0].strip(), ' ', line]).rstrip(), False
- # check for eol comment
- return line.partition(COMMENT)[0].strip(), False
+ # find the first occurence of a comment that is not escaped
+ match = re.match(r'.*?([^\\];)', line)
+
+ if match:
+ # the end of where the real string is is where the comment starts
+ line = line[0:(match.end()-1)]
+ return line.replace("\\", "").strip(), False
def try_include(line):
"""
@@ -224,7 +242,7 @@ def try_section(line):
def try_option(line):
"""Parses the line as an option, returning the key/value pair."""
- data = re.split('=>?', line)
+ data = re.split('=>?', line, 1)
# should split in two (key/val), but either way use first two elements
return data[0].rstrip(), data[1].lstrip()