code: def parse_unix_perm(text):
      '''Parse a Unix permission string and return integer value.'''
      # Based on ftp-ls.c symperms
      if len(text) != 9:
          return 0
  
      perms = 0
  
      for triad_index in range(3):
          string_index = triad_index * 3
          perms <<= 3
  
          if text[string_index] == 'r':
              perms |= 1 << 2
  
          if text[string_index + 1] == 'w':
              perms |= 1 << 1
  
          if text[string_index + 2] in 'xs':
              perms |= 1
  
      return permf parse_unix_perm(text):
      '''Parse a Unix permission string and return integer value.'''
      # Based on ftp-ls.c symperms
      if len(text) != 9:
          return 0
  
      perms = 0
  
      for triad_index in range(3):
          string_index = triad_index * 3
          perms <<= 3
  
          if text[string_index] == 'r':
              perms |= 1 << 2
  
          if text[string_index + 1] == 'w':
              perms |= 1 << 1
  
          if text[string_index + 2] in 'xs':
              perms |= 1
  
      return perms
docs: Parse a Unix permission string and return integer value.