This file is indexed.

/usr/lib/python2.7/dist-packages/pgxnclient/archive.py is in pgxnclient 1.2.1-3.

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
"""
pgxnclient -- archives handling
"""

# Copyright (C) 2011-2012 Daniele Varrazzo

# This file is part of the PGXN client

import os

from pgxnclient.i18n import _
from pgxnclient.utils import load_jsons
from pgxnclient.errors import PgxnClientException

def from_spec(spec):
    """Return an `Archive` instance to handle the file requested by *spec*
    """
    assert spec.is_file()
    return from_file(spec.filename)

def from_file(filename):
    """Return an `Archive` instance to handle the file *filename*
    """
    from pgxnclient.zip import ZipArchive
    from pgxnclient.tar import TarArchive

    for cls in (ZipArchive, TarArchive):
        a = cls(filename)
        if a.can_open():
            return a

    raise PgxnClientException(
        _("can't open archive '%s': file type not recognized")
        % filename)


class Archive(object):
    """Base class to handle archives."""
    def __init__(self, filename):
        self.filename = filename

    def can_open(self):
        """Return `!True` if the `!filename` can be opened by the obect."""
        raise NotImplementedError

    def open(self):
        """Open the archive for usage.

        Raise PgxnClientException if the archive can't be open.
        """
        raise NotImplementedError

    def close(self):
        """Close the archive after usage."""
        raise NotImplementedError

    def list_files(self):
        """Return an iterable with the list of file names in the archive."""
        raise NotImplementedError

    def read(self, fn):
        """Return a file's data from the archive."""
        raise NotImplementedError

    def unpack(self, destdir):
        raise NotImplementedError

    def get_meta(self):
        filename = self.filename

        self.open()
        try:
            # Return the first file with the expected name
            for fn in self.list_files():
                if fn.endswith('META.json'):
                    return load_jsons(self.read(fn).decode('utf8'))
            else:
                raise PgxnClientException(
                    _("file 'META.json' not found in archive '%s'") % filename)
        finally:
            self.close()

    def _find_work_directory(self, destdir):
        """
        Choose the directory where to work.

        Because we are mostly a wrapper for pgxs, let's look for a makefile.
        The tar should contain a single base directory, so return the first
        dir we found containing a Makefile, alternatively just return the
        unpacked dir
        """
        for dir in os.listdir(destdir):
            for fn in ('Makefile', 'makefile', 'GNUmakefile', 'configure'):
                if os.path.exists(os.path.join(destdir, dir, fn)):
                    return os.path.join(destdir, dir)

        return destdir