Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/styles/alignment.py: 74%

43 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1# Copyright (c) 2010-2022 openpyxl 

2 

3from openpyxl.compat import safe_string 

4 

5from openpyxl.descriptors import Bool, MinMax, Min, Alias, NoneSet 

6from openpyxl.descriptors.serialisable import Serialisable 

7 

8 

9horizontal_alignments = ( 

10 "general", "left", "center", "right", "fill", "justify", "centerContinuous", 

11 "distributed", ) 

12vertical_aligments = ( 

13 "top", "center", "bottom", "justify", "distributed", 

14) 

15 

16class Alignment(Serialisable): 

17 """Alignment options for use in styles.""" 

18 

19 tagname = "alignment" 

20 

21 __fields__ = ('horizontal', 

22 'vertical', 

23 'textRotation', 

24 'wrapText', 

25 'shrinkToFit', 

26 'indent', 

27 'relativeIndent', 

28 'justifyLastLine', 

29 'readingOrder', 

30 ) 

31 horizontal = NoneSet(values=horizontal_alignments) 

32 vertical = NoneSet(values=vertical_aligments) 

33 textRotation = NoneSet(values=range(181)) 

34 textRotation.values.add(255) 

35 text_rotation = Alias('textRotation') 

36 wrapText = Bool(allow_none=True) 

37 wrap_text = Alias('wrapText') 

38 shrinkToFit = Bool(allow_none=True) 

39 shrink_to_fit = Alias('shrinkToFit') 

40 indent = MinMax(min=0, max=255) 

41 relativeIndent = MinMax(min=-255, max=255) 

42 justifyLastLine = Bool(allow_none=True) 

43 readingOrder = Min(min=0) 

44 

45 def __init__(self, horizontal=None, vertical=None, 

46 textRotation=0, wrapText=None, shrinkToFit=None, indent=0, relativeIndent=0, 

47 justifyLastLine=None, readingOrder=0, text_rotation=None, 

48 wrap_text=None, shrink_to_fit=None, mergeCell=None): 

49 self.horizontal = horizontal 

50 self.vertical = vertical 

51 self.indent = indent 

52 self.relativeIndent = relativeIndent 

53 self.justifyLastLine = justifyLastLine 

54 self.readingOrder = readingOrder 

55 if text_rotation is not None: 55 ↛ 56line 55 didn't jump to line 56, because the condition on line 55 was never true

56 textRotation = text_rotation 

57 if textRotation is not None: 57 ↛ 59line 57 didn't jump to line 59, because the condition on line 57 was never false

58 self.textRotation = int(textRotation) 

59 if wrap_text is not None: 59 ↛ 60line 59 didn't jump to line 60, because the condition on line 59 was never true

60 wrapText = wrap_text 

61 self.wrapText = wrapText 

62 if shrink_to_fit is not None: 62 ↛ 63line 62 didn't jump to line 63, because the condition on line 62 was never true

63 shrinkToFit = shrink_to_fit 

64 self.shrinkToFit = shrinkToFit 

65 # mergeCell is vestigial 

66 

67 

68 def __iter__(self): 

69 for attr in self.__attrs__: 

70 value = getattr(self, attr) 

71 if value is not None and value != 0: 

72 yield attr, safe_string(value)