Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/test_totolo.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def test_versions(self):
precache_remote_resources()
versions = [v for v, _ in totolo.remote.versions()]
assert "v2023.06" in versions
assert "v0.3.3" in versions
assert "v0.3.3" not in versions # v0.* package tags are excluded from listings
with pytest.raises(ValueError):
totolo.remote.version("gobbledygook")

Expand Down
2 changes: 1 addition & 1 deletion totolo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


remote = TORemote()
__version__ = "2.1.2"
__version__ = "2.1.3"
__ALL__ = [
empty,
files,
Expand Down
15 changes: 14 additions & 1 deletion totolo/impl/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import re
import urllib.request
import functools

Expand All @@ -9,6 +10,16 @@
API_URL = "https://api.github.com/repos/theme-ontology/theming/"


def _is_ontology_release(tag):
"""Whether a release tag is a dated ontology snapshot (e.g. v2025.04).

v0.* tags are early totolo package releases, not ontology versions, and
cannot be built into a corpus -- exclude them from version listings.
"""
match = re.match(r"v?(\d+)", tag)
return not (match and int(match.group(1)) == 0)


def files(paths=None):
return TOParser.add_files(empty(), paths)

Expand Down Expand Up @@ -61,7 +72,9 @@ def version(self, version: str = ""):

def versions(self):
for item in self._get("releases"):
yield item["tag_name"], item["name"]
tag = item["tag_name"]
if _is_ontology_release(tag):
yield tag, item["name"]

@functools.lru_cache
def _get(self, endpoint):
Expand Down
5 changes: 4 additions & 1 deletion totolo/util/makejson.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import argparse
import json
import sys
from collections import defaultdict

import totolo.lib.argparse
Expand Down Expand Up @@ -143,7 +144,9 @@ def main():
verbosity=args.verbosity,
)
try:
print(json.dumps(dd, indent=4, ensure_ascii=False))
sys.stdout.buffer.write(json.dumps(dd, indent=4, ensure_ascii=False).encode("utf-8"))
sys.stdout.buffer.write(b"\n")
sys.stdout.buffer.flush()
except BrokenPipeError: # pragma: no cover
pass

Expand Down
2 changes: 2 additions & 0 deletions totolo/util/mergelist.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import argparse
import sys
from collections import defaultdict

import totolo
Expand Down Expand Up @@ -256,6 +257,7 @@ def main():
help="Read and report on stdout, but do not write changes to ontology.",
action="store_true",
)
sys.stdout.reconfigure(encoding='utf-8')
args = parser.parse_args()
mergelist(args.path_changes, args.path_ontology, args.dryrun)

Expand Down
Loading