Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6c38093

Browse files
committed
improve docs of config stack
1 parent56ddf77 commit6c38093

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

‎testgres/backup.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,11 @@ def spawn_replica(self, name=None, destroy=True, slot=None):
180180
returnnode
181181

182182
defcleanup(self):
183+
"""
184+
Remove all files that belong to this backup.
185+
No-op if it's been converted to a PostgresNode (destroy=True).
186+
"""
187+
183188
ifself._available:
184189
self._available=False
185190
rmtree(self.base_dir,ignore_errors=True)

‎testgres/config.py‎

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,19 @@
1313

1414
classGlobalConfig(object):
1515
"""
16-
Globalconfig (override default settings).
16+
Globalconfiguration object which allows user tooverride default settings.
1717
1818
Attributes:
1919
cache_initdb: shall we use cached initdb instance?
20-
cached_initdb_dir:shall we createa tempdir for cached initdb?
21-
cached_initdb_unique: shall weassign new node a unique system id?
20+
cached_initdb_dir:path toa tempdirectory for cached initdb.
21+
cached_initdb_unique: shall wegive new node a unique system id?
2222
2323
cache_pg_config: shall we cache pg_config results?
2424
25-
temp_dir:basetemp dirfor nodes with default 'base_dir'.
25+
temp_dir:path totemp dircontaining nodes with default 'base_dir'.
2626
27-
use_python_logging:use python loggingconfiguration for all nodes.
28-
error_log_lines: N of log lines to be shown inexception (0=inf).
27+
use_python_logging:enable python loggingsubsystem (see logger.py).
28+
error_log_lines: N of log lines to be shown inexceptions (0=inf).
2929
3030
node_cleanup_full: shall we remove EVERYTHING (including logs)?
3131
node_cleanup_on_good_exit: remove base_dir on nominal __exit__().
@@ -82,6 +82,10 @@ def __setattr__(self, name, value):
8282
super(GlobalConfig,self).__setattr__(name,value)
8383

8484
defkeys(self):
85+
"""
86+
Return a list of all available settings.
87+
"""
88+
8589
keys= []
8690

8791
forkeyindir(GlobalConfig):
@@ -91,15 +95,29 @@ def keys(self):
9195
returnkeys
9296

9397
defitems(self):
98+
"""
99+
Return setting-value pairs.
100+
"""
101+
94102
return ((key,self[key])forkeyinself.keys())
95103

96104
defupdate(self,config):
105+
"""
106+
Extract setting-value pairs from 'config' and
107+
assign those values to corresponding settings
108+
of this GlobalConfig object.
109+
"""
110+
97111
forkey,valueinconfig.items():
98112
self[key]=value
99113

100114
returnself
101115

102116
defcopy(self):
117+
"""
118+
Return a copy of this object.
119+
"""
120+
103121
returncopy.copy(self)
104122

105123

@@ -124,8 +142,8 @@ def _rm_cached_initdb_dirs():
124142

125143
defpush_config(**options):
126144
"""
127-
Permanently set custom GlobalConfig options
128-
andput previous settings on top of stack.
145+
Permanently set custom GlobalConfig options and
146+
put previous settings on top of the config stack.
129147
"""
130148

131149
# push current config to stack
@@ -150,10 +168,12 @@ def pop_config():
150168
defscoped_config(**options):
151169
"""
152170
Temporarily set custom GlobalConfig options for this context.
171+
Previous options are pushed to the config stack.
153172
154173
Example:
155174
>>> from .api import get_new_node
156175
>>> with scoped_config(cache_initdb=False):
176+
... # create a new node with fresh initdb
157177
... with get_new_node().init().start() as node:
158178
... print(node.execute('select 1'))
159179
[(1,)]
@@ -173,7 +193,7 @@ def scoped_config(**options):
173193
defconfigure_testgres(**options):
174194
"""
175195
Adjust current global options.
176-
Look at GlobalConfig to learnwhat can be set.
196+
Look attheGlobalConfig to learnabout existing settings.
177197
"""
178198

179199
testgres_config.update(options)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp