# Path: lib/config.py
# def load():
# def update(conf):
# def load_rule():
# def update_rule(rule):
# def rule_read(name, get_file_handle=None):
# def rule_write(name, rule):
# 
# Path: lib/settings.py
# SESSION_CONF_FILE = os.path.join(ROOT, 'conf/', 'session')


import os
import time
import md5
from lib import config
from lib.settings import SESSION_CONF_FILE

def update(session):
    size_control()
    with open(SESSION_CONF_FILE, 'a') as f:
        f.write(session + '\n')
        f.close()
        return True


def destroy(session):
    with open(SESSION_CONF_FILE, 'r') as f:
        lines = f.readlines()
        f.close()
        ff = open(SESSION_CONF_FILE, 'w')
        for line in lines:
            if session != line.strip():
                ff.write(line)
        ff.close()
        return True


def size_control():
    if os.path.getsize(SESSION_CONF_FILE) > config.load()["session_size"]:
        with open(SESSION_CONF_FILE, 'r') as f:
            lines = f.readlines()
            f.close()
            ff = open(SESSION_CONF_FILE, 'w')
            size = 0
            for line in lines:
                size += len(line)

# Path: lib/config.py
# def load():
# def update(conf):
# def load_rule():
# def update_rule(rule):
# def rule_read(name, get_file_handle=None):
# def rule_write(name, rule):
# 
# Path: lib/settings.py
# SESSION_CONF_FILE = os.path.join(ROOT, 'conf/', 'session')


# Path: lib/session.py
import os
import time
import md5
from lib import config
from lib.settings import SESSION_CONF_FILE


def update(session):
    size_control()
    with open(SESSION_CONF_FILE, 'a') as f:
        f.write(session + '\n')
        f.close()
        return True


def destroy(session):
    with open(SESSION_CONF_FILE, 'r') as f:
        lines = f.readlines()
        f.close()
        ff = open(SESSION_CONF_FILE, 'w')
        for line in lines:
            if session != line.strip():
                ff.write(line)
        ff.close()
        return True


def size_control():
    if os.path.getsize(SESSION_CONF_FILE) > config.load()["session_size"]:
        with open(SESSION_CONF_FILE, 'r') as f:
            lines = f.readlines()
            f.close()
            ff = open(SESSION_CONF_FILE, 'w')
            size = 0
            for line in lines:
                size += len(line)

                if size < config.load()["session_size"]: