本文整理匯總了Python中distutils.dep_util.newer_pairwise方法的典型用法代碼示例。如果您正苦於以下問題:Python dep_util.newer_pairwise方法的具體用法?Python dep_util.newer_pairwise怎麽用?Python dep_util.newer_pairwise使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類distutils.dep_util
的用法示例。
在下文中一共展示了dep_util.newer_pairwise方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_newer_pairwise
# 需要導入模塊: from distutils import dep_util [as 別名]
# 或者: from distutils.dep_util import newer_pairwise [as 別名]
def test_newer_pairwise(self):
tmpdir = self.mkdtemp()
sources = os.path.join(tmpdir, 'sources')
targets = os.path.join(tmpdir, 'targets')
os.mkdir(sources)
os.mkdir(targets)
one = os.path.join(sources, 'one')
two = os.path.join(sources, 'two')
three = os.path.abspath(__file__) # I am the old file
four = os.path.join(targets, 'four')
self.write_file(one)
self.write_file(two)
self.write_file(four)
self.assertEqual(newer_pairwise([one, two], [three, four]),
([one],[three]))
示例2: _prep_compile
# 需要導入模塊: from distutils import dep_util [as 別名]
# 或者: from distutils.dep_util import newer_pairwise [as 別名]
def _prep_compile(self, sources, output_dir, depends=None):
"""Decide which souce files must be recompiled.
Determine the list of object files corresponding to 'sources',
and figure out which ones really need to be recompiled.
Return a list of all object files and a dictionary telling
which source files can be skipped.
"""
# Get the list of expected output (object) files
objects = self.object_filenames(sources, output_dir=output_dir)
assert len(objects) == len(sources)
if self.force:
skip_source = {} # rebuild everything
for source in sources:
skip_source[source] = 0
elif depends is None:
# If depends is None, figure out which source files we
# have to recompile according to a simplistic check. We
# just compare the source and object file, no deep
# dependency checking involving header files.
skip_source = {} # rebuild everything
for source in sources: # no wait, rebuild nothing
skip_source[source] = 1
n_sources, n_objects = newer_pairwise(sources, objects)
for source in n_sources: # no really, only rebuild what's
skip_source[source] = 0 # out-of-date
else:
# If depends is a list of files, then do a different
# simplistic check. Assume that each object depends on
# its source and all files in the depends list.
skip_source = {}
# L contains all the depends plus a spot at the end for a
# particular source file
L = depends[:] + [None]
for i in range(len(objects)):
source = sources[i]
L[-1] = source
if newer_group(L, objects[i]):
skip_source[source] = 0
else:
skip_source[source] = 1
return objects, skip_source
# _prep_compile ()