import os
import random
import string
from datetime import date, datetime
import main


def random_name():
    return ''.join([random.choice(string.ascii_lowercase + string.digits) for n in range(20)])


def json_serial(obj):
    """JSON serializer for objects not serializable by default json code"""

    if isinstance(obj, (datetime, date)):
        return obj.isoformat()
    raise TypeError("Type %s not serializable" % type(obj))


def secret_key_gen():
    filepath = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + '/secret.txt'
    generated_key = ''.join([random.SystemRandom().choice(string.ascii_letters + string.digits)
                             for _ in range(50)])
    with open(filepath, 'w') as secret_file:
        secret_file.write(
            '%(key)s' % dict(key=generated_key)
        )

    print('Find your secret key at %(path)s' % dict(path=filepath))


def check_name(name):
    for shl in main.app.shopping_list:
        if shl.get('name') == name:
            return True
    return False


def get_shl(name):
    for shl in main.app.shopping_list:
        if shl.get('name') == name:
            return shl


def check_duplicate_item_name(shl_name, item_name):
    for shl in main.app.shopping_list:
        if shl.get('name') == shl_name:
            for item in shl.get('shl').items:
                if item.name == item_name:
                    return True

            return False


@@ -1056,120 +1056,586 @@
 def 
-get_shl(name):%0A    for shl in main.app.shopping_list:%0A        if shl.get('name') == name:%0A            return shl
+check_item(sname,iname):%0A    if check_name(sname):%0A        shl = get_shl(sname)%0A        items = shl.get('shl').items%0A        for item in items:%0A            if item.name == iname:%0A                return True%0A            break%0A        return False%0A    return False%0A%0A%0Adef get_shl(name):%0A    for shl in main.app.shopping_list:%0A        if shl.get('name') == name:%0A            return shl%0A%0A%0Adef get_item(shl_name, item_name):%0A    shl = get_shl(shl_name)%0A    items = shl.get('shl').items%0A    for item in items:%0A        if item.name == item_name:%0A            return item%0A    return False
 %0A%0A%0Ad
@@ -1896,24 +1896,213 @@
           return False%0A%0A
+%0Adef change_shl_name(name, new_name):%0A    for shl in main.app.shopping_list:%0A        if shl.get('name') == name:%0A            shl%5B'name'%5D = new_name%0A            return True%0A    return False%0A

Add more helper functions