d1_onedrive.impl package



d1_onedrive.impl.attributes module

Hold the size and other attributes for a file or folder.

class d1_onedrive.impl.attributes.Attributes(size=0, date=None, is_dir=False)

Bases: object


d1_onedrive.impl.cache_memory module

Cache Python objects in memory.

Cache Python objects with a limit on how many objects can be cached. When the cache reaches a configured size, adding a new object causes the oldest object to be removed. The oldest object is the object that was added first of the objects still in the cache.

class d1_onedrive.impl.cache_memory.Cache(max_items)

Bases: dict

keys() → a set-like object providing a view on D's keys
copy() → a shallow copy of D

d1_onedrive.impl.directory module

Hold the list of files and folders for a directory.

class d1_onedrive.impl.directory.Directory(init_list=None, disable_cache=False)

Bases: collections.abc.MutableSequence

insert(i, v)

S.insert(index, value) – insert value before index

d1_onedrive.impl.disk_cache module

Cache Python objects on disk.

Cache Python objects with a limit on how many objects can be cached. When the cache reaches a configured size, adding a new object causes the oldest object to be removed. The oldest object is the object that was added first of the objects still in the cache.

class d1_onedrive.impl.disk_cache.DiskCache(max_items, cache_directory_path)

Bases: dict

clear() → None. Remove all items from D.

d1_onedrive.impl.log_decorator module

class d1_onedrive.impl.log_decorator.log_func

Bases: object

d1_onedrive.impl.object_tree module

Object Tree.

Based on a source tree that contains only PIDs and queries, maintain the object tree that is browsed through the ONEDrive filesystem.

Cache the information on disk between runs of ONEDrive.

class d1_onedrive.impl.object_tree.ObjectTree(options, source_tree)

Bases: object


Synchronize the local tree of Solr records for DataONE identifiers and queries with the reference tree.

get_folder(path, root=None)

Get the contents of an object tree folder.


Get an object that has already been cached in the object tree.

Caching happens when the object tree is refreshed.


Get an object that may not currently be in the cache.

If the object is not in the cache, an attempt is made to retrieve the record from a CN on the fly. If the object is found, it is cached before being returned to the user. This allows the object tree caching system to be used for objects that are not in the object tree. ONEDrive uses this functionality for the FlatSpace folder.


Attempt to add a specific object to the cache.

Objects are normally only added to the object tree during refresh. This method is used by the FlatSpace resolver.


d1_onedrive.impl.onedrive_exceptions module

Type that gets raised as exception for invalid paths.

exception d1_onedrive.impl.onedrive_exceptions.PathException(message)

Bases: Exception

exception d1_onedrive.impl.onedrive_exceptions.ONEDriveException(message)

Bases: Exception

exception d1_onedrive.impl.onedrive_exceptions.NoResultException(message='')

Bases: Exception

d1_onedrive.impl.os_escape module

OS specific escaping.

Escape DataONE identifiers, so that they follow the filesystem conventions and restrictions for valid file- and folder names on a given OS.

Unescape the escaped file- and folder names to arrive at the original DataONE identifiers.

DataONE supports identifiers containing characters that cannot (or should not) be represented directly within the file- and folder names in a filesystem, such as the path separator character (“/” on *nix). This module contains functions for converting between DataONE identifiers and names that are suitable for use as file- and folder names on the operating systems that are supported by ONEDrive.

It is necessary to be able to get the original DataONE identifier given an escaped name, so the escaping must be reversible. This is because the filesystem driver (e.g., FUSE), passes the escaped name back to ONEDrive when the user interacts with the file or folder.

The current implementation simply uses URL percent-encoding of an utf-8 encoding of the Unicode strings.

Quote and unquote are somewhat borrowed from python urllib standard library.

d1_onedrive.impl.os_escape.unquote('abc%20def') → 'abc def'.
d1_onedrive.impl.os_escape.quote(s, unsafe='/')

Pass in a dictionary that has unsafe characters as the keys, and the percent encoded value as the value.


On Windows, the following characters are not allowed:

/ : * ? ” < > |


d1_onedrive.impl.util module

Misc utilities that don’t fit anywhere else.