Coverage for gws-app/gws/plugin/model_value/format/__init__.py: 0%

12 statements  

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

1"""Format value. 

2 

3Computes a string by applying a Python format string to the feature 

4attributes, using ``gws.u.format_map``. 

5 

6Example:: 

7 

8 fields+ { 

9 name "label" 

10 type "text" 

11 values+ { type "format" format "{street} {house_number}" } 

12 } 

13""" 

14 

15import gws 

16import gws.base.model.value 

17 

18 

19@gws.ext.config.modelValue('format') 

20class Config(gws.base.model.value.Config): 

21 """Value computed by a format string over feature attributes.""" 

22 

23 format: str 

24 """Format string to apply to feature attributes.""" 

25 

26 

27@gws.ext.object.modelValue('format') 

28class Object(gws.base.model.value.Object): 

29 """Format value object.""" 

30 

31 format: str 

32 """Format string.""" 

33 

34 def configure(self): 

35 self.format = self.cfg('format') 

36 

37 def compute(self, field, feature, mc): 

38 return gws.u.format_map(self.format, feature.attributes)