
                             S r SSKJr  SSKJr  SSKJr  SSKJr  SSKrSSKrSSKrSSK	r	SSK
r
SSKrSSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  \R*                  4S jrS rS rg)z<Shared utility methods for the update command and its tests.    )absolute_import)print_function)division)unicode_literalsN)IS_OSX)CommandException)StorageUrlFromString)GSUTIL_PUB_TARBALL)GSUTIL_PUB_TARBALL_PY2c                 B   SS/n [        [        R                  R                  U S5      S5       nU H}  nUR	                  S5      (       a$  UR                  UR                  5       S   5        M=  [        R                  " SU5      (       d  M[  UR                  UR                  5       S   5        M     SSS5        S
n[        R                  " U 5       H  nUR                  S5      (       d  XT;   a  M   XQ;  d  M'  [        SR                  [         R"                  " S[        R                  R                  [$        R&                  U5      -  5      5      5      e   g! , (       d  f       N= f! [         a(    [        R                  " 5       R                  S	U 5         gf = f)a5  Disallows the update command if files not in the gsutil distro are found.

This prevents users from losing data if they are in the habit of running
gsutil from the gsutil directory and leaving data in that directory.

This will also detect someone attempting to run gsutil update from a git
repo, since the top-level directory will contain git files and dirs (like
.git) that are not distributed with gsutil.

Args:
  directory: (str) The directory to use this functionality on.

Raises:
  CommandException: if files other than those distributed with gsutil found.
zMANIFEST.inthird_partyrzinclude zrecursive-include \w+ \*   Nz7MANIFEST.in not found in %s.
Skipping user data check.
)z	.coveragez	.DS_Store.githubz.style.yapfz.yapfignore__pycache__r   z.pyc
zA file (%s) that is not distributed with gsutil was found in the gsutil directory. The update command cannot run with user data in the gsutil directory.)openospathjoin
startswithappendsplitrematchIOErrorlogging	getLoggerwarnlistdirendswithr   textwrapwrapgslib
GSUTIL_DIR)	directorymanifest_linesfplineaddl_excludesfilenames         *platform/gsutil/gslib/utils/update_util.pyDisallowUpdateIfDataInGsutilDirr.   '   sO   , "=1.	bggll9m4c	:b$??:&&




R 0
1XX1488




Q
0	  
; - **Y'h  H$=%TYY
--. ggll5++X6789 : :	 (3 
;	: 
 	 	s5   *E, AE&E4E, 
E)%E, )E, ,/FFc                 z   [        U5      nUR                  5       (       a  U R                  UR                  UR                  UR
                  S/S9nUR                  (       aX  UR                  R                  (       a<  UR                  R                   H!  nUR                  S:X  d  M  UR                  s  $    gggg)a  Looks up the gsutil version of the specified gsutil tarball URL.

Version is specified in the metadata field set on that object.

Args:
  gsutil_api: gsutil Cloud API to use when retrieving gsutil tarball.
  url_str: tarball URL to retrieve (such as 'gs://pub/gsutil.tar.gz').

Returns:
  Version string if URL is a cloud URL containing x-goog-meta-gsutil-version
  metadata, else None.
metadata)providerfieldsgsutil_versionN)
r	   
IsCloudUrlGetObjectMetadatabucket_nameobject_nameschemer0   additionalPropertieskeyvalue)
gsutil_apiurl_strurlobjprops        r-   LookUpGsutilVersionrA   e   s     	W%#^^

&
&s'*03

/9l ' <C ||99,,33$88''
 4 :|     c                  V    [         R                  R                  S:X  a  [        $ [        $ )zReturns the appropriate gsutil pub tarball based on the Python version.

Returns:
  The storage_uri of the appropriate pub tarball.
   )sysversion_infomajorr   r
    rB   r-   GsutilPubTarballrI   ~   s$     	q !!	rB   )__doc__
__future__r   r   r   r   r   r   r   r#   rE   r%   gslib.utils.system_utilr   gslib.exceptionr   gslib.storage_urlr	   gslib.utils.constantsr
   r   r&   r.   rA   rI   rH   rB   r-   <module>rP      sS    C & %  '  	 	  
  * , 2 4 8 /4.>.> ;:|2rB   