API documentation
conf_path()
Returns the path found for the pg_service.conf on the system as string.
Returns:
Type | Description |
---|---|
Path
|
path to the pg_service.conf file as string |
Source code in pgserviceparser/__init__.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
full_config(conf_file_path=None)
Returns full pgservice config as configparser.ConfigParser().
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conf_file_path |
Optional[Path]
|
path to configuration file to load. If None the |
None
|
Returns:
Type | Description |
---|---|
ConfigParser
|
pg services loaded as ConfigParser |
Raises:
Type | Description |
---|---|
ServiceFileNotFound
|
when the service file is not found |
Source code in pgserviceparser/__init__.py
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
|
remove_service(service_name, conf_file_path=None)
Remove a complete service from the service file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name |
str
|
service name |
required |
conf_file_path |
Optional[Path]
|
path to the pg_service.conf. If None the |
None
|
Raises:
Type | Description |
---|---|
ServiceFileNotFound
|
when the service file is not found |
ServiceNotFound
|
when the service is not found |
Source code in pgserviceparser/__init__.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
|
service_config(service_name, conf_file_path=None)
Returns the config from the given service name as a dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name |
str
|
service name |
required |
conf_file_path |
Optional[Path]
|
path to the pg_service.conf. If None the |
None
|
Returns:
Type | Description |
---|---|
dict
|
service settings as dictionary |
Raises:
Type | Description |
---|---|
ServiceNotFound
|
when the service is not found |
Source code in pgserviceparser/__init__.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
service_names(conf_file_path=None)
Returns all service names in a list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
conf_file_path |
Optional[Path]
|
path to the pg_service.conf. If None the |
None
|
Returns:
Type | Description |
---|---|
list[str]
|
list of every service registered |
Raises:
Type | Description |
---|---|
ServiceFileNotFound
|
when the service file is not found |
Source code in pgserviceparser/__init__.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
write_service(service_name, settings, conf_file_path=None, create_if_not_found=False)
Writes a complete service to the service file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name |
str
|
service name |
required |
settings |
dict
|
settings dict defining the service config |
required |
conf_file_path |
Optional[Path]
|
path to the pg_service.conf. If None the |
None
|
create_if_not_found |
bool
|
option to create a new service if it does not exist yet. Defaults to False. |
False
|
Raises:
Type | Description |
---|---|
ServiceFileNotFound
|
when the service file is not found |
ServiceNotFound
|
when the service is not found |
Returns:
Type | Description |
---|---|
dict
|
existing or newly created service as dictionary |
Source code in pgserviceparser/__init__.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
|
write_service_setting(service_name, setting_key, setting_value, conf_file_path=None)
Writes a service setting to the service file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
service_name |
str
|
service name |
required |
setting_key |
str
|
key |
required |
setting_value |
str
|
value |
required |
conf_file_path |
Optional[Path]
|
path to the pg_service.conf. If None the |
None
|
Raises:
Type | Description |
---|---|
ServiceFileNotFound
|
when the service file is not found |
ServiceNotFound
|
when the service is not found |
Source code in pgserviceparser/__init__.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|