本文整理汇总了Python中settings.Settings.get方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.get方法的具体用法?Python Settings.get怎么用?Python Settings.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类settings.Settings
的用法示例。
在下文中一共展示了Settings.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: StatusBar
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
class StatusBar():
def __init__(self, window):
self.window = window
self.settings = Settings()
def update(self):
if ProcessCache.empty():
return self.erase()
status_bar_tasks = self.settings.get('status_bar_tasks', False)
if status_bar_tasks:
task_names = set([process.get_task_name() for process in ProcessCache.get()])
if status_bar_tasks != True:
if not isinstance(status_bar_tasks, list):
status_bar_tasks = [status_bar_tasks]
task_names = task_names.intersection(set(status_bar_tasks))
if task_names:
defer_sync(lambda: self.set(', '.join(task_names)))
def set(self, text):
text_format = self.settings.get('status_bar_format', '{task_name}')
status = text_format.format(task_name=text)
self.window.active_view().set_status(Settings.PACKAGE_NAME, status)
def erase(self):
self.window.active_view().erase_status(Settings.PACKAGE_NAME)
示例2: on_post_save
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def on_post_save(self, view):
settings = Settings()
self.view = view
self.run_kill = settings.get('kill_before_save_tasks', False)
self.run_tasks(settings.get("tasks_on_save", {}))
self.run_tasks(settings.get("silent_tasks_on_save", {}), silent=True)
self.view.run_command("gulp_update_status_bar")
示例3: __init__
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def __init__(self):
db_uri = Settings.get('db-uri', '---')
db_collection = Settings.get('mongo-db-collection', 'players')
self.client = pymongo.MongoClient(db_uri)
db = self.client.get_default_database()
self.collection = db[db_collection]
self.log_collection = db['logs_' + db_collection]
示例4: __init__
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def __init__(self, logger):
settings = Settings()
self.url = settings.get('WebDav', 'url')
self.login = settings.get('WebDav', 'login')
self.passwd = settings.get('WebDav', 'password')
self.basepath = requests.utils.urlparse(self.url).path
self.remotefolder = settings.get('WebDav', 'remoteFolder')
self.nosslcheck = settings.get('WebDav', 'nosslcheck')
self.time_delta = None
self.wc = None
self.locktoken = None
self.logger = logger
示例5: test_settings_load
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def test_settings_load(self):
self.assertFalse(os.path.exists(self.test_settings_path))
s = Settings()
for key, value in s.default_settings.items():
self.assert_(s[key] == value)
self.assert_(s.get(key) == value)
self.assert_(os.path.exists(s.settings_path))
示例6: save_attributes
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def save_attributes(self):
saveattrs = {}
try:
persisted = Settings.get(['torrents',self.hash,'attributes'])
except KeyError:
persisted = {}
for k in self._attributes:
if k in persisted and self._attributes[k] != persisted[k] or \
self._attributes[k] != self._default_attributes[k]:
saveattrs[k] = self._attributes[k]
if saveattrs:
#logging.info('saved attributes %s' % saveattrs)
path = ['torrents',self.hash,'attributes']
Settings.set(path, saveattrs)
saved = Settings.get(path)
示例7: test_basic
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def test_basic(self):
wSetting = Settings()
wSetting['test0'] = 'hello'
wSetting['test1'] = 10
wSetting['test2'] = [0, 2, 3]
self.assertEqual(wSetting.get('test3', 3), 3)
self.assertEqual(wSetting.save(), True)
示例8: ensure_stream_id
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def ensure_stream_id(self):
try:
self.sid = Settings.get(['torrents',self.hash,'sid'])
except:
chars = map(str,range(10)) + list('abcdef')
sid = ''.join( [random.choice( chars ) for _ in range(5)] )
Settings.set(['torrents',self.hash,'sid'], sid)
self.sid = sid
示例9: db
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def db(self):
"""
Lazy connect to db.
"""
if not hasattr(self.application, 'db'):
dsn = Settings.get('db')['dsn']
self.application.db = momoko.Pool(dsn=dsn, connection_factory=NamedTupleConnection)
return self.application.db
示例10: test_settings_save
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def test_settings_save(self):
s = Settings()
for key in s.default_settings:
self.assert_(s[key] == s.default_settings[key])
s['test_value'] = 1
s1 = Settings()
self.assert_(s1.get('test_value') == 1)
self.assert_(s1['test_value'] == 1)
示例11: get_config
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def get_config(key):
"""
Get configuration parameter.
"""
try:
click.echo(Settings.get(key))
except Exception as ex:
raise click.ClickException('Some error while setting: %s' % ex)
示例12: test1
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def test1():
db_uri = Settings.get('mongo-db-uri', '---')
db_collection = Settings.get('mongo-db-collection', '---')
client = pymongo.MongoClient(db_uri)
db = client.get_default_database()
print 'collections', db.collection_names()
collection = db[db_collection]
print 'count', collection.count()
players = collection.find()
for player in players:
print 'find', player
# # Note that the insert method can take either an array or a single dict.
# SEED_DATA = [
# {'player': 'miki', 'score': 1.0},
# {'player': 'tomi', 'score': 1.1}
# ]
# collection.insert_many(SEED_DATA)
# query = {'player': 'maki'}
# player = collection.find_one(query)
# print 'find_one', player
# players = collection.find(query)
# for player in players:
# print 'find', player
# print 'update...'
# collection.update_one(query, {'$set': {'score': 2.0}}, upsert=True)
#
# player = collection.find_one(query)
# print 'find_one', player
# players = collection.find(query)
# for player in players:
# print 'find', player
# db.drop_collection(db_collection)
client.close()
示例13: get_extra_assets
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def get_extra_assets(new_project_name):
expanded_files = []
def expand_selected_files(selected_files, expanded_files):
for filename in selected_files:
if os.path.isdir(filename):
expand_selected_files(CheckableDirModel.listDirectory(filename), expanded_files)
else:
expanded_files.append(filename)
selected_files = Settings.get().get_aux_files(new_project_name)
expand_selected_files(selected_files, expanded_files)
return expanded_files
示例14: Auth
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
class Auth(Debug):
def __init__(self):
self.authenticated = False
self.settings = Settings()
self.http = HTTP()
self.table = DB().table('auth')
@property
def hasCredentials(self):
if (self.settings.get('credentials.username') == "" or self.settings.get('credentials.password') == ""):
return False
else:
return True
@hasCredentials.setter
def hasCredentials(self):
self.username = ""
self.password = ""
@property
def password(self):
return self.settings.get('credentials.password')
@password.setter
def password(self, value):
self.settings.set('credentials.password', value)
@property
def username(self):
return self.settings.get('credentials.username')
@username.setter
def username(self, value):
self.settings.set('credentials.username', value)
def validate(self):
pass
示例15: load_metadata
# 需要导入模块: from settings import Settings [as 别名]
# 或者: from settings.Settings import get [as 别名]
def load_metadata(self):
try:
filename = Settings.get(['torrents',self.hash,'filename'])
except KeyError:
return
filepath = os.path.join(options.datapath, filename)
if os.path.exists(filepath):
fo = open( filepath )
data = fo.read()
self.meta = bencode.bdecode( data )
fo.close()
else:
logging.error('%s missing on disk' % filepath)