Ë
    €ÏŠ  ã                   óÎ   — d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlZddlZddlZddl	Z	ddl
Z
ddlZddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ej*                  fd„Zd„ Zd„ Zy)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                 ó   — ddg}	 t        t        j                  j                  | d«      d«      5 }|D ]o  }|j	                  d«      r#|j                  |j                  «       d   «       Œ7t        j                  d|«      sŒN|j                  |j                  «       d   «       Œq 	 ddd«       d
}t        j                  | «      D ]x  }|j                  d«      s||v rŒ||vsŒt        dj                  t!        j"                  dt        j                  j                  t$        j&                  |«      z  «      «      «      ‚ y# 1 sw Y   ŒœxY w# t        $ r' t        j                  «       j                  d	| «       Y yw xY w)aI  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Ú
z˜A 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.   '   sJ  € ð, " =Ð1€.ðÜ	Œbg‰gl‰l˜9 mÓ4°cÔ	:¸bÛˆ$Ø?‰?˜:Ô&Ø
×
Ñ
 §
¡
£¨RÑ 0Õ
1ÜX‰XÐ1°4Õ8Ø
×
Ñ
 §
¡
£¨Q¡Õ
0ñ	 ÷ 
;ð €-ô —*‘*˜YÖ'€hØ×Ñ˜Ô  H°Ñ$=ØØ~Ò%Ü˜TŸY™YÜ
-‰-ð.ô g‰gl‰lœ5×+Ñ+¨XÓ6ñ7ó8ó9ó :ð :ñ	 (÷3 
;Ð	:ûô 
ò Ü×ÑÓ×Ñð	Øôñ ð	ús/   †*E °AEÂ$EÂ&E ÅE
ÅE Å-E=Å<E=c                 ó\  — t        |«      }|j                  «       r‘| j                  |j                  |j                  |j
                  dg¬«      }|j                  rP|j                  j                  r9|j                  j                  D ]  }|j                  dk(  sŒ|j                  c S  yyyy)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·
±
Ø/9¨lð 'ó <€Cð ‡|‚|˜Ÿ™×9Ò9Ø—,‘,×3Ô3ˆ$Ø8‰8Ð'Ó'Ø—‘Ò
ñ 4ð :€|ð ó    c                  óT   — t         j                  j                  dk(  rt        S t        S )zŠReturns 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   