Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
82 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ __pycache__ | |
site | ||
dist | ||
*.egg-info | ||
build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .base import parse | ||
from .schemas import orator | ||
|
||
__version__ = "0.0.4" | ||
|
||
__all__ = ["parse", "orator"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import os | ||
|
||
try: | ||
# Python 3 | ||
from urllib.parse import urlparse | ||
|
||
except ImportError: | ||
# Python 2 | ||
from urlparse import urlparse | ||
|
||
|
||
DEFAULT_ENV = "DATABASE_URL" | ||
|
||
|
||
def parse(url=None): | ||
""" | ||
Parses a database URL. | ||
""" | ||
|
||
if url: | ||
return urlparse(url) | ||
|
||
url = os.environ.get(DEFAULT_ENV) | ||
return urlparse(url) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from .base import parse | ||
|
||
|
||
def orator(url=None, prefix=None): | ||
""" | ||
Function to parser for orator format. | ||
""" | ||
|
||
url = parse(url) | ||
|
||
config = { | ||
f"{url.scheme}": { | ||
"driver": url.scheme, | ||
"host": url.hostname, | ||
"database": url.path[1:], | ||
"user": url.username, | ||
"password": url.password, | ||
"prefix": prefix or "", | ||
} | ||
} | ||
|
||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters