Ticket #7961: edit_module.patch

File edit_module.patch, 1.4 KB (added by nbruin, 12 years ago)

making misc.edit_module pathname mangling more robust

  • sage/misc/edit_module.py

    # HG changeset patch
    # User Nils Bruin <nbruin@sfu.ca>
    # Date 1263695603 28800
    # Node ID bb221202def7bc4d775f43770ed36b64d3b8b853
    # Parent  1fe47c6a8f49f3a58ce9fd808984ceb6ddd9d02a
    Making devel path replacement more robust
    
    diff -r 1fe47c6a8f49 -r bb221202def7 sage/misc/edit_module.py
    a b  
    9090     #  3 from the line number to compensate for the 3 lines that were prefixed
    9191     #  in the preparsing process
    9292     #
    93      if filename[-3:] == '.py':
     93     if filename.endswith('.py'):
    9494       infile=open(filename,'r')
    9595       infile.readline()
    9696       if infile.readline().find("*autogenerated*") >= 0:
     
    9898         lineno = lineno-3
    9999
    100100   sageroot = sage.misc.sageinspect.SAGE_ROOT+'/'
    101    runbranches = ['local/lib/python/site-packages',
    102                   'local/lib/python2.5/site-packages']
    103    develbranch = 'devel/sage'
    104    for runbranch in runbranches:
    105      prefix = sageroot+runbranch
    106      if filename.startswith(prefix):
    107        filename = sageroot+develbranch+filename[len(prefix):]
    108      
     101   runpathpattern = '^'+sageroot+'local/lib/python[^/]*/site-packages'
     102   develbranch = sageroot+'devel/sage'
     103   import re
     104   filename=re.sub(runpathpattern,develbranch,filename)
     105
    109106   return filename, lineno+1
    110107
    111108def template_fields(template):