当前位置: 首页>>代码示例>>Python>>正文


Python Config.load方法代码示例

本文整理汇总了Python中deepin_utils.config.Config.load方法的典型用法代码示例。如果您正苦于以下问题:Python Config.load方法的具体用法?Python Config.load怎么用?Python Config.load使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在deepin_utils.config.Config的用法示例。


在下文中一共展示了Config.load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: is_mirror_disabled

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
def is_mirror_disabled():
    if os.path.exists(deepin_version_path):
        config = Config(deepin_version_path)
        config.load()
        return config.has_option("Custom", "Mirror") and config.get("Custom", "Mirror") == "False"
    else:
        return True # not deepin os, disable mirror change
开发者ID:martyr-deepin,项目名称:deepin-store,代码行数:9,代码来源:mirror_test.py

示例2: Mirror

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
class Mirror(object):
    def __init__(self, ini_file):
        self.config = Config(ini_file)
        self.config.load()
        deepin_url = self.get_repo_urls()[1]
        _url_parse = urlparse(deepin_url)
        self._hostname = _url_parse.scheme + "://" + _url_parse.netloc
        self._priority = int(self.config.get("mirror", "priority")) if self.config.has_option("mirror", "priority") else 100
    
    @property
    def hostname(self):
        return self._hostname

    @property
    def name(self):
        if self.config.has_option('mirror', 'name[%s]' % LANGUAGE):
            return self.config.get('mirror', 'name[%s]' % LANGUAGE)
        else:
            return self.config.get('mirror', 'name[%s]' % 'en_US')

    @property
    def priority(self):
        return self._priority

    def get_repo_urls(self):
        return (self.config.get('mirror', 'ubuntu_url'), self.config.get('mirror', 'deepin_url'))
开发者ID:PeterDaveHello,项目名称:deepin-software-center,代码行数:28,代码来源:mirror_test.py

示例3: scan_plugin_info

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
 def scan_plugin_info(self):
     self.engine_list = []
     self.engine_dict = {}
     
     for plugin_name in os.listdir(self.plugin_dir):
         plugin_config_file = os.path.join(self.plugin_dir, plugin_name, self.plugin_config_name)
         plugin_config = Config(plugin_config_file)
         plugin_config.load()
         
         language = get_language()
         plugin_display_name = plugin_config.get("Plugin Info", "name[%s]" % language) or plugin_config.get("Plugin Info", "name[en]")
         
         need_network = is_true(plugin_config.get("Voice Info", "need_network"))
         support_all_language = is_true(plugin_config.get("Voice Info", "support_all_language"))
         support_languages_info = plugin_config.get("Voice Info", "support_languages")
         priority = plugin_config.get("Voice Info", "priority")
         if support_languages_info == None:
             support_languages = []
         else:
             support_languages = support_languages_info.split(",")
             
         if support_all_language:
             self.engine_list.append((plugin_name, plugin_display_name, priority, need_network))
         else:
             self.update_dict(self.engine_dict, support_languages, plugin_name, plugin_display_name, priority, need_network)
开发者ID:PeterDaveHello,项目名称:deepin-translator,代码行数:27,代码来源:tts_plugin.py

示例4: run

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
def run():
    if not os.path.exists(data_newest_id_path):
        newest_data_id_config = Config(data_newest_id_path)
        newest_data_id_config.load()
        newest_data_id_config.set("newest", "data_id", "")
        newest_data_id_config.set("newest", "update_date", "")
        newest_data_id_config.write()
    else:
        newest_data_id_config = Config(data_newest_id_path)
        newest_data_id_config.load()

    try:
        update_date = newest_data_id_config.get("newest", "update_date")
    except Exception:
        update_date = ""

    if newest_data_id_config.get("newest", "data_id") == "" or update_date != UPDATE_DATE:
        clean()
        newest_data_id = str(uuid.uuid4())
        newest_data_dir = os.path.join(DATA_DIR, "update", newest_data_id)
        
        print "进行第一次数据解压..."
        for data_file in os.listdir(data_origin_dir):
            with tarfile.open(os.path.join(data_origin_dir, data_file), "r:gz") as tar_file:
                tar_file.extractall(newest_data_dir)
        print "进行第一次数据解压完成"
        
        newest_data_id_config.set("newest", "data_id", newest_data_id)
        newest_data_id_config.set("newest", "update_date", UPDATE_DATE)
        newest_data_id_config.write()
开发者ID:martyr-deepin,项目名称:deepin-software-center-data,代码行数:32,代码来源:unpack-data.py

