Skip to content

Commit fd0e745

Browse files
committed
fix: undo sorting to keep order as in python build file (page list param), generate persistant uuidv5 for package page
1 parent cb75660 commit fd0e745

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

src/osw/controller/page_package.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,14 @@ def create(
512512
)
513513
pp: PagePackage = None
514514
if len(res) == 0:
515-
# generate new entity
515+
# generate deterministic entity from globalID
516+
import uuid as uuid_module
517+
516518
pp = PagePackage(
517519
label=[Label(text=p.globalID)],
520+
uuid=str(
521+
uuid_module.uuid5(uuid_module.NAMESPACE_URL, p.globalID)
522+
),
518523
)
519524
else:
520525
# load entity

src/osw/wtsite.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1929,19 +1929,8 @@ def save_to_file(file_path__, content__):
19291929
with open(os.path.join(file_path__), "w", encoding="utf-8") as f__:
19301930
f__.write(content__)
19311931

1932-
def _sort_json_arrays(obj):
1933-
"""Recursively sort list-of-strings for deterministic serialization."""
1934-
if isinstance(obj, dict):
1935-
return {k: _sort_json_arrays(v) for k, v in obj.items()}
1936-
if isinstance(obj, list):
1937-
if all(isinstance(v, str) for v in obj):
1938-
return sorted(obj)
1939-
return [_sort_json_arrays(v) for v in obj]
1940-
return obj
1941-
19421932
def dump_slot_content(slot_key_, content_type_, content_):
19431933
if isinstance(content_, dict):
1944-
content_ = _sort_json_arrays(content_)
19451934
content_ = json.dumps(content_, indent=4, ensure_ascii=False)
19461935
if content_type_ == "Scribunto":
19471936
content_type_ = "lua"

0 commit comments

Comments
 (0)