JargonFile/makeJargon.py

38 lines
884 B
Python
Raw Normal View History

2014-04-26 12:52:25 -04:00
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')