quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zu...@apache.org
Subject [1/2] incubator-quickstep git commit: QUICKSTEP-38. Add support for python3 to utility scripts [Forced Update!]
Date Wed, 03 Aug 2016 18:54:08 GMT
Repository: incubator-quickstep
Updated Branches:
  refs/heads/optimizer-q-id c8ead67a1 -> 8cd5a56c9 (forced update)


QUICKSTEP-38. Add support for python3 to utility scripts


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/d4e714ce
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/d4e714ce
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/d4e714ce

Branch: refs/heads/optimizer-q-id
Commit: d4e714ce32e195c95a4e603db7ec8302865f9418
Parents: a61b99e
Author: Caleb Welton <cwelton@apache.org>
Authored: Tue Aug 2 10:44:41 2016 -0700
Committer: Zuyu Zhang <zuyuz@twitter.com>
Committed: Wed Aug 3 11:48:27 2016 -0700

----------------------------------------------------------------------
 cyclic_dependency.py   | 28 ++++++++++++++++------------
 validate_cmakelists.py | 42 +++++++++++++++++++++++-------------------
 2 files changed, 39 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d4e714ce/cyclic_dependency.py
----------------------------------------------------------------------
diff --git a/cyclic_dependency.py b/cyclic_dependency.py
index 8bf7d80..a5cca25 100755
--- a/cyclic_dependency.py
+++ b/cyclic_dependency.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
 
 # Script to do analyze the dependencies in Quickstep particularly cycles in the
 # dependency graph. This script can be used to find:
@@ -33,6 +33,10 @@
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
 import itertools
 import networkx as nx
 from optparse import OptionParser
@@ -110,18 +114,18 @@ def process_cmakelists_file(cmakelists_filename, qs_module_dirs):
 # target mapping, and target to node mapping.
 def create_graph(deps_in_cmake):
     nodes = set()
-    for source, dest_set in deps_in_cmake.iteritems():
+    for source, dest_set in iter(deps_in_cmake.items()):
         nodes.add(source)
         nodes.update(dest_set)
 
     nodes_list = list(nodes)
     nodes_map = {}
-    for i, n in zip(xrange(len(nodes_list)), nodes_list):
+    for i, n in zip(range(len(nodes_list)), nodes_list):
         nodes_map[n] = i
 
     G = nx.DiGraph()
 
-    for source, dest_set in deps_in_cmake.iteritems():
+    for source, dest_set in iter(deps_in_cmake.items()):
         source_node = nodes_map[source]
         for dest in dest_set:
             if source == dest: continue
@@ -137,17 +141,17 @@ def find_strongly_connected_components(G, nodes_list):
         if len(n) > 1:
             components += 1
             # Only output components bigger than 1.
-            print [nodes_list[i] for i in n]
+            print([nodes_list[i] for i in n])
     return components
 
 # Lists cycles in the graph truncating to 100 cycles.
 def find_cycles(G, nodes_list, truncate):
     cycles = 0
     for n in nx.simple_cycles(G):
-        print [nodes_list[i] for i in n]
+        print([nodes_list[i] for i in n])
         cycles += 1
         if cycles >= truncate:
-            print "Many cycles found. Truncating to {0} cycles.".format(truncate)
+            print("Many cycles found. Truncating to {0} cycles.".format(truncate))
             break
     return cycles
 
@@ -156,16 +160,16 @@ def find_path(G, nodes_list, nodes_map, source, target):
     source_node = nodes_map[source]
     target_node = nodes_map[target]
     if nx.has_path(G, source_node, target_node):
-        print [nodes_list[i] for i in nx.shortest_path(G,
+        print([nodes_list[i] for i in nx.shortest_path(G,
                 source_node,
-                target_node)]
+                target_node)])
     else:
-        print 'No path.'
+        print('No path.')
 
 def main():
     if not os.getcwd().endswith("quickstep"):
-        print ("WARNING: you don't appear to be running in the root quickstep "
-               "source directory. Don't blame me if something goes wrong.")
+        print("WARNING: you don't appear to be running in the root quickstep "
+              "source directory. Don't blame me if something goes wrong.")
     qs_module_dirs = []
     for filename in os.listdir("."):
         if (os.path.isdir(filename)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d4e714ce/validate_cmakelists.py
----------------------------------------------------------------------
diff --git a/validate_cmakelists.py b/validate_cmakelists.py
index 7dd6fc5..cf25d28 100755
--- a/validate_cmakelists.py
+++ b/validate_cmakelists.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python2
+#!/usr/bin/env python
 
 """Script to do basic sanity checking for target_link_libraries() commands in
 CMakeLists.txt files.
@@ -31,6 +31,10 @@ TODO List / Known Issues & Limitations:
 #   See the License for the specific language governing permissions and
 #   limitations under the License.
 
+from __future__ import absolute_import
+from __future__ import division
+from __future__ import print_function
+
 import os
 import sys
 
@@ -334,8 +338,8 @@ def process_cmakelists_file(cmakelists_filename, qs_module_dirs):
                 if "CMAKE_VALIDATE_IGNORE_END" in line:
                     scan_state = previous_state
                 elif "CMAKE_VALIDATE_IGNORE_BEGIN" in line:
-                    print "Nested IGNORE_BEGIN directives found in: "\
-                        + cmakelists_filename + ", exiting"
+                    print("Nested IGNORE_BEGIN directives found in: "
+                        + cmakelists_filename + ", exiting")
                     exit(-1)
                 else:
                     continue
@@ -397,25 +401,25 @@ def process_cmakelists_file(cmakelists_filename, qs_module_dirs):
                     stitched_string = ""
                     scan_state = CMAKE_SCANNING_NONE
     # After scanning, report any missing dependencies.
-    for target, include_deps in deps_from_includes.iteritems():
+    for target, include_deps in iter(deps_from_includes.items()):
         if target in skipped_targets:
             pass
         elif len(include_deps) != 0:
             if target not in deps_in_cmake:
                 if not (target in include_deps and len(include_deps) == 1):
                     validation_failed_targets.add(target)
-                    print "Missing target_link_libraries() for " + target + ":"
+                    print("Missing target_link_libraries() for " + target + ":")
                     for dep in sorted(include_deps):
-                        print "\t" + dep
+                        print("\t" + dep)
             else:
                 missing_deps = (include_deps
                                 - deps_in_cmake[target]
                                 - IGNORED_DEPENDENCIES)
                 if len(missing_deps) != 0:
                     validation_failed_targets.add(target)
-                    print "Missing target_link_libraries() for " + target + ":"
+                    print("Missing target_link_libraries() for " + target + ":")
                     for dep in sorted(missing_deps):
-                        print "\t" + dep
+                        print("\t" + dep)
         elif target == module_targetname:
             # Special case hack for module all-in-one library
             missing_deps = (frozenset(deps_from_includes.keys())
@@ -427,21 +431,21 @@ def process_cmakelists_file(cmakelists_filename, qs_module_dirs):
                     true_missing_deps.add(dep)
             if len(true_missing_deps) != 0:
                 validation_failed_targets.add(target)
-                print "Missing target_link_libraries() for " + target + ":"
+                print("Missing target_link_libraries() for " + target + ":")
                 for dep in sorted(true_missing_deps):
-                    print "\t" + dep
+                    print("\t" + dep)
     # Also report possibly superfluous extra dependencies.
-    for target, cmake_deps in deps_in_cmake.iteritems():
+    for target, cmake_deps in iter(deps_in_cmake.items()):
         if (target not in skipped_targets) and (target in deps_from_includes):
             extra_deps = cmake_deps - deps_from_includes[target]
             if target in extra_deps:
                 extra_deps.remove(target)
             if len(extra_deps) != 0 and target != module_targetname:
                 validation_failed_targets.add(target)
-                print ("Possibly superfluous target_link_libraries() for "
+                print("Possibly superfluous target_link_libraries() for "
                        + target + ":")
                 for dep in sorted(extra_deps):
-                    print "\t" + dep
+                    print("\t" + dep)
     return (validation_failed_targets, skipped_targets, generated_targets)
 
 def main(cmakelists_to_process):
@@ -461,8 +465,8 @@ def main(cmakelists_to_process):
             missing or superfluous dependencies.
     """
     if not os.getcwd().endswith("quickstep"):
-        print ("WARNING: you don't appear to be running in the root quickstep "
-               "source directory. Don't blame me if something goes wrong.")
+        print("WARNING: you don't appear to be running in the root quickstep "
+              "source directory. Don't blame me if something goes wrong.")
     qs_module_dirs = []
     for filename in os.listdir("."):
         if (os.path.isdir(filename)
@@ -493,17 +497,17 @@ def main(cmakelists_to_process):
         global_skipped_targets.update(local_skipped_targets)
         global_generated_targets.update(local_generated_targets)
     if len(global_skipped_targets) != 0:
-        print ("WARNING: The following targets had multiple add_library() "
+        print("WARNING: The following targets had multiple add_library() "
                + "commands and were NOT checked by this script (they should "
                + "be manually checked):")
         for target in sorted(global_skipped_targets):
-            print "\t" + target
+            print("\t" + target)
     if len(global_generated_targets) != 0:
-        print ("INFO: The add_library() commands for the following targets "
+        print("INFO: The add_library() commands for the following targets "
                + "appear to reference generated sources, so they were not "
                + "checked):")
         for target in sorted(global_generated_targets):
-            print "\t" + target
+            print("\t" + target)
     return len(global_validation_failed_targets)
 
 if __name__ == "__main__":


Mime
View raw message