Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize excluded languages comparison #65

Merged
merged 2 commits into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ For more information on inaccuracies, see issue
`jstrieb/github-stats`) separated by commas to a new secret—created as
before—called `EXCLUDED`.
- To ignore certain languages, add them (separated by commas) to a new
secret called `EXCLUDED_LANGS`.
secret called `EXCLUDED_LANGS`. For example, to exclude HTML and TeX you
could set the value to `html,tex`.
- To show statistics only for "owned" repositories and not forks with
contributions, add an environment variable (under the `env` header in the
[main
Expand Down
4 changes: 3 additions & 1 deletion github_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ async def get_stats(self) -> None:
self._languages = dict()
self._repos = set()

exclude_langs_lower = {x.lower() for x in self._exclude_langs}

next_owned = None
next_contrib = None
while True:
Expand Down Expand Up @@ -348,7 +350,7 @@ async def get_stats(self) -> None:
for lang in repo.get("languages", {}).get("edges", []):
name = lang.get("node", {}).get("name", "Other")
languages = await self.languages
if name in self._exclude_langs:
if name.lower() in exclude_langs_lower:
continue
if name in languages:
languages[name]["size"] += lang.get("size", 0)
Expand Down