mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
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
This commit is contained in:
committed by
Friendly Automation
parent
e0ee53dc9c
commit
fe540d0326
@@ -6,6 +6,7 @@ the GNU General Public License Version 2.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
import glob
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
from astdicts import OrderedDict
|
from astdicts import OrderedDict
|
||||||
@@ -57,6 +58,30 @@ class Section(MultiOrderedDict):
|
|||||||
"""
|
"""
|
||||||
return self.id == other.id
|
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,
|
def get(self, key, from_self=True, from_templates=True,
|
||||||
from_defaults=True):
|
from_defaults=True):
|
||||||
"""
|
"""
|
||||||
@@ -215,8 +240,17 @@ def try_include(line):
|
|||||||
included filename, otherwise None.
|
included filename, otherwise None.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
match = re.match('^#include\s*[<"]?(.*)[>"]?$', line)
|
match = re.match('^#include\s*([^;]+).*$', line)
|
||||||
return match.group(1) if match else None
|
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):
|
def try_section(line):
|
||||||
@@ -458,8 +492,9 @@ class MultiOrderedConfigParser:
|
|||||||
|
|
||||||
include_name = try_include(line)
|
include_name = try_include(line)
|
||||||
if include_name:
|
if include_name:
|
||||||
parser = self.add_include(include_name)
|
for incl in sorted(glob.iglob(include_name)):
|
||||||
parser.read(include_name, sect)
|
parser = self.add_include(incl)
|
||||||
|
parser.read(incl, sect)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
section, is_template, templates = try_section(line)
|
section, is_template, templates = try_section(line)
|
||||||
|
Reference in New Issue
Block a user