Example #1
0
  def getInfo(self, text=""):
    """
    Returns information about the aliases in here.

    This is used by #alias to tell all the aliases involved
    as well as #write which takes this information and dumps
    it to the file.

    @param text: the text to expand to find aliases the user
        wants information about.
    @type  text: string

    @return: a list of strings where each string represents an alias
    @rtype: list of strings
    """
    if len(self._aliases) == 0:
      return []

    listing = self._aliases.keys()
    if text:
      listing = utils.expand_text(text, listing)

    data = []
    for mem in listing:
      data.append("alias {%s} {%s}" % (mem, utils.escape(self._aliases[mem])))

    return data
Example #2
0
  def getInfo(self, text="", tag=None):
    """
    Returns information about the actions in here.

    This is used by #action to tell all the actions involved
    as well as #write which takes this information and dumps
    it to the file.

    @param text: the text to expand to find actions the user
        wants information about.
    @type  text: string

    @param tag: the tag which to find actions for.
    @type  tag: string

    @return: a list of strings where each string represents an action
    @rtype: list of strings
    """
    listing = self._actions.keys()
    if text:
      listing = utils.expand_text(text, listing)

    data = []
    for mem in listing:
      actup = self._actions[mem]
      
      if not tag or actup[6] == tag:
        data.append("action {%s} {%s} color={%d} priority={%d} onetime={%s} tag={%s}" % 
                (utils.escape(mem), utils.escape(actup[2]), actup[3], actup[4], actup[5], actup[6]))

    return data
Example #3
0
  def removeActions(self, text, mytag=None):
    """
    Removes actions that match the given text and have given tag 
    from the list and returns the list of actions that were removed
    so the calling function knows what actually happened.

    @param text: all actions that match this text pattern will 
        be removed.  the text pattern is "expanded" by 
        "utils.expand_text"
    @type  text: string

    @param mytag: all actions with given tag will be removed.
    @type  mytag: string

    @return: list of tuples (trigger, response, tag) of the action
        that were removed.
    @rtype: (string, string, string)
    """
    actions = self._actions
    keys = []
    if text:
      keys = utils.expand_text(text, actions.keys())
    elif mytag:  
      keys = actions.keys()

    ret = []
    for mem in keys:
      (trigger, compiled, response, color, priority, onetime, tag) = actions[mem]
      if not mytag or mytag == tag:
        ret.append((trigger, response, tag))
        del actions[mem]

    self._actionlist = None       # invalidating action list

    return ret
Example #4
0
    def removeVariables(self, ses, text):
        d = dict(ses._vars)
        d.update(session.Session.global_vars)
        badvariables = utils.expand_text(text, d.keys())
        ret = []
        for mem in badvariables:
            ret.append((mem, d[mem]))
            ses.removeVariable(mem)

        return ret
Example #5
0
  def removeAntiSubstitutes(self, text):
    """
    Removes antisubstitutes from the list.

    @returns: a list of antisubstitutes that were removed.
    @rtype: list of strings
    """
    badsubs = utils.expand_text(text, self._antisubs)

    ret = []
    for mem in badsubs:
      ret.append(mem)
      self._antisubs.remove(mem)

    return ret
Example #6
0
  def removeAntiGags(self, text=''):
    """
    Removes antigags from the list.

    @returns: a list of antigags that were removed.
    @rtype: list of strings
    """
    badgags = utils.expand_text(text, self._antigags.keys())

    ret = []
    for mem in badgags:
      ret.append(mem)
      del self._antigags[mem]

    return ret
Example #7
0
  def removeExcludes(self, exclude):
    """
    Removes a speedwalking exclude (and only one, no wildcards or the like)
    from the manager.
    
    @param exclude: the exclude to remove (we don't accept wildcards here)
    @type  exclude: string

    @returns: list of the excludes removed
    @rtype: list of strings
    """
    badexcludes = utils.expand_text(exclude, self._excludes)

    for mem in badexcludes:
      self._excludes.remove(mem)

    return badexcludes
