flexlate package

A composable, maintainable system for managing templates

Subpackages

Submodules

flexlate.add_mode module

class flexlate.add_mode.AddMode(value)[source]

Bases: str, enum.Enum

An enumeration.

LOCAL = 'local'
PROJECT = 'project'
USER = 'user'
flexlate.add_mode.get_expanded_out_root(out_root, project_root, render_relative_root_in_output, add_mode)[source]
Return type

Path

flexlate.adder module

class flexlate.adder.Adder[source]

Bases: object

add_template_source(repo, template, transaction, target_version=None, out_root=PosixPath('.'), merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates', add_mode=AddMode.LOCAL, remote='origin', config_manager=<flexlate.config_manager.ConfigManager object>)[source]
apply_template_and_add(repo, template, transaction, data=None, out_root=PosixPath('.'), add_mode=AddMode.LOCAL, merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates', no_input=False, remote='origin', config_manager=<flexlate.config_manager.ConfigManager object>, updater=<flexlate.update.main.Updater object>, renderer=<flexlate.render.multi.MultiRenderer object>)[source]
init_project_and_add_to_branches(repo, default_add_mode=AddMode.LOCAL, merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', user=False, remote='origin', config_manager=<flexlate.config_manager.ConfigManager object>)[source]
init_project_from_template_source_path(template, transaction, path=PosixPath('.'), target_version=None, data=None, default_folder_name='project', default_add_mode=AddMode.LOCAL, merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', remote='origin', no_input=False, config_manager=<flexlate.config_manager.ConfigManager object>, updater=<flexlate.update.main.Updater object>, renderer=<flexlate.render.multi.MultiRenderer object>, syncer=<flexlate.syncer.Syncer object>)[source]
Return type

str

flexlate.bootstrapper module

class flexlate.bootstrapper.Bootstrapper[source]

Bases: object

bootstrap_flexlate_init_from_existing_template(repo, template, transaction, target_version=None, data=None, default_add_mode=AddMode.LOCAL, merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates', remote='origin', no_input=False, adder=<flexlate.adder.Adder object>, config_manager=<flexlate.config_manager.ConfigManager object>, renderer=<flexlate.render.multi.MultiRenderer object>, updater=<flexlate.update.main.Updater object>, user_config_manager=<flexlate.user_config_manager.UserConfigManager object>)[source]

flexlate.branch_update module

flexlate.branch_update.abort_merge_and_reset_flexlate_branches(repo, current_branch, merged_branch_sha=None, template_branch_sha=None, merged_branch_name='flexlate-output', template_branch_name='flexlate-templates')[source]
flexlate.branch_update.get_flexlate_branch_name(repo, base_branch_name)[source]
Return type

str

flexlate.branch_update.get_flexlate_branch_name_for_feature_branch(feature_branch, base_branch_name)[source]
Return type

str

flexlate.branch_update.modify_files_via_branches_and_temp_repo(file_operation, repo, commit_message, out_root, merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates', remote='origin')[source]
flexlate.branch_update.prompt_to_fix_conflicts_and_reset_on_abort_return_aborted(repo, current_branch, merged_branch_sha, template_branch_sha, merged_branch_name, template_branch_name)[source]
Return type

bool

flexlate.branch_update.undo_transaction_in_flexlate_branches(repo, transaction, merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates')[source]

flexlate.checker module

class flexlate.checker.CheckResult(**data)[source]

Bases: pydantic.main.BaseModel

existing_version: str
property has_update: bool
Return type

bool

latest_version: str
source_name: str
class flexlate.checker.CheckResults(**data)[source]

Bases: pydantic.main.BaseModel

property has_updates: bool
Return type

bool

results: List[flexlate.checker.CheckResult]
property update_version_dict: Dict[str, str]
Return type

Dict[str, str]

property updates: List[flexlate.checker.CheckResult]
Return type

List[CheckResult]

class flexlate.checker.CheckResultsRenderable(**data)[source]

Bases: pydantic.main.BaseModel

results: List[flexlate.checker.CheckResult]
class flexlate.checker.Checker[source]

Bases: object

find_new_versions_for_template_sources(names=None, project_root=PosixPath('.'), config_manager=<flexlate.config_manager.ConfigManager object>, finder=<flexlate.finder.multi.MultiFinder object>)[source]
Return type

CheckResults

flexlate.cli module

flexlate.cli.add_source(path=typer.Argument, name=typer.Argument, version=typer.Option, template_root=typer.Option, add_mode=typer.Option, quiet=typer.Option)

Adds a new template source, so that files can be generated from it.

See the [user guide on adding new templates within an existing project]( https://nickderobertis.github.io/flexlate/tutorial/get-started/add-to-project.html ) for more details.

flexlate.cli.bootstrap(template_path=typer.Argument, path=typer.Argument, version=typer.Option, no_input=typer.Option, quiet=typer.Option, default_add_mode=typer.Option, remote=typer.Option, merged_branch_name=typer.Option, template_branch_name=typer.Option)

Sets up a Flexlate project from an existing project that was already generated by another tool such as Cookiecutter or Copier.

See the user guide on [adding Flexlate to a project already generated from a template]( https://nickderobertis.github.io/flexlate/tutorial/get-started/existing-project.html ) for more information.

flexlate.cli.check(names=typer.Argument, path=typer.Option, quiet=typer.Option)

Checks whether there are any updates available for the current template sources

Displays a tabular output of the templates that need to be updated. It will also exist with code 1 when updates are available so that it is easy to use in scripting.

See the user guide on [updating templates]( https://nickderobertis.github.io/flexlate/tutorial/updating.html ), especially [the section about checking for updates]( https://nickderobertis.github.io/flexlate/tutorial/updating.html#checking-for-updates ), for more information.

flexlate.cli.generate_applied_template(name=typer.Argument, template_root=typer.Argument, add_mode=typer.Option, no_input=typer.Option, quiet=typer.Option)

Applies a template to a given location, and stores it in config so it can be updated

See the [user guide on adding new templates within an existing project]( https://nickderobertis.github.io/flexlate/tutorial/get-started/add-to-project.html ) for more details.

flexlate.cli.init_project(path=typer.Argument, default_add_mode=typer.Option, merged_branch_name=typer.Option, template_branch_name=typer.Option, user=typer.Option, remote=typer.Option, quiet=typer.Option)

Initializes a flexlate project. This must be run before other commands

See the user guide on [adding templates within an existing project]( https://nickderobertis.github.io/flexlate/tutorial/get-started/add-to-project.html ) for more details.

flexlate.cli.init_project_from(template_path=typer.Argument, path=typer.Argument, version=typer.Option, folder_name=typer.Option, no_input=typer.Option, quiet=typer.Option, default_add_mode=typer.Option, remote=typer.Option, merged_branch_name=typer.Option, template_branch_name=typer.Option)

Generates a project from a template and sets it up as a Flexlate project.

Note that this will also create a new folder and initialize a git repository in it before adding the Flexlate output.

See the user guide on [creating a new project with Flexlate]( https://nickderobertis.github.io/flexlate/tutorial/get-started/new-project.html ) for more information.

flexlate.cli.merge(branch_name=typer.Argument, delete=typer.Option, path=typer.Option, quiet=typer.Option)

Merges feature flexlate branches into the main flexlate branches

Feature flexlate branches should be merged into main flexlate branches when the corresponding feature branch is merged into the repo’s main branch. This command provides a convenient way to do so.

See the user guide on [saving Flexlate updates]( https://nickderobertis.github.io/flexlate/tutorial/saving.html ), especially [the section about locally merging branches]( https://nickderobertis.github.io/flexlate/tutorial/saving.html#locally-merging-branches ), for more information.

flexlate.cli.pre_execute(version=typer.Option)
flexlate.cli.push_feature(feature_branch=typer.Argument, remote=typer.Option, path=typer.Option, quiet=typer.Option)

Pushes feature Flexlate branches to remote

See the user guide on [saving Flexlate updates]( https://nickderobertis.github.io/flexlate/tutorial/saving.html ), especially [the section about pushing changes with a PR workflow]( https://nickderobertis.github.io/flexlate/tutorial/saving.html#push-your-flexlate-feature-branch-changes ), for more information.

flexlate.cli.push_main(remote=typer.Option, path=typer.Option, quiet=typer.Option)

Pushes main Flexlate branches to remote

See the user guide on [saving Flexlate updates]( https://nickderobertis.github.io/flexlate/tutorial/saving.html ), especially [the section about pushing with a local workflow]( https://nickderobertis.github.io/flexlate/tutorial/saving.html#push-your-flexlate-main-branch-changes ), for more information.

flexlate.cli.remove_template_output(template_name=typer.Argument, template_root=typer.Argument, quiet=typer.Option)

Removes an applied template output

flexlate.cli.remove_template_source(template_name=typer.Argument, template_root=typer.Option, quiet=typer.Option)

Removes a template source, so that files can no longer be generated from it.

flexlate.cli.sync(path=typer.Argument, prompt=typer.Option, quiet=typer.Option)

Syncs manual changes to the flexlate branches, and updates templates accordingly.

This is useful if you want to move or modify flexlate configs after they are created, but there is no command in the CLI for it.

Note: Be sure to commit your changes before running sync

See the user guide on [making arbitrary changes]( https://nickderobertis.github.io/flexlate/tutorial/arbitrary-changes.html ) for more information.

flexlate.cli.undo(num_operations=typer.Argument, path=typer.Option, quiet=typer.Option)

Undoes the last flexlate operation, like ctrl/cmd + z for flexlate. Note that this modifies the git history, discarding the last commits. It has protections against deleting user commits but you should only use this on a feature branch.

See the user guide on [undoing Flexlate operations]( https://nickderobertis.github.io/flexlate/tutorial/undoing.html ) for more information.

flexlate.cli.update_template_source_target_version(name=typer.Argument, version=typer.Argument, path=typer.Option, add_mode=typer.Option, quiet=typer.Option)

Updates a target version for a template source.

If no version is passed, it will remove the targeting so it will always update.

See the user guide on [updating templates]( https://nickderobertis.github.io/flexlate/tutorial/updating.html ), especially [the section about changing target version]( https://nickderobertis.github.io/flexlate/tutorial/updating.html#change-target-version ), for more information.

flexlate.cli.update_templates(names=typer.Argument, no_input=typer.Option, abort_on_conflict=typer.Option, no_cleanup=typer.Option, quiet=typer.Option, path=typer.Option)

Updates applied templates in the project to the newest versions available that still satisfy source target versions

See the user guide on [updating templates]( https://nickderobertis.github.io/flexlate/tutorial/updating.html ) for more information.

flexlate.cli_utils module

flexlate.cli_utils.confirm_user(prompt)[source]
Return type

bool

flexlate.config module

class flexlate.config.AppliedTemplateConfig(*, name: str, data: Dict[str, Any], version: str, add_mode: flexlate.add_mode.AddMode, root: pathlib.Path = PosixPath('.'))[source]

Bases: pydantic.main.BaseModel

__init__(**kwargs)[source]

Create a new model by parsing and validating input data from keyword arguments.

Raises ValidationError if the input data cannot be parsed to form a valid model.

add_mode: flexlate.add_mode.AddMode
data: Dict[str, Any]
name: str
root: pathlib.Path
version: str
class flexlate.config.AppliedTemplateWithSource(**data)[source]

Bases: pydantic.main.BaseModel

applied_template: flexlate.config.AppliedTemplateConfig
applied_template_config_path: pathlib.Path
index: int
source: flexlate.config.TemplateSource
source_config_path: pathlib.Path
to_template_and_data()[source]
Return type

Tuple[Template, Dict[str, Any]]

class flexlate.config.FlexlateConfig(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, **values)[source]

Bases: pyappconf.model.BaseConfig

class Config[source]

Bases: object

extra = 'allow'
add_applied_template(applied_template, config_location)[source]
Return type

None

add_template_source(template_source, config_location)[source]
Return type

None

applied_templates: List[flexlate.config.AppliedTemplateConfig]
property child_configs: List[flexlate.config.FlexlateConfig]
Return type

List[FlexlateConfig]

property empty: bool
Return type

bool

classmethod from_dir_including_nested(root, adjust_applied_paths=True)[source]
Return type

FlexlateConfig

classmethod from_multiple(configs)[source]
Return type

FlexlateConfig

get_applied_template_by_update(update)[source]
Return type

AppliedTemplateConfig

get_num_applied_templates_in_child_config(child_config_path)[source]
classmethod load(path=None)[source]
Return type

FlexlateConfig

move_applied_template(template_name, config_path, new_config_path, render_relative_root_in_output, project_root=PosixPath('.'), out_root=PosixPath('.'), orig_project_root=PosixPath('.'))[source]
move_template_source(template_name, config_path, new_config_path)[source]
remove_applied_template(template_name, config_location, project_root=PosixPath('.'), out_root=PosixPath('.'), orig_project_root=PosixPath('.'))[source]
Return type

None

remove_template_source(template_name, config_location)[source]
Return type

None

save(serializer_kwargs=None, **kwargs)[source]
classmethod template_name_must_be_unique(v)[source]
template_sources: List[flexlate.config.TemplateSource]
property template_sources_dict: Dict[str, flexlate.config.TemplateSource]
Return type

Dict[str, TemplateSource]

update_applied_template(updater, config_location, index)[source]
Return type

None

update_template_source(updater, name)[source]
Return type

None

update_template_sources(updater, names=None)[source]
Return type

None

class flexlate.config.FlexlateProjectConfig(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, **values)[source]

Bases: pyappconf.model.BaseConfig

get_project_for_path(path=PosixPath('.'))[source]
Return type

ProjectConfig

projects: List[flexlate.config.ProjectConfig]
class flexlate.config.ProjectConfig(**data)[source]

Bases: pydantic.main.BaseModel

default_add_mode: flexlate.add_mode.AddMode
merged_branch_name: str
path: pathlib.Path
remote: str
template_branch_name: str
class flexlate.config.TemplateSource(**data)[source]

Bases: pydantic.main.BaseModel

property absolute_local_path: pathlib.Path
Return type

Path

classmethod from_template(template, target_version=None)[source]
Return type

TemplateSource

git_url: Optional[str]
property is_local_template: bool
Return type

bool

name: str
path: str
render_relative_root_in_output: pathlib.Path
render_relative_root_in_template: pathlib.Path
target_version: Optional[str]
to_template(version=None, finder=<flexlate.finder.multi.MultiFinder object>)[source]
Return type

Template

type: flexlate.template.types.TemplateType
property update_location: Union[str, pathlib.Path]
Return type

Union[str, Path]

version: Optional[str]
class flexlate.config.TemplateSourceWithTemplates(**data)[source]

Bases: pydantic.main.BaseModel

class Config[source]

Bases: object

arbitrary_types_allowed = True
source: flexlate.config.TemplateSource
templates: List[flexlate.template.base.Template]

flexlate.config_manager module

class flexlate.config_manager.ConfigManager[source]

Bases: object

add_applied_template(template, config_path, add_mode, data=None, project_root=PosixPath('.'), out_root=PosixPath('.'))[source]
add_project(path=PosixPath('.'), default_add_mode=AddMode.LOCAL, merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', user=False, remote='origin')[source]
add_template_source(template, config_path, target_version=None, project_root=PosixPath('.'))[source]
get_all_renderables(relative_to=None, project_root=PosixPath('.'), config=None)[source]
Return type

List[Renderable]

get_all_templates(relative_to=None, project_root=PosixPath('.'), config=None)[source]
Return type

List[Template]

get_applied_templates_with_sources(relative_to=None, project_root=PosixPath('.'), config=None)[source]
Return type

List[AppliedTemplateWithSource]

get_data_for_updates(updates, project_root=PosixPath('.'), config=None)[source]
Return type

List[Dict[str, Any]]

get_no_op_updates(project_root=PosixPath('.'), config=None)[source]
Return type

List[TemplateUpdate]

get_num_applied_templates_in_child_config(child_config_path, project_root=PosixPath('.'))[source]
get_renderables_for_updates(updates, project_root=PosixPath('.'), adjust_root=True)[source]
Return type

List[Renderable]

get_sources_with_templates(templates, project_root=PosixPath('.'), config=None)[source]
Return type

List[TemplateSourceWithTemplates]

get_template_by_name(name, project_root=PosixPath('.'), config=None)[source]
Return type

Template

get_template_sources(names=None, project_root=PosixPath('.'), config=None)[source]
Return type

List[TemplateSource]

load_config(project_root=PosixPath('.'), adjust_applied_paths=True)[source]
Return type

FlexlateConfig

load_project_config(path=PosixPath('.'))[source]
Return type

ProjectConfig

load_projects_config(path=PosixPath('.'))[source]
Return type

FlexlateProjectConfig

load_specific_projects_config(path=PosixPath('.'), user=False)[source]
move_applied_template(template_name, config_path, new_config_path, render_relative_root_in_output, project_root=PosixPath('.'), out_root=PosixPath('.'), orig_project_root=PosixPath('.'))[source]
move_local_applied_templates_if_necessary_produce_new_updates(updates, project_root=PosixPath('.'), orig_project_root=PosixPath('.'), renderer=<flexlate.render.multi.MultiRenderer object>)[source]
Return type

List[TemplateUpdate]

move_template_source(template_name, config_path, new_config_path, project_root=PosixPath('.'))[source]
remove_applied_template(template_name, config_path, project_root=PosixPath('.'), out_root=PosixPath('.'), orig_project_root=PosixPath('.'))[source]
Parameters
  • template_name (str) –

  • config_path (Path) –

  • project_root (Path) – The root of the current working project (may be a temp directory)

  • out_root (Path) –

  • orig_project_root (Path) – The root of the user’s project (always stays the same, even when working in a temp directory)

Returns

remove_template_source(template_name, config_path, project_root=PosixPath('.'))[source]
save_config(config)[source]
save_projects_config(config)[source]
template_source_exists(name, project_root=PosixPath('.'), config=None)[source]
Return type

bool

update_template_source_version(name, target_version=None, project_root=PosixPath('.'), config=None)[source]
update_template_sources(names, updater, project_root=PosixPath('.'), config=None)[source]
update_templates(updates, project_root=PosixPath('.'), use_template_source_path=True)[source]
flexlate.config_manager.determine_config_path_from_roots_and_add_mode(out_root=PosixPath('.'), project_root=PosixPath('.'), add_mode=AddMode.LOCAL)[source]
Return type

Path

flexlate.constants module

flexlate.error_handler module

flexlate.error_handler.simple_output_for_exceptions(*exceptions)[source]

flexlate.exc module

exception flexlate.exc.CannotFindAppliedTemplateException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.CannotFindClonedTemplateException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.CannotFindCorrectMergeParentException[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.CannotFindMergeForTransactionException[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.CannotFindTemplateSourceException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.CannotLoadConfigException[source]

Bases: flexlate.exc.FlexlateConfigException

exception flexlate.exc.CannotParseCommitMessageFlexlateTransaction[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.CannotRemoveAppliedTemplateException[source]

Bases: flexlate.exc.CannotRemoveConfigItemException

exception flexlate.exc.CannotRemoveConfigItemException[source]

Bases: flexlate.exc.FlexlateConfigException

exception flexlate.exc.CannotRemoveTemplateSourceException[source]

Bases: flexlate.exc.CannotRemoveConfigItemException

exception flexlate.exc.ExpectedMergeCommitException[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.FlexlateConfigException[source]

Bases: flexlate.exc.FlexlateException

exception flexlate.exc.FlexlateConfigFileNotExistsException[source]

Bases: flexlate.exc.CannotLoadConfigException

exception flexlate.exc.FlexlateException[source]

Bases: Exception

exception flexlate.exc.FlexlateGitException[source]

Bases: flexlate.exc.FlexlateException

exception flexlate.exc.FlexlateProjectConfigFileNotExistsException[source]

Bases: flexlate.exc.CannotLoadConfigException

exception flexlate.exc.FlexlateSyncException[source]

Bases: flexlate.exc.FlexlateException

exception flexlate.exc.FlexlateTemplateException[source]

Bases: flexlate.exc.FlexlateException

exception flexlate.exc.FlexlateTransactionException[source]

Bases: flexlate.exc.FlexlateException

exception flexlate.exc.FlexlateUpdateException[source]

Bases: flexlate.exc.FlexlateException

exception flexlate.exc.GitRepoDirtyException[source]

Bases: flexlate.exc.FlexlateGitException

exception flexlate.exc.GitRepoHasNoCommitsException[source]

Bases: flexlate.exc.FlexlateGitException

exception flexlate.exc.InvalidNumberOfTransactionsException[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.InvalidTemplateClassException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.InvalidTemplateDataException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.InvalidTemplatePathException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.InvalidTemplateTypeException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.LastCommitWasNotByFlexlateException[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.MergeCommitIsNotMergingAFlexlateTransactionException[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.MergeConflictsAndAbortException[source]

Bases: flexlate.exc.FlexlateUpdateException

exception flexlate.exc.RendererNotFoundException[source]

Bases: flexlate.exc.FlexlateException

exception flexlate.exc.TemplateLookupException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.TemplateNotRegisteredException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.TemplateSourceWithNameAlreadyExistsException[source]

Bases: flexlate.exc.FlexlateTemplateException

exception flexlate.exc.TooFewTransactionsException[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.TransactionMismatchBetweenBranchesException[source]

Bases: flexlate.exc.FlexlateTransactionException

exception flexlate.exc.TriedToCommitButNoChangesException[source]

Bases: flexlate.exc.FlexlateGitException

exception flexlate.exc.UnnecessarySyncException[source]

Bases: flexlate.exc.FlexlateSyncException

exception flexlate.exc.UserChangesWouldHaveBeenDeletedException[source]

Bases: flexlate.exc.FlexlateTransactionException

flexlate.ext_git module

flexlate.ext_git.abort_merge(repo)[source]
flexlate.ext_git.assert_repo_is_in_clean_state(repo)[source]
flexlate.ext_git.branch_exists(repo, branch_name)[source]
Return type

bool

flexlate.ext_git.checked_out_template_branch(repo, branch_name, base_branch_name)[source]
flexlate.ext_git.checkout_template_branch(repo, branch_name, base_branch_name)[source]
flexlate.ext_git.checkout_version(repo, version)[source]
flexlate.ext_git.clone_repo_at_version_get_repo_and_name(path, dst_folder, version=None)[source]
Return type

Tuple[Repo, str]

flexlate.ext_git.delete_all_tracked_files(repo)[source]
flexlate.ext_git.delete_local_branch(repo, branch_name)[source]
flexlate.ext_git.fast_forward_branch_without_checkout(repo, base_branch, ff_branch)[source]
flexlate.ext_git.get_branch_sha(repo, branch_name)[source]
Return type

Optional[str]

flexlate.ext_git.get_commits_between_two_commits(repo, start, end)[source]
Return type

List[Commit]

flexlate.ext_git.get_current_version(repo)[source]
Return type

str

flexlate.ext_git.get_merge_conflict_diffs(repo)[source]
Return type

str

flexlate.ext_git.get_repo_remote_name_from_repo(repo)[source]
Return type

str

flexlate.ext_git.list_tracked_files(repo)[source]
Return type

Set[Path]

flexlate.ext_git.merge_branch_into_current(repo, branch_name, allow_conflicts=True)[source]
flexlate.ext_git.push_to_remote(repo, branch_name, remote_name='origin')[source]
flexlate.ext_git.repo_has_merge_conflicts(repo)[source]
Return type

bool

flexlate.ext_git.reset_branch_to_commit_without_checkout(repo, branch_name, commit_sha=None)[source]
flexlate.ext_git.reset_current_branch_to_commit(repo, commit)[source]
flexlate.ext_git.restore_initial_commit_files(repo)[source]
flexlate.ext_git.stage_and_commit_all(repo, commit_message)[source]
flexlate.ext_git.temp_repo_that_pushes_to_branch(repo, branch_name, base_branch_name, delete_tracked_files=False, copy_current_configs=True, force_push=False, additional_branches=(), remote='origin')[source]
Return type

AbstractContextManager[Repo]

flexlate.ext_git.update_local_branches_from_remote_without_checkout(repo, branch_names, remote='origin')[source]

flexlate.get_version module

flexlate.get_version.get_flexlate_version()[source]
Return type

str

flexlate.logger module

class flexlate.logger.LogLevel(value)[source]

Bases: str, enum.Enum

An enumeration.

DEBUG = 'DEBUG'
INFO = 'INFO'
class flexlate.logger.LoggingConfig(_env_file='<object object>', _env_file_encoding=None, _env_nested_delimiter=None, _secrets_dir=None, **values)[source]

Bases: pydantic.env_settings.BaseSettings

class Config[source]

Bases: object

env_prefix = 'FLEXLATE_LOG_'
classmethod cast_log_level(v)[source]
level: flexlate.logger.LogLevel

flexlate.main module

class flexlate.main.Flexlate(quiet=False, adder=<flexlate.adder.Adder object>, bootstrapper=<flexlate.bootstrapper.Bootstrapper object>, checker=<flexlate.checker.Checker object>, remover=<flexlate.remover.Remover object>, config_manager=<flexlate.config_manager.ConfigManager object>, merger=<flexlate.merger.Merger object>, finder=<flexlate.finder.multi.MultiFinder object>, pusher=<flexlate.pusher.Pusher object>, renderer=<flexlate.render.multi.MultiRenderer object>, syncer=<flexlate.syncer.Syncer object>, undoer=<flexlate.transactions.undoer.Undoer object>, updater=<flexlate.update.main.Updater object>, user_config_manager=<flexlate.user_config_manager.UserConfigManager object>)[source]

Bases: object

__init__(quiet=False, adder=<flexlate.adder.Adder object>, bootstrapper=<flexlate.bootstrapper.Bootstrapper object>, checker=<flexlate.checker.Checker object>, remover=<flexlate.remover.Remover object>, config_manager=<flexlate.config_manager.ConfigManager object>, merger=<flexlate.merger.Merger object>, finder=<flexlate.finder.multi.MultiFinder object>, pusher=<flexlate.pusher.Pusher object>, renderer=<flexlate.render.multi.MultiRenderer object>, syncer=<flexlate.syncer.Syncer object>, undoer=<flexlate.transactions.undoer.Undoer object>, updater=<flexlate.update.main.Updater object>, user_config_manager=<flexlate.user_config_manager.UserConfigManager object>)[source]
add_template_source(path, name=None, target_version=None, template_root=PosixPath('.'), add_mode=None)[source]
apply_template_and_add(name, data=None, out_root=PosixPath('.'), add_mode=None, no_input=False)[source]
bootstrap_flexlate_init_from_existing_template(template_path, path=PosixPath('.'), template_version=None, data=None, default_add_mode=AddMode.LOCAL, merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', remote='origin', no_input=False)[source]
check(names=None, project_path=PosixPath('.'))[source]
Return type

CheckResults

init_project(path=PosixPath('.'), default_add_mode=AddMode.LOCAL, merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', user=False, remote='origin')[source]
init_project_from(template_path, path=PosixPath('.'), template_version=None, data=None, default_folder_name='project', no_input=False, default_add_mode=AddMode.LOCAL, remote='origin', merged_branch_name='flexlate-output', template_branch_name='flexlate-templates')[source]
Return type

str

merge_flexlate_branches(branch_name=None, delete=True, project_path=PosixPath('.'))[source]
push_feature_flexlate_branches(feature_branch=None, remote='origin', project_path=PosixPath('.'))[source]
push_main_flexlate_branches(remote=None, project_path=PosixPath('.'))[source]
remove_applied_template_and_output(template_name, out_root=PosixPath('.'))[source]
remove_template_source(template_name, template_root=PosixPath('.'))[source]
sync(prompt=False, project_path=PosixPath('.'))[source]
undo(num_operations=1, project_path=PosixPath('.'))[source]
update(names=None, data=None, no_input=False, abort_on_conflict=False, no_cleanup=False, project_path=PosixPath('.'))[source]
update_template_source_target_version(name, target_version=None, add_mode=None, project_path=PosixPath('.'))[source]

flexlate.merger module

class flexlate.merger.Merger[source]

Bases: object

merge_flexlate_branches(repo, branch_name=None, delete=True, merged_branch_name='flexlate-output', template_branch_name='flexlate-templates')[source]

flexlate.path_ops module

flexlate.path_ops.change_directory_to(path)[source]
flexlate.path_ops.copy_flexlate_configs(src, dst, root)[source]
flexlate.path_ops.location_relative_to_new_parent(path, orig_parent, new_parent, path_is_relative_to=None)[source]
Return type

Path

flexlate.path_ops.make_absolute_path_from_possibly_relative_to_another_path(path, possibly_relative_to)[source]
Return type

Path

flexlate.path_ops.make_all_dirs(paths)[source]
flexlate.path_ops.make_func_that_creates_cwd_and_out_root_before_running(out_root, func)[source]

When switching branches, the CWD or target out_root may no longer exist. Pass a function to this function to create a function that creates those directories as needed before running the logic

flexlate.pusher module

class flexlate.pusher.Pusher[source]

Bases: object

push_feature_flexlate_branches(repo, feature_branch=None, remote='origin', merged_branch_name='flexlate-output', template_branch_name='flexlate-templates')[source]
push_main_flexlate_branches(repo, remote='origin', merged_branch_name='flexlate-output', template_branch_name='flexlate-templates')[source]

flexlate.remover module

class flexlate.remover.Remover[source]

Bases: object

remove_applied_template_and_output(repo, template_name, transaction, out_root=PosixPath('.'), add_mode=AddMode.LOCAL, merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates', remote='origin', config_manager=<flexlate.config_manager.ConfigManager object>, updater=<flexlate.update.main.Updater object>, renderer=<flexlate.render.multi.MultiRenderer object>)[source]
remove_template_source(repo, template_name, transaction, out_root=PosixPath('.'), merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates', add_mode=AddMode.LOCAL, remote='origin', config_manager=<flexlate.config_manager.ConfigManager object>)[source]

flexlate.styles module

flexlate.styles.print_styled(message, style)[source]
flexlate.styles.styled(message, style)[source]
Return type

str

flexlate.syncer module

class flexlate.syncer.Syncer[source]

Bases: object

sync_local_changes_to_flexlate_branches(repo, transaction, merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates', no_input=False, remote='origin', updater=<flexlate.update.main.Updater object>, renderer=<flexlate.render.multi.MultiRenderer object>, config_manager=<flexlate.config_manager.ConfigManager object>)[source]

flexlate.temp_path module

flexlate.temp_path.create_temp_path()[source]

Returns a temporary folder path

Use this instead of tempfile.TemporaryDirectory because: 1. That returns a string and not a path 2. On MacOS, the temp directory has a symlink. This resolves the symlink so that

there won’t be any mismatch in resolved paths.

  1. On Windows, the temp directory can fail to delete with a PermissionError. This function will try to delete the temp directory, but if it fails with an error it will just ignore it.

Return type

Iterator[Path]

flexlate.template_data module

flexlate.template_data.merge_data(overrides, defaults)[source]
Return type

List[Dict[str, Any]]

flexlate.template_path module

flexlate.template_path.get_local_repo_path_and_name_cloning_if_repo_url(path, version=None, dst_folder=None)[source]
Return type

Tuple[Path, str]

flexlate.template_path.is_local_template(path)[source]
Return type

bool

flexlate.template_path.is_repo_url(value)[source]

Return True if value is a repository URL.

flexlate.types module

flexlate.user_config_manager module

class flexlate.user_config_manager.UserConfigManager[source]

Bases: object

A higher-level version of the config manager that also works with flexlate branches

ConfigManager is the lower-level version that does not care about branches

update_template_source_target_version(name, target_version, repo, transaction, project_path=PosixPath('.'), add_mode=None, merged_branch_name='flexlate-output', base_merged_branch_name='flexlate-output', template_branch_name='flexlate-templates', base_template_branch_name='flexlate-templates', remote='origin', config_manager=<flexlate.config_manager.ConfigManager object>)[source]