Commit 1a20405f authored by Alexander Gehrke's avatar Alexander Gehrke
Browse files

Fix parameter naming bug and remove kwargs which lead to this bug

parent cffdaaae
......@@ -2,13 +2,12 @@ from typing import Optional
from PIL import Image
import pypagexml.ds as ds
import pypagexml.ds.generated as dsgen
def new_document(metadata: Optional[ds.MetadataType], page: Optional[ds.PageType] = None) -> ds.PcGtsTypeSub:
doc = ds.PcGtsTypeSub(
metadata=metadata if metadata is not None else ds.MetadataTypeSub.default(),
page=page)
Metadata=metadata if metadata is not None else ds.MetadataTypeSub.default(),
Page=page)
return doc
......@@ -19,8 +18,8 @@ def new_document_from_image(path: str, metadata: Optional[ds.MetadataType] = Non
xres, yres = im.info['dpi'] if 'dpi' in im.info else (None, None)
return ds.PcGtsTypeSub(
metadata=metadata if metadata is not None else ds.MetadataTypeSub.default(),
page=ds.PageTypeSub(
Metadata=metadata if metadata is not None else ds.MetadataTypeSub.default(),
Page=ds.PageTypeSub(
imageFilename=path, imageWidth=w, imageHeight=h, imageXResolution=xres, imageYResolution=yres
)
)
......@@ -60,16 +59,16 @@ class PageXml:
return id
def add_paragraph(self, p, coords: ds.Points, ptype="paragraph"):
page: ds.PageTypeSub = self.pcgts.get_Page()
page.TextRegion.append(
page = self.pcgts.get_Page()
page.add_TextRegion(
ds.TextRegionTypeSub(
id=self.next_text_id(), Coords=ds.CoordsTypeSub.with_points(coords), type_=ptype
)
)
def add_image(self, p, coords: ds.Points):
page: ds.PageTypeSub = self.pcgts.get_Page()
page.ImageRegion.append(
page = self.pcgts.get_Page()
page.add_ImageRegion(
ds.ImageRegionTypeSub(
id=self.next_text_id(), Coords=ds.CoordsTypeSub.with_points(coords)
)
......
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment