@@ -115,6 +115,7 @@ async def split_xml(
115115 file_format_coll : xml .dom .minicompat .NodeList ,
116116 identifiers : list ,
117117 prefix : str ,
118+ start_index : int ,
118119) -> list | list :
119120 """Return a separate internal signature collection and file format
120121 collection so that they can be recombined as a new document.
@@ -137,7 +138,7 @@ async def split_xml(
137138 pairings .append (pair )
138139 ret = []
139140 for pair in pairings :
140- idx = len (identifiers ) + 1
141+ idx = len (identifiers ) + start_index
141142 identifiers .append (idx )
142143 pair .internal_signature .attributes ["ID" ] = f"{ idx } "
143144 pair .file_format .attributes ["ID" ] = f"{ idx } "
@@ -149,7 +150,7 @@ async def split_xml(
149150 return ret , identifiers
150151
151152
152- async def process_paths (manifest : list , prefix : str ):
153+ async def process_paths (manifest : list , prefix : str , start_index : int ):
153154 """Process the paths given as XML and prepare them to be combined
154155 into one xml.
155156 """
@@ -168,7 +169,7 @@ async def process_paths(manifest: list, prefix: str):
168169 )
169170 file_format_coll = doc .getElementsByTagName ("FileFormatCollection" )
170171 res , identifiers = await split_xml (
171- internal_sig_coll , file_format_coll , identifiers , prefix
172+ internal_sig_coll , file_format_coll , identifiers , prefix , start_index ,
172173 )
173174 if not res :
174175 logger .error ("cannot process: %s" , item )
@@ -196,12 +197,12 @@ async def create_manifest(path: str) -> list[str]:
196197 return paths
197198
198199
199- async def process_path (path : str , prefix : str ):
200+ async def process_path (path : str , prefix : str , start_index : int ):
200201 """Process the files at the given path."""
201202 logger .debug ("processing files at: %s" , path )
202203 # minidom.parseString()
203204 xml_paths = await create_manifest (path )
204- await process_paths (xml_paths , prefix )
205+ await process_paths (xml_paths , prefix , start_index )
205206
206207
207208def main () -> None :
@@ -225,6 +226,13 @@ def main() -> None:
225226 parser .add_argument (
226227 "--prefix" , help = "prefix for custom puids" , required = False , default = "ffdev"
227228 )
229+ parser .add_argument (
230+ "--start-index" ,
231+ help = "integer from which to start the singature index (for DROID copy-paste)" ,
232+ required = False ,
233+ type = int ,
234+ default = 1 ,
235+ )
228236 parser .add_argument (
229237 "--version" ,
230238 help = "print version information" ,
@@ -244,6 +252,7 @@ def main() -> None:
244252 process_path (
245253 path = args .path ,
246254 prefix = args .prefix ,
255+ start_index = args .start_index ,
247256 )
248257 )
249258
0 commit comments