cambios a metodo de consulta de codelist
FossilOrigin-Name: f127cde5990855880e481d75cd3c8fe27de0bcb534ce29dee889a630fa8e9d9b
This commit is contained in:
		| @@ -8,14 +8,15 @@ DATA_DIR = os.path.dirname(os.path.abspath(__file__)) | ||||
|  | ||||
| class CodeList: | ||||
|  | ||||
|     def __init__(self, filename, primary_column): | ||||
|     def __init__(self, filename, primary_column, name_column): | ||||
|         self.short_name = '' | ||||
|         self.long_name = '' | ||||
|         self.version = 1 | ||||
|         self.canonical_uri = '' | ||||
|         self.canonical_version_uri = '' | ||||
|         self.location_uri = '' | ||||
|          | ||||
|  | ||||
|         self.name_column = name_column | ||||
|         self.rows = {} | ||||
|         self._load(filename, primary_column) | ||||
|  | ||||
| @@ -49,6 +50,12 @@ class CodeList: | ||||
|         return self.rows[str(key)] | ||||
|  | ||||
|  | ||||
|     def by_name(self, name): | ||||
|         for k, v in self.rows.items(): | ||||
|             if v[self.name_column] == name: | ||||
|                 return v | ||||
|         raise KeyError | ||||
|      | ||||
| # nombres de variables igual a ./Identification/ShortName | ||||
| # TODO: garantizar unica carga en python | ||||
|  | ||||
| @@ -59,7 +66,7 @@ __all__ = ['TipoOrganizacion', | ||||
| def path_for_codelist(name): | ||||
|     return os.path.join(DATA_DIR, name) | ||||
|  | ||||
| TipoOrganizacion = CodeList(path_for_codelist('TipoOrganizacion-2.1.gc'), 'name') | ||||
| TipoResponsabilidad = CodeList(path_for_codelist('TipoResponsabilidad-2.1.gc'), 'name') | ||||
| TipoAmbiente = CodeList(path_for_codelist('TipoAmbiente-2.1.gc'), 'name') | ||||
| TipoDocumento = CodeList(path_for_codelist('TipoDocumento-2.1.gc'), 'name') | ||||
| TipoOrganizacion = CodeList(path_for_codelist('TipoOrganizacion-2.1.gc'), 'code', 'name') | ||||
| TipoResponsabilidad = CodeList(path_for_codelist('TipoResponsabilidad-2.1.gc'), 'code', 'name') | ||||
| TipoAmbiente = CodeList(path_for_codelist('TipoAmbiente-2.1.gc'), 'code', 'name') | ||||
| TipoDocumento = CodeList(path_for_codelist('TipoDocumento-2.1.gc'), 'code', 'name') | ||||
|   | ||||
		Reference in New Issue
	
	Block a user