A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

misc.py 791 B

1234567891011121314151617181920212223242526
  1. # -*- coding: utf-8 -*-
  2. from os.path import expanduser
  3. import oursql
  4. def open_sql_connection(bot, dbname):
  5. conn_args = bot.config.wiki["_toolserverSQL"][dbname]
  6. if "read_default_file" not in conn_args and "user" not in conn_args and "passwd" not in conn_args:
  7. conn_args["read_default_file"] = expanduser("~/.my.cnf")
  8. if "autoping" not in conn_args:
  9. conn_args["autoping"] = True
  10. if "autoreconnect" not in conn_args:
  11. conn_args["autoreconnect"] = True
  12. return oursql.connect(**conn_args)
  13. def urlstrip(context, url):
  14. if url.startswith("http://"):
  15. url = url[7:]
  16. if url.startswith("https://"):
  17. url = url[8:]
  18. if url.startswith("www."):
  19. url = url[4:]
  20. if url.endswith("/"):
  21. url = url[:-1]
  22. return url