Skip to content

Commit

Permalink
Merge 298520a into f0af058
Browse files Browse the repository at this point in the history
  • Loading branch information
ad-m committed Nov 10, 2019
2 parents f0af058 + 298520a commit 499887b
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 84 deletions.
41 changes: 10 additions & 31 deletions .travis.yml
@@ -1,19 +1,19 @@
version: ~> 1.0
language: python
sudo: false
os: linux
python:
- "2.7"
- "3.4"
- "3.5"
- "3.6"
- "3.7"
- "3.8-dev"
- "nightly"
- "pypy"
env:
jobs:
matrix:
- DJANGO="Django>=1.8,<1.9"
- DJANGO="Django>=1.9,<1.10"
- DJANGO="Django>=1.10,<1.11"
- DJANGO="Django>=1.11,<2.0"
- DJANGO="Django>=2.0,<2.1"
- DJANGO="Django==1.11.*"
- DJANGO="Django==2.0.*"
- DJANGO="Django==2.1.*"
- DJANGO="Django==2.2.*"
- DJANGO="https://github.com/django/django/archive/master.tar.gz"
install:
# The default pip doesn't properly support pre-release version specifiers.
Expand All @@ -28,29 +28,8 @@ branches:
- /^hotfix\/.+/
- /^v[\d\.]+/
script: coverage run --source=environ setup.py test
matrix:
jobs:
fast_finish: true
include:
- python: "3.3"
env: DJANGO="Django>=1.8,<1.9"
# Django 1.11+ supports Python 3.6
- python: "3.6"
env: DJANGO="Django>=1.11,<2.0"
- python: "3.6"
env: DJANGO="Django>=2.0,<2.1"
exclude:
# Django 2.0+ dropped support for Python 2.
- python: "2.7"
env: DJANGO="Django>=2.0,<2.1"
- python: "pypy"
env: DJANGO="Django>=2.0,<2.1"
- python: "2.7"
env: DJANGO="https://github.com/django/django/archive/master.tar.gz"
- python: "pypy"
env: DJANGO="https://github.com/django/django/archive/master.tar.gz"
# Django master dropped support for Python 3.4.
- python: "3.4"
env: DJANGO="https://github.com/django/django/archive/master.tar.gz"
allow_failures:
- env: DJANGO="https://github.com/django/django/archive/master.tar.gz"
after_success:
Expand Down
24 changes: 9 additions & 15 deletions appveyor.yml
Expand Up @@ -3,32 +3,26 @@ build: false
environment:
PYTHONIOENCODING: "utf-8"
matrix:
- PYTHON: "C:/Python27"
DJANGO_VERSION: "Django>=1.8,<1.9"

- PYTHON: "C:/Python27"
DJANGO_VERSION: "Django>=1.9,<1.10"

- PYTHON: "C:/Python27"
DJANGO_VERSION: "Django>=1.10,<1.11"
- PYTHON: "C:/Python35"
DJANGO_VERSION: "Django==1.8.*"

- PYTHON: "C:/Python27"
DJANGO_VERSION: "Django>=1.11,<2.0"
- PYTHON: "C:/Python35"
DJANGO_VERSION: "Django==1.9.*"

- PYTHON: "C:/Python35"
DJANGO_VERSION: "Django>=1.8,<1.9"
DJANGO_VERSION: "Django==1.10.*"

- PYTHON: "C:/Python35"
DJANGO_VERSION: "Django>=1.9,<1.10"
DJANGO_VERSION: "Django==1.11.*"

- PYTHON: "C:/Python35"
DJANGO_VERSION: "Django>=1.10,<1.11"
DJANGO_VERSION: "Django==2.0.*"

- PYTHON: "C:/Python35"
DJANGO_VERSION: "Django>=1.11,<2.0"
DJANGO_VERSION: "Django==2.1.*"

- PYTHON: "C:/Python35"
DJANGO_VERSION: "Django>=2.0,<2.1"
DJANGO_VERSION: "Django==2.2.*"

init:
- "ECHO %PYTHON%"
Expand Down
17 changes: 8 additions & 9 deletions docs/conf.py
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# Django-environ documentation build configuration file, created by
# sphinx-quickstart on Mon Apr 1 23:01:04 2013.
Expand Down Expand Up @@ -40,8 +39,8 @@
master_doc = 'index'

# General information about the project.
project = u'Django-environ'
copyright = u'2013-2015, Daniele Faraglia and other contributors'
project = 'Django-environ'
copyright = '2013-2015, Daniele Faraglia and other contributors'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -183,8 +182,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Django-environ.tex', u'Django-environ Documentation',
u'joke2k', 'manual'),
('index', 'Django-environ.tex', 'Django-environ Documentation',
'joke2k', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -213,8 +212,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'django-environ', u'Django-environ Documentation',
[u'joke2k'], 1)
('index', 'django-environ', 'Django-environ Documentation',
['joke2k'], 1)
]

