Coverage for gws-app/gws/base/printer/core.py: 100%

31 statements  

« prev     ^ index     » next       coverage.py v7.11.0, created at 2025-10-16 22:59 +0200

1from typing import Optional 

2 

3import gws 

4import gws.base.feature 

5import gws.base.model 

6import gws.base.template 

7import gws.config.util 

8import gws.lib.style 

9 

10gws.ext.new.printer('default') 

11 

12 

13class Config(gws.ConfigWithAccess): 

14 """Printer configuration""" 

15 

16 template: gws.ext.config.template 

17 """Print template""" 

18 title: str = '' 

19 """Printer title""" 

20 models: Optional[list[gws.ext.config.model]] 

21 """Data models""" 

22 qualityLevels: Optional[list[gws.TemplateQualityLevel]] 

23 """Quality levels supported by this printer""" 

24 

25 

26class Props(gws.Props): 

27 template: gws.base.template.Props 

28 model: gws.base.model.Props 

29 qualityLevels: list[gws.TemplateQualityLevel] 

30 title: str 

31 

32 

33class Object(gws.Printer): 

34 

35 def configure(self): 

36 gws.config.util.configure_models_for(self) 

37 self.template = self.create_child(gws.ext.object.template, self.cfg('template')) 

38 self.qualityLevels = self.cfg('qualityLevels') or [gws.TemplateQualityLevel(name='default', dpi=0)] 

39 self.title = self.cfg('title') or self.template.title or '' 

40 

41 def props(self, user): 

42 model = self.root.app.modelMgr.find_model(self, user=user, access=gws.Access.write) 

43 return Props( 

44 uid=self.uid, 

45 template=self.template, 

46 model=model, 

47 qualityLevels=self.qualityLevels, 

48 title=self.title, 

49 )