tardis.apps.deep_storage_download_mapper package

Submodules

tardis.apps.deep_storage_download_mapper.mapper module

File mapper that works for files stored in deep directory structures. It recreates the structure as stored in the datafile directory

tardis.apps.deep_storage_download_mapper.mapper.deep_storage_mapper(obj, rootdir=None)

If rootdir is None, just return a filesystem-safe representation of the object, e.g. “DatasetDescription_123” or “strange %2F filename.txt”

For now, only DataFiles are supported when rootdir is not None.

Parameters:
  • obj (DataFile, Dataset or Experiment) – The model instance (DataFile, Dataset or Experiment) to generate a path for.
  • rootdir (basestring) – The top-level directory name, or None
Returns:

Filesystem-safe path for the object in the archive or SFTP view.

Return type:

basestring

Raises:
tardis.apps.deep_storage_download_mapper.mapper.encode_if_py2(string)

UTF-8 encode string if necessary for Python 2.7.

If we get a unicode string in Python 2.7, e.g. u’ünicode’, we encode it as UTF-8 before URL quoting it.

We use “six.text_type” rather than “unicode” to check the string type in Python 2.7, to avoid getting an undefined variable error when linting in Python 3.

In Python 3, it is not necessary to explicitly encode in UTF-8 before URL quoting, and attempting to combine a bytes-encoded string with a database ID in Python 3 using “%s_%d” % (b”foo”, 123) gives “b’foo’_123” instead of “foo_123”, so it’s best to avoid explict encoding.

tardis.apps.deep_storage_download_mapper.urls module

Module contents