Changeset 169

Show
Ignore:
Timestamp:
03/22/06 13:25:55 (3 years ago)
Author:
abaxter
Message:

added -k/--keepgoing to say "keep going even if there are errors" - traceback is spat out, but compiling continues. default is False (break!)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pyramid/build.py

    r168 r169  
    1111import shutil 
    1212import syck 
     13import traceback 
    1314from os.path import join as opjoin 
    1415 
     
    3536def build(data, out, verbose=0, resourcedirs=[], rebuilddirs=None, 
    3637          partialbuild=False, constants=None, update=False, 
    37           createcache=False): 
     38          createcache=False, keepgoing=False): 
    3839 
    3940    DATADIR = os.path.abspath(data) 
     
    131132 
    132133 
    133         if os.path.exists( cachepath ) and partialbuild: 
     134        if os.path.exists(cachepath) and partialbuild: 
    134135            ctx = pickle.load(open(cachepath)) 
    135136            ctx.partialbuild = True 
    136             html = flat.flatten( [DOCTYPE, 
    137                         flatten(ctx.data[ctx.relpath]['index.yml'], ctx)]
     137            html = flat.flatten([DOCTYPE, 
     138                            flatten(ctx.data[ctx.relpath]['index.yml'], ctx)]
    138139            file(opjoin(OUTPUTDIR, root, 'index.html'), 'w').write(html) 
    139140        else: 
     
    148149 
    149150                try: 
    150                     html = flat.flatten( [DOCTYPE, 
     151                    html = flat.flatten([DOCTYPE, 
    151152                            flatten(Y.fragmentConstructor( 
    152                                     opjoin(root, 'index.yml')), ctx)]
     153                                    opjoin(root, 'index.yml')), ctx)]
    153154                except KeyError: 
    154155                    print '*'*80 
     
    160161 
    161162                    sys.exit() 
     163                except (KeyboardInterrupt, SystemExit): # roll on Python2.5 
     164                    raise 
     165                except: 
     166                    print "While building %s:"%(opjoin(OUTPUTDIR, root)) 
     167                    if not keepgoing: 
     168                        raise 
     169                    else: 
     170                        ee, ev, et = sys.exc_info() 
     171                        traceback.print_exception(ee, ev, et, file=sys.stdout) 
     172                        print "keepgoing (-k) specified, continuing" 
     173                        continue 
     174 
    162175 
    163176                file(opjoin(OUTPUTDIR, root, 'index.html'), 'w').write(html) 
     
    192205        constants = None 
    193206 
    194  
    195207    build(options.data, options.out, verbose=options.verbose, 
    196208          resourcedirs=resourcedirs, rebuilddirs=rebuilddirs, 
    197209          constants=constants, update=options.update, 
    198           createcache=options.createcache
     210          createcache=options.createcache, keepgoing=options.keepgoing
    199211 
    200212 
     
    226238        help="pass in the names constants (e.g. PDO=/root/pdo,PSF=/psf", 
    227239        metavar="CONSTANTS") 
     240    parser.add_option("-k", "--keepgoing", dest="keepgoing", 
     241        action="store_true", default=False, 
     242        help="keep going past errors if possible", 
     243        metavar="KEEPGOING") 
    228244    parser.add_option("-U", "--update", action="store_true", dest="update", 
    229245        default=False,