utils.py 937 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. from typing import Any, Generator, Iterable
  2. from config import DIR_WORK
  3. from input_output import read_rows, write_file, my_input2
  4. def unique_rows(rows:Iterable) -> Generator[str|Any, None, None]:
  5. # Уникальные строки
  6. return (i for i in set(rows))
  7. class proxy_type_raw:
  8. __slots__ = ()
  9. def socks5(self, proxy:str) -> str: return 'socks5://' + proxy + '\n'
  10. def socks4(self, proxy:str) -> str: return 'socks4://' + proxy + '\n'
  11. def http(self, proxy:str) -> str: return 'http://' + proxy + '\n'
  12. """
  13. Форматирование
  14. ...
  15. ...
  16. """
  17. if __name__ == '__name__':
  18. unique_rows(rows=read_rows(
  19. pathfile=DIR_WORK + '/check.txt'
  20. ))
  21. # Быстрое форматирование через input
  22. write_file(
  23. pathfile= DIR_WORK + '/check.txt',
  24. write=my_input2(
  25. end='',
  26. execute_with_element=proxy_type_raw().http),
  27. mode='a')