sentencenode.py 1.2 KB

12345678910111213141516171819202122232425262728
  1. class SuspectedSentenceNode:
  2. def __init__(self, file_path, line_no, private_word_list, purpose, func_name, private_info=None, script=None,
  3. confidence=1,
  4. methods_called=[]):
  5. self.file_path = file_path
  6. self.line_no = line_no
  7. self.script = script
  8. self.private_word_list = private_word_list
  9. self.purpose = purpose
  10. self.func_name = func_name
  11. self.private_info = private_info
  12. self.confidence = confidence
  13. self.init_private_info()
  14. self.methods_called = methods_called
  15. def init_private_info(self):
  16. if self.private_info is None:
  17. self.private_info = [(word[0], purpose) for word in self.private_word_list for purpose in self.purpose]
  18. self.private_info = list(set(self.private_info))
  19. def __str__(self):
  20. if self.private_info is None:
  21. return self.file_path + ' ' + str(self.line_no) + '\n' + str(self.private_word_list) + ' ' + self.purpose
  22. else:
  23. return self.file_path + ' ' + str(self.line_no) + '\n' + str(self.private_info)
  24. def __eq__(self, other):
  25. return self.file_path == other.file_path and self.line_no == other.line_no