コード例 #1
0
ファイル: __init__.py プロジェクト: cyclefusion/anaconda
        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)
コード例 #2
0
ファイル: __init__.py プロジェクト: bcl/anaconda
        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)
コード例 #3
0
ファイル: iutil_test.py プロジェクト: cyclefusion/anaconda
    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)
コード例 #4
0
ファイル: __init__.py プロジェクト: bcl/anaconda
        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)
コード例 #5
0
ファイル: iutil_test.py プロジェクト: mopsfelder/anaconda
    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)
コード例 #6
0
        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)
コード例 #7
0
ファイル: __init__.py プロジェクト: thaygiaoth/anaconda
        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)
コード例 #8
0
    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.redraw()
                    self.apply()
                else:
                    ScreenHandler.push_screen_modal(self.dialog,
                                                    self.visible_fields[idx])
                    self.redraw()
                    if self.dialog.value is not None:
                        setdeepattr(self.args,
                                    self.visible_fields[idx].attribute,
                                    self.dialog.value)
                        self.apply()
                return InputState.PROCESSED
        except ValueError:
            pass

        return NormalTUISpoke.input(self, args, key)
コード例 #9
0
ファイル: __init__.py プロジェクト: cyclefusion/anaconda
        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)
コード例 #10
0
ファイル: __init__.py プロジェクト: bcl/anaconda
        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)
コード例 #11
0
ファイル: __init__.py プロジェクト: cyclefusion/anaconda
    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)
コード例 #12
0
    def input(self, args, key):
        try:
            idx = int(key) - 1
            if idx >= 0 and idx < len(self.edit_fields):
                if self.edit_fields[idx].aux == self.CHECK:
                    setdeepattr(self.args, self.edit_fields[idx].attribute,
                                not getdeepattr(self.args, self.edit_fields[idx][1]))
                    self.app.redraw()
                    self.apply()
                else:
                    self.app.switch_screen_modal(self.dialog, self.edit_fields[idx])
                    if self.dialog.value is not None:
                        setdeepattr(self.args, self.edit_fields[idx].attribute,
                                    self.dialog.value)
                        self.apply()
                return True
        except ValueError:
            pass

        return NormalTUISpoke.input(self, args, key)
コード例 #13
0
ファイル: iutil_test.py プロジェクト: cyclefusion/anaconda
    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")
コード例 #14
0
ファイル: iutil_test.py プロジェクト: mopsfelder/anaconda
    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")