Skip to content

Commit

Permalink
More man build cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dwoz committed Feb 2, 2024
1 parent 038b33a commit 04189d1
Show file tree
Hide file tree
Showing 8 changed files with 107 additions and 162 deletions.
1 change: 0 additions & 1 deletion doc/ref/pillar/all/index.rst
Expand Up @@ -14,4 +14,3 @@ pillar modules
git_pillar
gpg
nodegroups
postgres
1 change: 1 addition & 0 deletions doc/ref/serializers/all/index.rst
Expand Up @@ -13,6 +13,7 @@ serializer modules
:toctree:
:template: autosummary.rst.tmpl

configparser
json
msgpack
tomlmod
Expand Down
6 changes: 6 additions & 0 deletions doc/ref/serializers/all/salt.serializers.configparser.rst
@@ -0,0 +1,6 @@
=============================
salt.serializers.configparser
=============================

.. automodule:: salt.serializers.configparser
:members:
1 change: 0 additions & 1 deletion doc/ref/states/all/index.rst
Expand Up @@ -106,7 +106,6 @@ state modules
test
timezone
tls
tuned
uptime
user
win_appx
Expand Down
15 changes: 7 additions & 8 deletions doc/topics/releases/2017.7.0.rst
Expand Up @@ -581,14 +581,13 @@ if so, the old container is stopped and destroyed, and the temporary container
is renamed and started.

Salt still needs to translate arguments into the format which docker-py
expects, but if it does not properly do so, the :ref:`skip_translate
<docker-container-running-skip-translate>` argument can be used to skip input
translation on an argument-by-argument basis, and you can then format your SLS
file to pass the data in the format that the docker-py expects. This allows you
to work around any changes in Docker's API or issues with the input
translation, and continue to manage your Docker containers using Salt. Read the
documentation for :ref:`skip_translate
<docker-container-running-skip-translate>` for more information.
expects, but if it does not properly do so, the REMOVED DURRING MODULE
MIGRATION argument can be used to skip input translation on an
argument-by-argument basis, and you can then format your SLS file to pass the
data in the format that the docker-py expects. This allows you to work around
any changes in Docker's API or issues with the input translation, and continue
to manage your Docker containers using Salt. Read the documentation for REMOVED
DURRING MODULE MIGRATION for more information.

.. note::
When running the :py:func:`docker_container.running
Expand Down
6 changes: 3 additions & 3 deletions doc/topics/releases/2018.3.0.rst
Expand Up @@ -54,7 +54,7 @@ Lots of Docker Improvements
Much Improved Support for Docker Networking
*******************************************

The :py:func:`docker_network.present <salt.states.docker_network.present>`
The REMOVED DURRING MODULE MIGRATION
state has undergone a full rewrite, which includes the following improvements:

Full API Support for Network Management
Expand All @@ -70,15 +70,15 @@ Custom Subnets
**************

Custom subnets can now be configured. Both IPv4 and mixed IPv4/IPv6 networks
are supported. See :ref:`here <salt-states-docker-network-present-ipam>` for
are supported. See REMOVED DURRING MODULE MIGRATION for
more information.

Network Configuration in :py:func:`docker_container.running <salt.states.docker_container.running>` States
**********************************************************************************************************

A long-requested feature has finally been added! It is now possible to
configure static IPv4/IPv6 addresses, as well as links and labels. See
:ref:`here <salt-states-docker-container-network-management>` for more
REMOVDE DURRING MODULE MIGRATION for more
information.

.. note::
Expand Down
90 changes: 90 additions & 0 deletions salt/serializers/configparser.py
@@ -0,0 +1,90 @@
"""
salt.serializers.configparser
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 2016.3.0
Implements a configparser serializer.
"""

import configparser
import io

from salt.serializers import DeserializationError, SerializationError

__all__ = ["deserialize", "serialize", "available"]

available = True


def deserialize(stream_or_string, **options):
"""
Deserialize any string or stream like object into a Python data structure.
:param stream_or_string: stream or string to deserialize.
:param options: options given to lower configparser module.
"""

cp = configparser.ConfigParser(**options)

try:
if not isinstance(stream_or_string, (bytes, str)):
cp.read_file(stream_or_string)
else:
cp.read_file(io.StringIO(stream_or_string))
data = {}
for section_name in cp.sections():
section = {}
for k, v in cp.items(section_name):
section[k] = v
data[section_name] = section
return data
except Exception as error: # pylint: disable=broad-except
raise DeserializationError(error)


def serialize(obj, **options):
"""
Serialize Python data to a configparser formatted string or file.
:param obj: the data structure to serialize
:param options: options given to lower configparser module.
"""

try:
if not isinstance(obj, dict):
raise TypeError(
f"configparser can only serialize dictionaries, not {type(obj)}"
)
fp = options.pop("fp", None)
cp = configparser.ConfigParser(**options)
_read_dict(cp, obj)

if fp:
return cp.write(fp)
else:
s = io.StringIO()
cp.write(s)
return s.getvalue()
except Exception as error: # pylint: disable=broad-except
raise SerializationError(error)


def _is_defaultsect(section_name):
return section_name == configparser.DEFAULTSECT


def _read_dict(cp, dictionary):
"""
Cribbed from python3's ConfigParser.read_dict function.
"""
for section, keys in dictionary.items():
section = str(section)
if not _is_defaultsect(section):
cp.add_section(section)

for key, value in keys.items():
key = cp.optionxform(str(key))
if value is not None:
value = str(value)
cp.set(section, key, value)
149 changes: 0 additions & 149 deletions salt/states/tuned.py

This file was deleted.

0 comments on commit 04189d1

Please sign in to comment.