Changeset 1455

Show
Ignore:
Timestamp:
07/19/06 03:46:53 (2 years ago)
Author:
jstenar
Message:

pyreadline: added automatic creation of configfile if missing. Maybe issues with movable python, py2exe etc.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • pyreadline/trunk/doc/ChangeLog

    r1452 r1455  
     12006-07-19 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
     2    * Added creation of default configuration file if missing. 
     3    * There may still be issues with config file creation for movpy, py2exe and similar systems. 
     4 
    152006-07-18 Jörgen Stenarson  <jorgen.stenarson -at- bostream.nu> 
    26    * Added AnsiState class to simplify work with getting the aansi color handling to work properly 
  • pyreadline/trunk/pyreadline/release.py

    r1340 r1455  
    2323branch = 'trunk' 
    2424 
    25 version = '1.3
     25version = '1.3.1.svn
    2626 
    2727revision = '$Revision$' 
  • pyreadline/trunk/pyreadline/rlmain.py

    r1452 r1455  
    3434    return buffer[point:point+1] in [A-Za-z0-9] 
    3535 
    36 config_path=os.path.expanduser("~/pyreadlineconfig.ini") 
     36config_path=os.environ.get("PYREADLINECONFIGFILE", 
     37                           os.path.normpath(os.path.expanduser("~/pyreadlineconfig.ini"))) 
     38pyreadlinedebug=os.environ.get("PYREADLINEDEBUG",False) 
    3739 
    3840class Readline: 
     
    12531255             "set_prompt_color":set_prompt_color, 
    12541256             "set_input_color":set_input_color,} 
    1255         if os.path.isfile(inputrcpath):  
     1257        if os.path.isdir(inputrcpath): 
     1258            print >>sys.stderr, "A directory is present with the name of the configuration file:\n  '%s'"%inputrcpath 
     1259            return 
     1260        elif not os.path.isfile(inputrcpath) and not pyreadlinedebug: 
     1261            configfilename=os.path.join(os.path.split(__file__)[0],"configuration\\pyreadlineconfig.ini") 
     1262            print "Could not find pyreadline configfile at default location:\n  '%s'.\nCreating a default file."%inputrcpath 
    12561263            try: 
    1257                 execfile(inputrcpath,loc,loc) 
    1258             except Exception,x: 
    1259                 import traceback 
    1260                 print >>sys.stderr, "Error reading .pyinputrc" 
    1261                 filepath,lineno=traceback.extract_tb(sys.exc_traceback)[1][:2] 
    1262                 print >>sys.stderr, "Line: %s in file %s"%(lineno,filepath) 
    1263                 print >>sys.stderr, x 
    1264                 raise ReadlineError("Error reading .pyinputrc") 
    1265  
    1266  
     1264                configfile=open(configfilename) 
     1265                conf=configfile.read() 
     1266                configfile.close() 
     1267            except IOError: 
     1268                print "could not find the default configuration template." 
     1269                print "Tried looking at:\n  ",configfilename 
     1270                return  
     1271            fil=open(inputrcpath,"w") 
     1272            fil.write(conf) 
     1273            fil.close() 
     1274        try: 
     1275            execfile(inputrcpath,loc,loc) 
     1276        except IOError: 
     1277            pass 
     1278        except Exception,x: 
     1279            raise 
     1280            import traceback 
     1281            print >>sys.stderr, "Error reading .pyinputrc" 
     1282            filepath,lineno=traceback.extract_tb(sys.exc_traceback)[1][:2] 
     1283            print >>sys.stderr, "Line: %s in file %s"%(lineno,filepath) 
     1284            print >>sys.stderr, x 
     1285            raise ReadlineError("Error reading .pyinputrc") 
    12671286 
    12681287def CTRL(c):