• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python strtools.to_bool函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pychron.core.helpers.strtools.to_bool函数的典型用法代码示例。如果您正苦于以下问题:Python to_bool函数的具体用法?Python to_bool怎么用?Python to_bool使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了to_bool函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
开发者ID:OSUPychron,项目名称:pychron,代码行数:25,代码来源:utilities.py


示例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()
开发者ID:NMGRL,项目名称:pychron,代码行数:27,代码来源:connection_preferences.py


示例3: wrapper

 def wrapper(*args, **kw):
     r = func(*args, **kw)
     if r:
         r = to_bool(r.strip())
         if invert:
             r = not r
     return r
开发者ID:NMGRL,项目名称:pychron,代码行数:7,代码来源:communication_helper.py


示例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
开发者ID:OSUPychron,项目名称:pychron,代码行数:7,代码来源:pychron_gp_actuator.py


示例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
开发者ID:OSUPychron,项目名称:pychron,代码行数:7,代码来源:base_browser_model.py


示例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
开发者ID:OSUPychron,项目名称:pychron,代码行数:27,代码来源:extraction_line_scene.py


示例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]
开发者ID:NMGRL,项目名称:pychron,代码行数:8,代码来源:parser.py


示例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()
开发者ID:OSUPychron,项目名称:pychron,代码行数:8,代码来源:tasks_plugin.py


示例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()
开发者ID:NMGRL,项目名称:pychron,代码行数:19,代码来源:dvc_preferences.py


示例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)
开发者ID:OSUPychron,项目名称:pychron,代码行数:11,代码来源:laser_handler.py


示例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)
开发者ID:NMGRL,项目名称:pychron,代码行数:13,代码来源:task_extensions.py


示例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)
开发者ID:OSUPychron,项目名称:pychron,代码行数:14,代码来源:irradiation_loader.py


示例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
开发者ID:NMGRL,项目名称:pychron,代码行数:14,代码来源:manager.py


示例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'
开发者ID:OSUPychron,项目名称:pychron,代码行数:15,代码来源:laser.py


示例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
开发者ID:OSUPychron,项目名称:pychron,代码行数:15,代码来源:base_tasks_application.py


示例16: get_plugins

    def get_plugins(self, category=None, all_=False, element=False):
        tree = self.get_root()
        tree = tree.find('plugins')
        if category:
            cat = tree.find(category)
            if cat is not None:
                plugins = cat.findall('plugin')
        else:
            try:
                plugins = tree.iter(tag='plugin')
            except AttributeError:
                plugins = tree.getiterator(tag='plugin')

        if plugins:
            return [p if element else p.text.strip()
                    for p in plugins if all_ or to_bool(p.get('enabled'))]
开发者ID:OSUPychron,项目名称:pychron,代码行数:16,代码来源:initialization_parser.py


示例17: activated

    def activated(self):

        model = self._get_browser_model()
        self.browser_model = model
        if not model.is_activated:
            self._setup_browser_model()

        with no_update(self):
            self.browser_model.current_task_name = self.default_task_name

        # self._top_level_filter = None
        self.activate_workspace()

        self.browser_model.activated()

        if to_bool(self.application.preferences.get('pychron.dvc.enabled')):
            self.dvc = self.application.get_service('pychron.dvc.dvc.DVC')
开发者ID:OSUPychron,项目名称:pychron,代码行数:17,代码来源:browser_task.py


示例18: _editor_factory

    def _editor_factory(self, is_uv=False, **kw):
        klass = UVExperimentEditor if is_uv else ExperimentEditor
        editor = klass(application=self.application,
                       automated_runs_editable=self.automated_runs_editable,
                       **kw)

        prefs = self.application.preferences
        prefid = 'pychron.experiment'
        bgcolor = prefs.get('{}.bg_color'.format(prefid))
        even_bgcolor = prefs.get('{}.even_bg_color'.format(prefid))
        use_analysis_type_colors = to_bool(prefs.get('{}.use_analysis_type_colors'.format(prefid)))

        editor.setup_tabular_adapters(bgcolor, even_bgcolor,
                                      self._assemble_state_colors(),
                                      use_analysis_type_colors,
                                      self._assemble_analysis_type_colors())
        return editor
开发者ID:NMGRL,项目名称:pychron,代码行数:17,代码来源:experiment_task.py


示例19: _get_parameters

 def _get_parameters(self, subtree, tag, all_=False, element=False):
     if subtree is None:
         print subtree
     return [d if element else d.text.strip()
             for d in subtree.findall(tag)
             if all_ or to_bool(d.get('enabled'))]
开发者ID:OSUPychron,项目名称:pychron,代码行数:6,代码来源:initialization_parser.py


示例20: _switch_factory

    def _switch_factory(self, v_elem, klass=None):
        if klass is None:
            klass = HardwareValve

        name = v_elem.text.strip()
        address = v_elem.find('address')
        act_elem = v_elem.find('actuator')
        description = v_elem.find('description')

        positive_interlocks = [i.text.strip() for i in v_elem.findall('positive_interlock')]
        interlocks = [i.text.strip() for i in v_elem.findall('interlock')]
        if description is not None:
            description = description.text.strip()

        actname = act_elem.text.strip() if act_elem is not None else 'switch_controller'
        actuator = self.get_actuator_by_name(actname)
        if actuator is None:
            if not globalv.ignore_initialization_warnings:
                self.warning_dialog(
                    'No actuator for {}. Valve will not operate. Check setupfiles/extractionline/valves.xml'.format(
                        name))

        qs = True
        vqs = v_elem.get('query_state')
        if vqs:
            qs = vqs == 'true'

        parent = v_elem.find('parent')

        parent_name = ''
        parent_inverted = False
        if parent is not None:
            parent_name = parent.text.strip()
            inverted = parent.find('inverted')
            if inverted is not None:
                parent_inverted = to_bool(inverted.text.strip())

        check_actuation_enabled = True
        cae = v_elem.find('check_actuation_enabled')
        if cae is not None:
            check_actuation_enabled = to_bool(cae.text.strip())

        check_actuation_delay = 0
        cad = v_elem.find('check_actuation_delay')
        if cad is not None:
            check_actuation_delay = float(cad.text.strip())

        st = v_elem.find('settling_time')
        if st is not None:
            st = float(st.txt.strip())

        hv = klass(name,
                   address=address.text.strip() if address is not None else '',
                   parent=parent_name,
                   parent_inverted=parent_inverted,
                   check_actuation_enabled=check_actuation_enabled,
                   check_actuation_delay=check_actuation_delay,
                   actuator=actuator,
                   description=description,
                   query_state=qs,
                   positive_interlocks=positive_interlocks,
                   interlocks=interlocks,
                   settling_time=st or 0)
        return name, hv
开发者ID:kenlchen,项目名称:pychron,代码行数:64,代码来源:switch_manager.py



注:本文中的pychron.core.helpers.strtools.to_bool函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python gui.invoke_in_main_thread函数代码示例发布时间:2022-05-25
下一篇:
Python logger_setup.logging_setup函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap