Commits

David Bennett committed 58c7bcf

Initial commit.

Comments (0)

Files changed (17)

+syntax: glob
+*.pyc
+*.pyo
+*.orig
+*.egg-info
+MANIFEST
+dist
+build
+docs/_build
+tests/assets/static/*
+.tox/
+reports/*
+
+David Bennett <david@dbinit.com>
+Copyright (c) 2012, David Bennett and contributors
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+    * Redistributions of source code must retain the above copyright
+      notice, this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above
+      copyright notice, this list of conditions and the following
+      disclaimer in the documentation and/or other materials provided
+      with the distribution.
+    * Neither the name of the author nor the names of other
+      contributors may be used to endorse or promote products derived
+      from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+include AUTHORS
+include LICENSE
+include README.rst
+recursive-include docs *
+recursive-include private_media/tests *
+global-exclude *.pyc
+====================
+django-private-media
+====================
+
+This is a Django app that provides helpers for serving private media files.

private_media/__init__.py

+# http://semver.org
+__version__ = "0.1.0"

private_media/conf.py

+"""
+Initializes the settings
+"""
+from appconf import AppConf
+from django.conf import settings
+
+
+class PrivateMediaConf(AppConf):
+    # The URL prefix for Nginx internal location
+    URL = '/_private/'
+
+    class Meta:
+        prefix = 'private_media'

private_media/models.py

Empty file added.

private_media/test_settings.py

+import os
+
+
+SITE_ID = 1
+
+TEST_ROOT = os.path.join(os.path.normcase(os.path.dirname(
+    os.path.abspath(__file__))), 'tests')
+
+DATABASE_ENGINE = 'sqlite3'
+
+DATABASES = {
+    'default': {
+        'ENGINE': 'django.db.backends.sqlite3',
+        'NAME': ':memory:',
+    }
+}
+
+MEDIA_URL = '/media/'
+
+MEDIA_ROOT = os.path.join(TEST_ROOT, 'assets', 'media')
+
+ADMIN_MEDIA_PREFIX = '/static/admin/'
+
+STATIC_URL = '/static/'
+
+STATIC_ROOT = os.path.join(TEST_ROOT, 'assets', 'static')
+
+ROOT_URLCONF = 'private_media.tests.urls'
+
+TEMPLATE_DIRS = (
+    os.path.join(TEST_ROOT, 'templates'),
+)
+
+INSTALLED_APPS = [
+    'django.contrib.contenttypes',
+    'django.contrib.sites',
+    'django.contrib.auth',
+    'django.contrib.admin',
+    'django_jenkins',
+]
+
+JENKINS_TASKS = (
+    'django_jenkins.tasks.run_pyflakes',
+    'django_jenkins.tasks.run_pep8',
+    'django_jenkins.tasks.with_coverage',
+    'django_jenkins.tasks.django_tests',
+)

private_media/tests/__init__.py

Empty file added.

private_media/tests/assets/media/media-file.txt

Empty file added.

private_media/tests/templates/404.html

+File not found.

private_media/tests/tests.py

Empty file added.

private_media/urls.py

Empty file added.

private_media/views.py

Empty file added.
+import os
+import re
+import sys
+from fnmatch import fnmatchcase
+from distutils.util import convert_path
+from setuptools import setup, find_packages
+
+
+def read(*parts):
+    return open(os.path.join(os.path.dirname(__file__), *parts)).read()
+
+
+def find_version(*file_paths):
+    version_file = read(*file_paths)
+    version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
+                              version_file, re.M)
+    if version_match:
+        return version_match.group(1)
+    raise RuntimeError("Unable to find version string.")
+
+
+# Provided as an attribute, so you can append to these instead
+# of replicating them:
+standard_exclude = ('*.py', '*.pyc', '*$py.class', '*~', '.*', '*.bak')
+standard_exclude_directories = ('.*', 'CVS', '_darcs', './build',
+                                './dist', 'EGG-INFO', '*.egg-info')
+
+
+# (c) 2005 Ian Bicking and contributors; written for Paste (http://pythonpaste.org)
+# Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
+# Note: you may want to copy this into your setup.py file verbatim, as
+# you can't import this from another package, when you don't know if
+# that package is installed yet.
+def find_package_data(
+    where='.', package='',
+    exclude=standard_exclude,
+    exclude_directories=standard_exclude_directories,
+    only_in_packages=True,
+    show_ignored=False):
+    """
+    Return a dictionary suitable for use in ``package_data``
+    in a distutils ``setup.py`` file.
+
+    The dictionary looks like::
+
+        {'package': [files]}
+
+    Where ``files`` is a list of all the files in that package that
+    don't match anything in ``exclude``.
+
+    If ``only_in_packages`` is true, then top-level directories that
+    are not packages won't be included (but directories under packages
+    will).
+
+    Directories matching any pattern in ``exclude_directories`` will
+    be ignored; by default directories with leading ``.``, ``CVS``,
+    and ``_darcs`` will be ignored.
+
+    If ``show_ignored`` is true, then all the files that aren't
+    included in package data are shown on stderr (for debugging
+    purposes).
+
+    Note patterns use wildcards, or can be exact paths (including
+    leading ``./``), and all searching is case-insensitive.
+    """
+
+    out = {}
+    stack = [(convert_path(where), '', package, only_in_packages)]
+    while stack:
+        where, prefix, package, only_in_packages = stack.pop(0)
+        for name in os.listdir(where):
+            fn = os.path.join(where, name)
+            if os.path.isdir(fn):
+                bad_name = False
+                for pattern in exclude_directories:
+                    if (fnmatchcase(name, pattern)
+                        or fn.lower() == pattern.lower()):
+                        bad_name = True
+                        if show_ignored:
+                            print >> sys.stderr, (
+                                "Directory %s ignored by pattern %s"
+                                % (fn, pattern))
+                        break
+                if bad_name:
+                    continue
+                if (os.path.isfile(os.path.join(fn, '__init__.py'))
+                    and not prefix):
+                    if not package:
+                        new_package = name
+                    else:
+                        new_package = package + '.' + name
+                    stack.append((fn, '', new_package, False))
+                else:
+                    stack.append((fn, prefix + name + '/', package, only_in_packages))
+            elif package or not only_in_packages:
+                # is a file
+                bad_name = False
+                for pattern in exclude:
+                    if (fnmatchcase(name, pattern)
+                        or fn.lower() == pattern.lower()):
+                        bad_name = True
+                        if show_ignored:
+                            print >> sys.stderr, (
+                                "File %s ignored by pattern %s"
+                                % (fn, pattern))
+                        break
+                if bad_name:
+                    continue
+                out.setdefault(package, []).append(prefix+name)
+    return out
+
+
+setup(
+    name="django-private-media",
+    version=find_version("private_media", "__init__.py"),
+    description="A Django app that provides helpers for serving private media files.",
+    long_description=read("README.rst"),
+    author="David Bennett",
+    author_email="david@dbinit.com",
+    license="BSD",
+    url="http://django-private-media.readthedocs.org/",
+    packages=find_packages(),
+    package_data=find_package_data(),
+    classifiers=[
+        "Development Status :: 4 - Beta",
+        "Environment :: Web Environment",
+        "Intended Audience :: Developers",
+        "License :: OSI Approved :: BSD License",
+        "Operating System :: OS Independent",
+        "Programming Language :: Python",
+        'Programming Language :: Python :: 2.5',
+        'Programming Language :: Python :: 2.6',
+        'Programming Language :: Python :: 2.7',
+        "Framework :: Django",
+    ],
+    zip_safe=False,
+    install_requires=[
+        'django-appconf >= 0.4',
+    ],
+)
+[tox]
+distribute = False
+envlist =
+    py25-1.2.X, py26-1.2.X, py27-1.2.X,
+    py25-1.3.X, py26-1.3.X, py27-1.3.X,
+    py25, py26, py27, docs
+
+[testenv]
+downloadcache = {toxworkdir}/_download/
+commands =
+    {envbindir}/python {envbindir}/django-admin.py jenkins {posargs:tests}
+setenv =
+    DJANGO_SETTINGS_MODULE = private_media.test_settings
+
+
+[testenv:docs]
+basepython = python2.7
+deps =
+    Sphinx==1.1.2
+    Django==1.3.1
+commands =
+    rm -rf docs/_build
+    {envbindir}/sphinx-build -b html -d docs/_build/doctrees docs docs/_build/html
+
+
+[testenv:py25-1.2.X]
+basepython = python2.5
+deps =
+    Django==1.2.4
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2
+
+[testenv:py26-1.2.X]
+basepython = python2.6
+deps =
+    Django==1.2.4
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2
+
+[testenv:py27-1.2.X]
+basepython = python2.7
+deps =
+    Django==1.2.4
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2
+
+
+[testenv:py25-1.3.X]
+basepython = python2.5
+deps =
+    Django==1.3.1
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2
+
+[testenv:py26-1.3.X]
+basepython = python2.6
+deps =
+    Django==1.3.1
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2
+
+[testenv:py27-1.3.X]
+basepython = python2.7
+deps =
+    Django==1.3.1
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2
+
+
+[testenv:py25]
+basepython = python2.5
+deps =
+    https://github.com/django/django/zipball/master
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2
+
+[testenv:py26]
+basepython = python2.6
+deps =
+    https://github.com/django/django/zipball/master
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2
+
+[testenv:py27]
+basepython = python2.7
+deps =
+    https://github.com/django/django/zipball/master
+    pep8
+    pyflakes
+    django-jenkins
+    unittest2