1 |
commit: 8119905e27e78619ea226205d20874f220f5bb37 |
2 |
Author: André Erdmann <dywi <AT> mailerd <DOT> de> |
3 |
AuthorDate: Fri Jul 6 22:14:41 2012 +0000 |
4 |
Commit: André Erdmann <dywi <AT> mailerd <DOT> de> |
5 |
CommitDate: Fri Jul 6 22:14:41 2012 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=8119905e |
7 |
|
8 |
main script: --help-config, --overlay |
9 |
|
10 |
modified: main.py |
11 |
modified: roverlay/argutil.py |
12 |
|
13 |
--- |
14 |
main.py | 29 ++++++++++++++++++++++++++--- |
15 |
roverlay/argutil.py | 19 +++++++++++++++++++ |
16 |
2 files changed, 45 insertions(+), 3 deletions(-) |
17 |
|
18 |
diff --git a/main.py b/main.py |
19 |
index df76b32..ce1189f 100755 |
20 |
--- a/main.py |
21 |
+++ b/main.py |
22 |
@@ -26,7 +26,7 @@ class DIE ( object ): |
23 |
if msg is not None: |
24 |
sys.stderr.write ( msg + "\n" ) |
25 |
# else: |
26 |
-# sys.stderr.write ( "died." ) |
27 |
+# sys.stderr.write ( "died.\n" ) |
28 |
sys.exit ( code ) |
29 |
# --- end of die (...) --- |
30 |
|
31 |
@@ -39,6 +39,9 @@ if __name__ != '__main__': |
32 |
|
33 |
|
34 |
# get args |
35 |
+# imports roverlay.argutil (deleted when done) |
36 |
+ |
37 |
+ |
38 |
try: |
39 |
import roverlay.argutil |
40 |
except ImportError: |
41 |
@@ -49,7 +52,8 @@ except ImportError: |
42 |
|
43 |
COMMAND_DESCRIPTION = { |
44 |
'sync' : 'sync repos', |
45 |
- 'create' : 'create the overlay', |
46 |
+ 'create' : 'create the overlay ' |
47 |
+ '(implies sync, override with --nosync)', |
48 |
# 'depres_console' : 'run an interactive depres console; TODO/REMOVE', |
49 |
'nop' : 'does nothing', |
50 |
} |
51 |
@@ -66,6 +70,8 @@ del roverlay.argutil |
52 |
|
53 |
# -- load config |
54 |
|
55 |
+# imports: roverlay, roverlay.config.entryutil (if --help-config) |
56 |
+ |
57 |
try: |
58 |
import roverlay |
59 |
except ImportError: |
60 |
@@ -82,20 +88,36 @@ try: |
61 |
del config_file, additional_config |
62 |
except: |
63 |
if HIDE_EXCEPTIONS: |
64 |
- die ( "Cannot load config file %r." % config_file, DIE.CONFIG ) |
65 |
+ die ( "Cannot load config file {!r}.".format ( config_file ), DIE.CONFIG ) |
66 |
else: |
67 |
raise |
68 |
|
69 |
+if OPTION ( 'list_config' ): |
70 |
+ try: |
71 |
+ from roverlay.config.entryutil import list_entries |
72 |
+ print ( "== main config file ==\n" ) |
73 |
+ print ( list_entries() ) |
74 |
+ except: |
75 |
+ raise |
76 |
+ die ( "Cannot list config entries!" ) |
77 |
+ |
78 |
+ EXIT_AFTER_CONFIG = True |
79 |
+ |
80 |
if OPTION ( 'print_config' ): |
81 |
try: |
82 |
conf.visualize ( into=sys.stdout ) |
83 |
except: |
84 |
die ( "Cannot print config!" ) |
85 |
+ EXIT_AFTER_CONFIG = True |
86 |
+ |
87 |
+ |
88 |
+if 'EXIT_AFTER_CONFIG' in locals() and EXIT_AFTER_CONFIG: |
89 |
sys.exit ( os.EX_OK ) |
90 |
|
91 |
|
92 |
# -- determine commands to run |
93 |
# (TODO) could replace this section when adding more actions |
94 |
+# imports roverlay.remote, roverlay.overlay.creator |
95 |
|
96 |
actions = set ( filter ( lambda x : x != 'nop', commands ) ) |
97 |
|
98 |
@@ -124,6 +146,7 @@ except ImportError: |
99 |
|
100 |
|
101 |
# -- run methods (and some vars) |
102 |
+# imports: nothing |
103 |
|
104 |
actions_done = set() |
105 |
set_action_done = actions_done.add |
106 |
|
107 |
diff --git a/roverlay/argutil.py b/roverlay/argutil.py |
108 |
index 540743a..4750d15 100644 |
109 |
--- a/roverlay/argutil.py |
110 |
+++ b/roverlay/argutil.py |
111 |
@@ -113,6 +113,14 @@ def get_parser ( CMD_DESC, DEFAULT_CONFIG ): |
112 |
) |
113 |
|
114 |
arg ( |
115 |
+ '--overlay', '-O', default=argparse.SUPPRESS, |
116 |
+ help='overlay directory to write (implies --write)', |
117 |
+ metavar="<OVERLAY>", |
118 |
+ type=couldbe_fs_dir |
119 |
+ ) |
120 |
+ |
121 |
+ |
122 |
+ arg ( |
123 |
'--show-overlay', '--show', |
124 |
help="print ebuilds and metadata to console", |
125 |
**opt_in |
126 |
@@ -157,6 +165,12 @@ def get_parser ( CMD_DESC, DEFAULT_CONFIG ): |
127 |
**opt_in |
128 |
) |
129 |
|
130 |
+ arg ( |
131 |
+ '--list-config-entries', '--help-config', |
132 |
+ help="list all known config entries", |
133 |
+ **opt_in |
134 |
+ ) |
135 |
+ |
136 |
# --write-desc |
137 |
# --log-level, --log-console, --log... |
138 |
|
139 |
@@ -210,9 +224,14 @@ def parse_argv ( *args, **kw ): |
140 |
write_overlay = p.write_overlay, |
141 |
print_stats = p.stats, |
142 |
print_config = p.print_config, |
143 |
+ list_config = p.list_config_entries, |
144 |
force_distroot = p.force_distroot, |
145 |
) |
146 |
|
147 |
+ if given ( 'overlay' ): |
148 |
+ doconf ( p.overlay, 'OVERLAY.dir' ) |
149 |
+ extra ['write_overlay'] = True |
150 |
+ |
151 |
if given ( 'field_definition' ): |
152 |
doconf ( p.field_definition, 'DESCRIPTION.field_definition_file' ) |