senfd 0.2.2__tar.gz → 0.2.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. {senfd-0.2.2/src/senfd.egg-info → senfd-0.2.3}/PKG-INFO +1 -1
  2. {senfd-0.2.2 → senfd-0.2.3}/pyproject.toml +1 -1
  3. senfd-0.2.3/src/senfd/__init__.py +1 -0
  4. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/documents/base.py +3 -3
  5. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/documents/enriched.py +11 -6
  6. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/pipeline.py +3 -2
  7. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/schemas/enriched.figure.document.schema.json +15 -15
  8. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/schemas/plain.figure.document.schema.json +1 -1
  9. {senfd-0.2.2 → senfd-0.2.3/src/senfd.egg-info}/PKG-INFO +1 -1
  10. senfd-0.2.2/src/senfd/__init__.py +0 -1
  11. {senfd-0.2.2 → senfd-0.2.3}/LICENSE +0 -0
  12. {senfd-0.2.2 → senfd-0.2.3}/README.rst +0 -0
  13. {senfd-0.2.2 → senfd-0.2.3}/setup.cfg +0 -0
  14. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/cli.py +0 -0
  15. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/documents/__init__.py +0 -0
  16. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/documents/plain.py +0 -0
  17. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/errors.py +0 -0
  18. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/schemas/__init__.py +0 -0
  19. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/tables.py +0 -0
  20. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/templates/__init__.py +0 -0
  21. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/templates/enriched.figure.document.html.jinja2 +0 -0
  22. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/templates/plain.figure.document.html.jinja2 +0 -0
  23. {senfd-0.2.2 → senfd-0.2.3}/src/senfd/utils.py +0 -0
  24. {senfd-0.2.2 → senfd-0.2.3}/src/senfd.egg-info/SOURCES.txt +0 -0
  25. {senfd-0.2.2 → senfd-0.2.3}/src/senfd.egg-info/dependency_links.txt +0 -0
  26. {senfd-0.2.2 → senfd-0.2.3}/src/senfd.egg-info/entry_points.txt +0 -0
  27. {senfd-0.2.2 → senfd-0.2.3}/src/senfd.egg-info/requires.txt +0 -0
  28. {senfd-0.2.2 → senfd-0.2.3}/src/senfd.egg-info/top_level.txt +0 -0
  29. {senfd-0.2.2 → senfd-0.2.3}/tests/test_case_conversion.py +0 -0
  30. {senfd-0.2.2 → senfd-0.2.3}/tests/test_cli.py +0 -0
  31. {senfd-0.2.2 → senfd-0.2.3}/tests/test_module.py +0 -0
  32. {senfd-0.2.2 → senfd-0.2.3}/tests/test_schema.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: senfd
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Semantic Enhancer for Figure Documents
5
5
  Author-email: "Simon A. F. Lund" <os@safl.dk>
6
6
  License: LGPL-2.1-only
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "senfd"
3
- version = "0.2.2"
3
+ version = "0.2.3"
4
4
  description = "Semantic Enhancer for Figure Documents"
5
5
  authors = [
6
6
  { name = "Simon A. F. Lund", email = "os@safl.dk" }
@@ -0,0 +1 @@
1
+ __version__ = "0.2.3"
@@ -104,7 +104,7 @@ class Document(BaseModel):
104
104
  """Writes the document JSON schema to file at the given 'path'"""
105
105
 
106
106
  return to_file(
107
- json.dumps(cls.schema(), indent=4),
107
+ json.dumps(cls.model_json_schema(), indent=4),
108
108
  cls.schema_filename(),
109
109
  path,
110
110
  )
@@ -141,7 +141,7 @@ class Document(BaseModel):
141
141
  )
142
142
  template = env.get_template(self.FILENAME_HTML_TEMPLATE)
143
143
 
144
- return template.render(document=self.dict())
144
+ return template.render(document=self.model_dump())
145
145
 
146
146
  def to_html_file(self, path: Optional[Path] = None) -> Path:
147
147
  """Writes the document to HTML-formatted file"""
@@ -152,7 +152,7 @@ class Document(BaseModel):
152
152
  """Returns True when validator raises no exceptions, False otherwise"""
153
153
 
154
154
  try:
155
- self.validate(self.dict())
155
+ self.model_validate(self.model_dump())
156
156
  except ValidationError as e:
157
157
  print(e)
158
158
  return False
@@ -24,13 +24,15 @@ class EnrichedFigure(Figure):
24
24
  def from_figure_description(
25
25
  cls, figure: Figure, match
26
26
  ) -> Tuple[Optional[Figure], Optional[NamedTuple]]:
27
- shared = set(figure.dict().keys()).intersection(set(match.groupdict().keys()))
27
+ shared = set(figure.model_dump().keys()).intersection(
28
+ set(match.groupdict().keys())
29
+ )
28
30
  if shared:
29
31
  # This occurs if child attributes overrides parent, this is an error in the
30
32
  # implementation of the child-figure
31
33
  raise RuntimeError(f"cls({cls.__name__}) has overlap({shared})")
32
34
 
33
- data = figure.dict()
35
+ data = figure.model_dump()
34
36
  mdict = match.groupdict()
35
37
  if mdict:
36
38
  data.update(mdict if mdict else {})
@@ -39,6 +41,7 @@ class EnrichedFigure(Figure):
39
41
  # table, errors = senfd.tables.HeaderTable.from_table(figure.table)
40
42
  # data["table"] = table.dict() if table else figure.table.dict()
41
43
  enriched_figure = cls(**data)
44
+ errors = None
42
45
  if figure.table:
43
46
  table, errors = senfd.tables.HeaderTable.from_table(figure.table)
44
47
  enriched_figure.table = table if table else figure.table
@@ -158,7 +161,9 @@ def get_figure_enriching_classes():
158
161
  return [
159
162
  cls
160
163
  for _, cls in inspect.getmembers(senfd.documents.enriched, inspect.isclass)
161
- if issubclass(cls, EnrichedFigure) and hasattr(cls, "REGEX_FIGURE_DESCRIPTION")
164
+ if issubclass(cls, EnrichedFigure)
165
+ and (cls is not senfd.documents.enriched.EnrichedFigure)
166
+ and hasattr(cls, "REGEX_FIGURE_DESCRIPTION")
162
167
  ]
163
168
 
164
169
 
@@ -170,9 +175,6 @@ class EnrichedFigureDocument(Document):
170
175
  FILENAME_SCHEMA: ClassVar[str] = "enriched.figure.document.schema.json"
171
176
  FILENAME_HTML_TEMPLATE: ClassVar[str] = "enriched.figure.document.html.jinja2"
172
177
 
173
- nontabular: List[Figure] = Field(default_factory=list)
174
- uncategorized: List[Figure] = Field(default_factory=list)
175
-
176
178
  acronyms: List[Acronyms] = Field(default_factory=list)
177
179
  io_controller_command_set_support: List[IoControllerCommandSetSupport] = Field(
178
180
  default_factory=list
@@ -198,6 +200,9 @@ class EnrichedFigureDocument(Document):
198
200
  offset: List[Offset] = Field(default_factory=list)
199
201
  property_definition: List[PropertyDefinition] = Field(default_factory=list)
200
202
 
203
+ nontabular: List[Figure] = Field(default_factory=list)
204
+ uncategorized: List[Figure] = Field(default_factory=list)
205
+
201
206
  @classmethod
202
207
  def from_figure_document_file(cls, path: Path):
203
208
  """Instantiate an 'organized' Document from a 'figure' document"""
@@ -1,11 +1,12 @@
1
1
  from pathlib import Path
2
- from typing import List
2
+ from typing import List, Type
3
3
 
4
+ from senfd.documents.base import Converter
4
5
  from senfd.documents.enriched import FromFigureDocument
5
6
  from senfd.documents.plain import FromDocx
6
7
  from senfd.errors import TableError
7
8
 
8
- CONVERTERS = [FromDocx, FromFigureDocument]
9
+ CONVERTERS: List[Type[Converter]] = [FromDocx, FromFigureDocument]
9
10
 
10
11
 
11
12
  def process(input: Path, output: Path) -> List[TableError]:
@@ -497,7 +497,7 @@
497
497
  "DocumentMeta": {
498
498
  "properties": {
499
499
  "version": {
500
- "default": "0.2.2",
500
+ "default": "0.2.3",
501
501
  "title": "Version",
502
502
  "type": "string"
503
503
  },
@@ -915,20 +915,6 @@
915
915
  "meta": {
916
916
  "$ref": "#/$defs/DocumentMeta"
917
917
  },
918
- "nontabular": {
919
- "items": {
920
- "$ref": "#/$defs/Figure"
921
- },
922
- "title": "Nontabular",
923
- "type": "array"
924
- },
925
- "uncategorized": {
926
- "items": {
927
- "$ref": "#/$defs/Figure"
928
- },
929
- "title": "Uncategorized",
930
- "type": "array"
931
- },
932
918
  "acronyms": {
933
919
  "items": {
934
920
  "$ref": "#/$defs/Acronyms"
@@ -1040,6 +1026,20 @@
1040
1026
  },
1041
1027
  "title": "Property Definition",
1042
1028
  "type": "array"
1029
+ },
1030
+ "nontabular": {
1031
+ "items": {
1032
+ "$ref": "#/$defs/Figure"
1033
+ },
1034
+ "title": "Nontabular",
1035
+ "type": "array"
1036
+ },
1037
+ "uncategorized": {
1038
+ "items": {
1039
+ "$ref": "#/$defs/Figure"
1040
+ },
1041
+ "title": "Uncategorized",
1042
+ "type": "array"
1043
1043
  }
1044
1044
  },
1045
1045
  "title": "EnrichedFigureDocument",
@@ -20,7 +20,7 @@
20
20
  "DocumentMeta": {
21
21
  "properties": {
22
22
  "version": {
23
- "default": "0.2.2",
23
+ "default": "0.2.3",
24
24
  "title": "Version",
25
25
  "type": "string"
26
26
  },
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: senfd
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Semantic Enhancer for Figure Documents
5
5
  Author-email: "Simon A. F. Lund" <os@safl.dk>
6
6
  License: LGPL-2.1-only
@@ -1 +0,0 @@
1
- __version__ = "0.2.2"
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes