On Sun, Sep 28, 2008 at 7:10 AM, David Pratt <fairwinds.dp@g mail.comwrote:
Why not just catch the ImportError-s and set some variables depending
on whether you were able to import the modules, e.g.:
# repeat for each soft-depended module
try:
import django_module
except ImportError:
imported_django = False
else:
imported_django = True
#later in the file
if imported_django and imported_sqlalc hemy:
class DjangoToSqlAlch emy(object):
#code that uses the django and sqlalchemy modules here
Regards,
Chris
--
Follow the path of the Iguana...
Hi. I am in the midst of preparing a package to convert between various
schemas including orms. The issue is I don't want django, slqalchemy, storm,
rdflib etc. as hard dependencies of the package. Each module is a schema to
schema conversion. As an example, I have imports for sqlalchemy with classes
and methods that use them.
>
from sqlalchemy.util import OrderedDict
from sqlalchemy import types as rdbtype
import sqlalchemy as sa
>
I have my own ideas about how I might do this but looking for
recommendations from others how they would handle this so the result would
be:
>
1. no hard dependencies on any of these other packages
2. load the module without failure.
3. import the dependent package if available to perform the conversion
schemas including orms. The issue is I don't want django, slqalchemy, storm,
rdflib etc. as hard dependencies of the package. Each module is a schema to
schema conversion. As an example, I have imports for sqlalchemy with classes
and methods that use them.
>
from sqlalchemy.util import OrderedDict
from sqlalchemy import types as rdbtype
import sqlalchemy as sa
>
I have my own ideas about how I might do this but looking for
recommendations from others how they would handle this so the result would
be:
>
1. no hard dependencies on any of these other packages
2. load the module without failure.
3. import the dependent package if available to perform the conversion
on whether you were able to import the modules, e.g.:
# repeat for each soft-depended module
try:
import django_module
except ImportError:
imported_django = False
else:
imported_django = True
#later in the file
if imported_django and imported_sqlalc hemy:
class DjangoToSqlAlch emy(object):
#code that uses the django and sqlalchemy modules here
Regards,
Chris
--
Follow the path of the Iguana...