summaryrefslogtreecommitdiff
path: root/alembic/script/base.py
diff options
context:
space:
mode:
authorGord Thompson <gord@gordthompson.com>2021-06-12 15:12:17 -0600
committerMike Bayer <mike_mp@zzzcomputing.com>2021-06-22 14:00:26 -0400
commitd7d358e4ca5e4eab69f2d6e983aa8d026a776ae3 (patch)
tree92ea6a39ccb2fe86af8e2bad0655f03235235054 /alembic/script/base.py
parentc48373b5ae95a6dc84d4f02404f0b2da54f54a61 (diff)
downloadalembic-d7d358e4ca5e4eab69f2d6e983aa8d026a776ae3.tar.gz
Support version_locations paths with spaces
Fixes: #842 Change-Id: Icae7899cecc137eaba26cd14ded9da89df35aae1
Diffstat (limited to 'alembic/script/base.py')
-rw-r--r--alembic/script/base.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/alembic/script/base.py b/alembic/script/base.py
index 723c011..f6c5070 100644
--- a/alembic/script/base.py
+++ b/alembic/script/base.py
@@ -140,7 +140,40 @@ class ScriptDirectory(object):
version_locations = config.get_main_option("version_locations")
if version_locations:
- version_locations = _split_on_space_comma.split(version_locations)
+ version_path_separator = config.get_main_option(
+ "version_path_separator"
+ )
+
+ split_on_path = {
+ None: None,
+ "space": " ",
+ "os": os.pathsep,
+ ":": ":",
+ ";": ";",
+ }
+
+ try:
+ split_char = split_on_path[version_path_separator]
+ except KeyError as ke:
+ util.raise_(
+ ValueError(
+ "'%s' is not a valid value for "
+ "version_path_separator; "
+ "expected 'space', 'os', ':', ';'"
+ % version_path_separator
+ ),
+ from_=ke,
+ )
+ else:
+ if split_char is None:
+ # legacy behaviour for backwards compatibility
+ version_locations = _split_on_space_comma.split(
+ version_locations
+ )
+ else:
+ version_locations = [
+ x for x in version_locations.split(split_char) if x
+ ]
prepend_sys_path = config.get_main_option("prepend_sys_path")
if prepend_sys_path: