2 from sfa.util.xml import XML
3 from sfa.util.config import Config
8 required_fields = ['version', 'url']
10 template = """<api_versions>
11 <api_version name="" version="" url="" />
14 def __init__(self, string=None, filename=None, create=False):
24 # load the default file
26 api_versions_file = os.path.sep.join(
27 [c.config_path, 'api_versions.xml'])
28 self.load(api_versions_file)
31 self.xml = XML(string=ApiVersions.template)
33 def load(self, source):
34 self.xml = XML(source)
36 def get_versions(self):
38 for value in self.xml.todict().values():
41 if isinstance(value, list):
43 if isinstance(item, dict) and \
44 set(ApiVersions.required_fields).issubset(item.keys()) and \
45 item['version'] != '' and item['url'] != '':
46 versions[str(item['version'])] = item['url']