fb-pdnstools 1.0.0__py3-none-any.whl → 1.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -23,7 +23,7 @@ from . import DEFAULT_API_PREFIX
23
23
  from . import DEFAULT_PORT
24
24
  from .xlate import XLATOR
25
25
 
26
- __version__ = '0.2.1'
26
+ __version__ = "1.0.0"
27
27
  LOG = logging.getLogger(__name__)
28
28
 
29
29
  _ = XLATOR.gettext
@@ -41,15 +41,23 @@ class PdnsBulkRmConfigError(ConfigError):
41
41
  class PdnsBulkRmCfg(BaseConfiguration):
42
42
  """A class for providing a configuration for the GetVmApplication class."""
43
43
 
44
- default_pdns_master = 'master.pp-dns.com'
44
+ default_pdns_master = "master.pp-dns.com"
45
45
  default_pdns_api_port = DEFAULT_PORT
46
46
  default_pdns_api_https = False
47
47
  default_pdns_api_prefix = DEFAULT_API_PREFIX
48
48
 
49
49
  # -------------------------------------------------------------------------
50
50
  def __init__(
51
- self, appname=None, verbose=0, version=__version__, base_dir=None,
52
- encoding=None, config_dir=None, config_file=None, initialized=False):
51
+ self,
52
+ appname=None,
53
+ verbose=0,
54
+ version=__version__,
55
+ base_dir=None,
56
+ encoding=None,
57
+ config_dir=None,
58
+ config_file=None,
59
+ initialized=False,
60
+ ):
53
61
  """Initialize the PdnsBulkRmCfg object."""
54
62
  self.pdns_master = self.default_pdns_master
55
63
  self.pdns_api_port = self.default_pdns_api_port
@@ -58,8 +66,14 @@ class PdnsBulkRmCfg(BaseConfiguration):
58
66
  self.pdns_api_prefix = self.default_pdns_api_prefix
59
67
 
60
68
  super(PdnsBulkRmCfg, self).__init__(
61
- appname=appname, verbose=verbose, version=version, base_dir=base_dir,
62
- encoding=encoding, config_dir=config_dir, config_file=config_file, initialized=False,
69
+ appname=appname,
70
+ verbose=verbose,
71
+ version=version,
72
+ base_dir=base_dir,
73
+ encoding=encoding,
74
+ config_dir=config_dir,
75
+ config_file=config_file,
76
+ initialized=False,
63
77
  )
64
78
 
65
79
  if initialized:
