From 3ff9d2804079eb3ef4c3fbefec77d814265d9a1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Blondon?= Date: Thu, 8 Aug 2019 15:44:01 +0200 Subject: [PATCH 1/8] Add information about the overriding behavior of ConfigParser.read methods --- Doc/library/configparser.rst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 04b52dc7b21531..c4c7649e3abc90 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -136,6 +136,26 @@ sections [1]_. Note also that keys in sections are case-insensitive and stored in lowercase [1]_. +If we need to read several configurations, each one having more priority than the previous one, we can use the same :class:`ConfigParser` instance to override previous defined data and keep not redefined data. + +.. doctest:: + + >>> config = configparser.ConfigParser() + >>> config.read('example.ini') + ['example.ini'] + >>> config['topsecret.server.com']['Port'] + '50022' + >>> config.read_string("[topsecret.server.com]\nPort=48484") + >>> config['topsecret.server.com']['Port'] + '48484' + >>> config.read_dict({"topsecret.server.com": {"Port": 21212}}) + >>> config['topsecret.server.com']['Port'] + '21212' + >>> config['topsecret.server.com']['ForwardX11'] + 'no' + +This behaviour is equivalent to a :meth:`ConfigParser.read` call with several files passed to ``filenames`` parameter. + Supported Datatypes ------------------- From b3ea8555964d312fdcde241d97a3b47cc434b76d Mon Sep 17 00:00:00 2001 From: sblondon Date: Fri, 9 Aug 2019 11:15:16 +0200 Subject: [PATCH 2/8] Update Doc/library/configparser.rst Co-Authored-By: Kyle Stanley --- Doc/library/configparser.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index c4c7649e3abc90..6f8f9f4ed1f738 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -136,7 +136,9 @@ sections [1]_. Note also that keys in sections are case-insensitive and stored in lowercase [1]_. -If we need to read several configurations, each one having more priority than the previous one, we can use the same :class:`ConfigParser` instance to override previous defined data and keep not redefined data. + If it is necessary to read several configurations, with each one having more + priority than the previous one, an instance of :class:`ConfigParser` can be + used to override previously defined properties and retain existing ones. .. doctest:: From 73ea042bace328fe9af8eee17f88653df7058175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Blondon?= Date: Fri, 9 Aug 2019 11:40:59 +0200 Subject: [PATCH 3/8] aesthetic: add another line before a paragraph, remove trailing spaces and remove 3 spaces before a paragraph --- Doc/library/configparser.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 6f8f9f4ed1f738..4dc86377b01d16 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -135,10 +135,9 @@ involves the ``DEFAULT`` section which provides default values for all other sections [1]_. Note also that keys in sections are case-insensitive and stored in lowercase [1]_. - - If it is necessary to read several configurations, with each one having more - priority than the previous one, an instance of :class:`ConfigParser` can be - used to override previously defined properties and retain existing ones. +If it is necessary to read several configurations, with each one having more +priority than the previous one, an instance of :class:`ConfigParser` can be +used to override previously defined properties and retain existing ones. .. doctest:: @@ -156,6 +155,7 @@ case-insensitive and stored in lowercase [1]_. >>> config['topsecret.server.com']['ForwardX11'] 'no' + This behaviour is equivalent to a :meth:`ConfigParser.read` call with several files passed to ``filenames`` parameter. Supported Datatypes From 13ad7ab63604562c6ca0648e1cb333c2b627cf95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Blondon?= Date: Fri, 9 Aug 2019 17:33:21 +0200 Subject: [PATCH 4/8] Fix formatting errors (line length and empty lines) --- Doc/library/configparser.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 4dc86377b01d16..abce7576d696bb 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -155,8 +155,9 @@ used to override previously defined properties and retain existing ones. >>> config['topsecret.server.com']['ForwardX11'] 'no' +This behaviour is equivalent to a :meth:`ConfigParser.read` call with several +files passed to ``filenames`` parameter. -This behaviour is equivalent to a :meth:`ConfigParser.read` call with several files passed to ``filenames`` parameter. Supported Datatypes ------------------- From 3774983eb3c8a22d21d08dbce6b09d073cb8664f Mon Sep 17 00:00:00 2001 From: sblondon Date: Sun, 11 Aug 2019 10:55:47 +0200 Subject: [PATCH 5/8] Parameter function are stylized in italic Co-Authored-By: Kyle Stanley --- Doc/library/configparser.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index abce7576d696bb..5778cc1d4502e0 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -156,7 +156,7 @@ used to override previously defined properties and retain existing ones. 'no' This behaviour is equivalent to a :meth:`ConfigParser.read` call with several -files passed to ``filenames`` parameter. +files passed to *filenames* parameter. Supported Datatypes From 8d9a0840b6a57c5ed3501b6ae31793b4bccefc19 Mon Sep 17 00:00:00 2001 From: sblondon Date: Thu, 12 Sep 2019 10:54:51 +0200 Subject: [PATCH 6/8] Update Doc/library/configparser.rst Co-Authored-By: Paul Ganssle --- Doc/library/configparser.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 5778cc1d4502e0..d078c9e9f46b25 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -156,7 +156,7 @@ used to override previously defined properties and retain existing ones. 'no' This behaviour is equivalent to a :meth:`ConfigParser.read` call with several -files passed to *filenames* parameter. +files passed to the *filenames* parameter. Supported Datatypes From 42dc02a955b92c740c3eb91a18237480baa576f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Blondon?= Date: Thu, 12 Sep 2019 14:31:12 +0200 Subject: [PATCH 7/8] Wording improvement --- Doc/library/configparser.rst | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index d078c9e9f46b25..8e819c35570008 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -135,9 +135,10 @@ involves the ``DEFAULT`` section which provides default values for all other sections [1]_. Note also that keys in sections are case-insensitive and stored in lowercase [1]_. -If it is necessary to read several configurations, with each one having more -priority than the previous one, an instance of :class:`ConfigParser` can be -used to override previously defined properties and retain existing ones. +It is possible to read several configurations into a single +:class:`ConfigParser`, where the most recently added configuration has the +highest priority. Any conflicting keys are taken from the more recent +configuration while the previously existing keys are retained. .. doctest:: From 196d4f86da2d5867ec55a92e1a5456e7fe783a1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Blondon?= Date: Fri, 18 Sep 2020 16:39:16 +0200 Subject: [PATCH 8/8] rename a variable to fix a doctest --- Doc/library/configparser.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Doc/library/configparser.rst b/Doc/library/configparser.rst index 8e819c35570008..29418d0a5afdd3 100644 --- a/Doc/library/configparser.rst +++ b/Doc/library/configparser.rst @@ -142,18 +142,18 @@ configuration while the previously existing keys are retained. .. doctest:: - >>> config = configparser.ConfigParser() - >>> config.read('example.ini') + >>> another_config = configparser.ConfigParser() + >>> another_config.read('example.ini') ['example.ini'] - >>> config['topsecret.server.com']['Port'] + >>> another_config['topsecret.server.com']['Port'] '50022' - >>> config.read_string("[topsecret.server.com]\nPort=48484") - >>> config['topsecret.server.com']['Port'] + >>> another_config.read_string("[topsecret.server.com]\nPort=48484") + >>> another_config['topsecret.server.com']['Port'] '48484' - >>> config.read_dict({"topsecret.server.com": {"Port": 21212}}) - >>> config['topsecret.server.com']['Port'] + >>> another_config.read_dict({"topsecret.server.com": {"Port": 21212}}) + >>> another_config['topsecret.server.com']['Port'] '21212' - >>> config['topsecret.server.com']['ForwardX11'] + >>> another_config['topsecret.server.com']['ForwardX11'] 'no' This behaviour is equivalent to a :meth:`ConfigParser.read` call with several pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy