diff options
author | SoniEx2 <endermoneymod@gmail.com> | 2020-04-30 19:51:21 -0300 |
---|---|---|
committer | SoniEx2 <endermoneymod@gmail.com> | 2020-05-01 00:03:06 -0300 |
commit | f216c88680a880db75ab24d9ce8fa35f327ac697 (patch) | |
tree | 5074fab69f7b17945cb4689659f396c2f9ec0701 /ganarchy | |
parent | 78aa9079158cbbf3c01facb4a3f1a76358b4258a (diff) |
Restore merge-configs functionality
For backwards compatibility. However, this is deprecated, and shouldn't be used on new deployments. It'll be removed in the future. The new config system has built-in support for external repo lists.
Diffstat (limited to 'ganarchy')
-rw-r--r-- | ganarchy/__init__.py | 22 | ||||
-rw-r--r-- | ganarchy/__main__.py | 1 | ||||
-rw-r--r-- | ganarchy/cli/merge_configs.py | 25 |
3 files changed, 26 insertions, 22 deletions
diff --git a/ganarchy/__init__.py b/ganarchy/__init__.py index c9ff942..c7bc025 100644 --- a/ganarchy/__init__.py +++ b/ganarchy/__init__.py @@ -33,7 +33,6 @@ from collections import defaultdict from urllib.parse import urlparse import ganarchy as m_ganarchy -from ganarchy import data as m_data MIGRATIONS = { "toml-config": ( @@ -439,27 +438,6 @@ class GAnarchy: self.projects = None @ganarchy.command() -@click.option('--skip-errors/--no-skip-errors', default=False) -@click.argument('files', type=click.File('r', encoding='utf-8'), nargs=-1) -def merge_configs(skip_errors, files): - """Merges config files.""" - config = None - for f in files: - try: - f.reconfigure(newline='') - config = Config(f, config, remove=False) - except (UnicodeDecodeError, qtoml.decoder.TOMLDecodeError): - if not skip_errors: - raise - if config: - env = get_env() - template = env.get_template('index.toml') - click.echo(template.render(config=config)) - -def update_remote_configs(): - pass - -@ganarchy.command() @click.argument('out', required=True) def run(out): """Runs ganarchy standalone. diff --git a/ganarchy/__main__.py b/ganarchy/__main__.py index ca17cb7..c7795ed 100644 --- a/ganarchy/__main__.py +++ b/ganarchy/__main__.py @@ -22,5 +22,6 @@ import ganarchy # Additional CLI commands import ganarchy.cli.debug +import ganarchy.cli.merge_configs ganarchy.cli.main(prog_name='ganarchy') diff --git a/ganarchy/cli/merge_configs.py b/ganarchy/cli/merge_configs.py new file mode 100644 index 0000000..d8e12e6 --- /dev/null +++ b/ganarchy/cli/merge_configs.py @@ -0,0 +1,25 @@ +import pathlib + +import click + +import ganarchy +import ganarchy.cli +import ganarchy.data + +@ganarchy.cli.main.command() +@click.option('--skip-errors/--no-skip-errors', default=False) +@click.argument('files', type=click.Path(exists=True, dir_okay=False, resolve_path=True), nargs=-1) +def merge_configs(skip_errors, files): + """Merges config files.""" + configs = [ganarchy.data.LocalDataSource(filename) for filename in files] + rlm = ganarchy.data.RepoListManager(ganarchy.data.ObjectDataSource({})) + rlm.sources += configs + res = [] + for src in rlm.sources: + res.append(src.update()) + effective = ganarchy.data.EffectiveSource(rlm) + if any(x is None for x in res): + click.echo("# This is DEPRECATED and will be REMOVED at some point!") + for pctp in effective.get_property_values(ganarchy.data.DataProperty.VCS_REPOS): + if pctp.active: + click.echo(f"""projects."{ganarchy.tomlescape(pctp.project_commit)}"."{ganarchy.tomlescape(pctp.uri)}"."{ganarchy.tomlescape(pctp.branch)}" = {{ active=true }}""") |