Coverage for gitman/models/config.py : 44%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
"""Wrappers for the dependency configuration files."""
"""A dictionary of dependency configuration options."""
filename="gitman.yml", location="gitman_sources"):
def config_path(self): """Get the full path to the configuration file."""
def log_path(self): """Get the full path to the log file."""
def location_path(self): """Get the full path to the dependency storage location."""
"""Get the full path to a dependency or internal file.""" else:
update=True, recurse=False, force=False, fetch=False, clean=True): """Download or update the specified dependencies."""
shell.mkdir(self.location_path)
if source.name in sources_filter: sources_filter.remove(source.name) else: log.info("Skipped dependency: %s", source.name) continue
source.update_files(force=force, fetch=fetch, clean=clean) source.create_link(self.root, force=force) common.newline() count += 1
config = load_config() if config: common.indent() count += config.install_dependencies( depth=None if depth is None else max(0, depth - 1), update=update and recurse, recurse=recurse, force=force, fetch=fetch, clean=clean, ) common.dedent()
shell.cd(self.location_path, _show=False)
return count
"""Run scripts for the specified dependencies.""" if depth == 0: log.info("Skipped directory: %s", self.location_path) return 0
sources = self._get_sources() sources_filter = list(names) if names else [s.name for s in sources]
shell.cd(self.location_path) common.newline() common.indent()
count = 0 for source in sources: if source.name in sources_filter: source.run_scripts(force=force) count += 1
config = load_config() if config: common.indent() count += config.run_scripts( depth=None if depth is None else max(0, depth - 1), force=force, ) common.dedent()
shell.cd(self.location_path, _show=False)
common.dedent()
return count
"""Lock down the immediate dependency versions.""" sources = self._get_sources(use_locked=obey_existing).copy() sources_filter = list(names) if names else [s.name for s in sources]
shell.cd(self.location_path) common.newline() common.indent()
count = 0 for source in sources: if source.name not in sources_filter: log.info("Skipped dependency: %s", source.name) continue
try: index = self.sources_locked.index(source) except ValueError: self.sources_locked.append(source.lock()) else: self.sources_locked[index] = source.lock() count += 1
shell.cd(self.location_path, _show=False)
if count: self.save()
return count
"""Delete the dependency storage location.""" shell.cd(self.root) shell.rm(self.location_path) common.newline()
"""Yield the path, repository URL, and hash of each dependency.""" if not os.path.exists(self.location_path): return
shell.cd(self.location_path) common.newline() common.indent()
for source in self.sources:
if depth == 0: log.info("Skipped dependency: %s", source.name) continue
yield source.identify(allow_dirty=allow_dirty)
config = load_config() if config: common.indent() yield from config.get_dependencies( depth=None if depth is None else max(0, depth - 1), allow_dirty=allow_dirty, ) common.dedent()
shell.cd(self.location_path, _show=False)
common.dedent()
"""Append a message to the log file.""" with open(self.log_path, 'a') as outfile: outfile.write(message.format(*args) + '\n')
"""Merge source lists using the requested section as the base.""" if self.sources_locked: return self.sources_locked else: log.info("No locked sources, defaulting to none...") return []
else: if self.sources_locked: log.info("Defaulting to locked sources...") sources = self.sources_locked else: log.info("No locked sources, using latest...") sources = self.sources
if source not in sources: log.info("Source %r missing from selected section", source.name) extras.append(source)
"""Load the configuration for the current project."""
|