# If true, show URL addresses after external links.
Expand All @@ -227,8 +226,8 @@
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
('index', 'Django-environ', u'Django-environ Documentation',
u'joke2k', 'Django-environ', "Django-environ allows you to utilize 12factor inspired environment "
('index', 'Django-environ', 'Django-environ Documentation',
'joke2k', 'Django-environ', "Django-environ allows you to utilize 12factor inspired environment "
"variables to configure your Django application.",
'Miscellaneous'),
]
Expand Down
2 changes: 0 additions & 2 deletions environ/compat.py
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

"""
environ.compat
~~~~~~~~~~~~~~~
Expand Down
26 changes: 13 additions & 13 deletions environ/environ.py
Expand Up @@ -37,13 +37,13 @@ def _cast_urlstr(v):
return unquote_plus(v) if isinstance(v, str) else v


class NoValue(object):
class NoValue:

def __repr__(self):
return '<{0}>'.format(self.__class__.__name__)
return '<{}>'.format(self.__class__.__name__)


class Env(object):
class Env:

"""Provide scheme-based lookups of environment variables so that each
caller doesn't have to pass in `cast` and `default` parameters.
Expand Down Expand Up @@ -244,7 +244,7 @@ def get_value(self, var, cast=None, default=NOTSET, parse_default=False):
:returns: Value from environment or default (if set)
"""

logger.debug("get '{0}' casted as '{1}' with default '{2}'".format(
logger.debug("get '{}' casted as '{}' with default '{}'".format(
var, cast, default
))

Expand Down Expand Up @@ -273,7 +273,7 @@ def get_value(self, var, cast=None, default=NOTSET, parse_default=False):
value = self.ENVIRON[var]
except KeyError:
if default is self.NOTSET:
error_msg = "Set the {0} environment variable".format(var)
error_msg = "Set the {} environment variable".format(var)
raise ImproperlyConfigured(error_msg)

value = default
Expand Down Expand Up @@ -340,7 +340,7 @@ def parse_value(cls, value, cast):
if len(parts) == 1:
float_str = parts[0]
else:
float_str = "{0}.{1}".format(''.join(parts[0:-1]), parts[-1])
float_str = "{}.{}".format(''.join(parts[0:-1]), parts[-1])
value = float(float_str)
else:
value = cast(value)
Expand Down Expand Up @@ -434,7 +434,7 @@ def db_url_config(cls, url, engine=None):
config['ENGINE'] = Env.DB_SCHEMES[config['ENGINE']]

if not config.get('ENGINE', False):
warnings.warn("Engine not recognized from url: {0}".format(config))
warnings.warn("Engine not recognized from url: {}".format(config))
return {}

return config
Expand Down Expand Up @@ -633,13 +633,13 @@ def read_env(cls, env_file=None, **overrides):
try:
with open(env_file) if isinstance(env_file, basestring) else env_file as f:
content = f.read()
except IOError:
except OSError:
warnings.warn(
"Error reading %s - if you're not configuring your "
"environment separately, check this." % env_file)
return

logger.debug('Read environment variables from: {0}'.format(env_file))
logger.debug('Read environment variables from: {}'.format(env_file))

for line in content.splitlines():
m1 = re.match(r'\A(?:export )?([A-Za-z_0-9]+)=(.*)\Z', line)
Expand All @@ -658,7 +658,7 @@ def read_env(cls, env_file=None, **overrides):
cls.ENVIRON.setdefault(key, value)


class Path(object):
class Path:

"""Inspired to Django Two-scoops, handling File Paths in Settings.
Expand Down Expand Up @@ -711,7 +711,7 @@ def root(self):

def __init__(self, start='', *paths, **kwargs):

super(Path, self).__init__()
super().__init__()

if kwargs.get('is_file', False):
start = os.path.dirname(start)
Expand Down Expand Up @@ -758,7 +758,7 @@ def __contains__(self, item):
return item.__root__.startswith(base_path)

def __repr__(self):
return "<Path:{0}>".format(self.__root__)
return "<Path:{}>".format(self.__root__)

def __str__(self):
return self.__root__
Expand All @@ -783,7 +783,7 @@ def _absolute_join(base, *paths, **kwargs):
absolute_path = os.path.abspath(os.path.join(base, *paths))
if kwargs.get('required', False) and not os.path.exists(absolute_path):
raise ImproperlyConfigured(
"Create required path: {0}".format(absolute_path))
"Create required path: {}".format(absolute_path))
return absolute_path


