Exemplo n.º 1
0
def validate_project(project_item):
    '''Make sure the project does not already exist.'''

    if os.path.exists(project_item['path']):
        raise Abort('Project already exists: %s' % project_item['path'])

    return True
Exemplo n.º 2
0
def validate_collection(collection_item):
    '''Make sure new collection does not exist'''

    if os.path.exists(collection_item['path']):
        raise Abort('collection already exists: ' + collection_item['name'])

    return True
Exemplo n.º 3
0
def save_next_workfile(ctx, publish_items):
    '''Save the next workfile.'''

    host = get_host()
    scene = publish_items['scene']

    # Get the next version number for the original scene name
    if ctx.workspace:
        next_version = ctx.workspace.get_next_version(
            scene['scene_data']['name'],
            scene['scene_data']['ext'],
        )
    else:
        next_version = int(scene['scene_data']['version']) + 1

    # Construct the next scene_file path
    next_scene_name = scene['scene_file'].replace(
        scene['scene_data']['version'],
        '{:0>3d}'.format(next_version),
    )
    next_scene_file = utils.unipath(scene['scene_root'], next_scene_name)

    # If the path already exists Abort...
    if os.path.isfile(next_scene_file):
        raise Abort('Next scene file already exists. Reopening workfile.')

    # Copy the original scene file to the next version
    shutil.copy2(scene['scene_file'], next_scene_file)

    return next_scene_file
Exemplo n.º 4
0
def validate_scene(publish_items):
    '''Validate the scene file.'''

    # Ensure publish scene does not exist
    scene = publish_items['scene']
    if os.path.isfile(scene['publish_file']):
        raise Abort('Publish file already exists: %s' %
                    os.path.basename(scene['publish_file']))
Exemplo n.º 5
0
def validate_task(task_item):
    '''Validate potential task'''

    if os.path.exists(task_item['path']):
        raise Abort('Task already exists: ' + task_item['name'])
    return True
Exemplo n.º 6
0
def validate_workspace(workspace_item):
    '''Validate potential workspace'''

    if os.path.exists(workspace_item['path']):
        raise Abort('Task already exists: ' + workspace_item['name'])
    return True
Exemplo n.º 7
0
def validate_shot(shot_item):
    '''Make sure shot does not exist'''

    if os.path.exists(shot_item['path']):
        raise Abort('Shot already exists: ' + shot_item['name'])
    return True
Exemplo n.º 8
0
def validate_sequence(sequence_item):
    '''Make sure new sequence does not exist.'''

    if os.path.exists(sequence_item['path']):
        raise Abort('Sequence already exists: ' + sequence_item['name'])
    return True
Exemplo n.º 9
0
def validate_asset_type(asset_type):
    '''Make sure new asset_type does not already exist'''

    if asset_type.exists:
        raise Abort('Asset Type already exists: %s' % asset_type.name)
    return True
Exemplo n.º 10
0
def validate_asset(asset_item):
    '''Make sure new asset does not exist'''

    if os.path.exists(asset_item['path']):
        raise Abort('Asset already exists: ' + asset_item['name'])
    return True
Exemplo n.º 11
0
def validate_template(template):
    '''Make sure template does not already exist'''

    if (os.path.exists(template.path)
            or template.name in construct.get_templates()):
        raise Abort('Template already exists: ' + template.name)