Loading src/climax/__init__.py +1 −1 Original line number Diff line number Diff line __version__ = "0.2.6" __version__ = "0.2.8" src/climax/__main__.py +23 −12 Original line number Diff line number Diff line Loading @@ -263,36 +263,44 @@ app = typer.Typer(help=_(CLI_MAIN_HELP)) def _sync_bundles(root_directory: Path): ignore_file = ".ignore" dot_max_dir = Path(root_directory, ".max") bundles_dir = Path(dot_max_dir, "basex", "webapp", "max", "bundles") official_bundles_dir = Path(dot_max_dir, "basex", "webapp", "max", "bundles") # first deactivate everything for item in os.listdir(bundles_dir): if os.path.isdir(Path(bundles_dir, item)): Path(bundles_dir, item, ignore_file).touch() for item in os.listdir(official_bundles_dir): if os.path.isdir(Path(official_bundles_dir, item)): Path(official_bundles_dir, item, ignore_file).touch() config = MaXProjectConfig(Path(root_directory, "config.xml")) vocabulary_bundle = config.vocabulary_bundle # then activate or install what is in config file for bundle_name, bundle in config.bundles.items(): bundle_dir = Path(bundles_dir, bundle_name) bundle_dir = Path(official_bundles_dir, bundle_name) if os.path.isdir(bundle_dir): Path(bundle_dir, ignore_file).unlink(missing_ok=True) else: if str(bundle["url"]).startswith("http://") or str( bundle["url"] ).startswith("https://"): bundle_archive_path = Path(bundles_dir, f"{bundle_name}.zip") bundle_archive_path = Path(official_bundles_dir, f"{bundle_name}.zip") cached_download(bundle["url"], bundle_archive_path) shutil.unpack_archive(bundle_archive_path, bundles_dir) dir_name, _ = os.path.splitext(os.path.basename(bundle["url"])) Path(bundles_dir, dir_name).rename(bundle_dir) shutil.unpack_archive(bundle_archive_path, official_bundles_dir) dir_name, _ignore = os.path.splitext(os.path.basename(bundle["url"])) Path(official_bundles_dir, dir_name).rename(bundle_dir) bundle_archive_path.unlink() if str(bundle["url"]).startswith("local://"): zip_name = str(bundle["url"])[len("local://") :] bundle_archive_path = Path( dot_max_dir, "resources", "local_bundles", f"{zip_name}" ) shutil.unpack_archive(bundle_archive_path, bundles_dir) dir_name, _ = os.path.splitext(os.path.basename(bundle["url"])) Path(bundles_dir, dir_name).rename(bundle_dir) shutil.unpack_archive(bundle_archive_path, official_bundles_dir) dir_name, _ignore = os.path.splitext(os.path.basename(bundle["url"])) Path(official_bundles_dir, dir_name).rename(bundle_dir) bundle_archive_path.unlink() if ( Path(bundle_dir, "expath-pkg.xml").exists() and bundle_name != vocabulary_bundle ): # deactivate vocabulary bundles if they're not the vocabulary used in the projects print(_("Ce bundle de vocabulaire sera ignoré: "), bundle_name) Path(bundle_dir, ignore_file).touch() _ping_projects(root_directory) Loading Loading @@ -762,6 +770,9 @@ def bundles_add( "url": f"local://{os.path.basename(local_destination)}", } config.bundles = current_bundles_config # if bundle has expath-pkg.xml, it's a vocabulary bundle if Path(local_destination, "expath-pkg.xml").exists(): config.vocabulary_bundle = bundle_name config.write() _sync_max_instance(directory, verbose=False) bundles_list(directory) Loading Loading
src/climax/__init__.py +1 −1 Original line number Diff line number Diff line __version__ = "0.2.6" __version__ = "0.2.8"
src/climax/__main__.py +23 −12 Original line number Diff line number Diff line Loading @@ -263,36 +263,44 @@ app = typer.Typer(help=_(CLI_MAIN_HELP)) def _sync_bundles(root_directory: Path): ignore_file = ".ignore" dot_max_dir = Path(root_directory, ".max") bundles_dir = Path(dot_max_dir, "basex", "webapp", "max", "bundles") official_bundles_dir = Path(dot_max_dir, "basex", "webapp", "max", "bundles") # first deactivate everything for item in os.listdir(bundles_dir): if os.path.isdir(Path(bundles_dir, item)): Path(bundles_dir, item, ignore_file).touch() for item in os.listdir(official_bundles_dir): if os.path.isdir(Path(official_bundles_dir, item)): Path(official_bundles_dir, item, ignore_file).touch() config = MaXProjectConfig(Path(root_directory, "config.xml")) vocabulary_bundle = config.vocabulary_bundle # then activate or install what is in config file for bundle_name, bundle in config.bundles.items(): bundle_dir = Path(bundles_dir, bundle_name) bundle_dir = Path(official_bundles_dir, bundle_name) if os.path.isdir(bundle_dir): Path(bundle_dir, ignore_file).unlink(missing_ok=True) else: if str(bundle["url"]).startswith("http://") or str( bundle["url"] ).startswith("https://"): bundle_archive_path = Path(bundles_dir, f"{bundle_name}.zip") bundle_archive_path = Path(official_bundles_dir, f"{bundle_name}.zip") cached_download(bundle["url"], bundle_archive_path) shutil.unpack_archive(bundle_archive_path, bundles_dir) dir_name, _ = os.path.splitext(os.path.basename(bundle["url"])) Path(bundles_dir, dir_name).rename(bundle_dir) shutil.unpack_archive(bundle_archive_path, official_bundles_dir) dir_name, _ignore = os.path.splitext(os.path.basename(bundle["url"])) Path(official_bundles_dir, dir_name).rename(bundle_dir) bundle_archive_path.unlink() if str(bundle["url"]).startswith("local://"): zip_name = str(bundle["url"])[len("local://") :] bundle_archive_path = Path( dot_max_dir, "resources", "local_bundles", f"{zip_name}" ) shutil.unpack_archive(bundle_archive_path, bundles_dir) dir_name, _ = os.path.splitext(os.path.basename(bundle["url"])) Path(bundles_dir, dir_name).rename(bundle_dir) shutil.unpack_archive(bundle_archive_path, official_bundles_dir) dir_name, _ignore = os.path.splitext(os.path.basename(bundle["url"])) Path(official_bundles_dir, dir_name).rename(bundle_dir) bundle_archive_path.unlink() if ( Path(bundle_dir, "expath-pkg.xml").exists() and bundle_name != vocabulary_bundle ): # deactivate vocabulary bundles if they're not the vocabulary used in the projects print(_("Ce bundle de vocabulaire sera ignoré: "), bundle_name) Path(bundle_dir, ignore_file).touch() _ping_projects(root_directory) Loading Loading @@ -762,6 +770,9 @@ def bundles_add( "url": f"local://{os.path.basename(local_destination)}", } config.bundles = current_bundles_config # if bundle has expath-pkg.xml, it's a vocabulary bundle if Path(local_destination, "expath-pkg.xml").exists(): config.vocabulary_bundle = bundle_name config.write() _sync_max_instance(directory, verbose=False) bundles_list(directory) Loading