dcase_util.files.RemoteFile

class dcase_util.files.RemoteFile(filename=None, content_type=None, local_md5=None, remote_file=None, remote_md5=None, remote_bytes=None, **kwargs)[source]

Remote file class

Constructor

Parameters
filenamestr

Local filename.

content_typestr or list of str

Content type, valid labels [‘code’, ‘documentation’, ‘meta’, ‘audio’, ‘features’].

local_md5str

Checksum of local file (MD5).

remote_filestr

URL to remote filename.

remote_md5str

Checksum of remote file (MD5).

remote_bytesint

Remote file size in bytes

__init__(filename=None, content_type=None, local_md5=None, remote_file=None, remote_md5=None, remote_bytes=None, **kwargs)[source]

Constructor

Parameters
filenamestr

Local filename.

content_typestr or list of str

Content type, valid labels [‘code’, ‘documentation’, ‘meta’, ‘audio’, ‘features’].

local_md5str

Checksum of local file (MD5).

remote_filestr

URL to remote filename.

remote_md5str

Checksum of remote file (MD5).

remote_bytesint

Remote file size in bytes

Methods

__init__([filename, content_type, ...])

Constructor

clear()

copy()

delimiter([exclude_delimiters])

Use csv.sniffer to guess delimiter for CSV file

detect_file_format([filename])

Detect file format from extension

download()

Download remote file and save it as local file.

empty()

Check if file is empty

exists()

Checks that file exists

filter([data, excluded_key_prefix])

Filter nested dict

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

get_dump_content(data)

Clean internal content for saving

get_file_information()

Get file information, filename

get_hash([data])

Get unique hash string (md5) for given parameter dict.

get_hash_for_path([dotted_path])

Get unique hash string for the data under given path.

get_leaf_path_list([target_field, ...])

Get path list to all leaf node in the nested dict.

get_path(path[, default, data])

Get value from nested dict with dotted path

is_content_type(content_type)

Check that file contains given type of content

is_package([filename])

Determine if the file is compressed package.

items()

keys()

load([filename, file_format])

Load file

local_changed()

Check does the local file corresponds to remote file (based on checksum or modification times and file size).

local_exists()

Check does the local file exists.

local_size_string()

File size of local file in human readable form.

log([level])

Log container content

merge(override[, target])

Recursive dict merge

pop(key[, default])

If key is not found, default is returned if given, otherwise KeyError is raised

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

remote_exists()

Check does the remote file exists (based on HTTP status code).

remote_info()

Get information about the remove file (status, size, checksum, last modification time).

remote_size_string()

File size of remote file in human readable form.

save([filename, file_format])

Save file

set_path(path, new_value[, data])

Set value in nested dict with dotted path

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

show([mode, indent, visualize])

Print container content

to_html([indent])

Get container information in a HTML formatted string

to_string([ui, indent])

Get container information in a string

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

validate_format()

Validate file format

values()

Attributes

bytes

File size in bytes

local_bytes

File size of local file in bytes.

local_md5

Checksum for local file.

local_modified

Modification timestamp for local file.

logger

Logger instance

md5

Checksum for file.

remote_bytes

File size of remote file.

remote_file

URL to remote file

remote_modified

Last modification time for remote file.

remote_status

Status of remote file.

valid_content_types

valid_formats

Valid file formats