# Path: reggata/errors.py
# class MsgException(Exception):
#     '''This exception is used in situations when no error occurred,
#     but we have to tell the user some text information.'''
#     def __init__(self, msg=None):
#         super(MsgException, self).__init__(msg)
# 
# Path: reggata/user_config.py
# class UserConfig(object):
#     '''
#         This class is an interface for reggata.conf configuration file.
#     It is a singleton class.
#     '''
#     _instance = None
#     _props = None
# 
#     def __new__(cls, *args, **kwargs):
#         if not cls._instance:
#             cls._instance = super(UserConfig, cls).__new__(cls, *args, **kwargs)
# 
#             cls._props = Properties()
#             if not os.path.exists(consts.USER_CONFIG_DIR):
#                 os.makedirs(consts.USER_CONFIG_DIR)
# 
#             if not os.path.exists(consts.USER_CONFIG_FILE):
#                 with codecs.open(consts.USER_CONFIG_FILE, "w", "utf-8") as f:
#                     f.write(reggata_default_conf.reggataDefaultConf)
# 
#             with codecs.open(consts.USER_CONFIG_FILE, "r", "utf-8") as f:
#                 cls._props.load(f)
# 
#         return cls._instance
# 
#     def __init__(self):
#         pass
# 
#     def __getitem__(self, key):
#         '''
#             This is an operation []. It returns a value of parameter with given key.
#         If there is no such key, an exception is raised.
#         '''
#         return self._props[key]
# 
#     def get(self, key, default=None):
#         '''
#             Returns value of parameter with given key. If there are no such key in
#         configuration, then a default value is returned.
#         '''
#         return self._props.get(key, default)
# 
#     def store(self, key, value):
#         self._props[key] = str(value)
#         with codecs.open(consts.USER_CONFIG_FILE, 'w', "utf-8") as f:
#             self._props.store(f)
# 
#     def storeAll(self, d):
#         if type(d) != dict:
#             raise TypeError("This is not a dict instance.")
#         for key in d.keys():
#             self._props[key] = str(d[key])
#         with codecs.open(consts.USER_CONFIG_FILE, 'w', "utf-8") as f:
#             self._props.store(f)
# 
#     def refresh(self):
#         with codecs.open(consts.USER_CONFIG_FILE, 'r', "utf-8") as f:
#             self._props.load(f)


import os
import subprocess
import shlex
import logging
import sys
import string
import reggata.consts as consts
from PyQt4.QtCore import QCoreApplication
from PyQt4 import QtCore
from reggata.errors import MsgException
from reggata.user_config import UserConfig
        UserConfig().storeAll(stateDict)



    def openFileWithExtApp(self, abs_path):

        _, ext = os.path.splitext(abs_path)
        appCommandPattern = self.__extensions.get(ext.lower(), None)

        if appCommandPattern is None:
            msg = QCoreApplication.translate("ext_app_mgr",
                        "External application for {0} file extension is not set. "
                        "Please, go to 'Main Menu -> Repository -> Manage External Applications' "
                        "and configure it",
                        None, QCoreApplication.UnicodeUTF8)
            raise Exception(msg.format(ext))

        appCommand = self.__replaceCommandPatternKeys(appCommandPattern,
                                                      filePath=abs_path,
                                                      dirPath=os.path.dirname(abs_path))
        self.__createSubprocess(appCommand)


    def openContainingDirWithExtAppManager(self, abs_path):
        if self.__state.extFileMgrCommandPattern is None:
            msg = QCoreApplication.translate("ext_app_mgr",
                        "No external file manager command is set. "
                        "Please, go to 'Main Menu -> Repository -> Manage External Applications' "
                        "and configure it",
                        None, QCoreApplication.UnicodeUTF8)

# Path: reggata/errors.py
# class MsgException(Exception):
#     '''This exception is used in situations when no error occurred,
#     but we have to tell the user some text information.'''
#     def __init__(self, msg=None):
#         super(MsgException, self).__init__(msg)
# 
# Path: reggata/user_config.py
# class UserConfig(object):
#     '''
#         This class is an interface for reggata.conf configuration file.
#     It is a singleton class.
#     '''
#     _instance = None
#     _props = None
# 
#     def __new__(cls, *args, **kwargs):
#         if not cls._instance:
#             cls._instance = super(UserConfig, cls).__new__(cls, *args, **kwargs)
# 
#             cls._props = Properties()
#             if not os.path.exists(consts.USER_CONFIG_DIR):
#                 os.makedirs(consts.USER_CONFIG_DIR)
# 
#             if not os.path.exists(consts.USER_CONFIG_FILE):
#                 with codecs.open(consts.USER_CONFIG_FILE, "w", "utf-8") as f:
#                     f.write(reggata_default_conf.reggataDefaultConf)
# 
#             with codecs.open(consts.USER_CONFIG_FILE, "r", "utf-8") as f:
#                 cls._props.load(f)
# 
#         return cls._instance
# 
#     def __init__(self):
#         pass
# 
#     def __getitem__(self, key):
#         '''
#             This is an operation []. It returns a value of parameter with given key.
#         If there is no such key, an exception is raised.
#         '''
#         return self._props[key]
# 
#     def get(self, key, default=None):
#         '''
#             Returns value of parameter with given key. If there are no such key in
#         configuration, then a default value is returned.
#         '''
#         return self._props.get(key, default)
# 
#     def store(self, key, value):
#         self._props[key] = str(value)
#         with codecs.open(consts.USER_CONFIG_FILE, 'w', "utf-8") as f:
#             self._props.store(f)
# 
#     def storeAll(self, d):
#         if type(d) != dict:
#             raise TypeError("This is not a dict instance.")
#         for key in d.keys():
#             self._props[key] = str(d[key])
#         with codecs.open(consts.USER_CONFIG_FILE, 'w', "utf-8") as f:
#             self._props.store(f)
# 
#     def refresh(self):
#         with codecs.open(consts.USER_CONFIG_FILE, 'r', "utf-8") as f:
#             self._props.load(f)


# Path: reggata/logic/ext_app_mgr.py
import os
import subprocess
import shlex
import logging
import sys
import string
import reggata.consts as consts
from PyQt4.QtCore import QCoreApplication
from PyQt4 import QtCore
from reggata.errors import MsgException
from reggata.user_config import UserConfig

        UserConfig().storeAll(stateDict)



    def openFileWithExtApp(self, abs_path):

        _, ext = os.path.splitext(abs_path)
        appCommandPattern = self.__extensions.get(ext.lower(), None)

        if appCommandPattern is None:
            msg = QCoreApplication.translate("ext_app_mgr",
                        "External application for {0} file extension is not set. "
                        "Please, go to 'Main Menu -> Repository -> Manage External Applications' "
                        "and configure it",
                        None, QCoreApplication.UnicodeUTF8)
            raise Exception(msg.format(ext))

        appCommand = self.__replaceCommandPatternKeys(appCommandPattern,
                                                      filePath=abs_path,
                                                      dirPath=os.path.dirname(abs_path))
        self.__createSubprocess(appCommand)


    def openContainingDirWithExtAppManager(self, abs_path):
        if self.__state.extFileMgrCommandPattern is None:
            msg = QCoreApplication.translate("ext_app_mgr",
                        "No external file manager command is set. "
                        "Please, go to 'Main Menu -> Repository -> Manage External Applications' "
                        "and configure it",
                        None, QCoreApplication.UnicodeUTF8)

            raise MsgException(msg.format(consts.USER_CONFIG_FILE))