コード例 #1
0
    def add_config(name: str, config_item: ConfigItem) -> None:
        """Add a config item to the configuration class.

        Args:
            name (str): The name of the config item
            config_item (pdm.project.config.ConfigItem): The config item to add
        """
        Config.add_config(name, config_item)
コード例 #2
0
ファイル: core.py プロジェクト: danieleades/pdm
    def __init__(
        self,
        core: Core,
        root_path: str | Path | None,
        is_global: bool = False,
        global_config: str | Path | None = None,
    ) -> None:
        self._pyproject: dict | None = None
        self._lockfile: dict | None = None
        self._environment: Environment | None = None
        self._python: PythonInfo | None = None
        self.core = core

        if global_config is None:
            global_config = Path.home() / ".pdm/config.toml"
        self.global_config = Config(Path(global_config), is_global=True)
        global_project = Path(self.global_config["global_project.path"])

        if root_path is None:
            root_path = (
                find_project_root(max_depth=self.global_config["project_max_depth"])
                if not is_global
                else global_project
            )
        if (
            not is_global
            and root_path is None
            and self.global_config["global_project.fallback"]
        ):
            self.core.ui.echo(
                "Project is not found, fallback to the global project",
                fg="yellow",
                err=True,
            )
            root_path = global_project
            is_global = True

        self.root = Path(root_path or "").absolute()
        self.is_global = is_global
        self.init_global_project()
        self._lockfile_file = self.root / "pdm.lock"
コード例 #3
0
 def project_config(self) -> Config:
     """Read-and-writable configuration dict for project settings"""
     return Config(self.root / ".pdm.toml")
コード例 #4
0
 def global_config(self) -> Config:
     """Read-and-writable configuration dict for global settings"""
     return Config(Path.home() / ".pdm" / "config.toml", is_global=True)
コード例 #5
0
ファイル: core.py プロジェクト: uranusjr/pdm
 def add_config(name: str, config_item: ConfigItem) -> None:
     """Add a config item to the configuration class"""
     Config.add_config(name, config_item)
コード例 #6
0
 def global_config(self):
     return Config(self.root / ".pdm-home" / "config.toml", is_global=True)
コード例 #7
0
 def config(self) -> Config:
     if not self._config:
         self._config = Config(self.root)
     return self._config