You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ac...@apache.org on 2015/01/06 17:27:36 UTC

svn commit: r1649865 - in /qpid/dispatch/trunk: doc/book/CMakeLists.txt doc/man/help2md.py doc/man/man2book.py python/qpid_dispatch_internal/compat/subproc.py

Author: aconway
Date: Tue Jan  6 16:27:36 2015
New Revision: 1649865

URL: http://svn.apache.org/r1649865
Log:
NO-JIRA: Get help2md.py working on python 2.6.

- missing subprocess.check_output
- missing flags keyword on re.sub
- fixed cmake dependency change from cmake 2.6.4

Added:
    qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/subproc.py
Modified:
    qpid/dispatch/trunk/doc/book/CMakeLists.txt
    qpid/dispatch/trunk/doc/man/help2md.py
    qpid/dispatch/trunk/doc/man/man2book.py

Modified: qpid/dispatch/trunk/doc/book/CMakeLists.txt
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/doc/book/CMakeLists.txt?rev=1649865&r1=1649864&r2=1649865&view=diff
==============================================================================
--- qpid/dispatch/trunk/doc/book/CMakeLists.txt (original)
+++ qpid/dispatch/trunk/doc/book/CMakeLists.txt Tue Jan  6 16:27:36 2015
@@ -67,4 +67,5 @@ endif(PANDOC)
 
 
 # Target to generate all chapters and books.
-add_custom_target(book ALL DEPENDS man ${BOOK} ${BOOKS})
+add_custom_target(book ALL DEPENDS ${BOOK} ${BOOKS})
+add_dependencies(book man) # Note: adding man to book DEPENDS does not work on cmake 2.6.4

Modified: qpid/dispatch/trunk/doc/man/help2md.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/doc/man/help2md.py?rev=1649865&r1=1649864&r2=1649865&view=diff
==============================================================================
--- qpid/dispatch/trunk/doc/man/help2md.py (original)
+++ qpid/dispatch/trunk/doc/man/help2md.py Tue Jan  6 16:27:36 2015
@@ -27,7 +27,7 @@ or append it at the end if there is no #
 """
 
 import re, sys
-from subprocess import check_output, STDOUT
+from qpid_dispatch_internal.compat.subproc import check_output, STDOUT
 from os import path
 
 def help2md(help_out):
@@ -58,8 +58,8 @@ def main(argv):
     source, target, program = argv[1], argv[2], argv[3:]
     source_md = open(source).read()
     options_md = help2md(check_output(program, stderr=STDOUT))
-    combine_md = re.sub(r"\n# Options.*?(?=(\n# |$))", options_md, source_md, flags=re.IGNORECASE | re.DOTALL)
-    upcase_md = re.sub(r"^#+ .*$", lambda m: m.group(0).upper(), combine_md, flags=re.MULTILINE)
+    combine_md = re.sub(r"\n# Options.*?(?=(\n# |$))(?ims)", options_md, source_md)
+    upcase_md = re.sub(r"^#+ .*$(?m)", lambda m: m.group(0).upper(), combine_md)
     open(target, "w").write(upcase_md)
 
 if __name__ == "__main__":

Modified: qpid/dispatch/trunk/doc/man/man2book.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/doc/man/man2book.py?rev=1649865&r1=1649864&r2=1649865&view=diff
==============================================================================
--- qpid/dispatch/trunk/doc/man/man2book.py (original)
+++ qpid/dispatch/trunk/doc/man/man2book.py Tue Jan  6 16:27:36 2015
@@ -28,5 +28,4 @@ man_files = sys.argv[1:]
 assert man_files
 for f in man_files:
     print "# Manual page %s" % path.splitext(path.basename(f))[0]
-    print re.sub("^#+ .*", lambda m: "#"+string.capwords(m.group(0)),
-                 open(f).read(), flags=re.MULTILINE)
+    print re.sub("^#+ .*(?m)", lambda m: "#"+string.capwords(m.group(0)), open(f).read())

Added: qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/subproc.py
URL: http://svn.apache.org/viewvc/qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/subproc.py?rev=1649865&view=auto
==============================================================================
--- qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/subproc.py (added)
+++ qpid/dispatch/trunk/python/qpid_dispatch_internal/compat/subproc.py Tue Jan  6 16:27:36 2015
@@ -0,0 +1,42 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License
+#
+
+"""
+Implementations of some handy subprocess functions missing in python 2.6
+"""
+
+from subprocess import *
+
+try:
+    from subprocess import check_output
+except ImportError:
+    def check_output(args, stdin=None, stderr=None, shell=False, universal_newlines=False, **kwargs):
+        """
+        Run command args and return its output as a byte string.
+        kwargs are passed through to L{subprocess.Popen}
+        @return: stdout of command (mixed with stderr if stderr=STDOUT)
+        @raise L{CalledProcessError}: If command returns non-0 exit status.
+        """
+        if "stdoutxo" in kwargs:
+            raise ValueError("Must not specify stdout in check_output")
+        p = Popen(args, stdout=PIPE, stdin=stdin, stderr=stderr, shell=shell, universal_newlines=universal_newlines, **kwargs)
+        out, err = p.communicate()
+        if p.returncode:
+            raise CalledProcessError(args, p.returncode, err or out)
+        return out



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org