summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlcd1232 <8745863+lcd1232@users.noreply.github.com>2018-01-26 13:21:37 +0300
committerCarlton Gibson <carlton.gibson@noumenal.es>2018-01-26 11:21:37 +0100
commit35728b757f6bc0fcacf373fcbb26d991e7a4b6ce (patch)
tree09b6cdd5b23794a8932b61682419ec76f8fa2523
parent1766d00bde1892d239200402870224f8d7cbe132 (diff)
downloaddjango-appconf-35728b757f6bc0fcacf373fcbb26d991e7a4b6ce.tar.gz
Add syntax highlighting (#39)
* Add syntax highlighting * Fix E722 * Fix coverage * Skip checking ImportError
-rw-r--r--README.rst24
-rw-r--r--appconf/utils.py3
2 files changed, 20 insertions, 7 deletions
diff --git a/README.rst b/README.rst
index 11e7d0e..2be202e 100644
--- a/README.rst
+++ b/README.rst
@@ -28,7 +28,9 @@ Overview
Say you have an app called ``myapp`` with a few defaults, which you want
to refer to in the app's code without repeating yourself all the time.
``appconf`` provides a simple class to implement those defaults. Simply add
-something like the following code somewhere in your app files::
+something like the following code somewhere in your app files:
+
+.. code-block:: python
from appconf import AppConf
@@ -51,7 +53,9 @@ setting is located at. E.g. if your ``models.py`` with the ``AppConf`` class
is in the ``myapp`` package, the prefix of the settings will be ``MYAPP``.
You can override the default prefix by specifying a ``prefix`` attribute of
-an inner ``Meta`` class::
+an inner ``Meta`` class:
+
+.. code-block:: python
from appconf import AppConf
@@ -66,13 +70,17 @@ an inner ``Meta`` class::
The ``MyAppConf`` class will automatically look at Django's global settings
to determine if you've overridden it. For example, adding this to your site's
-``settings.py`` would override ``SETTING_1`` of the above ``MyAppConf``::
+``settings.py`` would override ``SETTING_1`` of the above ``MyAppConf``:
+
+.. code-block:: python
ACME_SETTING_1 = "uno"
In case you want to use a different settings object instead of the default
``'django.conf.settings'``, set the ``holder`` attribute of the inner
-``Meta`` class to a dotted import path::
+``Meta`` class to a dotted import path:
+
+.. code-block:: python
from appconf import AppConf
@@ -88,7 +96,9 @@ In case you want to use a different settings object instead of the default
If you ship an ``AppConf`` class with your reusable Django app, it's
recommended to put it in a ``conf.py`` file of your app package and
-import ``django.conf.settings`` in it, too::
+import ``django.conf.settings`` in it, too:
+
+.. code-block:: python
from django.conf import settings
from appconf import AppConf
@@ -101,7 +111,9 @@ import ``django.conf.settings`` in it, too::
In the other files of your app you can easily make sure the settings
are correctly loaded if you import Django's settings object from that
-module, e.g. in your app's ``views.py``::
+module, e.g. in your app's ``views.py``:
+
+.. code-block:: python
from django.http import HttpResponse
from myapp.conf import settings
diff --git a/appconf/utils.py b/appconf/utils.py
index 98724c6..e71cb7d 100644
--- a/appconf/utils.py
+++ b/appconf/utils.py
@@ -1,10 +1,11 @@
import sys
+# flake8: noqa
def import_attribute(import_path, exception_handler=None):
try:
from importlib import import_module
- except ImportError:
+ except ImportError: # pragma: no cover
from django.utils.importlib import import_module
module_name, object_name = import_path.rsplit('.', 1)
try: