!;iCdZddlZddlZddlZddlZejeZdZdZ dZ e ee e gZ eZ dZdZdZd Zd Zd Zd ZdS) z-Helper functions for commonly used utilities.NWARNING EXCEPTIONIGNOREzFile: {0}: Is a symbolic link.z{0}: Is a directoryz,Cannot access {0}: No such file or directorycfd}ttr|Stj\}}}}}}}t t |t |z S)aA decorator to declare that only the first N arguments may be positional. This decorator makes it easy to support Python 3 style keyword-only parameters. For example, in Python 3 it is possible to write:: def fn(pos1, *, kwonly1=None, kwonly2=None): ... All named parameters after ``*`` must be a keyword:: fn(10, 'kw1', 'kw2') # Raises exception. fn(10, kwonly1='kw1') # Ok. Example ^^^^^^^ To define a function like above, do:: @positional(1) def fn(pos1, kwonly1=None, kwonly2=None): ... If no default value is provided to a keyword argument, it becomes a required keyword argument:: @positional(0) def fn(required_kw): ... This must be called with the keyword parameter:: fn() # Raises exception. fn(10) # Raises exception. fn(required_kw=10) # Ok. When defining instance or class methods always remember to account for ``self`` and ``cls``:: class MyClass(object): @positional(2) def my_method(self, pos1, kwonly1=None): ... @classmethod @positional(2) def my_method(cls, pos1, kwonly1=None): ... The positional decorator behavior is controlled by ``_helpers.positional_parameters_enforcement``, which may be set to ``POSITIONAL_EXCEPTION``, ``POSITIONAL_WARNING`` or ``POSITIONAL_IGNORE`` to raise an exception, log a warning, or do nothing, respectively, if a declaration is violated. Args: max_positional_arguments: Maximum number of positional arguments. All parameters after this index must be keyword only. Returns: A decorator that prevents using arguments after max_positional_args from being used as positional parameters. Raises: TypeError: if a keyword-only argument is provided as a positional parameter, but only if _helpers.positional_parameters_enforcement is set to POSITIONAL_EXCEPTION. cJtjfd}|S)Nc6t|kr~d}dkrd}djt||}ttkrt |tt krt||i|S)NszV{function}() takes at most {args_max} positional argument{plural} ({args_given} given))functionargs_max args_givenplural) lenformat__name__!positional_parameters_enforcementPOSITIONAL_EXCEPTION TypeErrorPOSITIONAL_WARNINGloggerwarning)argskwargsplural_smessagemax_positional_argswrappeds LC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\googleapiclient/_helpers.pypositional_wrapperzDpositional..positional_decorator..positional_wrapperos4yy...&!++"H<.positional_decoratorns?  ! ! , , , , , " ! ,("!r!) isinstanceintinspectgetfullargspec positionalr)rr$r_defaultss` rr)r)&sP"""""0%s++J##(/(>?R(S(S%aHaA4z#d))c(mm3445HIIIr!c tj|}i}|D]M\}}t |dkr*d|dd|}t ||d||<N|S)aParses unique key-value parameters from urlencoded content. Args: content: string, URL-encoded key-value pairs. Returns: dict, The key-value pairs from ``content``. Raises: ValueError: if one of the keys is repeated. r z.URL-encoded content contains a repeated value:z -> z, r)urllibparseparse_qsitemsrjoin ValueError)contenturlencoded_paramsparamskeyvaluemsgs rparse_unique_urlencodedr9s --g66 F'--// U u::??? %   CS// !Ahs Mr!c:tj|}t|j}||tj|}||}tj|S)aUpdates a URI with new query parameters. If a given key from ``params`` is repeated in the ``uri``, then the URI will be considered invalid and an error will occur. If the URI is valid, then each value from ``params`` will replace the corresponding value in the query parameters (if it exists). Args: uri: string, A valid URI, with potential existing query parameters. params: dict, A dictionary of query parameters. Returns: The same URI but with the new query parameters added. )query) r-r.urlparser9r;update urlencode_replace urlunparse)urir5parts query_params new_query new_partss rupdate_query_paramsrFsz" L ! !# & &E*5;77L &&|44IY//I < " "9 - --r!c.||St|||iS)a\Adds a query parameter to a url. Replaces the current value if it already exists in the URL. Args: url: string, url to add the query parameter to. name: string, query parameter name. value: string, query parameter value. Returns: Updated query parameter. Does not update the url if value is None. )rF)urlnamer7s r_add_query_parameterrJs" } "3u 666r!)__doc__r"r'loggingr- getLoggerrrrrPOSITIONAL_IGNORE frozensetPOSITIONAL_SETr_SYM_LINK_MESSAGE_IS_DIR_MESSAGE_MISSING_FILE_MESSAGEr)r9rFrJr!rrUs43  8 $ $"-/@A%7!4'FdJdJdJN2...277777r!