pmfp.entrypoint.project.new
¶
Submodules¶
Package Contents¶
Classes¶
资源包类. |
|
获取本目录下项目的基本信息. |
Functions¶
|
由路径字符串获取绝对路径. |
|
Clear the readonly bit and reattempt the removal. |
|
获取缓存根目录. |
|
获取配置信息. |
|
构造不同执行环境. |
|
|
|
|
|
|
|
构造模板中匹配的kv. |
|
将目标组件模板转换到项目目录. |
|
检测资源包是否已经有缓存,没有就缓存. |
|
检查组件的模板库是否有缓存,没有的话进行缓存. |
|
校验组件所在模板库的信息,通过的话返回模板库信息 |
|
Attributes¶
-
pmfp.entrypoint.project.new.
get_abs_path
(path_str: str, cwd: Optional[pathlib.Path] = None) → pathlib.Path[源代码]¶ 由路径字符串获取绝对路径.
- 参数
path_str (str) – 路径字符创
cwd (Optional[Path]) – 指定执行时的位置
- 返回
路径字符串的绝对路径
- 返回类型
Path
-
pmfp.entrypoint.project.new.
remove_readonly
(func: Callable, path: str, _: Any) → None[源代码]¶ Clear the readonly bit and reattempt the removal.
-
class
pmfp.entrypoint.project.new.
SourcePack
(repo_name: str, *, repo_namespace: Optional[str] = None, tag: str = 'latest', host: Optional[str] = None)[源代码]¶ 资源包类.
-
TENPLATE_URL
= {host}::{repo_namespace}::{repo_name}@{tag}¶
-
classmethod
from_sourcepack_string
(cls, sourcepack_string: str) → SourcePack¶ 从资源包字符串构造资源包对象.
- 参数
sourcepack_string (str) – 用于描述资源包的字符串,其形式为`”[[{host}::]{repo_namespace}::]{repo_name}[@{tag}]”`
- 返回
资源包对象.
- 返回类型
-
as_sourcepack_string
(self) → str¶ 构造资源包字符串.
-
git_url
(self, schema: str = 'https') → str¶ 构造资源包的git仓库地址url.
- 参数
schema (str, optional) – url协议. Defaults to “https”.
- 返回
git的仓库地址字符串.
- 返回类型
str
-
pull_latest
(self, cache_dir: pathlib.Path, throw: bool = True) → None¶ 拉取最新镜像,并将原来的版本以hash为tag保存
- 参数
temp_dir (Path) – [description]
throw (bool) – 是否抛出异常
-
clone_source_pack
(self, cache_dir: pathlib.Path, throw: bool = False) → None¶ 克隆资源包到本地缓存临时文件夹.
如果资源包的tag不是latest则clone下来后删除.git文件夹,否则保存
- 参数
cache_dir (Path) – 缓存文件夹地址.
throw (bool) – 是否抛出异常
-
source_pack_path
(self, cache_dir: pathlib.Path) → pathlib.Path¶ 构造资源包的本地路径.
- 参数
cache_dir (Path) – 缓存文件夹路径.
- 返回
资源包所在的文件夹路径
- 返回类型
Path
-
cache
(self, cache_dir: pathlib.Path, throw_clone: bool = False, throw_pull: bool = False, not_pull: bool = False) → None¶ 缓存资源包到本地.
- 参数
cache_dir (Path) – 缓存文件夹地址.
throw (bool) – 是否抛出异常
-
-
pmfp.entrypoint.project.new.
new_env
(language: str, *, env: Optional[str] = None, project_name: Optional[str] = None, version: Optional[str] = None, author: Optional[str] = None, author_email: Optional[str] = None, description: Optional[str] = None, keywords: Optional[List[str]] = None, requires: Optional[List[str]] = None, test_requires: Optional[List[str]] = None, setup_requires: Optional[List[str]] = None, extras_requires: Optional[List[str]] = None, cwd: str = '.') → None[源代码]¶ 构造不同执行环境.
- 参数
language (str) – 目标项目使用的语言
env (str) – 目标执行环境
project_name (str) – 项目名
version (str) – 项目版本
author (str) – 项目作者
author_email (str, optional) – 项目作者email. Defaults to “”.
description (str, optional) – 项目简介. Defaults to “”.
keywords (Optional[List[str]], optional) – 项目关键字. Defaults to None.
cwd (str, optional) – 命令执行根目录. Defaults to “.”.
-
pmfp.entrypoint.project.new.
make_project_info_with_default
(cwdp: pathlib.Path, language: str, env: Optional[str] = None, project_name: Optional[str] = None, version: Optional[str] = None, author: Optional[str] = None, author_email: Optional[str] = None, description: Optional[str] = None) → Dict[str, str][源代码]¶
-
pmfp.entrypoint.project.new.
install_requires
(env: str, *, package_names: Optional[List[str]] = None, requirements: Optional[str] = None, test: bool = False, setup: bool = False, extras: Optional[str] = None, requires: Optional[List[str]] = None, test_requires: Optional[List[str]] = None, setup_requires: Optional[List[str]] = None, extras_requires: Optional[List[str]] = None, env_args: Optional[List[str]] = None, cwd: str = '.') → None[源代码]¶
-
class
pmfp.entrypoint.project.new.
InfoBase
(*, description: Optional[str] = None, epilog: Optional[str] = None, usage: Optional[str] = None, name: Optional[str] = None, schema: Optional[schema_entry.entrypoint_base.SchemaType] = None, verify_schema: Optional[bool] = None, default_config_file_paths: Optional[List[str]] = None, config_file_only_get_need: Optional[bool] = None, load_all_config_file: Optional[bool] = None, env_prefix: Optional[str] = None, parse_env: Optional[bool] = None, argparse_check_required: Optional[bool] = None, argparse_noflag: Optional[str] = None, config_file_parser_map: Optional[Dict[str, Callable[[pathlib.Path], Dict[str, Any]]]] = None, main: Optional[Callable[Ellipsis, None]] = None)[源代码]¶ Bases:
pmfp.utils.endpoint.EndPoint
获取本目录下项目的基本信息.
-
verify_schema
= False¶
-
load_all_config_file
= True¶
-
config_file_only_get_need
= False¶
-
do_main
(self) → None¶ 执行入口函数.
-
-
pmfp.entrypoint.project.new.
_add_component
(cached_sourcepacks: List[str], projectconfig: Dict[str, Any], pmfpconf: Dict[str, Any], cache_dir: pathlib.Path, component_string: str, cwdp: pathlib.Path, *, located_path: Optional[str] = None, save: bool = True, kv: Optional[List[str]] = None, root_default_path: Optional[str] = None, oldtemplate_kw: Optional[Dict[str, Any]] = None) → Tuple[pmfp.utils.remote_cache_utils.ComponentTemplate, Dict[str, Any]][源代码]¶
-
pmfp.entrypoint.project.new.
make_template_kv
(sourcepack_config: Dict[str, Any], projectconfig: Dict[str, Any], kv: Optional[List[str]] = None, oldtemplate_kw: Optional[Dict[str, Any]] = None) → Dict[str, str][源代码]¶ 构造模板中匹配的kv.
- 参数
kv (Optional[List[str]], optional) – 外部输入的kv对. Defaults to None.
- 返回
模板render时的输入
- 返回类型
Dict[str, str]
-
pmfp.entrypoint.project.new.
to_target_source
(projectconfig: Dict[str, Any], target_component_info: Dict[str, Any], cwdp: pathlib.Path, sourcepackdir: pathlib.Path, target_source: str, tempkv: Dict[str, Any], located_path: Optional[str] = None, root_default_path: Optional[str] = None) → str[源代码]¶ 将目标组件模板转换到项目目录.
-
pmfp.entrypoint.project.new.
sourcepack_check_and_cached
(cached_sourcepack: List[str], source_pack: pmfp.utils.remote_cache_utils.SourcePack, cache_dir: pathlib.Path) → pathlib.Path[源代码]¶ 检测资源包是否已经有缓存,没有就缓存.
- 参数
cached_sourcepack (List[str]) – 已经缓存过的资源包列表
source_pack (SourcePack) – 资源包对象
cache_dir (Path) – 缓存根目录
- 引发
AttributeError – 不是目录,请确认情况
- 返回
资源包的本地缓存路径
- 返回类型
Path
-
pmfp.entrypoint.project.new.
check_and_cached
(cached_sourcepack: List[str], template_string: str, cache_dir: pathlib.Path) → Tuple[pmfp.utils.remote_cache_utils.SourcePack, pathlib.Path][源代码]¶ 检查组件的模板库是否有缓存,没有的话进行缓存.
`latest`标签的模板库都会进行缓存更新.
- 参数
template_string (str) – 模板仓库字符串
cache_dir (Path) – 缓存根目录
- 引发
AttributeError – 组件缓存位置不是目录
e – 其他执行中的异常
- 返回
组件对象
- 返回类型
-
pmfp.entrypoint.project.new.
check_source
(pmfpconf: Dict[str, Any], sourcepackdir: pathlib.Path, template_string: str, env: Optional[str] = None, language: Optional[str] = None) → Dict[str, Any][源代码]¶ 校验组件所在模板库的信息,通过的话返回模板库信息
-
pmfp.entrypoint.project.new.
new_project
(env: Optional[str] = None, language: Optional[str] = None, project_name: Optional[str] = None, version: Optional[str] = None, author: Optional[str] = None, author_email: Optional[str] = None, description: Optional[str] = None, keywords: Optional[List[str]] = None, template_string: Optional[str] = None, with_test: bool = False, install: bool = False, kv: Optional[List[str]] = None, install_env_args: Optional[List[str]] = None, cwd: str = '.') → None[源代码]¶