diff --git a/twander.py b/twander.py index 73e6986..456b32a 100755 --- a/twander.py +++ b/twander.py @@ -6,7 +6,7 @@ # Program Information PROGNAME = "twander" -RCSID = "$Id: twander.py,v 3.206 2006/12/18 22:02:25 tundra Exp $" +RCSID = "$Id: twander.py,v 3.207 2006/12/18 23:27:51 tundra Exp $" VERSION = RCSID.split()[2] # Copyright Information @@ -587,7 +587,8 @@ ##### ASSIGN = "=" # Assignment for variable definitions -ASSOCDFLT = "*" # Name for default association action +ASSOCDFLT = "*" # Symbol for default association action +ASSOCEXCL = "-" # Symbol for association exclusion action ASSOCIATE = "ASSOC" # Association keyword CONF = "" # Config file user selected with -c option COMMENT = r"#" # Comment introducer string @@ -1161,7 +1162,7 @@ # Cleanout any old configuration data - UI.Associations = {} + UI.Associations = {ASSOCEXCL:[]} UI.CmdTable = {} UI.Commands = [] UI.ConfigVisited = [] @@ -1768,7 +1769,12 @@ # Store associations for use at execution time if cmdkey == ASSOCIATE: - UI.Associations[cmdname] = cmd + if cmdname == ASSOCEXCL: + for exclude in cmd.split(): + print cmdname + UI.Associations[cmdname].append(exclude) + else: + UI.Associations[cmdname] = cmd return # Add the command entry to the command table. @@ -3576,22 +3582,30 @@ executable = os.stat(selected)[ST_MODE] & (S_IXUSR|S_IXGRP|S_IXOTH) - # Apply any relevant association information + # Apply any relevant association information, skipping types + # found in the exclusion list + excluded = False + for exclude in UI.Associations[ASSOCEXCL]: + if selected.endswith(exclude) or (OSPLATFORM == 'win32' and selected.lower().endswith(exclude.lower())): + excluded = True + assocfound = False - for assoc in UI.Associations: - if selected.endswith(assoc) or (OSPLATFORM == 'win32' and selected.lower().endswith(assoc.lower())): - selected = UI.Associations[assoc] + if not excluded: + + for assoc in UI.Associations: + if selected.endswith(assoc) or (OSPLATFORM == 'win32' and selected.lower().endswith(assoc.lower())): + selected = UI.Associations[assoc] + assocfound = True + + # If we did not find a file association and a default + # association is defined, apply it to everything + # except executable files. + + if not assocfound and (ASSOCDFLT in UI.Associations) and not executable: + selected = UI.Associations[ASSOCDFLT] assocfound = True - # If we did not find a file association and a default - # association is defined, apply it to everything - # except executable files. - - if not assocfound and (ASSOCDFLT in UI.Associations) and not executable: - selected = UI.Associations[ASSOCDFLT] - assocfound = True - # In the case of Unix-like OSs, if the file is non-executable # and has no association, this is an error and needs to @@ -5129,7 +5143,7 @@ debuginfo = [] for assocname in UI.Associations: - debuginfo.append(PadString(assocname, dASSOCWIDTH) + UI.Associations[assocname]) + debuginfo.append(PadString(assocname, dASSOCWIDTH) + str(UI.Associations[assocname])) debuginfo.sort() return debuginfo @@ -5300,7 +5314,7 @@ # Storage For Associations -UI.Associations = {} +UI.Associations = {ASSOCEXCL:[]} # Initialize list of all directories visited UI.AllDirs = []