<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def cp(self, local_path, target_path, acl='public-read', del_after_upload=False, overwrite=True, invalidate=False):
 """ Copy a file or folder from local to s3. Parameters local_path : string Path to file or folder. Or if you want to copy only the contents of folder, add /* at the end of folder name target_path : string Target path on S3 bucket. acl : string, optional File permissions on S3. Default is public-read options: - private: Owner gets FULL_CONTROL. No one else has any access rights. - public-read: Owners gets FULL_CONTROL and the anonymous principal is granted READ access. - public-read-write: Owner gets FULL_CONTROL and the anonymous principal is granted READ and WRITE access. - authenticated-read: Owner gets FULL_CONTROL and any principal authenticated as a registered Amazon S3 user is granted READ access del_after_upload : boolean, optional delete the local file after uploading. This is effectively like moving the file. You can use s3utils.mv instead of s3utils.cp to move files from local to S3. It basically sets this flag to True. default = False overwrite : boolean, optional overwrites files on S3 if set to True. Default is True invalidate : boolean, optional invalidates the CDN (a.k.a Distribution) cache if the file already exists on S3 default = False Note that invalidation might take up to 15 minutes to take place. It is easier and faster to use cache buster to grab lastest version of your file on CDN than invalidation. **Returns** Nothing on success but it will return what went wrong if something fails. Examples -------- copying /path/to/myfolder/test2.txt to test/myfolder/test2.txt copying /path/to/myfolder/test.txt to test/myfolder/test.txt copying /path/to/myfolder/hoho/photo.JPG to test/myfolder/hoho/photo.JPG copying /path/to/myfolder/hoho/haha/ff to test/myfolder/hoho/haha/ff ERROR:root:test3.txt already exist. Not overwriting. copying /path/to/myfolder/test2.txt to test/myfolder/test2.txt copying /path/to/myfolder/test.txt to test/myfolder/test.txt copying /path/to/myfolder/hoho/photo.JPG to test/myfolder/hoho/photo.JPG copying /path/to/myfolder/hoho/haha/ff to test/myfolder/hoho/haha/ff ERROR:root:trying to upload to s3 but file doesn't exist: /tmp/does_not_exist """

        result = None
        if overwrite:
            list_of_files = []
        else:
            list_of_files = self.ls(folder=target_path, begin_from_file="", num=-1, get_grants=False, all_grant_data=False)

        # copying the contents of the folder and not folder itself
        if local_path.endswith("/*"):
            local_path = local_path[:-2]
            target_path = re.sub(r"^/|/$", "", target_path)  # Amazon S3 doesn't let the name to begin with /
        # copying folder too
        else:
            local_base_name = os.path.basename(local_path)

            local_path = re.sub(r"/$", "", local_path)
            target_path = re.sub(r"^/", "", target_path)

            if not target_path.endswith(local_base_name):
                target_path = os.path.join(target_path, local_base_name)

        if os.path.exists(local_path):

            result = self.__find_files_and_copy(local_path, target_path, acl, del_after_upload, overwrite, invalidate, list_of_files)

        else:
            result = {'file_does_not_exist': local_path}
            logger.error("trying to upload to s3 but file doesn't exist: %s" % local_path)

        return result