Show the minimum needs dialog.
194820
def show_minimum_needs_configuration(self):
        """"""
        # import here only so that it is AFTER i18n set up
        from safe.gui.tools.minimum_needs.needs_manager_dialog import (
            NeedsManagerDialog)

        dialog = NeedsManagerDialog(
            parent=self.iface.mainWindow(),
            dock=self.dock_widget)
        dialog.exec_()
403836
def requirements(self):
        """"""
        class dotdict(dict):  # pylint: disable=invalid-name
            """Dot notation access to dictionary attributes."""

            def __getattr__(self, attr):
                value = self.get(attr)
                return dotdict(value) if isinstance(value, dict) else value

        return dotdict(self._meta.metadata.requirements)
295637
def _rlimit_min(one_val, nother_val):
    """"""
    if one_val < 0 or nother_val < 0 :
        return max(one_val, nother_val)
    else:
        return min(one_val, nother_val)
341542
def minimum_needs_parameter(field=None, parameter_name=None):
    
    try:
        if field['key']:
            for need_field in minimum_needs_fields:
                if need_field['key'] == field['key']:
                    return need_field['need_parameter']
    except (TypeError, KeyError):
        # in case field is None or field doesn't contain key.
        # just pass
        pass

    if parameter_name:
        for need_field in minimum_needs_fields:
            if need_field['need_parameter'].name == parameter_name:
                return need_field['need_parameter']
    return None
148280
def minimum(self, value):
        
        self._remove_min()
        if value is None:
            return
        self._add_min(val=value)
306251
def check_command(args):
    """"""
    outdated = check_requirements_file(args.requirements_file,
                                       args.skip_packages)

    if outdated:
        print('Requirements in {} are out of date:'.format(
            args.requirements_file))

        for item in outdated:
            print(' * {} is {} latest is {}.'.format(*item))

        sys.exit(1)
    else:
        print('Requirements in {} are up to date.'.format(
            args.requirements_file))
1074555
def check_requisite(self, low, running, chunks, pre=False):
        '''
        
        '''
        disabled_reqs = self.opts.get('disabled_requisites', [])
        if not isinstance(disabled_reqs, list):
            disabled_reqs = [disabled_reqs]
        present = False
        # If mod_watch is not available make it a require
        if 'watch' in low:
            if '{0}.mod_watch'.format(low['state']) not in self.states:
                if 'require' in low:
                    low['require'].extend(low.pop('watch'))
                else:
                    low['require'] = low.pop('watch')
            else:
                present = True
        if 'watch_any' in low:
            if '{0}.mod_watch'.format(low['state']) not in self.states:
                if 'require_any' in low:
                    low['require_any'].extend(low.pop('watch_any'))
                else:
                    low['require_any'] = low.pop('watch_any')
            else:
                present = True
        if 'require' in low:
            present = True
        if 'require_any' in low:
            present = True
        if 'prerequired' in low:
            present = True
        if 'prereq' in low:
            present = True
        if 'onfail' in low:
            present = True
        if 'onfail_any' in low:
            present = True
        if 'onfail_all' in low:
            present = True
        if 'onchanges' in low:
            present = True
        if 'onchanges_any' in low:
            present = True
        if not present:
            return 'met', ()
        self.reconcile_procs(running)
        reqs = {
                'require': [],
                'require_any': [],
                'watch': [],
                'watch_any': [],
                'prereq': [],
                'onfail': [],
                'onfail_any': [],
                'onfail_all': [],
                'onchanges': [],
                'onchanges_any': []}
        if pre:
            reqs['prerequired'] = []
        for r_state in reqs:
            if r_state in low and low[r_state] is not None:
                if r_state in disabled_reqs:
                    log.warning('The %s requisite has been disabled, Ignoring.', r_state)
                    continue
                for req in low[r_state]:
                    if isinstance(req, six.string_types):
                        req = {'id': req}
                    req = trim_req(req)
                    found = False
                    for chunk in chunks:
                        req_key = next(iter(req))
                        req_val = req[req_key]
                        if req_val is None:
                            continue
                        if req_key == 'sls':
                            # Allow requisite tracking of entire sls files
                            if fnmatch.fnmatch(chunk['__sls__'], req_val):
                                found = True
                                reqs[r_state].append(chunk)
                            continue
                        try:
                            if isinstance(req_val, six.string_types):
                                if (fnmatch.fnmatch(chunk['name'], req_val) or
                                    fnmatch.fnmatch(chunk['__id__'], req_val)):
                                    if req_key == 'id' or chunk['state'] == req_key:
                                        found = True
                                        reqs[r_state].append(chunk)
                            else:
                                raise KeyError
                        except KeyError as exc:
                            raise SaltRenderError(
                                'Could not locate requisite of [{0}] present in state with name [{1}]'.format(
                                    req_key, chunk['name']))
                        except TypeError:
                            # On Python 2, the above req_val, being an OrderedDict, will raise a KeyError,
                            # however on Python 3 it will raise a TypeError
                            # This was found when running tests.unit.test_state.StateCompilerTestCase.test_render_error_on_invalid_requisite
                            raise SaltRenderError(
                                'Could not locate requisite of [{0}] present in state with name [{1}]'.format(
                                    req_key, chunk['name']))
                    if not found:
                        return 'unmet', ()
        fun_stats = set()
        for r_state, chunks in six.iteritems(reqs):
            req_stats = set()
            if r_state.startswith('prereq') and not r_state.startswith('prerequired'):
                run_dict = self.pre
            else:
                run_dict = running

            while True:
                if self.reconcile_procs(run_dict):
                    break
                time.sleep(0.01)

            for chunk in chunks:
                tag = _gen_tag(chunk)
                if tag not in run_dict:
                    req_stats.add('unmet')
                    continue
                if r_state.startswith('onfail'):
                    if run_dict[tag]['result'] is True:
                        req_stats.add('onfail')  # At least one state is OK
                        continue
                else:
                    if run_dict[tag]['result'] is False:
                        req_stats.add('fail')
                        continue
                if r_state.startswith('onchanges'):
                    if not run_dict[tag]['changes']:
                        req_stats.add('onchanges')
                    else:
                        req_stats.add('onchangesmet')
                    continue
                if r_state.startswith('watch') and run_dict[tag]['changes']:
                    req_stats.add('change')
                    continue
                if r_state.startswith('prereq') and run_dict[tag]['result'] is None:
                    if not r_state.startswith('prerequired'):
                        req_stats.add('premet')
                if r_state.startswith('prereq') and not run_dict[tag]['result'] is None:
                    if not r_state.startswith('prerequired'):
                        req_stats.add('pre')
                else:
                    if run_dict[tag].get('__state_ran__', True):
                        req_stats.add('met')
            if r_state.endswith('_any') or r_state == 'onfail':
                if 'met' in req_stats or 'change' in req_stats:
                    if 'fail' in req_stats:
                        req_stats.remove('fail')
                if 'onchangesmet' in req_stats:
                    if 'onchanges' in req_stats:
                        req_stats.remove('onchanges')
                    if 'fail' in req_stats:
                        req_stats.remove('fail')
                if 'onfail' in req_stats:
                    # a met requisite in this case implies a success
                    if 'met' in req_stats:
                        req_stats.remove('onfail')
            if r_state.endswith('_all'):
                if 'onfail' in req_stats:
                    # a met requisite in this case implies a failure
                    if 'met' in req_stats:
                        req_stats.remove('met')
            fun_stats.update(req_stats)

        if 'unmet' in fun_stats:
            status = 'unmet'
        elif 'fail' in fun_stats:
            status = 'fail'
        elif 'pre' in fun_stats:
            if 'premet' in fun_stats:
                status = 'met'
            else:
                status = 'pre'
        elif 'onfail' in fun_stats and 'onchangesmet' not in fun_stats:
            status = 'onfail'
        elif 'onchanges' in fun_stats and 'onchangesmet' not in fun_stats:
            status = 'onchanges'
        elif 'change' in fun_stats:
            status = 'change'
        else:
            status = 'met'

        return status, reqs
