class_docstr: Parse a requirement.
  
  Parse a given requirement string into its parts, such as name, specifier,
  URL, and extras. Raises InvalidRequirement on a badly-formed requirement
  string.
class_docstr_tok: ["Parse","a","requirement",".","Parse","a","given","requirement","string","into","its","parts",",","such","as","name",",","specifier",",","URL",",","and","extras",".","Raises","InvalidRequirement","on","a","badly-formed","requirement","string","."]
code: def __init__(self, requirement_string):
      # type: (str) -> None
      try:
          req = REQUIREMENT.parseString(requirement_string)
      except ParseException as e:
          raise InvalidRequirement(
              'Parse error at "{0!r}": {1}'.format(
                  requirement_string[e.loc : e.loc + 8], e.msg
              )
          )
  
      self.name = req.name  # type: str
      if req.url:
          parsed_url = urlparse.urlparse(req.url)
          if parsed_url.scheme == "file":
              if urlparse.urlunparse(parsed_url) != req.url:
                  raise InvalidRequirement("Invalid URL given")
          elif not (parsed_url.scheme and parsed_url.netloc) or (
              not parsed_url.scheme and not parsed_url.netloc
          ):
              raise InvalidRequirement(
                  "Invalid URL: {0}".format(req.url)
              )
          self.url = req.url  # type: TOptional[str]
      else:
          self.url = None
      self.extras = set(
          req.extras.asList() if req.extras else []
      )  # type: Set[str]
      self.specifier = SpecifierSet(req.specifier)  # type: SpecifierSet
      self.marker = req.marker if req.marker else None
  
file_path: catboost/contrib/python/packaging/py2/packaging/requirements.py
imports: from __future__ import absolute_import, division, print_function
  import re
  import string
  import sys
  from pyparsing import Combine, Literal, Optional, ParseException, Regex, Word, ZeroOrMore, originalTextFor, stringEnd, stringStart
  from ._typing import TYPE_CHECKING
  from .markers import MARKER_EXPR, Marker
  from .specifiers import LegacySpecifier, Specifier, SpecifierSet
label_desc: Use image node_id 1 to create a new Requirement object from inherited base classes: object with example: obj = Requirement(requirement_string)