(job, data)
Insert file from data dict into database.

    # Only file is required, it can be a directory as well.
    [[settings.create]]
    file = runlog
    uid =
    name
    text =
    type =

     # List of files
    {'settings': {'create': [ {'file':'foo', }, {'file':'bar'} ]  }
Insert file from data dict into database.
Insert file from data dict into database .
def finalize_job(job, data):
    """
    Insert file from data dict into database.

    # Only file is required, it can be a directory as well.
    [[settings.create]]
    file = runlog
    uid =
    name
    text =
    type =

     # List of files
    {'settings': {'create': [ {'file':'foo', }, {'file':'bar'} ]  }

    """

    # Get files intended for insertion.
    create = data.get("settings", {}).get("create", [])
    root = job.path
    project = job.project

    for create_using in create:

        # Create full path using the file.
        fname = create_using.get("file", '')
        fname = fname.strip()
        fullpath = os.path.abspath(os.path.join(root, fname))

        # Ensure the file path is valid.
        valid = len(fname) and os.path.exists(fullpath) and fullpath.startswith(root)

        if not valid:
            raise FileNotFoundError(f"File: {fname} does not exist.")

        # Add the full path and project to data dict.
        create_using.update({"file": fullpath, "project": project})

        auth.get_or_create(**create_using)
def finalize_job ( job , data ) : # Get files intended for insertion. create = data . get ( "settings" , { } ) . get ( "create" , [ ] ) root = job . path project = job . project for create_using in create : # Create full path using the file. fname = create_using . get ( "file" , '' ) fname = fname . strip ( ) fullpath = os . path . abspath ( os . path . join ( root , fname ) ) # Ensure the file path is valid. valid = len ( fname ) and os . path . exists ( fullpath ) and fullpath . startswith ( root ) if not valid : raise FileNotFoundError ( f"File: {fname} does not exist." ) # Add the full path and project to data dict. create_using . update ( { "file" : fullpath , "project" : project } ) auth . get_or_create ( * * create_using )