1 |
We don't support python 2.6 anymore, so drop the non-argparse logic. |
2 |
--- |
3 |
bin/chpathtool.py | 45 +++++++++++---------------------------------- |
4 |
1 file changed, 11 insertions(+), 34 deletions(-) |
5 |
|
6 |
diff --git a/bin/chpathtool.py b/bin/chpathtool.py |
7 |
index 842f1f4..73c7a5f 100755 |
8 |
--- a/bin/chpathtool.py |
9 |
+++ b/bin/chpathtool.py |
10 |
@@ -7,18 +7,12 @@ doc = """Helper tool for converting installed files to custom prefixes. |
11 |
In other words, eprefixy $D for Gentoo/Prefix.""" |
12 |
__doc__ = doc |
13 |
|
14 |
- |
15 |
+import argparse |
16 |
import io |
17 |
import os |
18 |
import stat |
19 |
import sys |
20 |
|
21 |
-try: |
22 |
- from argparse import ArgumentParser |
23 |
-except ImportError: |
24 |
- ArgumentParser = None |
25 |
- from optparse import OptionParser |
26 |
- |
27 |
CONTENT_ENCODING = 'utf_8' |
28 |
FS_ENCODING = 'utf_8' |
29 |
|
30 |
@@ -152,33 +146,16 @@ def chpath_inplace_symlink(filename, st, old, new): |
31 |
|
32 |
def main(argv): |
33 |
|
34 |
- if ArgumentParser is not None: |
35 |
- parser = ArgumentParser(description=doc) |
36 |
- parser.add_argument('location', default=None, |
37 |
- help='root directory (e.g. $D)') |
38 |
- parser.add_argument('old', default=None, |
39 |
- help='original build prefix (e.g. /)') |
40 |
- parser.add_argument('new', default=None, |
41 |
- help='new install prefix (e.g. $EPREFIX)') |
42 |
- opts = parser.parse_args(argv) |
43 |
- |
44 |
- location, old, new = opts.location, opts.old, opts.new |
45 |
- else: |
46 |
- # Argument parsing compatibility for Python 2.6 using optparse. |
47 |
- parser = OptionParser(description=doc, |
48 |
- usage="usage: %prog [-h] location old new\n\n" + \ |
49 |
- " location: root directory (e.g. $D)\n" + \ |
50 |
- " old: original build prefix (e.g. /)\n" + \ |
51 |
- " new: new install prefix (e.g. $EPREFIX)") |
52 |
- |
53 |
- (opts, args) = parser.parse_args() |
54 |
- |
55 |
- if len(args) != 3: |
56 |
- parser.print_usage() |
57 |
- parser.error("%s: error: expected 3 arguments, got %i" |
58 |
- % (__file__, len(args))) |
59 |
- |
60 |
- location, old, new = args[0:3] |
61 |
+ parser = argparse.ArgumentParser(description=doc) |
62 |
+ parser.add_argument('location', default=None, |
63 |
+ help='root directory (e.g. $D)') |
64 |
+ parser.add_argument('old', default=None, |
65 |
+ help='original build prefix (e.g. /)') |
66 |
+ parser.add_argument('new', default=None, |
67 |
+ help='new install prefix (e.g. $EPREFIX)') |
68 |
+ opts = parser.parse_args(argv) |
69 |
+ |
70 |
+ location, old, new = opts.location, opts.old, opts.new |
71 |
|
72 |
is_text_file = IsTextFile() |
73 |
|
74 |
-- |
75 |
2.5.2 |