Esempio n. 1
0
 def _variable_suggestions(self, controller, start, ctx):  #建议变量
     datafile = controller.datafile
     start_normalized = utils.normalize(start)
     self._add_kw_arg_vars(controller, ctx.vars)
     variables = self._retriever.get_variables_from(datafile, ctx)
     return (v for v in variables
             if utils.normalize(v.name).startswith(start_normalized))
Esempio n. 2
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 utils.normalize(key).startswith(utils.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. 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 utils.normalize(key).startswith(utils.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 = utils.normalize(start)
     self._add_kw_arg_vars(controller, ctx.vars)
     variables = self._retriever.get_variables_from(datafile, ctx)
     return (v for v in variables
             if utils.normalize(v.name).startswith(start_normalized))
Esempio n. 5
0
 def _matches_unique_shortname(self, choice, prefix, duplicate_names):
     if isinstance(choice, VariableInfo):
         return True
     if not utils.normalize(choice.name).startswith(utils.normalize(prefix)):
         return False
     if utils.normalize(choice.name) in duplicate_names:
         return False
     return True
Esempio n. 6
0
 def _get_duplicate_names(self, choices):
     results = set()
     normalized_names = [utils.normalize(ch.name) for ch in choices]
     for choice in choices:
         normalized = utils.normalize(choice.name)
         if normalized_names.count(normalized) > 1:
             results.add(normalized)
     return results
Esempio n. 7
0
 def _get_duplicate_names(self, choices):
     results = set()
     normalized_names = [utils.normalize(ch.name) for ch in choices]
     for choice in choices:
         normalized = utils.normalize(choice.name)
         if normalized_names.count(normalized) > 1:
             results.add(normalized)
     return results
Esempio n. 8
0
 def _matches_unique_shortname(self, choice, prefix, duplicate_names):
     if isinstance(choice, VariableInfo):
         return True
     if not utils.normalize(choice.name).startswith(
             utils.normalize(prefix)):
         return False
     if utils.normalize(choice.name) in duplicate_names:
         return False
     return True
def highlight_matcher(value, content):
    if not value or not content:
        return False
    selection = normalize(value, ignore=['_'])
    if not selection:
        return False
    target = normalize(content, ignore=['_'])
    if not target:
        return False
    if selection == target:
        return True
    return _variable_matches(selection, target)
Esempio n. 10
0
def highlight_matcher(value, content):
    if not value or not content:
        return False
    selection = normalize(value, ignore=['_'])
    if not selection:
        return False
    target = normalize(content, ignore=['_'])
    if not target:
        return False
    if selection == target:
        return True
    return _variable_matches(selection, target)
Esempio n. 11
0
 def _keyword_suggestions(self, datafile, start, ctx):
     start_normalized = utils.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. 12
0
 def _keyword_suggestions(self, datafile, start, ctx):
     start_normalized = utils.normalize(start)
     all_kws = chain(self._get_default_keywords(),
                     self._retriever.get_keywords_from(datafile, ctx))
     return (sug for sug in all_kws
             if sug.name_begins_with(start_normalized)
             or sug.longname_begins_with(start_normalized))
Esempio n. 13
0
 def select_user_keyword_node(self, uk):
     parent_node = self._get_datafile_node(uk.parent.parent)
     if not parent_node:
         return
     if not self.IsExpanded(parent_node):
         self._expand_and_render_children(parent_node)
     node = self._controller.find_node_with_label(parent_node, utils.normalize(uk.name))
     if node != self.GetSelection():
         self.SelectItem(node)
Esempio n. 14
0
 def select_user_keyword_node(self, uk):
     parent_node = self._get_datafile_node(uk.parent.parent)
     if not parent_node:
         return
     if not self.IsExpanded(parent_node):
         self._expand_and_render_children(parent_node)
     node = self._controller.find_node_with_label(parent_node, utils.normalize(uk.name))
     if node != self.GetSelection():
         self.SelectItem(node)
Esempio n. 15
0
 def longname_begins_with(self, prefix):
     return utils.normalize(self.longname).startswith(prefix)
Esempio n. 16
0
 def is_unique(gvar):#是否是唯一的
     return utils.normalize(gvar.name) not in \
     [utils.normalize(lvar.name) for lvar in local_variables]
Esempio n. 17
0
 def _contains(self, string, pattern):
     return utils.normalize(pattern) in utils.normalize(string)
Esempio n. 18
0
 def name_matches(self, pattern):
     normalized = utils.normalize(self._undecorate(pattern))
     return utils.normalize(self.name[2:-1]).startswith(normalized)
Esempio n. 19
0
 def longname_begins_with(self, prefix):
     return utils.normalize(self.longname).startswith(prefix)
Esempio n. 20
0
 def is_unique(gvar):
     return utils.normalize(gvar.name) not in \
     [utils.normalize(lvar.name) for lvar in local_variables]
Esempio n. 21
0
 def name_begins_with(self, prefix):  #名字以什么开始
     return utils.normalize(self.name).startswith(prefix)
Esempio n. 22
0
 def __init__(self, initial=None, ignore=(), caseless=True, spaceless=True):
     self._data = {}
     self._keys = {}
     self._normalize = lambda s: utils.normalize(s, ignore, caseless,
                                                 spaceless)
     super(utils.NormalizedDict)