code: def trimpath(attributes):
      
      if 'pathdepth' in attributes:
          if attributes['pathdepth'] != 'full':
              pathelements = []
              remainder = attributes['file']
              limit = int(attributes['pathdepth'])
              while len(pathelements) < limit and remainder:
                  remainder, pe = os.path.split(remainder)
                  pathelements.insert(0, pe)
              return os.path.join(*pathelements)
          return attributes['file']
      return os.path.basename(attributes['file'])
docs: Simplifies the given path.
  
      If pathdepth is in attributes, the last pathdepth elements will be
      returned. If pathdepth is "full", the full path will be returned.
      Otherwise the filename only will be returned.
  
      Args:
          attributes: The element attributes.
  
      Returns:
          The trimmed path.