@@ -78,12 +92,12 @@ class PdnsBulkRmCfg(BaseConfiguration):
78
92
  """
79
93
  res = super(PdnsBulkRmCfg, self).as_dict(short=short)
80
94
 
81
- res['pdns_api_key'] = None
95
+ res["pdns_api_key"] = None
82
96
  if self.pdns_api_key:
83
97
  if self.verbose > 4:
84
- res['pdns_api_key'] = self.pdns_api_key
98
+ res["pdns_api_key"] = self.pdns_api_key
85
99
  else:
86
- res['pdns_api_key'] = '*******'
100
+ res["pdns_api_key"] = "*******"
87
101
 
88
102
  return res
89
103
 
@@ -92,34 +106,34 @@ class PdnsBulkRmCfg(BaseConfiguration):
92
106
  """Evaluate configuration in the section with the given name."""
93
107
  super(PdnsBulkRmCfg, self).eval_config_section(config, section_name)
94
108
 
95
- if section_name.lower() in ('pdns', 'powerdns'):
109
+ if section_name.lower() in ("pdns", "powerdns"):
96
110
  self._eval_config_pdns(config, section_name)
97
111
  return
98
112
 
99
113
  if self.verbose > 1:
100
- LOG.debug(_('Unhandled configuration section {!r}.').format(section_name))
114
+ LOG.debug(_("Unhandled configuration section {!r}.").format(section_name))
101
115
 
102
116
  # -------------------------------------------------------------------------
103
117
  def _eval_config_pdns(self, config, section_name):
104
118
 
105
119
  if self.verbose > 1:
106
- LOG.debug(_('Checking config section {!r} ...').format(section_name))
120
+ LOG.debug(_("Checking config section {!r} ...").format(section_name))
107
121
 
108
- re_api_key = re.compile(r'^\s*(?:api[_-]?)?key\s*', re.IGNORECASE)
109
- re_api_prefix = re.compile(r'^\s*(?:api[_-]?)?prefix\s*', re.IGNORECASE)
122
+ re_api_key = re.compile(r"^\s*(?:api[_-]?)?key\s*", re.IGNORECASE)
123
+ re_api_prefix = re.compile(r"^\s*(?:api[_-]?)?prefix\s*", re.IGNORECASE)
110
124
 
111
- for (key, value) in config.items(section_name):
125
+ for key, value in config.items(section_name):
112
126
 
113
- if key.lower() == 'master':
127
+ if key.lower() == "master":
114
128
  self.pdns_master = value
115
129
  continue
116
- elif key.lower() == 'port':
130
+ elif key.lower() == "port":
117
131
  self.pdns_api_port = int(value)
118
132
  continue
119
133
  elif re_api_key.match(key) and str(value).strip():
120
134
  self.pdns_api_key = str(value).strip()
121
135
  continue
122
- elif key.lower() == 'https':
136
+ elif key.lower() == "https":
123
137
  self.pdns_api_https = to_bool(value)
124
138
  continue
125
139
  elif re_api_prefix.match(key):
@@ -130,7 +144,7 @@ class PdnsBulkRmCfg(BaseConfiguration):
130
144
 
131
145
  # =============================================================================
132
146
 
133
- if __name__ == '__main__':
147
+ if __name__ == "__main__":
134
148
 
135
149
  pass
136
150
 
fb_pdnstools/common.py CHANGED
@@ -16,7 +16,7 @@ import logging
16
16
  # Own modules
17
17
  from .xlate import XLATOR
18
18
 
19
- __version__ = '0.1.2'
19
+ __version__ = "1.0.0"
20
20
 
21
21
  _ = XLATOR.gettext
22
22
 
@@ -28,7 +28,7 @@ SECONDS_PER_MINUTE = 60
28
28
 
29
29
 
30
30
  # =============================================================================
31
- def seconds2human(value, fs=' ', all_fields=False):
31
+ def seconds2human(value, fs=" ", all_fields=False):
32
32
  """
33
33
  Convert the given value as seconds into a human readable format.
34
34
 
@@ -62,24 +62,24 @@ def seconds2human(value, fs=' ', all_fields=False):
62
62
  elif isinstance(value, float):
63
63
  int_val = int(value + 0.5)
64
64
  elif value is None:
65
- msg = _('A None type for seconds cannot be converted in seconds.')
65
+ msg = _("A None type for seconds cannot be converted in seconds.")
66
66
  raise TypeError(msg)
67
67
  else:
68
68
  try:
69
69
  int_val = int(value)
70
70
  except (TypeError, ValueError) as e:
71
- msg = _('The value {val!r} cannot be interpreted as seconds: {e}')
71
+ msg = _("The value {val!r} cannot be interpreted as seconds: {e}")
72
72
  raise ValueError(msg.format(val=value, e=e))
73
73
 
74
74
  if int_val == 0:
75
75
  if all_fields:
76
- return '0d' + fs + '0h' + fs + '0m' + fs + '0s'
76
+ return "0d" + fs + "0h" + fs + "0m" + fs + "0s"
77
77
  else:
78
- return '0s'
78
+ return "0s"
79
79
 
80
- result = ''
80
+ result = ""
81
81
  if int_val < 0:
82
- result = '-'
82
+ result = "-"
83
83
  int_val *= -1
84
84
 
85
85
  days = int_val // SECONDS_PER_DAY
@@ -88,7 +88,7 @@ def seconds2human(value, fs=' ', all_fields=False):
88
88
  if days or all_fields:
89
89
  if result:
90
90
  result += fs
91
- result += '{}d'.format(days)
91
+ result += "{}d".format(days)
92
92
 
93
93
  hours = rest_days // SECONDS_PER_HOUR
94
94
  rest_hours = rest_days % SECONDS_PER_HOUR
@@ -96,7 +96,7 @@ def seconds2human(value, fs=' ', all_fields=False):
96
96
  if hours or all_fields:
97
97
  if result:
98
98
  result += fs
99
- result += '{}h'.format(hours)
99
+ result += "{}h".format(hours)
100
100
 
101
101
  minutes = rest_hours // SECONDS_PER_MINUTE
102
102
  seconds = rest_hours % SECONDS_PER_MINUTE
