[Asterisk-code-review] sip_to_pjsip.py: Handle #include globs and other fixes (asterisk[16])
Sean Bright
asteriskteam at digium.com
Thu Oct 29 15:08:12 CDT 2020
Sean Bright has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15080 )
Change subject: sip_to_pjsip.py: Handle #include globs and other fixes
......................................................................
sip_to_pjsip.py: Handle #include globs and other fixes
* Wildcards in #includes are now properly expanded
* Implement operators for Section class to allow sorting
ASTERISK-29142 #close
Change-Id: I9b9cd95f4cbe5c24506b75d17173c5aa1a83e5df
---
M contrib/scripts/sip_to_pjsip/astconfigparser.py
1 file changed, 39 insertions(+), 4 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/80/15080/1
diff --git a/contrib/scripts/sip_to_pjsip/astconfigparser.py b/contrib/scripts/sip_to_pjsip/astconfigparser.py
index ee857e2..eb48b70 100644
--- a/contrib/scripts/sip_to_pjsip/astconfigparser.py
+++ b/contrib/scripts/sip_to_pjsip/astconfigparser.py
@@ -6,6 +6,7 @@
"""
import re
+import glob
import itertools
from astdicts import OrderedDict
@@ -57,6 +58,30 @@
"""
return self.id == other.id
+ def __lt__(self, other):
+ """
+ Use self.id as means of determining equality
+ """
+ return self.id < other.id
+
+ def __gt__(self, other):
+ """
+ Use self.id as means of determining equality
+ """
+ return self.id > other.id
+
+ def __le__(self, other):
+ """
+ Use self.id as means of determining equality
+ """
+ return self.id <= other.id
+
+ def __ge__(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):
"""
@@ -215,8 +240,17 @@
included filename, otherwise None.
"""
- match = re.match('^#include\s*[<"]?(.*)[>"]?$', line)
- return match.group(1) if match else None
+ match = re.match('^#include\s*([^;]+).*$', line)
+ if match:
+ trimmed = match.group(1).rstrip()
+ quoted = re.match('^"([^"]+)"$', trimmed)
+ if quoted:
+ return quoted.group(1)
+ bracketed = re.match('^<([^>]+)>$', trimmed)
+ if bracketed:
+ return bracketed.group(1)
+ return trimmed
+ return None
def try_section(line):
@@ -458,8 +492,9 @@
include_name = try_include(line)
if include_name:
- parser = self.add_include(include_name)
- parser.read(include_name, sect)
+ for incl in sorted(glob.iglob(include_name)):
+ parser = self.add_include(incl)
+ parser.read(incl, sect)
continue
section, is_template, templates = try_section(line)
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15080
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I9b9cd95f4cbe5c24506b75d17173c5aa1a83e5df
Gerrit-Change-Number: 15080
Gerrit-PatchSet: 1
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20201029/b9f2c78e/attachment.html>
More information about the asterisk-code-review
mailing list