/usr/lib/python2.7/dist-packages/openpyxl/styles/fonts.py is in python-openpyxl 2.4.9-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | from __future__ import absolute_import
# Copyright (c) 2010-2017 openpyxl
from openpyxl.descriptors import (
Alias,
Sequence,
Integer
)
from openpyxl.descriptors.serialisable import Serialisable
from openpyxl.descriptors.nested import (
NestedValue,
NestedBool,
NestedNoneSet,
NestedMinMax,
NestedString,
NestedInteger,
NestedFloat,
)
from .colors import ColorDescriptor, Color, BLACK
from openpyxl.compat import safe_string
from openpyxl.xml.functions import Element, SubElement
from openpyxl.xml.constants import SHEET_MAIN_NS
def _no_value(tagname, value, namespace=None):
if value:
return Element(tagname, val=safe_string(value))
class Font(Serialisable):
"""Font options used in styles."""
UNDERLINE_DOUBLE = 'double'
UNDERLINE_DOUBLE_ACCOUNTING = 'doubleAccounting'
UNDERLINE_SINGLE = 'single'
UNDERLINE_SINGLE_ACCOUNTING = 'singleAccounting'
name = NestedString(allow_none=True)
charset = NestedInteger(allow_none=True)
family = NestedMinMax(min=0, max=14, allow_none=True)
sz = NestedFloat(allow_none=True)
size = Alias("sz")
b = NestedBool(to_tree=_no_value)
bold = Alias("b")
i = NestedBool(to_tree=_no_value)
italic = Alias("i")
strike = NestedBool(allow_none=True)
strikethrough = Alias("strike")
outline = NestedBool(allow_none=True)
shadow = NestedBool(allow_none=True)
condense = NestedBool(allow_none=True)
extend = NestedBool(allow_none=True)
u = NestedNoneSet(values=('single', 'double', 'singleAccounting',
'doubleAccounting'))
underline = Alias("u")
vertAlign = NestedNoneSet(values=('superscript', 'subscript', 'baseline'))
color = ColorDescriptor(allow_none=True)
scheme = NestedNoneSet(values=("major", "minor"))
tagname = "font"
__elements__ = ('name', 'charset', 'family', 'b', 'i', 'strike', 'outline',
'shadow', 'condense', 'color', 'extend', 'sz', 'u', 'vertAlign',
'scheme')
def __init__(self, name=None, sz=None, b=None, i=None, charset=None,
u=None, strike=None, color=None, scheme=None, family=None, size=None,
bold=None, italic=None, strikethrough=None, underline=None,
vertAlign=None, outline=None, shadow=None, condense=None,
extend=None):
self.name = name
self.family = family
if size is not None:
sz = size
self.sz = sz
if bold is not None:
b = bold
self.b = b
if italic is not None:
i = italic
self.i = i
if underline is not None:
u = underline
self.u = u
if strikethrough is not None:
strike = strikethrough
self.strike = strike
self.color = color
self.vertAlign = vertAlign
self.charset = charset
self.outline = outline
self.shadow = shadow
self.condense = condense
self.extend = extend
self.scheme = scheme
@classmethod
def from_tree(cls, node):
"""
Set default value for underline if child element is present
"""
underline = node.find("{%s}u" % SHEET_MAIN_NS)
if underline is not None and underline.get('val') is None:
underline.set("val", "single")
return super(Font, cls).from_tree(node)
DEFAULT_FONT = Font(name="Calibri", sz=11, family=2, b=False, i=False,
color=Color(theme=1), scheme="minor")
|