fixed running with default --range & using --separation options.

This commit is contained in:
Onur Guevenc 2011-07-22 11:59:03 +00:00
parent 105a09f3df
commit 8cb8637d41
1 changed files with 20 additions and 21 deletions

View File

@ -715,6 +715,10 @@ if options.filetype == None:
options.filetype = options.filetype.lower() options.filetype = options.filetype.lower()
if options.filetype == 'marc': offset_pos = 1
else: offset_pos = 0
# --- more sanity checks # --- more sanity checks
if options.filetype not in ['marc','spectral']: if options.filetype not in ['marc','spectral']:
@ -851,19 +855,10 @@ maxCountElementsOfNode = 0
for l in elementsOfNode.values(): for l in elementsOfNode.values():
maxCountElementsOfNode = max(maxCountElementsOfNode,len(l)) maxCountElementsOfNode = max(maxCountElementsOfNode,len(l))
# --- get output data from .t16 file
positions = range(stat['NumberOfIncrements'])
if options.filetype == 'marc':
offset_pos = 1
else:
offset_pos = 0
# --------------------------- build group membership -------------------------------- # --------------------------- build group membership --------------------------------
p.moveto(positions[0]+offset_pos) p.moveto(offset_pos)
index = {} index = {}
groups = [] groups = []
groupCount = 0 groupCount = 0
@ -1003,9 +998,11 @@ for position in range(stat['NumberOfIncrements']):
incAtPosition[position] = p.increment # remember "real" increment at this position incAtPosition[position] = p.increment # remember "real" increment at this position
positionOfInc[p.increment] = position # remember position of "real" increment positionOfInc[p.increment] = position # remember position of "real" increment
if not options.range:
if options.range: options.getIncrements = False
options.range = list(options.range) locations = range(stat['NumberOfIncrements']) # process all positions
else:
options.range = list(options.range) # convert to list
if options.sloppy: if options.sloppy:
locations = range(options.range[0],options.range[1]+1,options.range[2]) locations = range(options.range[0],options.range[1]+1,options.range[2])
else: else:
@ -1015,16 +1012,18 @@ if options.range:
options.range[1]+1), options.range[1]+1),
options.range[2] ) options.range[2] )
increments = map(lambda x: {False:incAtPosition[x],True:x}[options.getIncrements],locations) # build list of increments to process
time_start = time.time() time_start = time.time()
for incCount,location in enumerate(locations): for incCount,location in enumerate(locations): # walk through locations
if options.getIncrements: if options.getIncrements: # we talk in increments
position = positionOfInc[location] position = positionOfInc[location] # map back the actual position in the result file
else: else: # we talk positions anyway
position = location position = location # just take it then
p.moveto(position+offset_pos) # wind to correct position
p.moveto(position+offset_pos)
# --------------------------- file management -------------------------------- # --------------------------- file management --------------------------------
if options.separateFiles: if options.separateFiles:
@ -1054,8 +1053,8 @@ for incCount,location in enumerate(locations):
for (e,n,i,g,n_local) in group[1:]: # loop over group members for (e,n,i,g,n_local) in group[1:]: # loop over group members
member += 1 member += 1
if member%1000 == 0: if member%1000 == 0:
time_delta = ((len(positions)*memberCount)/float(member+incCount*memberCount)-1.0)*(time.time()-time_start) time_delta = ((len(locations)*memberCount)/float(member+incCount*memberCount)-1.0)*(time.time()-time_start)
bg.set_message('(%02i:%02i:%02i) processing point %i of %i from position %i...'%(time_delta//3600,time_delta%3600//60,time_delta%60,member,memberCount,position)) bg.set_message('(%02i:%02i:%02i) processing point %i of %i from %s %i...'%(time_delta//3600,time_delta%3600//60,time_delta%60,member,memberCount,{True:'increment',False:'position'}[options.getIncrements],position))
newby = [] # current member's data newby = [] # current member's data