<commit_before># File: s3.py
# Audiophiler s3 API calls
# @author: <NAME> (sgreene570)


import boto
import boto.s3.connection


def get_file(bucket, filename):
    key = bucket.get_key(filename)
    # Generates presigned URL that lasts for 900 seconds (15 minutes)
    # If streaming begins prior to the time cutoff, s3 will allow
    # for the streaming to continue, uninterrupted.
    return key.generate_url(900, query_auth=True, force_http=True)


def get_file_list(bucket):
    # List all files in the bucket
    return bucket.list()


def get_date_modified(bucket, filename):
    # Get date modified for a specific file in the bucket
    return bucket.get_key(filename).last_modified


def upload_file(bucket, filename, f):
    # Create bucket key with filename
    key = bucket.new_key(filename)
    # Upload the file
    key.set_contents_from_file(f)


def get_bucket(s3_url, s3_key, s3_secret, bucket_name):
    # Establish s3 connection through boto
    conn = boto.connect_s3(
                aws_access_key_id = s3_key,
                aws_secret_access_key = s3_secret,
                host = s3_url,
                calling_format = boto.s3.connection.OrdinaryCallingFormat(),
                )
    # Return the bucket rather than the entire resource
    return conn.get_bucket(bucket_name)<commit_msg>added delete functionality<commit_after># File: s3.py
# Audiophiler s3 API calls
# @author: <NAME> (sgreene570)


import boto
import boto.s3.connection


def get_file(bucket, filename):
    key = bucket.get_key(filename)
    # Generates presigned URL that lasts for 900 seconds (15 minutes)
    # If streaming begins prior to the time cutoff, s3 will allow
    # for the streaming to continue, uninterrupted.
    return key.generate_url(900, query_auth=True, force_http=True)


def get_file_list(bucket):
    # List all files in the bucket
    return bucket.list()


def get_date_modified(bucket, filename):
    # Get date modified for a specific file in the bucket
    return bucket.get_key(filename).last_modified


def upload_file(bucket, filename, f):
    # Create bucket key with filename
    key = bucket.new_key(filename)
    # Upload the file
    key.set_contents_from_file(f)


def remove_file(bucket, filename):
    bucket.delete_key(filename)


def get_bucket(s3_url, s3_key, s3_secret, bucket_name):
    # Establish s3 connection through boto
    conn = boto.connect_s3(
                aws_access_key_id = s3_key,
                aws_secret_access_key = s3_secret,
                host = s3_url,
                calling_format = boto.s3.connection.OrdinaryCallingFormat(),
                )
    # Return the bucket rather than the entire resource
    return conn.get_bucket(bucket_name)
{'fraction_non_alphanumeric': 0.0740058910162003, 'fraction_numerical': 0.017673048600883652, 'mean_word_length': 3.2320872274143304, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7414855', 'n_tokens_mistral': 869, 'n_tokens_neox': 824, 'n_words': 245}