Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added working management command wrapper

  • Loading branch information...
commit 72c1ec294c8a23be58f68a643f13716a4f32114b 1 parent 40127da
@1stvamp authored
View
2  src/dfs/__init__.py → dfs/__init__.py
@@ -3,8 +3,6 @@
from numbers import Number
class sale(Number):
- print u'MASSIVE 20% SALE ON ALL ITEMS MARKED sale()'
-
def _arith(self, other):
if other > 1:
sub = other * 0.2
View
0  ...dfs/form_scaffold/management/commands/__init__.py → dfs/management/__init__.py
File renamed without changes
View
0  src/dfs/form_scaffold/management/__init__.py → dfs/management/commands/__init__.py
File renamed without changes
View
23 ...orm_scaffold/management/commands/form_scaffold.py → dfs/management/commands/formscaffold.py
@@ -1,4 +1,3 @@
-#template_scaffold.py
"""
Wrapper to call scaffold from the commandline to dynamically generate::
from dfs import scaffold
@@ -8,22 +7,24 @@
"""
from dfs import scaffold
-from optparse import make_option
from django.core.management.base import BaseCommand, CommandError
+def do_import(name):
+ mod = __import__(name)
+ components = name.split('.')
+ for comp in components[1:]:
+ mod = getattr(mod, comp)
+ return mod
+
class Command(BaseCommand):
- args = '<form_source> <form_name> <output_type>'
- help = """Wrapper to call form scaffolding from the commandline and output
-static markup for a Django form, e.g.:
-python manage.py form_scaffold my_app.forms MyCustomForm as_ul
-"""
+ help = "Wrapper to call form scaffolding from the commandline, e.g.\nformscaffold my_app.forms MyForm as_p"
+ args = "<form module> <form class name> <output type>"
def handle(self, *args, **options):
- form_sources = args[0]
+ module_path = args[0]
form_name = args[1]
output_type = args[2]
scaffolder = getattr(scaffold, output_type)
- form = __import__(form_name)
- print scaffolder(form)
-
+ form = getattr(do_import(module_path), form_name)
+ self.stdout.write(scaffolder(cls=form))
View
0  src/dfs/form_scaffold/__init__.py → dfs/models.py
File renamed without changes
View
0  src/dfs/scaffold.py → dfs/scaffold.py
File renamed without changes
View
0  src/dfs/sofa.py → dfs/sofa.py
File renamed without changes
View
0  dfs/tests.py
No changes.
View
39 setup.py
@@ -1,25 +1,22 @@
"""Installer for django-form-scaffold"""
-try:
- from setuptools import setup, find_packages
-except ImportError:
- from ez_setup import use_setuptools
- use_setuptools()
- from setuptools import setup, find_packages
+from setuptools import setup, find_packages
+
setup(
- name='django-form-scaffold',
- description='Helper functions for generating templated markup of Django forms',
- version='1.1.0',
- author='Wes Mason',
- author_email='wes[at]1stvamp[dot]org',
- url='http://github.com/1stvamp/django-form-scaffold',
- packages=find_packages('src', exclude=['ez_setup']),
- package_dir={'': 'src'},
- setup_requires=(
- 'django>=1.1',
- ),
- provides=(
- 'dfs',
- ),
- license='Apache License 2.0'
+ name='django-form-scaffold',
+ description='Helper functions for generating templated markup of Django forms',
+ version='1.1.0',
+ author='Wes Mason',
+ author_email='wes[at]1stvamp[dot]org',
+ url='http://github.com/1stvamp/django-form-scaffold',
+ packages=find_packages(),
+ license='Apache License 2.0',
+ classifiers=(
+ 'Framework :: Django',
+ 'Intended Audience :: Developers',
+ 'Intended Audience :: System Administrators',
+ 'Operating System :: OS Independent',
+ 'Topic :: Software Development',
+ ),
+ zip_safe=False,
)
View
23 src/dfs/form_scaffold/tests.py
@@ -1,23 +0,0 @@
-"""
-This file demonstrates two different styles of tests (one doctest and one
-unittest). These will both pass when you run "manage.py test".
-
-Replace these with more appropriate tests for your application.
-"""
-
-from django.test import TestCase
-
-class SimpleTest(TestCase):
- def test_basic_addition(self):
- """
- Tests that 1 + 1 always equals 2.
- """
- self.failUnlessEqual(1 + 1, 2)
-
-__test__ = {"doctest": """
-Another way to test that 1 + 1 is equal to 2.
-
->>> 1 + 1 == 2
-True
-"""}
-
Please sign in to comment.
Something went wrong with that request. Please try again.