From 521020da78f6bbc5caa223c687363eba1f2e92ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thibault=20Cl=C3=A9rice?= Date: Wed, 1 Sep 2021 18:53:04 +0200 Subject: [PATCH] Reworked some stuff in HUM: --github-envs parameter for example --- .gitignore | 1 + TUTORIAL.md | 10 ++++------ humg.py | 10 ++++++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index 0fb7849..dd6d374 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +envs.txt # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] diff --git a/TUTORIAL.md b/TUTORIAL.md index f812f2c..d06635d 100644 --- a/TUTORIAL.md +++ b/TUTORIAL.md @@ -23,16 +23,14 @@ Tutorial: How to use HUM to get Badges 4. Set the name to GIST_SECRET 5. Paste the value from Step 2. -4. Edit your `.github/workflows/humGenerator.yaml` using HUM-Generator and add both a “ECHO-GITHUBWORKFLOW” environment value and a new line after humGenerator is run: `cat envs.txt >> $GITHUB_ENV` +4. Edit your Github Workflow using HUM-Generator + 1. Add the parameter `--github-envs` to your humGenerator line + 2. Add the line `cat envs.txt >> $GITHUB_ENV` after your `humGenerator` command: ```yaml - name: Run Report - # The two following lines are new - env: - ECHO-GITHUBWORKFLOW: "YES" - # Back to the "simple" configuration run: | - humGenerator --group fra/**/*.xml lat/**/*.xml + humGenerator --group fra/**/*.xml lat/**/*.xml --github-envs # This line is new : cat envs.txt >> $GITHUB_ENV ``` diff --git a/humg.py b/humg.py index 34e1a75..6af4102 100644 --- a/humg.py +++ b/humg.py @@ -144,7 +144,8 @@ def separator(): @click.option("-c", "--chars", default=False, is_flag=True, help="Show chars") @click.option("-g", "--group", default=False, is_flag=True, help="Group by directory for logs") @click.option("--parse", type=click.Choice(["alto", "page"]), default="alto") -def run(files, chars: bool = False, group: bool = False, parse: str = "alto"): +@click.option("--github-envs", default=False, is_flag=True) +def run(files, chars: bool = False, group: bool = False, parse: str = "alto", github_envs: bool = False): parser: Parser = None if parse == "alto": parser = Alto4Parser() @@ -199,15 +200,16 @@ def run(files, chars: bool = False, group: bool = False, parse: str = "alto"): show_title("Yaml Cataloging Details for HTR United") click.secho("""volume: - {count: """+str(sum(total_lines.values()))+""", metric: "lines"} + - {count: """+str(len(files))+""", metric: "files"} - {count: """+str(sum(total_regns.values()))+""", metric: "regions"} - {count: """+str(sum(total_chars.values()))+""", metric: "characters"}""", color=True, fg="blue") - if os.getenv("ECHO-GITHUBWORKFLOW"): + if github_envs: with open("envs.txt", "w") as f: f.write(f"HTRUNITED_LINES={str(sum(total_lines.values()))}\n") f.write(f"HTRUNITED_REGNS={str(sum(total_regns.values()))}\n") - f.write(f"HTRUNITED_CHARS={str(sum(total_chars.values()))}") - + f.write(f"HTRUNITED_CHARS={str(sum(total_chars.values()))}\n") + f.write(f"HTRUNITED_FILES={len(files)}\n") if __name__ == "__main__": run()