-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
36 lines (31 loc) · 1.12 KB
/
__init__.py
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
import re
import os
__author__ = 'Alesha'
path_name = os.path.join(os.path.dirname(__file__)).replace('\\', '/')
def create_commands():
f = open(path_name + '/search_engine/commands.py'.replace('\\', '/'))
lines = f.readlines()
out_lines = []
for line in lines:
if line[0] == '#':
out_lines.append(line+'\n')
elif len(line):
strings = re.compile('[a-zA-Z0-9/]+').findall(line)
print strings
if len(strings) > 5:
method = strings[0]
name = strings[1]
description = strings[2:]
op_name = '_'.join(entity for entity in re.compile('[a-z]+').findall(name))
comment = method + ',' + ' '.join(description)
code = op_name + ' = ' + "'" + name + "'"
out_lines.append("#"+comment+'\n')
out_lines.append(code+'\n')
for line in out_lines:
print line
f.close()
g = open(path_name + '/serch_engine/commands_.py'.replace('\\', '/'),'w+')
g.writelines(out_lines)
g.close()
if __name__ == '__main__':
create_commands()