Exemplo n.º 1
0
    def run(self, args, options):
        if len(args) != 1:
            raise UsageError()
        project_name = args[0]
        if not re.search(r'^[_a-zA-Z]\w*$', project_name):
            print(
                'Error: Project names must begin with a letter and contain '
                'only letters, numbers and underscores')
            sys.exit(1)
        elif os.path.exists(project_name):
            print 'Error: directory %r already exists' % project_name
            sys.exit(1)

        module_tmpl = os.path.join(_templates_path, 'module')
        copytree(module_tmpl,
                 os.path.join(project_name, project_name),
                 ignore=_ignore)
        shutil.copy(os.path.join(_templates_path, 'crawlmi.cfg'), project_name)
        for paths in _templates_to_render:
            path = os.path.join(*paths)
            file_tmpl = os.path.join(
                project_name,
                string.Template(path).substitute(project_name=project_name))
            render_templatefile(file_tmpl,
                                project_name=project_name,
                                ProjectName=string_camelcase(project_name))
Exemplo n.º 2
0
    def run(self, args, options):
        if len(args) != 1:
            raise UsageError()
        project_name = args[0]
        if not re.search(r'^[_a-zA-Z]\w*$', project_name):
            print ('Error: Project names must begin with a letter and contain '
                   'only letters, numbers and underscores')
            sys.exit(1)
        elif os.path.exists(project_name):
            print 'Error: directory %r already exists' % project_name
            sys.exit(1)

        module_tmpl = os.path.join(_templates_path, 'module')
        copytree(module_tmpl, os.path.join(project_name, project_name), ignore=_ignore)
        shutil.copy(os.path.join(_templates_path, 'crawlmi.cfg'), project_name)
        for paths in _templates_to_render:
            path = os.path.join(*paths)
            file_tmpl = os.path.join(
                project_name,
                string.Template(path).substitute(project_name=project_name))
            render_templatefile(
                file_tmpl,
                project_name=project_name,
                ProjectName=string_camelcase(project_name))
Exemplo n.º 3
0
 def test_string_camelcase(self):
     self.assertEqual(string_camelcase('lost-pound'), 'LostPound')
     self.assertEqual(string_camelcase('missing_images'), 'MissingImages')