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

Commitcf9313b

Browse files
committed
reorganize enums
1 parenta731c20 commitcf9313b

File tree

6 files changed

+56
-49
lines changed

6 files changed

+56
-49
lines changed

‎testgres/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
from .configimportTestgresConfig,configure_testgres
44

55
from .connectionimport \
6-
IsolationLevel, \
76
NodeConnection, \
87
InternalError, \
98
ProgrammingError
109

1110
from .exceptionsimport*
12-
from .nodeimportNodeStatus,PostgresNode
11+
from .enumsimport*
12+
from .nodeimportPostgresNode
1313

1414
from .utilsimport \
1515
reserve_port, \

‎testgres/backup.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
importtempfile
66

77
fromsiximportraise_from
8-
fromenumimportEnum
8+
from.enumsimportXLogMethod
99

1010
from .constsimport \
1111
DATA_DIR, \
1212
PG_CONF_FILE, \
13-
BACKUP_LOG_FILE
13+
BACKUP_LOG_FILE, \
14+
DEFAULT_XLOG_METHOD
1415

1516
from .exceptionsimportBackupException
1617

@@ -20,16 +21,6 @@
2021
execute_utility
2122

2223

23-
classXLogMethod(Enum):
24-
"""
25-
Available WAL methods for NodeBackup
26-
"""
27-
28-
none='none'
29-
fetch='fetch'
30-
stream='stream'
31-
32-
3324
classNodeBackup(object):
3425
"""
3526
Smart object responsible for backups
@@ -43,7 +34,7 @@ def __init__(self,
4334
node,
4435
base_dir=None,
4536
username=None,
46-
xlog_method=XLogMethod.fetch):
37+
xlog_method=DEFAULT_XLOG_METHOD):
4738
"""
4839
Create a new backup.
4940

‎testgres/connection.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
exceptImportError:
1010
raiseImportError("You must have psycopg2 or pg8000 modules installed")
1111

12-
fromenumimportEnum
12+
from.enumsimportIsolationLevel
1313

1414
from .exceptionsimportQueryException
1515

@@ -22,17 +22,6 @@
2222
ProgrammingError=pglib.ProgrammingError
2323

2424

25-
classIsolationLevel(Enum):
26-
"""
27-
Transaction isolation level for NodeConnection
28-
"""
29-
30-
ReadUncommitted='read uncommitted'
31-
ReadCommitted='read committed'
32-
RepeatableRead='repeatable read'
33-
Serializable='serializable'
34-
35-
3625
classNodeConnection(object):
3726
"""
3827
Transaction wrapper returned by Node

‎testgres/consts.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# coding: utf-8
22

3+
from .enumsimportXLogMethod
4+
35
# names for dirs in base_dir
46
DATA_DIR="data"
57
LOGS_DIR="logs"
@@ -12,3 +14,6 @@
1214
PG_LOG_FILE="postgresql.log"
1315
UTILS_LOG_FILE="utils.log"
1416
BACKUP_LOG_FILE="backup.log"
17+
18+
# default argument value
19+
DEFAULT_XLOG_METHOD=XLogMethod.fetch

‎testgres/enums.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
fromenumimportEnum,IntEnum
2+
3+
4+
classXLogMethod(Enum):
5+
"""
6+
Available WAL methods for NodeBackup
7+
"""
8+
9+
none='none'
10+
fetch='fetch'
11+
stream='stream'
12+
13+
14+
classIsolationLevel(Enum):
15+
"""
16+
Transaction isolation level for NodeConnection
17+
"""
18+
19+
ReadUncommitted='read uncommitted'
20+
ReadCommitted='read committed'
21+
RepeatableRead='repeatable read'
22+
Serializable='serializable'
23+
24+
25+
classNodeStatus(IntEnum):
26+
"""
27+
Status of a PostgresNode
28+
"""
29+
30+
Running,Stopped,Uninitialized=range(3)
31+
32+
# for Python 3.x
33+
def__bool__(self):
34+
returnself==NodeStatus.Running
35+
36+
# for Python 2.x
37+
__nonzero__=__bool__

‎testgres/node.py

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
importtempfile
99
importtime
1010

11-
fromenumimportIntEnum
1211
fromsiximportraise_from
1312

13+
from .enumsimportNodeStatus
14+
1415
from .cacheimportcached_initdb
1516

1617
from .configimportTestgresConfig
@@ -27,7 +28,8 @@
2728
HBA_CONF_FILE, \
2829
RECOVERY_CONF_FILE, \
2930
PG_LOG_FILE, \
30-
UTILS_LOG_FILE
31+
UTILS_LOG_FILE, \
32+
DEFAULT_XLOG_METHOD
3133

3234
from .exceptionsimport \
3335
CatchUpException, \
@@ -51,24 +53,7 @@
5153
method_decorator, \
5254
positional_args_hack
5355

54-
from .backupimport \
55-
XLogMethod, \
56-
NodeBackup
57-
58-
59-
classNodeStatus(IntEnum):
60-
"""
61-
Status of a PostgresNode
62-
"""
63-
64-
Running,Stopped,Uninitialized=range(3)
65-
66-
# for Python 3.x
67-
def__bool__(self):
68-
returnself==NodeStatus.Running
69-
70-
# for Python 2.x
71-
__nonzero__=__bool__
56+
from .backupimportNodeBackup
7257

7358

7459
classPostgresNode(object):
@@ -841,7 +826,7 @@ def execute(self,
841826

842827
returnres
843828

844-
defbackup(self,username=None,xlog_method=XLogMethod.fetch):
829+
defbackup(self,username=None,xlog_method=DEFAULT_XLOG_METHOD):
845830
"""
846831
Perform pg_basebackup.
847832
@@ -860,7 +845,7 @@ def backup(self, username=None, xlog_method=XLogMethod.fetch):
860845
defreplicate(self,
861846
name=None,
862847
username=None,
863-
xlog_method=XLogMethod.fetch,
848+
xlog_method=DEFAULT_XLOG_METHOD,
864849
use_logging=False):
865850
"""
866851
Create a binary replica of this node.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp