本文整理汇总了Python中deepin_utils.config.Config.set方法的典型用法代码示例。如果您正苦于以下问题:Python Config.set方法的具体用法?Python Config.set怎么用?Python Config.set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类deepin_utils.config.Config
的用法示例。
在下文中一共展示了Config.set方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SettingConfig
# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import set [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)
示例2: save_skin_name
# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import set [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)
示例3: run
# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import set [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()
示例4: data_init
# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import set [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()
示例5: init_config
# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import set [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
示例6: data_exit
# 需要导入模块: from deepin_utils.config import Config [as 别名]
# 或者: from deepin_utils.config.Config import set [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()