77from ..lib import FrameioUploader , FrameioDownloader
88
99class Asset (Service ):
10+ def _build_asset_info (self , filepath ):
11+ full_path = os .path .abspath (filepath )
12+
13+ file_info = {
14+ "filepath" : full_path ,
15+ "filename" : os .path .basename (full_path ),
16+ "filesize" : os .path .getsize (full_path ),
17+ "mimetype" : mimetypes .guess_type (full_path )[0 ]
18+ }
19+
20+ return file_info
21+
1022 def get (self , asset_id ):
1123 """
1224 Get an asset by id.
@@ -123,7 +135,7 @@ def copy(self, destination_folder_id, **kwargs):
123135 endpoint = '/assets/{}/copy' .format (destination_folder_id )
124136 return self .client ._api_call ('post' , endpoint , kwargs )
125137
126- def bulk_copy (self , destination_folder_id , asset_list = [] , copy_comments = False ):
138+ def bulk_copy (self , destination_folder_id , asset_list , copy_comments = False ):
127139 """Bulk copy assets
128140
129141 :Args:
@@ -137,8 +149,7 @@ def bulk_copy(self, destination_folder_id, asset_list=[], copy_comments=False):
137149 "7ee008c5-49a2-f8b5-997d-8b64de153c30"], copy_comments=True)
138150 """
139151
140- payload = {"batch" : []}
141- new_list = list ()
152+ payload = {"batch" : list ()}
142153
143154 if copy_comments :
144155 payload ['copy_comments' ] = "all"
@@ -183,18 +194,6 @@ def _upload(self, asset, file):
183194 # if not os.path.exists(folderpath):
184195 # sys.exit("Folder doesn't exist, exiting...")
185196
186- def build_asset_info (self , filepath ):
187- full_path = os .path .abspath (filepath )
188-
189- file_info = {
190- "filepath" : full_path ,
191- "filename" : os .path .basename (full_path ),
192- "filesize" : os .path .getsize (full_path ),
193- "mimetype" : mimetypes .guess_type (full_path )[0 ]
194- }
195-
196- return file_info
197-
198197 def upload (self , destination_id , filepath , asset = None ):
199198 """
200199 Upload a file. The method will exit once the file is downloaded.
@@ -220,7 +219,7 @@ def upload(self, destination_id, filepath, asset=None):
220219 # Then try to grab it as a project
221220 folder_id = Project (self .client ).get_project (destination_id )['root_asset_id' ]
222221 finally :
223- file_info = self .build_asset_info (filepath )
222+ file_info = self ._build_asset_info (filepath )
224223
225224 if not asset :
226225 try :
0 commit comments