COIN-OR::LEMON - Graph Library

Changeset 42:6df2bf124af4 in lemon-tutorial for scripts


Ignore:
Timestamp:
02/22/10 00:40:36 (15 years ago)
Author:
Peter Kovacs <kpeter@…>
Branch:
default
Phase:
public
Message:

Imporve the titlegen script
to correctly handle section numbers that are greater than ten

File:
1 edited

Legend:

Unmodified
Added
Removed
  • scripts/titlegen.py

    r26 r42  
    55import copy
    66import re
     7
     8max_sec_number=100
     9max_sec_depth=4
    710
    811def sec_inc(section, lev):
     
    1922    s=s[:-1]
    2023    return s
     24
     25def compare_sec(id1, id2):
     26    id1=id1.split('.')
     27    c1=0
     28    for s in id1:
     29        c1=c1*max_sec_number+int(s)
     30    for i in range(len(id1), max_sec_depth+1):
     31        c1*=max_sec_number
     32    id2=id2.split('.')
     33    c2=0
     34    for s in id2:
     35        c2=c2*max_sec_number+int(s)
     36    for i in range(len(id2), max_sec_depth+1):
     37        c2*=max_sec_number
     38    return c1-c2
    2139
    2240section = [];
     
    7088                             (prev_str,next_str))
    7189            elif gr[3]:
    72                 secs = [ x for x in toc]
    73                 secs.sort()
     90                secs = [ x for x in toc ]
     91                secs.sort(compare_sec)
    7492                for num in secs:
    7593                    fo.write("%s - \\ref %s\n"%('  '*((len(ind[toc[num]][0]))),
Note: See TracChangeset for help on using the changeset viewer.