[Git][NTPsec/ntpsec][master] Eliminate wafhelpers.util

Matt Selsky gitlab at mg.gitlab.com
Mon Apr 24 06:57:12 UTC 2017


Matt Selsky pushed to branch master at NTPsec / ntpsec


Commits:
6e864604 by Matt Selsky at 2017-04-24T02:53:25-04:00
Eliminate wafhelpers.util

Each function is only called once.  Move the functions closer to their callers.
Also, make indentation more consistent.

- - - - -


3 changed files:

- wafhelpers/asciidoc.py
- wafhelpers/configure.py
- − wafhelpers/util.py


Changes:

=====================================
wafhelpers/asciidoc.py
=====================================
--- a/wafhelpers/asciidoc.py
+++ b/wafhelpers/asciidoc.py
@@ -1,10 +1,46 @@
+import re
+
 from waflib import Task
 from waflib.TaskGen import extension
-from wafhelpers.util import ascii_doc_scan
 
 # asciidoc -b html5 -a linkcss -a stylesdir=/mnt/devel/ntp/commit/docs \
 #   -o asd driver32.txt
 
+# Borrowed from waf/docs/book/wscript in the Waf Project.
+re_xi = re.compile('''^(include|image)::(.*?.(txt|\\{PIC\\}))\[''', re.M)
+
+
+def ascii_doc_scan(self):
+    p = self.inputs[0].parent
+    node_lst = [self.inputs[0]]
+    seen = []
+    depnodes = []
+
+    while node_lst:
+        nd = node_lst.pop(0)
+        if nd in seen:
+            continue
+        seen.append(nd)
+
+        code = nd.read()
+        for m in re_xi.finditer(code):
+            name = m.group(2)
+            if m.group(3) == '{PIC}':
+
+                ext = '.eps'
+                if self.generator.rule.rfind('A2X') > 0:
+                    ext = '.png'
+
+                k = p.find_resource(name.replace('{PIC}', ext))
+                if k:
+                    depnodes.append(k)
+            else:
+                k = self.inputs[0].find_resource(name)
+                if k:
+                    depnodes.append(k)
+                    node_lst.append(k)
+    return [depnodes, ()]
+
 
 # ASCIIDOC_FLAGS are almost always needed and need to be set by the user.
 class asciidoc(Task.Task):


=====================================
wafhelpers/configure.py
=====================================
--- a/wafhelpers/configure.py
+++ b/wafhelpers/configure.py
@@ -5,11 +5,11 @@ import sys
 import time
 from wafhelpers.probes \
     import probe_header_with_prerequisites, probe_function_with_prerequisites
-from wafhelpers.util import msg, msg_setting, parse_version
 
 from waflib.Errors import WafError
 from waflib import Build
 from waflib.Context import BOTH
+from waflib.Logs import pprint
 
 
 class oc(Build.BuildContext):
@@ -33,6 +33,28 @@ class oc(Build.BuildContext):
         return 0
 
 
+def msg(str):
+    pprint("YELLOW", str)
+
+
+def msg_setting(name, val):
+    pprint("NORMAL", "  %-30s: " % name, sep="")
+    pprint("YELLOW", val)
+
+
+def parse_version(config):
+    with open("VERSION", "r") as f:
+        version_string = f.read().split(" ")[0].strip()
+        [major, minor, rev] = version_string.split(".")
+        # "NTPS" for NTPSec
+        # this avoids any naming collisions
+        map = {"NTPSEC_VERSION_MAJOR": int(major),
+               "NTPSEC_VERSION_MINOR": int(minor),
+               "NTPSEC_VERSION_REV": int(rev)}
+
+    config.update(map)
+
+
 def cmd_configure(ctx, config):
     srcnode = ctx.srcnode.abspath()
     bldnode = ctx.bldnode.abspath()


=====================================
wafhelpers/util.py deleted
=====================================
--- a/wafhelpers/util.py
+++ /dev/null
@@ -1,59 +0,0 @@
-import re
-from waflib.Logs import pprint
-
-
-def msg(str):
-        pprint("YELLOW", str)
-
-
-def msg_setting(name, val):
-        pprint("NORMAL", "  %-30s: " % name, sep="")
-        pprint("YELLOW", val)
-
-# Borrowed from waf/docs/book/wscript in the Waf Project.
-re_xi = re.compile('''^(include|image)::(.*?.(txt|\\{PIC\\}))\[''', re.M)
-
-
-def ascii_doc_scan(self):
-        p = self.inputs[0].parent
-        node_lst = [self.inputs[0]]
-        seen = []
-        depnodes = []
-
-        while node_lst:
-                nd = node_lst.pop(0)
-                if nd in seen:
-                    continue
-                seen.append(nd)
-
-                code = nd.read()
-                for m in re_xi.finditer(code):
-                        name = m.group(2)
-                        if m.group(3) == '{PIC}':
-
-                                ext = '.eps'
-                                if self.generator.rule.rfind('A2X') > 0:
-                                        ext = '.png'
-
-                                k = p.find_resource(name.replace('{PIC}', ext))
-                                if k:
-                                        depnodes.append(k)
-                        else:
-                                k = self.inputs[0].find_resource(name)
-                                if k:
-                                        depnodes.append(k)
-                                        node_lst.append(k)
-        return [depnodes, ()]
-
-
-def parse_version(config):
-        with open("VERSION", "r") as f:
-                version_string = f.read().split(" ")[0].strip()
-                [major, minor, rev] = version_string.split(".")
-                # "NTPS" for NTPSec
-                # this avoids any naming collisions
-                map = {"NTPSEC_VERSION_MAJOR": int(major),
-                       "NTPSEC_VERSION_MINOR": int(minor),
-                       "NTPSEC_VERSION_REV": int(rev)}
-
-        config.update(map)



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/6e864604de9aa46c41091fa316b18cdad6170427

---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/6e864604de9aa46c41091fa316b18cdad6170427
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170424/bed08855/attachment.html>


More information about the vc mailing list