/usr/lib/python2.7/dist-packages/openpyxl/formatting/formatting.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 | from __future__ import absolute_import
# Copyright (c) 2010-2017 openpyxl
from openpyxl.compat import OrderedDict
from openpyxl.descriptors import (
Bool,
String,
Sequence,
Alias,
)
from openpyxl.descriptors.excel import ExtensionList
from openpyxl.descriptors.serialisable import Serialisable
from .rule import Rule
class ConditionalFormatting(Serialisable):
tagname = "conditionalFormatting"
sqref = String(allow_none=True)
pivot = Bool(allow_none=True)
cfRule = Sequence(expected_type=Rule)
rules = Alias("cfRule")
def __init__(self, sqref=None, pivot=None, cfRule=(), extLst=None):
self.sqref = sqref
self.pivot = pivot
self.cfRule = cfRule
class ConditionalFormattingList(object):
"""Conditional formatting rules."""
def __init__(self):
self.cf_rules = OrderedDict()
self.max_priority = 0
def add(self, range_string, cfRule):
"""Add a rule such as ColorScaleRule, FormulaRule or CellIsRule
The priority will be added automatically.
"""
if not isinstance(cfRule, Rule):
raise ValueError("Only instances of openpyxl.formatting.rule.Rule may be added")
rule = cfRule
self.max_priority += 1
if not rule.priority:
rule.priority = self.max_priority
self.cf_rules.setdefault(range_string, []).append(rule)
def __bool__(self):
return bool(self.cf_rules)
__nonzero = __bool__
def __iter__(self):
for cell_range, rules in self.cf_rules.items():
yield ConditionalFormatting(sqref=cell_range, cfRule=rules)
|