1 |
--- |
2 |
bin/chpathtool.py | 43 ++++++++++++++++++++++++++++++++----------- |
3 |
1 file changed, 32 insertions(+), 11 deletions(-) |
4 |
|
5 |
diff --git a/bin/chpathtool.py b/bin/chpathtool.py |
6 |
index aa3b7d4..692a338 100755 |
7 |
--- a/bin/chpathtool.py |
8 |
+++ b/bin/chpathtool.py |
9 |
@@ -11,7 +11,11 @@ import os |
10 |
import stat |
11 |
import sys |
12 |
|
13 |
-from portage.util._argparse import ArgumentParser |
14 |
+if sys.hexversion < 0x2070000: |
15 |
+ # Argument parsing compatibility for Python 2.6 using optparse. |
16 |
+ from optparse import OptionParser |
17 |
+else: |
18 |
+ from portage.util._argparse import ArgumentParser |
19 |
|
20 |
CONTENT_ENCODING = 'utf_8' |
21 |
FS_ENCODING = 'utf_8' |
22 |
@@ -145,17 +149,34 @@ def chpath_inplace_symlink(filename, st, old, new): |
23 |
os.lchown(filename, st.st_uid, st.st_gid) |
24 |
|
25 |
def main(argv): |
26 |
+ if sys.hexversion < 0x2070000: |
27 |
+ # Argument parsing compatibility for Python 2.6 using optparse. |
28 |
+ parser = OptionParser(description=__doc__, |
29 |
+ usage="usage: %prog [-h] location old new\n\n" + \ |
30 |
+ " location: root directory (e.g. $D)\n" + \ |
31 |
+ " old: original build prefix (e.g. /)\n" + \ |
32 |
+ " new: new install prefix (e.g. $EPREFIX)") |
33 |
+ |
34 |
+ (opts, args) = parser.parse_args() |
35 |
+ |
36 |
+ if len(args) != 3: |
37 |
+ parser.print_usage() |
38 |
+ print("%s: error: expected 3 arguments, got %i" |
39 |
+ % (__file__, len(args))) |
40 |
+ return |
41 |
|
42 |
- parser = ArgumentParser(description=__doc__) |
43 |
- parser.add_argument('location', default=None, |
44 |
- help='root directory (e.g. $D)') |
45 |
- parser.add_argument('old', default=None, |
46 |
- help='original build prefix (e.g. /)') |
47 |
- parser.add_argument('new', default=None, |
48 |
- help='new install prefix (e.g. $EPREFIX)') |
49 |
- opts = parser.parse_args(argv) |
50 |
- |
51 |
- location, old, new = opts.location, opts.old, opts.new |
52 |
+ location, old, new = args[0:3] |
53 |
+ else: |
54 |
+ parser = ArgumentParser(description=__doc__) |
55 |
+ parser.add_argument('location', default=None, |
56 |
+ help='root directory (e.g. $D)') |
57 |
+ parser.add_argument('old', default=None, |
58 |
+ help='original build prefix (e.g. /)') |
59 |
+ parser.add_argument('new', default=None, |
60 |
+ help='new install prefix (e.g. $EPREFIX)') |
61 |
+ opts = parser.parse_args(argv) |
62 |
+ |
63 |
+ location, old, new = opts.location, opts.old, opts.new |
64 |
|
65 |
is_text_file = IsTextFile() |
66 |
|
67 |
-- |
68 |
1.8.5.2 |