API Documentation¶
Read / Write functions¶
-
uriutils.uriutils.
uri_open
(uri, mode='rb', auto_compress=True, in_memory=True, delete_tempfile=True, textio_args={}, storage_args={})[source]¶ Opens a URI for reading / writing. Analogous to the
open()
function. This method supportswith
context handling:with uri_open('http://www.example.com', mode='r') as f: print(f.read())
Parameters: - uri (str) – URI of file to open
- mode (str) – Either
rb
,r
,w
, orwb
for read/write modes in binary/text respectiely - auto_compress (bool) – Whether to automatically use the
gzip
module with.gz
URIsF - in_memory (bool) – Whether to store entire file in memory or in a local temporary file
- delete_tempfile (bool) – When
in_memory
isFalse
, whether to delete the temporary file on close - textio_args (dict) – Keyword arguments to pass to
io.TextIOWrapper
for text read/write mode - storage_args (dict) – Keyword arguments to pass to the underlying storage object
Returns: file-like object to URI
-
uriutils.uriutils.
uri_read
(*args, **kwargs)[source]¶ Reads the contents of a URI into a string or bytestring. See
uri_open()
for complete description of keyword parameters.Returns: Contents of URI Return type: str, bytes
-
uriutils.uriutils.
uri_dump
(uri, content, mode='wb', **kwargs)[source]¶ Dumps the contents of a string/bytestring into a URI. See
uri_open()
for complete description of keyword parameters.Parameters:
URI information¶
-
uriutils.uriutils.
uri_exists
(uri, storage_args={})[source]¶ Check if URI exists.
Parameters: Returns: True
if URI existsReturn type:
-
uriutils.uriutils.
uri_exists_wait
(uri, timeout=300, interval=5, storage_args={})[source]¶ Block / waits until URI exists.
Parameters: - uri (str) – URI to check existence
- timeout (float) – Number of seconds before timing out
- interval (float) – Calls
uri_exists()
everyinterval
seconds - storage_args (dict) – Keyword arguments to pass to the underlying storage object
Returns: True
if URI existsReturn type:
Argument Parser types¶
-
class
uriutils.uriutils.
URIType
[source]¶ A convenience class that can be used as the
type
argument toargparse.ArgumentParser.add_argument()
. It will return the result ofurllib.parse.urlparse()
.
-
class
uriutils.uriutils.
URIFileType
(mode='rb', **kwargs)[source]¶ A convenience class that can be used as the
type
argument toargparse.ArgumentParser.add_argument()
. It will return a file-like object usinguri_open()
.See
uri_open()
for complete description of keyword parameters.
-
class
uriutils.uriutils.
URIDirType
(create=False, storage_args={})[source]¶ A convenience class that can be used as the
type
argument toargparse.ArgumentParser.add_argument()
. It will return the result ofurllib.parse.urlparse()
.Parameters: