本文整理汇总了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;未经允许,请勿转载。 |
请发表评论