From: "André Erdmann" <dywi@mailerd.de>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/
Date: Fri, 6 Sep 2013 17:27:43 +0000 (UTC) [thread overview]
Message-ID: <1378488166.62c81650a1ce027d376dd04c70861a8be9faa934.dywi@gentoo> (raw)
commit: 62c81650a1ce027d376dd04c70861a8be9faa934
Author: André Erdmann <dywi <AT> mailerd <DOT> de>
AuthorDate: Fri Sep 6 17:22:46 2013 +0000
Commit: André Erdmann <dywi <AT> mailerd <DOT> de>
CommitDate: Fri Sep 6 17:22:46 2013 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/R_overlay.git;a=commit;h=62c81650
config tree: register_static, reset()
Optionally do not register a created ConfigTree instance as static instance.
Support for re-setting the config tree (which removes all config options from
it).
---
roverlay/config/tree.py | 33 +++++++++++++++++++++++++--------
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/roverlay/config/tree.py b/roverlay/config/tree.py
index 4be20c1..c87df55 100644
--- a/roverlay/config/tree.py
+++ b/roverlay/config/tree.py
@@ -31,7 +31,7 @@ class ConfigTree ( object ):
# static access to the first created ConfigTree
instance = None
- def __init__ ( self, import_const=True ):
+ def __init__ ( self, import_const=True, register_static=None ):
"""Initializes an ConfigTree, which is a container for options/values.
Values can be stored directly (such as the field_definitions) or
in a tree-like { section -> subsection[s] -> option = value } structure.
@@ -41,21 +41,38 @@ class ConfigTree ( object ):
arguments:
* import_const -- whether to deepcopy constants into the config tree or
not. Copying allows faster lookups.
+ * register_static -- if True: register new instance as static
+ if None: same as for True unless a static instance
+ is already registered
+ else: do nothing
"""
- if ConfigTree.instance is None:
- ConfigTree.instance = self
+ if register_static is True or (
+ self.__class__.instance is None and register_static is None
+ ):
+ self.__class__.instance = self
self.logger = logging.getLogger ( self.__class__.__name__ )
else:
self.logger = logging.getLogger (
- self.__class__.__name__ + "(%i)" % id ( self ) )
+ "{}({:d}".format ( self.__class__.__name__, id ( self ) )
+ )
- self._config = const.clone() if import_const else dict ()
- self._const_imported = import_const
- self._field_definition = None
- self._use_extend_map = None
+ self._config = None
+ self._const_imported = False
+ self._field_definition = None
+ self._use_extend_map = None
+ self.reset ( import_const=import_const )
# --- end of __init__ (...) ---
+ def reset ( self, import_const=None ):
+ if import_const is not None:
+ self._const_imported = bool ( import_const )
+
+ self._config = const.clone() if self._const_imported else dict()
+ self._field_definition = None
+ self._use_extend_map = None
+ # --- end of reset (...) ---
+
def get_loader ( self ):
"""Returns a ConfigLoader for this ConfigTree."""
return ConfigLoader ( self )
next reply other threads:[~2013-09-06 17:27 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-09-06 17:27 André Erdmann [this message]
-- strict thread matches above, loose matches on Subject: below --
2018-05-30 5:31 [gentoo-commits] proj/R_overlay:master commit in: roverlay/config/ Benda XU
2018-05-28 8:41 Benda XU
2014-08-23 19:03 André Erdmann
2014-08-23 19:03 André Erdmann
2014-04-01 16:38 André Erdmann
2014-04-01 16:38 André Erdmann
2014-04-01 16:38 André Erdmann
2014-01-26 19:06 André Erdmann
2013-09-13 15:10 André Erdmann
2013-09-11 11:14 André Erdmann
2013-09-11 10:30 André Erdmann
2013-09-11 10:27 André Erdmann
2013-09-11 10:27 André Erdmann
2013-09-10 14:40 André Erdmann
2013-09-10 14:40 André Erdmann
2013-09-04 10:16 André Erdmann
2013-08-14 14:56 André Erdmann
2013-08-12 8:18 André Erdmann
2013-08-09 15:27 André Erdmann
2013-08-09 15:27 André Erdmann
2013-08-06 10:58 André Erdmann
2013-08-05 11:44 André Erdmann
2013-08-02 13:39 André Erdmann
2013-07-30 18:40 André Erdmann
2013-07-29 14:56 André Erdmann
2013-07-24 17:45 André Erdmann
2013-07-16 16:36 André Erdmann
2013-07-12 13:57 André Erdmann
2013-07-12 13:57 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-07-12 13:57 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-07-11 16:29 André Erdmann
2013-07-10 15:10 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-07-10 16:16 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-06-30 15:58 André Erdmann
2013-06-19 18:59 André Erdmann
2013-06-13 16:34 [gentoo-commits] proj/R_overlay:gsoc13/next " André Erdmann
2013-06-18 14:12 ` [gentoo-commits] proj/R_overlay:master " André Erdmann
2013-06-04 21:06 André Erdmann
2013-02-09 20:45 André Erdmann
2013-02-09 20:45 André Erdmann
2013-02-09 20:45 André Erdmann
2013-01-28 23:54 André Erdmann
2013-01-28 23:54 André Erdmann
2012-08-09 9:26 André Erdmann
2012-08-08 23:46 André Erdmann
2012-08-02 15:14 André Erdmann
2012-08-01 21:10 André Erdmann
2012-07-11 18:43 André Erdmann
2012-07-06 22:19 André Erdmann
2012-07-06 22:19 André Erdmann
2012-07-05 16:00 André Erdmann
2012-07-03 17:48 André Erdmann
2012-06-29 22:48 André Erdmann
2012-06-26 15:42 André Erdmann
2012-06-25 18:19 André Erdmann
2012-06-25 18:19 André Erdmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1378488166.62c81650a1ce027d376dd04c70861a8be9faa934.dywi@gentoo \
--to=dywi@mailerd.de \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox