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