Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(6)  |  Call(6)  |  Derive(0)  |  Import(0)
Generates various useful things for you to get you started.

lamson gen -project STR -FORCE False

        def gen_command(project=None, FORCE=False):
    """
    Generates various useful things for you to get you started.

    lamson gen -project STR -FORCE False
    """
    project = project

    if os.path.exists(project) and not FORCE:
        print "Project %s exists, delete it first." % project
        sys.exit(1)
        return

    prototype = ZipFile(resource_stream(__name__, 'data/prototype.zip'))
    # looks like the very handy ZipFile.extractall is only in python 2.6

    if not os.path.exists(project):
        os.makedirs(project)

    files = prototype.namelist()

    for gen_f in files:
        if str(gen_f).endswith('/'):
            target = os.path.join(project, gen_f)
            if not os.path.exists(target):
                print "mkdir: %s" % target
                os.makedirs(target)
        else:
            target = os.path.join(project, gen_f)
            if os.path.exists(target): 
                continue

            print "copy: %s" % target
            out = open(target, 'w')
            out.write(prototype.read(gen_f))
            out.close()
        


src/l/a/lamson-1.3.4/tests/lamson_tests/command_tests.py   lamson(Download)
        shutil.rmtree(project)
 
    commands.gen_command(project=project)
    assert os.path.exists(project)
 
    # test that it exits if the project exists
    commands.gen_command(project=project)
 
    sys.exit.reset_mock()
    commands.gen_command(project=project, FORCE=True)
    assert not sys.exit.called
 

src/l/a/lamson-HEAD/tests/lamson_tests/command_tests.py   lamson(Download)
        shutil.rmtree(project)
 
    commands.gen_command(project=project)
    assert os.path.exists(project)
 
    # test that it exits if the project exists
    commands.gen_command(project=project)
 
    sys.exit.reset_mock()
    commands.gen_command(project=project, FORCE=True)
    assert not sys.exit.called