Permalink
Browse files

Initial implementation.

  • Loading branch information...
0 parents commit 9144e9b5a9ba8f233258a752bb0bcec1c3f4f2a5 @streeter committed Jun 7, 2012
Showing with 1,235 additions and 0 deletions.
  1. +23 −0 .gitignore
  2. +23 −0 .travis.yml
  3. +1 −0 AUTHORS
  4. +28 −0 LICENSE
  5. +6 −0 MANIFEST.in
  6. +3 −0 Makefile
  7. +41 −0 README.rst
  8. +4 −0 requirements/tests.txt
  9. +136 −0 setup.py
  10. +2 −0 uploadstatic/__init__.py
  11. 0 uploadstatic/management/__init__.py
  12. 0 uploadstatic/management/commands/__init__.py
  13. +133 −0 uploadstatic/management/commands/uploadstatic.py
  14. 0 uploadstatic/models.py
  15. +42 −0 uploadstatic/test_settings.py
  16. 0 uploadstatic/tests/__init__.py
  17. 0 uploadstatic/tests/apps/__init__.py
  18. 0 uploadstatic/tests/apps/test/__init__.py
  19. 0 uploadstatic/tests/apps/test/models.py
  20. +1 −0 uploadstatic/tests/apps/test/otherdir/odfile.txt
  21. +1 −0 uploadstatic/tests/apps/test/static/test/CVS
  22. +1 −0 uploadstatic/tests/apps/test/static/test/file.txt
  23. +1 −0 uploadstatic/tests/apps/test/static/test/file1.txt
  24. +1 −0 uploadstatic/tests/apps/test/static/test/test.ignoreme
  25. +1 −0 uploadstatic/tests/apps/test/static/test/test_absolute.ignoreme3
  26. +1 −0 uploadstatic/tests/apps/test/static/test/test_relative.ignoreme2
  27. 0 uploadstatic/tests/models.py
  28. +1 −0 uploadstatic/tests/project/documents/cached/absolute.css
  29. +1 −0 uploadstatic/tests/project/documents/cached/css/fonts/font.eot
  30. +1 −0 uploadstatic/tests/project/documents/cached/css/fonts/font.svg
  31. +8 −0 uploadstatic/tests/project/documents/cached/css/fragments.css
  32. BIN uploadstatic/tests/project/documents/cached/css/img/window.png
  33. +3 −0 uploadstatic/tests/project/documents/cached/css/window.css
  34. +1 −0 uploadstatic/tests/project/documents/cached/denorm.css
  35. BIN uploadstatic/tests/project/documents/cached/img/relative.png
  36. 0 uploadstatic/tests/project/documents/cached/other.css
  37. +5 −0 uploadstatic/tests/project/documents/cached/relative.css
  38. +1 −0 uploadstatic/tests/project/documents/cached/styles.css
  39. +1 −0 uploadstatic/tests/project/documents/cached/url.css
  40. +1 −0 uploadstatic/tests/project/documents/ignored/test_directory.txt
  41. +1 −0 uploadstatic/tests/project/documents/subdir/test.txt
  42. +1 −0 uploadstatic/tests/project/documents/test.txt
  43. +1 −0 uploadstatic/tests/project/documents/test/camelCase.txt
  44. +2 −0 uploadstatic/tests/project/documents/test/file.txt
  45. +1 −0 uploadstatic/tests/project/documents/test/test.ignoreme4
  46. +1 −0 uploadstatic/tests/project/documents/test/test_absolute.ignoreme6
  47. +1 −0 uploadstatic/tests/project/documents/test/test_relative.ignoreme5
  48. +1 −0 uploadstatic/tests/project/prefixed/test.ignoreme7
  49. +1 −0 uploadstatic/tests/project/prefixed/test.txt
  50. 0 uploadstatic/tests/project/site_media/media/media-file.txt
  51. +1 −0 uploadstatic/tests/project/templates/404.html
  52. +20 −0 uploadstatic/tests/storage.py
  53. +661 −0 uploadstatic/tests/tests.py
  54. 0 uploadstatic/tests/urls/__init__.py
  55. +5 −0 uploadstatic/tests/urls/default.py
  56. +4 −0 uploadstatic/tests/urls/helper.py
  57. +62 −0 uploadstatic/utils.py