示例5: SettingConfig

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
class SettingConfig(QObject):
    
    def __init__(self):
        QObject.__init__(self)
        self.config_file = get_config_file("config.ini")
        
        if os.path.exists(self.config_file):
            self.config = Config(self.config_file, DEFAULT_CONFIG)
            self.config.load()
        else:
            self.config = Config(self.config_file, DEFAULT_CONFIG)
            self.config.write()
            
    @pyqtSlot(str, bool)        
    def update_trayicon_config(self, config_id, config_value):
        with self.config.save_config():
            self.config.set("trayicon", config_id, config_value)

    @pyqtSlot(str, str)        
    def update_translate_config(self, config_id, config_value):
        with self.config.save_config():
            self.config.set("translate", config_id, config_value)
            
    @pyqtSlot(str, result=bool)        
    def get_trayicon_config(self, option):
        return is_true(self.config.get_config("trayicon", option))
    
    @pyqtSlot(str, result=str)
    def get_translate_config(self, option):
        return self.config.get_config("translate", option)
开发者ID:lihongwu,项目名称:deepin-translator,代码行数:32,代码来源:config.py

示例6: get_config_info_config

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
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
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:10,代码来源:settings.new.py

示例7: get_vpc_remind_config

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
def get_vpc_remind_config():
    CONFIG_INFO_PATH = os.path.expanduser("~/.config/deepin-system-settings/tray/config.ini")
    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
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:11,代码来源:tray_shutdown_plugin.py

示例8: save_skin_name

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
 def save_skin_name(self):
     '''
     Internal function to save skin name.
     '''
     skin_config = Config(self.skin_config_file)
     skin_config.load()
     if skin_config.get("skin", "skin_name") != self.skin_name:
         skin_config.set("skin", "skin_name", self.skin_name)
         skin_config.write(self.skin_config_file)
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:11,代码来源:skin_config.py

示例9: load_skin_from_package

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
    def load_skin_from_package(self, filepath):
        '''
        Load theme from given package.

        @param filepath: The file path of package.
        '''
        # Init.
        skin_dir = os.path.join(self.user_skin_dir, str(uuid.uuid4()))

        # Create skin directory.
        create_directory(skin_dir, True)

        # Extract skin package.
        tar = tarfile.open(filepath, "r:gz")
        tar.extractall(skin_dir)

        # Get skin image file.
        config = Config(os.path.join(skin_dir, "config.ini"))
        config.load()

        # Move theme files to given directory if theme is not in default theme list.
        skin_theme_name = config.get("theme", "theme_name")
        if not skin_theme_name in COLOR_SEQUENCE:
            # Check version when package have special theme that not include in standard themes.
            app_id = config.get("application", "app_id")
            app_version = config.get("application", "app_version")
            if app_id == self.app_given_id and app_version == self.app_given_version:
                # Remove same theme from given directories.
                remove_directory(os.path.join(self.ui_theme_dir, skin_theme_name))
                if self.app_theme_dir != None:
                    remove_directory(os.path.join(self.app_theme_dir, skin_theme_name))

                # Move new theme files to given directories.
                shutil.move(os.path.join(skin_dir, "ui_theme", skin_theme_name), self.ui_theme_dir)
                if self.app_theme_dir != None:
                    shutil.move(os.path.join(skin_dir, "app_theme", skin_theme_name), self.app_theme_dir)

                # Remove temp theme directories under skin directory.
                remove_directory(os.path.join(skin_dir, "ui_theme"))
                remove_directory(os.path.join(skin_dir, "app_theme"))
            else:
                # Remove skin directory if version mismatch.
                remove_directory(skin_dir)

                return False

        # Apply new skin.
        skin_image_file = config.get("background", "image")
        if self.reload_skin(os.path.basename(skin_dir)):
            self.apply_skin()

            return (True, skin_dir, skin_image_file)
        else:
            return (False, skin_dir, skin_image_file)
开发者ID:chenzhiwei,项目名称:deepin-ui,代码行数:56,代码来源:skin_config.py

示例10: is_fontend_running

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
 def is_fontend_running(self):
     if os.path.exists(DATA_CURRENT_ID_CONFIG_PATH):
         config = Config(DATA_CURRENT_ID_CONFIG_PATH)
         config.load()
         data_id = config.get('current', 'data_id')
         if data_id:
             return True
         else:
             return False
     else:
         False
开发者ID:iceleaf916,项目名称:software-update-manager,代码行数:13,代码来源:dsc-daemon.py

