Skip to content

Commit

Permalink
Reworked some stuff in HUM: --github-envs parameter for example
Browse files Browse the repository at this point in the history
  • Loading branch information
PonteIneptique committed Sep 1, 2021
1 parent cbdbaa2 commit 521020d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
envs.txt
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
10 changes: 4 additions & 6 deletions TUTORIAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down
10 changes: 6 additions & 4 deletions humg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()

0 comments on commit 521020d

Please # to comment.