Exemple #1
0
    def _get_selected_library_state(self):
        """Returns the LibraryState which was selected in the LibraryTree

        :return: selected state in TreeView
        :rtype: LibraryState
        """
        (model, row) = self.view.get_selection().get_selected()
        library_item_key = model[row][self.ID_STORAGE_ID]
        library_item = model[row][self.ITEM_STORAGE_ID]
        library_path = model[row][self.LIB_PATH_STORAGE_ID]

        if isinstance(library_item, dict):
            return None
        assert isinstance(library_item, str)
        library_file_system_path = library_item

        logger.debug(
            "Link library state '{0}' (with library tree path: {2} and file system path: {1}) into state "
            "machine.".format(
                str(library_item_key), library_file_system_path,
                self.convert_if_human_readable(str(library_path)) + "/" +
                str(library_item_key)))
        library_name = library_file_system_path.split(os.path.sep)[-1]
        return LibraryState(library_path, library_name, "0.1",
                            format_folder_name_human_readable(library_name))
Exemple #2
0
    def _get_selected_library_state(self):
        """Returns the LibraryState which was selected in the LibraryTree

        :return: selected state in TreeView
        :rtype: LibraryState
        """
        library_os_path, library_path, library_name, item_key = self.extract_library_properties_from_selected_row()
        if library_path is None:
            return None

        logger.debug("Link library state '{0}' (with library tree path: {2} and file system path: {1}) into state "
                     "machine.".format(str(item_key), library_os_path,
                                       self.convert_if_human_readable(str(library_path)) + "/" + str(item_key)))
        library_name = library_os_path.split(os.path.sep)[-1]
        return LibraryState(library_path, library_name, "0.1", format_folder_name_human_readable(library_name))
Exemple #3
0
 def convert_if_human_readable(s):
     """Converts a string to format which is more human readable"""
     return format_folder_name_human_readable(s) \
         if global_gui_config.get_config_value('LIBRARY_TREE_PATH_HUMAN_READABLE', False) else s