!;iVdZddlmZdZdgZddlZddlZddlmZddl m Z dgdfdZ dS) zdUtilities for making samples. Consolidates a lot of code commonly repeated in sample applications. )absolute_importz$jcgregorio@google.com (Joe Gregorio)initN) discovery) build_httpc ddlm}m} m} n#t$rt dwxYw|d|z}| jg} | |tj|tj | } | |dd} tj tj |d}|||| | }| |d z}|}||jr| ||| }|t- }|t/j||| }nPt3|5}t/j|d | }dddn #1swxYwY|| fS)ajA common initialization routine for samples. Many of the sample applications do the same initialization, which has now been consolidated into this function. This function uses common idioms found in almost all the samples, i.e. for an API with name 'apiname', the credentials are stored in a file named apiname.dat, and the client_secrets.json file is stored in the same directory as the application main file. Args: argv: list of string, the command-line parameters of the application. name: string, name of the API. version: string, version of the API. doc: string, description of the application. Usually set to __doc__. file: string, filename of the application. Usually set to __file__. parents: list of argparse.ArgumentParser, additional command-line flags. scope: string, The OAuth scope used. discovery_filename: string, name of local discovery file (JSON). Use when discovery doc not available via URL. Returns: A tuple of (service, flags), where service is the service object and flags is the parsed command-line flags. r)clientfiletoolsz^googleapiclient.sample_tools requires oauth2client. Please install oauth2client and try again.Nz https://www.googleapis.com/auth/) descriptionformatter_classparentszclient_secrets.json)scopemessagez.dat)httpzhttps://www.googleapis.com/)baser) oauth2clientrr r ImportError argparserextendargparseArgumentParserRawDescriptionHelpFormatter parse_argsospathjoindirnameflow_from_clientsecretsmessage_if_missingStoragegetinvalidrun_flow authorizerrbuildopenbuild_from_documentread)argvnameversiondocfilenamerr discovery_filenamerr r parent_parsersparserflagsclient_secretsflowstorage credentialsrservicediscovery_files PC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\googleapiclient/sample_tools.pyrr s;4 44444444444     l     }2T9o&N'"""  $ <F   d122h ' 'E W\\"'//(";";=RSSN  ) )eU-E-En-U-U *  Dll4&=))G++--Kk1nnT7E::  jll 3 3D!/$d;;;$ % % 3##%%,IPTG                U s ' *GGG) __doc__ __future__r __author____all__rrgoogleapiclientrgoogleapiclient.httprrr9rBs'&&&&& 3 ( %%%%%%++++++/3BSWLLLLLLrA