Changeset 4a79b76 in flexoentity
- Timestamp:
- 11/28/25 18:13:58 (7 weeks ago)
- Branches:
- master
- Children:
- df459f7
- Parents:
- 100c1d2
- File:
-
- 1 edited
-
flexoentity/flexo_entity.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
flexoentity/flexo_entity.py
r100c1d2 r4a79b76 56 56 from dataclasses import dataclass, field, replace 57 57 from typing import Optional 58 from pathlib import Path 58 59 from abc import ABC, abstractmethod 59 60 import hashlib 60 61 61 62 62 from flexoentity.id_factory import FlexOID , canonical_seed63 from flexoentity.id_factory import FlexOID 63 64 from flexoentity.logger import logger 64 65 … … 114 115 return self.name 115 116 117 116 118 TRANSITIONS = { 117 119 EntityState.DRAFT: [EntityState.APPROVED], … … 122 124 EntityState.OBSOLETE: [], 123 125 } 124 125 126 126 127 … … 306 307 return obj 307 308 308 def to_json(self, *, indent: int | None = None) -> str: 309 """I serialize myself (and my FlexOID) into JSON.""" 310 return json.dumps(self.to_dict(), indent=indent, ensure_ascii=False) 309 def to_json(self, indent: int = 2) -> str: 310 """Return a JSON representation including all FlexO metadata.""" 311 return json.dumps(self.to_dict(), ensure_ascii=False, indent=indent) 312 313 def to_json_file(self, path): 314 Path(path).write_text(self.to_json(), encoding="utf-8") 315 return path 311 316 312 317 @classmethod … … 315 320 data = json.loads(data_str) 316 321 return cls.from_dict(data) 322 323 @classmethod 324 def from_json_file(cls, filename: str): 325 with open(filename, "r", encoding="utf-8") as f: 326 data = json.load(f) 327 return cls.from_dict(data) 328 317 329 318 330 def _deserialize_content(self, content_dict):
Note:
See TracChangeset
for help on using the changeset viewer.
