File data model

Todo

Description...

class File(*args, **values)[source]
basename

The filename without extension.

classmethod build_elastic_query(term, multilingual=True)[source]

Build a search query for a term.

Parameters:
  • term (str) – The search term.
  • multilingual (bool) – Set to False to search only the current language.
clear_thumbnails()[source]

Remove all cached thumbnails.

clone(**kwargs)[source]

Copy this file or folder.

Parameters:path (str) – New path where the copy should be saved.
Returns:A clone of this File.
Return type:xmm.models.File
classmethod find_referencing_models()[source]

Find models that should be searched for references of this class.

classmethod from_field_map(field_map, dataset, is_list=False)[source]

Find an instance by looking up fields in a referencing dataset.

get_meta_data[source]

Read the EXIF data from the file.

Return type:list

Example of a result:

[{
    'category': 'category1',
    'tags': [{
        'tag': 'tag1',
        'value': 'value1'
    }, {
        'tag': 'tag2',
        'value': 'value2'
    }]
}, {
    'category': 'category2',
    'tags': [{
        'tag': 'tag1',
        'value': 'value1'
    }]
}]
get_thumbnail_path(size)[source]

Get absolute path to the thumbnail.

image_dimensions[source]

Get the image pixel size as a (width, height) tuple.

classmethod iter_tree_nodes(parent, order_by=None)[source]

Generator that loops over the subnodes of a given parent.

Parameters:parent (str) – Iterate over this node’s children
move_to(parent, pos=None)[source]

Move the specified node to a new parent.

TODO: This deletes any existing file in the target directory with the same name. This should be configurable.

Parameters: