# Path: opentaxforms/db.py
# def connect(appname, **kw):
#     # default values
#     user = pw = 'user'
#     dbname = appname.lower()
#     # optionally override defaults
#     user = os.environ.get(appname.upper() + '_DBUSER', user)
#     pw = os.environ.get(appname.upper() + '_DBPASS', pw)
#     dbname = os.environ.get(appname.upper() + '_DBNAME', dbname)
#     global conn
#     conn, engine, metadata, md = connect_(user=user, pw=pw, db=dbname, **kw)
#     return conn, engine, metadata, md
# 
# Path: opentaxforms/version.py

# 
# Path: opentaxforms/ut.py
# class Bag(object):
# 
#     # after alexMartelli at http://stackoverflow.com/questions/2597278
#     def __init__(self, *maps, **kw):
#         '''
#             >>> b=Bag(a=0)
#             >>> b.a=1
#             >>> b.b=0
#             >>> c=Bag(b)
#             '''
#         for mapp in maps:
#             getdict = None
#             if type(mapp) == dict:
#                 getdict = lambda x: x
#                 # def getdict(x): return x
#             elif type(mapp) == Bag:
#                 getdict = lambda x: x.__dict__
#                 # def getdict(x): return x.__dict__
#             elif type(mapp) == tuple:
#                 mapp, getdict = mapp
#             if getdict is not None:
#                 self.__dict__.update(getdict(mapp))
#             else:
#                 mapp, getitems = self._getGetitems(mapp)
#                 for k, v in getitems(mapp):
#                     self.__dict__[k] = v
#         self.__dict__.update(kw)
# 
#     def _getGetitems(self, mapp):
#         if type(mapp) == tuple:
#             mapp, getitems = mapp
#         else:
#             getitems = lambda m: m.items()
#             # def getitems(m): return m.items()
#         return mapp, getitems
# 
#     def __getitem__(self, key):
#         return self.__dict__[key]
# 
#     def __setitem__(self, key, val):
#         self.__dict__[key] = val
# 
#     def __len__(self):
#         return len(self.__dict__)
# 
#     def __call__(self, *keys):
#         '''slicing interface
#             gimmicky but useful, and doesnt pollute key namespace
#             >>> b=Bag(a=1,b=2)
#             >>> assert b('a','b')==(1,2)
#             '''
#         return tuple(self.__dict__[k] for k in keys)
# 
#     def clear(self):
#         self.__dict__={}
# 
#     def update(self, *maps):
#         '''
#             >>> b=Bag(a=1,b=2)
#             >>> b.update(Bag(a=1,b=1,c=0))
#             Bag({'a': 1, 'b': 1, 'c': 0})
#             '''
#         for mapp in maps:
#             mapp, getitems = self._getGetitems(mapp)
#             for k, v in getitems(mapp):
#                 self.__dict__[k] = v
#         return self
# 
#     def __add__(self, *maps):
#         self.__iadd__(*maps)
#         return self
# 
#     def __iadd__(self, *maps):
#         '''
#             >>> b=Bag(a=1,b=2)
#             >>> b+=Bag(a=1,b=1,c=0)
#             >>> assert b('a','b','c')==(2,3,0)
#             >>> b=Bag(a='1',b='2')
#             >>> b+=Bag(a='1',b='1',c='0')
#             >>> assert b('a','b','c')==('11','21','0')
#             '''
#         # todo error for empty maps[0]
#         zero = type(list(maps[0].values())[0])()
#         for mapp in maps:
#             mapp, getitems = self._getGetitems(mapp)
#             for k, v in getitems(mapp):
#                 self.__dict__.setdefault(k, zero)
#                 self.__dict__[k] += v
#         return self
# 
#     def __iter__(self):
#         return self.iterkeys()
# 
#     def iterkeys(self):
#         return iter(self.__dict__.keys())
# 
#     def keys(self):
#         return self.__dict__.keys()
# 
#     def values(self):
#         return self.__dict__.values()
# 
#     def items(self):
#         return self.__dict__.items()
# 
#     def iteritems(self):
#         return self.__dict__.iteritems()
# 
#     def get(self, key, dflt=None):
#         return self.__dict__.get(key, dflt)
# 
#     def __str__(self):
#         return 'Bag(' + pf(self.__dict__) + ')'
# 
#     def __repr__(self):
#         return self.__str__()


import flask_restless
from argparse import ArgumentParser
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
from .db import connect
from .version import appname, apiVersion
from .ut import Bag
        colsToShow.extend(colsToAdd)
        # print tabl,colsToShow
        apimanager.create_api(
            tablcls,
            url_prefix='/api/v%s' % (apiVersion, ),
            include_columns=colsToShow,
            )
    return counts


def parseCmdline():
    '''Load command line arguments'''
    parser = ArgumentParser(
        description='Automates tax forms'
                    ' and provides an API for new tax form interfaces'
        )
    parser.add_argument(
        '-P', '--postgres',
        help='use postgres database [default=sqlite]', action="store_true")
    return parser.parse_args()


def createApp(**kw):
    cmdline = kw.get('cmdline')
    verbose = kw.get('verbose')
    if 'cmdline' in kw:
        del kw['cmdline']
    if 'verbose' in kw:
        del kw['verbose']
    args = parseCmdline() if cmdline else Bag(dict(postgres=False))

