promtext-cli 0.1.2.dev98__py3-none-any.whl → 0.1.2.dev100__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.
promtext_cli/main.py CHANGED
@@ -1,10 +1,10 @@
1
- """This module takes care of entrypoints"""
1
+ """Provide the Entrypoints"""
2
2
 
3
3
  from .promtext import Promtext
4
4
 
5
5
 
6
6
  def main():
7
- """main method invoking the core class"""
7
+ """Main method invoking the core class"""
8
8
  Promtext().cli_entrypoint()
9
9
 
10
10
 
promtext_cli/promtext.py CHANGED
@@ -1,12 +1,12 @@
1
- """this is the module providing the core functionality"""
1
+ """module providing the core functionality"""
2
2
 
3
3
  import argparse
4
- from pathlib import Path
5
4
  import logging
6
5
  import sys
6
+ from pathlib import Path
7
7
 
8
- from prometheus_client.parser import text_string_to_metric_families
9
8
  from prometheus_client import CollectorRegistry, Gauge, write_to_textfile
9
+ from prometheus_client.parser import text_string_to_metric_families
10
10
 
11
11
 
12
12
  class Promtext:
@@ -21,7 +21,7 @@ class Promtext:
21
21
  self.metrics = {}
22
22
 
23
23
  def _arguments(self):
24
- """load every input item from arguments & define cli"""
24
+ """Load every input item from arguments & define cli"""
25
25
  # required file first
26
26
  parser = argparse.ArgumentParser(description="Prometheus textfile helper")
27
27
  parser.add_argument(
@@ -70,13 +70,11 @@ class Promtext:
70
70
  # check if self.args.filename exists with pathlib
71
71
  if self.textfile.is_file():
72
72
  for f in text_string_to_metric_families(
73
- self.textfile.read_text(encoding="utf-8")
73
+ self.textfile.read_text(encoding="utf-8"),
74
74
  ):
75
75
  # per metric: iterate over samples, create metric in registry
76
76
  m = False
77
- samples = []
78
- for s in f.samples:
79
- samples.append(s)
77
+ samples = list(f.samples)
80
78
  if len(samples) > 0:
81
79
  # if we have samples, use the labelnames from them
82
80
  labelnames = list(samples[0].labels.keys())
@@ -92,7 +90,8 @@ class Promtext:
92
90
  else:
93
91
  # we don't support other types yet, continue in these cases
94
92
  self.logger.warning(
95
- "unsupported metric type %s, dropping", f.type
93
+ "unsupported metric type %s, dropping",
94
+ f.type,
96
95
  )
97
96
  continue
98
97
  for s in samples:
@@ -109,7 +108,8 @@ class Promtext:
109
108
  )
110
109
  else:
111
110
  self.logger.warning(
112
- "got empty metric %s from old file, dropping", f.name
111
+ "got empty metric %s from old file, dropping",
112
+ f.name,
113
113
  )
114
114
 
115
115
  def _build_metrics(self):
@@ -139,19 +139,21 @@ class Promtext:
139
139
 
140
140
  # There is no way to access existing labelnames directly
141
141
  # pylint: disable=W0212
142
- old_labelnames = list(m._labelnames)
142
+ old_labelnames = list(m._labelnames) # noqa: SLF001
143
143
  for la in old_labelnames:
144
144
  self.logger.info("processing label %s", la)
145
145
  if la in labels: # labelvalues are needed in order!
146
146
  labelvalues.append(labels[la])
147
147
  else:
148
148
  self.logger.error(
149
- "previously known label '%s' missing, cannot update!", la
149
+ "previously known label '%s' missing, cannot update!",
150
+ la,
150
151
  )
151
152
  sys.exit(1)
152
153
  if len(old_labelnames) != len(labels.keys()):
153
154
  self.logger.error(
154
- "labelnames for metric %s not the same, cannot update! Old: %s, New: %s",
155
+ """labelnames for metric %s not the same, cannot update!
156
+ Old: %s, New: %s""",
155
157
  self.args.metric,
156
158
  old_labelnames,
157
159
  list(labels.keys()),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: promtext-cli
3
- Version: 0.1.2.dev98
3
+ Version: 0.1.2.dev100
4
4
  Summary: Prometheus Textfile Tooling
5
5
  Project-URL: Documentation, https://codeberg.org/margau/promtext-cli/src/branch/main#readme
6
6
  Project-URL: Issues, https://codeberg.org/margau/promtext-cli/issues
@@ -0,0 +1,7 @@
1
+ promtext_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ promtext_cli/main.py,sha256=4laMsJ9J1w1peJxv_QfvdRir6zXn19AmGFaEuo1dcRs,194
3
+ promtext_cli/promtext.py,sha256=yJMTHvMi6g-frMOgn1sXy0rcBQnxuVTsIr_AV2mVo1A,6449
4
+ promtext_cli-0.1.2.dev100.dist-info/METADATA,sha256=8w4dbLRmXcFYaR552lX_nOx86Q8lOIbMg_uhdpbu1wk,3415
5
+ promtext_cli-0.1.2.dev100.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
6
+ promtext_cli-0.1.2.dev100.dist-info/entry_points.txt,sha256=qH5Z6dM8QLK7tQ0RrdWZQtRcsdCyaGSU1WXygIcaRRc,52
7
+ promtext_cli-0.1.2.dev100.dist-info/RECORD,,
@@ -1,7 +0,0 @@
1
- promtext_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- promtext_cli/main.py,sha256=dSifo05hboJyEDbLv6F9u7ETNndlXmrRn_Ol8r4EEFk,208
3
- promtext_cli/promtext.py,sha256=BhCZ8ZjyyxD680FeXiaPwU9jXCku4D8fVPRLbZv0_Mc,6402
4
- promtext_cli-0.1.2.dev98.dist-info/METADATA,sha256=Y_VFIy0JR-yXiIedY5xoK6gpG81CIJj_cmL1lUdJFzQ,3414
5
- promtext_cli-0.1.2.dev98.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
6
- promtext_cli-0.1.2.dev98.dist-info/entry_points.txt,sha256=qH5Z6dM8QLK7tQ0RrdWZQtRcsdCyaGSU1WXygIcaRRc,52
7
- promtext_cli-0.1.2.dev98.dist-info/RECORD,,