importer.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. # ============================================================================
  2. # This file is part of Pwman3.
  3. #
  4. # Pwman3 is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License, version 2
  6. # as published by the Free Software Foundation;
  7. #
  8. # Pwman3 is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with Pwman3; if not, write to the Free Software
  15. # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  16. # ============================================================================
  17. # Copyright (C) 2014 Oz Nahum Tiram <nahumoz@gmail.com>
  18. # ============================================================================
  19. '''
  20. A module to hold the importer class
  21. '''
  22. class BaseImporter(object):
  23. """
  24. The base class which defines the action needed to import data
  25. to pwman database
  26. """
  27. def __init__(self):
  28. pass
  29. class CSVImporter(BaseImporter):
  30. """
  31. A reference implementation which imports a CSV to the pwman database
  32. """
  33. def __init__(self):
  34. pass
  35. class Importer(object):
  36. """
  37. The actual job runner which by default runs a csv importer instance.
  38. This could be changes by calling other instance which for example import
  39. from KeePass XML or other formats.
  40. """
  41. def __init__(self, invoke=CSVImporter):
  42. self.runner = invoke
  43. def run(self):
  44. self.runner()