sympa.py 702 B

12345678910111213141516171819
  1. #!/usr/bin/python3
  2. # Style Guide for Python Code https://www.python.org/dev/peps/pep-0008/
  3. # Docstring Conventions https://www.python.org/dev/peps/pep-0257/
  4. # Based upon:
  5. # https://www.sympa.org/distribution/contrib/sympa_extract.pl
  6. class Instance:
  7. def __init__(self, conn):
  8. self._conn = conn
  9. def get_subscribers(self, list, robot):
  10. rows = ["user_subscriber", "list_subscriber"]
  11. cur = self._conn.cursor()
  12. cur.execute("""SELECT %s FROM subscriber_table WHERE list_subscriber LIKE %%s AND robot_subscriber LIKE %%s""" % (",".join(rows)) , (list, robot))
  13. subscribers = []
  14. for item in cur:
  15. email = item[0].lower()
  16. subscribers.append(email)
  17. return subscribers