def ParsePathItem(item, opts=None):
  """Parses string path component to an `PathComponent` instance.

  Args:
    item: A path component string to be parsed.
    opts: A `PathOpts` object.

  Returns:
    `PathComponent` instance corresponding to given path fragment.

  Raises:
    ValueError: If the path item contains a recursive component fragment but
      cannot be parsed as such.
  """
  if item == os.path.curdir:
    return CurrentComponent()

  if item == os.path.pardir:
    return ParentComponent()

  recursion = PATH_RECURSION_REGEX.search(item)
  if recursion is None:
    return GlobComponent(item, opts)

  start, end = recursion.span()
  if not (start == 0 and end == len(item)):
    raise ValueError("malformed recursive component")

  if recursion.group("max_depth"):
    max_depth = int(recursion.group("max_depth"))
  else:
    max_depth = None

  return RecursiveComponent(max_depth=max_depth, opts=opts)
def ParsePathItem ( item , opts = None ) : if item == os . path . curdir : return CurrentComponent ( ) if item == os . path . pardir : return ParentComponent ( ) recursion = PATH_RECURSION_REGEX . search ( item ) if recursion is None : return GlobComponent ( item , opts ) start , end = recursion . span ( ) if not ( start == 0 and end == len ( item ) ) : raise ValueError ( "malformed recursive component" ) if recursion . group ( "max_depth" ) : max_depth = int ( recursion . group ( "max_depth" ) ) else : max_depth = None return RecursiveComponent ( max_depth = max_depth , opts = opts )
Parses string path component to an `PathComponent` instance.

  Args:
    item: A path component string to be parsed.
    opts: A `PathOpts` object.

  Returns:
    `PathComponent` instance corresponding to given path fragment.

  Raises:
    ValueError: If the path item contains a recursive component fragment but
      cannot be parsed as such.