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

JSONFragment patch stable #173

Merged
merged 1 commit into from
Nov 29, 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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ __pycache__
/.idea/
/.tox-logs/
/coverage.xml

/build
venv
.venv
3 changes: 2 additions & 1 deletion annet/annlib/jsontools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import fnmatch
import json
from collections.abc import Mapping, Sequence
from operator import itemgetter
from typing import Any, Dict, List, Optional

import jsonpatch
Expand Down Expand Up @@ -73,7 +74,7 @@ def _ensure_pointer_exists(doc: Dict[str, Any], pointer: jsonpointer.JsonPointer

def make_patch(old: Dict[str, Any], new: Dict[str, Any]) -> List[Dict[str, Any]]:
"""Generate a JSON patch by comparing the old document with the new one."""
return jsonpatch.make_patch(old, new).patch
return sorted(jsonpatch.make_patch(old, new).patch, key=itemgetter("path"))


def apply_patch(content: Optional[bytes], patch_bytes: bytes) -> bytes:
Expand Down