Exemplo n.º 1
0
  def _ReadPythonModuleConfiguration(self, config_parser):
    """Reads the Python module configuration.

    Args:
      config_parser (ConfigParser): configuration file parser.

    Raises:
      ConfigurationError: if the Python module year of creation cannot
          be converted to a base 10 integer value.
    """
    self.python_module_authors = self._GetOptionalConfigValue(
        config_parser, 'python_module', 'authors',
        default_value=self.project_authors)
    self.python_module_name = 'py{0:s}'.format(self.library_name_suffix)
    self.python_module_year_of_creation = self._GetOptionalConfigValue(
        config_parser, 'python_module', 'year_of_creation')

    if not self.python_module_year_of_creation:
      self.python_module_year_of_creation = self.project_year_of_creation
    else:
      try:
        self.python_module_year_of_creation = int(
            self.python_module_year_of_creation, 10)
      except ValueError:
        raise errors.ConfigurationError(
            'Invalid Python module year of creation: {0!s}'.format(
                self.python_module_year_of_creation))
Exemplo n.º 2
0
  def _ReadProjectConfiguration(self, config_parser):
    """Reads the project configuration.

    Args:
      config_parser (ConfigParser): configuration file parser.

    Raises:
      ConfigurationError: if the project year of creation cannot
          be converted to a base 10 integer value.
    """
    self.project_name = self._GetConfigValue(
        config_parser, 'project', 'name')

    self.project_data_format = self._GetOptionalConfigValue(
        config_parser, 'project', 'data_format', default_value='')

    project_description = ''
    if self.project_data_format:
      project_description = (
          '{0:s} is a library to access the {1:s} format.'.format(
              self.project_name, self.project_data_format))
    self.project_description = self._GetOptionalConfigValue(
        config_parser, 'project', 'description',
        default_value=project_description)

    project_authors = ['Joachim Metz <*****@*****.**>']
    self.project_authors = self._GetOptionalConfigValue(
        config_parser, 'project', 'authors', default_value=project_authors)

    self.project_documentation_url = self._GetOptionalConfigValue(
        config_parser, 'project', 'documentation_url')

    project_downloads_url = 'https://github.com/libyal/{0:s}/releases'.format(
        self.project_name)
    self.project_downloads_url = self._GetOptionalConfigValue(
        config_parser, 'project', 'downloads_url',
        default_value=project_downloads_url)

    project_git_url = 'https://github.com/libyal/{0:s}.git'.format(
        self.project_name)
    self.project_git_url = self._GetOptionalConfigValue(
        config_parser, 'project', 'git_url', default_value=project_git_url)

    self.project_status = self._GetConfigValue(
        config_parser, 'project', 'status')
    self.project_year_of_creation = self._GetConfigValue(
        config_parser, 'project', 'year_of_creation')

    try:
      self.project_year_of_creation = int(self.project_year_of_creation, 10)
    except ValueError:
      raise errors.ConfigurationError(
          'Invalid project year of creation: {0!s}'.format(
              self.project_year_of_creation))

    features = self._GetOptionalConfigValue(
        config_parser, u'project', u'features', default_value=[])

    self.supports_debug_output = 'debug_output' in features
Exemplo n.º 3
0
  def _ReadInfoToolConfiguration(self, config_parser):
    """Reads the info tool configuration.

    Args:
      config_parser (ConfigParser): configuration file parser.

    Raises:
      ConfigurationError: if the info tool source type is not supported.
    """
    self.info_tool_source_description = self._GetOptionalConfigValue(
        config_parser, 'info_tool', 'source_description')

    self.info_tool_source_type = self._GetOptionalConfigValue(
        config_parser, 'info_tool', 'source_type')

    if self.info_tool_source_type and self.info_tool_source_type not in (
        'container', 'file', 'image', 'volume'):
      raise errors.ConfigurationError(
          'unsupported info tool source type: {0:s}'.format(
              self.info_tool_source_type))
