http://code.google.com/p/pycopia/source/detail?r=530
Modified:
/trunk/CLI/pycopia/CLI.py
/trunk/QA/pycopia/QA/config.py
=======================================
--- /trunk/CLI/pycopia/CLI.py Wed Aug 17 22:51:10 2011
+++ /trunk/CLI/pycopia/CLI.py Mon Jan 30 23:10:04 2012
@@ -322,16 +322,15 @@
def printf(self, argv):
"""printf [<format>] <args>....
Print the arguments according to the format,
- or all arguments if first is not a format string."""
- if argv[1].find("%") >= 0:
- try:
- ns = vars(self._obj)
- except:
- ns = globals()
- args, kwargs = breakout_args(argv[2:], ns)
- self._print(str(argv[1]) % args)
- else:
- self._print(" ".join(argv[1:]))
+ or all arguments if first is not a format string. Format string has
Python format syntax
+ ({} style expansions) combined with Pycopia UI expansions."""
+ fmt = argv[1]
+ try:
+ ns = vars(self._obj)
+ except:
+ ns = globals()
+ args, kwargs = breakout_args(argv[2:], ns)
+ self._ui.printf(fmt.format(*args, **kwargs))
def exit(self, argv):
"""exit
=======================================
--- /trunk/QA/pycopia/QA/config.py Thu Jan 19 21:31:25 2012
+++ /trunk/QA/pycopia/QA/config.py Mon Jan 30 23:10:04 2012
@@ -471,6 +471,9 @@
d[prop.type.name] = prop.value
self._attributes = d
+ def __str__(self):
+ return "{} {}".format(self._attributes["manufacturer"],
self._attributes["name"])
+
def __getitem__(self, name):
return self._attributes[name]