Пример #1
0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os
from xdg_support import get_config_dir

from deepin_utils.config import Config
from deepin_utils.file import touch_file

CONFIG_INFO_PATH = os.path.join(get_config_dir(), "settings.ini")


def get_config_info_config():
    config_info_config = Config(CONFIG_INFO_PATH)
    if os.path.exists(CONFIG_INFO_PATH):
        config_info_config.load()
    else:
        touch_file(CONFIG_INFO_PATH)
        config_info_config.load()
    return config_info_config


def get_config_info(section, key):
    config = get_config_info_config()
    if config.has_option(section, key):
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import os
from xdg_support import get_config_dir

from deepin_utils.config import Config
from deepin_utils.file import touch_file

CONFIG_INFO_PATH = os.path.join(get_config_dir(), "settings.ini")

def get_config_info_config():
    config_info_config = Config(CONFIG_INFO_PATH)
    if os.path.exists(CONFIG_INFO_PATH):
        config_info_config.load()
    else:
        touch_file(CONFIG_INFO_PATH)
        config_info_config.load()
    return config_info_config

def get_config_info(section, key):
    config = get_config_info_config()
    if config.has_option(section, key):
        return config.get(section, key)
    else:
        try:
            os.rename(self.location, self.location + ".old")
        except:
            pass # if it doesn'texist we don't care

        os.rename(self.location + ".new", self.location)

        try:
            os.remove(self.location + ".old")
        except:
            pass

        self._saving = False
        self._dirty = False
        
location = get_config_dir()
global_settings = SettingsManager(
    os.path.join(location, "settings.ini"),
    get_config_path("settings.ini")
)

def get_system_deletes():
    deletes = global_settings.get_option("settings/system_deletes")
    if deletes:
        return deletes
    else:
        return []

def add_system_deletes(keys):
    deletes = get_system_deletes()
    if deletes: