<commit_before>import redis

STOREDB = 0
HOST = "localhost"
def get_stores():
    """Returns a list of available stores"""
    return redis.Redis(host=HOST, db=STOREDB).hkeys("stores")

def create_store(store_name, initial_data=[]):
    """Creates a store with the given store_name and initial_data

    Keyword arguments:
    store_name -- the name of the store
    initial_data -- initial data for the store (optional)
    """
    # Check that store name is unique (or create unique identifier)
    # Create the store
    # Load initial data into the store
    # Return the name of the store/status/objects created
    if store_name in get_stores():
        raise Exception("Store already exists.")
    stores_db = edis.Redis(host=HOST, db=STOREDB)
    stores_db.hset(store_name, stores_db.get("next"))
    stores_db.incr("next")
    return {"store_name": store_name, "db_id": stores_db.hget("stores", store_name)}

def delete_store(store_name):
    """Deletes the store with a given store_name

    Keyword arguments:
    store_name -- the name of the store
    """
    # Check privlages of user attempting to delete store
    # Delete store
    # Return the status/output of the operation
    pass

def get_store_contents(store_name):
    """Returns a list containing all the contents of the store

    Keyword arguments:
    store_name -- the name of the store
    """
    # Check privlages of user attempting to access store
    # Get and return contents of the store
    pass

def query_store(store_name, query):
    """Returns the result of querying the given store with query

    Keyword arguments:
    store_name -- the name of the store
    query -- a query string
    """
    # Check privlages of user attempting to acccess store
    # Run query on the given store and return results
    pass

def get_store_perms(store_name):
    """Returns a dictionary of permissions of the store

    Keyword arguments:
    store_name -- the name of the store
    """
    # Return the permissions of the store
    pass

def update_store_perms(store_name, perms):
    """Updates the permissions of the given store with perms

    Keyword arguments:
    store_name -- the name of the store
    perms -- dictionary of the updated permissions
    """
    # Updates the permissions of the store and returns the status
    pass

def store_insert(store_name, data):
    """Inserts data into the store

    Keyword arguments:
    store_name -- the name of the store
    data -- a list of key value pairs to be put in the store
    """
    # Insert the key value pairs into the store
    pass

def store_update(store_name, pair):
    """Updates a certain key-value pair in the store

    Keyword arguments:
    store_name -- the name of the store
    pair -- the updated pair (dict)
    """
    # Set the key of the store to the new value
    pass

def store_get_val(store_name, key):
    """Gets the value of the specified key in the store 

    Keyword arguments:
    store_name -- the name of the store
    key -- the key at which the value is store in the store
    """
    # Gets the value of the key in the store
    pass
<commit_msg>making changes to redis_adapter<commit_after>"""Store Adapter Template File

IMPORTANT: NOT A FUNCTIONAL ADAPTER. FUNCTIONS MUST BE IMPLEMENTED

Notes:
    - Each of the functions defined below must return a json serializable
      object, json_response, or valid HttpResponse object
    - A json_response creates an HttpResponse object given parameters:
        - content: string with the contents of the response 
        - status: string with the status of the response 
        - status_code: HTTP status code 
        - error: string with the error message if there is one 
"""
from common.response import json_response
import logging
logger = logging.getLogger(__name__)

import redis

STOREDB = 0
HOST = "localhost"

def get_stores():
    """Returns a list of available stores"""
    return redis.Redis(host=HOST, db=STOREDB).keys('store')

def create_store(request, store_name):
    """Creates a store with the given store_name and initial_data

    Keyword arguments:
    request -- request the data can be derived from
    store_name -- the name of the store
    """
    # Check to see that the store name is unique
    # Returns store_name and data

    # Gets initial data if it exists
    initial_data = json.loads(request.POST.get("data","[]"))

    if store_name in get_stores():
        raise Exception("Store already exists.")
    storedb = redis.Redis(host=HOST, db=STOREDB)
    storedb.set("store:" + store_name, initial_data)
    return {"store_name": store_name, "data": initial_data}

def delete_store(store_name):
    """Deletes the store with a given store_name

    Keyword arguments:
    store_name -- the name of the store
    """
    pass

def get_store_contents(store_name):
    """Returns a list containing all the contents of the store

    Keyword arguments:
    store_name -- the name of the store
    """
   pass

def query_store(store_name, query):
    """Returns the result of querying the given store with query

    Keyword arguments:
    store_name -- the name of the store
    query -- a query string
    """
    pass

def get_store_perms(store_name):
    """Returns a dictionary of permissions of the store

    Keyword arguments:
    store_name -- the name of the store
    """
    pass

def update_store_perms(request, store_name):
    """Updates the permissions of the given store with perms

    Keyword arguments:
    request -- Django HttpRequest object
    store_name -- the name of the store
    """
    pass

def store_insert(request, store_name):
    """Inserts data into the store

    Keyword arguments:
    request -- Django HttpRequest object
    store_name -- the name of the store
    """
    pass

def store_update(request, store_name, obj_id):
    """Updates a certain key-value pair in the store

    Keyword arguments:
    request -- Django HttpRequest object
    store_name -- the name of the store
    obj_id -- ID of the object in the store
    """
    pass

def store_get_obj(store_name, obj_id):
    """Gets the value of the specified key in the store 

    Keyword arguments:
    store_name -- the name of the store
    obj_id -- ID of the object in the store
    """
    pass

{'fraction_non_alphanumeric': 0.07330677290836653, 'fraction_numerical': 0.00031872509960159364, 'mean_word_length': 3.015355086372361, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 3, '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': '5915779', 'n_tokens_mistral': 1778, 'n_tokens_neox': 1756, 'n_words': 739}