copy files. local->local, S3->local, local->S3 (S3->S3 not supported) Args: fromPath (str): local or S3 URL toPath (str): local or S3 URL
(self,fromPath,toPath)
| 236 | |
| 237 | |
| 238 | def copy(self,fromPath,toPath): |
| 239 | """copy files. local->local, S3->local, local->S3 (S3->S3 not supported) |
| 240 | |
| 241 | Args: |
| 242 | fromPath (str): local or S3 URL |
| 243 | toPath (str): local or S3 URL |
| 244 | """ |
| 245 | if fromPath.startswith("s3n://") or fromPath.startswith("s3://"): |
| 246 | fromS3 = True |
| 247 | else: |
| 248 | fromS3 = False |
| 249 | if toPath.startswith("s3n://") or toPath.startswith("s3://"): |
| 250 | toS3 = True |
| 251 | else: |
| 252 | toS3 = False |
| 253 | if not fromS3 and not toS3: |
| 254 | self.copy_local(fromPath,toPath) |
| 255 | elif not fromS3 and toS3: |
| 256 | self.upload_s3(fromPath,toPath) |
| 257 | elif fromS3 and not toS3: |
| 258 | if os.path.isdir(toPath): |
| 259 | self.download_s3(fromPath,toPath) |
| 260 | else: |
| 261 | logger.error("Local destination folder must exist :%s",toPath) |
| 262 | else: |
| 263 | logger.warn("can't copy from s3 to s3") |
| 264 | |
| 265 | |
| 266 |
no test coverage detected