Skip to content

Commit 8c26540

Browse files
Docs: use placeholders in dbm flag param docs (#114482)
Also correct the default flag param for dbm.dumb.open(); it's 'c', not 'r'.
1 parent 925907e commit 8c26540

File tree

1 file changed

+43
-60
lines changed

1 file changed

+43
-60
lines changed

Doc/library/dbm.rst

Lines changed: 43 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,21 @@ the Oracle Berkeley DB.
3636
.. versionchanged:: 3.11
3737
Accepts :term:`path-like object` for filename.
3838

39+
.. Substitutions for the open() flag param docs;
40+
all submodules use the same text.
41+
42+
.. |flag_r| replace::
43+
Open existing database for reading only.
44+
45+
.. |flag_w| replace::
46+
Open existing database for reading and writing.
47+
48+
.. |flag_c| replace::
49+
Open database for reading and writing, creating it if it doesn't exist.
50+
51+
.. |flag_n| replace::
52+
Always create a new, empty database, open for reading and writing.
53+
3954
.. function:: open(file, flag='r', mode=0o666)
4055

4156
Open the database file *file* and return a corresponding object.
@@ -46,21 +61,13 @@ the Oracle Berkeley DB.
4661

4762
The optional *flag* argument can be:
4863

49-
+---------+-------------------------------------------+
50-
| Value | Meaning |
51-
+=========+===========================================+
52-
| ``'r'`` | Open existing database for reading only |
53-
| | (default) |
54-
+---------+-------------------------------------------+
55-
| ``'w'`` | Open existing database for reading and |
56-
| | writing |
57-
+---------+-------------------------------------------+
58-
| ``'c'`` | Open database for reading and writing, |
59-
| | creating it if it doesn't exist |
60-
+---------+-------------------------------------------+
61-
| ``'n'`` | Always create a new, empty database, open |
62-
| | for reading and writing |
63-
+---------+-------------------------------------------+
64+
.. csv-table::
65+
:header: "Value", "Meaning"
66+
67+
``'r'`` (default), |flag_r|
68+
``'w'``, |flag_w|
69+
``'c'``, |flag_c|
70+
``'n'``, |flag_n|
6471

6572
The optional *mode* argument is the Unix mode of the file, used only when the
6673
database has to be created. It defaults to octal ``0o666`` (and will be
@@ -165,21 +172,13 @@ supported.
165172

166173
The optional *flag* argument can be:
167174

168-
+---------+-------------------------------------------+
169-
| Value | Meaning |
170-
+=========+===========================================+
171-
| ``'r'`` | Open existing database for reading only |
172-
| | (default) |
173-
+---------+-------------------------------------------+
174-
| ``'w'`` | Open existing database for reading and |
175-
| | writing |
176-
+---------+-------------------------------------------+
177-
| ``'c'`` | Open database for reading and writing, |
178-
| | creating it if it doesn't exist |
179-
+---------+-------------------------------------------+
180-
| ``'n'`` | Always create a new, empty database, open |
181-
| | for reading and writing |
182-
+---------+-------------------------------------------+
175+
.. csv-table::
176+
:header: "Value", "Meaning"
177+
178+
``'r'`` (default), |flag_r|
179+
``'w'``, |flag_w|
180+
``'c'``, |flag_c|
181+
``'n'``, |flag_n|
183182

184183
The following additional characters may be appended to the flag to control
185184
how the database is opened:
@@ -297,21 +296,13 @@ to locate the appropriate header file to simplify building this module.
297296

298297
The optional *flag* argument must be one of these values:
299298

300-
+---------+-------------------------------------------+
301-
| Value | Meaning |
302-
+=========+===========================================+
303-
| ``'r'`` | Open existing database for reading only |
304-
| | (default) |
305-
+---------+-------------------------------------------+
306-
| ``'w'`` | Open existing database for reading and |
307-
| | writing |
308-
+---------+-------------------------------------------+
309-
| ``'c'`` | Open database for reading and writing, |
310-
| | creating it if it doesn't exist |
311-
+---------+-------------------------------------------+
312-
| ``'n'`` | Always create a new, empty database, open |
313-
| | for reading and writing |
314-
+---------+-------------------------------------------+
299+
.. csv-table::
300+
:header: "Value", "Meaning"
301+
302+
``'r'`` (default), |flag_r|
303+
``'w'``, |flag_w|
304+
``'c'``, |flag_c|
305+
``'n'``, |flag_n|
315306

316307
The optional *mode* argument is the Unix mode of the file, used only when the
317308
database has to be created. It defaults to octal ``0o666`` (and will be
@@ -376,21 +367,13 @@ The module defines the following:
376367

377368
The optional *flag* argument can be:
378369

379-
+---------+-------------------------------------------+
380-
| Value | Meaning |
381-
+=========+===========================================+
382-
| ``'r'`` | Open existing database for reading only |
383-
| | (default) |
384-
+---------+-------------------------------------------+
385-
| ``'w'`` | Open existing database for reading and |
386-
| | writing |
387-
+---------+-------------------------------------------+
388-
| ``'c'`` | Open database for reading and writing, |
389-
| | creating it if it doesn't exist |
390-
+---------+-------------------------------------------+
391-
| ``'n'`` | Always create a new, empty database, open |
392-
| | for reading and writing |
393-
+---------+-------------------------------------------+
370+
.. csv-table::
371+
:header: "Value", "Meaning"
372+
373+
``'r'``, |flag_r|
374+
``'w'``, |flag_w|
375+
``'c'`` (default), |flag_c|
376+
``'n'``, |flag_n|
394377

395378
The optional *mode* argument is the Unix mode of the file, used only when the
396379
database has to be created. It defaults to octal ``0o666`` (and will be modified

0 commit comments

Comments
 (0)