girder_large_image package

Subpackages

Submodules

girder_large_image.constants module

class girder_large_image.constants.PluginSettings[source]

Bases: object

LARGE_IMAGE_AUTO_SET = 'large_image.auto_set'
LARGE_IMAGE_CONFIG_FOLDER = 'large_image.config_folder'
LARGE_IMAGE_DEFAULT_VIEWER = 'large_image.default_viewer'
LARGE_IMAGE_ICC_CORRECTION = 'large_image.icc_correction'
LARGE_IMAGE_MAX_SMALL_IMAGE_SIZE = 'large_image.max_small_image_size'
LARGE_IMAGE_MAX_THUMBNAIL_FILES = 'large_image.max_thumbnail_files'
LARGE_IMAGE_MERGE_DICOM = 'large_image.merge_dicom'
LARGE_IMAGE_NOTIFICATION_STREAM_FALLBACK = 'large_image.notification_stream_fallback'
LARGE_IMAGE_SHOW_EXTRA = 'large_image.show_extra'
LARGE_IMAGE_SHOW_EXTRA_ADMIN = 'large_image.show_extra_admin'
LARGE_IMAGE_SHOW_EXTRA_PUBLIC = 'large_image.show_extra_public'
LARGE_IMAGE_SHOW_ITEM_EXTRA = 'large_image.show_item_extra'
LARGE_IMAGE_SHOW_ITEM_EXTRA_ADMIN = 'large_image.show_item_extra_admin'
LARGE_IMAGE_SHOW_ITEM_EXTRA_PUBLIC = 'large_image.show_item_extra_public'
LARGE_IMAGE_SHOW_THUMBNAILS = 'large_image.show_thumbnails'
LARGE_IMAGE_SHOW_VIEWER = 'large_image.show_viewer'

girder_large_image.girder_tilesource module

class girder_large_image.girder_tilesource.GirderTileSource(item, *args, **kwargs)[source]

Bases: FileTileSource

Initialize the tile class. See the base class for other available parameters.

Parameters:

item – a Girder item document which contains [‘largeImage’][‘fileId’] identifying the Girder file to be used for the tile source.

extensionsWithAdjacentFiles = {}
static getLRUHash(*args, **kwargs)[source]

Return a string hash used as a key in the recently-used cache for tile sources.

Returns:

a string hash value.

getState()[source]

Return a string reflecting the state of the tile source. This is used as part of a cache key when hashing function return values.

Returns:

a string hash value of the source state.

girderSource = True
mayHaveAdjacentFiles(largeImageFile)[source]
mimeTypesWithAdjacentFiles = {}
girder_large_image.girder_tilesource.getGirderTileSource(item, file=None, *args, **kwargs)[source]

Get a Girder tilesource using the known sources.

Parameters:
  • item – a Girder item or an item id.

  • file – if specified, the Girder file object to use as the large image file; used here only to check extensions.

Returns:

A girder tilesource for the item.

girder_large_image.girder_tilesource.getGirderTileSourceName(item, file=None, *args, **kwargs)[source]

Get a Girder tilesource name using the known sources. If tile sources have not yet been loaded, load them.

Parameters:
  • item – a Girder item.

  • file – if specified, the Girder file object to use as the large image file; used here only to check extensions.

Returns:

The name of a tilesource that can read the Girder item.

girder_large_image.girder_tilesource.loadGirderTileSources()[source]

Load all Girder tilesources from entrypoints and add them to the AvailableGiderTileSources dictionary.

girder_large_image.loadmodelcache module

girder_large_image.loadmodelcache.invalidateLoadModelCache(*args, **kwargs)[source]

Empty the LoadModelCache.

girder_large_image.loadmodelcache.loadModel(resource, model, plugin='_core', id=None, allowCookie=False, level=None)[source]

Load a model based on id using the current cherrypy token parameter for authentication, caching the results. This must be called in a cherrypy context.

Parameters:
  • resource – the resource class instance calling the function. Used for access to the current user and model importer.

  • model – the model name, e.g., ‘item’.

  • plugin – the plugin name when loading a plugin model.

  • id – a string id of the model to load.

  • allowCookie – true if the cookie authentication method is allowed.

  • level – access level desired.

Returns:

the loaded model.

Module contents

class girder_large_image.LargeImagePlugin(entrypoint)[source]

Bases: GirderPlugin

CLIENT_SOURCE_PATH = 'web_client'

The path of the plugin’s web client source code. This path is given relative to the python package. This property is used to link the web client source into the staging area while building in development mode. When this value is None it indicates there is no web client component.

DISPLAY_NAME = 'Large Image'

This is the named displayed to users on the plugin page. Unlike the entrypoint name used internally, this name can be an arbitrary string.

