X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sfatables%2Fsfatables;h=7f61a3f0346f5d355cb1f88e62c7c6236e56ef87;hb=342b9b05015e6a009d9dbccf559ae66334298b1f;hp=f4bb8a81536e9fefe43bcb4e8d0ba7b9bb4df4cb;hpb=b46f8ee1c69124fb2f99384ebb59c1f09fc459db;p=sfa.git diff --git a/sfatables/sfatables b/sfatables/sfatables index f4bb8a81..7f61a3f0 100755 --- a/sfatables/sfatables +++ b/sfatables/sfatables @@ -14,6 +14,7 @@ import libxml2 from optparse import OptionParser from sfatables import commands, matches, targets from sfatables.xmlextension import Xmlextension +from sfatables.globals import * def load_commands(module, list): command_dict={} @@ -25,11 +26,11 @@ def load_commands(module, list): return command_dict -def load_xml_extensions(module, list): +def load_xml_extensions(module, dir, list): ext_dict={} for ext_name in list: - module = Xmlextension(ext_name) + module = Xmlextension(dir, ext_name) ext_dict[ext_name]=module return ext_dict @@ -86,20 +87,21 @@ def main(): if (command.matches): if (len(pargs)<2): raise Exception("Must specify match for this command") - match_dict = load_xml_extensions("sfatables.matches",matches.all) + match_dict = load_xml_extensions("sfatables.matches",match_dir, matches.all) match_parser = create_parser_xml_ext(match_dict) matches_str = ",".join(match_dict.keys()) - match_parser.add_option('-m','--match',dest='match_name',help='Match name (one of %s)'%matches_str, metavar = 'MATCH') + match_parser.add_option('-m','--match',dest='name',help='Match name (one of %s)'%matches_str, metavar = 'MATCH') + match_parser.add_option('-n','--negate',dest='negate',help='Negate result',action='store_true') (match_options, args) = match_parser.parse_args(pargs[1]) try: - match_name = match_options.match_name + name = match_options.name except Exception: print "Must specify match name with -m" - if (match_dict.has_key(match_name)): - setattr(match_options, 'arguments', match_dict[match_name].arguments) + if (match_dict.has_key(name)): + setattr(match_options, 'arguments', match_dict[name].arguments) else: - raise Exception('Match %s not found'%match_name) + raise Exception('Match %s not found'%name) else: match_options=None @@ -107,20 +109,20 @@ def main(): if (command.targets): if (len(pargs)<3): raise Exception("Must specify a target for this command") - target_dict = load_xml_extensions("sfatables.targets",targets.all) + target_dict = load_xml_extensions("sfatables.targets",target_dir,targets.all) target_parser = create_parser_xml_ext(target_dict) targets_str = ",".join(target_dict.keys()) - target_parser.add_option('-j','--jump',dest='target_name',help='Target name (one of %s)'%targets, metavar = 'TARGET') + target_parser.add_option('-j','--jump',dest='name',help='Target name (one of %s)'%targets, metavar = 'TARGET') (target_options, args) = target_parser.parse_args(pargs[2]) try: - target_name = target_options.target_name + name = target_options.name except Exception: print "Must specify target name with -m" -# if (target_dict.has_key(target_name)): -# setattr(target_options, 'arguments', target_dict[target_name].arguments) -# else: -# raise Exception('Target %s not found'%target_name) + if (target_dict.has_key(name)): + setattr(target_options, 'arguments', target_dict[name].arguments) + else: + raise Exception('Target %s not found'%name) else: target_options = None