本文整理汇总了Python中pychron.core.helpers.strtools.to_bool函数的典型用法代码示例。如果您正苦于以下问题:Python to_bool函数的具体用法?Python to_bool怎么用?Python to_bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了to_bool函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_initialization_model
def get_initialization_model():
ip = InitializationParser()
rtree = load_plugin_tree()
gtree = load_global_tree()
for gi in ip.get_plugin_groups():
tree = get_tree(gi, rtree)
if tree:
ps = ip.get_plugins(gi, element=True)
if ps:
for pp in ps:
plugin = get_plugin(pp.text.strip(), tree)
if plugin:
plugin.enabled = to_bool(pp.get('enabled'))
for gi in ip.get_globals():
gv = gtree.get_value(gi.tag)
if gv:
gv.enabled = to_bool(gi.text.strip())
model = InitializationModel(trees=[gtree, rtree],
path_name=os.path.basename(ip.path),
parser=ip)
model.init_hash()
return model
示例2: __init__
def __init__(self, schema_identifier='', attrs=None):
super(ConnectionFavoriteItem, self).__init__()
self.schema_identifier = schema_identifier
if attrs:
attrs = attrs.split(',')
try:
self.name, self.kind, self.username, self.host, self.dbname, self.password = attrs
except ValueError:
try:
self.name, self.kind, self.username, self.host, self.dbname, self.password, enabled = attrs
self.enabled = to_bool(enabled)
except ValueError:
try:
(self.name, self.kind, self.username, self.host, self.dbname,
self.password, enabled, default) = attrs
self.enabled = to_bool(enabled)
self.default = to_bool(default)
except ValueError:
(self.name, self.kind, self.username, self.host, self.dbname,
self.password, enabled, default, path) = attrs
self.enabled = to_bool(enabled)
self.default = to_bool(default)
self.path = path
self.load_names()
示例3: wrapper
def wrapper(*args, **kw):
r = func(*args, **kw)
if r:
r = to_bool(r.strip())
if invert:
r = not r
return r
示例4: wrapper
def wrapper(*args, **kw):
r = func(*args, **kw)
if r:
r = r.strip()
r = to_bool(r)
# r = to_bool(r[4:-4])
return r
示例5: _get_db
def _get_db(self):
if self.use_workspace:
return self.workspace.index_db
elif to_bool(self.application.preferences.get('pychron.dvc.enabled')):
return self.application.get_service('pychron.dvc.dvc.DVC')
else:
return self.manager.db
示例6: _new_label
def _new_label(self, label, name, c,
layer=1,
origin=None, klass=None, **kw):
if origin is None:
ox, oy = 0, 0
else:
ox, oy = origin
if klass is None:
klass = Label
x, y = 0, 0
trans = label.find('translation')
if trans is not None:
x, y = map(float, trans.text.split(','))
c = self._make_color(c)
l = klass(ox + x, oy + y,
bgcolor=c,
use_border=to_bool(label.get('use_border', 'T')),
name=name,
text=label.text.strip(),
**kw)
font = label.find('font')
if font is not None:
l.font = font.text.strip()
self.add_item(l, layer=layer)
return l
示例7: _load_booleans
def _load_booleans(self, header, args, params):
for attr in ['autocenter',
'use_cdd_warming',
('disable_between_positions', 'dis_btw_pos')]:
v = self._get_attr_value(header, args, attr, cast=lambda x: to_bool(x.strip()))
if v is not None:
params[v[0]] = v[1]
示例8: _random_tip
def _random_tip(self):
if globalv.random_tip_enabled and to_bool(self.application.preferences.get('pychron.general.show_random_tip')):
from pychron.envisage.tasks.tip_view import TipView
t = random.choice(self.help_tips)
tv = TipView(text=t)
tv.edit_traits()
示例9: __init__
def __init__(self, schema_identifier='', attrs=None, load_names=False):
super(ConnectionFavoriteItem, self).__init__()
self.schema_identifier = schema_identifier
if attrs:
attrs = attrs.split(',')
try:
(self.name, self.kind, self.username, self.host, self.dbname,
self.password, enabled, default, path) = attrs
except ValueError:
(self.name, self.kind, self.username, self.host, self.dbname,
self.password, enabled, default, self.path, self.organization,
self.meta_repo_name, self.meta_repo_dir) = attrs
self.enabled = to_bool(enabled)
self.default = to_bool(default)
if load_names:
self.load_names()
示例10: GoToHole
def GoToHole(self, manager, hole, autocenter, *args):
try:
hole = int(hole)
autocenter = to_bool(autocenter)
err = manager.stage_manager.move_to_hole(str(hole),
correct_position=autocenter)
except (ValueError, TypeError):
err = InvalidArgumentsErrorCode('GoToHole', (hole, autocenter))
return self.error_response(err)
示例11: load
def load(self):
p = paths.task_extensions_file
if os.path.isfile(p):
with open(p, 'r') as rfile:
yl = yaml.load(rfile)
for te in self.task_extensions:
yd = next((d for d in yl if d['plugin_id'] == te.id), None)
if yd:
for ai in yd['actions']:
action, enabled = ai.split(',')
tt = next((ta for ta in te.additions if ta.model.id == action), None)
if tt:
tt.enabled = to_bool(enabled)
示例12: load_configuration
def load_configuration(self):
dm = self.dm
sheet = dm.get_sheet(("Configuration", 4))
for ri in dm.iterrows(sheet, 1):
name = ri[0].value
v = ri[1].value
if name == "autogenerate_labnumber":
v = to_bool(v)
self.debug('setting "{}"={}'.format(name, v))
if not hasattr(self, name):
self.warning('Invalid configuration option "{}"'.format(name))
else:
setattr(self, name, v)
示例13: _get_switch_channel
def _get_switch_channel(self, data):
if isinstance(data, dict):
name = data['name']
else:
name = data
name = str(name)
ch = self._switch_mapping.get(name, '')
inverted = False
if ',' in str(ch):
ch, inverted = ch.split(',')
inverted = to_bool(inverted)
#self.debug('get switch channel {} {}'.format(name, ch))
return ch, inverted
示例14: _go_to_hole
def _go_to_hole(self, data):
if isinstance(data, dict):
hole, autocenter = data['hole'], data['autocenter']
else:
hole, autocenter = data
try:
hole = int(hole)
autocenter = to_bool(autocenter)
err = self._manager.stage_manager.move_to_hole(str(hole),
correct_position=autocenter)
except (ValueError, TypeError):
err = InvalidArgumentsErrorCode('GoToHole', (hole, autocenter))
return err or 'OK'
示例15: get_task_extensions
def get_task_extensions(self, pid):
import yaml
p = paths.task_extensions_file
with open(p, 'r') as rfile:
yl = yaml.load(rfile)
for yi in yl:
# print yi['plugin_id'], pid
if yi['plugin_id'].startswith(pid):
tid = yi.get('task_id', '')
for ai in yi['actions']:
a, e = ai.split(',')
# print tid, a, e
if to_bool(e):
yield tid, a