mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
A spot of refactoring
This commit is contained in:
parent
37da6dc36a
commit
91e69ce7e3
2
setup.py
2
setup.py
@ -15,7 +15,7 @@ def check_version_info():
|
||||
raise SystemExit('calibre requires python >= 2.7.9 and < 3. Current python version: %s' % vi)
|
||||
check_version_info()
|
||||
|
||||
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
|
||||
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
import setup.commands as commands
|
||||
from setup import prints, get_warnings
|
||||
|
@ -27,6 +27,19 @@ __version__ = __appname__ = modules = functions = basenames = scripts = None
|
||||
|
||||
_cache_dir_built = False
|
||||
|
||||
def newer(targets, sources):
|
||||
if isinstance(targets, basestring):
|
||||
targets = [targets]
|
||||
if isinstance(sources, basestring):
|
||||
sources = [sources]
|
||||
for f in targets:
|
||||
if not os.path.exists(f):
|
||||
return True
|
||||
ttimes = map(lambda x: os.stat(x).st_mtime, targets)
|
||||
stimes = map(lambda x: os.stat(x).st_mtime, sources)
|
||||
newest_source, oldest_target = max(stimes), min(ttimes)
|
||||
return newest_source > oldest_target
|
||||
|
||||
def build_cache_dir():
|
||||
global _cache_dir_built
|
||||
ans = os.path.join(os.path.dirname(SRC), '.build-cache')
|
||||
@ -226,17 +239,7 @@ class Command(object):
|
||||
Return True if sources is newer that targets or if targets
|
||||
does not exist.
|
||||
'''
|
||||
if isinstance(targets, basestring):
|
||||
targets = [targets]
|
||||
if isinstance(sources, basestring):
|
||||
sources = [sources]
|
||||
for f in targets:
|
||||
if not os.path.exists(f):
|
||||
return True
|
||||
ttimes = map(lambda x: os.stat(x).st_mtime, targets)
|
||||
stimes = map(lambda x: os.stat(x).st_mtime, sources)
|
||||
newest_source, oldest_target = max(stimes), min(ttimes)
|
||||
return newest_source > oldest_target
|
||||
return newer(targets, sources)
|
||||
|
||||
def info(self, *args, **kwargs):
|
||||
prints(*args, **kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user