completed parser for the data sources
This commit is contained in:
parent
c38d163d23
commit
e996bfb5bf
|
@ -32,11 +32,3 @@ class ConstructionCatalogFactory:
|
|||
:return: Catalog
|
||||
"""
|
||||
return getattr(self, self._catalog_type, lambda: None)
|
||||
|
||||
@property
|
||||
def catalog_debug(self) -> Catalog:
|
||||
"""
|
||||
Enrich the city given to the class using the class given handler
|
||||
:return: Catalog
|
||||
"""
|
||||
return NrelCatalog(self._path)
|
|
@ -214,10 +214,28 @@ class ComnetCatalog(Catalog):
|
|||
return total / 365
|
||||
|
||||
def names(self, category=None):
|
||||
pass
|
||||
"""
|
||||
Get the catalog elements names
|
||||
:parm: for usage catalog category filter does nothing as there is only one category (usages)
|
||||
"""
|
||||
_names = {'usages': []}
|
||||
for usage in self._content.usages:
|
||||
_names['usages'].append(usage.usage)
|
||||
return _names
|
||||
|
||||
def entries(self, category=None):
|
||||
pass
|
||||
"""
|
||||
Get the catalog elements
|
||||
:parm: for usage catalog category filter does nothing as there is only one category (usages)
|
||||
"""
|
||||
return self._content
|
||||
|
||||
def get_entry(self, name):
|
||||
pass
|
||||
"""
|
||||
Get one catalog element by names
|
||||
:parm: entry name
|
||||
"""
|
||||
for usage in self._content.usages:
|
||||
if usage.usage.lower() == name.lower():
|
||||
return usage
|
||||
raise IndexError(f"{name} doesn't exists in the catalog")
|
||||
|
|
|
@ -13,3 +13,5 @@ class TestConstructionCatalog(TestCase):
|
|||
def test_comnet_catalog(self):
|
||||
catalog = UsageCatalogFactory('comnet').catalog
|
||||
self.assertIsNotNone(catalog, 'catalog is none')
|
||||
content = catalog.entries()
|
||||
self.assertEqual(len(content.usages), 33, 'Wrong number of usages')
|
||||
|
|
Loading…
Reference in New Issue
Block a user