How to use the peru.compat function in peru

To help you get started, we’ve selected a few peru examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buildinspace / peru / tests / test_sync.py View on Github external
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'})
github buildinspace / peru / tests / test_compat.py View on Github external
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)
github buildinspace / peru / tests / test_compat.py View on Github external
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)
github buildinspace / peru / peru / imports.py View on Github external
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)
github buildinspace / peru / peru / runtime.py View on Github external
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)
github buildinspace / peru / peru / local_module.py View on Github external
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)
github buildinspace / peru / peru / main.py View on Github external
def get_version():
    version_file = os.path.join(compat.MODULE_ROOT, 'VERSION')
    with open(version_file) as f:
        return f.read().strip()