@@ -104,19 +104,19 @@ def seconds2human(value, fs=' ', all_fields=False):
104
104
  if minutes or all_fields:
105
105
  if result:
106
106
  result += fs
107
- result += '{}m'.format(minutes)
107
+ result += "{}m".format(minutes)
108
108
 
109
109
  if seconds or all_fields:
110
110
  if result:
111
111
  result += fs
112
- result += '{}s'.format(seconds)
112
+ result += "{}s".format(seconds)
113
113
 
114
114
  return result
115
115
 
116
116
 
117
117
  # =============================================================================
118
118
 
119
- if __name__ == '__main__':
119
+ if __name__ == "__main__":
120
120
 
121
121
  pass
122
122
 
fb_pdnstools/errors.py CHANGED
@@ -18,7 +18,7 @@ from .xlate import XLATOR
18
18
 
19
19
  _ = XLATOR.gettext
20
20
 
21
- __version__ = '0.4.1'
21
+ __version__ = "1.0.0"
22
22
 
23
23
 
24
24
  # =============================================================================
@@ -47,8 +47,7 @@ class PDNSNoRecordsToRemove(PowerDNSZoneError):
47
47
  # -------------------------------------------------------------------------
48
48
  def __str__(self):
49
49
  """Typecast into a string."""
50
- msg = _('No Resource Record Sets found to remove from zone {!r}.').format(
51
- self.zone_name)
50
+ msg = _("No Resource Record Sets found to remove from zone {!r}.").format(self.zone_name)
52
51
  return msg
53
52
 
54
53
 
@@ -85,7 +84,7 @@ class PowerDNSWrongSoaDataError(PowerDNSRecordSetError):
85
84
  # -------------------------------------------------------------------------
86
85
  def __str__(self):
87
86
  """Typecast into a string."""
88
- msg = _('Could not interprete SOA data: {!r}.').format(self.data)
87
+ msg = _("Could not interprete SOA data: {!r}.").format(self.data)
89
88
  return msg
90
89
 
91
90
 
@@ -104,10 +103,11 @@ class PDNSApiError(PowerDNSHandlerError):
104
103
  def __str__(self):
105
104
  """Typecast into a string."""
106
105
  if self.uri:
107
- msg = _('Got a {code} error code from {uri!r}: {msg}').format(
108
- code=self.code, uri=self.uri, msg=self.msg)
106
+ msg = _("Got a {code} error code from {uri!r}: {msg}").format(
107
+ code=self.code, uri=self.uri, msg=self.msg
108
+ )
109
109
  else:
110
- msg = _('Got a {code} error code: {msg}').format(code=self.code, msg=self.msg)
110
+ msg = _("Got a {code} error code: {msg}").format(code=self.code, msg=self.msg)
111
111
 
112
112
  return msg
113
113
 
@@ -169,24 +169,24 @@ class PDNSRequestError(PowerDNSHandlerError):
169
169
  # -------------------------------------------------------------------------
170
170
  def __str__(self):
171
171
  """Typecast into a string."""
172
- msg = _('Got an error requesting {uri!r}: {msg}').format(uri=self.uri, msg=self.msg)
172
+ msg = _("Got an error requesting {uri!r}: {msg}").format(uri=self.uri, msg=self.msg)
173
173
  if self.request:
174
- cls = ''
174
+ cls = ""
175
175
  if not isinstance(self.request, str):
176
- cls = self.request.__class__.__name__ + ' - '
177
- msg += ' / Request: {c}{e}'.format(c=cls, e=self.request)
176
+ cls = self.request.__class__.__name__ + " - "
177
+ msg += " / Request: {c}{e}".format(c=cls, e=self.request)
178
178
  if self.response:
179
- cls = ''
179
+ cls = ""
180
180
  if not isinstance(self.response, str):
181
- cls = self.response.__class__.__name__ + ' - '
182
- msg += ' / Response: {c}{e}'.format(c=cls, e=self.response)
181
+ cls = self.response.__class__.__name__ + " - "
182
+ msg += " / Response: {c}{e}".format(c=cls, e=self.response)
183
183
 
184
184
  return msg
185
185
 
186
186
 
187
187
  # =============================================================================
188
188
 
189
- if __name__ == '__main__':
189
+ if __name__ == "__main__":
190
190
 
191
191
  pass
192
192