Exemplo n.º 4
0
  def _ReadMountToolConfiguration(self, config_parser):
    """Reads the mount tool configuration.

    Args:
      config_parser (ConfigParser): configuration file parser.

    Raises:
      ConfigurationError: if the mount tool features or source type is not
          supported.
    """
    self._mount_tool_features = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'features', default_value=[])

    if ('offset' in self._mount_tool_features and
        'parent' in self._mount_tool_features):
      raise errors.ConfigurationError(
          'unsupported mount tool features - offset and parent cannot be '
          'combined.')

    self.mount_tool_additional_arguments = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'additional_arguments')

    self.mount_tool_base_type = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'base_type')

    self.mount_tool_file_entry_access_time_type = (
        self._GetOptionalConfigValue(
            config_parser, 'mount_tool', 'file_entry_access_time_type'))

    if (self.mount_tool_file_entry_access_time_type and
        self.mount_tool_file_entry_access_time_type not in (
            'filetime', 'hfs_time', 'nano_posix_time')):
      raise errors.ConfigurationError(
          'unsupported mount tool file entry access time type: {0:s}'.format(
              self.mount_tool_file_entry_access_time_type))

    self.mount_tool_file_entry_access_time_value = (
        self._GetOptionalConfigValue(
            config_parser, 'mount_tool', 'file_entry_access_time_value',
            default_value='access_time'))

    self.mount_tool_file_entry_creation_time_type = (
        self._GetOptionalConfigValue(
            config_parser, 'mount_tool', 'file_entry_creation_time_type'))

    if (self.mount_tool_file_entry_creation_time_type and
        self.mount_tool_file_entry_creation_time_type not in (
            'filetime', 'hfs_time', 'nano_posix_time')):
      raise errors.ConfigurationError(
          'unsupported mount tool file entry creation time type: {0:s}'.format(
              self.mount_tool_file_entry_creation_time_type))

    self.mount_tool_file_entry_creation_time_value = (
        self._GetOptionalConfigValue(
            config_parser, 'mount_tool', 'file_entry_creation_time_value',
            default_value='creation_time'))

    self.mount_tool_file_entry_example = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'file_entry_example')

    self.mount_tool_file_entry_inode_change_time_type = (
        self._GetOptionalConfigValue(
            config_parser, 'mount_tool', 'file_entry_inode_change_time_type'))

    if (self.mount_tool_file_entry_inode_change_time_type and
        self.mount_tool_file_entry_inode_change_time_type not in (
            'filetime', 'hfs_time', 'nano_posix_time')):
      raise errors.ConfigurationError((
          'unsupported mount tool file entry inode change time type: '
          '{0:s}').format(self.mount_tool_file_entry_inode_change_time_type))

    self.mount_tool_file_entry_inode_change_time_value = (
        self._GetOptionalConfigValue(
            config_parser, 'mount_tool', 'file_entry_inode_change_time_value',
            default_value='inode_change_time'))

    self.mount_tool_file_entry_modification_time_type = (
        self._GetOptionalConfigValue(
            config_parser, 'mount_tool', 'file_entry_modification_time_type'))

    if (self.mount_tool_file_entry_modification_time_type and
        self.mount_tool_file_entry_modification_time_type not in (
            'filetime', 'hfs_time', 'nano_posix_time')):
      raise errors.ConfigurationError((
          'unsupported mount tool file entry modification time type: '
          '{0:s}').format(self.mount_tool_file_entry_modification_time_type))

    self.mount_tool_file_entry_modification_time_value = (
        self._GetOptionalConfigValue(
            config_parser, 'mount_tool', 'file_entry_modification_time_value',
            default_value='modification_time'))

    self.mount_tool_file_entry_type = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'file_entry_type')

    self.mount_tool_file_entry_type_size_value = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'file_entry_type_size_value',
        default_value='size')

    self.mount_tool_file_system_type = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'file_system_type')

    self.mount_tool_mounted_description = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'mounted_description')

    self.mount_tool_path_prefix = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'path_prefix',
        default_value=self.library_name_suffix)

    self.mount_tool_source = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'source')
    self.mount_tool_source_description = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'source_description')

    # If the long source description is not set it will default to
    # source description.
    self.mount_tool_source_description_long = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'source_description_long')

    self.mount_tool_source_type = self._GetOptionalConfigValue(
        config_parser, 'mount_tool', 'source_type')

    if self.mount_tool_source_type and self.mount_tool_source_type not in (
        'container', 'file', 'image', 'volume'):
      raise errors.ConfigurationError(
          'unsupported mount tool source type: {0:s}'.format(
              self.mount_tool_source_type))