8686MISSING_SSH_KEY_ERROR = "Attempt to use file transfer action requiring an SSH key without specifying a ssh_key."
8787
8888
89- class FileActionMapper ( object ) :
89+ class FileActionMapper :
9090 """
9191 Objects of this class define how paths are mapped to actions.
9292
@@ -263,7 +263,7 @@ def __inject_url(self, action, file_type):
263263 if "?" not in url_base :
264264 url_base = "%s?" % url_base
265265 # TODO: URL encode path.
266- url = "%s &path=%s &file_type=%s" % (url_base , action .path , file_type )
266+ url = "{} &path={} &file_type={}" . format (url_base , action .path , file_type )
267267 action .url = url
268268
269269 def __inject_ssh_properties (self , action ):
@@ -281,7 +281,7 @@ def __inject_ssh_properties(self, action):
281281UNSET_ACTION_KWD = "__UNSET__"
282282
283283
284- class BaseAction ( object ) :
284+ class BaseAction :
285285 whole_directory_transfer_supported = False
286286 action_spec : Dict [str , Any ] = {}
287287 action_type : str
@@ -341,7 +341,7 @@ def __str__(self):
341341 first = False
342342 else :
343343 attribute_str += ","
344- attribute_str += "%s=%s" % (key , value )
344+ attribute_str += "{}={}" . format (key , value )
345345 return "FileAction[%s]" % attribute_str
346346
347347
@@ -376,7 +376,7 @@ class RewriteAction(BaseAction):
376376 staging = STAGING_ACTION_NONE
377377
378378 def __init__ (self , source , file_lister = None , source_directory = None , destination_directory = None ):
379- super (RewriteAction , self ).__init__ (source , file_lister = file_lister )
379+ super ().__init__ (source , file_lister = file_lister )
380380 self .source_directory = source_directory
381381 self .destination_directory = destination_directory
382382
@@ -453,7 +453,7 @@ class RemoteTransferAction(BaseAction):
453453 staging = STAGING_ACTION_REMOTE
454454
455455 def __init__ (self , source , file_lister = None , url = None ):
456- super (RemoteTransferAction , self ).__init__ (source , file_lister = file_lister )
456+ super ().__init__ (source , file_lister = file_lister )
457457 self .url = url
458458
459459 def to_dict (self ):
@@ -511,7 +511,7 @@ class PubkeyAuthenticatedTransferAction(BaseAction):
511511
512512 def __init__ (self , source , file_lister = None , ssh_user = UNSET_ACTION_KWD ,
513513 ssh_host = UNSET_ACTION_KWD , ssh_port = UNSET_ACTION_KWD , ssh_key = UNSET_ACTION_KWD ):
514- super (PubkeyAuthenticatedTransferAction , self ).__init__ (source , file_lister = file_lister )
514+ super ().__init__ (source , file_lister = file_lister )
515515 self .ssh_user = ssh_user
516516 self .ssh_host = ssh_host
517517 self .ssh_port = ssh_port
@@ -587,7 +587,7 @@ def write_from_path(self, pulsar_path):
587587 self .ssh_port , key_file )
588588
589589
590- class MessageAction ( object ) :
590+ class MessageAction :
591591 """ Sort of pseudo action describing "files" store in memory and
592592 transferred via message (HTTP, Python-call, MQ, etc...)
593593 """
@@ -649,7 +649,7 @@ def from_dict(action_dict):
649649 return target_class .from_dict (action_dict )
650650
651651
652- class BasePathMapper ( object ) :
652+ class BasePathMapper :
653653 match_type : str
654654
655655 def __init__ (self , config ):
@@ -697,7 +697,7 @@ class PathTypeOnlyMapper(BasePathMapper):
697697 match_type = 'path_type_only'
698698
699699 def __init__ (self , config ):
700- super (PathTypeOnlyMapper , self ).__init__ (config )
700+ super ().__init__ (config )
701701
702702 def _path_matches (self , path ):
703703 return True
@@ -710,14 +710,14 @@ class PrefixPathMapper(BasePathMapper):
710710 match_type = 'prefix'
711711
712712 def __init__ (self , config ):
713- super (PrefixPathMapper , self ).__init__ (config )
713+ super ().__init__ (config )
714714 self .prefix_path = abspath (config ['path' ])
715715
716716 def _path_matches (self , path ):
717717 return path is not None and path .startswith (self .prefix_path )
718718
719719 def to_pattern (self ):
720- pattern_str = r"(%s%s [^\s,\"\']+)" % (escape (self .prefix_path ), escape (sep ))
720+ pattern_str = r"({}{} [^\s,\"\']+)" . format (escape (self .prefix_path ), escape (sep ))
721721 return compile (pattern_str )
722722
723723 def to_dict (self ):
@@ -728,7 +728,7 @@ class GlobPathMapper(BasePathMapper):
728728 match_type = 'glob'
729729
730730 def __init__ (self , config ):
731- super (GlobPathMapper , self ).__init__ (config )
731+ super ().__init__ (config )
732732 self .glob_path = config ['path' ]
733733
734734 def _path_matches (self , path ):
@@ -745,7 +745,7 @@ class RegexPathMapper(BasePathMapper):
745745 match_type = 'regex'
746746
747747 def __init__ (self , config ):
748- super (RegexPathMapper , self ).__init__ (config )
748+ super ().__init__ (config )
749749 self .pattern_raw = config ['path' ]
750750 self .pattern = compile (self .pattern_raw )
751751
@@ -775,7 +775,7 @@ def _mappper_from_dict(mapper_dict):
775775 return MAPPER_CLASS_DICT [map_type ](mapper_dict )
776776
777777
778- class FileLister ( object ) :
778+ class FileLister :
779779
780780 def __init__ (self , config ):
781781 self .depth = int (config .get ("depth" , "0" ))
@@ -793,7 +793,7 @@ def unstructured_map(self, path):
793793 while depth > 0 :
794794 path = dirname (path )
795795 depth -= 1
796- return dict ([( join (path , f ), f ) for f in directory_files (path )])
796+ return { join (path , f ): f for f in directory_files (path )}
797797
798798
799799DEFAULT_FILE_LISTER = FileLister (dict (depth = 0 ))
@@ -809,7 +809,7 @@ def unstructured_map(self, path):
809809 RsyncTransferAction ,
810810 ScpTransferAction ,
811811]
812- actions = dict ([( clazz .action_type , clazz ) for clazz in ACTION_CLASSES ])
812+ actions = { clazz .action_type : clazz for clazz in ACTION_CLASSES }
813813
814814
815815__all__ = (
0 commit comments