No Description

organiccodeconfig.py 1.5KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
  2. ### BEGIN LICENSE
  3. # This file is in the public domain
  4. ### END LICENSE
  5. ### DO NOT EDIT THIS FILE ###
  6. __all__ = [
  7. 'project_path_not_found',
  8. 'get_data_file',
  9. 'get_data_path',
  10. ]
  11. # Where your project will look for your data (for instance, images and ui
  12. # files). By default, this is ../data, relative your trunk layout
  13. __organiccode_data_directory__ = '../data/'
  14. __license__ = ''
  15. __version__ = 'VERSION'
  16. import os
  17. from locale import gettext as _
  18. class project_path_not_found(Exception):
  19. """Raised when we can't find the project directory."""
  20. def get_data_file(*path_segments):
  21. """Get the full path to a data file.
  22. Returns the path to a file underneath the data directory (as defined by
  23. `get_data_path`). Equivalent to os.path.join(get_data_path(),
  24. *path_segments).
  25. """
  26. return os.path.join(get_data_path(), *path_segments)
  27. def get_data_path():
  28. """Retrieve organiccode data path
  29. This path is by default <organiccode_lib_path>/../data/ in trunk
  30. and /usr/share/organiccode in an installed version but this path
  31. is specified at installation time.
  32. """
  33. # Get pathname absolute or relative.
  34. path = os.path.join(
  35. os.path.dirname(__file__), __organiccode_data_directory__)
  36. abs_data_path = os.path.abspath(path)
  37. if not os.path.exists(abs_data_path):
  38. raise project_path_not_found
  39. return abs_data_path
  40. def get_version():
  41. return __version__