This file is indexed.

/usr/lib/python3/dist-packages/drslib/mapfile.py is in python3-drslib 0.3.0a3-5.

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
# BSD Licence
# Copyright (c) 2011, Science & Technology Facilities Council (STFC)
# All rights reserved.
#
# See the LICENSE file in the source distribution of this software for
# the full license text.

"""
Generate mapfiles from streams of DRS objects

"""

from __future__ import print_function

#!TODO: check againsts similar code in datanode_admin and merge

import stat, os


def drs_to_id(drs):
    """
    Returns an esgpublish id for this drs object.

    The esgpublish id is a '.'-separated sequence of DRS components
    from the activity to realm level.
    
    """
    return '.'.join([drs.activity,
                     drs.product,
                     drs.institute,
                     drs.model,
                     drs.experiment,
                     drs.frequency,
                     drs.realm,
                     drs.table,
                     'r%di%dp%d' % drs.ensemble])

#!TODO: add callout to get parameters like checksum.
def write_mapfile(stream, fh):
    """
    Write an esgpublish mapfile from a stream of tuples (filepath, drs).

    """

    for path, drs in stream:
        file_stat = os.stat(path)
        size = file_stat[stat.ST_SIZE]
        mtime = file_stat[stat.ST_MTIME]

        print(' | '.join([drs_to_id(drs), path, str(size), "mod_time=%f"%float(mtime)]), file=fh)