<s> """<STR_LIT>""" <EOL> import os <EOL> import sys <EOL> import errno <EOL> import pathlib <EOL> import collections <EOL> import requests <EOL> import re <EOL> import json <EOL> import dateutil . parser <EOL> import hashlib <EOL> try : <EOL> import requests . packages . urllib3 as urllib3 <EOL> except ImportError : <EOL> import urllib3 <EOL> try : <EOL> import configparser <EOL> except ImportError : <EOL> import ConfigParser as configparser <EOL> default_config_path = '<STR_LIT>' <EOL> global_config = None <EOL> def read_config ( config_path = default_config_path ) : <EOL> """<STR_LIT>""" <EOL> config_path = os . path . expanduser ( config_path ) <EOL> if not os . path . isfile ( config_path ) : <EOL> raise OSError ( errno . ENOENT , <EOL> "<STR_LIT>" % <EOL> config_path ) <EOL> p = configparser . ConfigParser ( ) <EOL> p . read ( config_path ) <EOL> result = { } <EOL> for section in p . sections ( ) : <EOL> username = p . get ( section , '<STR_LIT:username>' ) if p . has_option ( section , '<STR_LIT:username>' ) else None <EOL> password = p . get ( section , '<STR_LIT:password>' ) if p . has_option ( section , '<STR_LIT:password>' ) else None <EOL> verify = p . getboolean ( section , '<STR_LIT>' ) if p . has_option ( section , '<STR_LIT>' ) else True <EOL> cert = p . get ( section , '<STR_LIT>' ) if p . has_option ( section , '<STR_LIT>' ) else None <EOL> result [ section ] = { '<STR_LIT:username>' : username , <EOL> '<STR_LIT:password>' : password , <EOL> '<STR_LIT>' : verify , <EOL> '<STR_LIT>' : cert } <EOL> if result [ section ] [ '<STR_LIT>' ] : <EOL> result [ section ] [ '<STR_LIT>' ] = os . path . expanduser ( result [ section ] [ '<STR_LIT>' ] ) <EOL> return result <EOL> def read_global_config ( config_path = default_config_path ) : <EOL> """<STR_LIT>""" <EOL> global global_config <EOL> if global_config is None : <EOL> try : <EOL> global_config = read_config ( config_path ) <EOL> except OSError : <EOL> pass <EOL> def without_http_prefix ( url ) : <EOL> """<STR_LIT>""" <EOL> if url . startswith ( '<STR_LIT>' ) : <EOL> return url [ <NUM_LIT:7> : ] <EOL> elif url . startswith ( '<STR_LIT>' ) : <EOL> return url [ <NUM_LIT:8> : ] <EOL> return url <EOL> def get_base_url ( config , url ) : <EOL> """<STR_LIT>""" <EOL> if not config : <EOL> return None <EOL> for item in config : <EOL> if url . startswith ( item ) : <EOL> return item <EOL> for item in config : <EOL> if without_http_prefix ( url ) . startswith ( without_http_prefix ( item ) ) : <EOL> return item <EOL> def get_config_entry ( config , url ) : <EOL> """<STR_LIT>""" <EOL> if not config : <EOL> return None <EOL> if url in config : <EOL> return config [ url ] <EOL> for item in config : <EOL> if without_http_prefix ( item ) == without_http_prefix ( url ) : <EOL> return config [ item ] <EOL> def get_global_config_entry ( url ) : <EOL> """<STR_LIT>""" <EOL> read_global_config ( ) <EOL> return get_config_entry ( global_config , url ) <EOL> def get_global_base_url ( url ) : <EOL> """<STR_LIT>""" <EOL> read_global_config ( ) <EOL> return get_base_url ( global_config , url ) <EOL> def md5sum ( filename ) : <EOL> """<STR_LIT>""" <EOL> md5 = hashlib . md5 ( ) <EOL> with open ( filename , '<STR_LIT:rb>' ) as f : <EOL> for chunk in iter ( lambda : f . read ( <NUM_LIT> * md5 . block_size ) , b'<STR_LIT>' ) : <EOL> md5 . update ( chunk ) <EOL> return md5 . hexdigest ( ) <EOL> def sha1sum ( filename ) : <EOL> """<STR_LIT>""" <EOL> sha1 = hashlib . sha1 ( ) <EOL> with open ( filename , '<STR_LIT:rb>' ) as f : <EOL> for chunk in iter ( lambda : f . read ( <NUM_LIT> * sha1 . block_size ) , b'<STR_LIT>' ) : <EOL> sha1 . update ( chunk ) <EOL> return sha1 . hexdigest ( ) <EOL> class HTTPResponseWrapper ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , obj ) : <EOL> self . obj = obj <EOL> def __getattr__ ( self , attr ) : <EOL> """<STR_LIT>""" <EOL> if attr in self . __dict__ : <EOL> return self . __dict__ [ attr ] <EOL> if attr == '<STR_LIT>' : <EOL> raise AttributeError <EOL> return getattr ( self . obj , attr ) <EOL> def __len__ ( self ) : <EOL> """<STR_LIT>""" <EOL> return int ( self . getheader ( '<STR_LIT>' ) ) <EOL> def encode_matrix_parameters ( parameters ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> for param in iter ( sorted ( parameters ) ) : <EOL> if isinstance ( parameters [ param ] , ( list , tuple ) ) : <EOL> value = ( '<STR_LIT>' % ( param ) ) . join ( parameters [ param ] ) <EOL> else : <EOL> value = parameters [ param ] <EOL> result . append ( "<STR_LIT>" % ( param , value ) ) <EOL> return '<STR_LIT:;>' . join ( result ) <EOL> def escape_chars ( s ) : <EOL> """<STR_LIT>""" <EOL> return "<STR_LIT>" . join ( [ '<STR_LIT:\\>' + ch if ch in '<STR_LIT>' else ch for ch in s ] ) <EOL> def encode_properties ( parameters ) : <EOL> """<STR_LIT>""" <EOL> result = [ ] <EOL> for param in iter ( sorted ( parameters ) ) : <EOL> if isinstance ( parameters [ param ] , ( list , tuple ) ) : <EOL> value = '<STR_LIT:U+002C>' . join ( [ escape_chars ( x ) for x in parameters [ param ] ] ) <EOL> else : <EOL> value = escape_chars ( parameters [ param ] ) <EOL> result . append ( "<STR_LIT>" % ( param , value ) ) <EOL> return '<STR_LIT:|>' . join ( result ) <EOL> class _ArtifactoryFlavour ( pathlib . _Flavour ) : <EOL> """<STR_LIT>""" <EOL> sep = '<STR_LIT:/>' <EOL> altsep = '<STR_LIT:/>' <EOL> has_drv = True <EOL> pathmod = pathlib . posixpath <EOL> is_supported = ( True ) <EOL> def parse_parts ( self , parts ) : <EOL> drv , root , parsed = super ( _ArtifactoryFlavour , self ) . parse_parts ( parts ) <EOL> return drv , root , parsed <EOL> def splitroot ( self , part , sep = sep ) : <EOL> """<STR_LIT>""" <EOL> drv = '<STR_LIT>' <EOL> root = '<STR_LIT>' <EOL> base = get_global_base_url ( part ) <EOL> if base and without_http_prefix ( part ) . startswith ( without_http_prefix ( base ) ) : <EOL> mark = without_http_prefix ( base ) . rstrip ( sep ) + sep <EOL> parts = part . split ( mark ) <EOL> else : <EOL> mark = sep + '<STR_LIT>' + sep <EOL> parts = part . split ( mark ) <EOL> if len ( parts ) >= <NUM_LIT:2> : <EOL> drv = parts [ <NUM_LIT:0> ] + mark . rstrip ( sep ) <EOL> rest = sep + mark . join ( parts [ <NUM_LIT:1> : ] ) <EOL> elif part . endswith ( mark . rstrip ( sep ) ) : <EOL> drv = part <EOL> rest = '<STR_LIT>' <EOL> else : <EOL> rest = part <EOL> if not rest : <EOL> return drv , '<STR_LIT>' , '<STR_LIT>' <EOL> if rest == sep : <EOL> return drv , '<STR_LIT>' , '<STR_LIT>' <EOL> if rest . startswith ( sep ) : <EOL> root , _ , part = rest [ <NUM_LIT:1> : ] . partition ( sep ) <EOL> root = sep + root + sep <EOL> return drv , root , part <EOL> def casefold ( self , string ) : <EOL> """<STR_LIT>""" <EOL> return string <EOL> def casefold_parts ( self , parts ) : <EOL> """<STR_LIT>""" <EOL> return parts <EOL> def resolve ( self , path ) : <EOL> """<STR_LIT>""" <EOL> return path <EOL> def is_reserved ( self , _ ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def make_uri ( self , path ) : <EOL> """<STR_LIT>""" <EOL> return path <EOL> _artifactory_flavour = _ArtifactoryFlavour ( ) <EOL> ArtifactoryFileStat = collections . namedtuple ( <EOL> '<STR_LIT>' , <EOL> [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT:size>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ] ) <EOL> class _ArtifactoryAccessor ( pathlib . _Accessor ) : <EOL> """<STR_LIT>""" <EOL> def rest_get ( self , url , params = None , headers = None , auth = None , verify = True , cert = None ) : <EOL> """<STR_LIT>""" <EOL> res = requests . get ( url , params = params , headers = headers , auth = auth , verify = verify , <EOL> cert = cert ) <EOL> return res . text , res . status_code <EOL> def rest_put ( self , url , params = None , headers = None , auth = None , verify = True , cert = None ) : <EOL> """<STR_LIT>""" <EOL> res = requests . put ( url , params = params , headers = headers , auth = auth , verify = verify , <EOL> cert = cert ) <EOL> return res . text , res . status_code <EOL> def rest_post ( self , url , params = None , headers = None , auth = None , verify = True , cert = None ) : <EOL> """<STR_LIT>""" <EOL> res = requests . post ( url , params = params , headers = headers , auth = auth , verify = verify , <EOL> cert = cert ) <EOL> return res . text , res . status_code <EOL> def rest_del ( self , url , params = None , auth = None , verify = True , cert = None ) : <EOL> """<STR_LIT>""" <EOL> res = requests . delete ( url , params = params , auth = auth , verify = verify , cert = cert ) <EOL> return res . text , res . status_code <EOL> def rest_put_stream ( self , url , stream , headers = None , auth = None , verify = True , cert = None ) : <EOL> """<STR_LIT>""" <EOL> res = requests . put ( url , headers = headers , auth = auth , data = stream , verify = verify , cert = cert ) <EOL> return res . text , res . status_code <EOL> def rest_get_stream ( self , url , auth = None , verify = True , cert = None ) : <EOL> """<STR_LIT>""" <EOL> res = requests . get ( url , auth = auth , stream = True , verify = verify , cert = cert ) <EOL> return res . raw , res . status_code <EOL> def get_stat_json ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> url = '<STR_LIT:/>' . join ( [ pathobj . drive , <EOL> '<STR_LIT>' , <EOL> str ( pathobj . relative_to ( pathobj . drive ) ) . strip ( '<STR_LIT:/>' ) ] ) <EOL> text , code = self . rest_get ( url , auth = pathobj . auth , verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if code == <NUM_LIT> and "<STR_LIT>" in text : <EOL> raise OSError ( <NUM_LIT:2> , "<STR_LIT>" % url ) <EOL> if code != <NUM_LIT:200> : <EOL> raise RuntimeError ( text ) <EOL> return json . loads ( text ) <EOL> def stat ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> jsn = self . get_stat_json ( pathobj ) <EOL> is_dir = False <EOL> if '<STR_LIT:size>' not in jsn : <EOL> is_dir = True <EOL> children = None <EOL> if '<STR_LIT>' in jsn : <EOL> children = [ child [ '<STR_LIT>' ] [ <NUM_LIT:1> : ] for child in jsn [ '<STR_LIT>' ] ] <EOL> stat = ArtifactoryFileStat ( <EOL> ctime = dateutil . parser . parse ( jsn [ '<STR_LIT>' ] ) , <EOL> mtime = dateutil . parser . parse ( jsn [ '<STR_LIT>' ] ) , <EOL> created_by = jsn . get ( '<STR_LIT>' , None ) , <EOL> modified_by = jsn . get ( '<STR_LIT>' , None ) , <EOL> mime_type = jsn . get ( '<STR_LIT>' , None ) , <EOL> size = int ( jsn . get ( '<STR_LIT:size>' , '<STR_LIT:0>' ) ) , <EOL> sha1 = jsn . get ( '<STR_LIT>' , { '<STR_LIT>' : None } ) [ '<STR_LIT>' ] , <EOL> md5 = jsn . get ( '<STR_LIT>' , { '<STR_LIT>' : None } ) [ '<STR_LIT>' ] , <EOL> is_dir = is_dir , <EOL> children = children ) <EOL> return stat <EOL> def is_dir ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> stat = self . stat ( pathobj ) <EOL> return stat . is_dir <EOL> except OSError as exc : <EOL> if exc . errno != errno . ENOENT : <EOL> raise <EOL> return False <EOL> def is_file ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> stat = self . stat ( pathobj ) <EOL> return not stat . is_dir <EOL> except OSError as exc : <EOL> if exc . errno != errno . ENOENT : <EOL> raise <EOL> return False <EOL> def listdir ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> stat = self . stat ( pathobj ) <EOL> if not stat . is_dir : <EOL> raise OSError ( <NUM_LIT:20> , "<STR_LIT>" % str ( pathobj ) ) <EOL> return stat . children <EOL> def mkdir ( self , pathobj , _ ) : <EOL> """<STR_LIT>""" <EOL> if not pathobj . drive or not pathobj . root : <EOL> raise RuntimeError ( "<STR_LIT>" % str ( pathobj ) ) <EOL> if pathobj . exists ( ) : <EOL> raise OSError ( <NUM_LIT> , "<STR_LIT>" % str ( pathobj ) ) <EOL> url = str ( pathobj ) + '<STR_LIT:/>' <EOL> text , code = self . rest_put ( url , auth = pathobj . auth , verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if not code == <NUM_LIT> : <EOL> raise RuntimeError ( "<STR_LIT>" % ( text , code ) ) <EOL> def rmdir ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> stat = self . stat ( pathobj ) <EOL> if not stat . is_dir : <EOL> raise OSError ( <NUM_LIT:20> , "<STR_LIT>" % str ( pathobj ) ) <EOL> url = str ( pathobj ) + '<STR_LIT:/>' <EOL> text , code = self . rest_del ( url , auth = pathobj . auth , verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if code not in [ <NUM_LIT:200> , <NUM_LIT> , <NUM_LIT> ] : <EOL> raise RuntimeError ( "<STR_LIT>" % text ) <EOL> def unlink ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> stat = self . stat ( pathobj ) <EOL> if stat . is_dir : <EOL> raise OSError ( <NUM_LIT:1> , "<STR_LIT>" % str ( pathobj ) ) <EOL> url = str ( pathobj ) <EOL> text , code = self . rest_del ( url , auth = pathobj . auth , verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if code not in [ <NUM_LIT:200> , <NUM_LIT> , <NUM_LIT> ] : <EOL> raise RuntimeError ( "<STR_LIT>" % ( code , text ) ) <EOL> def touch ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> if not pathobj . drive or not pathobj . root : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> if pathobj . exists ( ) : <EOL> return <EOL> url = str ( pathobj ) <EOL> text , code = self . rest_put ( url , auth = pathobj . auth , verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if not code == <NUM_LIT> : <EOL> raise RuntimeError ( "<STR_LIT>" % ( text , code ) ) <EOL> def owner ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> stat = self . stat ( pathobj ) <EOL> if not stat . is_dir : <EOL> return stat . modified_by <EOL> else : <EOL> return '<STR_LIT>' <EOL> def creator ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> stat = self . stat ( pathobj ) <EOL> if not stat . is_dir : <EOL> return stat . created_by <EOL> else : <EOL> return '<STR_LIT>' <EOL> def open ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> url = str ( pathobj ) <EOL> raw , code = self . rest_get_stream ( url , auth = pathobj . auth , verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if not code == <NUM_LIT:200> : <EOL> raise RuntimeError ( "<STR_LIT>" % code ) <EOL> return raw <EOL> def deploy ( self , pathobj , fobj , md5 = None , sha1 = None , parameters = None ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( fobj , urllib3 . response . HTTPResponse ) : <EOL> fobj = HTTPResponseWrapper ( fobj ) <EOL> url = str ( pathobj ) <EOL> if parameters : <EOL> url += "<STR_LIT>" % encode_matrix_parameters ( parameters ) <EOL> headers = { } <EOL> if md5 : <EOL> headers [ '<STR_LIT>' ] = md5 <EOL> if sha1 : <EOL> headers [ '<STR_LIT>' ] = sha1 <EOL> text , code = self . rest_put_stream ( url , <EOL> fobj , <EOL> headers = headers , <EOL> auth = pathobj . auth , <EOL> verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if code not in [ <NUM_LIT:200> , <NUM_LIT> ] : <EOL> raise RuntimeError ( "<STR_LIT:%s>" % text ) <EOL> def copy ( self , src , dst , suppress_layouts = False ) : <EOL> """<STR_LIT>""" <EOL> url = '<STR_LIT:/>' . join ( [ src . drive , <EOL> '<STR_LIT>' , <EOL> str ( src . relative_to ( src . drive ) ) . rstrip ( '<STR_LIT:/>' ) ] ) <EOL> params = { '<STR_LIT:to>' : str ( dst . relative_to ( dst . drive ) ) . rstrip ( '<STR_LIT:/>' ) , <EOL> '<STR_LIT>' : int ( suppress_layouts ) } <EOL> text , code = self . rest_post ( url , <EOL> params = params , <EOL> auth = src . auth , <EOL> verify = src . verify , <EOL> cert = src . cert ) <EOL> if code not in [ <NUM_LIT:200> , <NUM_LIT> ] : <EOL> raise RuntimeError ( "<STR_LIT:%s>" % text ) <EOL> def move ( self , src , dst ) : <EOL> """<STR_LIT>""" <EOL> url = '<STR_LIT:/>' . join ( [ src . drive , <EOL> '<STR_LIT>' , <EOL> str ( src . relative_to ( src . drive ) ) . rstrip ( '<STR_LIT:/>' ) ] ) <EOL> params = { '<STR_LIT:to>' : str ( dst . relative_to ( dst . drive ) ) . rstrip ( '<STR_LIT:/>' ) } <EOL> text , code = self . rest_post ( url , <EOL> params = params , <EOL> auth = src . auth , <EOL> verify = src . verify , <EOL> cert = src . cert ) <EOL> if code not in [ <NUM_LIT:200> , <NUM_LIT> ] : <EOL> raise RuntimeError ( "<STR_LIT:%s>" % text ) <EOL> def get_properties ( self , pathobj ) : <EOL> """<STR_LIT>""" <EOL> url = '<STR_LIT:/>' . join ( [ pathobj . drive , <EOL> '<STR_LIT>' , <EOL> str ( pathobj . relative_to ( pathobj . drive ) ) . strip ( '<STR_LIT:/>' ) ] ) <EOL> params = '<STR_LIT>' <EOL> text , code = self . rest_get ( url , <EOL> params = params , <EOL> auth = pathobj . auth , <EOL> verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if code == <NUM_LIT> and "<STR_LIT>" in text : <EOL> raise OSError ( <NUM_LIT:2> , "<STR_LIT>" % url ) <EOL> if code == <NUM_LIT> and "<STR_LIT>" in text : <EOL> return { } <EOL> if code != <NUM_LIT:200> : <EOL> raise RuntimeError ( text ) <EOL> return json . loads ( text ) [ '<STR_LIT>' ] <EOL> def set_properties ( self , pathobj , props , recursive ) : <EOL> """<STR_LIT>""" <EOL> url = '<STR_LIT:/>' . join ( [ pathobj . drive , <EOL> '<STR_LIT>' , <EOL> str ( pathobj . relative_to ( pathobj . drive ) ) . strip ( '<STR_LIT:/>' ) ] ) <EOL> params = { '<STR_LIT>' : encode_properties ( props ) } <EOL> if not recursive : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:0>' <EOL> text , code = self . rest_put ( url , <EOL> params = params , <EOL> auth = pathobj . auth , <EOL> verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if code == <NUM_LIT> and "<STR_LIT>" in text : <EOL> raise OSError ( <NUM_LIT:2> , "<STR_LIT>" % url ) <EOL> if code != <NUM_LIT> : <EOL> raise RuntimeError ( text ) <EOL> def del_properties ( self , pathobj , props , recursive ) : <EOL> """<STR_LIT>""" <EOL> if isinstance ( props , str ) : <EOL> props = ( props , ) <EOL> url = '<STR_LIT:/>' . join ( [ pathobj . drive , <EOL> '<STR_LIT>' , <EOL> str ( pathobj . relative_to ( pathobj . drive ) ) . strip ( '<STR_LIT:/>' ) ] ) <EOL> params = { '<STR_LIT>' : '<STR_LIT:U+002C>' . join ( sorted ( props ) ) } <EOL> if not recursive : <EOL> params [ '<STR_LIT>' ] = '<STR_LIT:0>' <EOL> text , code = self . rest_del ( url , <EOL> params = params , <EOL> auth = pathobj . auth , <EOL> verify = pathobj . verify , <EOL> cert = pathobj . cert ) <EOL> if code == <NUM_LIT> and "<STR_LIT>" in text : <EOL> raise OSError ( <NUM_LIT:2> , "<STR_LIT>" % url ) <EOL> if code != <NUM_LIT> : <EOL> raise RuntimeError ( text ) <EOL> _artifactory_accessor = _ArtifactoryAccessor ( ) <EOL> class ArtifactoryProAccessor ( _ArtifactoryAccessor ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class ArtifactoryOpensourceAccessor ( _ArtifactoryAccessor ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> class PureArtifactoryPath ( pathlib . PurePath ) : <EOL> """<STR_LIT>""" <EOL> _flavour = _artifactory_flavour <EOL> __slots__ = ( ) <EOL> class _FakePathTemplate ( object ) : <EOL> def __init__ ( self , accessor ) : <EOL> self . _accessor = accessor <EOL> class ArtifactoryPath ( pathlib . Path , PureArtifactoryPath ) : <EOL> """<STR_LIT>""" <EOL> __slots__ = ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def __new__ ( cls , * args , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> obj = pathlib . Path . __new__ ( cls , * args , ** kwargs ) <EOL> cfg_entry = get_global_config_entry ( obj . drive ) <EOL> obj . auth = kwargs . get ( '<STR_LIT>' , None ) <EOL> obj . cert = kwargs . get ( '<STR_LIT>' , None ) <EOL> if obj . auth is None and cfg_entry : <EOL> obj . auth = ( cfg_entry [ '<STR_LIT:username>' ] , cfg_entry [ '<STR_LIT:password>' ] ) <EOL> if obj . cert is None and cfg_entry : <EOL> obj . cert = cfg_entry [ '<STR_LIT>' ] <EOL> if '<STR_LIT>' in kwargs : <EOL> obj . verify = kwargs . get ( '<STR_LIT>' ) <EOL> elif cfg_entry : <EOL> obj . verify = cfg_entry [ '<STR_LIT>' ] <EOL> else : <EOL> obj . verify = True <EOL> return obj <EOL> def _init ( self , * args , ** kwargs ) : <EOL> if not '<STR_LIT>' in kwargs : <EOL> kwargs [ '<STR_LIT>' ] = _FakePathTemplate ( _artifactory_accessor ) <EOL> super ( ArtifactoryPath , self ) . _init ( * args , ** kwargs ) <EOL> @ property <EOL> def parent ( self ) : <EOL> """<STR_LIT>""" <EOL> obj = super ( ArtifactoryPath , self ) . parent <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> def with_name ( self , name ) : <EOL> """<STR_LIT>""" <EOL> obj = super ( ArtifactoryPath , self ) . with_name ( name ) <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> def with_suffix ( self , suffix ) : <EOL> """<STR_LIT>""" <EOL> obj = super ( ArtifactoryPath , self ) . with_suffix ( suffix ) <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> def relative_to ( self , * other ) : <EOL> """<STR_LIT>""" <EOL> obj = super ( ArtifactoryPath , self ) . relative_to ( * other ) <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> def joinpath ( self , * args ) : <EOL> """<STR_LIT>""" <EOL> obj = super ( ArtifactoryPath , self ) . joinpath ( * args ) <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> def __truediv__ ( self , key ) : <EOL> """<STR_LIT>""" <EOL> obj = super ( ArtifactoryPath , self ) . __truediv__ ( key ) <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> def __rtruediv__ ( self , key ) : <EOL> """<STR_LIT>""" <EOL> obj = super ( ArtifactoryPath , self ) . __truediv__ ( key ) <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> if sys . version_info < ( <NUM_LIT:3> , ) : <EOL> __div__ = __truediv__ <EOL> __rdiv__ = __rtruediv__ <EOL> def _make_child ( self , args ) : <EOL> obj = super ( ArtifactoryPath , self ) . _make_child ( args ) <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> def _make_child_relpath ( self , args ) : <EOL> obj = super ( ArtifactoryPath , self ) . _make_child_relpath ( args ) <EOL> obj . auth = self . auth <EOL> obj . verify = self . verify <EOL> obj . cert = self . cert <EOL> return obj <EOL> def __iter__ ( self ) : <EOL> """<STR_LIT>""" <EOL> for name in self . _accessor . listdir ( self ) : <EOL> if name in [ '<STR_LIT:.>' , '<STR_LIT:..>' ] : <EOL> continue <EOL> yield self . _make_child_relpath ( name ) <EOL> def open ( self , mode = '<STR_LIT:r>' , buffering = - <NUM_LIT:1> , encoding = None , <EOL> errors = None , newline = None ) : <EOL> """<STR_LIT>""" <EOL> if mode != '<STR_LIT:r>' or buffering != - <NUM_LIT:1> or encoding or errors or newline : <EOL> raise NotImplementedError ( '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> return self . _accessor . open ( self ) <EOL> def owner ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _accessor . owner ( self ) <EOL> def creator ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _accessor . creator ( self ) <EOL> def is_dir ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _accessor . is_dir ( self ) <EOL> def is_file ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _accessor . is_file ( self ) <EOL> def is_symlink ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def is_socket ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def is_fifo ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def is_block_device ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def is_char_device ( self ) : <EOL> """<STR_LIT>""" <EOL> return False <EOL> def touch ( self , mode = <NUM_LIT> , exist_ok = True ) : <EOL> """<STR_LIT>""" <EOL> if self . exists ( ) and not exist_ok : <EOL> raise OSError ( <NUM_LIT> , "<STR_LIT>" , str ( self ) ) <EOL> self . _accessor . touch ( self ) <EOL> def chmod ( self , mode ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def lchmod ( self , mode ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def symlink_to ( self , target , target_is_directory = False ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def deploy ( self , fobj , md5 = None , sha1 = None , parameters = { } ) : <EOL> """<STR_LIT>""" <EOL> return self . _accessor . deploy ( self , fobj , md5 , sha1 , parameters ) <EOL> def deploy_file ( self , <EOL> file_name , <EOL> calc_md5 = True , <EOL> calc_sha1 = True , <EOL> parameters = { } ) : <EOL> """<STR_LIT>""" <EOL> if calc_md5 : <EOL> md5 = md5sum ( file_name ) <EOL> if calc_sha1 : <EOL> sha1 = sha1sum ( file_name ) <EOL> target = self <EOL> if self . is_dir ( ) : <EOL> target = self / pathlib . Path ( file_name ) . name <EOL> with open ( file_name , '<STR_LIT:rb>' ) as fobj : <EOL> target . deploy ( fobj , md5 , sha1 , parameters ) <EOL> def deploy_deb ( self , <EOL> file_name , <EOL> distribution , <EOL> component , <EOL> architecture , <EOL> parameters = { } ) : <EOL> """<STR_LIT>""" <EOL> params = { <EOL> '<STR_LIT>' : distribution , <EOL> '<STR_LIT>' : component , <EOL> '<STR_LIT>' : architecture <EOL> } <EOL> params . update ( parameters ) <EOL> self . deploy_file ( file_name , parameters = params ) <EOL> def copy ( self , dst , suppress_layouts = False ) : <EOL> """<STR_LIT>""" <EOL> if self . drive == dst . drive : <EOL> self . _accessor . copy ( self , dst , suppress_layouts = suppress_layouts ) <EOL> else : <EOL> with self . open ( ) as fobj : <EOL> dst . deploy ( fobj ) <EOL> def move ( self , dst ) : <EOL> """<STR_LIT>""" <EOL> if self . drive != dst . drive : <EOL> raise NotImplementedError ( <EOL> "<STR_LIT>" ) <EOL> self . _accessor . move ( self , dst ) <EOL> @ property <EOL> def properties ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _accessor . get_properties ( self ) <EOL> @ properties . setter <EOL> def properties ( self , properties ) : <EOL> self . del_properties ( self . properties , recursive = False ) <EOL> self . set_properties ( properties , recursive = False ) <EOL> @ properties . deleter <EOL> def properties ( self ) : <EOL> self . del_properties ( self . properties , recursive = False ) <EOL> def set_properties ( self , properties , recursive = True ) : <EOL> """<STR_LIT>""" <EOL> if not properties : <EOL> return <EOL> return self . _accessor . set_properties ( self , properties , recursive ) <EOL> def del_properties ( self , properties , recursive = None ) : <EOL> """<STR_LIT>""" <EOL> return self . _accessor . del_properties ( self , properties , recursive ) <EOL> def walk ( pathobj , topdown = True ) : <EOL> """<STR_LIT>""" <EOL> dirs , nondirs = [ ] , [ ] <EOL> for child in pathobj : <EOL> relpath = str ( child . relative_to ( str ( pathobj ) ) ) <EOL> if relpath . startswith ( '<STR_LIT:/>' ) : <EOL> relpath = relpath [ <NUM_LIT:1> : ] <EOL> if relpath . endswith ( '<STR_LIT:/>' ) : <EOL> relpath = relpath [ : - <NUM_LIT:1> ] <EOL> if child . is_dir ( ) : <EOL> dirs . append ( relpath ) <EOL> else : <EOL> nondirs . append ( relpath ) <EOL> if topdown : <EOL> yield pathobj , dirs , nondirs <EOL> for dir in dirs : <EOL> for result in walk ( pathobj / dir ) : <EOL> yield result <EOL> if not topdown : <EOL> yield pathobj , dirs , nondirs </s>
