Commits

abudden committed e3bf11f

Fixed python debug and added method of determining whether default value
was explicitly set or not.

  • Participants
  • Parent commits 5a81acc

Comments (0)

Files changed (7)

autoload/TagHighlight/RunPythonScript.vim

 				endif
 			endif
 		endfor
+		exe PY 'manually_set = ' string(handled_options)
 		for check_opt in keys(a:options)
 			if index(handled_options, check_opt) == -1
 				call TagHLDebug("Unhandled run option: " . check_opt, "Information")
 			endif
 		endfor
-		exe PY 'RunWithOptions(options)'
+		exe PY 'RunWithOptions(options, manually_set)'
 	elseif index(["python","compiled"], s:python_variant) != -1
 		let args = s:python_cmd[:]
 		" We're calling the script externally, build a list of arguments

plugin/TagHighlight/TagHighlight.py

 def main():
     from module.cmd import ProcessCommandLine
     from module.worker import RunWithOptions
-    options = ProcessCommandLine()
-    RunWithOptions(options)
+    options, manually_set = ProcessCommandLine()
+    RunWithOptions(options, manually_set)
 
 if __name__ == "__main__":
     main()

plugin/TagHighlight/module/cmd.py

 
 def ProcessCommandLine():
     parser = optparse.OptionParser()
+    pyoptions = []
 
     for dest in AllOptions.keys():
         if 'CommandLineSwitches' not in AllOptions[dest]:
             # Vim-only option
             continue
+        if AllOptions[dest]['Default'] == 'None':
+            AllOptions[dest]['Default'] = None
+
+        pyoptions.append(dest)
         if not isinstance(AllOptions[dest]['CommandLineSwitches'], list):
             AllOptions[dest]['CommandLineSwitches'] = AllOptions[dest]['CommandLineSwitches'].split(',')
+
         if AllOptions[dest]['Type'] == 'bool':
             if AllOptions[dest]['Default'] == True:
                 action = 'store_false'
                 action = 'store_true'
             parser.add_option(*AllOptions[dest]['CommandLineSwitches'],
                     action=action,
-                    default=AllOptions[dest]['Default'],
+                    default='DEFAULT_OPTION_USED',
                     dest=dest,
                     help=AllOptions[dest]['Help'])
         else:
                 action='append'
             else:
                 # TODO: This needs handling somehow
+                pyoptions.remove(dest)
                 continue
                 raise Exception('Unrecognised option type: ' + AllOptions[dest]['Type'])
             parser.add_option(*AllOptions[dest]['CommandLineSwitches'],
                     action=action,
-                    default=AllOptions[dest]['Default'],
+                    default='DEFAULT_OPTION_USED',
                     type=optparse_type,
                     dest=dest,
                     help=AllOptions[dest]['Help'])
 
     options, remainder = parser.parse_args()
+    manually_set = []
+    optdict = vars(options)
 
-    return vars(options)
+    for dest in pyoptions:
+        if optdict[dest] == 'DEFAULT_OPTION_USED':
+            optdict[dest] = AllOptions[dest]['Default']
+        else:
+            manually_set.append(dest)
+
+    return optdict, manually_set

plugin/TagHighlight/module/config.py

                 'revision_id': 'Unreleased',
                 }
 
-def SetInitialOptions(new_options):
+def SetInitialOptions(new_options, manual_options):
     global config
     for key in new_options:
         config[key] = new_options[key]
         SetDebugLogLevel(config['DebugLevel'])
     if 'DebugFile' in config:
         SetDebugLogFile(config['DebugFile'])
+    config['ManuallySetOptions'] = manual_options
 
 def LoadLanguages():
     global config

plugin/TagHighlight/module/ctags_interface.py

     # now so that argument globs work correctly.
     os.chdir(options['SourceDir'])
 
-    if 'CtagsArguments' in options:
+    if 'CtagsArguments' in options['ManuallySetOptions']:
         args = options['CtagsArguments']
     else:
-        if 'CtagsVariant' in options:
+        if 'CtagsVariant' in options['ManuallySetOptions']:
             variant = options['CtagsVariant']
         else:
             variant = 'exuberant'

plugin/TagHighlight/module/debug.py

 
 import os
 
-debug_log_levels = ('Critical', 'Error', 'Warning', 'Status', 'Information', 'None')
+debug_log_levels = ('None', 'Critical', 'Error', 'Warning', 'Status', 'Information')
 debug_log_file = None
 debug_log_level = 'None'
 

plugin/TagHighlight/module/worker.py

 import sys
 import os
 
-def RunWithOptions(options):
+def RunWithOptions(options, manually_set=[]):
     start_directory = os.getcwd()
     from .config import config, SetInitialOptions, LoadLanguages
     from .debug import Debug
 
-    SetInitialOptions(options)
+    SetInitialOptions(options, manually_set)
 
     Debug("Running types highlighter generator", "Information")
     Debug("Release:" + config['Release'], "Information")