# Path: opentaxforms/db.py
# def connect(appname, **kw):
#     # default values
#     user = pw = 'user'
#     dbname = appname.lower()
#     # optionally override defaults
#     user = os.environ.get(appname.upper() + '_DBUSER', user)
#     pw = os.environ.get(appname.upper() + '_DBPASS', pw)
#     dbname = os.environ.get(appname.upper() + '_DBNAME', dbname)
#     global conn
#     conn, engine, metadata, md = connect_(user=user, pw=pw, db=dbname, **kw)
#     return conn, engine, metadata, md
# 
# Path: opentaxforms/version.py

# 
# Path: opentaxforms/ut.py
# class Bag(object):
# 
#     # after alexMartelli at http://stackoverflow.com/questions/2597278
#     def __init__(self, *maps, **kw):
#         '''
#             >>> b=Bag(a=0)
#             >>> b.a=1
#             >>> b.b=0
#             >>> c=Bag(b)
#             '''
#         for mapp in maps:
#             getdict = None
#             if type(mapp) == dict:
#                 getdict = lambda x: x
#                 # def getdict(x): return x
#             elif type(mapp) == Bag:
#                 getdict = lambda x: x.__dict__
#                 # def getdict(x): return x.__dict__
#             elif type(mapp) == tuple:
#                 mapp, getdict = mapp
#             if getdict is not None:
#                 self.__dict__.update(getdict(mapp))
#             else:
#                 mapp, getitems = self._getGetitems(mapp)
#                 for k, v in getitems(mapp):
#                     self.__dict__[k] = v
#         self.__dict__.update(kw)
# 
#     def _getGetitems(self, mapp):
#         if type(mapp) == tuple:
#             mapp, getitems = mapp
#         else:
#             getitems = lambda m: m.items()
#             # def getitems(m): return m.items()
#         return mapp, getitems
# 
#     def __getitem__(self, key):
#         return self.__dict__[key]
# 
#     def __setitem__(self, key, val):
#         self.__dict__[key] = val
# 
#     def __len__(self):
#         return len(self.__dict__)
# 
#     def __call__(self, *keys):
#         '''slicing interface
#             gimmicky but useful, and doesnt pollute key namespace
#             >>> b=Bag(a=1,b=2)
#             >>> assert b('a','b')==(1,2)
#             '''
#         return tuple(self.__dict__[k] for k in keys)
# 
#     def clear(self):
#         self.__dict__={}
# 
#     def update(self, *maps):
#         '''
#             >>> b=Bag(a=1,b=2)
#             >>> b.update(Bag(a=1,b=1,c=0))
#             Bag({'a': 1, 'b': 1, 'c': 0})
#             '''
#         for mapp in maps:
#             mapp, getitems = self._getGetitems(mapp)
#             for k, v in getitems(mapp):
#                 self.__dict__[k] = v
#         return self
# 
#     def __add__(self, *maps):
#         self.__iadd__(*maps)
#         return self
# 
#     def __iadd__(self, *maps):
#         '''
#             >>> b=Bag(a=1,b=2)
#             >>> b+=Bag(a=1,b=1,c=0)
#             >>> assert b('a','b','c')==(2,3,0)
#             >>> b=Bag(a='1',b='2')
#             >>> b+=Bag(a='1',b='1',c='0')
#             >>> assert b('a','b','c')==('11','21','0')
#             '''
#         # todo error for empty maps[0]
#         zero = type(list(maps[0].values())[0])()
#         for mapp in maps:
#             mapp, getitems = self._getGetitems(mapp)
#             for k, v in getitems(mapp):
#                 self.__dict__.setdefault(k, zero)
#                 self.__dict__[k] += v
#         return self
# 
#     def __iter__(self):
#         return self.iterkeys()
# 
#     def iterkeys(self):
#         return iter(self.__dict__.keys())
# 
#     def keys(self):
#         return self.__dict__.keys()
# 
#     def values(self):
#         return self.__dict__.values()
# 
#     def items(self):
#         return self.__dict__.items()
# 
#     def iteritems(self):
#         return self.__dict__.iteritems()
# 
#     def get(self, key, dflt=None):
#         return self.__dict__.get(key, dflt)
# 
#     def __str__(self):
#         return 'Bag(' + pf(self.__dict__) + ')'
# 
#     def __repr__(self):
#         return self.__str__()


# Path: opentaxforms/serve.py
import flask_restless
from argparse import ArgumentParser
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import scoped_session, sessionmaker
from .db import connect
from .version import appname, apiVersion
from .ut import Bag

        colsToShow.extend(colsToAdd)
        # print tabl,colsToShow
        apimanager.create_api(
            tablcls,
            url_prefix='/api/v%s' % (apiVersion, ),
            include_columns=colsToShow,
            )
    return counts


def parseCmdline():
    '''Load command line arguments'''
    parser = ArgumentParser(
        description='Automates tax forms'
                    ' and provides an API for new tax form interfaces'
        )
    parser.add_argument(
        '-P', '--postgres',
        help='use postgres database [default=sqlite]', action="store_true")
    return parser.parse_args()


def createApp(**kw):
    cmdline = kw.get('cmdline')
    verbose = kw.get('verbose')
    if 'cmdline' in kw:
        del kw['cmdline']
    if 'verbose' in kw:
        del kw['verbose']
    args = parseCmdline() if cmdline else Bag(dict(postgres=False))

    app = Flask(appname)