Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_sync_from_subdir(self):
module_dir = shared.create_dir({'foo': 'bar'})
self.write_yaml(
'''\
# Use a relative module path, to make sure it gets resolved
# relative to the project root and not the dir where peru was
# called.
cp module relative_foo:
path: {}
imports:
relative_foo: subdir
''', os.path.relpath(module_dir, start=self.test_dir))
subdir = os.path.join(self.test_dir, 'a', 'b')
peru.compat.makedirs(subdir)
run_peru_command(['sync'], subdir)
self.assertTrue(
os.path.isdir(os.path.join(self.test_dir, '.peru')),
msg=".peru dir didn't end up in the right place")
assert_contents(os.path.join(self.test_dir, 'subdir'), {'foo': 'bar'})
def test_makedirs(self):
tmp_dir = shared.tmp_dir()
foo_dir = os.path.join(tmp_dir, "foo")
compat.makedirs(foo_dir)
os.chmod(foo_dir, 0o700)
# Creating the dir again should be a no-op even though the permissions
# have changed.
compat.makedirs(foo_dir)
def test_makedirs(self):
tmp_dir = shared.tmp_dir()
foo_dir = os.path.join(tmp_dir, "foo")
compat.makedirs(foo_dir)
os.chmod(foo_dir, 0o700)
# Creating the dir again should be a no-op even though the permissions
# have changed.
compat.makedirs(foo_dir)
def _set_last_imports(runtime, tree):
if tree == _get_last_imports(runtime):
# Don't modify the lastimports file if the imports haven't changed.
# This lets you use it as a build stamp for Make.
return
compat.makedirs(_last_imports_path(runtime).parent)
with _last_imports_path(runtime).open('w') as f:
f.write(tree)
def __init__(self, args, env):
"Don't instantiate this class directly. Use the Runtime() constructor."
self._set_paths(args, env)
compat.makedirs(self.state_dir)
self._tmp_root = os.path.join(self.state_dir, 'tmp')
compat.makedirs(self._tmp_root)
self.overrides = KeyVal(
os.path.join(self.state_dir, 'overrides'), self._tmp_root)
self._used_overrides = set()
self.force = args.get('--force', False)
if args['--quiet'] and args['--verbose']:
raise PrintableError(
"Peru can't be quiet and verbose at the same time.")
self.quiet = args['--quiet']
self.verbose = args['--verbose']
self.no_overrides = args.get('--no-overrides', False)
self.no_cache = args.get('--no-cache', False)
def _set_last_imports(self, tree):
compat.makedirs(os.path.dirname(self._last_imports_path()))
with open(self._last_imports_path(), 'w') as f:
f.write(tree)
def get_version():
version_file = os.path.join(compat.MODULE_ROOT, 'VERSION')
with open(version_file) as f:
return f.read().strip()