data Package¶
data
Package¶
Package containig data related modules
url
Module¶
Module providing tools to parse and create valid urls and paths.
usage example:
When in fastr.config under the mounts section the data mount is set to /media/data, you will get the following. .. code-block:: python
>>> from fastr.data.url import get_path_from_url
>>> get_path_from_url('vfs://data/temp/blaat1.png')
'/media/data/temp/blaat1.png'
-
fastr.data.url.
basename
(url)[source]¶ Get basename of url
Parameters: url (str) – the url Returns: the basename of the path in the url
-
fastr.data.url.
create_vfs_url
(mountpoint, path)[source]¶ Construct an url from a given mount point and a relative path to the mount point.
Parameters: Returns: the created vfs url
-
fastr.data.url.
dirname
(url)[source]¶ Get the dirname of the url
Parameters: url (str) – the url Returns: the dirname of the path in the url
-
fastr.data.url.
dirurl
(url)[source]¶ Get the a new url only having the dirname as the path
Parameters: url (str) – the url Returns: the modified url with only dirname as path
-
fastr.data.url.
full_split
(urlpath)[source]¶ Split the path in the url in a list of parts
Parameters: urlpath – the url path Returns: a list of parts
-
fastr.data.url.
get_path_from_url
(url)[source]¶ Get the path to a file from a url. Currently supports the file:// and vfs:// scheme’s
Examples:
>>> url.get_path_from_url('vfs://neurodata/user/project/file.ext') 'Y:\neuro3\user\project\file.ext' >>> 'file:///d:/data/project/file.ext' 'd:\data\project\file.ext'
Warning
file:// will not function cross platform and is mainly for testing
-
fastr.data.url.
get_url_scheme
(url)[source]¶ Get the schem of the url
Parameters: url (str) – url to extract scheme from Returns: the url scheme Return type: str
-
fastr.data.url.
isurl
(string)[source]¶ Check if string is a valid url
Parameters: string (str) – potential url Returns: flag indicating if string is a valid url
-
fastr.data.url.
join
(url, *p)[source]¶ Join the path in the url with p
Parameters: - url (str) – the base url to join with
- p – additional parts of the path
Returns: the url with the parts added to the path
-
fastr.data.url.
normurl
(url)[source]¶ Normalized the path of the url
Parameters: url (str) – the url Returns: the normalized url