mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
python3: use exec() instead of execfile()
This commit is contained in:
parent
c68a5c8ab1
commit
9ecadb9c13
@ -248,7 +248,8 @@ def run_script(path, args):
|
|||||||
g = globals()
|
g = globals()
|
||||||
g['__name__'] = '__main__'
|
g['__name__'] = '__main__'
|
||||||
g['__file__'] = ef
|
g['__file__'] = ef
|
||||||
execfile(ef, g)
|
with open(ef, 'rb') as f:
|
||||||
|
exec(compile(f.read(), ef, 'exec'), g)
|
||||||
|
|
||||||
|
|
||||||
def inspect_mobi(path):
|
def inspect_mobi(path):
|
||||||
|
@ -4602,7 +4602,9 @@ class CatalogBuilder(object):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
templates = {}
|
templates = {}
|
||||||
execfile(P('catalog/section_list_templates.py'), templates)
|
ef = P('catalog/section_list_templates.py')
|
||||||
|
with open(ef, 'rb')) as f:
|
||||||
|
exec(compile(f.read(), ef, 'exec'), templates)
|
||||||
for name, template in templates.iteritems():
|
for name, template in templates.iteritems():
|
||||||
if name.startswith('by_') and name.endswith('_template'):
|
if name.startswith('by_') and name.endswith('_template'):
|
||||||
setattr(self, name, force_unicode(template, 'utf-8'))
|
setattr(self, name, force_unicode(template, 'utf-8'))
|
||||||
|
@ -214,7 +214,8 @@ def ipython(user_ns=None):
|
|||||||
c = Config()
|
c = Config()
|
||||||
user_conf = os.path.expanduser('~/.ipython/profile_default/ipython_config.py')
|
user_conf = os.path.expanduser('~/.ipython/profile_default/ipython_config.py')
|
||||||
if os.path.exists(user_conf):
|
if os.path.exists(user_conf):
|
||||||
execfile(user_conf, {'get_config': lambda: c})
|
with open(user_conf, 'rb') as f:
|
||||||
|
exec(compile(f.read(), user_conf, 'exec'), {'get_config': lambda: c})
|
||||||
c.TerminalInteractiveShell.prompts_class = CustomPrompt
|
c.TerminalInteractiveShell.prompts_class = CustomPrompt
|
||||||
c.InteractiveShellApp.exec_lines = [
|
c.InteractiveShellApp.exec_lines = [
|
||||||
'from __future__ import division, absolute_import, unicode_literals, print_function',
|
'from __future__ import division, absolute_import, unicode_literals, print_function',
|
||||||
|
@ -203,7 +203,8 @@ def compile_srv():
|
|||||||
base = base_dir()
|
base = base_dir()
|
||||||
iconf = os.path.join(base, 'imgsrc', 'srv', 'generate.py')
|
iconf = os.path.join(base, 'imgsrc', 'srv', 'generate.py')
|
||||||
g = {'__file__': iconf}
|
g = {'__file__': iconf}
|
||||||
execfile(iconf, g)
|
with open(iconf, 'rb') as f:
|
||||||
|
exec(compile(f.read(), iconf, 'exec'), g)
|
||||||
icons = g['merge']().encode('utf-8')
|
icons = g['merge']().encode('utf-8')
|
||||||
with lopen(os.path.join(base, 'resources', 'content-server', 'reset.css'), 'rb') as f:
|
with lopen(os.path.join(base, 'resources', 'content-server', 'reset.css'), 'rb') as f:
|
||||||
reset = f.read()
|
reset = f.read()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user