def python(files, input_files, **kwargs): remove = [] add = [] for path, fi in iteritems(files): if path.ext == '.pyc': pyfile = path.parent / path.stem + '.py' if pyfile.is_file(): logging.info("Removing %s", path) remove.append(path) pyfile = path.parent / path.stem + '.py' if pyfile not in files: logging.info("Adding %s", pyfile) add.append(TracedFile(pyfile)) for path in remove: files.pop(path, None) for fi in add: files[fi.path] = fi for i in irange(len(input_files)): lst = [] for path in input_files[i]: if path.ext in ('.py', '.pyc'): logging.info("Removing input %s", path) else: lst.append(path) input_files[i] = lst
def combine_files(newfiles, newpackages, oldfiles, oldpackages): """Merges two sets of packages and files. """ files = set(oldfiles) files.update(newfiles) packages = dict((pkg.name, pkg) for pkg in newpackages) for oldpkg in oldpackages: if oldpkg.name in packages: pkg = packages[oldpkg.name] # Here we build TracedFiles from the Files so that the comment # (size, etc) gets set s = set(TracedFile(fi.path) for fi in oldpkg.files) s.update(pkg.files) oldpkg.files = list(s) packages[oldpkg.name] = oldpkg else: oldpkg.files = [TracedFile(fi.path) for fi in oldpkg.files] packages[oldpkg.name] = oldpkg packages = listvalues(packages) return files, packages
def python(files, input_files, **kwargs): add = [] for path, fi in files.items(): if path.ext == b'.pyc': pyfile = path.parent / path.stem + '.py' if pyfile.is_file(): if pyfile not in files: logger.info("Adding %s", pyfile) add.append(TracedFile(pyfile)) for fi in add: files[fi.path] = fi for i in range(len(input_files)): lst = [] for path in input_files[i]: if path.ext in (b'.py', b'.pyc'): logger.info("Removing input %s", path) else: lst.append(path) input_files[i] = lst