From 9c241d084ed9feb17d34be75af4a065af999ed60 Mon Sep 17 00:00:00 2001 From: Remi PLANEL <rplanel@pasteur.fr> Date: Wed, 13 Dec 2023 14:08:17 +0100 Subject: [PATCH] add a command to organize structure files --- .../df-wiki-cli/df_wiki_cli/content/main.py | 39 +++++++++++++++++++ packages/df-wiki-cli/pyproject.toml | 2 +- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/packages/df-wiki-cli/df_wiki_cli/content/main.py b/packages/df-wiki-cli/df_wiki_cli/content/main.py index 015ec277..d01337bc 100644 --- a/packages/df-wiki-cli/df_wiki_cli/content/main.py +++ b/packages/df-wiki-cli/df_wiki_cli/content/main.py @@ -1,5 +1,7 @@ import typer import sys +import re +import shutil from typing_extensions import Annotated from typing import Optional, List from pathlib import Path @@ -72,3 +74,40 @@ def lint( sys.exit(1) else: console.print("[green] Everything is alright") + + +@app.command() +def structure( + dir: Annotated[ + Path, + typer.Option( + exists=True, + file_okay=False, + dir_okay=True, + writable=False, + readable=True, + resolve_path=True, + ), + ], + output: Annotated[ + Path, + typer.Option( + exists=True, + file_okay=False, + dir_okay=True, + writable=True, + readable=True, + resolve_path=True, + ), + ], +): + console.rule(f"[bold blue]{dir.name}", style="blue") + for f in dir.iterdir(): + console.print(f"[green] {f.name}") + # get the system name + system = re.split("_|\.", f.name)[0].lower() + + console.print(system) + systemDir = output / system + systemDir.mkdir(parents=True, exist_ok=True) + shutil.copy2(f, systemDir) diff --git a/packages/df-wiki-cli/pyproject.toml b/packages/df-wiki-cli/pyproject.toml index 1ff1b2b8..320115fc 100644 --- a/packages/df-wiki-cli/pyproject.toml +++ b/packages/df-wiki-cli/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "df-wiki-cli" -version = "0.1.1" +version = "0.1.2" description = "" authors = ["Remi PLANEL <rplanel@pasteur.fr>"] readme = "README.md" -- GitLab