summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/wic/plugin.py3
-rw-r--r--scripts/lib/wic/utils/cmdln.py57
-rw-r--r--scripts/lib/wic/utils/runner.py3
3 files changed, 42 insertions, 21 deletions
diff --git a/scripts/lib/wic/plugin.py b/scripts/lib/wic/plugin.py
index d714b6d7a9..e901f807ad 100644
--- a/scripts/lib/wic/plugin.py
+++ b/scripts/lib/wic/plugin.py
@@ -82,7 +82,8 @@ class PluginMgr(object):
82 82
83 def _load_all(self): 83 def _load_all(self):
84 for (pdir, loaded) in self.plugin_dirs.iteritems(): 84 for (pdir, loaded) in self.plugin_dirs.iteritems():
85 if loaded: continue 85 if loaded:
86 continue
86 87
87 sys.path.insert(0, pdir) 88 sys.path.insert(0, pdir)
88 for mod in [x[:-3] for x in os.listdir(pdir) if x.endswith(".py")]: 89 for mod in [x[:-3] for x in os.listdir(pdir) if x.endswith(".py")]:
diff --git a/scripts/lib/wic/utils/cmdln.py b/scripts/lib/wic/utils/cmdln.py
index d8f1c051ab..47654b934f 100644
--- a/scripts/lib/wic/utils/cmdln.py
+++ b/scripts/lib/wic/utils/cmdln.py
@@ -443,7 +443,8 @@ class RawCmdln(cmd.Cmd):
443 elif line[0] == '?': 443 elif line[0] == '?':
444 line = 'help ' + line[1:] 444 line = 'help ' + line[1:]
445 i, n = 0, len(line) 445 i, n = 0, len(line)
446 while i < n and line[i] in self.identchars: i = i+1 446 while i < n and line[i] in self.identchars:
447 i = i+1
447 cmd, arg = line[:i], line[i:].strip() 448 cmd, arg = line[:i], line[i:].strip()
448 return cmd, arg, line 449 return cmd, arg, line
449 450
@@ -499,8 +500,10 @@ class RawCmdln(cmd.Cmd):
499 doc = self.__class__.__doc__ # try class docstring 500 doc = self.__class__.__doc__ # try class docstring
500 if doc is None: 501 if doc is None:
501 # Try to provide some reasonable useful default help. 502 # Try to provide some reasonable useful default help.
502 if self.cmdlooping: prefix = "" 503 if self.cmdlooping:
503 else: prefix = self.name+' ' 504 prefix = ""
505 else:
506 prefix = self.name+' '
504 doc = """Usage: 507 doc = """Usage:
505 %sCOMMAND [ARGS...] 508 %sCOMMAND [ARGS...]
506 %shelp [COMMAND] 509 %shelp [COMMAND]
@@ -629,7 +632,8 @@ class RawCmdln(cmd.Cmd):
629 token2canonical = self._get_canonical_map() 632 token2canonical = self._get_canonical_map()
630 aliases = {} 633 aliases = {}
631 for token, cmdname in token2canonical.items(): 634 for token, cmdname in token2canonical.items():
632 if token == cmdname: continue 635 if token == cmdname:
636 continue
633 aliases.setdefault(cmdname, []).append(token) 637 aliases.setdefault(cmdname, []).append(token)
634 638
635 # Get the list of (non-hidden) commands and their 639 # Get the list of (non-hidden) commands and their
@@ -697,7 +701,8 @@ class RawCmdln(cmd.Cmd):
697 helpnames = {} 701 helpnames = {}
698 token2cmdname = self._get_canonical_map() 702 token2cmdname = self._get_canonical_map()
699 for attrname, attr in self._gen_names_and_attrs(): 703 for attrname, attr in self._gen_names_and_attrs():
700 if not attrname.startswith("help_"): continue 704 if not attrname.startswith("help_"):
705 continue
701 helpname = attrname[5:] 706 helpname = attrname[5:]
702 if helpname not in token2cmdname: 707 if helpname not in token2cmdname:
703 helpnames[helpname] = attr 708 helpnames[helpname] = attr
@@ -757,8 +762,10 @@ class RawCmdln(cmd.Cmd):
757 762
758 # Adjust argcount for possible *args and **kwargs arguments. 763 # Adjust argcount for possible *args and **kwargs arguments.
759 argcount = co_argcount 764 argcount = co_argcount
760 if co_flags & CO_FLAGS_ARGS: argcount += 1 765 if co_flags & CO_FLAGS_ARGS:
761 if co_flags & CO_FLAGS_KWARGS: argcount += 1 766 argcount += 1
767 if co_flags & CO_FLAGS_KWARGS:
768 argcount += 1
762 769
763 # Determine the usage string. 770 # Determine the usage string.
764 usage = "%s %s" % (self.name, cmdname) 771 usage = "%s %s" % (self.name, cmdname)
@@ -838,8 +845,10 @@ class RawCmdln(cmd.Cmd):
838 token2canonical = {} 845 token2canonical = {}
839 cmd2funcname = {} # use a dict to strip duplicates 846 cmd2funcname = {} # use a dict to strip duplicates
840 for attr in self.get_names(): 847 for attr in self.get_names():
841 if attr.startswith("do_"): cmdname = attr[3:] 848 if attr.startswith("do_"):
842 elif attr.startswith("_do_"): cmdname = attr[4:] 849 cmdname = attr[3:]
850 elif attr.startswith("_do_"):
851 cmdname = attr[4:]
843 else: 852 else:
844 continue 853 continue
845 cmd2funcname[cmdname] = attr 854 cmd2funcname[cmdname] = attr
@@ -1280,12 +1289,14 @@ def line2argv(line):
1280 i = -1 1289 i = -1
1281 while 1: 1290 while 1:
1282 i += 1 1291 i += 1
1283 if i >= len(line): break 1292 if i >= len(line):
1293 break
1284 ch = line[i] 1294 ch = line[i]
1285 1295
1286 if ch == "\\" and i+1 < len(line): 1296 if ch == "\\" and i+1 < len(line):
1287 # escaped char always added to arg, regardless of state 1297 # escaped char always added to arg, regardless of state
1288 if arg is None: arg = "" 1298 if arg is None:
1299 arg = ""
1289 if (sys.platform == "win32" 1300 if (sys.platform == "win32"
1290 or state in ("double-quoted", "single-quoted") 1301 or state in ("double-quoted", "single-quoted")
1291 ) and line[i+1] not in tuple('"\''): 1302 ) and line[i+1] not in tuple('"\''):
@@ -1306,17 +1317,20 @@ def line2argv(line):
1306 arg += ch 1317 arg += ch
1307 elif state == "default": 1318 elif state == "default":
1308 if ch == '"': 1319 if ch == '"':
1309 if arg is None: arg = "" 1320 if arg is None:
1321 arg = ""
1310 state = "double-quoted" 1322 state = "double-quoted"
1311 elif ch == "'": 1323 elif ch == "'":
1312 if arg is None: arg = "" 1324 if arg is None:
1325 arg = ""
1313 state = "single-quoted" 1326 state = "single-quoted"
1314 elif ch in string.whitespace: 1327 elif ch in string.whitespace:
1315 if arg is not None: 1328 if arg is not None:
1316 argv.append(arg) 1329 argv.append(arg)
1317 arg = None 1330 arg = None
1318 else: 1331 else:
1319 if arg is None: arg = "" 1332 if arg is None:
1333 arg = ""
1320 arg += ch 1334 arg += ch
1321 if arg is not None: 1335 if arg is not None:
1322 argv.append(arg) 1336 argv.append(arg)
@@ -1380,7 +1394,8 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False):
1380 indents = [] 1394 indents = []
1381 margin = None 1395 margin = None
1382 for i, line in enumerate(lines): 1396 for i, line in enumerate(lines):
1383 if i == 0 and skip_first_line: continue 1397 if i == 0 and skip_first_line:
1398 continue
1384 indent = 0 1399 indent = 0
1385 for ch in line: 1400 for ch in line:
1386 if ch == ' ': 1401 if ch == ' ':
@@ -1393,16 +1408,19 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False):
1393 break 1408 break
1394 else: 1409 else:
1395 continue # skip all-whitespace lines 1410 continue # skip all-whitespace lines
1396 if DEBUG: print "dedent: indent=%d: %r" % (indent, line) 1411 if DEBUG:
1412 print "dedent: indent=%d: %r" % (indent, line)
1397 if margin is None: 1413 if margin is None:
1398 margin = indent 1414 margin = indent
1399 else: 1415 else:
1400 margin = min(margin, indent) 1416 margin = min(margin, indent)
1401 if DEBUG: print "dedent: margin=%r" % margin 1417 if DEBUG:
1418 print "dedent: margin=%r" % margin
1402 1419
1403 if margin is not None and margin > 0: 1420 if margin is not None and margin > 0:
1404 for i, line in enumerate(lines): 1421 for i, line in enumerate(lines):
1405 if i == 0 and skip_first_line: continue 1422 if i == 0 and skip_first_line:
1423 continue
1406 removed = 0 1424 removed = 0
1407 for j, ch in enumerate(line): 1425 for j, ch in enumerate(line):
1408 if ch == ' ': 1426 if ch == ' ':
@@ -1410,7 +1428,8 @@ def _dedentlines(lines, tabsize=8, skip_first_line=False):
1410 elif ch == '\t': 1428 elif ch == '\t':
1411 removed += tabsize - (removed % tabsize) 1429 removed += tabsize - (removed % tabsize)
1412 elif ch in '\r\n': 1430 elif ch in '\r\n':
1413 if DEBUG: print "dedent: %r: EOL -> strip up to EOL" % line 1431 if DEBUG:
1432 print "dedent: %r: EOL -> strip up to EOL" % line
1414 lines[i] = lines[i][j:] 1433 lines[i] = lines[i][j:]
1415 break 1434 break
1416 else: 1435 else:
diff --git a/scripts/lib/wic/utils/runner.py b/scripts/lib/wic/utils/runner.py
index 8d48f68034..f6a1d0828c 100644
--- a/scripts/lib/wic/utils/runner.py
+++ b/scripts/lib/wic/utils/runner.py
@@ -90,7 +90,8 @@ def show(cmdln_or_args):
90 cmd = cmdln_or_args 90 cmd = cmdln_or_args
91 91
92 msg = 'running command: "%s"' % cmd 92 msg = 'running command: "%s"' % cmd
93 if out: out = out.strip() 93 if out:
94 out = out.strip()
94 if out: 95 if out:
95 msg += ', with output::' 96 msg += ', with output::'
96 msg += '\n +----------------' 97 msg += '\n +----------------'