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

Drop deprecated ngon parsing and fix json maintenance #47

Merged
merged 2 commits into from
Jun 25, 2024
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
89 changes: 11 additions & 78 deletions flatsurvey/cache/cache.py

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions flatsurvey/cache/externalize_pickles.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def __init__(self, jsons, in_place, pickle_dir, report):
@click.command(name="externalize-pickles")
@click.argument("jsons", nargs=-1)
@click.option("--inplace", default=False, is_flag=True)
@click.option("--pickles", type=click.Path(exists=True), help="output directory")
@click.option(
"--pickles",
required=True,
type=click.Path(exists=True),
help="output directory",
)
def click(jsons, inplace, pickles):
return {
"goals": [ExternalizePickles],
Expand All @@ -58,10 +63,16 @@ def externalize(json):
if "pickle" in json:
value = json["pickle"]

import base64

value = base64.decodebytes(value.encode("ascii"))

if len(value) > 128:
import hashlib
from hashlib import sha256

hash = hashlib.md5(value.encode("utf-8")).hexdigest()
sha = sha256()
sha.update(value)
hash = sha.hexdigest()

import os.path

Expand All @@ -70,7 +81,7 @@ def externalize(json):
import gzip

with gzip.open(fname, mode="w") as compressed:
compressed.write(value.encode("ascii"))
compressed.write(value)

json["pickle"] = hash

Expand Down
3 changes: 3 additions & 0 deletions flatsurvey/reporting/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@
from flatsurvey.ui.group import GroupedCommand


# TODO: This segfaults with recent versions of SageMath. PARI is not
# thread or fork-safe in the way SageMath uses it, so threading out seems to
# break things.
class Progress(Reporter, Command):
r"""
Reports progress on the command line.
Expand Down
Loading