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

32 statements  

« prev     ^ index     » next       coverage.py v7.8.0, created at 2025-04-17 01:37 +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.job 

9import gws.lib.style 

10 

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

12 

13 

14class Config(gws.Config): 

15 """Printer configuration""" 

16 

17 template: gws.ext.config.template 

18 """Print template""" 

19 title: str = '' 

20 """Printer title""" 

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

22 """Data models""" 

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

24 """Quality levels supported by this printer""" 

25 

26 

27class Props(gws.Props): 

28 template: gws.base.template.Props 

29 model: gws.base.model.Props 

30 qualityLevels: list[gws.TemplateQualityLevel] 

31 title: str 

32 

33 

34class Object(gws.Printer): 

35 

36 def configure(self): 

37 gws.config.util.configure_models_for(self) 

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

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

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

41 

42 def props(self, user): 

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

44 return Props( 

45 uid=self.uid, 

46 template=self.template, 

47 model=model, 

48 qualityLevels=self.qualityLevels, 

49 title=self.title, 

50 )