load(info)[source]
girder_large_image.addSettingsToConfig(config, user, name=None)[source]

Add the settings for showing thumbnails and images in item lists to a config file if the itemList or itemListDialog options are not set.

Parameters:
  • config – the config dictionary to modify.

  • user – the current user.

  • name – the name of the config file.

girder_large_image.adjustConfigForUser(config, user)[source]

Given the current user, adjust the config so that only relevant and combined values are used. If the root of the config dictionary contains “access”: {“user”: <dict>, “admin”: <dict>}, the base values are updated based on the user’s access level. If the root of the config contains “group”: {<group-name>: <dict>, …}, the base values are updated for every group the user is a part of.

The order of update is groups in C-sort alphabetical order followed by access/user and then access/admin as they apply.

Parameters:

config – a config dictionary.

girder_large_image.checkForFlatLargeImage(item, imagePattern)[source]

Check if an item that contains a companion file of a folder/image style image is adjacent to the image file itself (“flat” layout). The image file can be another file in the same item or the sole file of another item in the same folder. If found, try to make it a large image.

Parameters:
  • item – the item containing the companion file.

  • imagePattern – a regex that matches the name of the image file.

Returns:

True if a large image was created.

girder_large_image.checkForLargeImageFiles(event)[source]
girder_large_image.checkForMergeDicom(item)[source]
girder_large_image.handleCopyItem(event)[source]

When copying an item, finish adjusting the largeImage fileId reference to the copied file.

girder_large_image.handleFileSave(event)[source]

When a file is first saved, mark its mime type based on its extension if we would otherwise just mark it as generic application/octet-stream.

girder_large_image.handleRemoveFile(event)[source]

When a file is removed, check if it is a largeImage fileId. If so, delete the largeImage record.

girder_large_image.handleSettingSave(event)[source]

When certain settings are changed, clear the caches.

girder_large_image.metadataSearchHandler(query, types, user=None, level=None, limit=0, offset=0, models=None, searchModels=None, metakey='meta')[source]

Provide a substring search on metadata.

girder_large_image.patchMount()[source]
girder_large_image.prepareCopyItem(event)[source]

When copying an item, adjust the largeImage fileId reference so it can be matched to the to-be-copied file.

girder_large_image.removeThumbnails(event)[source]
girder_large_image.unbindGirderEventsByHandlerName(handlerName)[source]
girder_large_image.userPrivateFolder(user, create=False)[source]

Get a user’s private folder. This is the top-level user folder with the lowest id that is not public; it is usually named Private, but this doesn’t depend on the name. Callers are responsible for access checks.

Parameters:
  • user – a Girder user model.

  • create – if True, create the folder if it does not exist. It is named Private unless that name is already used, in which case a numeric suffix is added.

Returns:

the folder model or None.

girder_large_image.userYamlConfigFile(user, name)[source]

Get a named config file from a user’s private folder. Unlike yamlConfigFile, this does not walk up a folder tree; it is intended for per-user preferences that are combined with a folder’s config by the client. Callers are responsible for access checks.

Parameters:
  • user – the Girder user model whose file is loaded.

  • name – the name of the config file.

Returns:

the parsed config or an empty dictionary if there is none.

girder_large_image.userYamlConfigFileWrite(user, name, yaml_config, writer)[source]

Create or replace a named config file in a user’s private folder. Callers are responsible for access checks.

Parameters:
  • user – the Girder user model whose file is written.

  • name – the name of the config file.

  • yaml_config – a yaml config string.

  • writer – the user performing the write.

girder_large_image.validateBoolean(doc)[source]
girder_large_image.validateBooleanOrAll(doc)[source]
girder_large_image.validateBooleanOrICCIntent(doc)[source]
girder_large_image.validateDefaultViewer(doc)[source]
girder_large_image.validateDictOrJSON(doc)[source]
girder_large_image.validateFolder(doc)[source]
girder_large_image.validateNonnegativeInteger(doc)[source]
girder_large_image.yamlConfigFile(folder, name, user)[source]

Get a resolved named config file based on a folder and user.

Parameters:
  • folder – a Girder folder model.

  • name – the name of the config file.

  • user – the user that the response if adjusted for.

Returns:

either None if no config file, or a yaml record.

girder_large_image.yamlConfigFileWrite(folder, name, user, yaml_config, user_context)[source]

If the user has appropriate permissions, create or modify an item in the specified folder with the specified name, storing the config value as a file.

Parameters:
  • folder – a Girder folder model.

  • name – the name of the config file.

  • user – the user that the response if adjusted for.

  • yaml_config – a yaml config string.

  • user_context – whether these settings should only apply to the current user.