Skip to content

Commit 1c21be1

Browse files
Robert Sachunskyfinkf
authored andcommitted
set pcGtsId to METS file ID everywhere
1 parent 9e20991 commit 1c21be1

File tree

9 files changed

+15
-7
lines changed

9 files changed

+15
-7
lines changed

ocrd_cis/align/cli.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from ocrd.decorators import ocrd_cli_wrap_processor
99
from ocrd_utils import MIMETYPE_PAGE
1010
from ocrd_utils import getLogger
11+
from ocrd_utils import make_file_id
1112
from ocrd_modelfactory import page_from_file
1213
from ocrd_models.ocrd_page import to_xml
1314
from ocrd_models.ocrd_page_generateds import TextEquivType
@@ -43,15 +44,14 @@ def process(self):
4344
pcgts = self.align(alignments, ift)
4445
# keep the right part after OCR-D-...-filename
4546
# and prepend output_file_grp
46-
# ID = concat_padded(self.output_file_grp, _id+1)
47-
basename = os.path.basename(ift[0].input_file.url)
48-
ID = self.output_file_grp + '-' + basename.replace('.xml', '')
47+
input_file = ift[0].input_file
48+
file_id = make_file_id(input_file, self.output_file_grp)
49+
pcgts.set_pcGtsId(file_id)
4950
out = self.workspace.add_file(
50-
ID=ID,
51+
ID=file_id,
5152
file_grp=self.output_file_grp,
52-
pageId=ift[0].input_file.pageId,
53-
basename=basename,
54-
local_filename=os.path.join(self.output_file_grp, basename),
53+
pageId=input_file.pageId,
54+
local_filename=os.path.join(self.output_file_grp, file_id + '.xml'),
5555
mimetype=MIMETYPE_PAGE,
5656
content=to_xml(pcgts),
5757
)

ocrd_cis/ocropy/binarize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def process(self):
169169

170170
# update METS (add the PAGE file):
171171
file_path = os.path.join(self.output_file_grp, file_id + '.xml')
172+
pcgts.set_pcGtsId(file_id)
172173
out = self.workspace.add_file(
173174
ID=file_id,
174175
file_grp=self.output_file_grp,

ocrd_cis/ocropy/clip.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ def process(self):
212212

213213
# update METS (add the PAGE file):
214214
file_path = os.path.join(self.output_file_grp, file_id + '.xml')
215+
pcgts.set_pcGtsId(file_id)
215216
out = self.workspace.add_file(
216217
ID=file_id,
217218
file_grp=self.output_file_grp,

ocrd_cis/ocropy/denoise.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def process(self):
121121

122122
# update METS (add the PAGE file):
123123
file_path = os.path.join(self.output_file_grp, file_id + '.xml')
124+
pcgts.set_pcGtsId(file_id)
124125
out = self.workspace.add_file(
125126
ID=file_id,
126127
file_grp=self.output_file_grp,

ocrd_cis/ocropy/deskew.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ def process(self):
112112

113113
# update METS (add the PAGE file):
114114
file_path = os.path.join(self.output_file_grp, file_id + '.xml')
115+
pcgts.set_pcGtsId(file_id)
115116
out = self.workspace.add_file(
116117
ID=file_id,
117118
file_grp=self.output_file_grp,

ocrd_cis/ocropy/dewarp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ def process(self):
180180

181181
# update METS (add the PAGE file):
182182
file_path = os.path.join(self.output_file_grp, file_id + '.xml')
183+
pcgts.set_pcGtsId(file_id)
183184
out = self.workspace.add_file(
184185
ID=file_id,
185186
file_grp=self.output_file_grp,

ocrd_cis/ocropy/recognize.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ def process(self):
179179
# update METS (add the PAGE file):
180180
file_id = make_file_id(input_file.ID, self.output_file_grp)
181181
file_path = os.path.join(self.output_file_grp, file_id + '.xml')
182+
pcgts.set_pcGtsId(file_id)
182183
out = self.workspace.add_file(
183184
ID=file_id,
184185
file_grp=self.output_file_grp,

ocrd_cis/ocropy/resegment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ def process(self):
276276

277277
# update METS (add the PAGE file):
278278
file_path = os.path.join(self.output_file_grp, file_id + '.xml')
279+
pcgts.set_pcGtsId(file_id)
279280
out = self.workspace.add_file(
280281
ID=file_id,
281282
file_grp=self.output_file_grp,

ocrd_cis/ocropy/segment.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ def process(self):
382382

383383
# update METS (add the PAGE file):
384384
file_path = os.path.join(self.output_file_grp, file_id + '.xml')
385+
pcgts.set_pcGtsId(file_id)
385386
out = self.workspace.add_file(
386387
ID=file_id,
387388
file_grp=self.output_file_grp,

0 commit comments

Comments
 (0)