fixed sorted / unsorted pages
This commit is contained in:
parent
30c6817cb0
commit
9da10819b4
@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python
|
||||
import sys, os, string, json
|
||||
from operator import attrgetter
|
||||
|
||||
fp1 = ''
|
||||
fp2 = ''
|
||||
@ -87,6 +88,9 @@ if __name__ == '__main__':
|
||||
|
||||
data = difference(data1, data2)
|
||||
|
||||
data['QUOTES'] = sorted(data['QUOTES'], key=lambda entry: int(entry['pp']))
|
||||
data['NOTES'] = sorted(data['NOTES'], key=lambda entry: int(entry['pp']))
|
||||
|
||||
json.dump(data, sys.stdout)
|
||||
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ def process_quote(c):
|
||||
fp, l = c
|
||||
ppnbr = int(extract_identifier(l))
|
||||
for i in quotes.keys():
|
||||
if int(i) < ppnbr:
|
||||
if i < ppnbr:
|
||||
emit_quotes(quotes[i])
|
||||
emit_line(l)
|
||||
return QUOTES(c)
|
||||
@ -110,7 +110,9 @@ def emit_remaining_quotes():
|
||||
rest = []
|
||||
for i in quotes:
|
||||
rest.extend(quotes[i])
|
||||
emit_quotes(rest)
|
||||
for j in rest:
|
||||
emit_quote(j)
|
||||
#emit_quotes(rest)
|
||||
|
||||
def emit_quotes(list):
|
||||
while list:
|
||||
@ -141,11 +143,12 @@ def emit_line(l):
|
||||
def reoder(q):
|
||||
out = {}
|
||||
while q:
|
||||
i = q.pop()
|
||||
if i['pp'] in out.keys():
|
||||
out[i['pp']].append(i)
|
||||
ip = q.pop()
|
||||
i = int(ip['pp'])
|
||||
if i in out.keys():
|
||||
out[i].append(ip)
|
||||
else:
|
||||
out[i['pp']] = [i]
|
||||
out[i] = [ip]
|
||||
return out
|
||||
|
||||
def open_file(p):
|
||||
@ -208,6 +211,8 @@ if __name__ == '__main__':
|
||||
quotes = reoder(data['QUOTES'])
|
||||
notes = reoder(data['NOTES'])
|
||||
|
||||
print quotes
|
||||
|
||||
notes_cnt = 0
|
||||
|
||||
try:
|
||||
|
||||
@ -61,7 +61,7 @@ def section(line):
|
||||
else: return parse
|
||||
|
||||
def page(line):
|
||||
return line.rstrip('\n').split(',')[1][-1]
|
||||
return line.rstrip('\n').split(',')[-1].split(' ')[-1]
|
||||
|
||||
if __name__ == '__main__':
|
||||
m = StateMachine();
|
||||
|
||||
@ -20,4 +20,4 @@ fi
|
||||
|
||||
parse-skim.py < $filename
|
||||
|
||||
rm $filename
|
||||
#rm $filename
|
||||
Loading…
x
Reference in New Issue
Block a user