API reference

core module

db module

Database URL parser.

yaenv.db.add_scheme(scheme: str, backend: str) None[source]

Extend the dictionary of supported schemes.

Parameters
  • scheme (int) – The scheme of the database.

  • backend (str) – The backend of the database.

Examples

>>> add_scheme('mysql-connector', 'mysql.connector.django')
yaenv.db.parse(url: str) DBConfig[source]

Parse a database URL.

Parameters

url (str) – The database URL to be parsed.

Returns

DBConfig – A dictionary that can be used in django.settings.DATABASES.

Examples

>>> parse('mysql://user:pass@127.0.0.1:3306/django')
{
    'ENGINE': 'django.db.backends.mysql',
    'NAME': 'django',
    'USER': 'user',
    'PASSWORD': 'pass',
    'HOST': '127.0.0.1',
    'PORT': '3306',
    'OPTIONS': {}
}
class yaenv.db.DBConfig

Type representing a database config object.

email module

E-mail URL parser.

yaenv.email.parse(url: str) EmailConfig[source]

Parse an e-mail URL.

Parameters

url (str) – The e-mail URL to be parsed.

Returns

EmailConfig – A dictionary that can be used in django.settings.EMAIL_*.

Examples

>>> parse('smtp+tls://user:pass@example.com')
{
    'EMAIL_BACKEND': 'django.core.mail.backends.smtp.EmailBackend',
    'EMAIL_HOST_USER': 'user',
    'EMAIL_HOST_PASSWORD': 'pass',
    'EMAIL_HOST': 'example.com',
    'EMAIL_USE_TLS': True,
    'EMAIL_PORT': 587
}
class yaenv.email.EmailConfig

Type representing an e-mail config object.

utils module

Useful utilities.

yaenv.utils.is_truthy(arg: Any) bool[source]

Check if the given argument is truthy.

Parameters

arg (Any) – The argument to check.

Returns

bool – True if arg is truthy.

Examples

>>> is_truthy('ON')
True
>>> is_truthy(10)
False
yaenv.utils.is_falsy(arg: Any) bool[source]

Check if the given argument is falsy.

Parameters

arg (Any) – The argument to check.

Returns

bool – True if arg is falsy.

Examples

>>> is_falsy('NO')
True
>>> is_falsy(-1)
False