/usr/share/pyshared/jsb/lib/examples.py is in jsonbot 0.84.4-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 | # jsb/examples.py
#
#
""" examples is a dict of example objects. """
## basic imports
import re
## Example class
class Example(object):
""" an example. """
def __init__(self, descr, ex, url=False):
self.descr = descr
self.example = ex
self.url = url
## Collection of exanples
class Examples(dict):
""" examples holds all the examples. """
def add(self, name, descr, ex, url=False):
""" add description and example. """
self[name.lower()] = Example(descr, ex, url)
def size(self):
""" return size of examples dict. """
return len(self.keys())
def getexamples(self):
""" get all examples in list. """
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
## global examples object
examples = Examples()
def size():
return examples.size()
|