MCPcopy
hub / github.com/aws/aws-cli / format

Method format

awscli/customizations/s3/fileformat.py:17–62  ·  view source on GitHub ↗

This function formats the source and destination path to the proper form for a file generator. Note that a file is designated as an s3 file if it begins with s3:// :param src: The path of the source :type src: string :param dest: The path of the des

(self, src, dest, parameters)

Source from the content-addressed store, hash-verified

15
16class FileFormat:
17 def format(self, src, dest, parameters):
18 """
19 This function formats the source and destination
20 path to the proper form for a file generator.
21
22 Note that a file is designated as an s3 file if it begins with s3://
23
24 :param src: The path of the source
25 :type src: string
26 :param dest: The path of the dest
27 :type dest: string
28 :param parameters: A dictionary that will be formed when the arguments
29 of the command line have been parsed. For this
30 function the dictionary should have the key 'dir_op'
31 which is a boolean value that is true when
32 the operation is being performed on a local directory/
33 all objects under a common prefix in s3 or false when
34 it is on a single file/object.
35
36 :returns: A dictionary that will be passed to a file generator.
37 The dictionary contains the keys src, dest, dir_op, and
38 use_src_name. src is a dictionary containing the source path
39 and whether its located locally or in s3. dest is a dictionary
40 containing the destination path and whether its located
41 locally or in s3.
42 """
43 src_type, src_path = self.identify_type(src)
44 dest_type, dest_path = self.identify_type(dest)
45 format_table = {'s3': self.s3_format, 'local': self.local_format}
46 # :var dir_op: True when the operation being performed is on a
47 # directory/objects under a common prefix or false when it
48 # is a single file
49 dir_op = parameters['dir_op']
50 src_path = format_table[src_type](src_path, dir_op)[0]
51 # :var use_src_name: True when the destination file/object will take on
52 # the name of the source file/object. False when it
53 # will take on the name the user specified in the
54 # command line.
55 dest_path, use_src_name = format_table[dest_type](dest_path, dir_op)
56 files = {
57 'src': {'path': src_path, 'type': src_type},
58 'dest': {'path': dest_path, 'type': dest_type},
59 'dir_op': dir_op,
60 'use_src_name': use_src_name,
61 }
62 return files
63
64 def local_format(self, path, dir_op):
65 """

Calls 1

identify_typeMethod · 0.95