Beispiel #1
0
    def config_call():
        form = npys.ActionPopup(name='Values returned by callables')
        cb_skip_classes = form.add(npys.Checkbox,
                                   name="Skip classes (__init__)")
        cb_skip_genfunc = form.add(npys.Checkbox,
                                   name="Skip generator functions")

        form.add(Separator)
        opt_list = npys.OptionList()
        opt_list.options.append(
            OptionMultiFreeListNarrow('Skip callables named'))
        opt_skip_callables = form.add(npys.OptionListDisplay,
                                      values=opt_list.options,
                                      scroll_exit=True,
                                      max_height=None)
        opt_list.options[0].set(['exit'])

        widgets = SimpleNamespace()
        widgets.cb_skip_classes = cb_skip_classes
        widgets.cb_skip_genfunc = cb_skip_genfunc
        widgets.cb_skip_genfunc = cb_skip_genfunc
        widgets.opt_skip_callables = opt_skip_callables

        load_subconfig_call(subconfig, widgets)
        form.on_ok = lambda: store_subconfig_call(subconfig, widgets)
        form.display()
        form.edit()
Beispiel #2
0
        def whenPressed(self):
            # file_name = npyscreen.selectFile(must_exist=False,sort_by_extension=True)
            f = npyscreen.ActionPopup(name="New target and config creation")
            cfg_wgt = f.add(npyscreen.TitleText, name="Config name")
            tgt_wgt = f.add(npyscreen.TitleText, name="Target name")
            f.edit()

            cfg_name = cfg_wgt.value
            tgt_name = tgt_wgt.value

            if os.path.isfile(
                    os.path.normpath(self.project_path + '/' + cfg_name)):
                npyscreen.notify_confirm(
                    'File {} is already exists, please select another name'.
                    format(cfg_name),
                    title='File already exists')
            elif not cfg_name or len(cfg_name) == 0:
                npyscreen.notify_confirm('Invalid configuration file name',
                                         title='Invalid file name')
            elif not tgt_name or len(tgt_name) == 0:
                npyscreen.notify_confirm('Invalid target name',
                                         'Invalid target name')
            else:
                self.parent.user_action = 'new_cfg'
                self.parent.selected_file = cfg_name
                self.parent.selected_target = tgt_name
                # Create new metafile
                self.parent.metadata[tgt_name] = {'config': cfg_name}
                # Close whole form
                self.parent.editing = False
Beispiel #3
0
    def config_attr():
        form = npys.ActionPopup(name='Attributes')
        cb_skip_func = form.add(npys.Checkbox, name="Skip functions")
        cb_skip_meth = form.add(npys.Checkbox, name="Skip methods")
        cb_skip_priv = form.add(npys.Checkbox,
                                name="Skip non-public (_xyz, __xyz)")
        cb_skip_dund = form.add(npys.Checkbox, name="Skip dunders (__xyz__)")

        form.add(Separator)
        opt_list = npys.OptionList()
        opt_list.options.append(
            OptionMultiFreeListNarrow("Don't visit instances of"))
        opt_dont_visit = form.add(npys.OptionListDisplay,
                                  values=opt_list.options,
                                  scroll_exit=True,
                                  max_height=None)
        opt_list.options[0].set([
            'bool', 'int', 'float', 'complex', 'bytes', 'bytearray', 'str',
            'dict', 'list', 'set', 'frozenset', 'memoryview', 'type(None)'
        ])

        widgets = SimpleNamespace()
        widgets.cb_skip_func = cb_skip_func
        widgets.cb_skip_meth = cb_skip_meth
        widgets.cb_skip_priv = cb_skip_priv
        widgets.cb_skip_dund = cb_skip_dund
        widgets.opt_dont_visit = opt_dont_visit

        load_subconfig_attr(subconfig, widgets)
        form.on_ok = lambda: store_subconfig_attr(subconfig, widgets)
        form.display()
        form.edit()
    def onRegisterPopup(self):
        def on_ok():
            self.reset()
            self.display()

        def on_cancel():
            self.parentApp.setNextForm(None)

        form = npyscreen.ActionPopup(
            name="All the entities for the Data Center has been registered",
            lines=9,
            columns=80)
        form.show_aty = 7
        form.show_atx = 45
        form.OK_BUTTON_TEXT = 'Yes'
        form.CANCEL_BUTTON_TEXT = 'No'
        form.on_ok = on_ok
        form.on_cancel = on_cancel
        label = form.add_widget(
            npyscreen.FixedText,
            value='Do you want to register entities from another Data Center?',
            color='CONTROL',
            editable=0,
            rely=3)
        action = form.edit()
        return action
    def onImportPopup(self, title, success, error):
        def on_ok():
            pass

        def on_cancel():
            self.parentApp.setNextForm('import_entities')

        form = npyscreen.ActionPopup(name=title, lines=9, columns=80)
        form.show_aty = 7
        form.OK_BUTTON_TEXT = 'Yes'
        form.CANCEL_BUTTON_TEXT = 'No'
        form.on_ok = on_ok
        form.on_cancel = on_cancel

        if (success != None):
            form.success = form.add(npyscreen.FixedText,
                                    value=success,
                                    color='VERYGOOD',
                                    editable=False,
                                    rely=2)
        else:
            form.error = form.add(npyscreen.FixedText,
                                  value=error,
                                  color='CRITICAL',
                                  editable=False,
                                  rely=2)

        label = form.add_widget(
            npyscreen.FixedText,
            value='Do you want to import additional storage domains?',
            color='CONTROL',
            editable=0,
            rely=5)
        action = form.edit()
        return action
    def form_export_to(self):
        """Show the form to select the export_format and the file name

        :returns
        A export_format file and the name of the file.

        """

        export_form = npyscreen.ActionPopup(name="Export to")

        format_to = export_form.add(
            npyscreen.TitleSelectOne,
            max_height=4,
            value=[
                1,
            ],
            name="Select export_format",
            values=["excel", "csv", "string", "markdown", "HTML"],
            scroll_exit=True)
        file_name_path = export_form.add(
            npyscreen.TitleText,
            name="File and name path:",
        )

        file_name_path.value = "changeme.txt"

        export_form.edit()

        return format_to.value[0], file_name_path.value
