* fix: printu prints unicode strings and objects
* fix: use unicode() constructor instead of str() in several places
This commit is contained in:
@@ -491,7 +491,7 @@ Usage: info <package1> <package2> ... <packagen>
|
||||
import os.path
|
||||
|
||||
metadata, files = pisi.api.info(arg)
|
||||
ctx.ui.info(str(metadata.package))
|
||||
ctx.ui.info(unicode(metadata.package))
|
||||
if self.options.files or self.options.files_path:
|
||||
if files:
|
||||
ctx.ui.info(_('\nFiles:'))
|
||||
|
||||
+1
-1
@@ -369,7 +369,7 @@ class PackageInfo:
|
||||
self.name, self.version, self.release, self.build)
|
||||
s += _('\nSummary: ') + self.summary
|
||||
s += _('\nDescription: ') + self.description
|
||||
s += _('\nComponent: ') + str(self.partof)
|
||||
s += _('\nComponent: ') + unicode(self.partof)
|
||||
s += _('\nProvides: ')
|
||||
for x in self.providesComar:
|
||||
s += x.om
|
||||
|
||||
+2
-1
@@ -386,6 +386,7 @@ class autoxml(type):
|
||||
def encode(xml, node, value, errs):
|
||||
"""encode given value inside DOM node"""
|
||||
if value:
|
||||
#FIXME: unicode() here?
|
||||
writetext(xml, node, token, str(value))
|
||||
else:
|
||||
if req == mandatory:
|
||||
@@ -393,7 +394,7 @@ class autoxml(type):
|
||||
|
||||
def format(value, errs):
|
||||
"""format value for pretty printing"""
|
||||
return str(value)
|
||||
return unicode(value)
|
||||
|
||||
return initialize, decode, encode, format
|
||||
|
||||
|
||||
+6
-4
@@ -151,12 +151,14 @@ valid_filetypes = [
|
||||
]
|
||||
|
||||
def printu(obj):
|
||||
if isinstance(obj, unicode):
|
||||
"""smart print command which handles unicode strings and objects which
|
||||
return unicode __str__'s, a common case in our implementation"""
|
||||
if isinstance(obj, str):
|
||||
print obj
|
||||
elif isinstance(obj, unicode):
|
||||
print obj.encode('utf-8')
|
||||
elif isinstance(obj, str):
|
||||
print obj.decode('utf-8')
|
||||
else:
|
||||
print str(obj)
|
||||
print unicode(obj).encode('utf-8') # this is printu!
|
||||
|
||||
def valuesort(x, y):
|
||||
if x[1] > y[1]:
|
||||
|
||||
Reference in New Issue
Block a user