db_1.py 989 B

12345678910111213141516171819202122232425
  1. def databases_to_archive(self):
  2. """
  3. Return a list of databases that are eligibles to archiving. If no
  4. database are provided or the * character is used the method basically
  5. do a SHOW DATABASE to get available databases
  6. The method exclude the databases that are explicitly excluded
  7. """
  8. if self._databases_to_archive:
  9. return self._databases_to_archive
  10. if self.databases is None or self.databases == '*':
  11. self._databases_to_archive = self.get_os_databases()
  12. else:
  13. self._databases_to_archive = [
  14. d for d in re.split(',|;|\n', self.databases.replace(' ', ''))
  15. ]
  16. excluded_databases_regex = \
  17. "^(" + "|".join(self.excluded_databases) + ")$"
  18. self._databases_to_archive = [
  19. d for d in self._databases_to_archive
  20. if not re.match(excluded_databases_regex, d)
  21. ]
  22. return self._databases_to_archive