This commit is contained in:
Eli Schwartz 2019-03-21 01:20:29 -04:00
parent cb85e778d8
commit d66fdc2df7
No known key found for this signature in database
GPG Key ID: CEB167EFB5722BD6
6 changed files with 23 additions and 24 deletions

View File

@ -90,12 +90,12 @@ class Coffee(Command): # {{{
updated = {} updated = {}
for arcname in todo: for arcname in todo:
name = arcname.rpartition('.')[0] name = arcname.rpartition('.')[0]
print ('\t%sCompiling %s'%(time.strftime('[%H:%M:%S] ') if print('\t%sCompiling %s'%(time.strftime('[%H:%M:%S] ') if
timestamp else '', name)) timestamp else '', name))
src, sig = src_files[arcname] src, sig = src_files[arcname]
js, errors = compile_coffeescript(open(src, 'rb').read(), filename=src) js, errors = compile_coffeescript(open(src, 'rb').read(), filename=src)
if errors: if errors:
print ('\n\tCompilation of %s failed'%name) print('\n\tCompilation of %s failed'%name)
for line in errors: for line in errors:
print(line, file=sys.stderr) print(line, file=sys.stderr)
if ignore_errors: if ignore_errors:
@ -105,8 +105,8 @@ class Coffee(Command): # {{{
else: else:
if opts.show_js: if opts.show_js:
self.show_js(js) self.show_js(js)
print ('#'*80) print('#'*80)
print ('#'*80) print('#'*80)
zi = zipfile.ZipInfo() zi = zipfile.ZipInfo()
zi.filename = arcname zi.filename = arcname
zi.date_time = time.localtime()[:6] zi.date_time = time.localtime()[:6]

View File

@ -510,8 +510,7 @@ class LitWriter(object):
data.write(pack('<Bc', 1, '\\')) data.write(pack('<Bc', 1, '\\'))
offset = 0 offset = 0
for state in states: for state in states:
items = manifest[state] items = sorted(manifest[state])
items.sort()
data.write(pack('<I', len(items))) data.write(pack('<I', len(items)))
for item in items: for item in items:
id, media_type = item.id, item.media_type id, media_type = item.id, item.media_type

View File

@ -96,14 +96,14 @@ class MOBIFile(object):
self.read_tbs() self.read_tbs()
def print_header(self, f=sys.stdout): def print_header(self, f=sys.stdout):
print (str(self.mf.palmdb).encode('utf-8'), file=f) print(str(self.mf.palmdb).encode('utf-8'), file=f)
print (file=f) print(file=f)
print ('Record headers:', file=f) print('Record headers:', file=f)
for i, r in enumerate(self.mf.records): for i, r in enumerate(self.mf.records):
print ('%6d. %s'%(i, r.header), file=f) print('%6d. %s'%(i, r.header), file=f)
print (file=f) print(file=f)
print (str(self.mf.mobi8_header).encode('utf-8'), file=f) print(str(self.mf.mobi8_header).encode('utf-8'), file=f)
def read_fdst(self): def read_fdst(self):
self.fdst = None self.fdst = None
@ -202,7 +202,7 @@ class MOBIFile(object):
resource_index = len(container.resources) resource_index = len(container.resources)
elif sig == b'\xa0\xa0\xa0\xa0' and len(payload) == 4: elif sig == b'\xa0\xa0\xa0\xa0' and len(payload) == 4:
if container is None: if container is None:
print ('Found an end of container record with no container, ignoring') print('Found an end of container record with no container, ignoring')
else: else:
container.resources.append(None) container.resources.append(None)
continue continue
@ -287,7 +287,7 @@ class MOBIFile(object):
except: except:
calculated_bytes = b'failed to calculate tbs bytes' calculated_bytes = b'failed to calculate tbs bytes'
if calculated_bytes != otbs: if calculated_bytes != otbs:
print ('WARNING: TBS mismatch for record %d'%i) print('WARNING: TBS mismatch for record %d'%i)
desc.append('WARNING: TBS mismatch!') desc.append('WARNING: TBS mismatch!')
desc.append('Calculated sequences: %r'%calculated_sequences) desc.append('Calculated sequences: %r'%calculated_sequences)
desc.append('') desc.append('')

View File

@ -77,7 +77,7 @@ class InsertTag(Dialog): # {{{
def test(cls): def test(cls):
d = cls() d = cls()
if d.exec_() == d.Accepted: if d.exec_() == d.Accepted:
print (d.tag) print(d.tag)
# }}} # }}}
@ -475,7 +475,7 @@ class QuickOpen(Dialog):
items = get_items_from_dir(os.getcwdu(), lambda x:not x.endswith('.pyc')) items = get_items_from_dir(os.getcwdu(), lambda x:not x.endswith('.pyc'))
d = cls(items) d = cls(items)
d.exec_() d.exec_()
print (d.selected_result) print(d.selected_result)
# }}} # }}}
@ -1037,7 +1037,7 @@ class FilterCSS(Dialog): # {{{
def test(cls): def test(cls):
d = cls() d = cls()
if d.exec_() == d.Accepted: if d.exec_() == d.Accepted:
print (d.filtered_properties) print(d.filtered_properties)
# }}} # }}}

View File

@ -261,10 +261,10 @@ class Server(socketserver.ThreadingMixIn, HTTPServer): # {{{
The default is to print a traceback and continue. The default is to print a traceback and continue.
""" """
print ('-'*40) print('-'*40)
print ('Exception happened during processing of request', request) print('Exception happened during processing of request', request)
traceback.print_exc() # XXX But this goes to stderr! traceback.print_exc() # XXX But this goes to stderr!
print ('-'*40) print('-'*40)
# }}} # }}}
@ -320,9 +320,9 @@ def main():
from pygments.lexers import JavascriptLexer from pygments.lexers import JavascriptLexer
from pygments.formatters import TerminalFormatter from pygments.formatters import TerminalFormatter
from pygments import highlight from pygments import highlight
print (highlight(ans, JavascriptLexer(), TerminalFormatter())) print(highlight(ans, JavascriptLexer(), TerminalFormatter()))
else: else:
print (ans.encode(sys.stdout.encoding or 'utf-8')) print(ans.encode(sys.stdout.encoding or 'utf-8'))
else: else:
serve(port=args.port, host=args.host) serve(port=args.port, host=args.host)

View File

@ -169,10 +169,10 @@ class Detect(object):
# to use raster fonts (the default). In this case # to use raster fonts (the default). In this case
# rather than failing, write an informative error # rather than failing, write an informative error
# message and the asciized version of the text. # message and the asciized version of the text.
print ('Non-ASCII text detected. You must set your Console\'s font to' print('Non-ASCII text detected. You must set your Console\'s font to'
' Lucida Console or Consolas or some other TrueType font to see this text', file=self.stream, end=' -- ') ' Lucida Console or Consolas or some other TrueType font to see this text', file=self.stream, end=' -- ')
from calibre.utils.filenames import ascii_text from calibre.utils.filenames import ascii_text
print (ascii_text(t + text), file=self.stream, end='') print(ascii_text(t + text), file=self.stream, end='')
continue continue
if not ignore_errors: if not ignore_errors:
raise ctypes.WinError(err) raise ctypes.WinError(err)