lnk.config package

lnk.config.cli module

The command-line interface to the config command.

lnk.config.configure module

Methods used to configure settings in the config files.

Note that these methods are not in any-way object-oriented or general-purpose, they solely execute the config command.

lnk.config.configure.be_quiet(manager, keys, values)[source]

Handles the case where the quiet flag was set.

The effective result is the same as if the quiet flag was not set, but it is done more efficiently because nothing needs to be formatted here.

Parameters:
  • keys (tuple) – The keys.
  • values (tuple) – The values.
lnk.config.configure.configure(which, command, keys, values, quiet, all_keys)[source]

Does the actual configuration-management.

Arguments:
which (str): The configuration file for which to configure settings
(e.g. ‘lnk’ or ‘bitly’).
command (str): Optionally, the command of the which for which
to configure settings (e.g. ‘link’).

keys (tuple): The keys to show. values (tuple): The values to give the keys. quiet (bool): Whether to output anything or just do the

configuration quietly.

all_keys (bool): Whether to show all keys.

Returns:
If quiet is True, nothing, else either a string-joined list of lines showing all updates, if values were supplied, else only the keys and if no keys were found (e.g. if the –all-keys was passed but the settings dictionary is empty) the string ‘Nothing to see...

‘.

lnk.config.configure.echo(*args)[source]

Echoes the return value of configure() to stdout.

Parameters:args (variadic) – The arguments to forward to configure().
lnk.config.configure.format_value(value)[source]

Formats a value for output.

Parameters:value – The value to format.
Returns:If the value is a list, returns a comma-separated string of the items in the list. If the value is a dictionary, returns a comma-separated string-representation of the key-value-pairs. Else returns the value, cast to a string.
lnk.config.configure.update(manager, key, values)[source]

Updates the configuration and returns a formatted string for the update.

Parameters:
  • manager (config.manager.Manager) – The manager instance used for interacting with the configuration file.
  • key (str) – The key to configure.
  • values (tuple) – The tuple of values. If not None, the first one will be popped out of this list and regarded as the new value for the key.
Returns:

A formatted line, following the schema ‘<key>: <old_value> => <new_value>’.

lnk.config.manager module

class lnk.config.manager.Manager(which=None, write=False)[source]

Bases: object

assert_open()[source]
close()[source]
items
keys
open(which)[source]
values
write()[source]
lnk.config.manager.get(which, key)[source]

Convenience method to retrieve only one key without having to instantiate a Manager object.

Module contents