diff options
author | Noufal Ibrahim <noufal@nibrahim.net.in> | 2014-11-16 10:01:56 +0530 |
---|---|---|
committer | Noufal Ibrahim <noufal@nibrahim.net.in> | 2014-11-16 10:01:56 +0530 |
commit | 0586f71a641f3a685eee57c55bfdf9b9b1cdafa4 (patch) | |
tree | de27ad732b952c1f32da8c67739d404168cafeaa /alembic/config.py | |
parent | afaba66ea550d9aefc823b7025d0e2b56d4a37fa (diff) | |
download | alembic-0586f71a641f3a685eee57c55bfdf9b9b1cdafa4.tar.gz |
Adds cfg_vars to Config.
This dictionary can be used to pass key value pairs that are used as
defaults while instantiating the SafeConfigParser.
Diffstat (limited to 'alembic/config.py')
-rw-r--r-- | alembic/config.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/alembic/config.py b/alembic/config.py index f20abea..d9dbca9 100644 --- a/alembic/config.py +++ b/alembic/config.py @@ -51,10 +51,13 @@ class Config(object): ..versionadded:: 0.4 + :param cfg_vars: A dictionary of keys and values that will be used + for substitution in the alembic config file. + """ def __init__(self, file_=None, ini_section='alembic', output_buffer=None, - stdout=sys.stdout, cmd_opts=None): + stdout=sys.stdout, cmd_opts=None, cfg_vars = {}): """Construct a new :class:`.Config` """ @@ -63,6 +66,7 @@ class Config(object): self.output_buffer = output_buffer self.stdout = stdout self.cmd_opts = cmd_opts + self.cfg_vars = cfg_vars cmd_opts = None """The command-line options passed to the ``alembic`` script. @@ -113,7 +117,8 @@ class Config(object): here = os.path.abspath(os.path.dirname(self.config_file_name)) else: here = "" - file_config = SafeConfigParser({'here': here}) + self.cfg_vars['here'] = here + file_config = SafeConfigParser(self.cfg_vars) if self.config_file_name: file_config.read([self.config_file_name]) else: |