Coverage for gws-app/gws/base/metadata/__init__.py: 100%

2 statements  

« prev     ^ index     » next       coverage.py v7.16.2, created at 2026-10-05 13:35 +0200

1"""OWS and ISO 19115 metadata. 

2 

3Metadata describes an object (the application, a project, a layer, an OWS 

4service) for the client, for OWS capabilities documents and for CSW catalog 

5records. It is held in a flat ``gws.Metadata`` data object. The structure is 

6based on: 

7 

8- ISO 19115:2003 Geographic information -- Metadata 

9- ISO 19139 - Geographic Information - Metadata - XML Schema Implementation 

10- OGC Web Services Common Standard OGC 06-121r9 

11- Web Map Server Implementation Specification OGC 06-042 

12- Web Feature Service 2.0 Interface Standard OGC 09-025r1 

13 

14Submodules: 

15 

16- ``core``: the metadata ``Config`` and ``Props`` and the functions that create, 

17 merge and convert metadata objects. ``new`` creates an empty object; 

18 ``from_dict``, ``from_config``, ``from_props`` and ``from_args`` create one 

19 from other sources; ``update`` merges values into an existing object; 

20 ``normalize`` returns a cleaned copy; ``props`` converts metadata to client 

21 props; ``keyword_groups`` groups keywords by vocabulary for OWS output. 

22 Merging is done key by key: later sources override earlier ones, except for 

23 ``keywords`` and ``isoTopicCategories``, which are combined. Date values are 

24 parsed to ``datetime`` objects, and the derived language codes and INSPIRE 

25 theme names are filled in on every update. 

26- ``inspire``: INSPIRE code lists as enums and the names and definitions of 

27 INSPIRE data themes. 

28- ``iso``: ISO 19115 code lists as enums. 

29- ``inspire_generate``: a script that downloads the INSPIRE theme register and 

30 regenerates the theme part of ``inspire``. It is not imported. 

31 

32Example:: 

33 

34 metadata { 

35 title "Roads" 

36 abstract "Road network of the city" 

37 keywords [ "roads" "transport" ] 

38 language "en" 

39 inspireTheme "tn" 

40 isoTopicCategories [ "transportation" ] 

41 } 

42 

43Usage in Python:: 

44 

45 md = gws.base.metadata.from_args(app_metadata, self.cfg('metadata')) 

46 md = gws.base.metadata.update(md, title='Roads') 

47 for kg in gws.base.metadata.keyword_groups(md): 

48 print(kg.codeSpace, kg.keywords) 

49""" 

50 

51from .core import ( 

52 Config, 

53 Props, 

54 props, 

55 from_args, 

56 from_config, 

57 from_dict, 

58 from_props, 

59 update, 

60 normalize, 

61 new, 

62 keyword_groups, 

63 KeywordGroup, 

64) 

65 

66from . import inspire, iso