884945
def _check_min(par, minval, name, unit, verb):
    """
    scalar = False
    if par.shape == ():
        scalar = True
        par = np.atleast_1d(par)
    if minval is not None:
        ipar = np.where(par < minval)
        par[ipar] = minval
        if verb > 0 and np.size(ipar) != 0:
            print('* WARNING :: ' + name + ' < ' + str(minval) + ' ' + unit +
                  ' are set to ' + str(minval) + ' ' + unit + '!')
    if scalar:
        return np.squeeze(par)
    else:
        return par
909523
def q_limited(self):
        
        if (self.q >= self.q_max) or (self.q <= self.q_min):
            return True
        else:
            return False
741593
def ok(self, *args, cb=None):
        """"""
        self.clear_widgets()
        if cb:
            cb()
        self.idx += 1
        self.advance_dialog()
1228614
def get_requirements():
    """"""
    with open(os.path.join(topdir, 'requirements.txt')) as fin:
        lines = fin.readlines()
    lines = [line.strip() for line in lines]
    return lines
1308022
def ensure_hbounds(self):
        """"""
        self.cursor.x = min(max(0, self.cursor.x), self.columns - 1)
837521
def show_help(self):
        """"""
        print("Sorry, not well understood.")
        print("- use", str(self.yes_input), "to answer 'YES'")
        print("- use", str(self.no_input), "to answer 'NO'")
29909
def display_dialog(self, *args, **kwargs):
        """"""
        form = kwargs.pop('form_instance', None)
        success_message = kwargs.pop('success_message', None)

        if not form:
            form = self.get_form_class()(initial=kwargs, instance=self.object)

        if not hasattr(form, "helper"):
            form.helper = FormHelper()
        form.helper.form_tag = False

        return {
            'title': self.title.format(
                model_name=self.get_model_config().model_name,
                object=str(self.object) if self.object else '',
            ),
            'content': self.render_to_string(self.template, {
                'form': form,
                'success_message': success_message,
            }),
            'submit_label': self.submit_label,
            'success': bool(success_message),
        }
263521
def _create_minimum_needs_action(self):
        """"""
        icon = resources_path('img', 'icons', 'show-minimum-needs.svg')
        self.action_minimum_needs = QAction(
            QIcon(icon),
            self.tr('Minimum Needs Calculator'), self.iface.mainWindow())
        self.action_minimum_needs.setStatusTip(self.tr(
            'Open InaSAFE minimum needs calculator'))
        self.action_minimum_needs.setWhatsThis(self.tr(
            'Open InaSAFE minimum needs calculator'))
        self.action_minimum_needs.triggered.connect(self.show_minimum_needs)
        self.add_action(
            self.action_minimum_needs, add_to_toolbar=self.full_toolbar)
13294
def min(self):
        """"""
        if "min" not in self.attrs.keys():

            def f(dataset, s):
                return np.nanmin(dataset[s])

            self.attrs["min"] = np.nanmin(list(self.chunkwise(f).values()))
        return self.attrs["min"]
494615
def show_error(self, *messages):
        """"""
        if not self.quiet:
            self.display(messages, main_sig, debug=True)