403Webshell
Server IP : 217.160.0.244  /  Your IP : 216.73.217.138
Web Server : Apache
System : Linux infong-eu155 4.4.400-icpu-108 #2 SMP Wed Feb 11 11:51:01 UTC 2026 x86_64
User : u100174116 ( 6746176)
PHP Version : 8.5.10
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/breezy/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/breezy/__pycache__/osutils.cpython-313.pyc
�

p��gB;���%SSKrSSKrSSKrSSKrSSKrSSKrSSKrSSKJr SSK	J
r
 SSKJr SS/r\"\
"5S5 SS	KJr SS
KJr SSKrSSKJr \"\SS5r\"\S
S5r\"\SS5r"SS\R25rSrSrSrSrSqSr Sr!Sr"SS\!SSSSS0r#Sr$\"\RJS S5r&\&cS!r&S"r'S#r(S$r)S%r*S&r+S'r,S(r-S)r.S*r/S+r0S,r1S-r2\2"\Rf5r3\RJRhr4\RJRjr5\RJRlr7\(r8\"\RJRrS.5r:S/r;\Rxr<\RJRzr=\RJR|r>\RJR~r?\RJR�r@\R�rA\R�rBS0rCSrD\R�S1:Xa7\+r4\,r5\-r7\.r8\/r<\2"\05r3S2rDS3rFS4\F4S5jrG\HR�r:\HR�r;O\R�S6:Xa\1r<S�S7jrKS8rLS9rMS:rNS;rOS<rPS=rQS>rRS�S?jrSS�S@jrTS�SAjrUSBrVSCrWSDrXSErY\4SFjrZ\4SGjr[SHr\SIr]S�SJjr^/SKQr_\_Vs/sHoSL-PM	 snr`S�SNjra0rb\c\d\e4\fSO'S\b4SPjrgS�SQjrhSRriSSrjSTrkSUrl\R�rn\nR�SV:wa	\n"S5 SXrqSYrrSZrsS[rtS\\e4S]jru/rvS^rwS_rxSS`KyJzrz Sar~SbrScr�Sdr�Ser�Sfr�Sgr�Shr�Sir�Sjr�Skr�Slr�\R�Sm;a\�r�O\�r�Snr�Sor�Spr�S4r�\R�S6:XaSMr�Sqr�Srr�Ssr�\�(a\�r�O\�r�S�Stjr�Sur�Svq�Sq�Swr�Sxr�Syr�Sr�\R�S1:Xa\�r�O\�r�Szr�S{r�S|r�S}r�\GR>"S~5r�Sr�S�r�S\GRF4S�jr�"S�S�5r�Sq�S�S�jr�"S�S�\�5r�S�S�jr�S�S�jr�S�r�S�r�Sq�S�r�S�r�S�r�S�r�\GRd\GRf\GRh/r�\�\d\fS�'S�Hr�\�GRq\"\\�55 M S\�4S�jr�S�r�S�S�jr�S�r�S�r�S�r�S�r�S�r�\�q�\R�4S�jr�\R�4S�jr�S�r�\R�S1:XaS�r�OS�r�\R�GR�S�5(aS�r�OS\R�S6:XaS�r�O?S�\R�;aS�r�O+\R�S�:XaS�r�O\R�S1:XaS�r�OS�r�Sq�S�S�jr�"S�S�\GR�5r�S�\eS�\
\e/\�4S�\e4S�jr�S�r�S�r�S�r�\R�S1:Xa\HGR�r�O\�r�/S�Qr�\�Vs/sHn\"\US5cM\"\U5PM snr�S�r�S�r�S�r�"S�S�5r�"S�S�\�5r�"S�S�\�5r�Sq�S�r�\GR�r�gs snf!\pa SWrnGNf=f!\{ar|\w"\|5 SS`K}Jzrz Sr|C|GNSr|C|ff=f!\�a GM�f=fs snf)��N)�partial)�Callable�)�lazy_import�md5�shaaf
import locale
import ntpath
import posixpath
import select
# We need to import both shutil and rmtree as we export the later on posix
# and need the former on windows
import shutil
from shutil import rmtree
import socket
import subprocess
import unicodedata

from breezy import (
    config,
    trace,
    win32utils,
    )
from breezy.i18n import gettext
)r)�sha1)�errors�O_BINARY�O_TEXT�O_NOINHERITc��\rSrSrSrSrSrg)�UnsupportedTimezoneFormat�LzSUnsupported timezone format "%(timezone)s", options are "utc", "original", "local".c��Xlg�N��timezone)�selfrs  �0/usr/lib/python3/dist-packages/breezy/osutils.py�__init__�"UnsupportedTimezoneFormat.__init__Rs�� �
�rN)�__name__�
__module__�__qualname__�__firstlineno__�_fmtr�__static_attributes__�rrrrLs��	2�	�
!rrc��[R"U5Rn[R"U5(dUS-n[X5 gg)zMake a filename read-only.im�N��os�lstat�st_mode�stat�S_ISLNK�chmod_if_possible��filename�mods  r�
make_readonlyr,Vs;��
�(�(�8�
�
$�
$�C��<�<�����H�n���(�(�rc��[R"U5Rn[R"U5(dUS-n[X5 gg)N�r"r)s  r�
make_writabler/^s;��
�(�(�8�
�
$�
$�C��<�<�����E�k���(�(�rc��[R"X5 g![a]nUR[R[R
4;a)[RSRX55 SnAgeSnAff=f)Nz#ignore error on chmod of {!r}: {!r})	r#�chmod�OSError�errno�EPERM�EACCES�trace�mutter�format)r*�mode�es   rr(r(es^���	���� ����
�7�7�u�{�{�E�L�L�1�1��L�L�>�E�E�h�R�S��
���s��
B�AA;�:A;�;Bc���[U5S:a[U5$Sn[XS9nUS/nUSSH*n[USU5(aMUR	U5 M, [U5$)z�Return the smallset subset of paths which are outside paths.

:param paths: A container (and hence not None) of paths.
:return: A set of paths sufficient to include everything in paths via
    is_inside, drawn from the paths parameter.
�c�p�[U[5(aURS5$URS5$)N�/�/)�
isinstance�bytes�split��paths r�sort_key�(minimum_path_selection.<locals>.sort_key�s,���d�E�"�"��:�:�d�#�#��:�:�c�?�"r)�keyrrN���)�len�set�sorted�	is_inside�append)�pathsrE�sorted_paths�search_pathsrDs     r�minimum_path_selectionrQwst���5�z�A�~��5�z��#��%�.�L� ��O�$�L��Q�R� ����b�)�4�0�0�����%�!�
�|��rc��[c[R"S5q[RU5(aSU-S-$U$)znReturn a quoted filename filename.

This previously used backslash quoting, but that works poorly on
Windows.
z([^a-zA-Z0-9.,:/\\_~-])�")�	_QUOTE_RE�re�compile�search��fs r�quotefnrZ�s=�����J�J�9�:�	��������Q�w��}���r�	directoryc�^�[R"S5n[R"U5 U$)zReturn the current umask.r)r#�umask)r]s r�	get_umaskr^�s!��

�H�H�Q�K�E��H�H�U�O��Lr�file�r?�symlink�@ztree-reference�+c�6�[U$![a gf=f)Nr`)�_kind_marker_map�KeyError)�kinds r�kind_markerrh�s&�����%�%������s��
��lexistsc��[[S[R5nU"U5 g![aVnUR[R
:XaSnAg[R"[S5RX55eSnAff=f)Nr$TFzlstat/stat of ({0!r}): {1!r})
�getattrr#r&r2r3�ENOENTr
�BzrError�gettextr8)rYr&r:s   rriri�sk��
	��2�w����0�D���G����	��w�w�%�,�,�&���o�o��:�;�B�B�1�H����		�s�'*�
B
�B�.B�B
c���SSKJn [RR	U5n[RRU5nSU[R"5[R"5[S54-n[Xg5nSnU"X5 SnSn
U"X5 Sn
U(aU
(a	U"U5 gU"Xq5 gg!Ua N6[a:n	U	RS[R[R4;aeSn	A	NtSn	A	f[aGn	[U	SS5b.U	R[R[R4;aeSn	A	N�Sn	A	ff=f![aUn	U(aHU	RS[R4;a(UR!5UR!5:XaSn	A	GNeSn	A	ff=f!U(aU
(a	U"U5 fU"Xq5 ff=f)	aA fancy rename, when you don't have atomic rename.

:param old: The old path, to rename from
:param new: The new path, to rename to
:param rename_func: The potentially non-atomic rename function
:param unlink_func: A way to delete the target file if the full rename
    succeeds
r��
NoSuchFileztmp.%s.%.9f.%d.%s�
FTNr3)�	transportrqr#rD�basename�dirname�time�getpid�
rand_chars�pathjoinr2r3rl�ENOTDIR�	Exceptionrk�lower)�old�new�rename_func�unlink_funcrq�baseru�tmp_name�file_existedr:�successs           r�fancy_renamer��s���&��7�7���C� �D��g�g�o�o�c�"�G�#�d�D�I�I�K�����j�QS�n�%U�U�H���*�H��L���C�"� ���G�+�	�C���� ���H�%��H�*�
��M�
����
�7�7�4����u�}�}�=�=��>�����1�g�t�$�,�����L�L��M�M�@
�1
�
�	1
�����
�

����D�%�,�,�/�/��	�	��s�y�y�{�*�
���
�����H�%��H�*�
�s[�C�
E �E�	E�0D	�	
E�=E�E� 
F?�*A	F:�3G�9F:�:F?�?G�"G$c�f�[RU5nURS5(aUSSnU$)Nz//r)�	posixpath�normpath�
startswithrCs r�_posix_normpathr� s3�����d�#�D����t����A�B�x���Krc�V�[RU5upUR5U-$)a3Force drive letters to be consistent.

win32 is inconsistent whether it returns lower or upper case
and even if it was consistent the user might type the other
so we force it to uppercase
running python.exe under cmd.exe return capital C:\\
running win32 python inside a cygwin shell returns lowercase c:\\
)�ntpath�
splitdrive�upper)rD�drives  r�_win32_fixdriver�/s'���#�#�D�)�K�E��;�;�=�4��rc�t�[U[5(aURSS5$URSS5$)zAReturn path with directory separators changed to forward slashes.�\r>�\r?)r@rA�replacerCs r�_win32_fix_separatorsr�<s1���$�����|�|�E�4�(�(��|�|�D�#�&�&rc�P�[[[RU555$r)r�r�r��abspathrCs r�_win32_abspathr�Ds���0�����1E�F�G�Grc�P�[[[RU555$r)r�r�r��realpathrCs r�_win32_realpathr�Is���0�����1F�G�H�Hrc�:�[[R"U65$r)r�r��join)�argss r�_win32_pathjoinr�Ns�� ����d�!3�4�4rc�P�[[[RU555$r)r�r�r�r�rCs r�_win32_normpathr�Rs���0�����1F�G�H�Hrc�P�[[[R"555$r)r�r�r#�getcwdr rr�
_win32_getcwdr�Vs���0�����=�>�>rc�>�[X[R[RS9 g![ahnUR
[
R[
R[
R[
R4;a[R"U5 eSnAff=f)z�We expect to be able to atomically replace 'new' with old.

On win32, if new exists, it must be moved out of the way first,
and then deleted.
)rr�N)r�r#�rename�unlinkr2r3r4r5�EBUSY�EINVALr$)r}r~r:s   r�
_win32_renamer�Zs`��	��S�2�9�9�"�)�)�L�����7�7�u�{�{�E�L�L�%�+�+�u�|�|�L�L�

�H�H�S�M�
���s�'*�
B�A#B�Bc�T�[RS[R"55$�N�NFC)�unicodedata�	normalizer#r�r rr�_mac_getcwdr�ls��� � ���	�	��4�4rc�^�U4SjnU$)z�Adds extra information to any exceptions that come from rename().

The exception has an updated message and 'old_filename' and 'new_filename'
attributes.
c	�>�T"X5 g![aEn[URURSRX5-5nXlXlUeSnAff=f)Nz& [occurred when renaming '{}' to '{}'])r2r3�strerrorr8�old_filename�new_filename)r}r~r:�detailed_errorrs    �r�_rename_wrapper�/_rename_wrap_exception.<locals>._rename_wrapperws]���		!���!���	!�$�����
�
�E�L�L�S�V�V��N�+.�'�*-�'� � ��	!�s��
A�AA�Ar )rr�s` r�_rename_wrap_exceptionr�ps���
!��r�~c�*�SSKnUR5$�Nr)�getpass�getuser)r�s r�getuser_unicoder��s����?�?��rc��U$rr )�sts r�	wrap_statr��s��
�Ir�win32�c��USnU[R[R[R4;aG[	U[
5(a2UR[R:Xa[U5 U"U5 ge)ziError handler for shutil.rmtree function [for win32]
Helps to remove files and dirs marked as read-only.
rN)	r#r��remove�rmdirr@r2r3r5r/)�functionrD�excinfo�	exceptions    r�_win32_delete_readonlyr��sW���A�J�	�����B�I�I�r�x�x�8�8��9�g�.�.����5�<�<�/��$���T�N�rFc�.�[RXU5$)z=Replacer for shutil.rmtree: could remove readonly dirs/files.)�shutil�rmtree)rD�
ignore_errors�onerrors   rr�r��s���}�}�T�'�:�:r�darwinc�(�SSKJn [[RSS5nU(dP[[R
SS5nU(d[
5nU(a	U"SU5 O#UnU(a	U"SU5 OU(a	U"SU5 US:Xa[
5nU(a	U"S	U5 [R"U5 U$![aE [RRS
RU[
555 [
5nU$f=f)aFind the best encoding for printing to the screen.

This attempts to check both sys.stdout and sys.stdin to see
what encoding they are in, and if that fails it falls back to
osutils.get_user_encoding().
The problem is that on Windows, locale.getpreferredencoding()
is not the same encoding as that used by the console:
http://mail.python.org/pipermail/python-list/2003-May/162357.html

On my standard US Windows XP, the preferred encoding is
cp1252, but the console is cp437

:param trace: If True trace the selected encoding via mutter().
r)r7�encodingNz1encoding stdout as osutils.get_user_encoding() %rz(encoding stdout as sys.stdin encoding %rz)encoding stdout as sys.stdout encoding %r�cp0zJcp0 is invalid encoding. encoding stdout as osutils.get_user_encoding() %rzIbrz: warning: unknown terminal encoding {}.
  Using encoding {} instead.
)
r6r7rk�sys�stdout�stdin�get_user_encoding�codecs�lookup�LookupError�stderr�writer8)r6r7�output_encoding�input_encodings    r�get_terminal_encodingr��s�����c�j�j�*�d�;�O�� ����J��=���/�1�O���G����-�O���A�?�S����>��P��%��+�-����E��
�
.��
�
�o�&�����.��
�
���
-�-3�V��!2�!4�.�	
�,�-����.�s�*C�AD�Dc���[[RSS5b[nO[n[RRU5up#US:XdUS:XdUS:XaU"U5$[
U"U5U5$)Nr�r`�.�..)rkr#rDr�r�rBry)rY�F�pr:s    r�
normalizepathr�s`���r�w�w�
�D�)�5�����
�W�W�]�]�1�
�F�Q��B�w�!�s�(�a�4�i���t����!��a� � rc��[R"[R"U5[R5$![
a gf=f)z%True if f is an accessible directory.F)r&�S_ISDIRr#r$�ST_MODEr2rXs r�isdirr��9����|�|�B�H�H�Q�K����5�6�6��������:=�
A
�	A
c��[R"[R"U5[R5$![
a gf=f)zTrue if f is a regular file.F)r&�S_ISREGr#r$r�r2rXs r�isfiler�r�r�c��[R"[R"U5[R5$![
a gf=f)zTrue if f is a symlink.F)r&r'r#r$r�r2rXs r�islinkr�$r�r�c���X:XagUS;ag[U[5(aURS5(dUS-
nOURS5(dUS-
nURU5$)aTrue if fname is inside dir.

The parameters should typically be passed to osutils.normpath first, so
that . and .. and repeated slashes are eliminated, and the separators
are canonical for the platform.

The empty string as a dir name is taken as top-of-tree and matches
everything.
T)r`rr>r?)r@rA�endswithr�)�dir�fnames  rrLrL,sf���|��
�i����#�u����|�|�D�!�!��4�K�C���|�|�C� � ��3�J�C����C� � rc�.^�[U4SjU55$)z*True if fname is inside any of given dirs.c3�<># �UHn[UT5v� M g7fr�rL)�.0rur�s  �r�	<genexpr>� is_inside_any.<locals>.<genexpr>Js����A��W�y��%�(�(��s���any)�dir_listr�s `r�
is_inside_anyr�Hs����A��A�A�Arc�Z�UH%n[X!5(d[X5(dM% g g)z?True if fname is a child or a parent of any of the given files.TFr�)r�r�rus   r�is_inside_or_parent_of_anyrMs)�����W�$�$�	�%�(A�(A���rc��SnUS:�aoUS:�ag[X#5nURU5nU(dU$UbU"[U5U5 URU5 [U5n	X)-nXi-
nUS:�aMgU$URU5nU(dU$UbU"[U5U5 URU5 U[U5-
nMQ)a�Copy contents of one file to another.

The read_length can either be -1 to read to end-of-file (EOF) or
it can specify the maximum number of bytes to read.

The buff_size represents the maximum size for each read operation
performed on from_file.

:param report_activity: Call this as bytes are read, see
    Transport._report_activity
:param direction: Will be passed to report_activity

:return: The number of bytes copied.
r)�min�readrIr�)
�	from_file�to_file�read_length�	buff_size�report_activity�	direction�length�num_bytes_to_read�block�actual_bytes_reads
          r�pumpfilerUs���,�F��a���A�o� #�K� ;���N�N�#4�5�E���&�M�%�*���E�
�I�6��M�M�%� � #�E�
���,�K��'�F��A�o�2�M���N�N�9�-�E���
�M�	�*���E�
�I�6��M�M�%� ��c�%�j� �F�rc��U(dSn[S[U5U5n[U5nURnUHnU"XFXb-5 M g)z�Write bytes to file_handle in many smaller writes.

:param bytes: The string to write.
:param file_handle: The file to write to.
iPrN)�rangerI�
memoryviewr�)rA�file_handle�segment_size�offsets�viewr��offsets       r�pump_string_filer�sM������A�s�5�z�<�0�G��e��D����E���
�d�F�1�2�3�rc#�Z# �URU5n[U5S:XagUv� M'7fr�)rrI)�
input_file�readsize�bs   r�
file_iteratorr�s.���
��O�O�H�%���q�6�Q�;����	�s�)+c�>�UR5R5$r)�	hexdigest�encode)�hashobjs r�
_hexdigestr"�s������%�%�'�'rc��[5nSnURU5nU(dOURU5 M,[U5$)zZCalculate the hexdigest of an open file.

The file cursor should be already at the start.
�)rr�updater")rY�s�BUFSIZErs    r�sha_filer(�sB��
	��A��G�
�
�F�F�7�O����	�����	�
�a�=�rc��Sn[5nSnURU5nU(dO!U[U5-
nURU5 M:U[	U54$)z�Calculate the size and hexdigest of an open file.

The file cursor should be already at the start and
the caller is responsible for closing the file afterwards.
rr$)rrrIr%r")rY�sizer&r'rs     r�
size_sha_filer+�sY��
�D���A��G�
�
�F�F�7�O������A����	��������A���rc�Z�[5n[R"U[R[-[
-5n[R"US5nU(d![U5[R"U5 $URU5 MR![R"U5 f=f)z6Calculate the SHA1 of a file by reading the full text.�)
rr#�open�O_RDONLYrr
rr"�closer%)r�r&rYrs    r�sha_file_by_namer1�sw����A�
����r�{�{�X�-��;�<�A�������7�#�A��!�!�}�	�����
�H�H�Q�K�	��	�����s�)B�?B�B*c�Z�U"5nUHnURU5 M [U5$)z-Return the sha-1 of concatenation of strings.)r%r")�strings�_factoryr&�strings    r�sha_stringsr6�s)���
�A���	�������a�=�rc�$�[U"U55$r)r")rYr4s  r�
sha_stringr8�s���h�q�k�"�"rc�b�UR5n[U5[[U55S.$)N)r*r	)rrIr"r)rYrs  r�fingerprint_filer:�s%��	����A���F�J�s�1�v�$6�7�7rc�l�SnURU5nURU5nX4:wagU(dgM2)z"Returns true if equal in contents.iTF)r)�arr'�ai�bis     r�
compare_filesr?�s7���G�
�
�V�V�G�_��
�V�V�G�_��
�8����
rc��Uc[R"5n[R"U5n[R"U5n[R"U5n[R"U5n[	X4-
5nU$)zEReturn offset of local zone from GMT, either at present or at time t.)rv�	localtime�gmtime�mktime�int)�t�
local_time�utc_time�
local_seconds�utc_secondsrs      r�local_time_offsetrJ�s[���y��I�I�K������"�J��{�{�1�~�H��K�K�
�+�M��+�+�h�'�K�
��,�
-�F��Mr)�Mon�Tue�Wed�Thu�Fri�Sat�Sunz %Y-%m-%d %H:%M:%STc��[XX#U5up5nURS[US5n[R"X55nXv-$)alReturn a formatted date string.

:param t: Seconds since the epoch.
:param offset: Timezone offset in seconds east of utc.
:param timezone: How to display the time: 'utc', 'original' for the
     timezone specified by offset, or 'local' for the process's current
     timezone.
:param date_fmt: strftime format.
:param show_offset: Whether to append the timezone.
z%a�)�_format_dater��weekdaysrv�strftime�rErr�date_fmt�show_offset�tt�
offset_str�date_strs        r�format_dater]sM��".�	�8�{�"��X�:�����h�r�!�u�o�6�H��}�}�X�*�H�� � r�
_offset_cachec���UcSn[R"X-5n[USn[R"XC5nUR	US5nUcSUS-US-S-4-nXbU'XV-$)z�Return a formatted date string in the original timezone.

This routine may be faster then format_date.

:param t: Seconds since the epoch.
:param offset: Timezone offset in seconds east of utc.
NrrS�
 %+03d%02d��<)rvrB�_default_format_by_weekday_numrV�get)rEr�_cacherZrXr\r[s       r�,format_date_with_offset_in_original_timezonerf#s|���~���	
���Q�Z�	 �B�-�b��e�4�H��}�}�X�*�H����F�D�)�J���!�V�d�]�V�b�[�B�4F�$G�G�
�#�v��� � rc��[XX#U5up5n[R"X55n[U[5(dUR[
5S5nXv-$)a�Return an unicode date string formatted according to the current locale.

:param t: Seconds since the epoch.
:param offset: Timezone offset in seconds east of utc.
:param timezone: How to display the time: 'utc', 'original' for the
     timezone specified by offset, or 'local' for the process's current
     timezone.
:param date_fmt: strftime format.
:param show_offset: Whether to append the timezone.
r�)rTrvrVr@�str�decoder�rWs        r�format_local_daterj7sT��".�	�8�{�"��X�:��}�}�X�*�H��h��$�$��?�?�#4�#6�	�B��� � rc�2�US:Xa[R"U5nSnOWUS:XaUcSn[R"X-5nO3US:Xa"[R"U5n[U5nO[	U5eUcSnU(aSUS-US-S-4-OS	nX5U4$)
N�utcr�original�localz%a %Y-%m-%d %H:%M:%Sr`rarbr`)rvrBrArJr)rErrrXrYrZr[s       rrTrTMs����5��
�[�[��^����	�Z�	��>��F�
�[�[���
$��	�W�	�
�^�^�A�
��"�1�%��'��1�1���)��@K���$���"���(:�;�	;�QS��
�*�%�%rc�X�[R"S[R"U55$)Nz%Y%m%d%H%M%S)rvrVrB)�whens r�compact_daterqbs���=�=�����T�):�;�;rc�\�[U5nUS:�aSnOSnU*nUnUS:aUS:XaUSU3$USU3$[US-5nUSU--nUS:XaS	nOS
nUS:aUS:Xa	SUUUU4-$USUS
USU3$[US-5nUSU--nUS:XaS	nOS
nUS:XaSXSXa4-$SXSXa4-$)a)Get a nice looking string for a time delta.

:param delta: The time difference in seconds, can be positive or negative.
    positive indicates time in the past, negative indicates time in the
    future. (usually time.time() - stored_time)
:return: String formatted to show approximate resolution
r�agoz
in the future�Zrz second z	 seconds rbr`r&z%d minute, %d second%s %sz
 minutes, z second� z%d hour, %d minute%s %sz%d hours, %d minute%s %s)rD)�deltar
�seconds�minutes�plural_seconds�hours�plural_minutess       r�format_deltar|fs'��
��J�E���z��	�#�	�����G���|��a�<��Y�h�y�k�2�2��Y�i�	�{�3�3��'�B�,��G��r�G�|��G��!�|�������|��a�<�.�����	2��
��Y�j��	���8H��)��U�U���"���E��r�E�z��G��!�|�������z�(�E�N�+V�V�V�%���(S�S�Src�l�[R"UR55[R$)zReturn size of given open file.)r#�fstat�filenor&�ST_SIZErXs r�filesizer��s ��
�8�8�A�H�H�J�����-�-r�ntc�x�SSKnSnU(a,U[URSS55-
nUS-nU(aM,U$)Nrr`�r)�random�chr�randint)�nr�r&s   r�
rand_bytesr��s>����A���S�����3�/�0�0���Q����!��Hr�$0123456789abcdefghijklmnopqrstuvwxyzc�L�Sn[U5HnU[US--
nM U$)z�Return a random string of num alphanumeric characters.

The result only contains lowercase chars because it may be used on
case-insensitive filesystems.
r`�$)r��ALNUM)�numr&�raw_bytes   rrxrx�s/��	�A��s�O��	�U�8�b�=�
!�!��$��Hrc���[U[5n[RRS:Xa7U(a[
R"SU5nOB[
R"SU5nO*U(aUR
S5nOUR
S5nU(aSnSnOSnS	n/nUHBnXc:Xa"[R"[S
5U-5eXd;aM1URU5 MD U$)zTurn string into list of parts.r�s[\\/]z[\\/]r>r?s..)�.rr�)r�r`�sorry, %r not allowed in path)r@rAr#rD�seprUrBr
rmrnrM)r��	use_bytes�ps�
parent_dir�current_empty_dir�rpsrYs       r�	splitpathr��s����1�e�$�I�	�w�w�{�{�d������*�a�(�B����(�A�&�B�������B������B���
�'���
�%��
�C�
���?��/�/�'�*I�"J�Q�"N�O�O�
�
#���J�J�q�M�
��Jrc��UH4nUS:XdUbUS:XdM[R"[S5U-5e [U6$)Nr�r`r�)r
rmrnry)r�rYs  r�joinpathr��sC��
��
��I�1�9�!�r�'��/�/�'�*I�"J�Q�"N�O�O���Q�<�rr*c��/n[[U55nU(a3UR[U55 UR	5 U(aM3U$)zqReturn the list of parent directories, deepest first.

For example, parent_directories("a/b/c") -> ["a/b", "a"].
)r�rurMr��pop)r*�parents�partss   r�parent_directoriesr��sB��
�G��g�h�'�(�E�
����x���'�
�	�	���%��Nrc��[U5nU[;a:[RSR	U55 [RU5 gg)a�Handle failing to load a binary extension.

This should be called from the ImportError block guarding the attempt to
import the native extension.  If this function returns, the pure-Python
implementation should be loaded instead::

>>> try:
>>>     import breezy._fictional_extension_pyx
>>> except ImportError, e:
>>>     breezy.osutils.failed_to_load_extension(e)
>>>     import breezy._fictional_extension_py
z%failed to load compiled extension: {}N)rh�_extension_load_failuresr6r7r8rM)r��
exception_strs  r�failed_to_load_extensionr��sA��*�	�N�M��4�4�
���<�C�C�M�R�S� �'�'�
�6�5rc��[(dg[R5RS5(agSSKJn U"S5 g)N�missing_extensionsr��warningz_brz: warning: some compiled extensions could not be loaded; see ``brz help missing-extensions``)r��config�GlobalConfig�suppress_warningr6r�r�s r�report_extension_load_failuresr�s9��#�#��
����-�-�.B�C�C����	.�r)�chunks_to_linesc�Z�[U[5(a[U/5$[U5$)z@Split s into lines, but without removing the newline characters.)r@rAr��_split_lines�r&s r�split_linesr�2s(���!�U�����s�#�#��A��rc���[U[5(aSOSnURU5nUSSVs/sHo3U-PM	 nnUS(aURUS5 U$s snf)zqSplit s into lines, but without removing the newline characters.

This supports Unicode or plain string objects.
�
�
NrH)r@rArBrM)r&�nl�lines�line�results     rr�r�=sa��
�Q��&�&��D�B�
�G�G�B�K�E�$)�#�2�J�
/�J�D�R�i�J�F�
/��R�y��
�
�e�B�i� ��M��0s�A"c�(�[RS;$)N)r��cygwinr��r��platformr rr�hardlinks_goodr�Js���<�<�<�<�<rc��[5(d[RX5 g[R"X5 g![
a>nUR[R:wae[RX5 SnAgSnAff=f)z6Hardlink a file, or copy it if it can't be hardlinked.N)r�r��copyfiler#�linkr2r3�EXDEV)�src�destr:s   r�link_or_copyr�Ns]���������"��#�
�������#��7�7�e�k�k�!������"�"��#�s�>�
B�4B�Bc��[U5 g![aanUR[R[R4;a-[U5 O![a Of=f[U5 SnAgeSnAff=f)zDDelete a file, symlink or directory.

Will delete even if readonly.
N)�_delete_file_or_dirr2r3r4r5r/)rDr:s  r�
delete_anyr�[se��
��D�!���	��7�7�u�{�{�E�L�L�1�1�
��d�#���
��
����%�%���	�s>��
A9�.A4�A�A4�
A �A4�A � A4�3A4�4A9c�~�[U5(a[R"U5 g[R"U5 gr)r�r#r�r�rCs rr�r�ns#��
�T�{�{�
�����
�	�	�$�rc���[[SS5cg[U5nUc[RS:g$US;$![
Ra n[RSX5 SnAgSnAff=f)Nr�Fr���vfat�ntfs� Unable to get fs type for %r: %sT�	rkr#�get_fs_typer�r�r
�DependencyNotPresentr6r7�rD�fs_typer:s   r�supports_hardlinksr�zso���r�6�4� �(��	/��d�#��
�?��<�<�7�*�*��.�.�.���&�&��
���7��A����s�;�A/�A*�*A/c��[R"U5n[R"U5n[R"U5nU$)z�Return a string representing the path to which the symbolic link points.

:param abspath: The link absolute unicode path.

This his guaranteed to return the symbolic link in unicode in all python
versions.
)r#�fsencode�readlink�fsdecode)r�r��targets   rr�r��s3���;�;�w��D�
�[�[��
�F�
�[�[��
 �F��Mrc�b^�[T[5(aSnOSn[U4SjU55$)z1True if there are any whitespace characters in s.z 	

)� �	r��
��c3�,># �UH	oT;v� M g7frr �r��chr&s  �rr��&contains_whitespace.<locals>.<genexpr>�s����$��2�Q�w����)r@rhr�)r&�wss` r�contains_whitespacer��s-����!�S���
��
6���$��$�$�$rc�.^�[U4SjS55$)z.True if there is any vertical whitespace in s.c3�,># �UH	oT;v� M g7frr r�s  �rr��&contains_linebreaks.<locals>.<genexpr>�s����,��2�Q�w��r�z

r�r�s`r�contains_linebreaksr��s����,��,�,�,rc�j�[U5[:a[[S5U4-5e[	U5n/nUn[U5[U5::aX@:wa[
R"X 5eX@:XaO'[U5upEU(aURU5 M`U(a[[U56$g)a�Return path relative to base, or raise PathNotChild exception.

The path may be either an absolute path or a path relative to the
current working directory.

os.path.commonprefix (python2.4) has a bad bug that it works just
on string prefixes, assuming that '/u' is a prefix of '/u2'.  This
avoids that problem.

NOTE: `base` should not have a trailing slash otherwise you'll get
PathNotChild exceptions regardless of `path`.
z,%r is too short to calculate a relative pathr`)rI�MIN_ABS_PATHLENGTH�
ValueErrorrnr�r
�PathNotChildrBrMry�reversed)r�rD�rpr&�head�tails      r�relpathr��s����4�y�%�%���B�C�t�g�M�
�	
�
���B�
�A�
�D�
��t�9��D�	�!�d�l��%�%�b�/�/��<���4�[�
���
�H�H�T�N��	���!��%�%�rc���[X5nU(dU$[U5nUn[URS55nUHtnUR	5n[
R"U5nUH/n	XyRR	5:XdM"U	Rn M] [XF/[U5Q76n O U[U5SRS5$![a [XF/[U5Q76n M@f=f)a�Return the canonical path relative to base.

Like relpath, but on case-insensitive-case-preserving file-systems, this
will return the relpath as stored on the file-system rather than in the
case specified in the input string, for all existing portions of the path.

This will cause O(N) behaviour if called for every path in a tree; if you
have a number of paths to convert, you should use canonical_relpaths().
r?N)r�r��iterrBr|r#�scandirr2ry�list�namerDrI�lstrip)
r�rD�rel�abs_base�current�bit_iter�bit�lbit�next_entries�entrys
          r�_cicp_canonical_relpathr�s����$�
�C���
��t�}�H��G��C�I�I�c�N�#�H����y�y�{��	��:�:�g�.�L�"�E��z�z�'�'�)�)��*�*���"��w�=�d�8�n�=�G��%�&�3�x�=�?�#�*�*�3�/�/���	��w�=�d�8�n�=�G��		�s�C�C7�6C7)r�r�c�D�UVs/sHn[X5PM sn$s snf)z�Create an iterable to canonicalize a sequence of relative paths.

The intent is for this implementation to use a cache, vastly speeding
up multiple transformations in the same directory.
)�canonical_relpath)r�rNr�s   r�canonical_relpathsrs"��16�6��1��d�&��6�6��6s�c��[U[5(aU$URS5$![a [R
"U5ef=f)z�Coerce unicode_or_utf8_string into unicode.

If it is unicode, it is returned.
Otherwise it is decoded from utf-8. If decoding fails, the exception is
wrapped in a BzrBadParameterNotUnicode exception.
�utf8)r@rhri�UnicodeDecodeErrorr
�BzrBadParameterNotUnicode��unicode_or_utf8_strings r�safe_unicodersR���(�#�.�.�%�%�G�%�,�,�V�4�4���G��.�.�/E�F�F�G�s	�*�!Ac��[U[5(aURS5 U$UR
S5$![a [R
"U5ef=f)z�Coerce unicode_or_utf8_string to a utf8 string.

If it is a str, it is returned.
If it is Unicode, it is encoded into a utf-8 string.
�utf-8)r@rArirr
rr r	s r�	safe_utf8r%sd���(�%�0�0�	K�"�)�)�'�2�&�%�!�(�(��1�1��"�	K��2�2�3I�J�J�	K�s	�;�!Ac��[$)zJReturn True if this platform normalizes unicode filenames.

Only Mac OSX.
)�_platform_normalizes_filenamesr rr�normalizes_filenamesr=s
��
*�)rc��[U[5(a$UR[R"55n[
R
SU5S4$)a�Get the unicode normalized path, and if you can access the file.

On platforms where the system normalizes filenames (Mac OSX),
you can access a file by any path which will normalize correctly.
On platforms where the system does not normalize filenames
(everything else), you have to access a file by its exact path.

Internally, bzr only supports NFC normalization, since that is
the standard for XML documents.

So return the normalized path, and a flag indicating if the file
can be accessed by that path.
r�T�r@rArir��getfilesystemencodingr�r�rCs r�_accessible_normalized_filenamerEs@���$�����{�{�3�4�4�6�7��� � ���-�t�3�3rc��[U[5(a$UR[R"55n[
R
SU5nXU:H4$r�r)rD�
normalizeds  r�!_inaccessible_normalized_filenamerXsF���$�����{�{�3�4�4�6�7���&�&�u�d�3�J��T�)�)�)rc��^^^�SSKnURmU(a	UUU4SjnOTnWRTU5nU(a	T"TS5 U$![a g[a SmNPf=f)a\A wrapper for signal.signal that also calls siginterrupt(signum, False)
on platforms that support that.

:param restart_syscall: if set, allow syscalls interrupted by a signal to
    automatically restart (by calling `signal.siginterrupt(signum,
    False)`).  May be ignored if the feature is not available on this
    platform or Python version.
rNc��grr )�signum�flags  r�siginterrupt�(set_signal_handler.<locals>.siginterruptys��rc�">�T"TS5 T"U6 g)NFr )r��handlerrrs ���r�sig_handler�'set_signal_handler.<locals>.sig_handler~s���
���'��T�NrF)�signalr�ImportError�AttributeError)rr �restart_syscallr#r!�old_handlerrs``    @r�set_signal_handlerr(esr������*�*���	�	����-�-���4�K���V�U�#����1�����	��s�A�
A&�A&�%A&�P�no_datac��[[RS5nUb	US:�aU$g[[RSS5nUbU"5(dg[SS5=upn[S:XaUq
Sq	O[S:Xa[U:waSq	[S:XaUbUS:�aU$[[RS5$![[4a SnN�f=f![[4a Of=f[S:XaUbUS:�aU$g)	a�Return terminal width.

None is returned if the width can't established precisely.

The rules are:
- if BRZ_COLUMNS is set, returns its value
- if there is no controlling terminal, returns None
- query the OS, if the queried size has changed since the last query,
  return its value,
- if COLUMNS is set, returns its value,
- if the OS has a value (even though it's never changed), return its value.

From there, we need to query the OS to get the size of the controlling
terminal.

On Unices we query the OS by:
- get termios.TIOCGWINSZ
- if an error occurs or a negative value is obtained, returns None

On Windows we query the OS by:
- win32utils.get_console_size() decides,
- returns None on error (provided default value)
�BRZ_COLUMNSNr�isattyr*�	unchanged�changed�COLUMNS)rDr#�environrfr�rkr�r��_terminal_size�_terminal_size_state�_first_terminal_size)�widthr-�height�os_sizes    r�terminal_widthr8�s��N��B�J�J�}�-�.��
���1�9��L��
�S�Z�Z��4�
0�F�
�~�V�X�X��-�T�4�8�8�M�E�G��y�(�&��*��	��	,�1E��1P�(���y�(�������L�
��2�:�:�i�(�)�)��=
�j�!������>
�j�!�
��
���{�*�������L�s#�B<� C�<C�C�C'�&C'c�2�[RXS9upX4$)N)�defaultx�defaulty)�
win32utils�get_console_size)r5r6s  r�_win32_terminal_sizer>�s���/�/��/�P�M�E��=�rc���SSKnSSKnSSKnURSSSSS5nUR	SUR
U5nUR
SU5SSupX4$![[4a X4$f=f)Nr�HHHHrr<)	�fcntl�struct�termios�pack�ioctl�
TIOCGWINSZ�unpackr2r%)r5r6rArBrCr&�xs       r�_ioctl_terminal_sizerI�s���	
�����K�K���1�a��+���K�K��7�-�-�q�1���
�
�f�a�0��1�5�
���=���
�^�$�
���=��
�s�AA�A/�.A/c���[RS:Xag[U5nUc[RS:g$US;agg![Ra n[
R
SX5 SnAgSnAff=f)z�Return if filesystem at path supports executable bit.

:param path: Path for which to check the file system
:return: boolean indicating whether executable bit can be stored/relied upon
r�FNr�r�T)r�r�r�r
r�r6r7r�s   r�supports_executablerKs���|�|�w���	��d�#���?��<�<�7�*�*��&�&��'����&�&�B�
���7��A�A���B�s�A�A5�A0�0A5c���[[SS5cg[U5nUc[RS:g$US;agg![
Ra n[RSX5 SnAgSnAff=f)zIReturn if the filesystem at path supports the creation of symbolic links.raNFr�r�r�Tr�r�s   r�supports_symlinksrM's����r�9�d�#�+��	��d�#���?��<�<�7�*�*��&�&��'����&�&�B�
���7��A�A���B�s�?�A3�A.�.A3c�(�[RS:g$)a�Return True if 'readonly' has POSIX semantics, False otherwise.

Notably, a win32 readonly file cannot be deleted, unlike POSIX where the
directory controls creation/deletion, etc.

And under win32, readonly means that the directory itself cannot be
deleted.  The contents of a readonly directory can be changed, unlike POSIX
where files in readonly directories cannot be added, deleted or renamed.
r�r�r rr�supports_posix_readonlyrO8s���<�<�7�"�"rc��[RRU5nUcUb[RU	U$U[RU'U$)aModify the environment, setting or removing the env_variable.

:param env_variable: The environment variable in question
:param value: The value to set the environment to. If None, then
    the variable will be removed.
:return: The original value of the environment variable.
�r#r1rd)�env_variable�value�orig_vals   r�set_or_unset_envrUEsI���z�z�~�~�l�+�H��}����
�
�<�(��O�$)��
�
�<� ��Orz^([A-Za-z]:[/\\])?[^:<>*"?\|]*$c��[RS:wag[RU5c[R
"U5eg)z{Check whether the supplied path is legal.
This is only required on Windows, so we don't test on other platforms
right now.
r�N)r�r��_valid_win32_path_re�matchr
�IllegalPathrCs r�check_legal_pathrZYs:��
�|�|�w����!�!�$�'�/�� � ��&�&�0ric#�D^# �[m[U5STS[U54/nU(a�UR5un  pPU(aUS-nOSnUS- /n[R"U5HYnU"UR
5n	UR
SS9n
[U
R5nURXi-X�X�R45 M[ UR5 X@4U4v� URU4Sj[U555 U(aM�gg![a NRf=f7f)a�Yield data about all the directories in a tree.

This yields all the data about the contents of a directory at a time.
After each directory has been yielded, if the caller has mutated the list
to exclude some directories, they are then not descended into.

The data yielded is of the form:
((directory-relpath, directory-path-from-top),
[(relpath, basename, kind, lstat, path-from-top), ...]),
 - directory-relpath is the relative path of the directory being returned
   with respect to top. prefix is prepended to this.
 - directory-path-from-root is the path including top for this directory.
   It is suitable for use with os functions.
 - relpath is the relative path within the subtree being walked.
 - basename is the basename of the path
 - kind is the kind of the file now. If unknown then the file is not
   present within the tree - but it may be recorded as versioned. See
   versioned_kind.
 - lstat is the stat data *if* the file was statted.
 - planned, not implemented:
   path_from_tree_root is the path from the root of the tree.

:param prefix: Prefix the relpaths that are yielded with 'prefix'. This
    allows one to walk a subtree but get paths that are relative to a tree
    rooted higher up.
:return: an iterator over the dirs.
r`Nr?F��follow_symlinksc3�<># �UHoST:XdM
Uv� M g7f)r<Nr )r��d�
_directorys  �rr��walkdirs.<locals>.<genexpr>�s����K�"4�Q�!��
�8J�q�q�"4�s��	)�_directory_kindrr�r#r�r�r&�file_kind_from_stat_moder%rMrD�NotADirectoryError�sort�extendr�)
�top�prefixr��pending�relroot�_�	relprefix�dirblockrr��	statvaluergr`s
            @r�walkdirsrogs	����B!�J��V�$�b�*�d�L��<M�N�O�G�
� '���
����A�q���#�
�I��I��c�	���	����C�����
�
�+��!�J�J�u�J�=�	�/�	�0A�0A�B������!1�4�y�*�*� U�V�	)�	�
�
���n�h�&�&�	���K�(�8�"4�K�K�-�'�� "�	��	�s2�AD �A3D�
AD �D �
D�D �D�D c�(�\rSrSrSrSSjrSrSrg)�	DirReaderi�z%An interface for reading directories.c�,�[UR5e)z�Converts top and prefix to a starting dir entry.

:param top: A utf8 path
:param prefix: An optional utf8 path to prefix output relative paths
    with.
:return: A tuple starting with prefix, and ending with the native
    encoding of top.
)�NotImplementedError�top_prefix_to_starting_dir�rrgrhs   rrt�$DirReader.top_prefix_to_starting_dir�s��"�$�"A�"A�B�Brc�,�[UR5e)a	Read a specific dir.

:param prefix: A utf8 prefix to be preprended to the path basenames.
:param top: A natively encoded path to read.
:return: A list of the directories contents. Each item contains:
    (utf8_relpath, utf8_name, kind, lstatvalue, native_abspath)
)rs�read_dir)rrhrgs   rrx�DirReader.read_dir�s��"�$�-�-�0�0rr N�r`)rrrr�__doc__rtrxrr rrrqrq�s��/�	C�1rrqc#�# �[cAUc[R"5n[RS:XaOUS;aSSKJn U"5q[c
[5q[RX5//n[Rn[nU(a�USR5un  p�US(dUR5 [U"X�55n
X�4U
4v� [U
5Vs/sHo�SU:XdM
UPM nnU(aURU5 U(aM�gg![an[U5 SnAN�SnAff=fs snf7f)apYield data about all the directories in a tree.

This yields the same information as walkdirs() only each entry is yielded
in utf-8. On platforms which have a filesystem encoding of utf8 the paths
are returned as exact byte-strings.

:return: yields a tuple of (dir_info, [file_info])
    dir_info is (utf8_relpath, path-from-top)
    file_info is (utf8_relpath, utf8_name, kind, lstat, path-from-top)
    if top is an absolute path, path-from-top is also an absolute path.
    path-from-top might be unicode or utf8, but it is the correct path to
    pass to os functions to affect the file in question. (such as os.lstat)
Nr�)r
�asciir��
UTF8DirReaderrHr<)�_selected_dir_readerr�rr��_readdir_pyxrr$r��UnicodeDirReaderrtrxrbr�rKr�rM)
rgrh�fs_encrr:rirxr`rjrkrmr_�nexts
             r�_walkdirs_utf8r��s%����#��>��.�.�0�F��<�<�7�"��
�)�
)�
�7�'4��$�
�#�/�1��%�?�?��L�M�N�G�#�,�,�H� �J�
� '����� 1����A�q��r�{��K�K�M��(�7�0�1���n�h�&�&�#�H�-�D�-�a�1���1C��-��D���N�N�4� ��'���
�(��+���
��(E�sG�;E	�
D"�BE	�'E�7E�=!E	� E	�"
E�,D<�7E	�<E�E	c�4�\rSrSrSrS/rSrS	SjrSrSr	g)
r�i�z9A dir reader for non-utf8 file systems, which transcodes.�_utf8_encodec�:�[R"S5Ulg)Nr)r��
getencoderr�)rs rr�UnicodeDirReader.__init__�s��"�-�-�f�5��rc�4�[U5SSS[U54$)z)See DirReader.top_prefix_to_starting_dir.N)rrrus   rrt�+UnicodeDirReader.top_prefix_to_starting_dir�s���&�!�4��t�\�#�5F�G�Grc��URnU(aUS-nOSnUS-n/nURn[R"[	U55Hdn[R
"UR5n	XY-n
U"U	S5SnURSS9n[UR5n
U"XK-X�X�45 Mf [U5$)a�Read a single directory from a non-utf8 file system.

top, and the abspath element in the output are unicode, all other paths
are utf8. Local disk IO is done via unicode calls to listdir etc.

This is currently the fallback code path when the filesystem encoding is
not UTF-8. It may be better to implement an alternative so that we can
safely handle paths that are not properly decodable in the current
encoding.

See DirReader.read_dir for details.
r>rr?�surrogateescaperFr\)r�rMr#r�rr�r�r&rcr%rK)rrhrgr�rl�	top_slashrmrMrr�r��	name_utf8rnrgs              rrx�UnicodeDirReader.read_dir�s����(�(�����
�I��I��#�I�	��������Z�Z�	�#��/�E��;�;�u�z�z�*�D��&�G�$�T�+<�=�a�@�I��
�
�5�
�9�I�+�I�,=�,=�>�D��I�)�9�I�O�P�
0��h��r)r�Nrz)
rrrrr{�	__slots__rrtrxrr rrr�r��s��C�� �I�6�H� rr�c��Uc0nSnSn[RUUS.nURU5 [RRU5(dUS"X5 [
XS9HupgUHup�p�nXZ"X�5 M M g)a;Copy all of the entries in from_path into to_path.

:param from_path: The base directory to copy.
:param to_path: The target directory. If it does not exist, it will
    be created.
:param handlers: A dictionary of functions, which takes a source and
    destinations for files, directories, etc.
    It is keyed on the file kind, such as 'directory', 'symlink', or 'file'
    'file', 'directory', and 'symlink' should always exist.
    If they are missing, they will be replaced with 'os.mkdir()',
    'os.readlink() + os.symlink()', and 'shutil.copy2()', respectively.
Nc�0�[R"U5 gr)r#�mkdir)�sourcer�s  r�copy_dir�copy_tree.<locals>.copy_dir5s
��
����rc�\�[R"U5n[R"X!5 g)zCopy the contents of a symlink.N)r#r�ra)r�r��link_tos   r�	copy_link�copy_tree.<locals>.copy_link8s���+�+�f�%��
�
�
�7�!r)r_rar[r[)rh)r��copy2r%r#rD�existsro)
�	from_path�to_path�handlersr�r��
real_handlers�	_dir_info�entriesr��_namerg�_str�s
             r�	copy_treer�s���(�����"�������M�
����"�
�7�7�>�>�'�"�"��k�"�9�6�&�y�A��	�29�.�G�D�w����1�3:�Brc�`�[[SS5nUcgUc'[RRU5nUS:XaSn[R"U5nU"XR
UR5 g![a. [RSUU5 [R5 gf=f)z�Copy usr/grp ownership from src file/dir to dst file/dir.

If src is None, the containing directory is used as source. If chown
fails, the error is ignored and a warning is printed.
�chownNr`r�zLUnable to copy ownership from "%s" to "%s". You may want to set it manually.)rkr#rDrur&�st_uid�st_gidr2r6r��log_exception_quietly)�dstr�r�r&s    r�copy_ownership_from_pathr�Ls���
�B���&�E��}��
�{��g�g�o�o�c�"���"�9��C�
&��G�G�C�L��
�c�8�8�Q�X�X�&���&�
�
�
�
/���		
�	�#�#�%�&�s�3A5�55B-�,B-c��[U5U4$)zoGenerate a prefix-order path key for path.

This can be used to sort paths in the same way that walkdirs does.
)rurCs r�path_prefix_keyr�hs��

�D�M�4� � rc�@�[U5n[U5nX#:�X#:-
$)zCCompare path_a and path_b to generate the same order walkdirs uses.)r�)�path_a�path_b�key_a�key_bs    r�compare_paths_prefix_orderr�ps%���F�#�E��F�#�E��M�e�m�,�,rc���[b[$[RS:Xa6[[SS5b$[R[R5nO[RS5n[R"U5RnUS:Xa[RS:XaSnUqU$![a< US;a.[RRS	RU55 SnUqU$f=f)
aFind out what the preferred user encoding is.

This is generally the encoding that is used for command line parameters
and file contents. This may be different from the terminal encoding
or the filesystem encoding.

:return: A string defining the preferred user encoding
N�posix�CODESETFr}r�r
)r`r�zCbrz: warning: unknown encoding {}. Continuing with ascii encoding.
)�_cached_user_encodingr#r�rk�locale�nl_langinfor��getpreferredencodingr�r�r�r�r�r�r�r8)�
user_encodings rr�r�zs����(�$�$�	�w�w�'��g�f�i��>�J�
�*�*�6�>�>�:�
��3�3�E�:�
�(��
�
�m�4�9�9�
��G�#��|�|�x�'�!(�
�*�����'� ���+��J�J���5�5;�V�M�5J�
�
 �
�*����' �s�. B.�.AC4�3C4c��[5$r)r�r rr�get_diff_header_encodingr��s�� �"�"rc�z�[RS:Xa[R5$SSKnUR5$)z�Return the current unicode host name.

This is meant to be used in place of socket.gethostname() because that
behaves inconsistently on different platforms.
r�rN)r�r�r<�
get_host_name�socket�gethostname)r�s rr�r��s1���|�|�w���'�'�)�)���!�!�#�#rr-�_end_of_stream_errors)�
WSAECONNRESET�WSAECONNABORTEDc���URU5nUbU"[U5S5 U$![a>nURSnU[;aSnAgU[
R:XaSnAMleSnAff=f)z�Read up to max_read_size of bytes from sock and notify of progress.

Translates "Connection reset by peer" into file-like EOF (return an
empty string rather than raise an error), and repeats the recv if
interrupted by a signal.
Nrrr)�recvrIr2r�r�r3�EINTR)�sockr	�
max_read_size�datar:�enos      r�read_bytes_from_socketr��st���	��9�9�]�+�D��*���D�	�6�2��K���		��&�&��)�C��+�+������#����		�s �+�
A3�A.�A.�-A.�.A3c��Sn[U5U:a7[USU[U5-
5nUS:XaU$X#-
n[U5U:aM7U$)apReceive an exact number of bytes.

Regular Socket.recv() may return less than the requested number of bytes,
depending on what's in the OS buffer.  MSG_WAITALL is not available
on all platforms, but this should work everywhere.  This will return
less than the requested amount if the remote end closes.

This isn't optimized and is intended mostly for use in testing.
rN)rIr�)r��countrr~s    r�recv_allr��sV��	�A�

�a�&�5�.�$�V�T�5�3�q�6�>�B���#�:���H�	
���	�a�&�5�.�

�Hrc���Sn[U5n[U5nX4:a^URXSU[-5nUS:Xa%[R
"SR
U55eX6-
nUb	U"US5 X4:aM]gg![aZnURS[;a[R
"SU5eURS[R:waeSnANhSnAff=f)a�Send all bytes on a socket.

Breaks large blocks in smaller chunks to avoid buffering limitations on
some platforms, and catches EINTR which may be thrown if the send is
interrupted by a signal.

This is preferred to socket.sendall(), because it avoids portability bugs
and provides activity reporting.

:param report_activity: Call this as bytes are read, see
    Transport._report_activity
rzSending to {} returned 0 bytesNr�zError trying to write to socket)rIr�send�MAX_SOCKET_CHUNKr
�ConnectionResetr8r2r�r�r3r�)r�rAr	�
sent_total�
byte_countr�sentr:s        r�send_allr��s����J��U��J��e��D�
�
!�	/��9�9�T�z�<L�/L�M�N�D��q�y��,�,�4�;�;�D�A���
��J��*���g�.��
!���	��v�v�a�y�1�1��,�,�-N�PQ�R�R��v�v�a�y�E�K�K�'��(��	�s�A=�=
C!�AC�C!c�Z�[RS5nUup#[RX#S[R5H5nUupVpxn	Sn
[RXVU5n
U
R	U	5 U
s $ Ue![
a&nUnU
bU
R
5 SnAM`SnAMfSnAff=f)Nz!getaddrinfo returns an empty listr)r��error�getaddrinfo�SOCK_STREAM�connectr2r0)�address�err�host�port�res�af�socktype�proto�	canonname�sar�r:s            r�connect_socketr�s����,�,�:�
;�C��J�D��!�!�$�a��1C�1C�D��-0�*��e����		��=�=��u�5�D��L�L����K�
E��I���	��C����
�
��� ��	�s�(A:�:
B*�B%�%B*c��[RRU5up[[	[SU55U5$)z�Determine the real path to a file.

All parent elements are dereferenced.  But the file itself is not
dereferenced.
:param path: The original path.  May be absolute or relative.
:return: the real path *to* the file
r�)r#rDrBryr�)rD�parentr�s   r�dereference_pathr�0s3���7�7�=�=��&�L�F��H�X�c�6�2�3�T�:�:rc�(�[RS:H$)z7Return True if we can use MAPI to launch a mail client.r�r�r rr�
supports_mapir�>s���<�<�7�"�"rc��US:XaUnOsURS5(a8U[S5SRS[R5n[X5nO%[R"SRU55e[[R5n[[SS5(a[[USS55n[[X255nUR!5sSSS5 $!,(df   g=f)a�Load a resource from a package and return it as a string.

Note: Only packages that start with breezy are currently supported.

This is designed to be a lightweight implementation of resource
loading in a way which is API compatible with the same API from
pkg_resources. See
http://peak.telecommunity.com/DevCenter/PkgResources#basic-resource-access.
If and when pkg_resources becomes a standard library, this routine
can delegate to it.
�breezyzbreezy.Nr�z!resource package {} not in breezy�frozenr�)r�rIr�r#r�ryr
rmr8rur��__file__rkr�r�r.r)�package�
resource_name�resource_relpathr�rYs     r�resource_stringr�Cs����(��(��	�	�	�I�	&�	&��#�i�.�*�+�3�3�C����@��#�G�;���o�o�A�H�H��Q�R�R��6�?�?�#�D��s�H�d�#�#��x��d�D�1�2��	
�h�t�.�	/�1��v�v�x�
0�	/�	/�s�C0�0
C>c��[[LaSSKJn U"5Rq[U5$![
a	 SSKJq Nf=f)Nrr~)�_kind_from_mode)rc�file_kind_from_stat_mode_thunkr�r�kind_from_moder$�_readdir_pyr�)r9rs  rr�r�`sH���#A�A�	Q�3�'4��'E�'E�$�
$�D�)�)��	�	Q�
Q�	Q�s�1�A�Ac��U"U5$![aCn[USS5[R[R4;aSSKJn U"U5eeSnAff=f)Nr3rrp)r2rkr3rlrzrsrq)rY�_lstatr:rqs    r�	file_statr�qsO����a�y������1�g�t�$����u�}�}�(E�E�-��Q�-��
���s�
�
A�>A�Ac�B�[X5n[UR5$r)r�rcr%)rYr��
stat_values   r�	file_kindr|s���1�%�J�#�J�$6�$6�7�7rc��U"U0UD6$![a*nUR[R:XaSnAM8eSnAff=f)aRRun f(*a, **kw), retrying if an EINTR error occurs.

WARNING: you must be certain that it is safe to retry the call repeatedly
if EINTR does occur.  This is typically only true for low-level operations
like os.read.  If in any doubt, don't use this.

Keep in mind that this is not a complete solution to EINTR.  There is
probably code in the Python standard library and other dependencies that
may encounter EINTR if a signal arrives (and there is signal handler for
that signal).  So this function can reduce the impact for IO that breezy
directly controls, but it is not a complete solution.
N)r2r3r�)rYr<�kwr:s    r�until_no_eintrr�s@���	��a�;�2�;����	��w�w�%�+�+�%����	�s��
?�:�:�?c�*�SSKnUR5$r�)�msvcrt�getch)rs r�getcharr	�s����|�|�~�rc�P�SSKnSSKn[RR	5nURU5nUR
U5 [RRS5nURX RU5 U$!URX RU5 f=f)Nrr)
rC�ttyr�r�r�	tcgetattr�setrawr�	tcsetattr�	TCSADRAIN)rCr�fd�settingsr�s     rr	r	�s�����
�Y�Y�
�
�
���$�$�R�(��	?��J�J�r�N�������"�B����b�"3�"3�X�>��	��
���b�"3�"3�X�>�s�0B�B%�linuxc�f�[R"S5$![[[4a gf=f)N�SC_NPROCESSORS_ONLN)r#�sysconfr�r2r%r rr�_local_concurrencyr�s0��	��:�:�3�4�4���G�^�4�	��	�s��0�0c�l�[R/SQ[RS9R5S$)N)�sysctl�-nzhw.availcpu�r�r��
subprocess�Popen�PIPE�communicater rrrr�s1�����+�J�O�O� �
�
�+�-���	r�bsdc�l�[R/SQ[RS9R5S$)N)rrzhw.ncpurrrr rrrr�s1�����'�
��� �
�
�+�-���	r�sunos5c�l�[RSS/[RS9R5S$)N�psrinfoz-prrrr rrrr�s>�������
��?�?� �
��+�-��
�	rc�@�[RRS5$)N�NUMBER_OF_PROCESSORSrQr rrrr�s���z�z�~�~�4�5�5rc��grr r rrrr�s��rc�P�[b
U(a[$[RRSS5nUcSSKnUR5n[U5nU(aUqU$![a [5nN.![a N;f=ff=f![[4a SnNKf=f)z�Return how many processes can be run concurrently.

Rely on platform specific implementations and default to 1 (one) if
anything goes wrong.
N�BRZ_CONCURRENCYrr)�_cached_local_concurrencyr#r1rd�multiprocessing�	cpu_countrsrr2rD�	TypeErrorr�)�	use_cache�concurrencyr+s   r�local_concurrencyr0�s���!�,��(�(��*�*�.�.�!2�D�9�K����	�)�3�3�5�K���+�&���$/�!����#�	�
�0�2����
��
��		��
�z�"�����s;�A$�B�$
B
�/
A;�;
B	�B
�B	�	B
�B%�$B%c�(�\rSrSrSrSSjrSrSrg)�UnicodeOrBytesToBytesWriteri�z2A stream writer that doesn't decode str arguments.c�P�[RRXU5 Xlgr)r��StreamWriterrr )rr �streamr
s    rr�$UnicodeOrBytesToBytesWriter.__init__�s�����$�$�T�6�:��rc���[U[5(aURRU5 gUR	XR
5up#URRU5 gr)r@rhr5r�r r
)r�objectr�rks    rr��!UnicodeOrBytesToBytesWriter.write	sG���f�c�"�"��K�K���f�%��k�k�&�+�+�6�G�D��K�K���d�#r)r N)�strict)rrrrr{rr�rr rrr2r2�s��<��$rr2r�r��returnc�l�SnUSUS3nU"U5(aUS-
nUSUS3nU"U5(aMU$)a~Find a non-existing backup file name.

This will *not* create anything, this only return a 'free' entry.  This
should be used for checking names in a directory below a locked
tree/branch/repo to avoid race conditions. This is LBYL (Look Before You
Leap) and generally discouraged.

:param base: The base name.

:param exists: A callable returning True if the path parameter exists.
rz.~r�r )r�r��counterr�s    r�available_backup_namer>		sQ���G��V�2�g�Y�a� �D�
��,�,��1�����r�'��!�$����,�,��Krc��SSKnURXR5nURXRX!R-5 g![[
4a gf=f)ziSet a Unix file descriptor's FD_CLOEXEC flag.  Do nothing if platform
support for this is not available.
rN)rA�F_GETFD�F_SETFD�
FD_CLOEXECr$r%)rrAr}s   r�set_fd_cloexecrC	sN��
���k�k�"�m�m�,��
���B�
�
�s�-=�-=�'=�>����(�
��
�s�AA
�
A�Ac�"�[RS:Xa�[RR	SS5R[R5nUVs/sHo"R5PM nn[RRU5up2US:waUR5U;agUnU/nOS/n[RR	S5nUb�UR[R5nUH^nUHUn[RRXP5U-n[R"U[R5(dMQUs s $ M` [RS:Xa[RU5nXp:waU$gs snf)aFinds an executable on the PATH.

On Windows, this will try to append each extension in the PATHEXT
environment variable to the name, if it cannot be found with the name
as given.

:param name: The base name of the executable.
:return: The path to the executable found or None.
r��PATHEXTr`N�PATH)r�r�r#r1rdrB�pathsepr|rD�splitextr��access�X_OKr<�get_app_path)r��exts�extr�rDr_rY�app_paths        r�find_executable_on_pathrO+	s-���|�|�w���z�z�~�~�i��,�2�2�2�:�:�>��'+�,�t��	�	��t��,��G�G�$�$�T�*�	���"�9��y�y�{�$�&���D��5�D���t��
�:�:�>�>�&�!�D����z�z�"�*�*�%���C����G�G�L�L��)�C�/���9�9�Q����(�(��H���
�|�|�w���*�*�4�0�����O���+-s�Fc��[R"US5 g![afnUR[R:XaSnAgUR[R
:XaSnAg[RSX5 SnAgSnAff=f)z?True if pid doesn't correspond to live process on this machine.rFNTzos.kill(%d, 0) failed: %s)r#�killr2r3�ESRCHr4r6r7)�pidr:s  r�_posix_is_local_pid_deadrTO	se���
����Q�������7�7�e�k�k�!��
�W�W����
#���L�L�4�c�=����s ��
B
�B�B�*B�B
)�EAGAINr��ENOTSUP�
EOPNOTSUPPr5c	��[[S[[SS55nUb
U"U5 gg![aDn[R	SRU55 [USS5[;aeSnAgSnAff=f)z�Flush file contents to disk if possible.

:param fileno: Integer OS file handle.
:raises TransportNotPossible: If flushing to disk is not possible.
�	fdatasync�fsyncNz$ignoring error calling fdatasync: {}r3)rkr#r2r6r7r8�_fdatasync_ignored)r�fnr:s   rrYrYr	sx��
��[�'�"�g�t�"<�	=�B�	�~�		��v�J����	�

�L�L�?�F�F�q�I�J��q�'�4�(�0B�B��C��
	�s�/�
A=�:A8�8A=c���[R"U5 g![aKnUR[R:wae[R
"U5/:waU"U5eSnAgSnAff=f)z�Make sure a local directory exists and is empty.

If it does not exist, it is created.  If it exists and is not empty, an
instance of exception_class is raised.
N)r#r�r2r3�EEXIST�listdir)rD�exception_classr:s   r�ensure_empty_directory_existsra�	sV��(�
�������(��7�7�e�l�l�"��
�:�:�d��r�!�!�$�'�'�"��(�s��
A.�AA)�)A.c#�# �[US5nUHXnURS5(aMUR5n[U5S:aM<USUSR	SS54v� MZ SSS5 g!,(df   g=f7f)	z�Read an fstab-style file and extract mountpoint+filesystem information.

:param path: Path to read from
:yield: Tuples with mountpoints (as bytestrings) and filesystem names
�rb�#r�rr<r}r�N)r.r�rBrIri)rDrYr��colss    r�	read_mtabrf�	sq���
�d�D�	�Q��D����t�$�$���:�:�<�D��4�y�1�}���q�'�4��7�>�>�'�9�=�=�=�
�
�	�	�s�
B�AA7�.	B�7
B�Bc��\rSrSrSrSrSrg)�FilesystemFinderi�	�*Find the filesystem for a particular path.c��[er)rs)rrDs  r�find�FilesystemFinder.find�	s��!�!rr N)rrrrr{rkrr rrrhrh�	s
��4�"rrhc�8�\rSrSrSrSrSr\S5rSr	Sr
g)	�MtabFilesystemFinderi�	riz	/etc/mtabc�(�Sn[XSS9Ulg)Nc��[US5$r�)rI)rHs rrG�*MtabFilesystemFinder.__init__.<locals>.key�	s���q��t�9�rT)rG�reverse)rK�_mountpoints)r�mountpointsrGs   rr�MtabFilesystemFinder.__init__�	s��	�#�;��F��rc��U"[UR55$![a(n[R	SU5 U"/5sSnA$SnAff=f)z�Create a FilesystemFinder from an mtab-style file.

Note that this will silenty ignore mtab if it doesn't exist or can not
be opened.
zUnable to read mtab: %sN)rf�	MTAB_PATHr2r6r7)�clsr:s  r�	from_mtab�MtabFilesystemFinder.from_mtab�	sC��	��y����/�0�0���	��L�L�2�A�6��r�7�N��	�s��
A�A
�A�
Ac��[U[5(d[R"U5nURHup#[X!5(dMUs $ g)z�Find the filesystem used by a particular path.

:param path: Path to find (bytestring or text type)
:return: Filesystem name (as text type) or None, if the filesystem is
    unknown.
N)r@rAr#r�rsrL)rrD�
mountpoint�
filesystems    rrk�MtabFilesystemFinder.find�	sH���$��&�&��;�;�t�$�D�&*�&7�&7�"�J���*�*�!�!�'8�r)rsN)rrrrr{rwr�classmethodryrkrr rrrnrn�	s)��4��I�G�����rrnc��\rSrSrSrSrg)�Win32FilesystemFinderi�	c�6�[RR[RRU55Sn[	U[
5(a[R"U5n[RUS-5nUcgSSS.RX35$)Nrr�r�r�)�FAT32�NTFS)
r#rDr�r�r@rAr�r<r�rd)rrDr�r�s    rrk�Win32FilesystemFinder.find�	s{�����"�"�2�7�7�?�?�4�#8�9�!�<���e�U�#�#��K�K��&�E��(�(����6���?����
��#�g�
�	 rr N)rrrrrkrr rrr�r��	s��
 rr�c��[c3[RS:Xa[5qO[R5q[R
U5$)z�Return the filesystem type for the partition a path is in.

:param path: Path to search filesystem type for
:return: A FS type, as string. E.g. "ext2"
r�)�_FILESYSTEM_FINDERr�r�r�rnryrkrCs rr�r��	s?���!��<�<�7�"�!6�!8��!5�!?�!?�!A���"�"�4�(�(r)F)rH��Nrr)r�)rrmNT)T)r`N)�r�r3r#rUr&r�rv�	functoolsr�typingrr�__all__�globals�hashlibrr	rr�r`r
rkrrr
rmrr,r/r(rQrTrZrbr^rerhrDrir�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�ryr��
expanduser�
_get_home_dirr�r�rurtrBrHr$r~r�r�r�r�r�r<�get_home_location�
get_user_namer�r�r�r�r�rLr�rrrrr"r(r+r1r6r8r:r?rJrUrcr]r^�dictrDrh�__annotations__rfrjrTrqr|r��urandomr�rrsr�rxr�r�r�r�r�r��_chunks_to_lines_pyxr�r$r:�_chunks_to_lines_pyr�r�r�r�r�r�r�r�r�r�r�rrrrrrrrr�normalized_filenamer(�default_terminal_widthr3r4r8r>rIr2rKrMrOrUrVrWrZ�_WIN32_ERROR_DIRECTORYr�rorqr�r�r�r�r�r�r�r�r�r�r�r��
ECONNRESET�EPIPEr�r�r��_enorMr%r�r�r�r�r�r�r�r�rcr�rrr	r�rr*r0r4r2�boolr>rCrOrT�is_local_pid_dead�_maybe_ignoredr[rYrarfrhrnr�r�r��perf_counter)�wdr�s00r�<module>r�s���"��	�	��
����$�
�	���
��I���0��
���2�z�1�%��	��X�q�	!���b�-��+��!����!�)�)��$�6
�	��"����B��S�
�s��c�	����"�'�'�9�d�
+��
�?��H+�V�
 �'�H�
I�
5�I�?��$5��.
 ��	�	�	*��
�'�'�/�/��
�7�7����
�7�7�<�<��������*�*�C�0�
��
����
�'�'�/�/��
�7�7����
���
�
��
�7�7����	����
��������<�<�7���G��H��H��H�
�F�
#�M�
2�F���
�$)�2H�;��0�0�M� �.�.�O��\�\�X��
�F�7�t	!����!�8B�
�����
3�l4�$�(���$�#&���#�
8�
	�
� =��FN�!O�h��';�";�h�!O��!�(!#�
�t�C��H�~�"�<=�]�!�*BF�!�,&�*<�0T�f.��Z�Z�
�
���D� ���1�
�	/��	
� �D�
��
���7�6�"5�5��
�=�
#��&	�/��
%� -�
#�L,0�h�<�<�&�&�/����7�G�2�&"'���<�<�8��%)�"�*�4�&*�"�9��;��%�P���!����Q�h�
�����<�<�7��)�N�)�N��*�"
#��"�z�z�"D�E��'����b�k�k�9L�x1�1�2��/!�d* �y�* �Z+2�\&�8!�-���,�^#�$�$��$)�$4�$4�e�k�k�5�<�<�#P��t�C�y�P�0�D�
��$�$�W�U�D�%9�:�
1�26�EU��4
�&/�D�0;�#�
�:*�:���������8�
�.�<�<�7�����<�<���7�#�#��
	�\�\�X����c�l�l���	�\�\�X���	�\�\�W��6�
�
!���@$�&�"5�"5�$����X�s�e�T�k�-B��s��(
�!�H�,�<�<�7��"�4�4��0��G�������u�d�D�!��G�E�4������((�
>� "�"�&�+�&�R �,� ���
)� � � ���[7"P��|�	�	�	��L�5��Q��4�4��5��p�
��
��L
sN�W=�,X�X�X4�Y�1
Y�	X�X�X1�X,�,X1�4X?�>X?

Youez - 2016 - github.com/yon3zu
LinuXploit