def primary_matches(self, text):
     """Return matches when text is at beginning of the line"""
     matches = []
     n = len(text)
     for list in [keyword.kwlist,
                              __builtin__.__dict__.keys(),
                              __main__.__dict__.keys()]:
         for word in list:
             if word[:n] == text:
                 matches.append(word)
     # IRAF module functions
     matches.extend(iraf.getAllMatches(text))
     return matches
Example #2
0
 def primary_matches(self, text):
     """Return matches when text is at beginning of the line"""
     matches = []
     n = len(text)
     for list in [
             keyword.kwlist,
             __builtin__.__dict__.keys(),
             __main__.__dict__.keys()
     ]:
         for word in list:
             if word[:n] == text:
                 matches.append(word)
     # IRAF module functions
     matches.extend(iraf.getAllMatches(text))
     return matches
Example #3
0
 def secondary_matches(self, text, line):
     """Compute matches for tokens when not at start of line"""
     # Check first character following initial alphabetic string.
     # If next char is alphabetic (or null) use filename matches.
     # Also use filename matches if line starts with '!'.
     # Otherwise use matches from Python dictionaries.
     lt = len(line) - len(text)
     if line[:1] == "!":
         # Matching filename for OS escapes
         # Ideally would use tcsh-style matching of commands
         # as first argument, but that looks unreasonably hard
         return self.filename_matches(text, line[:lt])
     m = self.taskpat.match(line)
     if m is None or keyword.iskeyword(m.group(1)):
         if line[lt - 1:lt] in ['"', "'"]:
             # use filename matches for quoted strings
             return self.filename_matches(text, line[:lt])
         else:
             if not hasattr(self, "namespace"):
                 self.namespace = {}
             return Completer.global_matches(self, text)
     else:
         taskname = m.group(1)
         # check for pipe/redirection using last non-blank character
         mpipe = re.search(r"[|><][ \t]*$", line[:lt])
         if mpipe:
             s = mpipe.group(0)
             if s[0] == "|":
                 # pipe -- use task matches
                 return iraf.getAllMatches(text)
             else:
                 # redirection -- just match filenames
                 return self.filename_matches(text, line[:lt])
         elif taskname in taskArgDict:
             # task takes task names as arguments
             return iraf.getAllTasks(text)
         elif taskname in pkgArgDict:
             # task takes package names as arguments
             return iraf.getAllPkgs(text)
         else:
             return self.argument_matches(text, taskname, line)
 def secondary_matches(self, text, line):
     """Compute matches for tokens when not at start of line"""
     # Check first character following initial alphabetic string.
     # If next char is alphabetic (or null) use filename matches.
     # Also use filename matches if line starts with '!'.
     # Otherwise use matches from Python dictionaries.
     lt = len(line)-len(text)
     if line[:1] == "!":
         # Matching filename for OS escapes
         # Ideally would use tcsh-style matching of commands
         # as first argument, but that looks unreasonably hard
         return self.filename_matches(text, line[:lt])
     m = self.taskpat.match(line)
     if m is None or keyword.iskeyword(m.group(1)):
         if line[lt-1:lt] in ['"', "'"]:
             # use filename matches for quoted strings
             return self.filename_matches(text, line[:lt])
         else:
             return Completer.global_matches(self,text)
     else:
         taskname = m.group(1)
         # check for pipe/redirection using last non-blank character
         mpipe = re.search(r"[|><][ \t]*$", line[:lt])
         if mpipe:
             s = mpipe.group(0)
             if s[0] == "|":
                 # pipe -- use task matches
                 return iraf.getAllMatches(text)
             else:
                 # redirection -- just match filenames
                 return self.filename_matches(text, line[:lt])
         elif taskArgDict.has_key(taskname):
             # task takes task names as arguments
             return iraf.getAllTasks(text)
         elif pkgArgDict.has_key(taskname):
             # task takes package names as arguments
             return iraf.getAllPkgs(text)
         else:
             return self.argument_matches(text, taskname, line)