<p>Friendly Automation <strong>submitted</strong> this change.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15108">View Change</a></p><div style="white-space:pre-wrap">Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit

</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">sip_to_pjsip.py: Handle #include globs and other fixes<br><br>* Wildcards in #includes are now properly expanded<br><br>* Implement operators for Section class to allow sorting<br><br>ASTERISK-29142 #close<br><br>Change-Id: I9b9cd95f4cbe5c24506b75d17173c5aa1a83e5df<br>---<br>M contrib/scripts/sip_to_pjsip/astconfigparser.py<br>1 file changed, 39 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/contrib/scripts/sip_to_pjsip/astconfigparser.py b/contrib/scripts/sip_to_pjsip/astconfigparser.py</span><br><span>index ee857e2..eb48b70 100644</span><br><span>--- a/contrib/scripts/sip_to_pjsip/astconfigparser.py</span><br><span>+++ b/contrib/scripts/sip_to_pjsip/astconfigparser.py</span><br><span>@@ -6,6 +6,7 @@</span><br><span> """</span><br><span> </span><br><span> import re</span><br><span style="color: hsl(120, 100%, 40%);">+import glob</span><br><span> import itertools</span><br><span> </span><br><span> from astdicts import OrderedDict</span><br><span>@@ -57,6 +58,30 @@</span><br><span>         """</span><br><span>         return self.id == other.id</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+    def __lt__(self, other):</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+        Use self.id as means of determining equality</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+        return self.id < other.id</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    def __gt__(self, other):</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+        Use self.id as means of determining equality</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+        return self.id > other.id</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    def __le__(self, other):</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+        Use self.id as means of determining equality</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+        return self.id <= other.id</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+    def __ge__(self, other):</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+        Use self.id as means of determining equality</span><br><span style="color: hsl(120, 100%, 40%);">+        """</span><br><span style="color: hsl(120, 100%, 40%);">+        return self.id >= other.id</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>     def get(self, key, from_self=True, from_templates=True,</span><br><span>             from_defaults=True):</span><br><span>         """</span><br><span>@@ -215,8 +240,17 @@</span><br><span>     included filename, otherwise None.</span><br><span>     """</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">-    match = re.match('^#include\s*[<"]?(.*)[>"]?$', line)</span><br><span style="color: hsl(0, 100%, 40%);">-    return match.group(1) if match else None</span><br><span style="color: hsl(120, 100%, 40%);">+    match = re.match('^#include\s*([^;]+).*$', line)</span><br><span style="color: hsl(120, 100%, 40%);">+    if match:</span><br><span style="color: hsl(120, 100%, 40%);">+        trimmed = match.group(1).rstrip()</span><br><span style="color: hsl(120, 100%, 40%);">+        quoted = re.match('^"([^"]+)"$', trimmed)</span><br><span style="color: hsl(120, 100%, 40%);">+        if quoted:</span><br><span style="color: hsl(120, 100%, 40%);">+            return quoted.group(1)</span><br><span style="color: hsl(120, 100%, 40%);">+        bracketed = re.match('^<([^>]+)>$', trimmed)</span><br><span style="color: hsl(120, 100%, 40%);">+        if bracketed:</span><br><span style="color: hsl(120, 100%, 40%);">+            return bracketed.group(1)</span><br><span style="color: hsl(120, 100%, 40%);">+        return trimmed</span><br><span style="color: hsl(120, 100%, 40%);">+    return None</span><br><span> </span><br><span> </span><br><span> def try_section(line):</span><br><span>@@ -458,8 +492,9 @@</span><br><span> </span><br><span>             include_name = try_include(line)</span><br><span>             if include_name:</span><br><span style="color: hsl(0, 100%, 40%);">-                parser = self.add_include(include_name)</span><br><span style="color: hsl(0, 100%, 40%);">-                parser.read(include_name, sect)</span><br><span style="color: hsl(120, 100%, 40%);">+                for incl in sorted(glob.iglob(include_name)):</span><br><span style="color: hsl(120, 100%, 40%);">+                    parser = self.add_include(incl)</span><br><span style="color: hsl(120, 100%, 40%);">+                    parser.read(incl, sect)</span><br><span>                 continue</span><br><span> </span><br><span>             section, is_template, templates = try_section(line)</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15108">change 15108</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/15108"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 18 </div>
<div style="display:none"> Gerrit-Change-Id: I9b9cd95f4cbe5c24506b75d17173c5aa1a83e5df </div>
<div style="display:none"> Gerrit-Change-Number: 15108 </div>
<div style="display:none"> Gerrit-PatchSet: 2 </div>
<div style="display:none"> Gerrit-Owner: Sean Bright <sean.bright@gmail.com> </div>
<div style="display:none"> Gerrit-Reviewer: Friendly Automation </div>
<div style="display:none"> Gerrit-Reviewer: George Joseph <gjoseph@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>
<div style="display:none"> Gerrit-MessageType: merged </div>