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

Python iutil.getdeepattr函数代码示例

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

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



在下文中一共展示了getdeepattr函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _prep_text

        def _prep_text(i, entry):
            number = tui.TextWidget("%2d)" % i)
            title = tui.TextWidget(_(entry.title))
            value = getdeepattr(self.args, entry.attribute)
            value = tui.TextWidget(value)

            return tui.ColumnWidget([(3, [number]), (None, [title, value])], 1)
开发者ID:cyclefusion,项目名称:anaconda,代码行数:7,代码来源:__init__.py


示例2: set_deep_attr_test

    def set_deep_attr_test(self):
        """Test setdeepattr."""

        # pylint: disable=attribute-defined-outside-init
        # pylint: disable=no-member

        class O(object):
            pass

        a = O()
        a.b = O()
        a.b1 = 1
        a.b.c = O()
        a.b.c1 = "ř"

        # set to a new attribute
        iutil.setdeepattr(a, "b.c.d", True)
        self.assertEqual(a.b.c.d, True)

        # override existing attribute
        iutil.setdeepattr(a, "b.c", 1234)
        self.assertEqual(a.b.c, 1234)

        # "" is actually a valid attribute name
        # that can be only accessed by getattr
        iutil.setdeepattr(a, "", 1234)
        self.assertEqual(getattr(a, ""), 1234)

        iutil.setdeepattr(a, "b.", 123)
        self.assertEqual(iutil.getdeepattr(a, "b."), 123)

        # error should raise AttributeError
        with self.assertRaises(AttributeError):
            iutil.setdeepattr(a, "b.c.d.e.f.g.h", 1234)
开发者ID:cyclefusion,项目名称:anaconda,代码行数:34,代码来源:iutil_test.py


示例3: _prep_password

        def _prep_password(i, entry):
            number = tui.TextWidget("%2d)" % i)
            title = tui.TextWidget(_(entry.title))
            value = getdeepattr(self.args, entry.attribute)
            value = tui.TextWidget("".join(["*"] * len(value)))

            return tui.ColumnWidget([(3, [number]), (None, [title, value])], 1)
开发者ID:cs2c-zhangchao,项目名称:nkwin1.0-anaconda,代码行数:7,代码来源:__init__.py


示例4: _prep_check

        def _prep_check(i, entry):
            number = tui.TextWidget("%2d)" % i)
            value = getdeepattr(self.args, entry.attribute)
            ch = tui.CheckboxWidget(
                title=_(entry.title), completed=bool(value))

            return tui.ColumnWidget([(3, [number]), (None, [ch])], 1)
开发者ID:thaygiaoth,项目名称:anaconda,代码行数:7,代码来源:__init__.py


示例5: _prep_password

        def _prep_password(i, entry):
            number = tui.TextWidget("%2d)" % i)
            title = tui.TextWidget(_(entry.title))
            value = ""
            if len(getdeepattr(self.args, entry.attribute)) > 0:
                value = _("Password set.")
            value = tui.TextWidget(value)

            return tui.ColumnWidget([(3, [number]), (None, [title, value])], 1)
开发者ID:cyclefusion,项目名称:anaconda,代码行数:9,代码来源:__init__.py


示例6: input

    def input(self, args, key):
        try:
            idx = int(key) - 1
            if idx >= 0 and idx < len(self.visible_fields):
                if self.visible_fields[idx].aux == self.CHECK:
                    setdeepattr(self.args, self.visible_fields[idx].attribute,
                                not getdeepattr(self.args, self.visible_fields[idx][1]))
                    self.app.redraw()
                    self.apply()
                else:
                    self.app.switch_screen_modal(self.dialog, self.visible_fields[idx])
                    if self.dialog.value is not None:
                        setdeepattr(self.args, self.visible_fields[idx].attribute,
                                    self.dialog.value)
                        self.apply()
                return True
        except ValueError:
            pass

        return NormalTUISpoke.input(self, args, key)
开发者ID:cyclefusion,项目名称:anaconda,代码行数:20,代码来源:__init__.py


示例7: get_deep_attr_test

    def get_deep_attr_test(self):
        """Test getdeepattr."""

        # pylint: disable=attribute-defined-outside-init

        class O(object):
            pass

        a = O()
        a.b = O()
        a.b1 = 1
        a.b.c = 2
        a.b.c1 = "ř"

        self.assertEqual(iutil.getdeepattr(a, "b1"), 1)
        self.assertEqual(iutil.getdeepattr(a, "b.c"), 2)
        self.assertEqual(iutil.getdeepattr(a, "b.c1"), "ř")

        # be consistent with getattr and throw
        # AttributeError if non-existent attribute is requested
        with self.assertRaises(AttributeError):
            iutil.getdeepattr(a, "")
        with self.assertRaises(AttributeError):
            iutil.getdeepattr(a, "b.c.d")
开发者ID:cyclefusion,项目名称:anaconda,代码行数:24,代码来源:iutil_test.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python iutil.ipmi_report函数代码示例发布时间:2022-05-25
下一篇:
Python iutil.getSysroot函数代码示例发布时间: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