# Path: tasks/meta.py
# class OBSTimespan(UniqueMixin, Base):
#     '''
#     Describes a timespan table in our database.
#     '''
#     __tablename__ = 'obs_timespan'
# 
#     id = Column(Text, primary_key=True)  # fully-qualified id
#     alias = Column(Text)  # alias for backwards compatibility
#     name = Column(Text)  # human-readable name
#     description = Column(Text)  # human-readable description
#     timespan = Column(DATERANGE)
#     weight = Column(Integer, default=0)
# 
#     @classmethod
#     def unique_hash(cls, id):
#         return id
# 
#     @classmethod
#     def unique_filter(cls, query, id):
#         return query.filter(OBSTimespan.id == id)
# 
# def current_session():
#     '''
#     Returns the session relevant to the currently operating :class:`Task`, if
#     any.  Outside the context of a :class:`Task`, this can still be used for
#     manual session management.
#     '''
#     return _current_session.get()


import re
import calendar
from dateutil.parser import parse
from tasks.meta import OBSTimespan, current_session

QUARTERS = {1: 'first',
            2: 'second',
            3: 'third',
            4: 'fourth'}


def get_timespan(timespan_id):
    ts_id, ts_alias, ts_name, ts_description, ts_timespan = parse_timespan(timespan_id)

# Path: tasks/meta.py
# class OBSTimespan(UniqueMixin, Base):
#     '''
#     Describes a timespan table in our database.
#     '''
#     __tablename__ = 'obs_timespan'
# 
#     id = Column(Text, primary_key=True)  # fully-qualified id
#     alias = Column(Text)  # alias for backwards compatibility
#     name = Column(Text)  # human-readable name
#     description = Column(Text)  # human-readable description
#     timespan = Column(DATERANGE)
#     weight = Column(Integer, default=0)
# 
#     @classmethod
#     def unique_hash(cls, id):
#         return id
# 
#     @classmethod
#     def unique_filter(cls, query, id):
#         return query.filter(OBSTimespan.id == id)
# 
# def current_session():
#     '''
#     Returns the session relevant to the currently operating :class:`Task`, if
#     any.  Outside the context of a :class:`Task`, this can still be used for
#     manual session management.
#     '''
#     return _current_session.get()


# Path: lib/timespan.py
import re
import calendar
from dateutil.parser import parse
from tasks.meta import OBSTimespan, current_session


QUARTERS = {1: 'first',
            2: 'second',
            3: 'third',
            4: 'fourth'}


def get_timespan(timespan_id):
    ts_id, ts_alias, ts_name, ts_description, ts_timespan = parse_timespan(timespan_id)

    session = current_session()