Skip to content

Commit

Permalink
Reformat with black (#974)
Browse files Browse the repository at this point in the history
* Reformat with black

* Put black info and version in pyproject

* Run lint in CI

* Delete old experimental make_kit

* black the bin directory too
  • Loading branch information
simoncozens authored Jun 5, 2024
1 parent 572c40c commit c33db8b
Show file tree
Hide file tree
Showing 102 changed files with 5,021 additions and 4,082 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ jobs:
- name: Install packages
run: |
pip install '.[qa]'
pip install mypy pytest
pip install '.[test]'
- name: lint
run: |
black . --check --diff --color
- name: Run Tests
env:
DEV_FAMILY_DOWNLOAD: ${{ secrets.DEV_FAMILY_DOWNLOAD }}
Expand Down
5 changes: 4 additions & 1 deletion Lib/gftools/actions/checkgooglefonts.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
"""Test whether the font should be PRed to GF, inform GitHub if so.
"""

import yaml
import os
from sys import exit


if __name__ == "__main__":
config = yaml.load(open(os.path.join("sources", "config.yaml")), Loader=yaml.FullLoader)
config = yaml.load(
open(os.path.join("sources", "config.yaml")), Loader=yaml.FullLoader
)
if "googleFonts" in config and config["googleFonts"]:
print("This font should be submitted to Google Fonts")
print(f"::set-output name=is_gf::true")
Expand Down
5 changes: 4 additions & 1 deletion Lib/gftools/actions/checkversionbump.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
::set-output name=newtag::v1.001
"""

import yaml
import os
import re
Expand Down Expand Up @@ -64,7 +65,9 @@ def version_has_ever_changed(file, version):


if __name__ == "__main__":
config = yaml.load(open(os.path.join("sources", "config.yaml")), Loader=yaml.FullLoader)
config = yaml.load(
open(os.path.join("sources", "config.yaml")), Loader=yaml.FullLoader
)
sources = config["sources"]

current_version = None
Expand Down
22 changes: 15 additions & 7 deletions Lib/gftools/actions/getlatestversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,19 @@
from github import Github
import re


def get_latest_release(family, user=None, repo=None):
if not (user and repo):
repo_url = subprocess.check_output(["git", "remote", "get-url", "origin"]).decode("utf8").strip()
repo_url = (
subprocess.check_output(["git", "remote", "get-url", "origin"])
.decode("utf8")
.strip()
)
url_split = repo_url.split("/")
user, repo = url_split[3], url_split[4]

g = Github(os.environ["GITHUB_TOKEN"])
repo = g.get_repo(user + '/' + repo)
repo = g.get_repo(user + "/" + repo)
for release in repo.get_releases():
if release.draft:
continue
Expand All @@ -27,16 +32,19 @@ def get_latest_release(family, user=None, repo=None):
return version, download_url
return None, None


if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(description="Return the URL of a font's latest release artefact")
parser.add_argument('--user', help='the repository username', default="notofonts")
parser.add_argument('--repo', help='the repository name')
parser.add_argument('family', help='the font family name')

parser = argparse.ArgumentParser(
description="Return the URL of a font's latest release artefact"
)
parser.add_argument("--user", help="the repository username", default="notofonts")
parser.add_argument("--repo", help="the repository name")
parser.add_argument("family", help="the font family name")
args = parser.parse_args()

version, download_url = get_latest_release(args.family, args.user, args.repo)
if version and download_url:
print(f"::set-output name=version::{version}")
print(f"::set-output name=url::{download_url}")

25 changes: 18 additions & 7 deletions Lib/gftools/actions/qa2issue.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,28 @@
issue labelled qa-``version``. If not, it creates an issue with the text
provided, and labels it accordingly; if there is, it adds the text as a new comment.
"""

import argparse
import subprocess
from gftools.gfgithub import GitHubClient

if __name__ == "__main__":
url_split = subprocess.check_output(["git", "remote", "get-url", "origin"]).decode("utf8").strip().split("/")
url_split = (
subprocess.check_output(["git", "remote", "get-url", "origin"])
.decode("utf8")
.strip()
.split("/")
)
client = GitHubClient(url_split[3], url_split[4])

parser = argparse.ArgumentParser(description='Create or update github issue')
parser.add_argument('--template', help='the issue name',
default="Fontbakery QA Report for Version {}")
parser.add_argument('version', help='the proposed version')
parser.add_argument('file', help='file containing MarkDown content')
parser = argparse.ArgumentParser(description="Create or update github issue")
parser.add_argument(
"--template",
help="the issue name",
default="Fontbakery QA Report for Version {}",
)
parser.add_argument("version", help="the proposed version")
parser.add_argument("file", help="file containing MarkDown content")
args = parser.parse_args()

label = f"qa-{args.version}"
Expand All @@ -45,4 +54,6 @@
client._post(client.rest_url(f"issues/{number}/labels"), {"labels": [label]})
see_url = response["html_url"]

print(f"::error file=sources/config.yaml,title=Fontbakery check failed::See {see_url}")
print(
f"::error file=sources/config.yaml,title=Fontbakery check failed::See {see_url}"
)
51 changes: 29 additions & 22 deletions Lib/gftools/axes_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Lib/gftools/builder/dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
Credit to Cosimo Lupo (anthrotype) for starting this as a gist:
https://gist.github.com/anthrotype/531a425c8a0ba5ee975bc2ec8add7b82
"""

from collections import deque, defaultdict
import re
from typing import (
Expand Down
1 change: 0 additions & 1 deletion Lib/gftools/builder/recipeproviders/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def sources(self) -> List[File]:
return [get_file(str(p)) for p in self.config["sources"]]



def get_provider(provider: str):
# First try gftools.builder.recipeproviders.X
try:
Expand Down
66 changes: 33 additions & 33 deletions Lib/gftools/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,30 @@
NAMEID_DARK_BACKGROUD_PALETTE = 24

NAMEID_STR = {
NAMEID_COPYRIGHT_NOTICE: "COPYRIGHT_NOTICE",
NAMEID_FONT_FAMILY_NAME: "FONT_FAMILY_NAME",
NAMEID_FONT_SUBFAMILY_NAME: "FONT_SUBFAMILY_NAME",
NAMEID_UNIQUE_FONT_IDENTIFIER: "UNIQUE_FONT_IDENTIFIER",
NAMEID_FULL_FONT_NAME: "FULL_FONT_NAME",
NAMEID_VERSION_STRING: "VERSION_STRING",
NAMEID_POSTSCRIPT_NAME: "POSTSCRIPT_NAME",
NAMEID_TRADEMARK: "TRADEMARK",
NAMEID_MANUFACTURER_NAME: "MANUFACTURER_NAME",
NAMEID_DESIGNER: "DESIGNER",
NAMEID_DESCRIPTION: "DESCRIPTION",
NAMEID_VENDOR_URL: "VENDOR_URL",
NAMEID_DESIGNER_URL: "DESIGNER_URL",
NAMEID_LICENSE_DESCRIPTION: "LICENSE_DESCRIPTION",
NAMEID_LICENSE_INFO_URL: "LICENSE_INFO_URL",
NAMEID_TYPOGRAPHIC_FAMILY_NAME: "TYPOGRAPHIC_FAMILY_NAME",
NAMEID_TYPOGRAPHIC_SUBFAMILY_NAME: "TYPOGRAPHIC_SUBFAMILY_NAME",
NAMEID_COMPATIBLE_FULL_MACONLY: "COMPATIBLE_FULL_MACONLY",
NAMEID_SAMPLE_TEXT: "SAMPLE_TEXT",
NAMEID_POSTSCRIPT_CID_NAME: "POSTSCRIPT_CID_NAME",
NAMEID_WWS_FAMILY_NAME: "WWS_FAMILY_NAME",
NAMEID_WWS_SUBFAMILY_NAME: "WWS_SUBFAMILY_NAME",
NAMEID_LIGHT_BACKGROUND_PALETTE: "LIGHT_BACKGROUND_PALETTE",
NAMEID_DARK_BACKGROUD_PALETTE: "DARK_BACKGROUD_PALETTE"
NAMEID_COPYRIGHT_NOTICE: "COPYRIGHT_NOTICE",
NAMEID_FONT_FAMILY_NAME: "FONT_FAMILY_NAME",
NAMEID_FONT_SUBFAMILY_NAME: "FONT_SUBFAMILY_NAME",
NAMEID_UNIQUE_FONT_IDENTIFIER: "UNIQUE_FONT_IDENTIFIER",
NAMEID_FULL_FONT_NAME: "FULL_FONT_NAME",
NAMEID_VERSION_STRING: "VERSION_STRING",
NAMEID_POSTSCRIPT_NAME: "POSTSCRIPT_NAME",
NAMEID_TRADEMARK: "TRADEMARK",
NAMEID_MANUFACTURER_NAME: "MANUFACTURER_NAME",
NAMEID_DESIGNER: "DESIGNER",
NAMEID_DESCRIPTION: "DESCRIPTION",
NAMEID_VENDOR_URL: "VENDOR_URL",
NAMEID_DESIGNER_URL: "DESIGNER_URL",
NAMEID_LICENSE_DESCRIPTION: "LICENSE_DESCRIPTION",
NAMEID_LICENSE_INFO_URL: "LICENSE_INFO_URL",
NAMEID_TYPOGRAPHIC_FAMILY_NAME: "TYPOGRAPHIC_FAMILY_NAME",
NAMEID_TYPOGRAPHIC_SUBFAMILY_NAME: "TYPOGRAPHIC_SUBFAMILY_NAME",
NAMEID_COMPATIBLE_FULL_MACONLY: "COMPATIBLE_FULL_MACONLY",
NAMEID_SAMPLE_TEXT: "SAMPLE_TEXT",
NAMEID_POSTSCRIPT_CID_NAME: "POSTSCRIPT_CID_NAME",
NAMEID_WWS_FAMILY_NAME: "WWS_FAMILY_NAME",
NAMEID_WWS_SUBFAMILY_NAME: "WWS_SUBFAMILY_NAME",
NAMEID_LIGHT_BACKGROUND_PALETTE: "LIGHT_BACKGROUND_PALETTE",
NAMEID_DARK_BACKGROUD_PALETTE: "DARK_BACKGROUD_PALETTE",
}

# Platform IDs:
Expand All @@ -79,17 +79,17 @@
PLATFORM_ID__CUSTOM = 4

PLATID_STR = {
PLATFORM_ID__UNICODE: "UNICODE",
PLATFORM_ID__MACINTOSH: "MACINTOSH",
PLATFORM_ID__ISO: "ISO",
PLATFORM_ID__WINDOWS: "WINDOWS",
PLATFORM_ID__CUSTOM: "CUSTOM"
PLATFORM_ID__UNICODE: "UNICODE",
PLATFORM_ID__MACINTOSH: "MACINTOSH",
PLATFORM_ID__ISO: "ISO",
PLATFORM_ID__WINDOWS: "WINDOWS",
PLATFORM_ID__CUSTOM: "CUSTOM",
}

OFL_LICENSE_INFO = (
"This Font Software is licensed under the SIL Open Font License, "
"Version 1.1. This license is available with a FAQ at: "
"https://openfontlicense.org"
"This Font Software is licensed under the SIL Open Font License, "
"Version 1.1. This license is available with a FAQ at: "
"https://openfontlicense.org"
)

OFL_LICENSE_URL = "https://openfontlicense.org"
Expand Down Expand Up @@ -184,4 +184,4 @@
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE."""
OTHER DEALINGS IN THE FONT SOFTWARE."""
Loading

0 comments on commit c33db8b

Please sign in to comment.