Commit d14635d27fe4dfe67a29d11e3bcafd69a4dcbe7c

Authored by decalage2
1 parent 253eb712

olemeta: removed the UTF8 codec for console display, to run on Python 2+3 (issue #62)

.gitignore
@@ -97,3 +97,4 @@ ENV/ @@ -97,3 +97,4 @@ ENV/
97 # Rope project settings 97 # Rope project settings
98 .ropeproject 98 .ropeproject
99 99
  100 +/temp/
oletools/olemeta.py
@@ -46,6 +46,7 @@ http://www.decalage.info/python/oletools @@ -46,6 +46,7 @@ http://www.decalage.info/python/oletools
46 # 2015-12-29 v0.03 PL: - only display properties present in the file 46 # 2015-12-29 v0.03 PL: - only display properties present in the file
47 # 2016-09-06 v0.50 PL: - added main entry point for setup.py 47 # 2016-09-06 v0.50 PL: - added main entry point for setup.py
48 # 2016-10-25 PL: - fixed print for Python 3 48 # 2016-10-25 PL: - fixed print for Python 3
  49 +# 2016-10-28 PL: - removed the UTF8 codec for console display
49 50
50 __version__ = '0.50' 51 __version__ = '0.50'
51 52
@@ -75,7 +76,8 @@ def main(): @@ -75,7 +76,8 @@ def main():
75 meta = ole.get_metadata() 76 meta = ole.get_metadata()
76 77
77 # console output with UTF8 encoding: 78 # console output with UTF8 encoding:
78 - console_utf8 = codecs.getwriter('utf8')(sys.stdout) 79 + # It looks like we do not need the UTF8 codec anymore, both for Python 2 and 3
  80 + console_utf8 = sys.stdout #codecs.getwriter('utf8')(sys.stdout)
79 81
80 # TODO: move similar code to a function 82 # TODO: move similar code to a function
81 83
@@ -87,11 +89,11 @@ def main(): @@ -87,11 +89,11 @@ def main():
87 # TODO: pretty printing for strings, dates, numbers 89 # TODO: pretty printing for strings, dates, numbers
88 # TODO: better unicode handling 90 # TODO: better unicode handling
89 # print('- %s: %s' % (prop, value)) 91 # print('- %s: %s' % (prop, value))
90 - if isinstance(value, unicode):  
91 - # encode to UTF8, avoiding errors  
92 - value = value.encode('utf-8', errors='replace')  
93 - else:  
94 - value = str(value) 92 + # if isinstance(value, unicode):
  93 + # # encode to UTF8, avoiding errors
  94 + # value = value.encode('utf-8', errors='replace')
  95 + # else:
  96 + # value = str(value)
95 t.write_row([prop, value], colors=[None, 'yellow']) 97 t.write_row([prop, value], colors=[None, 'yellow'])
96 t.close() 98 t.close()
97 print('') 99 print('')
@@ -104,11 +106,11 @@ def main(): @@ -104,11 +106,11 @@ def main():
104 # TODO: pretty printing for strings, dates, numbers 106 # TODO: pretty printing for strings, dates, numbers
105 # TODO: better unicode handling 107 # TODO: better unicode handling
106 # print('- %s: %s' % (prop, value)) 108 # print('- %s: %s' % (prop, value))
107 - if isinstance(value, unicode):  
108 - # encode to UTF8, avoiding errors  
109 - value = value.encode('utf-8', errors='replace')  
110 - else:  
111 - value = str(value) 109 + # if isinstance(value, unicode):
  110 + # # encode to UTF8, avoiding errors
  111 + # value = value.encode('utf-8', errors='replace')
  112 + # else:
  113 + # value = str(value)
112 t.write_row([prop, value], colors=[None, 'yellow']) 114 t.write_row([prop, value], colors=[None, 'yellow'])
113 t.close() 115 t.close()
114 116