oneibl.onelight

ONE light.

Functions

add_default_handler

add_repo

Interactive prompt to add a repository.

config_dir

Path to the config directory.

config_file

Path to the config file.

default_config

Return an empty configuration dictionary.

default_download_dir

Default download directory on the client computer, with {…} placeholders fields.

download_dir

Return the download directory.

download_file

Download a file from HTTP and save it to a file.

figshare_request

Perform a REST request against the figshare API.

find_session_dirs

Iterate over all session directories found in a root directory.

find_session_files

Iterate over all files within session directories found within a root directory.

format_download_dir

Replace the placeholder fields in the download directory by the appropriate values for a given session.

get_config

Return the config file dictionary.

get_one

Get the singleton One instance, loading it from the config file, or using the singleton instance if it has already been instantiated.

get_repo

Get a repository by its name.

is_documented_by

is_file_in_session_dir

Return whether a file path is within a session directory.

is_session_dir

Return whether a path is a session directory.

load_array

Load a single file.

make_http_root_file

Make a root TSV file for an HTTP server.

read_root_file

repo_dir

Path to the local directory of the repository.

repository

Get the current repository.

set_config

Set the config file.

set_figshare_url

Get or create a figshare repo with a given figshare URL.

set_repo

Set the current repository.

update_repo

Update a repository.

walk

Iterate over all files found within a root directory.

write_root_file

Classes

Bunch

A subclass of dictionary with an additional dot syntax.

FigshareOne

FigshareUploader

FtpUploader

HttpOne

LocalOne

ONE

add_default_handler(level='INFO', logger=<Logger oneibl.onelight (DEBUG)>)[source]
class Bunch(*args, **kwargs)[source]

Bases: dict

A subclass of dictionary with an additional dot syntax.

copy()[source]

Return a new Bunch instance which is a copy of the current Bunch instance.

is_documented_by(original)[source]
config_dir()[source]

Path to the config directory.

repo_dir()[source]

Path to the local directory of the repository.

config_file()[source]

Path to the config file.

default_config()[source]

Return an empty configuration dictionary.

get_config()[source]

Return the config file dictionary.

set_config(config)[source]

Set the config file.

get_repo(name=None, config=None)[source]

Get a repository by its name.

update_repo(name=None, **kwargs)[source]

Update a repository.

add_repo(name=None)[source]

Interactive prompt to add a repository.

set_figshare_url(url)[source]

Get or create a figshare repo with a given figshare URL.

read_root_file(path)[source]
write_root_file(path, iterator)[source]
walk(root)[source]

Iterate over all files found within a root directory.

is_session_dir(path)[source]

Return whether a path is a session directory.

Example of a session dir: /path/to/root/mainenlab/Subjects/ZM_1150/2019-05-07/001/

is_file_in_session_dir(path)[source]

Return whether a file path is within a session directory.

find_session_dirs(root)[source]

Iterate over all session directories found in a root directory.

find_session_files(root)[source]

Iterate over all files within session directories found within a root directory.

make_http_root_file(root, base_url, output)[source]

Make a root TSV file for an HTTP server.

Note: the session root directory needs to be the directory that contains the <lab> subdirectories, so that the relative file paths are correctly obtained.

download_file(url, save_to, auth=None, log_level=10)[source]

Download a file from HTTP and save it to a file. If Basic HTTP authentication is needed, pass auth=(username, password).

default_download_dir()[source]

Default download directory on the client computer, with {…} placeholders fields.

download_dir()[source]

Return the download directory.

format_download_dir(session, download_dir)[source]

Replace the placeholder fields in the download directory by the appropriate values for a given session.

load_array(path)[source]

Load a single file.

class FtpUploader(host, login=None, password=None, port=21, remote_root=None)[source]

Bases: object

connect()[source]
upload(root_dir, base_dir=None)[source]
class HttpOne(root_file=None, download_dir=None, auth=None)[source]

Bases: object

list(session)[source]

List all dataset types found in a session.

search(dataset_types=(), **kwargs)[source]

Search all sessions that have all requested dataset types.

load_dataset(session, dataset_type, download_only=False)[source]

Download and load a single dataset in a given session and with a given dataset type.

load_object(session, obj, download_only=False, dry_run=False)[source]

Load all attributes of a given object.

class LocalOne(root_dir)[source]

Bases: oneibl.onelight.HttpOne

figshare_request(endpoint=None, data=None, method='GET', url=None, binary=False, error_level=40)[source]

Perform a REST request against the figshare API.

class FigshareUploader(article_id)[source]

Bases: object

iter_files(private=True)[source]

Iterate over all ALF files of a given figshare article.

upload_dir(root_dir, dry_run=False, limit=None)[source]

Upload to figshare all session files found in a root directory.

clean_publish()[source]

Clean up and publish the figshare article.

class FigshareOne(article_id=None, download_dir=None, private=False)[source]

Bases: oneibl.onelight.HttpOne

set_repo(name=None)[source]

Set the current repository.

repository()[source]

Get the current repository.

get_one(private=False)[source]

Get the singleton One instance, loading it from the config file, or using the singleton instance if it has already been instantiated.

class ONE[source]

Bases: object

set_local_dir(name=None, **kwargs)[source]
set_figshare_url(url)[source]
search_terms()[source]
set_download_dir(path)[source]

Set the download directory. May contain fields like {lab}, {subject}, etc.

search(dataset_types, private=False, **kwargs)[source]

Search all sessions that have all requested dataset types.

list(session)[source]

List all dataset types found in a session.

load_object(session, obj=None, **kwargs)[source]

Load all attributes of a given object.

load_dataset(session, dataset_type, **kwargs)[source]

Download and load a single dataset in a given session and with a given dataset type.