Expand Down
17 changes: 8 additions & 9 deletions environ/test.py
@@ -1,4 +1,3 @@
from __future__ import print_function
import os
import sys
import unittest
Expand Down Expand Up @@ -279,7 +278,7 @@ def test_exported(self):
class FileEnvTests(EnvTests):

def setUp(self):
super(FileEnvTests, self).setUp()
super().setUp()
Env.ENVIRON = {}
self.env = Env()
file_path = Path(__file__, is_file=True)('test_env.txt')
Expand All @@ -288,7 +287,7 @@ def setUp(self):
class SubClassTests(EnvTests):

def setUp(self):
super(SubClassTests, self).setUp()
super().setUp()
self.CONFIG = self.generateData()
class MyEnv(Env):
ENVIRON = self.CONFIG
Expand Down Expand Up @@ -605,7 +604,7 @@ def test_solr_parsing(self):
def test_solr_multicore_parsing(self):
timeout = 360
index = 'solr_index'
url = '%s/%s?TIMEOUT=%s' % (self.solr_url, index, timeout)
url = '{}/{}?TIMEOUT={}'.format(self.solr_url, index, timeout)
url = Env.search_url_config(url)

self.assertEqual(url['ENGINE'], 'haystack.backends.solr_backend.SolrEngine')
Expand All @@ -616,7 +615,7 @@ def test_solr_multicore_parsing(self):

def test_elasticsearch_parsing(self):
timeout = 360
url = '%s?TIMEOUT=%s' % (self.elasticsearch_url, timeout)
url = '{}?TIMEOUT={}'.format(self.elasticsearch_url, timeout)
url = Env.search_url_config(url)

self.assertEqual(url['ENGINE'], 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine')
Expand All @@ -629,7 +628,7 @@ def test_elasticsearch_parsing(self):
def test_whoosh_parsing(self):
storage = 'file' # or ram
post_limit = 128 * 1024 * 1024
url = '%s?STORAGE=%s&POST_LIMIT=%s' % (self.whoosh_url, storage, post_limit)
url = '{}?STORAGE={}&POST_LIMIT={}'.format(self.whoosh_url, storage, post_limit)
url = Env.search_url_config(url)

self.assertEqual(url['ENGINE'], 'haystack.backends.whoosh_backend.WhooshEngine')
Expand All @@ -643,7 +642,7 @@ def test_whoosh_parsing(self):

def test_xapian_parsing(self):
flags = 'myflags'
url = '%s?FLAGS=%s' % (self.xapian_url, flags)
url = '{}?FLAGS={}'.format(self.xapian_url, flags)
url = Env.search_url_config(url)

self.assertEqual(url['ENGINE'], 'haystack.backends.xapian_backend.XapianEngine')
Expand All @@ -664,7 +663,7 @@ def test_common_args_parsing(self):
excluded_indexes = 'myapp.indexes.A,myapp.indexes.B'
include_spelling = 1
batch_size = 100
params = 'EXCLUDED_INDEXES=%s&INCLUDE_SPELLING=%s&BATCH_SIZE=%s' % (
params = 'EXCLUDED_INDEXES={}&INCLUDE_SPELLING={}&BATCH_SIZE={}'.format(
excluded_indexes,
include_spelling,
batch_size
Expand Down Expand Up @@ -759,7 +758,7 @@ def load_suite():
try:
if sys.argv[1] == '-o':
for key, value in BaseTests.generateData().items():
print("{0}={1}".format(key, value))
print("{}={}".format(key, value))
sys.exit()
except IndexError:
pass
Expand Down
9 changes: 4 additions & 5 deletions setup.py
@@ -1,7 +1,5 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
from setuptools import setup, find_packages
import io
import os
Expand All @@ -22,7 +20,7 @@

# Import the README and use it as the long-description.
# Note: this will only work if 'README.md' is present in your MANIFEST.in file!
LONG_DESCRIPTION = '\n' + io.open(os.path.join(here, 'README.rst'), encoding="utf8").read()
LONG_DESCRIPTION = '\n' + open(os.path.join(here, 'README.rst'), encoding="utf8").read()

setup(
name=NAME,
Expand All @@ -36,6 +34,7 @@
license=LICENSE,
packages=find_packages(),
platforms=["any"],
python_requires=">=3",
include_package_data=True,
test_suite='environ.test.load_suite',
zip_safe=False,
Expand All @@ -49,9 +48,9 @@
'Framework :: Django :: 1.10',
'Framework :: Django :: 1.11',
'Framework :: Django :: 2.0',
'Framework :: Django :: 2.1',
'Framework :: Django :: 2.2',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
Expand Down

0 comments on commit 499887b

Please sign in to comment.