lynguine.access
The access module provides functionality for accessing data from various sources, including local files, web resources, and databases.
IO Module
- class lynguine.access.io.LynguineSafeDumper(stream, default_style=None, default_flow_style=False, canonical=None, indent=None, width=None, allow_unicode=None, line_break=None, encoding=None, explicit_start=None, explicit_end=None, version=None, tags=None, sort_keys=True)[source]
Bases:
SafeDumper- ANCHOR_TEMPLATE = 'id%03d'
- DEFAULT_MAPPING_TAG = 'tag:yaml.org,2002:map'
- DEFAULT_SCALAR_TAG = 'tag:yaml.org,2002:str'
- DEFAULT_SEQUENCE_TAG = 'tag:yaml.org,2002:seq'
- DEFAULT_TAG_PREFIXES = {'!': '!', 'tag:yaml.org,2002:': '!!'}
- ESCAPE_REPLACEMENTS = {'\x00': '0', '\x07': 'a', '\x08': 'b', '\t': 't', '\n': 'n', '\x0b': 'v', '\x0c': 'f', '\r': 'r', '\x1b': 'e', '"': '"', '\\': '\\', '\x85': 'N', '\xa0': '_', '\u2028': 'L', '\u2029': 'P'}
- classmethod add_implicit_resolver(tag, regexp, first)
- classmethod add_multi_representer(data_type, representer)
- classmethod add_path_resolver(tag, path, kind=None)
- classmethod add_representer(data_type, representer)
- analyze_scalar(scalar)
- anchor_node(node)
- ascend_resolver()
- check_empty_document()
- check_empty_mapping()
- check_empty_sequence()
- check_resolver_prefix(depth, path, kind, current_node, current_index)
- check_simple_key()
- close()
- descend_resolver(current_node, current_index)
- determine_block_hints(text)
- dispose()
- emit(event)
- expect_alias()
- expect_block_mapping()
- expect_block_mapping_key(first=False)
- expect_block_mapping_simple_value()
- expect_block_mapping_value()
- expect_block_sequence()
- expect_block_sequence_item(first=False)
- expect_document_end()
- expect_document_root()
- expect_document_start(first=False)
- expect_first_block_mapping_key()
- expect_first_block_sequence_item()
- expect_first_document_start()
- expect_first_flow_mapping_key()
- expect_first_flow_sequence_item()
- expect_flow_mapping()
- expect_flow_mapping_key()
- expect_flow_mapping_simple_value()
- expect_flow_mapping_value()
- expect_flow_sequence()
- expect_flow_sequence_item()
- expect_node(root=False, sequence=False, mapping=False, simple_key=False)
- expect_nothing()
- expect_scalar()
- expect_stream_start()
- flush_stream()
- generate_anchor(node)
- ignore_aliases(data)
- increase_indent(flow=False, indentless=False)
- inf_value = inf
- need_events(count)
- need_more_events()
- open()
- prepare_anchor(anchor)
- prepare_tag(tag)
- prepare_tag_handle(handle)
- prepare_tag_prefix(prefix)
- prepare_version(version)
- process_anchor(indicator)
- process_scalar()
- process_tag()
- represent(data)
- represent_binary(data)
- represent_bool(data)
- represent_data(data)
- represent_date(data)
- represent_datetime(data)
- represent_dict(data)
- represent_float(data)
- represent_int(data)
- represent_list(data)
- represent_mapping(tag, mapping, flow_style=None)
- represent_none(data)
- represent_scalar(tag, value, style=None)
- represent_sequence(tag, sequence, flow_style=None)
- represent_set(data)
- represent_str(data)
- represent_undefined(data)
- represent_yaml_object(tag, data, cls, flow_style=None)
- resolve(kind, value, implicit)
- serialize(node)
- serialize_node(node, parent, index)
- write_double_quoted(text, split=True)
- write_folded(text)
- write_indent()
- write_indicator(indicator, need_whitespace, whitespace=False, indention=False)
- write_line_break(data=None)
- write_literal(text)
- write_plain(text, split=True)
- write_single_quoted(text, split=True)
- write_stream_end()
- write_stream_start()
- write_tag_directive(handle_text, prefix_text)
- write_version_directive(version_text)
- yaml_implicit_resolvers = {'': [('tag:yaml.org,2002:null', re.compile('^(?: ~\n |null|Null|NULL\n | )$', re.VERBOSE))], '!': [('tag:yaml.org,2002:yaml', re.compile('^(?:!|&|\\*)$'))], '&': [('tag:yaml.org,2002:yaml', re.compile('^(?:!|&|\\*)$'))], '*': [('tag:yaml.org,2002:yaml', re.compile('^(?:!|&|\\*)$'))], '+': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE))], '-': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE))], '.': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE))], '0': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '1': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '2': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '3': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '4': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '5': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '6': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '7': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '8': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '9': [('tag:yaml.org,2002:float', re.compile('^(?:[-+]?(?:[0-9][0-9_]*)\\.[0-9_]*(?:[eE][-+][0-9]+)?\n |\\.[0-9][0-9_]*(?:[eE][-+][0-9]+)?\n |[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*\n , re.VERBOSE)), ('tag:yaml.org,2002:int', re.compile('^(?:[-+]?0b[0-1_]+\n |[-+]?0[0-7_]+\n |[-+]?(?:0|[1-9][0-9_]*)\n |[-+]?0x[0-9a-fA-F_]+\n |[-+]?[1-9][0-9_]*(?::[0-5]?[0-9]), re.VERBOSE)), ('tag:yaml.org,2002:timestamp', re.compile('^(?:[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\n |[0-9][0-9][0-9][0-9] -[0-9][0-9]? -[0-9][0-9]?\n (?:[Tt]|[ \\t]+)[0-9][0-9]?\n :[0-9][0-9], re.VERBOSE))], '<': [('tag:yaml.org,2002:merge', re.compile('^(?:<<)$'))], '=': [('tag:yaml.org,2002:value', re.compile('^(?:=)$'))], 'F': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE))], 'N': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE)), ('tag:yaml.org,2002:null', re.compile('^(?: ~\n |null|Null|NULL\n | )$', re.VERBOSE))], 'O': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE))], 'T': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE))], 'Y': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE))], 'f': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE))], 'n': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE)), ('tag:yaml.org,2002:null', re.compile('^(?: ~\n |null|Null|NULL\n | )$', re.VERBOSE))], 'o': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE))], 't': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE))], 'y': [('tag:yaml.org,2002:bool', re.compile('^(?:yes|Yes|YES|no|No|NO\n |true|True|TRUE|false|False|FALSE\n |on|On|ON|off|Off|OFF)$', re.VERBOSE))], '~': [('tag:yaml.org,2002:null', re.compile('^(?: ~\n |null|Null|NULL\n | )$', re.VERBOSE))]}
- yaml_multi_representers = {}
- yaml_path_resolvers = {}
- yaml_representers = {<class 'NoneType'>: <function SafeRepresenter.represent_none>, <class 'bool'>: <function SafeRepresenter.represent_bool>, <class 'bytes'>: <function SafeRepresenter.represent_binary>, <class 'datetime.date'>: <function SafeRepresenter.represent_date>, <class 'datetime.datetime'>: <function SafeRepresenter.represent_datetime>, <class 'dict'>: <function SafeRepresenter.represent_dict>, <class 'float'>: <function SafeRepresenter.represent_float>, <class 'int'>: <function SafeRepresenter.represent_int>, <class 'list'>: <function SafeRepresenter.represent_list>, <class 'set'>: <function SafeRepresenter.represent_set>, <class 'str'>: <function multiline_str_representer>, <class 'tuple'>: <function SafeRepresenter.represent_list>, None: <function SafeRepresenter.represent_undefined>}
- lynguine.access.io.read_json(details)[source]
Read data from a json file.
- Parameters:
details (dict) – The details of the file to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.write_json(df, details)[source]
Write data to a json file.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data to be written.
details (dict) – The details of the file to be written.
- lynguine.access.io.read_yaml(details)[source]
Read data from a yaml file.
- Parameters:
details (dict) – The details of the file to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.read_markdown(details)[source]
Read data from a markdown file.
- Parameters:
details (dict) – The details of the file to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.write_markdown(df, details)[source]
Write data to a markdown file.
- Parameters:
df (pandas.DataFrame) – The data to be written.
details (dict) – The details of the file to be written.
- lynguine.access.io.write_yaml(df, details)[source]
Write data to a yaml file.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data to be written.
details (dict) – The details of the file to be written.
- lynguine.access.io.read_bibtex(details)[source]
Read data from a bibtex file.
- Parameters:
details (dict) – The details of the file to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.write_bibtex(df, details)[source]
Write data to a bibtex file.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data to be written.
details (dict) – The details of the file to be written.
- lynguine.access.io.read_directory(details, filereader=None, filereader_args={}, default_glob='*', source=None)[source]
Read data from a directory of files.
- Parameters:
details (dict) – The details of the directory to be read.
filereader (function) – The function to be used to read the file.
filereader_args (dict) – The arguments to be passed to the filereader.
default_glob (str) – The default glob to be used if none is specified.
source (dict) – The source information for the data.
- Raises:
ValueError – if the same filename is specified multiple times.
- lynguine.access.io.read_list(filelist)[source]
Read from a list of files.
- Parameters:
filelist (list) – The list of files to be read.
- Returns:
The data read from the files.
- Return type:
- lynguine.access.io.read_files(filelist, store_fields=None, filereader=None, filereader_args=None)[source]
Read files from a given list.
- Parameters:
- Returns:
The data read from the files.
- Return type:
- lynguine.access.io.write_directory(df, details, filewriter=None, filewriter_args={})[source]
Write scoring data to a directory of files.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data to be written.
details (dict) – The details of the file to be written.
filewriter (function) – The function to be used to write the file.
filewriter_args (dict) – The arguments to be passed to the filewriter.
- Raises:
ValueError – if the same filename is specified multiple times.
- lynguine.access.io.read_json_file(filename)[source]
Read a json file and return a python dictionary.
- lynguine.access.io.write_json_file(data, filename)[source]
Write a json file from a python dicitonary.
- lynguine.access.io.read_txt_file(filename)[source]
Read a text file and return a dictionary with the content.
- lynguine.access.io.default_file_reader(typ)[source]
Return the default file reader for a given type.
- Parameters:
typ (str) – The type of file to be read.
- Returns:
The default file reader.
- Return type:
function
- Raises:
ValueError – if the type is not recognised.
- lynguine.access.io.default_file_writer(typ)[source]
Return the default file writer for a given type.
- Parameters:
typ (str) – The type of file to be written.
- Returns:
The default file writer.
- Return type:
function
- Raises:
ValueError – if the type is not recognised.
- lynguine.access.io.read_yaml_file(filename)[source]
Read a yaml file and return a python dictionary.
- lynguine.access.io.read_bibtex_file(filename)[source]
Red a bibtex file and return a python dictionary.
- lynguine.access.io.write_bibtex_file(data, filename)[source]
Write a bibtex file from a python dictionary.
- lynguine.access.io.write_yaml_file(data, filename)[source]
Write a yaml file from a python dictionary.
- lynguine.access.io.read_yaml_meta_file(filename)[source]
Read meta information associated with a file as a yaml and return a python dictionary if it exists.
- lynguine.access.io.write_yaml_meta_file(data, filename)[source]
Write meta information associated with a file to a yaml.
- lynguine.access.io.read_markdown_file(filename, include_content=True)[source]
Read a markdown file and return a python dictionary.
- lynguine.access.io.read_docx_file(filename, include_content=True)[source]
Read information from a docx file.
- lynguine.access.io.read_talk_file(filename, include_content=True)[source]
Read a markdown talk file.
- lynguine.access.io.read_talk_include_file(filename, include_content=True)[source]
Read a markdown talk include file.
- lynguine.access.io.write_url_file(data, filename, content, include_content=True)[source]
Write a url to a file
- lynguine.access.io.write_markdown_file(data, filename, content=None, include_content=True)[source]
Write a markdown file from a python dictionary
- lynguine.access.io.create_document_content(**kwargs)[source]
Create a document content from the arguments. :param content: The content of the document. :type content: str :param filename: The filename of the document. :type filename: str :param directory: The directory of the document. :type directory: str :return: The data, filename and content of the document. :rtype: tuple
- lynguine.access.io.create_letter(**kwargs)[source]
Create a markdown letter. :param content: The content of the letter. :type content: str :param filename: The filename of the letter. :type filename: str :param directory: The directory of the letter. :type directory: str :return: The data, filename and content of the letter. :rtype: tuple
- lynguine.access.io.write_letter_file(data, filename, content, include_content=True)[source]
Write a letter file from a python dictionary
- lynguine.access.io.write_formlink(data, filename, content, include_content=True)[source]
Write a url to prepopulate a Google form
- lynguine.access.io.write_docx_file(data, filename, content, include_content=True)[source]
Write a docx file from a python dictionary.
- lynguine.access.io.write_tex_file(data, filename, content, include_content=True)[source]
Write a docx file from a python dictionary.
- lynguine.access.io.read_csv(details)[source]
Read data from a csv file.
- Parameters:
details (dict) – The details of the file to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.read_excel(details)[source]
Read data from an excel spreadsheet.
- Parameters:
details (dict) – The details of the file to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.read_fake(details)[source]
Read data from an artificially generated source.
- Parameters:
details (dict) – The details of the data to be read.
- Returns:
The data read from the source.
- Return type:
- lynguine.access.io.read_local(details)[source]
Read data directly from details file.
- Parameters:
details (dict) – The details of the data to be read.
- Returns:
The data read from the settings file..
- Return type:
- Raises:
ValueError – If the ‘details’ is not a dictionary or is missing required keys.
- lynguine.access.io.read_gsheet(details)[source]
Read data from a Google sheet using secure credential management.
- Parameters:
details (dict) – The details of the file to be read.
- Returns:
The data read from the file.
- Return type:
- Raises:
ValueError – If credentials cannot be retrieved
- lynguine.access.io.write_excel(df, details)[source]
Write data to an excel spreadsheet.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data to be written.
details (dict) – The details of the file to be written.
- lynguine.access.io.write_csv(df, details)[source]
Write data to an csv spreadsheet.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data to be written.
details (dict) – The details of the file to be written.
- lynguine.access.io.write_gsheet(df, details)[source]
Write data to a Google sheet using secure credential management.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data to be written.
details (dict) – The details of the file to be written.
- Raises:
ValueError – If credentials cannot be retrieved
- lynguine.access.io.gdrf_(default_glob, filereader, name='', docstr='')[source]
Function generator for different directory readers.
- Parameters:
- Returns:
The function to be created.
- Return type:
function
- lynguine.access.io.gdwf_(filewriter, name='', docstr='')[source]
Function generator for different directory writers.
- lynguine.access.io.populate_directory_readers(readers)[source]
Populate the directory readers automatically creates functions for reading directories.
- Parameters:
readers (list) – The readers to be created.
- lynguine.access.io.populate_directory_writers(writers)[source]
This function automatically create functions for writing directories.
- Parameters:
writers (list) – The writers to be created.
- lynguine.access.io.finalize_data(df, interface)[source]
Finalize the data frame by augmenting with any columns.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data frame to be finalized.
interface (lynguine.config.interface.Interface) – The interface of the data frame.
- Returns:
The finalized data frame.
- Return type:
pandas.DataFrame or lynguine.data.CustomDataFrame
- lynguine.access.io.read_hstack(details)[source]
Read data from a horizontal stack of data sources.
- Parameters:
details (dict) – The details of the data to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.read_stack(details)[source]
Read data from a horizontal stack of data series, where each source is a single-row DataFrame. Returns a single-row DataFrame combining all sources.
- Parameters:
details (dict) – The details of the data series to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.read_vstack(details)[source]
Read data from a vertical stack of data sources.
- Parameters:
details (dict) – The details of the data to be read.
- Returns:
The data read from the file.
- Return type:
- lynguine.access.io.read_series(details)[source]
Read in the series data from the details given in configuration. A series type is a data frame where the indices aren’t unique. If read in as a series, then each entry in each column of data frame is converted to a list, where the number of elements of the list are the number of non-unique elements from the index.
- Parameters:
details (dict) – The details of the series data to be read.
- Returns:
The data read in.
- Return type:
- lynguine.access.io.read_data(details)[source]
Read in the data from the details given in configuration.
- Parameters:
details (dict) – The details of the data to be read.
- Returns:
The data read in.
- Return type:
- lynguine.access.io.read_auto(details)[source]
Read in the data from the details given in configuration. Use the file extension to determine the type of data to read.
- Parameters:
details (dict) – The details of the data to be read.
- Returns:
The data read in.
- Return type:
- lynguine.access.io.convert_data(read_details, write_details)[source]
Convert a data set from one form to another.
- lynguine.access.io.data_exists(details)[source]
Check if a particular data structure exists or needs to be created.
- lynguine.access.io.load_or_create_df(details, index)[source]
Load in a data frame or create it if it doesn’t exist yet.
- Parameters:
details (dict) – The details of the data to be loaded or created.
index (pandas.Index) – The index to be used if the data frame needs to be created.
- Returns:
The data frame.
- lynguine.access.io.globals_data(details, index=None)[source]
Load in the globals data to a data frame.
- Parameters:
details (dict) – The details of the data to be loaded.
- lynguine.access.io.cache(details, index=None)[source]
Load in the cache data to a data frame.
- Parameters:
details (dict) – The details of the data to be loaded.
- lynguine.access.io.scores(details, index=None)[source]
Load in the score data to data frames.
- Parameters:
details (dict) – The details of the data to be loaded.
- lynguine.access.io.series(details, index=None)[source]
Load in a series to data frame
- Parameters:
details (dict) – The details of the data to be loaded.
- lynguine.access.io.write_data(df, details)[source]
Write the data using the details given in configuration.
- Parameters:
df (pandas.DataFrame or lynguine.data.CustomDataFrame) – The data to be written.
details (dict) – The details of the data to be written.
- lynguine.access.io.read_bibtex_directory(details)
Read a directory of bibtex files.
- lynguine.access.io.read_docx_directory(details)
Read a directory of word files.
- lynguine.access.io.read_json_directory(details)
Read a directory of json files.
- lynguine.access.io.read_markdown_directory(details)
Read a directory of markdown files.
- lynguine.access.io.read_meta_directory(details)
Read a directory of yaml meta files.
- lynguine.access.io.read_plain_directory(details)
Read a directory of files.
- lynguine.access.io.read_yaml_directory(details)
Read a directory of yaml files.
- lynguine.access.io.write_json_directory(df, details)
Write a directory of json files.
- lynguine.access.io.write_markdown_directory(df, details)
Write a directory of markdown files.
- lynguine.access.io.write_meta_directory(df, details)
Write a directory of yaml meta files.
- lynguine.access.io.write_yaml_directory(df, details)
Write a directory of yaml files.
Download Module
- class lynguine.access.download.FileDownloader(interface, data_resources, data_name)[source]
Bases:
objectA class for downloading data files from a url.
Initialize the FileDownloader class. :param data_resources: The data resources dictionary. :param data_name: The name of the data to download.
- property interface
Return the interface object. :return: The interface object.
- property data_name
Return the name of the data to download. :return: The name of the data to download.
- property data_resources
Return the data resources dictionary. :return: The data resources dictionary.
- class lynguine.access.download.GitDownloader(interface, data_resources, data_name, git_url)[source]
Bases:
FileDownloaderInitialize the FileDownloader class. :param data_resources: The data resources dictionary. :param data_name: The name of the data to download.
- property data_name
Return the name of the data to download. :return: The name of the data to download.
- property data_resources
Return the data resources dictionary. :return: The data resources dictionary.
- download_data(prompt=<function prompt_stdin>)
Check with the user that they are happy with terms and conditions for the data, then download it. :param prompt: A function that takes a string and returns a boolean. :return: None :raises: ValueError if the data is not found.
- property interface
Return the interface object. :return: The interface object.