lynguine.access
The access module provides functionality for accessing data from various sources, including local files, web resources, and databases.
IO Module
Access-stage I/O for lynguine.
Flow-level readers (read_data, write_data, directory globs) confine
configured paths with extract_full_filename / confine_configured_path
before calling into file helpers (CIP-000A).
The filename helpers below (read_yaml_file, read_json_file, and the
other *_file functions) are trusted-caller primitives: they open()
the path they are given and do not apply allowed_roots. Untrusted or
config-supplied names must be confined at the flow boundary first, not
passed in raw from HTTP or interface YAML. CodeQL py/path-injection
on those open() sites is a trusted-caller primitive, not a missing
jail (CIP-000D cluster A).
- lynguine.access.io.gzip_codec_from_name(filename)[source]
Return
gzipif filename declares compression by suffix.
- lynguine.access.io.resolve_text_codec(filename, compress=None)[source]
Declare gzip from suffix and/or
compress: gzip(CIP-0015).A
.ymlname is never treated as gzip.compress: gzipwith a non-.gzfilename is an error.
- lynguine.access.io.open_text_store(filename, mode, compress=None, compress_level=6)[source]
Open a YAML/JSON store as text, optionally gzip-wrapped.
- exception lynguine.access.io.PyArrowMissingError[source]
Bases:
ImportErrorRaised when parquet IO is requested but pyarrow is not installed.
- add_note()
Exception.add_note(note) – add a note to the exception
- args
- msg
exception message
- name
module name
- path
module path
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- lynguine.access.io.parquet_codec_from_file(filename)[source]
Column codec from parquet metadata without loading the table.
- 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.
A top-level YAML mapping is always treated as a single-row table (constants / parameters). All-scalar maps keep an explicit index (default
value). Maps with nested dict/list values become one row with those values as cell objects, matchingread_markdown.Optional
fieldsprojects the document before the row is formed (top-level keys, dotted paths, orfield+path/liquid).A YAML sequence of mappings remains a multi-row table.
- Parameters:
details (dict) – The details of the file to be read.
- Returns:
The data read from the file.
- Return type:
- Raises:
ValueError – If the document is neither a mapping nor a sequence.
- 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.
Opt-in
recursive: trueon a source entry (or ondetails) enablesglob.glob(..., recursive=True)so patterns such as**/*.ymlwalk nested trees. Default is non-recursive;**is only meaningful whenrecursiveis true (CIP-000F).Opt-in
fieldson a source entry (or ondetails) projects each mapping-valued file to the listed top-level keys before normalize (CIP-000F). Absentfieldskeeps full-document behaviour.include_start_directory(source entry ordetails, defaultTrue) controls whether matches whose immediate parent is the sourcedirectoryitself are kept. SetFalsefor descendants-only discovery (e.g. nested**/_referia.ymlwithout the file in.).Opt-in
exclude(source entry ordetails, list of glob strings) drops matches whose path relative to the source directory matches any pattern after glob / regexp /include_start_directory(CIP-0018).today/**omits that directory and everything under it. Absent or emptyexcludekeeps today’s match set.- 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.
Trusted-caller API: entries in
filelistare not confined here. Directory-glob flow paths confine before callingread_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, fields=None, source_directory=None)[source]
Read files from a given list.
Trusted-caller API: this function does not apply
allowed_roots. Callers that have configuration or request-derived names must confine each path first (CIP-000A).When
fieldsis set, each mapping-valued payload is reduced to those top-level keys before pathstore_fieldsare appended (CIP-000F).- Parameters:
filelist (list) – The list of files to be read.
store_fields (dict) – The fields to be stored in the data.
filereader (function) – The function to be used to read the file.
filereader_args (dict) – The arguments to be passed to the filereader.
fields (list or None) – Optional list of top-level keys to keep from each mapping.
source_directory (str or None) – Glob root used to compute
sourceDirectoryrelative to the catalog, not cwd (CIP-0018).
- 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, compress=None)[source]
Read a json file and return a python dictionary.
Trusted-caller I/O: does not confine
filename. Configured or untrusted names must go throughextract_full_filenamefirst (CIP-000A).
- lynguine.access.io.write_json_file(data, filename, compress=None, compress_level=6)[source]
Write a json file from a python dictionary.
Trusted-caller I/O: does not confine
filename(CIP-000A).
- lynguine.access.io.read_txt_file(filename)[source]
Read a text file and return a dictionary with the content.
Trusted-caller I/O: does not confine
filename(CIP-000A).
- 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.is_markdown_yaml_path(filename)[source]
True when
filenameis a markdown file used as a YAML store.
- lynguine.access.io.read_yaml_file(filename, compress=None)[source]
Read a yaml file and return a python dictionary.
Trusted-caller I/O: does not confine
filename. Configured or untrusted names must go throughextract_full_filenamefirst (CIP-000A)..yml.gzis gzip YAML (CIP-0015); a.ymlfile whose bytes are gzip is an error (no magic-byte decode).A
.md/.markdownpath is YAML frontmatter plus a body. The body is stored ascontentso the file is a YAML mapping with one extra field, not a second document thatsafe_loadwould drop.
- lynguine.access.io.read_bibtex_file(filename)[source]
Read a bibtex file and return a python dictionary.
Trusted-caller I/O: does not confine
filename(CIP-000A).
- lynguine.access.io.write_bibtex_file(data, filename)[source]
Write a bibtex file from a python dictionary.
Trusted-caller I/O: does not confine
filename(CIP-000A).
- lynguine.access.io.write_yaml_file(data, filename, compress=None, compress_level=6)[source]
Write a yaml file from a python dictionary.
Trusted-caller I/O: does not confine
filename(CIP-000A)..yml.gzwrites gzip YAML (CIP-0015).
- 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.
Trusted-caller I/O: does not confine
filename(CIP-000A).
- 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
Trusted-caller I/O: does not confine
filename(CIP-000A).
- 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_parquet(details)[source]
Read a parquet table (CIP-0015 phase 2). Requires
lynguine[parquet].
- 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.
When
indexnames a generated column, later duplicate values in that column are disambiguated so the frame keepsnrowsafterfrom_flowsets the index.- 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.
The path is confined via
extract_full_filename(CIP-000A). The followingopen()is still a trusted-caller primitive as far as CodeQL is concerned (CIP-000D cluster A).- 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_parquet(df, details)[source]
Write a parquet table with list<float32> numeric list columns.
Requires
lynguine[parquet]. Default codec is snappy; setcompress: zstd(or gzip/brotli/lz4/none) to override.
- 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.
Sources join left to right. Two-way overlaps keep the left column and suffix the right (default
_right). A later source that would recreate an existing suffixed name is dropped: earlier columns win.Optional per-right-specification
normalize: casefoldjoins on Unicode-casefolded keys while preserving left-side orthography (CIP-001C). Omit the key for case-sensitive (pandas-compatible) joins.- 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.compose_wide_column_name(key, field, *, separator='_', order='index_then_field')[source]
Build a wide column name from index key and field (CIP-0010).
- lynguine.access.io.parse_wide_column_name(name, *, separator='_', order='index_then_field', keys, fields=None)[source]
Parse a wide column name into
(key, field)(CIP-0010 Pattern A).keysare the authoritative index labels (e.g. fromflattenKeys). Matching prefers longer key strings so one key is not a prefix of another. Whenfieldsis given, names must match an exact key/field composition; otherwise the remainder after the key+separator is the field name.
- lynguine.access.io.wide_flatten_dataframe(df, *, separator='_', order='index_then_field', columns=None, keys_field='flattenKeys')[source]
Reshape many rows into one row with index-augmented column names (CIP-0010).
Turns an
N × MDataFrame with a unique index into a1 × (N×M)frame whose column names are{index}{separator}{field}(or{field}{separator}{index}whenorderisfield_then_index).When
keys_fieldis set (defaultflattenKeys), the wide row also carries an ordered list of former index labels for Liquid/view loops. Passkeys_field=Noneto omit that column.Empty input (no rows) yields a single empty row (plus empty
keys_fieldlist when enabled). Optionalcolumnsselects value fields to widen; other columns are dropped (not kept as globals).v1 policy:
separatormust not appear instr(index)labels so names stay unambiguously splittable.- Parameters:
df (DataFrame) – Source frame; the current index labels identify each former row.
separator (str) – Joiner between index and field in output names.
order (str) –
index_then_fieldorfield_then_index.columns (list | None) – Optional subset of value columns to widen.
keys_field (str | None) – Column name for the ordered key list, or
Noneto omit.
- Returns:
Single-row DataFrame with flat string column names.
- Raises:
ValueError – On invalid
order, non-unique index, unknowncolumns, keys field collision, or separator in an index label.- Return type:
DataFrame
- lynguine.access.io.wide_unflatten_dataframe(wide, *, separator='_', order='index_then_field', keys_field='flattenKeys', fields=None)[source]
Inverse of materialized
wide_flatten_dataframe()(CIP-0010 Pattern B).Rebuilds a tall frame from a single wide row. Uses
keys_field(defaultflattenKeys) for index labels when present; otherwise keys must be recoverable from column names viafieldsor parse rules.Not the default Save path for catalogs — prefer Pattern A virtual views.
- lynguine.access.io.wide_view_get(data, wide_name, *, separator='_', order='index_then_field', keys=None, fields=None)[source]
Get a tall-store cell via a wide column name (CIP-0010 Pattern A).
Does not reshape
data. ForCustomDataFrameuses focusset_index/set_column/get_value; for a plain DataFrame uses label-based.at.
- lynguine.access.io.wide_view_set(data, wide_name, value, *, separator='_', order='index_then_field', keys=None, fields=None)[source]
Set a tall-store cell via a wide column name (CIP-0010 Pattern A).
Does not reshape
data. Shape (nrows, ncols) is unchanged.
- lynguine.access.io.read_wide_flatten(details)[source]
Read a nested data source then wide-flatten to one row (CIP-0010).
Loads
specificationsviaread_data(so nestedcomputeruns throughfinalize_data), promotes a nested tall index when needed, then applieswide_flatten_dataframe(). The outerfinalize_datainread_data()may then runcomputeon the wide row.This is a materialized snapshot (Pattern B). For editable catalogs, prefer tall store +
wide_view_get()/wide_view_set()(Pattern A).- Parameters:
details (dict) – Must include
type: wide_flattenandspecifications. Optional:separator(default_),order(defaultindex_then_field),columns,index(label of the singleton wide row — same role as wrappingindexonstack/local; omit for legacy0),keys_field(defaultflattenKeys; set false/null to omit). Tall identity before flatten comes from nestedspecifications.index(column promoted viaset_index) or from the nested frame’s existing index.- Returns:
Single-row DataFrame with index-augmented column names.
- 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.explode_list_field(df, field, inherit=None, index=None)[source]
Expand a list-of-mappings column into one row per item (CIP-0014).
Parent columns listed in inherit are copied onto every child row. The list field itself is not kept. Child mapping keys become columns.
- Return type:
DataFrame
- lynguine.access.io.pack_dataframe(df, columns, index_value='corpus', index_name='Name', drop_incomplete=False, incomplete_field='embedding')[source]
Stack selected columns into one row of aligned array cells (CIP-0014).
- Return type:
DataFrame
- lynguine.access.io.omit_nested_keys_frame(df, details)[source]
Copy list-of-dict cells without bulky nested keys (CIP-0014 write).
omit_nested_keysmaps a column name to keys to strip, e.g.extraction_phrases: [embedding]. The source frame is not mutated, so in-memory embeddings remain available for pack on the same Save.
- lynguine.access.io.omit_columns_frame(df, details)[source]
Drop write-only-ignored columns (e.g. embedding) without mutating source.
- lynguine.access.io.reshape_for_write(df, details)[source]
Apply CIP-0014 explode / pack declared on a store, then write.
- Return type:
DataFrame
- lynguine.access.io.store_stat(details)[source]
File facts for a named store without loading the table (CIP-0015).
- Return type:
- 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.
IO Types (CIP-0019)
Tabular IO type registry (CIP-0019).
Builtin type: values stay in read_data / write_data. Packages
outside lynguine register extra names with register_io_type. This is
the table-store sibling of CIP-0013 register_strategy (documents).
Do not import this module for its side effects from import lynguine.
Entry points in group lynguine.io_types load only when a matching
type: is requested and is not already registered.
- exception lynguine.access.io_types.ReservedIOTypeError[source]
Bases:
ValueErrorRaised when a plugin tries to register a builtin
type:name.- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lynguine.access.io_types.ReadOnlyIOTypeError[source]
Bases:
ValueErrorRaised when
write_datais asked to write a read-only type.- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lynguine.access.io_types.UnknownIOTypeError[source]
Bases:
ValueErrorRaised when
get_io_typeis asked for an unregistered name.- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lynguine.access.io_types.PluginImportError[source]
Bases:
ValueErrorRaised when a
plugins:module or entry point fails to load.- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- exception lynguine.access.io_types.MissingIOCredentialError[source]
Bases:
ValueErrorRaised when a plugin type needs
credential:and the item omitted it.- add_note()
Exception.add_note(note) – add a note to the exception
- args
- with_traceback()
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class lynguine.access.io_types.IOType(name, read, write=None, credential_type=None)[source]
Bases:
objectRegistered tabular reader, and optional writer, for one
type:.- Parameters:
- lynguine.access.io_types.is_reserved_io_type(name)[source]
Return True if name is a lynguine builtin
type:.
- lynguine.access.io_types.register_io_type(name, *, read, write=None, credential_type=None)[source]
Register a tabular IO type.
Replaces any prior plugin entry with the same name. Builtin names in
RESERVED_IO_TYPEScannot be registered.credential_type is a CIP-0005 validator kind (for example
google_oauthortrello_api). When set, lynguine fetches the secret named by the item’scredential:key and passes the payload to the plugin asdetails["credential_value"]. The plugin does not callCredentialManageritself.
- lynguine.access.io_types.get_io_type(name)[source]
Return the registered spec for name, or raise
UnknownIOTypeError.
- lynguine.access.io_types.plugins_from_mapping(mapping)[source]
Extract
plugins:module names from a details dict or Interface.
- lynguine.access.io_types.load_plugins(names, *, needed_type=None)[source]
Import listed plugin modules so they can call
register_io_type.Failed imports name the module. Other exceptions from the module propagate unchanged.
- Parameters:
needed_type (str | None)
- Return type:
None
- lynguine.access.io_types.unknown_io_type_message(kind, ftype)[source]
Error text for an unknown
type:; includes registered plugin names.
- lynguine.access.io_types.resolve_registered_io_type(name)[source]
Return a plugin spec for name, loading a matching entry point if needed.
Builtin reserved names are never resolved here, even if an entry point claims them.
- lynguine.access.io_types.bind_plugin_credentials(details, spec, *, operation)[source]
Resolve CIP-0005 secrets for a plugin that declared
credential_type.YAML
credential:names the stored key. The registeredcredential_typeis the validator kind. Returns a shallow copy of details withcredential_valueset to the stored payload (thevaluefield when present). Types with nocredential_typeare returned unchanged.
- lynguine.access.io_types.try_read_registered_type(details, ftype)[source]
Read via a plugin if ftype is registered. None means use builtins.
- Parameters:
ftype (str)
- Return type:
DataFrame | None
Download Module
- lynguine.access.download.load_data_resources_catalogue(catalogue_path, item=None)[source]
Load a pods-style data-resources catalogue from a local JSON path.
Accepts either a dict keyed by dataset name (
data_resources.json) or a mapping with a top-leveldatasetslist of entries that each includename.
- lynguine.access.download.materialise_data_resources(item, remote, interface=None, prompt=None)[source]
Expand a named pods catalogue entry into cached files (ods CIP-0003).
- lynguine.access.download.authorize_remote(remote, interface=None, *, label='remote', prompt=None)[source]
Prompt for licence acknowledgement before a remote materialise.
Honours
overide_manual_authorizeon the interface for non-interactive runs (CIP-0009).
- lynguine.access.download.download_url_to(url, save_path, *, suffix='')[source]
HTTP(S) GET
urland write the body tosave_path.
- lynguine.access.download.clone_or_pull_repo(git_url, repo_path)[source]
Clone
git_urlintorepo_path, or pull if a.gitdir exists.
- lynguine.access.download.materialise(item, interface=None, prompt=None)[source]
Materialise a
remote:artefact before the localtype:read.When
itemhas noremotekey, returnsNone(no-op), unlesssourceis a legacy remote mapping (type: url|github), which raises a migration error pointing atremote:.- Parameters:
item – Access-stage data item (may be a list of items).
interface – Optional Interface for authorize overrides.
prompt – Optional yes/no prompt callable.
- Returns:
Local path materialised or confirmed, a list of paths for list items, or
Nonewhen there is nothing to materialise.
- 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.