Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
:type revision: ``str``
"""
config.targets = files
files = list(files)
state = State(config)
# Resolve target paths when the cli has specified --path
if config.path != DEFAULT_PATH:
targets = [str(Path(config.path) / Path(file)) for file in files]
else:
targets = files
# Expand directories to paths
files = [
os.path.relpath(fn, config.path)
for fn in radon.cli.harvest.iter_filenames(targets)
]
logger.debug(f"Targeting - {files}")
if not revision:
target_revision = state.index[state.default_archiver].last_revision
else:
rev = resolve_archiver(state.default_archiver).cls(config).find(revision)
logger.debug(f"Resolved {revision} to {rev.key} ({rev.message})")
try:
target_revision = state.index[state.default_archiver][rev.key]
except KeyError:
logger.error(
f"Revision {revision} is not in the cache, make sure you have run wily build."
)
exit(1)
)
if path is None:
files = target_revision.get_paths(config, state.default_archiver, operator)
logger.debug(f"Analysing {files}")
else:
# Resolve target paths when the cli has specified --path
if config.path != DEFAULT_PATH:
targets = [str(Path(config.path) / Path(path))]
else:
targets = [path]
# Expand directories to paths
files = [
os.path.relpath(fn, config.path)
for fn in radon.cli.harvest.iter_filenames(targets)
]
logger.debug(f"Targeting - {files}")
for item in files:
for archiver in state.archivers:
try:
logger.debug(
f"Fetching metric {metric.name} for {operator} in {str(item)}"
)
val = target_revision.get(
config, archiver, operator, str(item), metric.name
)
value = val
data.append((item, value))
except KeyError:
logger.debug(f"Could not find file {item} in index")