Skip to content

Commit 411ae51

Browse files
committed
First commit! Initial decimal-based implementation of nested intervals.
0 parents  commit 411ae51

38 files changed

+3428
-0
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
*.pyc
2+
.tox
3+
*.egg-info
4+
*.sqlite3

INSTALL

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Thanks for downloading Django Nested Intervals
2+
3+
To install, run the following command inside this directory:
4+
5+
python setup.py install
6+
7+
Or if you'd prefer, you can simply place the included ``nested_intervals`` directory
8+
somewhere on your PYTHONPATH, or symlink to it from somewhere on your
9+
PYTHONPATH; this is useful if you're working from a git checkout.
10+
11+
Requires:
12+
- Python 2.7 or newer
13+
- Django 1.11 or newer
14+
15+
You can obtain Python from https://www.python.org/ and Django from
16+
https://www.djangoproject.com/

LICENSE

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
Django Nested Intervals
2+
-----------------------
3+
4+
Copyright (c) 2018, Jamie Alexandre
5+
Interface and some code from Django MPTT, Copyright (c) 2007, Jonathan Buchanan
6+
7+
Permission is hereby granted, free of charge, to any person obtaining a copy of
8+
this software and associated documentation files (the "Software"), to deal in
9+
the Software without restriction, including without limitation the rights to
10+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11+
the Software, and to permit persons to whom the Software is furnished to do so,
12+
subject to the following conditions:
13+
14+
The above copyright notice and this permission notice shall be included in all
15+
copies or substantial portions of the Software.
16+
17+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

MANIFEST.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include INSTALL
2+
include LICENSE
3+
include MANIFEST.in
4+
include NOTES
5+
include README.rst
6+
global-exclude __pycache__ *.pyc

README.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
=======================
2+
django-nested-intervals
3+
=======================
4+
5+
Utilities for implementing Nested Interval tree structures with your
6+
Django Models and working with trees of Model instances.
7+
8+
Interface closely tracks Django MPTT.

create-release.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash -ex
2+
3+
python ./setup.py clean
4+
rm -rf ./*.egg-info
5+
6+
python setup.py sdist bdist_wheel register upload

nested_intervals/__init__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from __future__ import unicode_literals
2+
3+
__version__ = "0.0.1"
4+
VERSION = tuple(__version__.split("."))
5+
6+
default_app_config = "nested_intervals.apps.NestedIntervalsConfig"
7+

nested_intervals/apps.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from __future__ import unicode_literals
2+
3+
from django.apps import AppConfig
4+
5+
6+
class NestedIntervalsConfig(AppConfig):
7+
name = "nested_intervals"
8+
verbose_name = "nested_intervals"

nested_intervals/conf.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from django.conf import settings
2+
3+
DECIMAL_PLACES = getattr(settings, "NESTED_INTERVALS_DECIMAL_PLACES", 30)

nested_intervals/exceptions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
Nested Interval exceptions.
3+
"""
4+
from __future__ import unicode_literals
5+
6+
7+
class InvalidMove(Exception):
8+
"""
9+
An invalid node move was attempted.
10+
11+
For example, attempting to make a node a child of itself.
12+
"""
13+
pass
14+
15+
16+
class IntervalTooSmall(Exception):
17+
"""
18+
The interval sizes resulting from an insertion would be too small to represent
19+
given the current number of decimal places. The calling code will need to rebalance.
20+
"""

0 commit comments

Comments
 (0)