You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by ju...@apache.org on 2015/12/23 13:26:56 UTC
svn commit: r1721534 -
/subversion/trunk/notes/move-tracking/path_pairs_to_eid_map.py
Author: julianfoad
Date: Wed Dec 23 12:26:55 2015
New Revision: 1721534
URL: http://svn.apache.org/viewvc?rev=1721534&view=rev
Log:
* notes/move-tracking/path_pairs_to_eid_map.py
Take input from command-line arguments.
Modified:
subversion/trunk/notes/move-tracking/path_pairs_to_eid_map.py
Modified: subversion/trunk/notes/move-tracking/path_pairs_to_eid_map.py
URL: http://svn.apache.org/viewvc/subversion/trunk/notes/move-tracking/path_pairs_to_eid_map.py?rev=1721534&r1=1721533&r2=1721534&view=diff
==============================================================================
--- subversion/trunk/notes/move-tracking/path_pairs_to_eid_map.py (original)
+++ subversion/trunk/notes/move-tracking/path_pairs_to_eid_map.py Wed Dec 23 12:26:55 2015
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+# Usage: path_pairs_to_eid_map.py [INITIAL-PATH FINAL-PATH ...]
+#
# Convert a list of (initial_path, final_path) pairs to a pair of element
# mappings:
# initial_map = {eid: (parent_eid, name), ...}
@@ -15,8 +17,12 @@
# assume (A -> A) and (X -> X). Another example: for input [(A -> X),
# (A/B/C -> X/B/D)], assume (A/B -> X/B).
+import sys
import posixpath
+class ArgumentsError(Exception):
+ pass
+
# input: a list of pairs of paths
input_example_1 = [
("A/D/H", "A"),
@@ -29,6 +35,17 @@ input_example_2 = [
]
input_path_pairs = input_example_1
+# Read input from pairs of command-line arguments, if given.
+if len(sys.argv) > 1:
+ n_args = len(sys.argv) - 1
+ if n_args % 2:
+ raise ArgumentsError("Need an even number (not %d) of paths, to be used in pairs" %
+ n_args)
+ argv = sys.argv[1:]
+ argv = [None if (a == '' or a == 'None' or a == 'nil') else a
+ for a in argv]
+ input_path_pairs = zip(argv[::2], argv[1::2])
+
print("Input:")
for e in input_path_pairs:
print(" " + str(e))