blueprintpy.core

blueprintpy コアパッケージ

モジュール

blueprintpy.core.argument

class blueprintpy.core.argument.Argument(name: str, description: str, argtype: Optional[str] = None, default_value: Optional[str] = None)

ベースクラス: object

パッケージテンプレート内で展開される引数.

パラメータ
  • name (str) -- 引数名

  • description (str) -- 引数の説明

  • argtype (Optional[str], optional) -- 引数タイプ

  • default_value (Optional[str], optional) -- デフォルト値

注釈

argtype パラメータは引数の型を示します. blueprintpy コアモジュールでは利用されませんが、CLIツールのデフォルト引数ハンドラでは対応する名称の レゾルバ (blueprintpy.cli.args_handler.resolver) を呼び出そうとします.

blueprintpy.core.config

class blueprintpy.core.config.Config(name: str, args: List[Argument], contents: List[Content], args_handler_name: Optional[str] = None)

ベースクラス: object

パッケージテンプレートの構成.

パラメータ
  • name (str) -- テンプレート名

  • args (List[Argument]) -- テンプレート引数リスト

  • contents (List[Content]) -- 展開されるファイルコンテンツのリスト

  • args_handler_name (Optional[str], optional) -- 引数ハンドラの名前

注釈

args_handler_name パラメータには、引数ハンドラ(blueprintpy.cli.args_handler)の 属性 __handler_name__ の値を指定してください. 指定がなかった場合は、blueprintpy.cliが自動でデフォルトのハンドラを呼び出します.

blueprintpy.core.content

class blueprintpy.core.content.Content(src: str, dest: str, use_template_engine: Optional[bool] = None)

ベースクラス: object

パッケージテンプレートに含まれるファイル.

パラメータ
  • src (str) -- オリジナル相対パス

  • dest (str) -- コピー先相対パス

  • use_template_engine (Optional[bool], optional) -- テンプレートエンジンを使用するか

注釈

use_template_engine にNoneが渡された場合, 拡張子が .j2 または .jinja2 のファイルではTrue、 それ以外のファイルではFalseがセットされます.

blueprintpy.core.content_builder

class blueprintpy.core.content_builder.ContentBuilder(template_root: Path, extract_root: Path, template_args: List[Argument], template_loader: Optional[BaseLoader] = None)

ベースクラス: object

Contentビルダ

パラメータ
  • template_root (Path) -- 読み込むテンプレートのルート

  • extract_root (Path) -- 展開先のルート

  • template_args (List[Argument]) -- テンプレート引数

  • template_loader (Optional[BaseLoader], optional) -- テンプレートローダー

注釈

template_root , extract_root は、インスタンス初期化時に絶対パスに変換されます.

build(content: Content) PreparedContent

引数に与えられたContentオブジェクトを読み込んで処理し、展開可能なContentオブジェクトを生成します.

パラメータ

content (Content) -- 変換元のContent

戻り値

処理結果

戻り値の型

PreparedContent

blueprintpy.core.content_extractor

class blueprintpy.core.content_extractor.ContentExtractor

ベースクラス: object

PreparedContentの展開

static extract(content: PreparedContent)

引数に渡されたPreparedContentを適切な場所に配置します.

パラメータ

content (PreparedContent) -- 配置するコンテンツ

例外

ValueError -- コンテンツのパスが不正であるか、コンテンツの指すオブジェクトが不正だった場合

注釈

コンテンツの各パスは絶対パスである必要があります.

また、content のパスは検証されません. 内容のバリデーションは引数ハンドリングプロセスで行うことを推奨します.

blueprintpy.core.prepared_content

class blueprintpy.core.prepared_content.PreparedContent(dest_path: Path, source: Optional[Path] = None, extract_object: Optional[bytes] = None)

ベースクラス: object

展開可能なContent

パラメータ
  • dest_path (Path) -- 展開先の絶対パス

  • source (Optional[Path], optional) -- 展開するファイルの絶対パス

  • extract_object (Optional[bytes], optional) -- 展開するオブジェクトのバイト列

例外

ValueError -- 展開するべきコンテンツが指定されなかった場合

注釈

source, extract_object のいずれかに有効な値が入力されている必要があります.