# Path: pupa/cli/commands/base.py
# class BaseCommand(object):
# 
#     def __init__(self, subparsers):
#         self.subparser = subparsers.add_parser(self.name, description=self.help)
#         self.add_args()
# 
#     def add_args(self):
#         pass
# 
#     def add_argument(self, *args, **kwargs):
#         self.subparser.add_argument(*args, **kwargs)
# 
#     def handle(self, args):
#         raise NotImplementedError('commands must implement handle(args)')
# 
# Path: pupa/exceptions.py
# class CommandError(PupaError):
#     """ Errors from within pupa CLI """


import os
from .base import BaseCommand
from pupa.exceptions import CommandError
from opencivicdata.common import JURISDICTION_CLASSIFICATIONS
from opencivicdata.divisions import Division
        lines.append('')
        lines.append('    def scrape(self):')
        lines.append('        # needs to be implemented')
        lines.append('        pass')
        lines.append('')
        with open(os.path.join(dirname, stype + '.py'), 'w') as of:
            of.write('\n'.join(lines))


class Command(BaseCommand):
    name = 'init'
    help = 'start a new pupa scraper'

    def add_args(self):
        self.add_argument('module', type=str, help='name of the new scraper module')

    def handle(self, args, other):
        if os.path.exists(args.module):
            raise CommandError('Directory {} already exists'.format(repr(args.module)))

        division = None
        while not division:
            division = prompt('division id (see https://github.com/opencivicdata/'
                              'ocd-division-ids/tree/master/identifiers): ')
            if not division:
                print("\nERROR: Division ID is required.\n")

        try:
            Division.get(division)
        except (ValueError, IndexError):

# Path: pupa/cli/commands/base.py
# class BaseCommand(object):
# 
#     def __init__(self, subparsers):
#         self.subparser = subparsers.add_parser(self.name, description=self.help)
#         self.add_args()
# 
#     def add_args(self):
#         pass
# 
#     def add_argument(self, *args, **kwargs):
#         self.subparser.add_argument(*args, **kwargs)
# 
#     def handle(self, args):
#         raise NotImplementedError('commands must implement handle(args)')
# 
# Path: pupa/exceptions.py
# class CommandError(PupaError):
#     """ Errors from within pupa CLI """


# Path: pupa/cli/commands/init.py
import os
from .base import BaseCommand
from pupa.exceptions import CommandError
from opencivicdata.common import JURISDICTION_CLASSIFICATIONS
from opencivicdata.divisions import Division

        lines.append('')
        lines.append('    def scrape(self):')
        lines.append('        # needs to be implemented')
        lines.append('        pass')
        lines.append('')
        with open(os.path.join(dirname, stype + '.py'), 'w') as of:
            of.write('\n'.join(lines))


class Command(BaseCommand):
    name = 'init'
    help = 'start a new pupa scraper'

    def add_args(self):
        self.add_argument('module', type=str, help='name of the new scraper module')

    def handle(self, args, other):
        if os.path.exists(args.module):
            raise CommandError('Directory {} already exists'.format(repr(args.module)))

        division = None
        while not division:
            division = prompt('division id (see https://github.com/opencivicdata/'
                              'ocd-division-ids/tree/master/identifiers): ')
            if not division:
                print("\nERROR: Division ID is required.\n")

        try:
            Division.get(division)
        except (ValueError, IndexError):

            raise CommandError('Division ID {} is invalid'.format(repr(division)))