url: Utils for data locators#

URL module

slice_sequence_to_string(data_slice)[source]#

Convert a Python slice sequence or a slice into a string

Parameters:

data_slice (Download Windows installer) –

Return type:

Download Windows installer

class DataUrl(path=None, file_path=None, data_path=None, data_slice=None, scheme=None)[source]#

Non-mutable object to parse a string representing a resource data locator.

It supports:

  • path to file and path inside file to the data

  • data slicing

  • fabio or silx access to the data

  • absolute and relative file access

>>> # fabio access using absolute path
>>> DataUrl("fabio:///data/image.edf?slice=2")
>>> DataUrl("fabio:///C:/data/image.edf?slice=2")
>>> # silx access using absolute path
>>> DataUrl("silx:///data/image.h5?path=/data/dataset&slice=1,5")
>>> DataUrl("silx:///data/image.edf?path=/scan_0/detector/data")
>>> DataUrl("silx:///C:/data/image.edf?path=/scan_0/detector/data")
>>> # `path=` can be omitted if there are no other query keys
>>> DataUrl("silx:///data/image.h5?/data/dataset")
>>> # is the same as
>>> DataUrl("silx:///data/image.h5?path=/data/dataset")
>>> # `::` can be used instead of `?` which can be useful with shell in
>>> # command lines
>>> DataUrl("silx:///data/image.h5::/data/dataset")
>>> # is the same as
>>> DataUrl("silx:///data/image.h5?/data/dataset")
>>> # Relative path access
>>> DataUrl("silx:./image.h5")
>>> DataUrl("fabio:./image.edf")
>>> DataUrl("silx:image.h5")
>>> DataUrl("fabio:image.edf")
>>> # It also supports parsing of file access for convenience
>>> DataUrl("./foo/bar/image.edf")
>>> DataUrl("C:/data/")
Parameters:
is_valid()[source]#
Return type:

Download Windows installer

Returns true if the URL is valid. Else attributes can be None.

path()[source]#
Return type:

Download Windows installer

Returns the string representing the URL.

is_absolute()[source]#
Return type:

Download Windows installer

Returns true if the file path is an absolute path.

file_path()[source]#
Return type:

Download Windows installer

Returns the path to the file containing the data.

data_path()[source]#
Return type:

Download Windows installer

Returns the path inside the file to the data.

data_slice()[source]#
Return type:

Download Windows installer

Returns the slicing applied to the data.

It is a tuple containing numbers, slice or ellipses.

scheme()[source]#
Return type:

Download Windows installer

Returns the scheme. It can be None if no scheme is specified.