utils.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import json
  2. def arrayToFile(filename, array=[]):
  3. fd = open(filename, 'w')
  4. for item in array:
  5. fd.write(item + '\n')
  6. fd.close()
  7. def getFileContent(filename, parseJson=False):
  8. fd = open(filename, 'r')
  9. content = fd.read()
  10. fd.close()
  11. if parseJson:
  12. content = json.loads(content)
  13. return content
  14. def removeEOLCharacters(item, replace=''):
  15. item = item.replace('\n', replace)
  16. item = item.replace('\r', replace)
  17. return item
  18. def getFileLines(filename, removeEOL=False):
  19. fd = open(filename, 'r')
  20. lines = fd.readlines()
  21. fd.close()
  22. if removeEOL:
  23. lines = [removeEOLCharacters(line) for line in lines]
  24. return lines
  25. def hasBadKeywords(emailContent):
  26. keywords = [
  27. 'puta', 'mierda', 'carajo', 'cerdos', 'cerdo', 'trasero',
  28. 'mother fuckers', 'fuck', 'bitch', 'bozal', 'bosal', 'pene', 'vagina',
  29. 'marica', 'maricon', 'gay', 'lesbiana', 'gordo', 'puerco', 'puercos',
  30. 'franchute', 'maldit', 'cojud', 'huevon', 'boludo',
  31. 'huev', 'shit', 'asshole'
  32. ]