parameters: (args_parser, args)
return_statement: return filename, make_parser
docstring: Parses results from arguments added by
      `add_filename_and_parser_argparse_arguments`:
      * Parses filename (and possibly --find_resource) and returns filename.
      * Parses --package_path and returns make_parser factory.
docstring_summary: Parses results from arguments added by
      `add_filename_and_parser_argparse_arguments`:
      * Parses filename (and possibly --find_resource) and returns filename.
      * Parses --package_path and returns make_parser factory.
docstring_tokens: Parses results from arguments added by add_filename_and_parser_argparse_arguments : * Parses filename ( and possibly -- find_resource ) and returns filename . * Parses -- package_path and returns make_parser factory .
function: def parse_filename_and_parser(args_parser, args):
      """
      Parses results from arguments added by
      `add_filename_and_parser_argparse_arguments`:
      * Parses filename (and possibly --find_resource) and returns filename.
      * Parses --package_path and returns make_parser factory.
      """
  
      def make_parser(plant):
          parser = Parser(plant)
          # Get the package pathname.
          if args.package_path:
              # Verify that package.xml is found in the designated path.
              package_path = os.path.abspath(args.package_path)
              package_xml = os.path.join(package_path, "package.xml")
              if not os.path.isfile(package_xml):
                  args_parser.error(f"package.xml not found at: {package_path}")
  
              # Get the package map and populate it using the package path.
              parser.package_map().AddPackageXml(package_xml)
          return parser
  
      if args.find_resource:
          res_path = os.path.normpath(args.filename)
          print(f"Using FindResourceOrThrow('{res_path}')")
          filename = FindResourceOrThrow(res_path)
      else:
          filename = os.path.abspath(args.filename)
          if not os.path.isfile(filename):
              args_parser.error(f"File does not exist: {filename}")
  
      return filename, make_parser
function_tokens: def parse_filename_and_parser ( args_parser , args ) : def make_parser ( plant ) : parser = Parser ( plant ) # Get the package pathname. if args . package_path : # Verify that package.xml is found in the designated path. package_path = os . path . abspath ( args . package_path ) package_xml = os . path . join ( package_path , "package.xml" ) if not os . path . isfile ( package_xml ) : args_parser . error ( f"package.xml not found at: {package_path}" ) # Get the package map and populate it using the package path. parser . package_map ( ) . AddPackageXml ( package_xml ) return parser if args . find_resource : res_path = os . path . normpath ( args . filename ) print ( f"Using FindResourceOrThrow('{res_path}')" ) filename = FindResourceOrThrow ( res_path ) else : filename = os . path . abspath ( args . filename ) if not os . path . isfile ( filename ) : args_parser . error ( f"File does not exist: {filename}" ) return filename , make_parser