Example #8
0
  def removeGags(self, text):
    """
    Removes gags from the list.

    Returns a list of tuples of gag item/gag that
    were removed.

    @param text: gags matching text will be removed
    @type  text: string

    @returns: list of (item, gag) tuples of removed gags
    @rtype: list of (string, string)
    """
    badgags = utils.expand_text(text, self._gags.keys())

    ret = []
    for mem in badgags:
      ret.append(mem)
      del self._gags[mem]

    return ret
Example #9
0
  def getExcludesInfo(self, text=""):
    """
    Returns information about the speedwalking excludes in here.
    
    This is used by #swexcl to tell all the excludes involved as well as
    #write which takes this information and dumps it to the file.
    
    @param text: the text to expand on to find excludes that the user
        is interested in
    @type  text: string

    @returns: list of strings where each string represents an exclude
    @rtype: list of strings
    """
    listing = self._excludes
    if text:
      listing = utils.expand_text(text, listing)
    
    listing = ["swexclude {%s}" % mem for mem in listing]
    
    return listing
Example #10
0
  def removeHighlights(self, text):
    """
    Removes highlights from the list.

    Returns a list of tuples of highlight item/highlight that
    were removed.

    @param text: we remove highlights that match this text
    @type  text: string

    @return: list of (text, style)
    @rtype: list of (string, string)
    """
    badhighlights = utils.expand_text(text, self._highlights.keys())

    ret = []
    for mem in badhighlights:
      ret.append((self._highlights[mem][0], mem))
      del self._highlights[mem]

    return ret
Example #11
0
  def removeSubstitutes(self, text):
    """
    Removes substitutes from the list.

    Returns a list of tuples of substitute item/substitute that
    were removed.

    @param text: substitutes matching text will be removed
    @type  text: string

    @returns: list of (item, substitute) tuples of removed substitutes
    @rtype: list of (string, string)
    """
    badsubstitutes = utils.expand_text(text, self._substitutes.keys())

    ret = []
    for mem in badsubstitutes:
      ret.append((mem, self._substitutes[mem]))
      del self._substitutes[mem]

    return ret
Example #12
0
  def getAntiSubstitutesInfo(self, text):
    """
    Returns information about the antisubstitutes in here.

    This is used by #antisubstitute to tell all the antisubstitutes involved
    as well as #write which takes this information and dumps it to the file.

    @param text: the text used to figure out which antisubstitutes to provide
        information on
    @type  text: string

    @return: list of strings where each string represents an antisubstitute
    @rtype: list of strings
    """
    listing = self._antisubs
    if text:
      listing = utils.expand_text(text, listing)

    listing = ["antisubstitute {%s}" % mem for mem in listing]

    return listing
Example #13
0
 def getDirsInfo(self, text=""):
   """
   Returns information about the speedwalking aliases in here.
   
   This is used by #swdir to tell all the speedwalking aliases involved as
   well as #write which takes this information and dumps it to the file.
   
   @param text: the text to expand on to find aliases that the user is
       interested in
   @type  text: string
   
   @returns: list of strings where each string represents a speedwalk alias
   @rtype: list of strings
   """
   listing = self._dirs.keys()
   if text:
     listing = utils.expand_text(text, listing)
   
   listing = ["swdir {%s} {%s}" % (mem, self._dirs[mem]) for mem in listing]
   
   return listing
Example #14
0
  def getAntiGagsInfo(self, text=""):
    """
    Returns information about the antigags in here.

    This is used by #antigag to tell all the antigags involved
    as well as #write which takes this information and dumps it to the file.

    @param text: the text used to figure out which antigags to provide
        information on
    @type  text: string

    @return: list of strings where each string represents a gag
    @rtype: list of strings
    """
    data = self._antigags.keys()
    if text:
      data = utils.expand_text(text, data)

    data = ["antigag {%s}" % mem for mem in data]

    return data
Example #15
0
  def removeAliases(self, text):
    """
    Removes aliases from the list.

    Returns a list of tuples of alias name/expansion that
    were removed.

    @param text: the text which when run through util.expand
        gives us the aliases to remove
    @type  text: string

    @return: the list of alias/expansions that match the text
    @rtype: list of (string, string)
    """
    badaliases = utils.expand_text(text, self._aliases.keys())

    ret = []
    for mem in badaliases:
      ret.append((mem, self._aliases[mem]))
      del self._aliases[mem]

    return ret
