mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Various corrections to the py3 syntax changes
This commit is contained in:
parent
1d15fe84c0
commit
73a0b1ca2a
@ -8,9 +8,9 @@ __docformat__ = 'restructuredtext en'
|
||||
|
||||
import os
|
||||
|
||||
|
||||
from sphinx.builders.latex import LaTeXBuilder
|
||||
|
||||
|
||||
class LaTeXHelpBuilder(LaTeXBuilder):
|
||||
name = 'mylatex'
|
||||
|
||||
@ -18,9 +18,9 @@ class LaTeXHelpBuilder(LaTeXBuilder):
|
||||
LaTeXBuilder.finish(self)
|
||||
self.info('Fixing Cyrillic characters...')
|
||||
tex = os.path.join(self.outdir, 'calibre.tex')
|
||||
with open(tex, 'r+') as f:
|
||||
raw = f.read()
|
||||
with open(tex, 'r+b') as f:
|
||||
raw = f.read().decode('utf-8')
|
||||
for x in (u'Михаил Горбачёв', u'Фёдор Миха́йлович Достоевский'):
|
||||
raw = raw.replace(x, u'{\\fontencoding{T2A}\\selectfont %s}' % (x.replace(u'а́', u'a')))
|
||||
f.seek(0)
|
||||
f.write(raw)
|
||||
f.write(raw.encode('utf-8'))
|
||||
|
@ -278,7 +278,7 @@ class PDFStream(object):
|
||||
self.stream = HashingStream(stream)
|
||||
self.compress = compress
|
||||
self.write_line(PDFVER)
|
||||
self.write_line(u'%íì¦"'.encode())
|
||||
self.write_line(u'%íì¦"'.encode('utf-8'))
|
||||
creator = ('%s %s [https://calibre-ebook.com]'%(__appname__,
|
||||
__version__))
|
||||
self.write_line('%% Created by %s'%creator)
|
||||
@ -528,5 +528,3 @@ class PDFStream(object):
|
||||
self.write_line('startxref')
|
||||
self.write_line('%d'%startxref)
|
||||
self.stream.write('%%EOF')
|
||||
|
||||
|
||||
|
@ -53,13 +53,13 @@ class Tokenize:
|
||||
|
||||
def __unicode_process(self, token):
|
||||
# change scope in
|
||||
if token == '\{':
|
||||
if token == r'\{':
|
||||
self.__uc_value.append(self.__uc_value[-1])
|
||||
# basic error handling
|
||||
self.__reini_utf8_counters()
|
||||
return token
|
||||
# change scope out
|
||||
elif token == '\}':
|
||||
elif token == r'\}':
|
||||
self.__uc_value.pop()
|
||||
self.__reini_utf8_counters()
|
||||
return token
|
||||
@ -113,10 +113,10 @@ class Tokenize:
|
||||
input_file = self.__replace_spchar.mreplace(input_file)
|
||||
# this is for older RTF
|
||||
input_file = self.__par_exp.sub('\n\\par \n', input_file)
|
||||
input_file = self.__cwdigit_exp.sub("\g<1>\n\g<2>", input_file)
|
||||
input_file = self.__cs_ast.sub("\g<1>", input_file)
|
||||
input_file = self.__ms_hex_exp.sub("\\mshex0\g<1> ", input_file)
|
||||
input_file = self.__utf_ud.sub("\\{\\uc0 \g<1>\\}", input_file)
|
||||
input_file = self.__cwdigit_exp.sub("\\g<1>\n\\g<2>", input_file)
|
||||
input_file = self.__cs_ast.sub(r"\g<1>", input_file)
|
||||
input_file = self.__ms_hex_exp.sub("\\mshex0\\g<1> ", input_file)
|
||||
input_file = self.__utf_ud.sub("\\{\\uc0 \\g<1>\\}", input_file)
|
||||
# remove \n in bin data
|
||||
input_file = self.__bin_exp.sub(lambda x:
|
||||
x.group().replace('\n', '') + '\n', input_file)
|
||||
|
@ -23,7 +23,11 @@ from calibre.utils.date import UNDEFINED_DATE
|
||||
from calibre.utils.localization import get_lang
|
||||
from calibre.utils.file_type_icons import EXT_MAP
|
||||
|
||||
try:
|
||||
NO_URL_FORMATTING = QUrl.None_
|
||||
except AttributeError:
|
||||
NO_URL_FORMATTING = getattr(QUrl, 'None')
|
||||
|
||||
|
||||
# Setup gprefs {{{
|
||||
gprefs = JSONConfig('gui')
|
||||
|
@ -57,7 +57,7 @@ def css():
|
||||
val = P('templates/book_details.css', data=True).decode('utf-8')
|
||||
col = QApplication.instance().palette().color(QPalette.Link).name()
|
||||
val = val.replace('LINK_COLOR', col)
|
||||
_css = re.sub(r'/\*.*?\*/', '', val, flags=re.DOTALL)
|
||||
_css = re.sub(unicode(r'/\*.*?\*/'), u'', val, flags=re.DOTALL)
|
||||
return _css
|
||||
|
||||
|
||||
|
@ -387,7 +387,7 @@ _ebook_edit() {
|
||||
files)
|
||||
ebookfile=${~${(Q)line[1]}}
|
||||
|
||||
if [[ -f "$ebookfile" && "$ebookfile" =~ '\.[eE][pP][uU][bB]$' ]]; then
|
||||
if [[ -f "$ebookfile" && "$ebookfile" =~ '\\.[eE][pP][uU][bB]$' ]]; then
|
||||
_zip_cache_name="$ebookfile"
|
||||
_zip_cache_list=( ${(f)"$(zipinfo -1 $_zip_cache_name 2>/dev/null)"} )
|
||||
else
|
||||
|
@ -39,7 +39,7 @@ class TestHTTP(BaseTest):
|
||||
'\r\n', a='one', b='two 2 3', c='three')
|
||||
|
||||
test('Non-ascii headers parsing',
|
||||
'a:mūs\r', '\r\n', a='mūs')
|
||||
'a:mūs\r'.encode('utf-8'), '\r\n', a='mūs')
|
||||
|
||||
test('Comma-separated parsing',
|
||||
'Accept-Encoding: one',
|
||||
|
Loading…
x
Reference in New Issue
Block a user