def dependencies_add(self, dependencies): added_deps = [] for raw_dep in dependencies: symlink_path = join(self.dirs.dependencies, raw_dep) if islink(symlink_path): logging.info("Target '{}' is already a dependency of target '{}'.".format(raw_dep, self.name)) continue from cbob.error import TargetDoesntExistError try: dep_target = get_target(raw_dep) except TargetDoesntExistError as e: logging.warning("Target '{}' is not really a target.".format(raw_dep)) continue make_rel_symlink(dep_target.path, symlink_path) added_deps.append(raw_dep) log_summary(added_deps, "dependency", added=True, target_name=self.name, plural="dependencies") self.dependencies = None
def _add_something_from_globs(self, dir_path, globs, thing, checks=None, target_name=None): added_things = [] for file_name, abs_file_path, symlink_path in self._iter_globs(globs, dir_path): if islink(symlink_path): tail = " of target '{}'".format(target_name) if target_name is not None else "" logging.debug("'{}' is already a {}{}.".format(file_name, thing, tail)) continue if commonprefix((abs_file_path, self.root_path)) != self.root_path: logging.warning("{} '{}' is not in a (sub)-direcory of the project.".format(thing.capitalize(), file_name)) continue if checks is not None: fail = False for check in checks: if not check(file_name, abs_file_path, symlink_path): fail = True break if fail: continue added_things.append(file_name) make_rel_symlink(abs_file_path, symlink_path) log_summary(added_things, thing, added=True, target_name=target_name)