Read jargon into array
This commit is contained in:
parent
c619867b92
commit
20eb0fbc34
37
makeJargon.py
Executable file
37
makeJargon.py
Executable file
@ -0,0 +1,37 @@
|
||||
import os
|
||||
import string
|
||||
|
||||
def jargonParseEntry(filename):
|
||||
if not os.path.isfile(filename):
|
||||
return []
|
||||
|
||||
entry = []
|
||||
|
||||
line = []
|
||||
with open(filename) as fp:
|
||||
line = fp.readlines()
|
||||
fp.close()
|
||||
|
||||
text = ''
|
||||
if len(line) > 2:
|
||||
for i in range(len(line)):
|
||||
if i == 0:
|
||||
entry.append(line[i].replace('\n','').strip())
|
||||
if i >= 2:
|
||||
text = text + line[i]
|
||||
text = text.replace('\n',' ')
|
||||
entry.append(text.strip())
|
||||
|
||||
return entry
|
||||
|
||||
def jargonGetEntries(entriesDir):
|
||||
entries = []
|
||||
for dirName, subdirList, fileList in os.walk(entriesDir):
|
||||
for filename in fileList:
|
||||
entry = jargonParseEntry(entriesDir + '/' + filename)
|
||||
if entry:
|
||||
entries.append(entry)
|
||||
return entries
|
||||
|
||||
if __name__ == "__main__":
|
||||
entries = jargonGetEntries('entries')
|
Loading…
x
Reference in New Issue
Block a user