utils.py 778 B

12345678910111213141516171819202122232425262728293031
  1. import argparse
  2. import logging
  3. from .crawler_util import *
  4. from .slider_util import *
  5. from .time_util import *
  6. def init_loging_config():
  7. level = logging.INFO
  8. logging.basicConfig(
  9. level=level,
  10. format="%(asctime)s [%(threadName)s] %(name)s %(levelname)s (%(filename)s:%(lineno)d) - %(message)s",
  11. datefmt='%Y-%m-%d %H:%M:%S'
  12. )
  13. _logger = logging.getLogger("MediaCrawler")
  14. _logger.setLevel(level)
  15. return _logger
  16. logger = init_loging_config()
  17. def str2bool(v):
  18. if isinstance(v, bool):
  19. return v
  20. if v.lower() in ('yes', 'true', 't', 'y', '1'):
  21. return True
  22. elif v.lower() in ('no', 'false', 'f', 'n', '0'):
  23. return False
  24. else:
  25. raise argparse.ArgumentTypeError('Boolean value expected.')