Skip to content

Commit

Permalink
Added example importing of boundaryservice.utils to definitions.py bo…
Browse files Browse the repository at this point in the history
…ilerplate.
  • Loading branch information
onyxfish committed Aug 17, 2011
1 parent fe7c730 commit 9669a39
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions boundaryservice/management/commands/startshapedefinitions.py
Expand Up @@ -39,14 +39,16 @@ def handle(self, *args, **options):
raise CommandError("The shapefiles directory does not exist. Create it or specify a different directory.")
def_path = os.path.join(options['data_dir'], "definitions.py")
if os.path.exists(def_path) and not options.get("force"):
raise CommandError("Sorry, %s already exists." % def_path)
raise CommandError("%s already exists." % def_path)
outfile = open(def_path, "w")
outfile.write(BOILERPLATE)
outfile.close()
logging.info('Created definitions.py in %s' % options['data_dir'])

BOILERPLATE = """from datetime import date
from boundaryservice import utils
SHAPEFILES = {
# This key should be the plural name of the boundaries in this set
'City Council Districts': {
Expand All @@ -58,9 +60,9 @@ def handle(self, *args, **options):
'kind_first': False,
# Function which each feature wall be passed to in order to extract its "external_id" property
# The utils module contains several generic functions for doing this
'ider': None,
'ider': utils.simple_namer(['DISTRICT']),
# Function which each feature will be passed to in order to extract its "name" property
'namer': None,
'namer': utils.simple_namer(['NAME']),
# Authority that is responsible for the accuracy of this data
'authority': 'Tyler GIS Department',
# Geographic extents which the boundary set encompasses
Expand Down

0 comments on commit 9669a39

Please sign in to comment.