This file is indexed.

/usr/share/pyshared/instant/paths.py is in python-instant 1.0.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
70
71
72
73
74
75
76
77
78
79
80
81
"""This module contains helper functions for working with temp and cache directories."""

# Utilities for directory handling:

import os
import shutil
import tempfile
import time
from output import instant_debug, instant_assert

_tmp_dir = None
def get_temp_dir():
    """Return a temporary directory for the duration of this process.
    
    Multiple calls in the same process returns the same directory.
    Remember to all delete_temp_dir() before exiting."""
    global _tmp_dir
    if _tmp_dir is None:
        datestring = "%d-%d-%d-%02d-%02d" % time.localtime()[:5]
        suffix = datestring + "_instant"
        _tmp_dir = tempfile.mkdtemp(suffix)
        instant_debug("Created temp directory '%s'." % _tmp_dir)
    return _tmp_dir

def delete_temp_dir():
    """Delete the temporary directory created by get_temp_dir()."""
    global _tmp_dir
    if _tmp_dir and os.path.isdir(_tmp_dir):
        shutil.rmtree(_tmp_dir, ignore_errors=True)
    _tmp_dir = None

def get_instant_dir():
    "Return a temporary directory for the duration of this process."
    # os.path.expanduser works for Windows, Linux, and Mac
    # In Windows, $HOME is os.environ['HOMEDRIVE'] + os.environ['HOMEPATH']
    instant_dir = os.path.join(os.path.expanduser("~"), ".instant")
    if not os.path.isdir(instant_dir):
        instant_debug("Creating instant directory '%s'." % instant_dir)
        os.mkdir(instant_dir)
    return instant_dir

def get_default_cache_dir():
    "Return the default cache directory."
    if "INSTANT_CACHE_DIR" in os.environ:
        cache_dir = os.environ["INSTANT_CACHE_DIR"]
    else:
        cache_dir = os.path.join(get_instant_dir(), "cache")
    if not os.path.isdir(cache_dir):
        instant_debug("Creating cache directory '%s'." % cache_dir)
        os.mkdir(cache_dir)
    return cache_dir

def get_default_error_dir():
    "Return the default cache directory."
    if "INSTANT_ERROR_DIR" in os.environ:
        cache_dir = os.environ["INSTANT_ERROR_DIR"]
    else:
        cache_dir = os.path.join(get_instant_dir(), "error")
    if not os.path.isdir(cache_dir):
        instant_debug("Creating cache directory '%s'." % cache_dir)
        os.mkdir(cache_dir)
    return cache_dir

def validate_cache_dir(cache_dir):
    if cache_dir is None:
        return get_default_cache_dir()
    instant_assert(isinstance(cache_dir, str), "Expecting cache_dir to be a string.")
    cache_dir = os.path.abspath(cache_dir)
    if not os.path.isdir(cache_dir):
        os.mkdir(cache_dir)
    return cache_dir

def _test():
    print "Temp dir:", get_temp_dir()
    print "Instant dir:", get_instant_dir()
    print "Default cache dir:", get_default_cache_dir()
    print "Default error dir:", get_default_error_dir()
    delete_temp_dir()
   
if __name__ == "__main__":
    _test()