diff --git a/docs/index.rst b/docs/index.rst index 4f50419..da1523b 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -9,6 +9,27 @@ Ska Package Helpers .. automodule:: ska_helpers :members: +Logging +------- + +.. automodule:: ska_helpers.logging + :members: + + +Retry +----- + +.. automodule:: ska_helpers.retry + :members: + + +Setup Helpers +------------- + +.. automodule:: ska_helpers.setup_helper + :members: + + Utilities --------- diff --git a/ska_helpers/setup_helper.py b/ska_helpers/setup_helper.py new file mode 100644 index 0000000..beb04b9 --- /dev/null +++ b/ska_helpers/setup_helper.py @@ -0,0 +1,23 @@ +# Licensed under a 3-clause BSD style license - see LICENSE.rst + +def duplicate_package_info(vals, name_in, name_out): + """ + Duplicate a list or dict of values inplace, replacing ``name_in`` with ``name_out``. + + Normally used in setup.py for making a namespace package that copies a flat one. + For an example see setup.py in the ska_sun or Ska.Sun repo. + + :param vals: list or dict of values + :param name_in: string to replace at start of each value + :param name_out: output string + """ + import re + + for name in list(vals): + new_name = re.sub(f"^{name_in}", name_out, name) + if isinstance(vals, dict): + vals[new_name] = vals[name] + else: + vals.append(new_name) + +