本文整理汇总了Python中settings.Settings.retrieve方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.retrieve方法的具体用法?Python Settings.retrieve怎么用?Python Settings.retrieve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.retrieve方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _add_to_recents
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import retrieve [as 别名]
def _add_to_recents(self, path):
settings = Settings.retrieve('backstage')
recents = settings.get('recents', [ ])
for recent in recents:
if path == recent['path']:
recents.remove(recent)
break
name = os.path.basename(path)
location = os.path.dirname(path)
documents_dir = Dirs.documents_dir()
home_dir = Dirs.home_dir()
desktop_dir = Dirs.desktop_dir()
if location.startswith(documents_dir):
location = location.replace(documents_dir, '{{Documents}}')
if location.startswith(desktop_dir):
location = location.replace(desktop_dir, '{{Desktop}}')
if location.startswith(home_dir):
location = location.replace(home_dir, '{{Home}}')
recents.insert(0, { 'name': name, 'path': path, 'location': location })
recents = recents[0:5]
settings.set('recents', recents)
settings.sync()
for instanceId, instance in Instance.instances.items():
instance._on_settings()
示例2: _on_settings
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import retrieve [as 别名]
def _on_settings(self, request=None):
settings = Settings.retrieve('backstage')
localFSRecents = settings.get('localFSRecents')
if localFSRecents is None:
localFSRecents = [
{ 'name': '{{Documents}}', 'path': '{{Documents}}' },
{ 'name': '{{Desktop}}', 'path': '{{Desktop}}' } ]
recents = settings.get('recents', [ ])
response = silkycoms.SettingsResponse()
for recent in recents:
recentEntry = silkycoms.DataSetEntry()
recentEntry.name = recent['name']
recentEntry.path = recent['path']
recentEntry.location = recent['location']
response.recents.append(recentEntry)
for localFSRecent in localFSRecents:
recent = silkycoms.DataSetEntry()
recent.name = localFSRecent['name']
recent.path = localFSRecent['path']
response.localFSRecents.append(recent)
self._coms.send(response, self._instance_id, request)
示例3: __init__
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import retrieve [as 别名]
def __init__(self, session_path, instance_id=None):
self._coms = None
self._dataset = None
self._filepath = None
self._analyses = Analyses()
self._em = EngineManager()
self._session_path = session_path
self._em.add_results_listener(self._on_results)
settings = Settings.retrieve()
settings.sync()
if instance_id is not None:
self._instance_id = instance_id
else:
self._instance_id = str(uuid.uuid4())
print("created " + self._instance_id)
self._instance_path = os.path.join(self._session_path, self._instance_id)
os.makedirs(self._instance_path, exist_ok=True)
self._buffer_path = os.path.join(self._instance_path, 'buffer')
self._em.start(self._session_path)
Instance.instances[self._instance_id] = self