本文整理汇总了Python中kivy.config.ConfigParser.read方法的典型用法代码示例。如果您正苦于以下问题:Python ConfigParser.read方法的具体用法?Python ConfigParser.read怎么用?Python ConfigParser.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.config.ConfigParser
的用法示例。
在下文中一共展示了ConfigParser.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_panel
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
def update_panel(self):
'''Update the MenuSidebar
'''
self.config_parsers = {}
self.interface.menu.buttons_layout.clear_widgets()
for _file in os.listdir(self.PROFILES_PATH):
_file_path = os.path.join(self.PROFILES_PATH, _file)
config_parser = ConfigParser()
config_parser.read(_file_path)
prof_name = config_parser.getdefault('profile', 'name', 'PROFILE')
if not prof_name.strip():
prof_name = 'PROFILE'
self.config_parsers[
str(prof_name) + '_' + _file_path] = config_parser
for _file in sorted(self.config_parsers):
prof_name = self.config_parsers[_file].getdefault('profile',
'name',
'PROFILE')
if not prof_name.strip():
prof_name = 'PROFILE'
self.add_json_panel(prof_name,
self.config_parsers[_file],
os.path.join(
get_kd_data_dir(),
'settings',
'build_profile.json')
)
# force to show the first profile
first_panel = self.interface.menu.buttons_layout.children[-1].uid
self.interface.content.current_uid = first_panel
示例2: ProjectSettings
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
class ProjectSettings(Settings):
'''Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of project.
'''
project = ObjectProperty(None)
'''Reference to :class:`desginer.project_manager.Project`
'''
config_parser = ObjectProperty(None)
'''Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
'''
def load_proj_settings(self):
'''This function loads project settings
'''
self.config_parser = ConfigParser()
file_path = os.path.join(self.project.path, PROJ_CONFIG)
if not os.path.exists(file_path):
if not os.path.exists(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path))
CONFIG_TEMPLATE = '''[proj_name]
name = Project
[arguments]
arg =
[env variables]
env =
'''
f = open(file_path, 'w')
f.write(CONFIG_TEMPLATE)
f.close()
self.config_parser.read(file_path)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
settings_dir = os.path.join(_dir, 'designer', 'settings')
self.add_json_panel('Shell Environment',
self.config_parser,
os.path.join(settings_dir,
'proj_settings_shell_env.json'))
self.add_json_panel('Project Properties',
self.config_parser,
os.path.join(settings_dir,
'proj_settings_proj_prop.json'))
@ignore_proj_watcher
def on_config_change(self, *args):
'''This function is default handler of on_config_change event.
'''
self.config_parser.write()
super(ProjectSettings, self).on_config_change(*args)
示例3: ProjectSettings
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
class ProjectSettings(Settings):
"""Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of project.
"""
project = ObjectProperty(None)
"""Reference to :class:`desginer.project_manager.Project`
"""
config_parser = ObjectProperty(None)
"""Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
"""
def load_proj_settings(self):
"""This function loads project settings
"""
self.config_parser = ConfigParser()
file_path = os.path.join(self.project.path, PROJ_CONFIG)
if not os.path.exists(file_path):
if not os.path.exists(os.path.dirname(file_path)):
os.makedirs(os.path.dirname(file_path))
CONFIG_TEMPLATE = """[proj_name]
name = Project
[arguments]
arg =
[env variables]
env =
"""
f = open(file_path, "w")
f.write(CONFIG_TEMPLATE)
f.close()
self.config_parser.read(file_path)
settings_dir = os.path.join(get_kd_data_dir(), "settings")
self.add_json_panel(
"Shell Environment", self.config_parser, os.path.join(settings_dir, "proj_settings_shell_env.json")
)
self.add_json_panel(
"Project Properties", self.config_parser, os.path.join(settings_dir, "proj_settings_proj_prop.json")
)
@ignore_proj_watcher
def on_config_change(self, *args):
"""This function is default handler of on_config_change event.
"""
self.config_parser.write()
super(ProjectSettings, self).on_config_change(*args)
示例4: load_config
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
def load_config(self):
'''(internal) This function is used for returning a ConfigParser with
the application configuration. It's doing 3 things:
#. Creating an instance of a ConfigParser
#. Loading the default configuration by calling
:meth:`build_config`, then
#. If it exists, it loads the application configuration file,
otherwise it creates one.
:return:
:class:`~kivy.config.ConfigParser` instance
'''
try:
config = ConfigParser.get_configparser('app')
except KeyError:
config = None
if config is None:
config = ConfigParser(name='app')
self.config = config
self.build_config(config)
# if no sections are created, that's mean the user don't have
# configuration.
if len(config.sections()) == 0:
return
# ok, the user have some sections, read the default file if exist
# or write it !
filename = self.get_application_config()
if filename is None:
return config
Logger.debug('App: Loading configuration <{0}>'.format(filename))
if exists(filename):
try:
config.read(filename)
except:
Logger.error('App: Corrupted config file, ignored.')
config.name = ''
try:
config = ConfigParser.get_configparser('app')
except KeyError:
config = None
if config is None:
config = ConfigParser(name='app')
self.config = config
self.build_config(config)
pass
else:
Logger.debug('App: First configuration, create <{0}>'.format(
filename))
config.filename = filename
config.write()
return config
示例5: get_config
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
def get_config():
config = ConfigParser()
config.read('config.ini')
config.adddefaultsection('game')
config.setdefault('game', 'outside_coordinates', True)
config.setdefault('game', 'show_pieces', True)
config.setdefault('game', 'square_coordinates', False)
return config
示例6: DesignerSettings
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
class DesignerSettings(Settings):
'''Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of Kivy Designer.
'''
config_parser = ObjectProperty(None)
'''Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
'''
def load_settings(self):
'''This function loads project settings
'''
self.config_parser = ConfigParser()
DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(),
DESIGNER_CONFIG_FILE_NAME)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
DEFAULT_CONFIG = os.path.join(_dir, DESIGNER_CONFIG_FILE_NAME)
if not os.path.exists(DESIGNER_CONFIG):
shutil.copyfile(DEFAULT_CONFIG,
DESIGNER_CONFIG)
self.config_parser.read(DESIGNER_CONFIG)
self.config_parser.upgrade(DEFAULT_CONFIG)
self.add_json_panel('Kivy Designer Settings', self.config_parser,
os.path.join(_dir, 'designer',
'settings', 'designer_settings.json'))
path = self.config_parser.getdefault(
'global', 'python_shell_path', '')
if path == "":
self.config_parser.set('global', 'python_shell_path',
sys.executable)
self.config_parser.write()
def on_config_change(self, *args):
'''This function is default handler of on_config_change event.
'''
self.config_parser.write()
super(DesignerSettings, self).on_config_change(*args)
示例7: on_start
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
def on_start(self):
"""
Método chamado para inicializar o menu inicial
:return: nada
"""
Window.size = (300, 100)
config = ConfigParser()
# Carrega últimas configurações utilizadas (ou padrões se arquivo não é encontrado)
config.read('settings.ini')
self.username = config.get('section0', 'key00')
self.color = SettingsApp.get_color(config.get('section0', 'key01'))
if config.get('section1', 'key10') == "Single":
self.is_multiplayer = False
else:
self.is_multiplayer = True
self.match = config.get('section1', 'key11')
self.rows = config.getint('section2', 'key20')
self.columns = config.getint('section2', 'key21')
self.bombs = config.getint('section3', 'key30')
示例8: NewGame
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
class NewGame(AnchorLayout):
app = ObjectProperty(None)
config = ObjectProperty(None)
settings = ObjectProperty(None)
def __init__(self, **kwargs):
super(NewGame, self).__init__(**kwargs)
self.config = ConfigParser()
self.config.read(tttraders_user_conf('tttraders.ini'))
self.settings.register_type("int", TTSettingInt)
for tab in TradersGame.ConfigTabs:
lst = TradersGame.Config[tab]
for c in lst:
if c.get("key", None):
self.config.adddefaultsection(c['section'])
self.config.setdefault(c['section'], c['key'], c.get("default", None))
self.settings.add_json_panel(tab, self.config, data=json.dumps(lst))
示例9: on_new
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
def on_new(self, *args):
'''Handler for "New Profile" button
'''
new_name = 'new_profile'
i = 1
while os.path.exists(os.path.join(
self.PROFILES_PATH, new_name + str(i) + '.ini')):
i += 1
new_name += str(i)
new_prof_path = os.path.join(
self.PROFILES_PATH, new_name + '.ini')
shutil.copy2(os.path.join(self.DEFAULT_PROFILES, 'desktop.ini'),
new_prof_path)
config_parser = ConfigParser()
config_parser.read(new_prof_path)
config_parser.set('profile', 'name', new_name.upper())
config_parser.write()
self.update_panel()
self.settings_changed = True
示例10: DesignerSettings
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
class DesignerSettings(Settings):
"""Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of Kivy Designer.
"""
config_parser = ObjectProperty(None)
"""Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
"""
def load_settings(self):
"""This function loads project settings
"""
self.config_parser = ConfigParser()
DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(), DESIGNER_CONFIG_FILE_NAME)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
if not os.path.exists(DESIGNER_CONFIG):
shutil.copyfile(os.path.join(_dir, DESIGNER_CONFIG_FILE_NAME), DESIGNER_CONFIG)
self.config_parser.read(DESIGNER_CONFIG)
self.add_json_panel(
"Kivy Designer Settings",
self.config_parser,
os.path.join(_dir, "designer", "settings", "designer_settings.json"),
)
path = self.config_parser.getdefault("global", "python_shell_path", "")
if path == "":
self.config_parser.set("global", "python_shell_path", sys.executable)
self.config_parser.write()
def on_config_change(self, *args):
"""This function is default handler of on_config_change event.
"""
self.config_parser.write()
super(DesignerSettings, self).on_config_change(*args)
示例11: __init__
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
def __init__(self, *args, **kwargs):
self.callback = kwargs.pop("callback", None)
self.pages = kwargs.pop("pages", ["general", "synchronisation", "kivy"])
self.title = "Paramètres"
self.size_hint = (0.9, 0.9)
config = ConfigParser()
config.read(UTILS_Divers.GetRepData() + "config.cfg")
self.settings = Settings()
self.settings.register_type('password', SettingPassword)
self.settings.register_type('chaine', SettingChaine)
if "general" in self.pages : self.settings.add_json_panel("Généralités", config, data=json.dumps(JSON_GENERAL, encoding="utf-8"))
if "synchronisation" in self.pages : self.settings.add_json_panel("Synchronisation", config, data=json.dumps(JSON_SYNCHRONISATION, encoding="utf-8"))
if "kivy" in self.pages : self.settings.add_kivy_panel()
self.settings.interface.menu.close_button.text = "Fermer"
self.content = self.settings
self.settings.bind(on_close=self.OnBoutonFermer)
self.bind(on_dismiss=self.on_dismiss)
super(Popup, self).__init__(*args, **kwargs)
示例12: Backlight_Control
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
import time
import datetime
import json
# ===========================
# Control The Backlight
# ===========================
def Backlight_Control(light_status):
subproces.call('echo 0 > Light.SATUS')
# ========================
# Load the Defaults
# ========================
config = ConfigParser()
config.read('doorbell.ini')
CODES = ConfigParser()
CODES.read('codes.ini')
CODES_DICT = {s:dict(CODES.items(s)) for s in CODES.sections()}
NUMBERS = ConfigParser()
NUMBERS.read('numbers.ini')
NUMBERS_DICT = {s:dict(NUMBERS.items(s)) for s in NUMBERS.sections()}
LANGUAGES = ConfigParser()
LANGUAGES.read('languages.ini')
LANGUAGES_DICT = {s:dict(LANGUAGES.items(s)) for s in LANGUAGES.sections()}
# ===========================
示例13: ConfigParser
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
from kivy.factory import Factory
from kivy.app import App
from kivy.properties import StringProperty
from kivy.lang import Builder
import csv
import os
import json
app = App.get_running_app()
from kivy.config import ConfigParser
config = ConfigParser()
config.read('myconfig.ini')
config.adddefaultsection('pycon2018')
config.setdefault('pycon2018', 'register_data_dir', 'data')
class ScreenRegister(Factory.Screen):
_data = {}
'''Holds the data in :attr:`data_file_dir` was processed or not.
:attr:`_data` is a :type:`String`, defaults to False.
'''
data_file_dir = StringProperty(config.get(
'pycon2018', 'register_data_dir'))
'''This is the data dir where the registeration data is stored.
All csv files should be present in this folder.
示例14: DesignerSettings
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
class DesignerSettings(Settings):
"""Subclass of :class:`kivy.uix.settings.Settings` responsible for
showing settings of Kivy Designer.
"""
config_parser = ObjectProperty(None)
"""Config Parser for this class. Instance
of :class:`kivy.config.ConfigParser`
"""
def __init__(self, **kwargs):
super(DesignerSettings, self).__init__(*kwargs)
self.register_type("list", SettingList)
self.register_type("shortcut", SettingShortcut)
def load_settings(self):
"""This function loads project settings
"""
self.config_parser = ConfigParser(name="DesignerSettings")
DESIGNER_CONFIG = os.path.join(get_kivy_designer_dir(), DESIGNER_CONFIG_FILE_NAME)
_dir = os.path.dirname(designer.__file__)
_dir = os.path.split(_dir)[0]
DEFAULT_CONFIG = os.path.join(_dir, DESIGNER_CONFIG_FILE_NAME)
if not os.path.exists(DESIGNER_CONFIG):
shutil.copyfile(DEFAULT_CONFIG, DESIGNER_CONFIG)
self.config_parser.read(DESIGNER_CONFIG)
self.config_parser.upgrade(DEFAULT_CONFIG)
# creates a panel before insert it to update code input theme list
panel = self.create_json_panel(
"Kivy Designer Settings",
self.config_parser,
os.path.join(_dir, "designer", "settings", "designer_settings.json"),
)
uid = panel.uid
if self.interface is not None:
self.interface.add_panel(panel, "Kivy Designer Settings", uid)
# loads available themes
for child in panel.children:
if child.id == "code_input_theme_options":
child.items = styles.get_all_styles()
# tries to find python and buildozer path if it's not defined
path = self.config_parser.getdefault("global", "python_shell_path", "")
if path.strip() == "":
self.config_parser.set("global", "python_shell_path", sys.executable)
self.config_parser.write()
buildozer_path = self.config_parser.getdefault("buildozer", "buildozer_path", "")
if buildozer_path.strip() == "":
buildozer_path = find_executable("buildozer")
if buildozer_path:
self.config_parser.set("buildozer", "buildozer_path", buildozer_path)
self.config_parser.write()
self.add_json_panel(
"Buildozer", self.config_parser, os.path.join(_dir, "designer", "settings", "buildozer_settings.json")
)
self.add_json_panel(
"Hanga", self.config_parser, os.path.join(_dir, "designer", "settings", "hanga_settings.json")
)
self.add_json_panel(
"Keyboard Shortcuts", self.config_parser, os.path.join(_dir, "designer", "settings", "shortcuts.json")
)
def on_config_change(self, *args):
"""This function is default handler of on_config_change event.
"""
self.config_parser.write()
super(DesignerSettings, self).on_config_change(*args)
示例15: update_program
# 需要导入模块: from kivy.config import ConfigParser [as 别名]
# 或者: from kivy.config.ConfigParser import read [as 别名]
def update_program(self):
"""Проверяет наличие обновлений на сервере github,com.
Проверяестя версия программы, версии плагинов, наличие измененных
программых файлов."""
if platform != "android":
print("Проверка обновлений:")
print("------------------------------------")
temp_path = "{}/Data/temp".format(core.prog_path)
if not os.path.exists(temp_path):
os.mkdir(temp_path)
update_file = urllib.urlopen(
"https://github.com/HeaTTheatR/HeaTDV4A/raw/master/"
"Data/uploadinfo.ini").read()
open("{}/uploadinfo.ini".format(temp_path), "w").write(
update_file)
config_update = ConfigParser()
config_update.read("{}/uploadinfo.ini".format(temp_path))
info_list_update = []
new_version_program = \
config_update.getfloat("info_update", "new_version_program")
updated_files_program = \
eval(config_update.get("info_update", "updated_files_program"))
dict_official_plugins_program = \
config_update.items("plugin_update")
official_plugins_program = dict(dict_official_plugins_program)
install_user_plugins = self.started_plugins
current_version_program = __version__
if platform != "android":
print("Проверка версии программы ...")
print("Проверка актуальности плагинов ...")
for plugin in install_user_plugins.keys():
try:
info_official_plugin = eval(official_plugins_program[plugin])
if info_official_plugin[plugin]['plugin-version'] > \
install_user_plugins[plugin]['plugin-version']:
info_list_update.append(info_official_plugin)
if platform != "android":
print("Плагин '{}' обновился до версии '{}'!".format(
plugin, info_official_plugin[plugin][
'plugin-version']))
except KeyError:
continue
if platform != "android":
print("Проверка обновлений завершена ...")
print("------------------------------------")
print()
if len(info_list_update) or new_version_program > \
current_version_program:
self.update = True
if platform != "android":
print("Доступны обновления!")
print("------------------------------------")
print()
else:
if platform != "android":
print("Обновлений нет!")
print("------------------------------------")
print()