This file is indexed.

/usr/lib/python3/dist-packages/irclog2html/xchatlogsplit.py is in irclog2html 2.15.3-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
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
Split xchat2 log file into daily log files suitable as input for logs2html.py.

Usage: xchatlogsplit.py filename

XXX code is ugly

This is more of an example than a real script, although I have used it to
restore some actual IRC chat log history from my xchat logs.
"""

from __future__ import print_function

import sys
import time
import os
import re
import locale
from warnings import warn

STAMP_RX = re.compile(r'^[*][*][*][*] ((BEGIN|ENDING) LOGGING AT|(LOGINIMAS|ŽURNALAS) (PRADĖTAS|BAIGTAS)) ')

def readxchatlogs(infile):
    date = None
    ymd = None
    for line in infile:
        m = STAMP_RX.match(line)
        if m:
            stamp = line[len(m.group(0)):].strip()
            try:
                t = time.strptime(stamp, '%a %b %d %H:%M:%S %Y')
            except ValueError:
                locale.setlocale(locale.LC_TIME, "")
                t = time.strptime(stamp, '%a %b %d %H:%M:%S %Y')
                locale.setlocale(locale.LC_TIME, "C")

            ymd = t[:3]
            date = time.strftime("%Y-%m-%d", t)
        elif line.strip():
            assert date, 'what year?  got only %s' % line
            try:
                t = time.strptime(line[:len('Ddd YY HH:MM:SS'):], '%b %d %H:%M:%S')
            except ValueError:
                locale.setlocale(locale.LC_TIME, "")
                try:
                    t = time.strptime(stamp, '%a %b %d %H:%M:%S %Y')
                except:
                    warn("Skipping %s" % line.strip())
                    locale.setlocale(locale.LC_TIME, "C")
                    continue
                locale.setlocale(locale.LC_TIME, "C")
            t = (ymd[0], ) + t[1:]
            if t[:3] < ymd: # new year wraparound
                warn("Guessing that wraparound occurred: %s -> %s" % (ymd, t[:3]))
                t = (ymd[0] + 1, ) + t[1:]
            ymd = t[:3]
            date = time.strftime("%Y-%m-%d", t)
            line = line[len('Ddd YY '):]
        elif not date:
            continue

        assert date
        yield date, line

def main(argv=sys.argv):
    if len(argv) < 2:
        sys.exit(__doc__)
    filename = argv[1]
    prefix = os.path.basename(filename).split('-')[1].split('.')[0]
    dir = os.path.dirname(filename)
    prefix = os.path.join(dir, prefix)
    curdate = None
    outfile = None
    for date, line in readxchatlogs(file(filename)):
        if curdate != date:
            if outfile: outfile.close()
            curdate = date
            outfilename = prefix + "." + date + ".log"
            if os.path.exists(outfilename):
                sys.exit("refusing to overwrite %s" % outfilename)
            outfile = open(outfilename, "a")
        print(line, end=' ', file=outfile)
    if outfile: outfile.close()

if __name__ == '__main__':
    main()