# Path: raggregate/models/stat.py
# class Stat(Base):
#     __tablename__ = 'stats'
# 
#     # this table is a k-v store for statistical information.
#     key = Column(UnicodeText, primary_key=True)
#     value = Column(UnicodeText)
#     last_update = Column(DateTime(timezone=True), default=sqlalchemy.sql.func.now())
# 
#     def __init__(self, key, value):
#         self.key = key
#         self.value = value


from raggregate.models.stat import Stat
from datetime import datetime
from datetime import timedelta
    from raggregate.queries import submission
    from raggregate.queries import users
    from raggregate.queries import epistle as epistle_queries
    from raggregate.models.anonallowance import AnonAllowance
    from lxml.html import fromstring, tostring
    from raggregate.models.ban import Ban
    from raggregate.queries import user_preference as up
import calendar
import pytz
import time
import sqlahelper
import sqlalchemy
import json
    import uuid
    import os


dbsession = sqlahelper.get_session()

def get_from_post(post, key):
    if key in post and post[key] != '':
        return post[key]
    else:
        return None

def realize_timedelta_constructor(con_str):
    """ Converts a timedelta constructor parameter list into a real timedelta.
    @param con_str: the constructor parameters to convert"""
    return eval("timedelta({0})".format(con_str))

def now_in_utc():
    return datetime.utcnow().replace(tzinfo=pytz.utc)

def get_key_from_stat(key, type = None):

# Path: raggregate/models/stat.py
# class Stat(Base):
#     __tablename__ = 'stats'
# 
#     # this table is a k-v store for statistical information.
#     key = Column(UnicodeText, primary_key=True)
#     value = Column(UnicodeText)
#     last_update = Column(DateTime(timezone=True), default=sqlalchemy.sql.func.now())
# 
#     def __init__(self, key, value):
#         self.key = key
#         self.value = value


# Path: raggregate/queries/general.py
from raggregate.models.stat import Stat
from datetime import datetime
from datetime import timedelta
    from raggregate.queries import submission
    from raggregate.queries import users
    from raggregate.queries import epistle as epistle_queries
    from raggregate.models.anonallowance import AnonAllowance
    from lxml.html import fromstring, tostring
    from raggregate.models.ban import Ban
    from raggregate.queries import user_preference as up
import calendar
import pytz
import time
import sqlahelper
import sqlalchemy
import json
    import uuid
    import os



dbsession = sqlahelper.get_session()

def get_from_post(post, key):
    if key in post and post[key] != '':
        return post[key]
    else:
        return None

def realize_timedelta_constructor(con_str):
    """ Converts a timedelta constructor parameter list into a real timedelta.
    @param con_str: the constructor parameters to convert"""
    return eval("timedelta({0})".format(con_str))

def now_in_utc():
    return datetime.utcnow().replace(tzinfo=pytz.utc)

def get_key_from_stat(key, type = None):

    sa = dbsession.query(Stat).filter(Stat.key == key).one()