Skip to content

Commit a73a6a3

Browse files
[3.12] Docs: use placeholders in dbm flag param docs (GH-114482) (#114497)
Also correct the default flag param for dbm.dumb.open(); it's 'c', not 'r'. (cherry picked from commit 8c26540) Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent be85f35 commit a73a6a3

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:
@@ -290,21 +289,13 @@ to locate the appropriate header file to simplify building this module.
290289

291290
The optional *flag* argument must be one of these values:
292291

293-
+---------+-------------------------------------------+
294-
| Value | Meaning |
295-
+=========+===========================================+
296-
| ``'r'`` | Open existing database for reading only |
297-
| | (default) |
298-
+---------+-------------------------------------------+
299-
| ``'w'`` | Open existing database for reading and |
300-
| | writing |
301-
+---------+-------------------------------------------+
302-
| ``'c'`` | Open database for reading and writing, |
303-
| | creating it if it doesn't exist |
304-
+---------+-------------------------------------------+
305-
| ``'n'`` | Always create a new, empty database, open |
306-
| | for reading and writing |
307-
+---------+-------------------------------------------+
292+
.. csv-table::
293+
:header: "Value", "Meaning"
294+
295+
``'r'`` (default), |flag_r|
296+
``'w'``, |flag_w|
297+
``'c'``, |flag_c|
298+
``'n'``, |flag_n|
308299

309300
The optional *mode* argument is the Unix mode of the file, used only when the
310301
database has to be created. It defaults to octal ``0o666`` (and will be
@@ -363,21 +354,13 @@ The module defines the following:
363354

364355
The optional *flag* argument can be:
365356

366-
+---------+-------------------------------------------+
367-
| Value | Meaning |
368-
+=========+===========================================+
369-
| ``'r'`` | Open existing database for reading only |
370-
| | (default) |
371-
+---------+-------------------------------------------+
372-
| ``'w'`` | Open existing database for reading and |
373-
| | writing |
374-
+---------+-------------------------------------------+
375-
| ``'c'`` | Open database for reading and writing, |
376-
| | creating it if it doesn't exist |
377-
+---------+-------------------------------------------+
378-
| ``'n'`` | Always create a new, empty database, open |
379-
| | for reading and writing |
380-
+---------+-------------------------------------------+
357+
.. csv-table::
358+
:header: "Value", "Meaning"
359+
360+
``'r'``, |flag_r|
361+
``'w'``, |flag_w|
362+
``'c'`` (default), |flag_c|
363+
``'n'``, |flag_n|
381364

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

0 commit comments

Comments
 (0)