Init project, mostly from template
This commit is contained in:
parent
d865cada51
commit
8c0ededb16
9 changed files with 150 additions and 0 deletions
6
build
Normal file
6
build
Normal file
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
pyvenv-3.4 env
|
||||
env/bin/pip install -r requirements.txt --upgrade
|
0
django_client_reverse/__init__.py
Normal file
0
django_client_reverse/__init__.py
Normal file
11
django_client_reverse/tests.py
Normal file
11
django_client_reverse/tests.py
Normal file
|
@ -0,0 +1,11 @@
|
|||
from rest_framework.test import APITestCase
|
||||
from django.core.urlresolvers import reverse
|
||||
|
||||
|
||||
class ReverserTestCase(APITestCase):
|
||||
def setUp(self):
|
||||
super().setUp()
|
||||
|
||||
def test_thing(self):
|
||||
response = self.client.get(reverse('reverser'))
|
||||
print(response)
|
5
django_client_reverse/urls.py
Normal file
5
django_client_reverse/urls.py
Normal file
|
@ -0,0 +1,5 @@
|
|||
from django.conf.urls import include, url
|
||||
from .views import Reverser
|
||||
urlpatterns = [
|
||||
url(r'^$', Reverser.as_view(), name="reverser")
|
||||
]
|
10
django_client_reverse/views.py
Normal file
10
django_client_reverse/views.py
Normal file
|
@ -0,0 +1,10 @@
|
|||
from rest_framework.views import APIView
|
||||
from rest_framework.response import Response
|
||||
from rest_framework.renderers import JSONRenderer
|
||||
|
||||
|
||||
class Reverser(APIView):
|
||||
renderer_classes = (JSONRenderer,)
|
||||
|
||||
def get(self, request, format=None):
|
||||
return Response("Response")
|
10
manage.py
Executable file
10
manage.py
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testsettings")
|
||||
|
||||
from django.core.management import execute_from_command_line
|
||||
|
||||
execute_from_command_line(sys.argv)
|
3
requirements.txt
Normal file
3
requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
Django==1.8.7
|
||||
djangorestframework==3.3.1
|
||||
dj-database-url==0.3.0
|
81
setup.py
Normal file
81
setup.py
Normal file
|
@ -0,0 +1,81 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import print_function
|
||||
from setuptools import setup
|
||||
import re
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
name = 'django-client-reverse'
|
||||
package = 'django_client_reverse'
|
||||
description = 'Django module to access URL reversing client-side'
|
||||
url = 'https://github.com/RealOrangeOne/'
|
||||
author = 'TheOrangeOne'
|
||||
author_email = 'git@theorangeone.net'
|
||||
license = 'BSD'
|
||||
install_requires = [
|
||||
"Django>=1.8",
|
||||
"djangorestframework>=3.3.0",
|
||||
]
|
||||
|
||||
long_description = description
|
||||
|
||||
def get_version(package):
|
||||
"""
|
||||
Return package version as listed in `__version__` in `init.py`.
|
||||
"""
|
||||
init_py = open(os.path.join(package, '__init__.py')).read()
|
||||
return re.search("^__version__ = ['\"]([^'\"]+)['\"]", init_py, re.MULTILINE).group(1)
|
||||
|
||||
|
||||
def get_packages(package):
|
||||
"""
|
||||
Return root package and all sub-packages.
|
||||
"""
|
||||
return [dirpath
|
||||
for dirpath, dirnames, filenames in os.walk(package)
|
||||
if os.path.exists(os.path.join(dirpath, '__init__.py'))]
|
||||
|
||||
|
||||
def get_package_data(package):
|
||||
"""
|
||||
Return all files under the root package, that are not in a
|
||||
package themselves.
|
||||
"""
|
||||
walk = [(dirpath.replace(package + os.sep, '', 1), filenames)
|
||||
for dirpath, dirnames, filenames in os.walk(package)
|
||||
if not os.path.exists(os.path.join(dirpath, '__init__.py'))]
|
||||
|
||||
filepaths = []
|
||||
for base, filenames in walk:
|
||||
filepaths.extend([os.path.join(base, filename)
|
||||
for filename in filenames])
|
||||
return {package: filepaths}
|
||||
|
||||
|
||||
if sys.argv[-1] == 'publish':
|
||||
os.system("python setup.py sdist upload")
|
||||
args = {'version': get_version(package)}
|
||||
print("You probably want to also tag the version now:")
|
||||
print(" git tag -a %(version)s -m 'version %(version)s'" % args)
|
||||
print(" git push --tags")
|
||||
sys.exit()
|
||||
|
||||
|
||||
setup(
|
||||
name=name,
|
||||
version=get_version(package),
|
||||
url=url,
|
||||
license=license,
|
||||
description=description,
|
||||
long_description=long_description,
|
||||
author=author,
|
||||
author_email=author_email,
|
||||
packages=get_packages(package),
|
||||
package_data=get_package_data(package),
|
||||
install_requires=install_requires,
|
||||
classifiers=[
|
||||
]
|
||||
)
|
24
testsettings.py
Normal file
24
testsettings.py
Normal file
|
@ -0,0 +1,24 @@
|
|||
import os
|
||||
|
||||
import dj_database_url
|
||||
DATABASES = {'default': dj_database_url.config(default="sqlite://memory")}
|
||||
|
||||
INSTALLED_APPS = (
|
||||
'django.contrib.auth',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.contenttypes',
|
||||
'django_client_reverse'
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
)
|
||||
|
||||
SECRET_KEY = 'abcde12345'
|
||||
|
||||
ROOT_URLCONF = 'django_client_reverse.urls'
|
Reference in a new issue