original_docstring: 
      Download the contents of a folder directory
      Args:
          bucket_name: the name of the s3 bucket
          s3_folder: the folder path in the s3 bucket
          local_dir: a relative or absolute directory path in the local file system
      
docstring: Download the contents of a folder directory
docstring_tokens: Download the contents of a folder directory
code: def download_s3_folder(s3_folder, bucket_name, dir=None):
      """
      Download the contents of a folder directory
      Args:
          bucket_name: the name of the s3 bucket
          s3_folder: the folder path in the s3 bucket
          local_dir: a relative or absolute directory path in the local file system
      """
      s3 = aws_utils.get_boto3_resource('s3') #boto3.resource('s3')
      bucketFolder = s3.Bucket(bucket_name)
      for obj in bucketFolder.objects.filter(Prefix = s3_folder):
          windowspath = obj.key.split(s3_folder)[1].replace('/', '\\')
          target = dir + windowspath
          # else os.path.join(local_dir, os.path.basename(obj.key))
          print(target)
          if not os.path.exists(os.path.dirname(target)):
              os.makedirs(os.path.dirname(target))
          print(obj.key)
          try:
              bucketFolder.download_file(obj.key, target)
          except botocore.exceptions.ClientError as e:
              #traceback.print_exc()
              if e.response['Error']['Code'] == "404":
                  print("The object does not exist.")
                  raise ValueError("The object does not exist.")
              else:
                  msg = 'AWS Error : '
                  print( msg + str(e))
                  raise ValueError(msg)
code_tokens: def download_s3_folder ( s3_folder , bucket_name , dir = None ) : s3 = aws_utils . get_boto3_resource ( 's3' ) bucketFolder = s3 . Bucket ( bucket_name ) for obj in bucketFolder . objects . filter ( Prefix = s3_folder ) : windowspath = obj . key . split ( s3_folder ) [ 1 ] . replace ( '/' , '\\' ) target = dir + windowspath print ( target ) if not os . path . exists ( os . path . dirname ( target ) ) : os . makedirs ( os . path . dirname ( target ) ) print ( obj . key ) try : bucketFolder . download_file ( obj . key , target ) except botocore . exceptions . ClientError as e : if e . response [ 'Error' ] [ 'Code' ] == "404" : print ( "The object does not exist." ) raise ValueError ( "The object does not exist." ) else : msg = 'AWS Error : ' print ( msg + str ( e ) ) raise ValueError ( msg )
short_docstring: Download the contents of a folder directory
short_docstring_tokens: Download the contents of a folder directory
comment: """
      Download the contents of a folder directory
      Args:
          bucket_name: the name of the s3 bucket
          s3_folder: the folder path in the s3 bucket
          local_dir: a relative or absolute directory path in the local file system
      """$SEP$#boto3.resource('s3')$SEP$# else os.path.join(local_dir, os.path.basename(obj.key))$SEP$#traceback.print_exc()