def _get_choices(self, value, row):
     if self._previous_value and value.startswith(self._previous_value):
         return [(key, val) for key, val in self._previous_choices
                                 if normalize(key).startswith(normalize(value))]
     choices = self._suggestion_source.get_suggestions(value, row)
     duplicate_names = self._get_duplicate_names(choices)
     return self._format_choices(choices, value, duplicate_names)
Esempio n. 2
0
 def _variable_suggestions(self, controller, start, ctx):
     datafile = controller.datafile
     start_normalized = normalize(start)
     self._add_kw_arg_vars(controller, ctx.vars)
     vars = self._retriever.get_variables_from(datafile, ctx)
     return (v for v in vars
             if normalize(v.name).startswith(start_normalized))
Esempio n. 3
0
 def _get_choices(self, value, row):
     if self._previous_value and value.startswith(self._previous_value):
         return [(key, val) for key, val in self._previous_choices
                                 if normalize(key).startswith(normalize(value))]
     choices = self._suggestion_source.get_suggestions(value, row)
     duplicate_names = self._get_duplicate_names(choices)
     return self._format_choices(choices, value, duplicate_names)
Esempio n. 4
0
 def _variable_suggestions(self, controller, start, ctx):
     datafile = controller.datafile
     start_normalized = normalize(start)
     self._add_kw_arg_vars(controller, ctx.vars)
     vars = self._retriever.get_variables_from(datafile, ctx)
     return (v for v in vars
             if normalize(v.name).startswith(start_normalized))
Esempio n. 5
0
 def _get_duplicate_names(self, choices):
     results = set()
     normalized_names = [normalize(ch.name) for ch in choices]
     for choice in choices:
         normalized = normalize(choice.name)
         if normalized_names.count(normalized) > 1:
             results.add(normalized)
     return results
Esempio n. 6
0
 def _matches_unique_shortname(self, choice, prefix, duplicate_names):
     if isinstance(choice, VariableInfo):
         return True
     if not normalize(choice.name).startswith(normalize(prefix)):
         return False
     if normalize(choice.name) in duplicate_names:
         return False
     return True
 def _matches_unique_shortname(self, choice, prefix, duplicate_names):
     if isinstance(choice, VariableInfo):
         return True
     if not normalize(choice.name).startswith(normalize(prefix)):
         return False
     if normalize(choice.name) in duplicate_names:
         return False
     return True
 def _get_duplicate_names(self, choices):
     results = set()
     normalized_names = [normalize(ch.name) for ch in choices]
     for choice in choices:
         normalized = normalize(choice.name)
         if normalized_names.count(normalized) > 1:
             results.add(normalized)
     return results
Esempio n. 9
0
 def _get_choices(self, value, row):
     if self._previous_value and value.startswith(self._previous_value):
         return [(key, val) for key, val in self._previous_choices
                                 if normalize(key).startswith(normalize(value))]
     if self._controller and row:
         choices = self._controller.get_local_namespace_for_row(row).get_suggestions(value)
     else:
         choices = self._plugin.content_assist_values(value) # TODO: Remove old functionality when no more needed
     return self._format_choices(choices, value)
def find_attribute(obj, attr, prefix):
    attr = str(attr)
    for i_attr in dir(obj):
        normalized_i_attr = normalizing.normalize(i_attr, ignore='_')
        normalized_attr = normalizing.normalize(prefix + attr, ignore='_')
        if normalized_i_attr == normalized_attr:
            return getattr(obj, i_attr)

    try:
        attr = int(attr, 0)
        return attr
    except ValueError:
        raise RuntimeError('Attribute "%s" in "%s" not found.' % (attr, obj))
Esempio n. 11
0
def find_attribute(obj, attr, prefix):
    attr = str(attr)
    for i_attr in dir(obj):
        normalized_i_attr = normalizing.normalize(i_attr, ignore='_')
        normalized_attr = normalizing.normalize(prefix + attr,
                ignore='_')
        if normalized_i_attr == normalized_attr:
            return getattr(obj, i_attr)

    try:
        attr = int(attr, 0)
        return attr
    except ValueError:
        raise RuntimeError('Attribute "%s" in "%s" not found.' % (attr, obj))
Esempio n. 12
0
 def _keyword_suggestions(self, datafile, start, ctx):
     start_normalized = normalize(start)
     return (
         sug
         for sug in chain(self._get_default_keywords(),
                          self._retriever.get_keywords_from(datafile, ctx))
         if sug.name_begins_with(start_normalized)
         or sug.longname_begins_with(start_normalized))
Esempio n. 13
0
 def _keyword_suggestions(self, datafile, start, ctx):
     start_normalized = normalize(start)
     return (sug for sug in chain(self._get_default_keywords(),
                                        self._retriever.get_keywords_from(datafile, ctx))
                   if sug.name_begins_with(start_normalized) or
                      sug.longname_begins_with(start_normalized))
Esempio n. 14
0
 def longname_begins_with(self, prefix):
     return normalize(self.longname).startswith(prefix)
Esempio n. 15
0
 def longname_begins_with(self, prefix):
     return normalize(self.longname).startswith(prefix)
Esempio n. 16
0
 def _format(self, choice, prefix):
     return choice.name if normalize(choice.name).startswith(normalize(prefix)) else choice.longname