d1_onedrive.impl package¶
Subpackages¶
- d1_onedrive.impl.clients package
- d1_onedrive.impl.drivers package
- d1_onedrive.impl.resolver package
- Submodules
- d1_onedrive.impl.resolver.author module
- d1_onedrive.impl.resolver.d1_object module
- d1_onedrive.impl.resolver.flat_space module
- d1_onedrive.impl.resolver.object_tree_resolver module
- d1_onedrive.impl.resolver.region module
- d1_onedrive.impl.resolver.resolver_base module
- d1_onedrive.impl.resolver.resource_map module
- d1_onedrive.impl.resolver.root module
- d1_onedrive.impl.resolver.single module
- d1_onedrive.impl.resolver.taxa module
- d1_onedrive.impl.resolver.time_period module
- d1_onedrive.impl.tests package
- Submodules
- d1_onedrive.impl.tests.command_echoer module
- d1_onedrive.impl.tests.object_tree_test_sample module
- d1_onedrive.impl.tests.test_author_resolver module
- d1_onedrive.impl.tests.test_d1_object_resolver module
- d1_onedrive.impl.tests.test_disk_cache module
- d1_onedrive.impl.tests.test_flat_space_resolver module
- d1_onedrive.impl.tests.test_os_escape module
- d1_onedrive.impl.tests.test_region_resolver module
- d1_onedrive.impl.tests.test_resource_map_resolver module
- d1_onedrive.impl.tests.test_root_resolver module
- d1_onedrive.impl.tests.test_solr_client module
- d1_onedrive.impl.tests.test_taxa_resolver module
- d1_onedrive.impl.tests.test_time_period_resolver module
- d1_onedrive.impl.tests.test_util module
- d1_onedrive.impl.tests.test_zotero_client module
Submodules¶
d1_onedrive.impl.attributes module¶
Hold the size and other attributes for a file or folder.
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.
d1_onedrive.impl.directory module¶
Hold the list of files and folders for a directory.
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.
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
-
refresh
()¶ 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_object_tree_folder_name
(object_tree_folder)¶
-
get_object_record
(pid)¶ Get an object that has already been cached in the object tree.
Caching happens when the object tree is refreshed.
-
get_object_record_with_sync
(pid)¶ 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.
-
add_object_to_cache
(pid)¶ 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.
-
get_science_object
(pid)¶
-
get_system_metadata
(pid)¶
-
get_source_tree_folder
(path)¶
-
sync_cache_with_source_tree
()¶
-
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.
-
d1_onedrive.impl.os_escape.
posix_filename_from_identifier
(identifier)¶
-
d1_onedrive.impl.os_escape.
posix_identifier_from_filename
(filename)¶
-
d1_onedrive.impl.os_escape.
windows_filename_from_identifier
(identifier)¶ On Windows, the following characters are not allowed:
/ : * ? ” < > |
-
d1_onedrive.impl.os_escape.
windows_identifier_from_filename
(filename)¶
-
d1_onedrive.impl.os_escape.
identifier_from_filename
(filename)¶
-
d1_onedrive.impl.os_escape.
filename_from_identifier
(identifier)¶