This file is indexed.

/usr/lib/python3/dist-packages/openpyxl/benchmarks/styles.py is in python3-openpyxl 2.3.0-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
from __future__ import print_function

from itertools import product
from random import Random
from tempfile import TemporaryFile
import time

import openpyxl
from openpyxl.styles import Style, Alignment, Font


rand = Random()


def generate_all_styles():
    styles = []
    alignments = ['center', 'centerContinuous', 'general', 'justify', 'left',
                  'right']

    font_names = ['Calibri', 'Tahoma', 'Arial', 'Times New Roman']
    font_sizes = range(11, 36, 2)
    bold_options = [True, False]
    underline_options = [True, False]
    italic_options = [True, False]

    for alignment, name, size, bold, underline, italic in product(alignments,
                                                                  font_names,
                                                                  font_sizes,
                                                                  bold_options,
                                                                  underline_options,
                                                                  italic_options):
        s = Style(font=Font(name=name, size=size, italic=italic, underline=underline, bold=bold),
                  alignment=Alignment(horizontal=alignment, vertical=alignment))
        styles.append(s)
    return styles

styles = generate_all_styles()
n = 10000


def optimized_workbook(styles):
    wb = openpyxl.Workbook(optimized_write=True)
    worksheet = wb.create_sheet()
    for _ in range(1, n):
        style = rand.choice(styles)
        worksheet.append([(0, style)])
    return wb


def non_optimized_workbook(styles):
    wb = openpyxl.Workbook()
    for idx in range(1, n):
        worksheet = rand.choice(wb.worksheets)
        cell = worksheet.cell(column=1, row=(idx + 1))
        cell.value = 0
        cell.style = rand.choice(styles)
    return wb


def to_profile(wb, f, n):
    t = -time.time()
    wb.save(f)
    print('took %.4fs for %d styles' % (t + time.time(), n))

for func in (optimized_workbook, non_optimized_workbook):
    print('%s: ' % func.__name__, end='')
    wb = func(styles)
    f = TemporaryFile()
    to_profile(wb, f, n)