Example #1
0
 def _remove_something_from_globs(self, dir_path, globs, thing, target_name=None):
     removed_things = []
     for file_name, abs_file_path, symlink_path in self._iter_globs(globs, dir_path):
         try:
             os.unlink(symlink_path)
         except OSError:
             tail = " of target '{}'".format(target_name) if target_name is not None else ""
             logging.debug("{}' is not a {}{}.".format(file_name, thing, tail))
             continue
         removed_things.append(file_name)
     log_summary(removed_things, thing, added=False, target_name=target_name)
Example #2
0
    def dependencies_remove(self, dependencies):
        removed_deps = []
        for raw_dep in dependencies:
            symlink_path = join(self.dirs.dependencies, raw_dep)
            try:
                os.unlink(symlink_path)
            except OSError:
                logging.warning("Target '{}' is not a dependency of target '{}'.".format(raw_dep, self.name))
                continue
            removed_deps.append(raw_dep)

        log_summary(removed_deps, "dependency", added=False, target_name=self.name, plural="dependencies")
        self.dependencies = None
Example #3
0
 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
Example #4
0
 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)