shell bypass 403
l
��bc @ s� d Z d d l Z d d l Z d d l m Z d d d g Z i Z d Z d d � Z d
� Z
d � Z Gd � d � Z d d
� Z
e e d � Z d � Z d � Z e d k r� e � n d S( u� Utilities for comparing files and directories.
Classes:
dircmp
Functions:
cmp(f1, f2, shallow=True) -> int
cmpfiles(a, b, common) -> ([], [], [])
i N( u filterfalseu cmpu dircmpu cmpfilesi i c C s� t t j | � � } t t j | � � } | d t j k sP | d t j k rT d S| rj | | k rj d S| d | d k r� d St j | | | | f � } | d k r� t | | � } t
t � d k r� t j � n | t | | | | f <n | S( u� Compare two files.
Arguments:
f1 -- First file name
f2 -- Second file name
shallow -- Just check stat signature (do not read the files).
defaults to 1.
Return value:
True if the files are the same, False otherwise.
This function uses a cache for past comparisons and the results,
with a cache invalidation mechanism relying on stale signatures.
i i id FTN( u _sigu osu statu S_IFREGu Falseu Trueu _cacheu getu Noneu _do_cmpu lenu clear( u f1u f2u shallowu s1u s2u outcome( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu cmp s &
c C s t j | j � | j | j f S( N( u statu S_IFMTu st_modeu st_sizeu st_mtime( u st( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu _sig; s c C sx t } t | d � �] } t | d � �E } x; | j | � } | j | � } | | k r[ d S| s- d Sq- Wd QXWd QXd S( Nu rbFT( u BUFSIZEu openu readu Falseu True( u f1u f2u bufsizeu fp1u fp2u b1u b2( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu _do_cmp@ s c B s� | Ee Z d Z d d d � Z d � Z d � Z d � Z d � Z d � Z d � Z
d � Z d � Z d
� Z
e d e d e d
e d e d e d e d e d e d e d e d e d e � Z d � Z d S( uT A class that manages the comparison of 2 directories.
dircmp(a, b, ignore=None, hide=None)
A and B are directories.
IGNORE is a list of names to ignore,
defaults to ['RCS', 'CVS', 'tags'].
HIDE is a list of names to hide,
defaults to [os.curdir, os.pardir].
High level usage:
x = dircmp(dir1, dir2)
x.report() -> prints a report on the differences between dir1 and dir2
or
x.report_partial_closure() -> prints report on differences between dir1
and dir2, and reports on common immediate subdirectories.
x.report_full_closure() -> like report_partial_closure,
but fully recursive.
Attributes:
left_list, right_list: The files in dir1 and dir2,
filtered by hide and ignore.
common: a list of names in both dir1 and dir2.
left_only, right_only: names only in dir1, dir2.
common_dirs: subdirectories in both dir1 and dir2.
common_files: files in both dir1 and dir2.
common_funny: names in both dir1 and dir2 where the type differs between
dir1 and dir2, or the name is not stat-able.
same_files: list of identical files.
diff_files: list of filenames which differ.
funny_files: list of files which could not be compared.
subdirs: a dictionary of dircmp objects, keyed by names in common_dirs.
c C sm | | _ | | _ | d k r6 t j t j g | _ n | | _ | d k r` d d d g | _ n | | _ d S( Nu RCSu CVSu tags( u leftu rightu Noneu osu curdiru pardiru hideu ignore( u selfu au bu ignoreu hide( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu __init__o s c C sn t t j | j � | j | j � | _ t t j | j � | j | j � | _ | j j � | j j � d S( N(
u _filteru osu listdiru leftu hideu ignoreu left_listu rightu
right_listu sort( u self( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu phase0{ s
c C s� t t t t j j | j � | j � � } t t t t j j | j � | j � � } t t | j t
| j | � � � | _ t t | j t
| j | � � � | _ t t | j t
| j | � � � | _ d S( N( u dictu zipu mapu osu pathu normcaseu left_listu
right_listu listu __getitem__u filteru __contains__u commonu filterfalseu left_onlyu
right_only( u selfu au b( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu phase1� s
**''c
C s� g | _ g | _ g | _ x| j D]t} t j j | j | � } t j j | j | � } d } y t j | � } Wn. t j
k
r� } z d } WYd d } ~ Xn Xy t j | � } Wn. t j
k
r� } z d } WYd d } ~ Xn X| r�t j | j � } t j | j � } | | k r2| j j
| � q�t j | � rT| j j
| � q�t j | � rv| j j
| � q�| j j
| � q% | j j
| � q% Wd S( Ni i ( u common_dirsu common_filesu common_funnyu commonu osu pathu joinu leftu rightu statu erroru S_IFMTu st_modeu appendu S_ISDIRu S_ISREG(
u selfu xu a_pathu b_pathu oku a_statu whyu b_statu a_typeu b_type( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu phase2� s4 c C s7 t | j | j | j � } | \ | _ | _ | _ d S( N( u cmpfilesu leftu rightu common_filesu
same_filesu
diff_filesu funny_files( u selfu xx( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu phase3� s c C ss i | _ xc | j D]X } t j j | j | � } t j j | j | � } t | | | j | j � | j | <q Wd S( N(
u subdirsu common_dirsu osu pathu joinu leftu rightu dircmpu ignoreu hide( u selfu xu a_xu b_x( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu phase4� s
c C s2 | j � x! | j j � D] } | j � q Wd S( N( u phase4u subdirsu valuesu phase4_closure( u selfu sd( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu phase4_closure� s
c C sK t d | j | j � | j rH | j j � t d | j d | j � n | j rz | j j � t d | j d | j � n | j r� | j j � t d | j � n | j r� | j j � t d | j � n | j r� | j j � t d | j � n | j r| j j � t d | j � n | j
rG| j
j � t d | j
� n d S( Nu diffu Only inu :u Identical files :u Differing files :u Trouble with common files :u Common subdirectories :u Common funny cases :( u printu leftu rightu left_onlyu sortu
right_onlyu
same_filesu
diff_filesu funny_filesu common_dirsu common_funny( u self( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu report� s,
c C s9 | j � x( | j j � D] } t � | j � q Wd S( N( u reportu subdirsu valuesu print( u selfu sd( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu report_partial_closure� s
c C s9 | j � x( | j j � D] } t � | j � q Wd S( N( u reportu subdirsu valuesu printu report_full_closure( u selfu sd( ( u. /usr/local/python-3.2/lib/python3.2/filecmp.pyu report_full_closure� s
u subdirsu
same_filesu
diff_filesu funny_filesu common_dirsu common_filesu common_funnyu commonu left_onlyu
right_onlyu left_listu
right_listc C s<