@@ -0,0 +1,23 @@
+*.pyc
+*.pyo
+*.swp
+*.orig
+*.kpf
+*.egg-info
+.project
+.pydevproject
+.DS_Store
+MANIFEST
+dist
+build
+dev.db
+local_settings.py
+eggs/*
+downloads/*
+.installed.cfg
+bin/*
+develop-eggs/*.egg-link
+docs/_build
+tests/project/site_media/static/*
+*.egg
+.coverage
@@ -0,0 +1,23 @@
+language: python
+python:
+ - "2.5"
+ - "2.6"
+ - "2.7"
+before_install:
+ - export PIP_USE_MIRRORS=true
+ - export PIP_INDEX_URL=https://simple.crate.io/
+ - export DJANGO_SETTINGS_MODULE=uploadstatic.test_settings
+install:
+ - pip install -e .
+ - pip install -r requirements/tests.txt Django==$DJANGO
+before_script:
+ - flake8 uploadstatic --ignore=E501
+script:
+ - make test
+env:
+ - DJANGO=1.2.7
+ - DJANGO=1.3.1
+ - DJANGO=1.4
+branches:
+ only:
+ - master
@@ -0,0 +1 @@
+Chris Streeter <chris@chrisstreeter.com>
28 LICENSE
@@ -0,0 +1,28 @@
+Copyright (c) 2012, Chris Streeter 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.
@@ -0,0 +1,6 @@
+include AUTHORS
+include LICENSE
+include README.rst
+recursive-include docs *
+recursive-include uploadstatic/tests *
+global-exclude *.pyc
@@ -0,0 +1,3 @@
+test:
+ coverage run --branch --source=uploadstatic `which django-admin.py` test --settings=uploadstatic.test_settings uploadstatic
+ coverage report --omit=uploadstatic/test*
@@ -0,0 +1,41 @@
+===================
+django-uploadstatic
+===================
+
+This is a Django app that provides helpers for uploading static files.
+
+It is based off of `github.com/jezdez/django-staticfiles`_
+but only uploads all the files in the collected `STATIC_ROOT` to S3 using
+the ``storages.backends.s3boto.S3BotoStorage`` storage backend in the
+``django-storages``.
+
+Installation
+------------
+
+- Use your favorite Python packaging tool to install ``uploadstatic``
+ from `PyPI`_, e.g.::
+
+ pip install django-uploadstatic
+
+- Added ``"uploadstatic"`` to your ``INSTALLED_APPS`` setting::
+
+ INSTALLED_APPS = [
+ # ...
+ "uploadstatic",
+ ]
+
+- Set your ``STATIC_URL`` setting to the URL that handles serving
+ static files from S3::
+
+ STATIC_URL = "https://s3.amazonaws.com/some-domain/"
+
+- Once you are ready to upload all static files that have been collecte in your
+ site's ``STATIC_ROOT``, use the ``uploadstatic`` management
+ command::
+
+ python manage.py uploadstatic
+
+ Then your files will be accessible from the ``STATIC_URL`` setting.
+
+.. _github.com/jezdez/django-staticfiles: http://github.com/jezdez/django-staticfiles
+.. _PyPI: http://pypi.python.org/pypi/django-uploadstatic
@@ -0,0 +1,4 @@
+flake8
+django-discover-runner
+coverage
+unittest2
136 setup.py
@@ -0,0 +1,136 @@
+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-uploadstatic",
+ version=find_version("uploadstatic", "__init__.py"),
+ description="A Django app that provides helpers for uploading static files.",
+ long_description=read("README.rst"),
+ author="Chris Streeter",
+ author_email="chris@chrisstreeter.com",
+ license="BSD",
+ url="http://github.com/streeter/django-uploadstatic",
+ packages=find_packages(),
+ package_data=find_package_data(),
+ classifiers=[
+ "Development Status :: 5 - Production/Stable",
+ "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,
+)
@@ -0,0 +1,2 @@
+# following PEP 386
+__version__ = "0.1.0"
No changes.
No changes.
Oops, something went wrong.

0 comments on commit 9144e9b

Please sign in to comment.