parameters: (self, pattern)
docstring: Renames the layer, scanning for patterns in the user's input trying to preserve metadata.
          Patterns have the form meta_name=value,
          E.g. s=50,100 to tell the tool to export two copies of the layer at 50% and 100% of its size
          This function will only replace or update corresponding metadata.
          If the rename string starts with a name, the layer's name will change to that.
docstring_summary: Renames the layer, scanning for patterns in the user's input trying to preserve metadata.
          Patterns have the form meta_name=value,
          E.g. s=50,100 to tell the tool to export two copies of the layer at 50% and 100% of its size
          This function will only replace or update corresponding metadata.
          If the rename string starts with a name, the layer's name will change to that.
docstring_tokens: Renames the layer scanning for patterns in the user s input trying to preserve metadata . Patterns have the form meta_name = value E . g . s = 50 100 to tell the tool to export two copies of the layer at 50% and 100% of its size This function will only replace or update corresponding metadata . If the rename string starts with a name the layer s name will change to that .
function: def rename(self, pattern):
          """
          Renames the layer, scanning for patterns in the user's input trying to preserve metadata.
          Patterns have the form meta_name=value,
          E.g. s=50,100 to tell the tool to export two copies of the layer at 50% and 100% of its size
          This function will only replace or update corresponding metadata.
          If the rename string starts with a name, the layer's name will change to that.
          """
          patterns = pattern.strip().split()
          a = self.cfg["delimiters"]["assign"]
  
          patterns = map(partial(flip(str.split), a), patterns)
  
          success, patterns = tee(patterns)
          success = map(lambda p: len(p) == 2, success)
          if not all(success):
              raise ValueError("malformed pattern.")
  
          key = lambda p: p[0] in self.cfg["meta"].keys()
          patterns = sorted(patterns, key=key)
          patterns = groupby(patterns, key)
  
          newName = self.node.name()
          for k, ps in patterns:
              for p in ps:
                  how = (
                      "replace"
                      if k is False
                      else "add"
                      if p[1] != "" and "{}{}".format(p[0], a) not in newName
                      else "subtract"
                      if p[1] == ""
                      else "update"
                  )
                  pat = (
                      p
                      if how == "replace"
                      else (r"$", r" {}{}{}".format(p[0], a, p[1]))
                      if how == "add"
                      else (
                          r"\s*({}{})[\w,/.]+\s*".format(p[0], a),
                          " " if how == "subtract" else r" \g<1>{} ".format(p[1]),
                      )
                  )
                  newName = re.sub(pat[0], pat[1], newName).strip()
          self.node.setName(newName)
function_tokens: def rename ( self , pattern ) : patterns = pattern . strip ( ) . split ( ) a = self . cfg [ "delimiters" ] [ "assign" ] patterns = map ( partial ( flip ( str . split ) , a ) , patterns ) success , patterns = tee ( patterns ) success = map ( lambda p : len ( p ) == 2 , success ) if not all ( success ) : raise ValueError ( "malformed pattern." ) key = lambda p : p [ 0 ] in self . cfg [ "meta" ] . keys ( ) patterns = sorted ( patterns , key = key ) patterns = groupby ( patterns , key ) newName = self . node . name ( ) for k , ps in patterns : for p in ps : how = ( "replace" if k is False else "add" if p [ 1 ] != "" and "{}{}" . format ( p [ 0 ] , a ) not in newName else "subtract" if p [ 1 ] == "" else "update" ) pat = ( p if how == "replace" else ( r"$" , r" {}{}{}" . format ( p [ 0 ] , a , p [ 1 ] ) ) if how == "add" else ( r"\s*({}{})[\w,/.]+\s*" . format ( p [ 0 ] , a ) , " " if how == "subtract" else r" \g<1>{} " . format ( p [ 1 ] ) , ) ) newName = re . sub ( pat [ 0 ] , pat [ 1 ] , newName ) . strip ( ) self . node . setName ( newName )