X-Git-Url: http://git.onelab.eu/?p=sfa.git;a=blobdiff_plain;f=sfatables%2Fsfatables;h=0693020d380c5d64a0533cd5cb52e55a3b7558aa;hp=2f20f3f9de5f8727ffcb2f263b8c604f2bf7ef68;hb=e57b7150dee76d42fc15f9477a3045e5171c8878;hpb=4b2e86d099a60df5fb6b9732c080a3d10512c029 diff --git a/sfatables/sfatables b/sfatables/sfatables index 2f20f3f9..0693020d 100755 --- a/sfatables/sfatables +++ b/sfatables/sfatables @@ -9,10 +9,11 @@ import sys import os import pdb +import glob import libxml2 from optparse import OptionParser -from sfatables import commands, matches, targets +from sfatables import commands from sfatables.xmlextension import Xmlextension from sfatables.globals import * @@ -26,12 +27,16 @@ def load_commands(module, list): return command_dict -def load_xml_extensions(module, dir, list): +def load_xml_extensions(module, ext_dir): ext_dict={} - for ext_name in list: - module = Xmlextension(dir, ext_name) + exts = glob.glob(ext_dir + os.path.sep + "*") + for ext in exts: + module = Xmlextension(ext) + # get the filename and get rid of the ".xml" extension + ext_name = os.path.extsep.join(os.path.splitext(os.path.basename(ext))[:-1]) ext_dict[ext_name]=module + print "Loaded:", ext_name, ext return ext_dict @@ -87,7 +92,7 @@ def main(): if (command.matches): if (len(pargs)<2): raise Exception("Must specify match for this command") - match_dict = load_xml_extensions("sfatables.matches",match_dir, matches.all) + match_dict = load_xml_extensions("sfatables.matches",match_dir) match_parser = create_parser_xml_ext(match_dict) matches_str = ",".join(match_dict.keys()) match_parser.add_option('-m','--match',dest='name',help='Match name (one of %s)'%matches_str, metavar = 'MATCH') @@ -109,10 +114,10 @@ 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",target_dir,targets.all) + target_dict = load_xml_extensions("sfatables.targets",target_dir) target_parser = create_parser_xml_ext(target_dict) targets_str = ",".join(target_dict.keys()) - target_parser.add_option('-j','--jump',dest='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_str, metavar = 'TARGET') target_parser.add_option('-e','--element',dest='element',help='Element name', metavar = 'ELEMENT') (target_options, args) = target_parser.parse_args(pargs[2]) try: