Menu

[r1]: / Translator.py  Maximize  Restore  History

Download this file

69 lines (44 with data), 1.3 kB

 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
import re, pdb
def trim(txt):
t = txt.strip()
return t
def preg_match(expression, string):
if expression[0] == '/':
expression = expression[1:]
if expression[-1] == '/':
expression = expression[0:-1]
matches = re.findall(expression, string)
return matches
def preg_replace(expression, replace, string):
new_string = re.sub(expression, replace, string)
return new_string
def substr(string, start, length = None):
if length:
substr = string[start:length + 1]
else:
substr = string[start:]
return substr
def strpos(haystack, needle):
if needle in haystack:
strpos = haystack.find(needle)
else:
return False
return strpos
def str_replace(search, replace, string):
if search in string:
string = string.replace(search, replace)
return string
def get_class(obj):
name = obj.__class__.__name__
return name
def array_pop(array):
return array.pop()
def array_push(array, value):
return array.append(value)
messages = []
def addLogMessage(message, dump = False):
messages.append(message)
#print message
def dumpLogs():
logs = open('Log.txt', 'w')
logs.writelines(messages)
MongoDB Logo MongoDB