-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathsplit-essex.py
More file actions
executable file
·37 lines (33 loc) · 1.12 KB
/
Copy pathsplit-essex.py
File metadata and controls
executable file
·37 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
#=========================================================================
# This is OPEN SOURCE SOFTWARE governed by the MIT License.
# Copyright (C)2026 William H. Majoros <bmajoros@duke.edu>
#=========================================================================
import sys
import ProgramName
from EssexParser import EssexParser
def makeFilename(filestem,n):
return filestem+str(n+1)+".essex"
#=========================================================================
# main()
#=========================================================================
if(len(sys.argv)!=4):
exit(ProgramName.get()+" <in.essex> <elements-per-partition> <out-filestem>\n")
(infile,MAX_PER_CHUNK,filestem)=sys.argv[1:]
MAX_PER_CHUNK=int(MAX_PER_CHUNK)
chunkNum=0
fh=open(makeFilename(filestem,chunkNum),"wt")
numInChunk=0
parser=EssexParser(infile)
while(True):
tree=parser.nextElem()
if(tree is None): break
tree.print(fh)
numInChunk+=1
if(numInChunk>=MAX_PER_CHUNK):
fh.close()
chunkNum+=1
numInChunk=0
fh=open(makeFilename(filestem,chunkNum),"wt")
fh.close()
parser.close()