コード例 #1
0
ファイル: packaging.py プロジェクト: DasIch/pwhash
    def run(self):
        InstallBase.run(self)

        for package in self.distribution.packages:
            package_dir = get_install_dir(self.install_lib, package)
            application_config_path = os.path.join(package_dir, "pwhash.json")
            deployment_config_path = os.path.join(package_dir, "pwhashc.json")
            if os.path.isfile(application_config_path):
                log.info(
                    u"Compiling %r to %r" % (application_config_path, deployment_config_path)
                )
                if not self.dry_run:
                    application_config = config.load(application_config_path)
                    config.dump(
                        deployment_config_path,
                        config.compile(application_config)
                    )
コード例 #2
0
ファイル: hashers.py プロジェクト: DasIch/pwhash
    def from_config_file(cls, filepath, relative_to_importable=None):
        """
        Like :meth:`from_config` but loads the config from a json file at
        `filepath` first.

        If `relative_to_importable` is given loads the config from a file
        relative to a directory that is either the directory of a package or
        the directory in which a module is contained, depending on whether the
        name passed as `relative_to_importable` refers to a package or module.
        """
        from pwhash import config
        if relative_to_importable is not None:
            importable_dir = get_root_path(relative_to_importable)
            if importable_dir is None:
                raise ValueError(
                    "cannot determine path for importable: %r" % relative_to_importable
                )
            filepath = os.path.join(importable_dir, filepath)
        return cls.from_config(config.load(filepath))