code: def glob2re(part):
      
      return "[^/]*".join(
          re.escape(bit).replace(r'\[\^', '[^').replace(r'\[', '[').replace(r'\]', ']')
          for bit in part.split("*")
      )
docs: Convert a path part to regex syntax.