A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

45 行
1.2 KiB

  1. # -*- coding: utf-8 -*-
  2. from os.path import expanduser
  3. from urlparse import parse_qs
  4. import oursql
  5. class Query(object):
  6. def __init__(self, environ):
  7. self.query = {}
  8. parsed = parse_qs(environ["QUERY_STRING"])
  9. for key, value in parsed.iteritems():
  10. self.query[key] = value[-1].decode("utf8")
  11. def __getattr__(self, key):
  12. try:
  13. return self.query[key]
  14. except KeyError:
  15. return None
  16. def __setattr__(self, key, value):
  17. self.query[key] = value
  18. def open_sql_connection(bot, dbname):
  19. conn_args = bot.config.wiki["_toolserverSQL"][dbname]
  20. if "read_default_file" not in conn_args and "user" not in conn_args and "passwd" not in conn_args:
  21. conn_args["read_default_file"] = expanduser("~/.my.cnf")
  22. if "autoping" not in conn_args:
  23. conn_args["autoping"] = True
  24. if "autoreconnect" not in conn_args:
  25. conn_args["autoreconnect"] = True
  26. return oursql.connect(**conn_args)
  27. def urlstrip(context, url):
  28. if url.startswith("http://"):
  29. url = url[7:]
  30. if url.startswith("https://"):
  31. url = url[8:]
  32. if url.startswith("www."):
  33. url = url[4:]
  34. if url.endswith("/"):
  35. url = url[:-1]
  36. return url