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


Python Config.write方法代码示例

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


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

示例1: SettingConfig

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import write [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

示例2: run

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import write [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

示例3: save_skin_name

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import write [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

示例4: data_init

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import write [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

示例5: init_config

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import write [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

示例6: data_exit

# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import write [as 别名]
def data_exit():
    data_current_id_config = Config(DATA_CURRENT_ID_CONFIG_FILE)
    data_current_id_config.load()
    data_current_id_config.set("current", "data_id", "")
    data_current_id_config.write()
开发者ID:PeterDaveHello,项目名称:deepin-software-center,代码行数:7,代码来源:data.py


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