Beispiel #7
0
    def config_iter():
        form = npys.ActionPopup(name='Items of iterables')
        ct_max_count = form.add(TitleConstrainedText,
                                name='Max count',
                                value='5')
        ct_max_count.entry_widget.set_validator(parse_count)

        widgets = SimpleNamespace()
        widgets.ct_max_count = ct_max_count

        load_subconfig_iter(subconfig, widgets)
        form.on_ok = lambda: store_subconfig_iter(subconfig, widgets)
        form.display()
        form.edit()
Beispiel #8
0
def save_config_dialog(widgets, subconfigs):
    config_name = widgets.co_config.values[widgets.co_config.value]
    if config_name == DEFAULT_CONFIG_NAME:
        config_name = "Untitled"
    form = npys.ActionPopup(name='Save Config')

    ct_config_name = form.add(TitleConstrainedText,
                              name='Config',
                              value=config_name)

    form.add(Separator)

    ct_overwrite = form.add(ConstrainedText)
    ct_overwrite.editable = False

    def check_existing(value):
        ct_overwrite.value = ''
        try:
            config_name_validator(value)
        except Exception:
            raise
        else:
            if ct_config_name.value != DEFAULT_CONFIG_NAME and ct_config_name.value in widgets.co_config.values:
                if widgets.co_config.values.index(
                        ct_config_name.value) == widgets.co_config.value:
                    ct_overwrite.value = '(current config)'
                else:
                    ct_overwrite.value = '(existing config)'
        finally:
            ct_overwrite.update()

    def update_co_config():
        if ct_config_name.value not in widgets.co_config.values:
            widgets.co_config.values.append(ct_config_name.value)
        widgets.co_config.value = widgets.co_config.values.index(
            ct_config_name.value)
        widgets.co_config.update()

    ct_config_name.entry_widget.set_validator(check_existing)
    form.on_ok = update_co_config
    check_existing(ct_config_name.value)
    form.display()
    form.edit()
Beispiel #9
0
    def config_item():
        form = npys.ActionPopup(name='Items of mappings')
        co_iterator = form.add(TitleComboEx,
                               name="Iterator",
                               values=[
                                   'obj.items()',
                                   'zip(obj.keys(), obj.values())',
                                   '(key, obj[key] for key in obj.keys())'
                               ])
        #['Call items method', 'Zip keys and values', 'Subscribe from keys'])
        co_iterator.entry_widget.on_popup_close_callback = lambda widget: None
        co_iterator.value = 0

        widgets = SimpleNamespace()
        widgets.co_iterator = co_iterator

        load_subconfig_item(subconfig, widgets)
        form.on_ok = lambda: store_subconfig_item(subconfig, widgets)
        form.display()
        form.edit()