Skip to content

Commit

Permalink
Added working management command wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
1stvamp committed Feb 16, 2011
1 parent 40127da commit 72c1ec2
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 57 deletions.
2 changes: 0 additions & 2 deletions src/dfs/__init__.py → dfs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#template_scaffold.py
"""
Wrapper to call scaffold from the commandline to dynamically generate::
from dfs import scaffold
Expand All @@ -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))
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file added dfs/tests.py
Empty file.
39 changes: 18 additions & 21 deletions setup.py
Original file line number Diff line number Diff line change
@@ -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,
)
23 changes: 0 additions & 23 deletions src/dfs/form_scaffold/tests.py

This file was deleted.

0 comments on commit 72c1ec2

Please sign in to comment.