INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Move some fields to the position specified by field_position_local. | def record_move_fields(rec, tag, field_positions_local,
field_position_local=None):
"""
Move some fields to the position specified by 'field_position_local'.
:param rec: a record structure as returned by create_record()
:param tag: the tag of the fields to be moved
:param fie... |
Delete all subfields with subfield_code in the record. | def record_delete_subfield(rec, tag, subfield_code, ind1=' ', ind2=' '):
"""Delete all subfields with subfield_code in the record."""
ind1, ind2 = _wash_indicators(ind1, ind2)
for field in rec.get(tag, []):
if field[1] == ind1 and field[2] == ind2:
field[0][:] = [subfield for subfield i... |
Return the the matching field. | def record_get_field(rec, tag, field_position_global=None,
field_position_local=None):
"""
Return the the matching field.
One has to enter either a global field position or a local field position.
:return: a list of subfield tuples (subfield code, value).
:rtype: list
"""
... |
Replace a field with a new field. | def record_replace_field(rec, tag, new_field, field_position_global=None,
field_position_local=None):
"""Replace a field with a new field."""
if field_position_global is None and field_position_local is None:
raise InvenioBibRecordFieldError(
"A field position is req... |
Return the subfield of the matching field. | def record_get_subfields(rec, tag, field_position_global=None,
field_position_local=None):
"""
Return the subfield of the matching field.
One has to enter either a global field position or a local field position.
:return: a list of subfield tuples (subfield code, value).
:... |
Delete subfield from position specified. | def record_delete_subfield_from(rec, tag, subfield_position,
field_position_global=None,
field_position_local=None):
"""
Delete subfield from position specified.
Specify the subfield by tag, field number and subfield position.
"""
subf... |
Add subfield into specified position. | def record_add_subfield_into(rec, tag, subfield_code, value,
subfield_position=None,
field_position_global=None,
field_position_local=None):
"""Add subfield into specified position.
Specify the subfield by tag, field number ... |
Modify controlfield at position specified by tag and field number. | def record_modify_controlfield(rec, tag, controlfield_value,
field_position_global=None,
field_position_local=None):
"""Modify controlfield at position specified by tag and field number."""
field = record_get_field(
rec, tag,
field_po... |
Modify subfield at specified position. | def record_modify_subfield(rec, tag, subfield_code, value, subfield_position,
field_position_global=None,
field_position_local=None):
"""Modify subfield at specified position.
Specify the subfield by tag, field number and subfield position.
"""
subf... |
Move subfield at specified position. | def record_move_subfield(rec, tag, subfield_position, new_subfield_position,
field_position_global=None,
field_position_local=None):
"""Move subfield at specified position.
Sspecify the subfield by tag, field number and subfield position to new
subfield pos... |
Return first ( string ) value that matches specified field of the record. | def record_get_field_value(rec, tag, ind1=" ", ind2=" ", code=""):
"""Return first (string) value that matches specified field of the record.
Returns empty string if not found.
Parameters (tag, ind1, ind2, code) can contain wildcard %.
Difference between wildcard % and empty '':
- Empty char spe... |
Return the list of values for the specified field of the record. | def record_get_field_values(rec, tag, ind1=" ", ind2=" ", code="",
filter_subfield_code="",
filter_subfield_value="",
filter_subfield_mode="e"):
"""Return the list of values for the specified field of the record.
List can be fi... |
Generate the XML for record rec. | def record_xml_output(rec, tags=None, order_fn=None):
"""Generate the XML for record 'rec'.
:param rec: record
:param tags: list of tags to be printed
:return: string
"""
if tags is None:
tags = []
if isinstance(tags, str):
tags = [tags]
if tags and '001' not in tags:
... |
Generate the XML for field field and returns it as a string. | def field_xml_output(field, tag):
"""Generate the XML for field 'field' and returns it as a string."""
marcxml = []
if field[3]:
marcxml.append(' <controlfield tag="%s">%s</controlfield>' %
(tag, MathMLParser.html_to_text(field[3])))
else:
marcxml.append(' <dataf... |
Return the DOI ( s ) of the record. | def record_extract_dois(record):
"""Return the DOI(s) of the record."""
record_dois = []
tag = "024"
ind1 = "7"
ind2 = "_"
subfield_source_code = "2"
subfield_value_code = "a"
identifiers_fields = record_get_field_instances(record, tag, ind1, ind2)
for identifer_field in identifiers_... |
Print a record. | def print_rec(rec, format=1, tags=None):
"""
Print a record.
:param format: 1 XML, 2 HTML (not implemented)
:param tags: list of tags to be printed
"""
if tags is None:
tags = []
if format == 1:
text = record_xml_output(rec, tags)
else:
return ''
return text |
Print a list of records. | def print_recs(listofrec, format=1, tags=None):
"""
Print a list of records.
:param format: 1 XML, 2 HTML (not implemented)
:param tags: list of tags to be printed
if 'listofrec' is not a list it returns empty string
"""
if tags is None:
tags = []
text = ""
if type(l... |
Return the global and local positions of the first occurrence of the field. | def record_find_field(rec, tag, field, strict=False):
"""
Return the global and local positions of the first occurrence of the field.
:param rec: A record dictionary structure
:type rec: dictionary
:param tag: The tag of the field to search for
:type tag: string
:param field: ... |
Find subfield instances in a particular field. | def record_match_subfields(rec, tag, ind1=" ", ind2=" ", sub_key=None,
sub_value='', sub_key2=None, sub_value2='',
case_sensitive=True):
"""
Find subfield instances in a particular field.
It tests values in 1 of 3 possible ways:
- Does a subfield c... |
Remove unchanged volatile subfields from the record. | def record_strip_empty_volatile_subfields(rec):
"""Remove unchanged volatile subfields from the record."""
for tag in rec.keys():
for field in rec[tag]:
field[0][:] = [subfield for subfield in field[0]
if subfield[1][:9] != "VOLATILE:"] |
Turns all subfields to volatile | def record_make_all_subfields_volatile(rec):
"""
Turns all subfields to volatile
"""
for tag in rec.keys():
for field_position, field in enumerate(rec[tag]):
for subfield_position, subfield in enumerate(field[0]):
if subfield[1][:9] != "VOLATILE:":
... |
Remove empty subfields and fields from the record. | def record_strip_empty_fields(rec, tag=None):
"""
Remove empty subfields and fields from the record.
If 'tag' is not None, only a specific tag of the record will be stripped,
otherwise the whole record.
:param rec: A record dictionary structure
:type rec: dictionary
:param tag: The tag... |
Remove all non - empty controlfields from the record. | def record_strip_controlfields(rec):
"""
Remove all non-empty controlfields from the record.
:param rec: A record dictionary structure
:type rec: dictionary
"""
for tag in rec.keys():
if tag[:2] == '00' and rec[tag][0][3]:
del rec[tag] |
Order subfields from a record alphabetically based on subfield code. | def record_order_subfields(rec, tag=None):
"""
Order subfields from a record alphabetically based on subfield code.
If 'tag' is not None, only a specific tag of the record will be reordered,
otherwise the whole record.
:param rec: bibrecord
:type rec: bibrec
:param tag: tag where the subfi... |
Given a field will place all subfields into a dictionary Parameters: * field - tuple: The field to get subfields for Returns: a dictionary codes as keys and a list of values as the value | def field_get_subfields(field):
""" Given a field, will place all subfields into a dictionary
Parameters:
* field - tuple: The field to get subfields for
Returns: a dictionary, codes as keys and a list of values as the value """
pairs = {}
for key, value in field[0]:
if key in pairs and... |
Compare 2 fields. | def _compare_fields(field1, field2, strict=True):
"""
Compare 2 fields.
If strict is True, then the order of the subfield will be taken care of, if
not then the order of the subfields doesn't matter.
:return: True if the field are equivalent, False otherwise.
"""
if strict:
# Retur... |
Check if a field is well - formed. | def _check_field_validity(field):
"""
Check if a field is well-formed.
:param field: A field tuple as returned by create_field()
:type field: tuple
:raise InvenioBibRecordFieldError: If the field is invalid.
"""
if type(field) not in (list, tuple):
raise InvenioBibRecordFieldError(... |
Shift all global field positions. | def _shift_field_positions_global(record, start, delta=1):
"""
Shift all global field positions.
Shift all global field positions with global field positions
higher or equal to 'start' from the value 'delta'.
"""
if not delta:
return
for tag, fields in record.items():
newfi... |
Return true if MARC tag matches a pattern. | def _tag_matches_pattern(tag, pattern):
"""Return true if MARC 'tag' matches a 'pattern'.
'pattern' is plain text, with % as wildcard
Both parameters must be 3 characters long strings.
.. doctest::
>>> _tag_matches_pattern("909", "909")
True
>>> _tag_matches_pattern("909", "9... |
Check if the global field positions in the record are valid. | def _validate_record_field_positions_global(record):
"""
Check if the global field positions in the record are valid.
I.e., no duplicate global field positions and local field positions in the
list of fields are ascending.
:param record: the record data structure
:return: the first error found... |
Sort the fields inside the record by indicators. | def _record_sort_by_indicators(record):
"""Sort the fields inside the record by indicators."""
for tag, fields in record.items():
record[tag] = _fields_sort_by_indicators(fields) |
Sort a set of fields by their indicators. | def _fields_sort_by_indicators(fields):
"""Sort a set of fields by their indicators.
Return a sorted list with correct global field positions.
"""
field_dict = {}
field_positions_global = []
for field in fields:
field_dict.setdefault(field[1:3], []).append(field)
field_positions... |
Create a record object using the LXML parser. | def _create_record_lxml(marcxml,
verbose=CFG_BIBRECORD_DEFAULT_VERBOSE_LEVEL,
correct=CFG_BIBRECORD_DEFAULT_CORRECT,
keep_singletons=CFG_BIBRECORD_KEEP_SINGLETONS):
"""
Create a record object using the LXML parser.
If correct == 1, the... |
Retrieve all children from node node with name name. | def _get_children_by_tag_name(node, name):
"""Retrieve all children from node 'node' with name 'name'."""
try:
return [child for child in node.childNodes if child.nodeName == name]
except TypeError:
return [] |
Iterate through all the children of a node. | def _get_children_as_string(node):
"""Iterate through all the children of a node.
Returns one string containing the values from all the text-nodes
recursively.
"""
out = []
if node:
for child in node:
if child.nodeType == child.TEXT_NODE:
out.append(child.dat... |
Check and correct the structure of the record. | def _correct_record(record):
"""
Check and correct the structure of the record.
:param record: the record data structure
:return: a list of errors found
"""
errors = []
for tag in record.keys():
upper_bound = '999'
n = len(tag)
if n > 3:
i = n - 3
... |
Return a warning message of code code. | def _warning(code):
"""
Return a warning message of code 'code'.
If code = (cd, str) it returns the warning message of code 'cd' and appends
str at the end
"""
if isinstance(code, str):
return code
message = ''
if isinstance(code, tuple):
if isinstance(code[0], str):
... |
Compare twolists using given comparing function. | def _compare_lists(list1, list2, custom_cmp):
"""Compare twolists using given comparing function.
:param list1: first list to compare
:param list2: second list to compare
:param custom_cmp: a function taking two arguments (element of
list 1, element of list 2) and
:return: True or False dep... |
Parse an XML document and clean any namespaces. | def parse(self, path_to_xml=None):
"""Parse an XML document and clean any namespaces."""
if not path_to_xml:
if not self.path:
self.logger.error("No path defined!")
return
path_to_xml = self.path
root = self._clean_xml(path_to_xml)
... |
Clean MARCXML harvested from OAI. | def _clean_xml(self, path_to_xml):
"""Clean MARCXML harvested from OAI.
Allows the xml to be used with BibUpload or BibRecord.
:param xml: either XML as a string or path to an XML file
:return: ElementTree of clean data
"""
try:
if os.path.isfile(path_to_xm... |
Generate the record deletion if deleted form OAI - PMH. | def create_deleted_record(self, record):
"""Generate the record deletion if deleted form OAI-PMH."""
identifier = record_get_field_value(record,
tag="037",
code="a")
recid = identifier.split(":")[-1]
... |
Return a session for yesss. at. | def _login(self, session, get_request=False):
"""Return a session for yesss.at."""
req = session.post(self._login_url, data=self._logindata)
if _LOGIN_ERROR_STRING in req.text or \
req.status_code == 403 or \
req.url == _LOGIN_URL:
err_mess = "YesssSMS... |
Check for working login data. | def login_data_valid(self):
"""Check for working login data."""
login_working = False
try:
with self._login(requests.Session()) as sess:
sess.get(self._logout_url)
except self.LoginError:
pass
else:
login_working = True
... |
Send an SMS. | def send(self, recipient, message):
"""Send an SMS."""
if self._logindata['login_rufnummer'] is None or \
self._logindata['login_passwort'] is None:
err_mess = "YesssSMS: Login data required"
raise self.LoginError(err_mess)
if not recipient:
ra... |
Return the date of the article in file. | def get_date(self, filename):
"""Return the date of the article in file."""
try:
self.document = parse(filename)
return self._get_date()
except DateNotFoundException:
print("Date problem found in {0}".format(filename))
return datetime.datetime.strf... |
Return this articles collection. | def get_collection(self, journal):
"""Return this articles' collection."""
conference = ''
for tag in self.document.getElementsByTagName('conference'):
conference = xml_to_text(tag)
if conference or journal == "International Journal of Modern Physics: Conference Series":
... |
Get the MARCXML of the files in xaml_jp directory. | def get_record(self, filename, ref_extract_callback=None):
"""Get the MARCXML of the files in xaml_jp directory.
:param filename: the name of the file to parse.
:type filename: string
:param refextract_callback: callback to be used to extract
unstruct... |
Attach fulltext FFT. | def _attach_fulltext(self, rec, doi):
"""Attach fulltext FFT."""
url = os.path.join(self.url_prefix, doi)
record_add_field(rec, 'FFT',
subfields=[('a', url),
('t', 'INSPIRE-PUBLIC'),
('d', 'Fulltext'... |
Convert the list of bibrecs into one MARCXML. | def convert_all(cls, records):
"""Convert the list of bibrecs into one MARCXML.
>>> from harvestingkit.bibrecord import BibRecordPackage
>>> from harvestingkit.inspire_cds_package import Inspire2CDS
>>> bibrecs = BibRecordPackage("inspire.xml")
>>> bibrecs.parse()
>>> xm... |
Yield single conversion objects from a MARCXML file or string. | def from_source(cls, source):
"""Yield single conversion objects from a MARCXML file or string.
>>> from harvestingkit.inspire_cds_package import Inspire2CDS
>>> for record in Inspire2CDS.from_source("inspire.xml"):
>>> xml = record.convert()
"""
bibrecs = BibRecord... |
Return the opposite mapping by searching the imported KB. | def get_config_item(cls, key, kb_name, allow_substring=True):
"""Return the opposite mapping by searching the imported KB."""
config_dict = cls.kbs.get(kb_name, None)
if config_dict:
if key in config_dict:
return config_dict[key]
elif allow_substring:
... |
Load configuration from config. | def load_config(from_key, to_key):
"""Load configuration from config.
Meant to run only once per system process as
class variable in subclasses."""
from .mappings import mappings
kbs = {}
for key, values in mappings['config'].iteritems():
parse_dict = {}
... |
Try to match the current record to the database. | def match(self, query=None, **kwargs):
"""Try to match the current record to the database."""
from invenio.search_engine import perform_request_search
if not query:
# We use default setup
recid = self.record["001"][0][3]
return perform_request_search(p="035:%s... |
Keep only fields listed in field_list. | def keep_only_fields(self):
"""Keep only fields listed in field_list."""
for tag in self.record.keys():
if tag not in self.fields_list:
record_delete_fields(self.record, tag) |
Clear any fields listed in field_list. | def strip_fields(self):
"""Clear any fields listed in field_list."""
for tag in self.record.keys():
if tag in self.fields_list:
record_delete_fields(self.record, tag) |
Add 035 number from 001 recid with given source. | def add_systemnumber(self, source, recid=None):
"""Add 035 number from 001 recid with given source."""
if not recid:
recid = self.get_recid()
if not self.hidden and recid:
record_add_field(
self.record,
tag='035',
subfields=... |
Add a control - number 00x for given tag with value. | def add_control_number(self, tag, value):
"""Add a control-number 00x for given tag with value."""
record_add_field(self.record,
tag,
controlfield_value=value) |
650 Translate Categories. | def update_subject_categories(self, primary, secondary, kb):
"""650 Translate Categories."""
category_fields = record_get_field_instances(self.record,
tag='650',
ind1='1',
... |
Retrieve the data for a reference. | def _get_reference(self, ref):
"""Retrieve the data for a reference."""
label = get_value_in_tag(ref, 'label')
label = re.sub('\D', '', label)
for innerref in ref.getElementsByTagName('mixed-citation'):
ref_type = innerref.getAttribute('publication-type')
institut... |
Adds the reference to the record | def _add_references(self, rec):
""" Adds the reference to the record """
for ref in self.document.getElementsByTagName('ref'):
for ref_type, doi, authors, collaboration, journal, volume, page, year,\
label, arxiv, publisher, institution, unstructured_text,\
... |
Reads a xml file in JATS format and returns a xml string in marc format | def get_record(self, xml_file):
""" Reads a xml file in JATS format and returns
a xml string in marc format """
self.document = parse(xml_file)
if get_value_in_tag(self.document, "meta"):
raise ApsPackageXMLError("The XML format of %s is not correct"
... |
Connects and logins to the server. | def connect(self):
""" Connects and logins to the server. """
self._ftp.connect()
self._ftp.login(user=self._username, passwd=self._passwd) |
Downloads a whole folder from the server. FtpHandler. download_folder () will download all the files from the server in the working directory. | def download_folder(self, folder='', target_folder=''):
""" Downloads a whole folder from the server.
FtpHandler.download_folder() will download all the files
from the server in the working directory.
:param folder: the absolute path for the folder on the server.
:type folder: ... |
Downloads a file from the FTP server to target folder | def download(self, source_file, target_folder=''):
""" Downloads a file from the FTP server to target folder
:param source_file: the absolute path for the file on the server
it can be the one of the files coming from
FtpHandler.dir().
:type source_file: str... |
Changes the working directory on the server. | def cd(self, folder):
""" Changes the working directory on the server.
:param folder: the desired directory.
:type folder: string
"""
if folder.startswith('/'):
self._ftp.cwd(folder)
else:
for subfolder in folder.split('/'):
if sub... |
Lists the files and folders of a specific directory default is the current working directory. | def ls(self, folder=''):
""" Lists the files and folders of a specific directory
default is the current working directory.
:param folder: the folder to be listed.
:type folder: string
:returns: a tuple with the list of files in the folder
and the list of subfo... |
Lists all the files on the folder given as parameter. FtpHandler. dir () lists all the files on the server. | def dir(self, folder='', prefix=''):
""" Lists all the files on the folder given as parameter.
FtpHandler.dir() lists all the files on the server.
:para folder: the folder to be listed.
:type folder: string
:param prefix: it does not belong to the interface,
... |
Creates a folder in the server | def mkdir(self, folder):
""" Creates a folder in the server
:param folder: the folder to be created.
:type folder: string
"""
current_folder = self._ftp.pwd()
#creates the necessary folders on
#the server if they don't exist
folders = folder.split('/')
... |
Delete a file from the server. | def rm(self, filename):
""" Delete a file from the server.
:param filename: the file to be deleted.
:type filename: string
"""
try:
self._ftp.delete(filename)
except error_perm: # target is either a directory
# either it does not ... |
Delete a folder from the server. | def rmdir(self, foldername):
""" Delete a folder from the server.
:param foldername: the folder to be deleted.
:type foldername: string
"""
current_folder = self._ftp.pwd()
try:
self.cd(foldername)
except error_perm:
print('550 Delete oper... |
Returns the filesize of a file | def get_filesize(self, filename):
""" Returns the filesize of a file
:param filename: the full path to the file on the server.
:type filename: string
:returns: string representation of the filesize.
"""
result = []
def dir_callback(val):
result.appe... |
Uploads a file on the server to the desired location | def upload(self, filename, location=''):
""" Uploads a file on the server to the desired location
:param filename: the name of the file to be uploaded.
:type filename: string
:param location: the directory in which the file will
be stored.
:type location... |
Parses a block of text indiscriminately | def parse_data(self, text, maxwidth, maxheight, template_dir, context,
urlize_all_links):
"""
Parses a block of text indiscriminately
"""
# create a dictionary of user urls -> rendered responses
replacements = {}
user_urls = set(re.findall(URL_RE, text)... |
Parses a block of text rendering links that occur on their own line normally but rendering inline links using a special template dir | def parse_data(self, text, maxwidth, maxheight, template_dir, context,
urlize_all_links):
"""
Parses a block of text rendering links that occur on their own line
normally but rendering inline links using a special template dir
"""
block_parser = TextBlockParse... |
Do the legwork of logging into the Midas Server instance storing the API key and token. | def login(email=None, password=None, api_key=None, application='Default',
url=None, verify_ssl_certificate=True):
"""
Do the legwork of logging into the Midas Server instance, storing the API
key and token.
:param email: (optional) Email address to login with. If not set, the
console ... |
Renew or get a token to use for transactions with the Midas Server instance. | def renew_token():
"""
Renew or get a token to use for transactions with the Midas Server
instance.
:returns: API token.
:rtype: string
"""
session.token = session.communicator.login_with_api_key(
session.email, session.api_key, application=session.application)
if len(session.to... |
Create an item from the local file in the Midas Server folder corresponding to the parent folder id. | def _create_or_reuse_item(local_file, parent_folder_id, reuse_existing=False):
"""
Create an item from the local file in the Midas Server folder corresponding
to the parent folder id.
:param local_file: full path to a file on the local file system
:type local_file: string
:param parent_folder_i... |
Create a folder from the local file in the midas folder corresponding to the parent folder id. | def _create_or_reuse_folder(local_folder, parent_folder_id,
reuse_existing=False):
"""
Create a folder from the local file in the midas folder corresponding to
the parent folder id.
:param local_folder: full path to a directory on the local file system
:type local_folder... |
Create and return a hex checksum using the MD5 sum of the passed in file. This will stream the file rather than load it all into memory. | def _streaming_file_md5(file_path):
"""
Create and return a hex checksum using the MD5 sum of the passed in file.
This will stream the file, rather than load it all into memory.
:param file_path: full path to the file
:type file_path: string
:returns: a hex checksum
:rtype: string
"""
... |
Create a bitstream in the given item. | def _create_bitstream(file_path, local_file, item_id, log_ind=None):
"""
Create a bitstream in the given item.
:param file_path: full path to the local file
:type file_path: string
:param local_file: name of the local file
:type local_file: string
:param log_ind: (optional) any additional m... |
Function for doing an upload of a file as an item. This should be a building block for user - level functions. | def _upload_as_item(local_file, parent_folder_id, file_path,
reuse_existing=False):
"""
Function for doing an upload of a file as an item. This should be a
building block for user-level functions.
:param local_file: name of local file to upload
:type local_file: string
:para... |
Function for creating a remote folder and returning the id. This should be a building block for user - level functions. | def _create_folder(local_folder, parent_folder_id):
"""
Function for creating a remote folder and returning the id. This should be
a building block for user-level functions.
:param local_folder: full path to a local folder
:type local_folder: string
:param parent_folder_id: id of parent folder ... |
Function to recursively upload a folder and all of its descendants. | def _upload_folder_recursive(local_folder,
parent_folder_id,
leaf_folders_as_items=False,
reuse_existing=False):
"""
Function to recursively upload a folder and all of its descendants.
:param local_folder: full path to l... |
Return whether a folder contains only files. This will be False if the folder contains any subdirectories. | def _has_only_files(local_folder):
"""
Return whether a folder contains only files. This will be False if the
folder contains any subdirectories.
:param local_folder: full path to the local folder
:type local_folder: string
:returns: True if the folder contains only files
:rtype: bool
"... |
Upload a folder as a new item. Take a folder and use its base name as the name of a new item. Then upload its containing files into the new item as bitstreams. | def _upload_folder_as_item(local_folder, parent_folder_id,
reuse_existing=False):
"""
Upload a folder as a new item. Take a folder and use its base name as the
name of a new item. Then, upload its containing files into the new item as
bitstreams.
:param local_folder: The ... |
Upload a pattern of files. This will recursively walk down every tree in the file pattern to create a hierarchy on the server. As of right now this places the file into the currently logged in user s home directory. | def upload(file_pattern, destination='Private', leaf_folders_as_items=False,
reuse_existing=False):
"""
Upload a pattern of files. This will recursively walk down every tree in
the file pattern to create a hierarchy on the server. As of right now, this
places the file into the currently logge... |
Descend a path to return a folder id starting from the given folder id. | def _descend_folder_for_id(parsed_path, folder_id):
"""
Descend a path to return a folder id starting from the given folder id.
:param parsed_path: a list of folders from top to bottom of a hierarchy
:type parsed_path: list[string]
:param folder_id: The id of the folder from which to start the desc... |
Find an item or folder matching the name. A folder will be found first if both are present. | def _search_folder_for_item_or_folder(name, folder_id):
"""
Find an item or folder matching the name. A folder will be found first if
both are present.
:param name: The name of the resource
:type name: string
:param folder_id: The folder to search within
:type folder_id: int | long
:ret... |
Get a folder id from a path on the server. | def _find_resource_id_from_path(path):
"""
Get a folder id from a path on the server.
Warning: This is NOT efficient at all.
The schema for this path is:
path := "/users/<name>/" | "/communities/<name>" , {<subfolder>/}
name := <firstname> , "_" , <lastname>
:param path: The virtual path ... |
Download a folder to the specified path along with any children. | def _download_folder_recursive(folder_id, path='.'):
"""
Download a folder to the specified path along with any children.
:param folder_id: The id of the target folder
:type folder_id: int | long
:param path: (optional) the location to download the folder
:type path: string
"""
session.... |
Download the requested item to the specified path. | def _download_item(item_id, path='.', item=None):
"""
Download the requested item to the specified path.
:param item_id: The id of the item to be downloaded
:type item_id: int | long
:param path: (optional) the location to download the item
:type path: string
:param item: The dict of item i... |
Recursively download a file or item from the Midas Server instance. | def download(server_path, local_path='.'):
"""
Recursively download a file or item from the Midas Server instance.
:param server_path: The location on the server to find the resource to
download
:type server_path: string
:param local_path: The location on the client to store the downloaded ... |
Do the generic processing of a request to the server. | def request(self, method, parameters=None, file_payload=None):
"""
Do the generic processing of a request to the server.
If file_payload is specified, it will be PUT to the server.
:param method: Desired API method
:type method: string
:param parameters: (optional) Para... |
Login and get a token. If you do not specify a specific application Default will be used. | def login_with_api_key(self, email, api_key, application='Default'):
"""
Login and get a token. If you do not specify a specific application,
'Default' will be used.
:param email: Email address of the user
:type email: string
:param api_key: API key assigned to the user
... |
List the folders in the users home area. | def list_user_folders(self, token):
"""
List the folders in the users home area.
:param token: A valid token for the user in question.
:type token: string
:returns: List of dictionaries containing folder information.
:rtype: list[dict]
"""
parameters = di... |
Get the default API key for a user. | def get_default_api_key(self, email, password):
"""
Get the default API key for a user.
:param email: The email of the user.
:type email: string
:param password: The user's password.
:type password: string
:returns: API key to confirm that it was fetched successf... |
List the public users in the system. | def list_users(self, limit=20):
"""
List the public users in the system.
:param limit: (optional) The number of users to fetch.
:type limit: int | long
:returns: The list of users.
:rtype: list[dict]
"""
parameters = dict()
parameters['limit'] = l... |
Get a user by the first and last name of that user. | def get_user_by_name(self, firstname, lastname):
"""
Get a user by the first and last name of that user.
:param firstname: The first name of the user.
:type firstname: string
:param lastname: The last name of the user.
:type lastname: string
:returns: The user re... |
Get a user by the first and last name of that user. | def get_user_by_id(self, user_id):
"""
Get a user by the first and last name of that user.
:param user_id: The id of the desired user.
:type user_id: int | long
:returns: The user requested.
:rtype: dict
"""
parameters = dict()
parameters['user_id... |
Get a user by the email of that user. | def get_user_by_email(self, email):
"""
Get a user by the email of that user.
:param email: The email of the desired user.
:type email: string
:returns: The user requested.
:rtype: dict
"""
parameters = dict()
parameters['email'] = email
r... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.