Example #16
0
    def getInfo(self, text=''):
        """
    Returns information about the gags in here.

    This is used by #gag to tell all the gags involved
    as well as #write which takes this information and dumps
    it to the file.

    @param text: the text used to figure out which gags to provide
        information on
    @type  text: string

    @return: list of strings where each string represents a gag
    @rtype: list of strings
    """
        data = list(self._gags.keys())
        if text:
            data = utils.expand_text(text, data)

        data = ["gag {%s}" % mem for mem in data]

        return data
Example #17
0
  def getInfo(self, text=''):
    """
    Returns information about the substitutes in here.

    This is used by #substitute to tell all the substitutes involved
    as well as #write which takes this information and dumps
    it to the file.

    @param text: the text used to figure out which substitutes to provide
        information on
    @type  text: string

    @return: list of strings where each string represents a substitute
    @rtype: list of strings
    """
    listing = self._substitutes.keys()
    if text:
      listing = utils.expand_text(text, listing)

    listing = ["substitute {%s} {%s}" % (mem, utils.escape(self._substitutes[mem])) for mem in listing]

    return listing
Example #18
0
    def getDirsInfo(self, text=""):
        """
    Returns information about the speedwalking aliases in here.
    
    This is used by #swdir to tell all the speedwalking aliases involved as
    well as #write which takes this information and dumps it to the file.
    
    @param text: the text to expand on to find aliases that the user is
        interested in
    @type  text: string
    
    @returns: list of strings where each string represents a speedwalk alias
    @rtype: list of strings
    """
        listing = self._dirs.keys()
        if text:
            listing = utils.expand_text(text, listing)

        listing = [
            "swdir {%s} {%s}" % (mem, self._dirs[mem]) for mem in listing
        ]

        return listing
Example #19
0
    def removeActions(self, text, mytag=None):
        """
    Removes actions that match the given text and have given tag 
    from the list and returns the list of actions that were removed
    so the calling function knows what actually happened.

    @param text: all actions that match this text pattern will 
        be removed.  the text pattern is "expanded" by 
        "utils.expand_text"
    @type  text: string

    @param mytag: all actions with given tag will be removed.
    @type  mytag: string

    @return: list of tuples (trigger, response, tag) of the action
        that were removed.
    @rtype: (string, string, string)
    """
        actions = self._actions
        keys = []
        if text:
            keys = utils.expand_text(text, actions.keys())
        elif mytag:
            keys = actions.keys()

        ret = []
        for mem in keys:
            (trigger, compiled, response, color, priority, onetime,
             tag) = actions[mem]
            if not mytag or mytag == tag:
                ret.append((trigger, response, tag))
                del actions[mem]

        self._actionlist = None  # invalidating action list

        return ret
Example #20
0
  def getInfo(self, text="", colorize=0):
    """
    Returns information about the highlights in here.

    This is used by #highlight to tell all the highlights involved
    as well as #write which takes this information and dumps
    it to the file.

    @param text: we return info on highlights that match this text
    @type  text: string

    @param colorize: whether (1) or not (0) to colorize the style
        text in the style
    @type  colorize: int

    @return: list of strings where each string represents a highlight
    @rtype: list of strings
    """
    listing = self._highlights.keys()

    if text:
      listing = utils.expand_text(text, listing)

    data = []
    for mem in listing:
      if colorize == 1:
        data.append("highlight {%s%s%s} {%s}" % 
                    (ansi.get_color(self._highlights[mem][0]),
                     self._highlights[mem][0], 
                     ansi.get_color("default"),
                     utils.escape(mem)))
      else:
        data.append("highlight {%s} {%s}" % 
                    (self._highlights[mem][0], utils.escape(mem)))

    return data
Example #21
0
 def getInfo(self, ses, text=""):
     data = ses._vars.keys()
     if text:
         data = utils.expand_text(text, data)
     data = ["variable {%s} {%s}" % (m, ses._vars[m]) for m in data]
     return data
Example #22
0
 def getInfo(self, ses, text=""):
   data = list(ses._vars.keys())
   if text:
     data = utils.expand_text(text, data)
   data = ["variable {%s} {%s}" % (m, ses._vars[m]) for m in data]
   return data