Newer
Older
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
# program to "thin down" the gradint .py for low memory environments
# by taking out some of the code that's unused on that platform
import sys
if "s60" in sys.argv: # S60 version
version = "S60"
to_omit = [
"if use_unicode_filenames:", # WinCE
"if paranoid_file_management:",
'if not extsep==".":',
"if macsound:","elif macsound:",
"if winsound:",
"if unix:",
"if winsound or mingw32:",
"elif unix and not macsound:",
"if gotSox and unix:",
"class SoundCollector(object):",
"def lame_endian_parameters():",
"def soundfile_to_data(file,soxParams):",
# TODO SH sound collector will have problem with indentation due to """..""" strings
"def decode_mp3(file):",
"class Mp3FileCache(object):",
"if outputFile:",
"class InputSourceManager(object):",
"def wavToMp3(directory):",
"def makeMp3Zips(baseDir,outDir,zipNo,direc=None):",
"class RecorderControls:",
"def doRecWords():",
"if app:","elif app:",
"def addStatus(widget,status,mouseOnly=0):",
"def removeStatus(widget):",
"def addButton(parent,text,command,packing=None,status=None):",
"def addLabel(row,label):",
"def CXVMenu(e):",
"def selectAll(e):",
"def selectAllButNumber(e):",
"def addTextBox(row,wide=0):",
"def addLabelledBox(row,wide=0):",
"def addRow(parent,wide=0):",
"def addRightRow(widerow):",
"def make_output_row(parent):",
"def select_userNumber(N,updateGUI=1):",
"def updateUserRow(fromMainMenu=0):",
"def renameUser(i,radioButton,parent,cancel=0):",
"def deleteUser(i):",
"def setupScrollbar(parent,rowNo):",
"class ExtraButton(object):",
"def make_extra_buttons_waiting_list():",
"def startTk():",
"def guiVocabList(parsedVocab):",
"def synchronizeListbox(listbox,masterList):",
"if useTK:",
"def openDirectory(dir):",
"if winCEsound:",
"def check_for_slacking():",
"def gui_outputTo_end():",
"def gui_outputTo_start():",
]
else: assert 0, "Unrecognised version on command line"
revertToIndent = -1
lCount = -1
for l in sys.stdin.xreadlines():
lCount += 1
if lCount==2: print "\n# NOTE: this version has been automatically TRIMMED for "+version+" (some non-"+version+" code taken out)\n"
l=l.rstrip()
assert not "\t" in l, "can't cope with tabs"
indentLevel=-1
for i in range(len(l)):
if not l[i]==" ":
indentLevel = i ; break
if indentLevel<0 or indentLevel==len(l) or (revertToIndent>=0 and indentLevel>revertToIndent): continue
revertToIndent = -1
if (l+"#")[:l.find("#")].strip() in to_omit:
print (l+"#")[:l.find("#")]+" pass # trimmed"
revertToIndent = indentLevel
else: print l