示例11: get_last_update_time

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
def get_last_update_time():
    config = Config(SYS_CONFIG_INFO_PATH)

    if os.path.exists(SYS_CONFIG_INFO_PATH):
        config.load()
        if config.has_option("update", "last_update_time"):
            return config.get("update", "last_update_time")
        else:
            return ""
    else:
        return ""
开发者ID:martyr-deepin,项目名称:deepin-store,代码行数:13,代码来源:utils.py

示例12: Mirror

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
class Mirror(object):
    def __init__(self, ini_file):
        self.ini_file = ini_file
        self.config = Config(ini_file)
        self.config.load()
        deepin_url = self.get_repo_urls()[1]
        self._url_parse = urlparse(deepin_url)
        self._hostname = self._url_parse.scheme + "://" + self._url_parse.netloc
    
    @property
    def host(self):
        return self._url_parse.netloc

    @property
    def hostname(self):
        return self._hostname
开发者ID:electricface,项目名称:deepin-software-center,代码行数:18,代码来源:mirrors.py

示例13: ModuleInfo

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
class ModuleInfo(object):
    '''
    class docs
    '''
	
    def __init__(self, module_path):
        '''
        init docs
        '''
        self.path = module_path
        self.config = Config(os.path.join(self.path, "config.ini"))
        self.config.load()
        self.id = self.config.get("main", "id")
        # TODO: lihongwu req to support i18n
        self.name = MODULES_NAME_FOR_L18N.get(self.id, "")
        self.default_name = self.config.get("name", "default")

        """
        self.name = self.default_name
        if MAIN_LANG != "en_US":
            self.name = self.config.get("name", MAIN_LANG)
        """

        icon_infos = [self.get_system_icon_info(self.id, 48), 
                      self.get_system_icon_info(self.id, 16),
                     ]
        
        self.icon_pixbuf = None
        self.menu_icon_pixbuf = None
        try:
            self.icon_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_infos[0])
            self.menu_icon_pixbuf = gtk.gdk.pixbuf_new_from_file(icon_infos[1])
        except:
            self.icon_pixbuf = app_theme.get_pixbuf("navigate/none-big.png").get_pixbuf()
            self.menu_icon_pixbuf = app_theme.get_pixbuf("navigate/none-small.png").get_pixbuf()
            
        self.search_keyword = self.config.get("main", "search_keyword")
        
    def get_system_icon_info(self, icon_id, icon_size):
        '''
        NOTE: Because dtk.ui.utils.get_system_icon_info need take 20ms every call,
        it will slow down start speed of deepin system settings.
        
        So i return path directly to solve start speed problem.
        '''
        return "/usr/share/icons/Deepin/apps/%s/preferences-%s.png" % (icon_size, icon_id)
开发者ID:electricface,项目名称:deepin-system-settings,代码行数:48,代码来源:module_info.py

示例14: data_init

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
def data_init():
    global data_init_flag
    global DATA_ID
    
    if not data_init_flag:
        data_init_flag = True
        
        data_newest_id_config = Config(DATA_NEWEST_ID_CONFIG_FILE)
        data_newest_id_config.load()
        DATA_ID = data_newest_id_config.get("newest", "data_id")
        
        if not os.path.exists(DATA_CURRENT_ID_CONFIG_FILE):
            touch_file(DATA_CURRENT_ID_CONFIG_FILE)
            os.chmod(DATA_CURRENT_ID_CONFIG_FILE, 0777)
            
        data_current_id_config = Config(DATA_CURRENT_ID_CONFIG_FILE)
        data_current_id_config.load()
        data_current_id_config.set("current", "data_id", DATA_ID)
        data_current_id_config.write()
开发者ID:PeterDaveHello,项目名称:deepin-software-center,代码行数:21,代码来源:data.py

示例15: init_config

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import load [as 别名]
    def init_config(self):
        if os.path.exists(CONFIG_INFO_PATH):
            config = Config(CONFIG_INFO_PATH)
            config.load()
            uid = config.get("statistics", 'uid')
            if not uid:
                uid = uuid.uuid4().hex
                config.set("statistics", 'uid', uid)
                config.set("statistics", 'last_date', '')
                config.write()
        else:
            touch_file(CONFIG_INFO_PATH)
            uid = uuid.uuid4().hex
            config = Config(CONFIG_INFO_PATH)
            config.load()
            config.set("statistics", 'uid', uid)
            config.set("statistics", 'last_date', '')
            config.write()

        return config
开发者ID:menghun3,项目名称:deepin-software-center-1,代码行数:22,代码来源:dsc-daemon.py


注:本文中的deepin_utils.config.Config.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。