save point (see note)

Changed license to AGPLv3, "finished" console command framework (for now?), and
added initial db/lib/pyramid/wx subpackages - though those are not yet well tested.
This commit is contained in:
Lance Edgar 2012-03-20 09:11:01 -05:00
parent 3d75732d36
commit a6decbb313
36 changed files with 2910 additions and 172 deletions

101
edbob/initialization.py Normal file
View file

@ -0,0 +1,101 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
################################################################################
#
# edbob -- Pythonic Software Framework
# Copyright © 2010-2012 Lance Edgar
#
# This file is part of edbob.
#
# edbob is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# edbob is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with edbob. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
"""
``edbob.initialization`` -- Initialization Framework
"""
import os
# import locale
import logging
from edbob.configuration import AppConfigParser
from edbob.configuration import default_system_paths, default_user_paths
from edbob.core import graft
from edbob.times import set_timezone
__all__ = ['init']
log = logging.getLogger(__name__)
def init(appname='edbob', *args, **kwargs):
"""
Initializes the edbob framework, typically by first reading some config
file(s) to determine which interfaces to engage. This must normally be
called prior to doing anything really useful, as it is responsible for
extending the live API in-place.
The meaning of ``args`` is as follows:
If ``args`` is empty, the ``EDBOB_CONFIG`` environment variable is first
consulted. If it is nonempty, then its value is split according to
``os.pathsep`` and the resulting sequence is passed to
``edbob.config.read()``.
If both ``args`` and ``EDBOB_CONFIG`` are empty, the "standard" locations
are assumed, and the results of calling both
:func:`edbob.configuration.default_system_paths()` and
:func:`edbob.configuration.default_user_paths()` are passed on to
``edbob.config.read()``.
Any other values in ``args`` will be passed directly to
``edbob.config.read()`` and so will be interpreted there. Basically they
are assumed to be either strings, or sequences of strings, which represent
paths to various config files, each being read in the order in which it
appears within ``args``. (Configuration is thereby cascaded such that the
file read last will override those before it.)
"""
config = AppConfigParser(appname)
if args:
config_paths = list(args)
elif os.environ.get('EDBOB_CONFIG'):
config_paths = os.environ['EDBOB_CONFIG'].split(os.pathsep)
else:
config_paths = default_system_paths(appname) + default_user_paths(appname)
shell = bool(kwargs.get('shell'))
for paths in config_paths:
config.read(paths, recurse=not shell)
config.configure_logging()
# loc = config.get('edbob', 'locale')
# if loc:
# locale.setlocale(locale.LC_ALL, loc)
# log.info("Set locale to '%s'" % loc)
tz = config.get('edbob', 'timezone')
if tz:
set_timezone(tz)
log.info("Set timezone to '%s'" % tz)
else:
log.warning("No timezone configured; falling back to US/Central")
set_timezone('US/Central')
import edbob
graft(edbob, locals(), 'config')
edbob.inited = True