/usr/share/pyshared/gozerbot/examples.py is in gozerbot 0.99.1-2.
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 | # gozerbot/examples.py
#
#
"""
examples is a dict of example objects.
"""
__copyright__ = 'this file is in the public domain'
# ==============
# IMPORT SECTION
# basic imports
import re
# END IMPORT
# ==========
# ============
# LOCK SECTION
# no locks
# END LOCK
# ========
class Example(object):
"""
an example.
:param descr: description of the example
:type descr: string
:param ex: the example
:type ex: string
"""
def __init__(self, descr, ex):
self.descr = descr
self.example = ex
class Examples(dict):
"""
examples object is a dict.
"""
def add(self, name, descr, ex):
"""
add description and example.
:param name: name of the example
:type name: string
:param descr: description of the example
:type descr: string
:param ex: the example
:type ex: string
.. literalinclude:: ../../gozerbot/examples.py
:pyobject: Examples.add
"""
self[name.lower()] = Example(descr, ex)
def size(self):
"""
return size of examples dict.
:rtype: integer
.. literalinclude:: ../../gozerbot/examples.py
:pyobject: Examples.size
"""
return len(self.keys())
def getexamples(self):
"""
get all examples in list.
:rtype: list
.. literalinclude:: ../../gozerbot/examples.py
:pyobject: Examples.getexamples
"""
result = []
for i in self.values():
ex = i.example.lower()
exampleslist = re.split('\d\)', ex)
for example in exampleslist:
if example:
result.append(example.strip())
return result
# ============
# INIT SECTION
# main examples object
examples = Examples()
# END INIT
# ========
|