This file is indexed.

/usr/lib/python2.7/dist-packages/zhpy/interpreter.py is in python-zhpy 1.7.3.1-1.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
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# -*- coding: utf-8 -*-

"""zhpy interactive interpretor

This is the MIT license:
http://www.opensource.org/licenses/mit-license.php

Copyright (c) 2007~ Fred Lin and contributors. zhpy is a trademark of Fred Lin.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""


from code import InteractiveConsole
from zhpy import convertor
import sys

class ZhPyConsole(InteractiveConsole):
    """
    Wrapper around Python and filter input/output to the shell
    """

    def push(self, line):
        self.buffer.append(line)
        source = "\n".join(self.buffer)
        #windows patch
        encoding = sys.stdout.encoding
        if encoding == 'cp950':
            encoding = ''

        more = self.runsource(convertor(source, encoding=encoding),
                            self.filename)
        if not more:
            self.resetbuffer()
        return more

try:
    from release import version
except:
    version = 'core'


def interpreter(lang=None):
    """
    zhpy interpreter

Accept args:
    lang:
        interpreter language
    """
    try:
        import readline
    except ImportError:
        pass
    else:
        import rlcompleter
        """Indentable rlcompleter"""
        class irlcompleter(rlcompleter.Completer):
            def complete(self, text, state):
                #print text, state, str(type(text))
                if text == "":
                    #replace tab to 4 spaces
                    return ['    ', None][state]
                elif lang == 'tw':
                    if text in ["印","pri","prin","print"]:
                        return ['印出'][state]
                    elif text == "for":
                        return ['取'][state]
                    elif text == 'in':
                        return ['自'][state]
                    elif text in ['範', 'ran', 'rang', 'range']:
                        return ['範圍'][state]
                    elif text in ["定","def"]:
                        return ['定義'][state]
                    elif text in ["類", "cla", "clas", "class"]:
                        return ['類別'][state]
                    elif text in ["導", "imp", "impo", "impor", "import"]:
                        return ['導入'][state]
                    elif text in ["返", "ret", "retu", "retur", "return"]:
                        return ['返回'][state]
                    elif text in ["fro", "from"]:
                        return ['從'][state]
                    elif text in ["作", "as"]:
                        return ['作為'][state]
                    elif text in ['如', 'if']:
                        return ['如果'][state]
                    elif text in ['假', 'eli', 'elif']:
                        return ['假使'][state]
                    elif text in ['否', 'els', 'else']:
                        return ['否則'][state]
                    elif text in ['Non', 'None']:
                        return ['空'][state]
                elif lang == 'cn':
                    if text in ["打","pri","prin","print"]:
                        return ['打印'][state]
                    elif text == "for":
                        return ['取'][state]
                    elif text == 'in':
                        return ['自'][state]
                    elif text in ['范', 'ran', 'rang', 'range']:
                        return ['范围'][state]
                    elif text in ["定","def"]:
                        return ['定义'][state]
                    elif text in ["类", "cla", "clas", "class"]:
                        return ['类'][state]
                    elif text in ["导", "imp", "impo", "impor", "import"]:
                        return ['导入'][state]
                    elif text in ["返", "ret", "retu", "retur", "return"]:
                        return ['返回'][state]
                    elif text in ["fro", "from"]:
                        return ['从'][state]
                    elif text in ["作", "as"]:
                        return ['作为'][state]
                    elif text in ['如', 'if']:
                        return ['如果'][state]
                    elif text in ['假', 'eli', 'elif']:
                        return ['假使'][state]
                    elif text in ['否', 'els', 'else']:
                        return ['否则'][state]
                    elif text in ['Non', 'None']:
                        return ['空'][state]
                else:
                    return rlcompleter.Completer.complete(self,text,state)

        #you could change this line to bind another key instead tab.
        readline.parse_and_bind("tab: complete")
        readline.set_completer(irlcompleter().complete)
    con = ZhPyConsole()
    if lang == 'tw':
        banner = '周蟒 %s%s 基於 Python %s'%(version, sys.platform,
                                                  sys.version.split()[0])
        if sys.platform == 'win32':
            banner = unicode(banner, 'utf-8').encode(sys.stdout.encoding)
    elif lang == 'cn':
        banner = '周蟒 %s%s 基于 Python %s'%(version, sys.platform,
                                                  sys.version.split()[0])
        if sys.platform == 'win32':
            banner = unicode(banner, 'utf-8').encode(sys.stdout.encoding)
    else:
        banner = 'zhpy %s in %s on top of Python %s'%(version, sys.platform,
                                                  sys.version.split()[0])
    #annotator()
    # able to import modules in current directory
    sys.path.insert(0, '')
    con.interact(banner)


if __name__=="__main__":
    try:
        import import_hook
    except:
        print "There's no zhimport support"

    import sys
    argv = sys.argv[1:]

    #profiling
    if len(argv)!=0 and argv[0] =="--profile":
        import profile
        profile.run("interpreter()", "prof.txt")
        import pstats
        p = pstats.Stats("prof.txt")
        p.sort_stats("time").print_stats()
    else:
        interpreter()