]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/tools/build/test/load_dir.py
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / tools / build / test / load_dir.py
index faa47d216e022c7458f1741e1ce31876ef691cf3..1b082b1c6cb9d4945df16f087460b0037fc4cea8 100644 (file)
@@ -5,13 +5,15 @@ Traverses a directory and output the code that would create the same directory
 structure during testing. Assumes that the instance of Tester is called 't'.
 """
 
+from __future__ import print_function
+
 import sys
 import os
 import stat
 import string
 
 def usage():
-    print "usage: load_dir.py directory"
+    print("usage: load_dir.py directory")
 
 
 def remove_first_component(path):
@@ -21,18 +23,18 @@ def remove_first_component(path):
         if not s[0]:
             break
         result[:1] = list(s)
-    return apply(os.path.join, result[1:])
+    return os.path.join(*result[1:])
 
 
 def create_file(arg, dirname, fnames):
     for n in fnames:
         path = os.path.join(dirname, n)
         if not os.path.isdir(path):
-            print "t.write(\"%s\", \"\"\"" % (remove_first_component(path),),
+            print("t.write(\"%s\", \"\"\"" % (remove_first_component(path),),)
             f = open(path, "r")
             for l in f:
-                print l,
-            print '\n""")\n'
+                print(l)
+            print('\n""")\n')
 
 
 header = """#!/usr/bin/python
@@ -64,17 +66,18 @@ def main():
         path = sys.argv[1]
 
         if not os.access(path, os.F_OK):
-            print "Path '%s' does not exist" % (path,)
+            print("Path '%s' does not exist" % (path,))
             sys.exit(1)
 
         if not os.path.isdir(path):
-            print "Path '%s' is not a directory" % (path,)
+            print("Path '%s' is not a directory" % (path,))
 
-        print header
+        print(header)
 
-        os.path.walk(path, create_file, None)
+        for root, _, files in os.walk(path):
+            create_file(None, root, files)
 
-        print footer
+        print(footer)
 
 
 if __name__ == '__main__':