line-protocol-parser 1.1.4__tar.gz → 2.0.0__tar.gz

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.
Files changed (18) hide show
  1. {line_protocol_parser-1.1.4/line_protocol_parser.egg-info → line_protocol_parser-2.0.0}/PKG-INFO +33 -10
  2. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/README.rst +30 -4
  3. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/include/line_protocol_parser.h +7 -1
  4. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/line_protocol_parser/__init__.py +2 -2
  5. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0/line_protocol_parser.egg-info}/PKG-INFO +33 -10
  6. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/setup.py +1 -5
  7. line_protocol_parser-2.0.0/src/line_protocol_parser.c +890 -0
  8. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/src/module.c +62 -8
  9. line_protocol_parser-2.0.0/tests/test_parse_line.py +744 -0
  10. line_protocol_parser-1.1.4/src/line_protocol_parser.c +0 -524
  11. line_protocol_parser-1.1.4/tests/test_parse_line.py +0 -189
  12. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/LICENSE.md +0 -0
  13. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/MANIFEST.in +0 -0
  14. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/line_protocol_parser.egg-info/SOURCES.txt +0 -0
  15. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/line_protocol_parser.egg-info/dependency_links.txt +0 -0
  16. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/line_protocol_parser.egg-info/top_level.txt +0 -0
  17. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/setup.cfg +0 -0
  18. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.0}/tests/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: line-protocol-parser
3
- Version: 1.1.4
3
+ Version: 2.0.0
4
4
  Summary: Parse InfluxDB line protocol string into Python dictionary
5
5
  Home-page: https://github.com/Penlect/line-protocol-parser
6
6
  Author: Daniel Andersson
@@ -18,17 +18,13 @@ Classifier: Operating System :: POSIX :: Linux
18
18
  Classifier: Operating System :: MacOS
19
19
  Classifier: Operating System :: Microsoft :: Windows :: Windows 10
20
20
  Classifier: Programming Language :: C
21
- Classifier: Programming Language :: Python :: 3.5
22
- Classifier: Programming Language :: Python :: 3.6
23
- Classifier: Programming Language :: Python :: 3.7
24
- Classifier: Programming Language :: Python :: 3.8
25
- Classifier: Programming Language :: Python :: 3.9
26
21
  Classifier: Programming Language :: Python :: 3.10
27
22
  Classifier: Programming Language :: Python :: 3.11
28
23
  Classifier: Programming Language :: Python :: 3.12
29
24
  Classifier: Programming Language :: Python :: 3.13
30
25
  Classifier: Programming Language :: Python :: 3.14
31
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Requires-Python: >=3.10
32
28
  License-File: LICENSE.md
33
29
  Dynamic: author
34
30
  Dynamic: author-email
@@ -38,6 +34,7 @@ Dynamic: home-page
38
34
  Dynamic: keywords
39
35
  Dynamic: license
40
36
  Dynamic: license-file
37
+ Dynamic: requires-python
41
38
  Dynamic: summary
42
39
 
43
40
  Welcome to InfluxDB line-protocol-parser
@@ -68,10 +65,25 @@ The line protocol has the following format:
68
65
 
69
66
  and is documented here: `InfluxDB line protocol`_.
70
67
 
68
+ This parser is aligned with archived InfluxDB v1.2 single-line parser
69
+ semantics for standard text inputs. When an input point omits the timestamp,
70
+ ``parse_line()`` returns ``None`` for ``time`` so omission remains distinct
71
+ from an explicit ``0`` timestamp. Leading ``#`` comment lines, including
72
+ lines with leading whitespace before ``#``, are treated as valid input and
73
+ ``parse_line()`` returns ``None`` for those lines as well. The parser also
74
+ accepts the same top-level whitespace skipping before measurements, fields,
75
+ and timestamps that the archived v1.2 parser tolerated, along with trailing
76
+ spaces after the optional timestamp. The combined measurement/tag key is
77
+ limited to 65535 bytes, matching the archived parser limit.
78
+ Unsigned ``123u`` field values are retained as a package extension even though
79
+ they are not documented in the archived v1.2 reference.
80
+
71
81
  The ``line_protocol_parser`` module only contains the ``parse_line`` function and the ``LineFormatError`` exception which is raised on failure.
72
82
 
73
83
  Installation
74
84
  ^^^^^^^^^^^^
85
+ Python 3.10 or newer is required.
86
+
75
87
  From PyPI:
76
88
 
77
89
  .. code-block:: bash
@@ -102,6 +114,7 @@ Use Case 1: Read points from a file
102
114
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103
115
  Suppose you have a text file with influxDB measurement points, "my_influxDB_points.txt"::
104
116
 
117
+ # generated by sensor gateway
105
118
  myMeasurement,someTag=A temperature=37.0 1570977942581909918
106
119
  myMeasurement,someTag=A temperature=37.3 1570977942581910000
107
120
  myMeasurement,someTag=A temperature=36.9 1570977942581912345
@@ -115,7 +128,9 @@ Then you can load each line into a dicitonary to be printed like this:
115
128
  >>> from line_protocol_parser import parse_line
116
129
  >>> with open('my_influxDB_points.txt', 'r') as f_obj:
117
130
  ... for line in f_obj:
118
- ... print(parse_line(line))
131
+ ... point = parse_line(line)
132
+ ... if point is not None:
133
+ ... print(point)
119
134
 
120
135
 
121
136
  Use Case 2: InfluxDB subscriptions
@@ -165,7 +180,9 @@ Create a python file *server.py* with the following content:
165
180
  def do_POST(self):
166
181
  content_length = int(self.headers['Content-Length'])
167
182
  post_data = self.rfile.read(content_length)
168
- pprint(parse_line(post_data))
183
+ point = parse_line(post_data)
184
+ if point is not None:
185
+ pprint(point)
169
186
  self.send_response(200)
170
187
  self.end_headers()
171
188
 
@@ -209,6 +226,12 @@ If you are not interested in the Python wrapper you may find the pure-c files us
209
226
  * ``include/line_protocol_parser.h``
210
227
  * ``src/line_protocol_parser.c``
211
228
 
229
+ The C API keeps the original point-or-error contract. If you want to skip
230
+ leading ``#`` comment lines in C code, filter those lines before calling
231
+ ``LP_parse_line()``. The C API accepts NUL-terminated strings only, while the
232
+ Python wrapper rejects embedded NUL bytes instead of silently truncating
233
+ input.
234
+
212
235
  Example:
213
236
 
214
237
  .. code-block:: c
@@ -237,7 +260,7 @@ Changelog
237
260
  ^^^^^^^^^
238
261
  The changelog is maintained in the debian directory, please check there: `changelog <debian/changelog>`_.
239
262
 
240
- .. _line protocol: https://docs.influxdata.com/influxdb/latest/write_protocols/line_protocol_reference/
241
- .. _InfluxDB line protocol: https://docs.influxdata.com/influxdb/latest/write_protocols/line_protocol_reference/
263
+ .. _line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
264
+ .. _InfluxDB line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
242
265
  .. _InfluxDB Subscriptions: https://docs.influxdata.com/influxdb/latest/administration/subscription-management/
243
266
  .. _InfluxDB container: https://hub.docker.com/_/influxdb
@@ -26,10 +26,25 @@ The line protocol has the following format:
26
26
 
27
27
  and is documented here: `InfluxDB line protocol`_.
28
28
 
29
+ This parser is aligned with archived InfluxDB v1.2 single-line parser
30
+ semantics for standard text inputs. When an input point omits the timestamp,
31
+ ``parse_line()`` returns ``None`` for ``time`` so omission remains distinct
32
+ from an explicit ``0`` timestamp. Leading ``#`` comment lines, including
33
+ lines with leading whitespace before ``#``, are treated as valid input and
34
+ ``parse_line()`` returns ``None`` for those lines as well. The parser also
35
+ accepts the same top-level whitespace skipping before measurements, fields,
36
+ and timestamps that the archived v1.2 parser tolerated, along with trailing
37
+ spaces after the optional timestamp. The combined measurement/tag key is
38
+ limited to 65535 bytes, matching the archived parser limit.
39
+ Unsigned ``123u`` field values are retained as a package extension even though
40
+ they are not documented in the archived v1.2 reference.
41
+
29
42
  The ``line_protocol_parser`` module only contains the ``parse_line`` function and the ``LineFormatError`` exception which is raised on failure.
30
43
 
31
44
  Installation
32
45
  ^^^^^^^^^^^^
46
+ Python 3.10 or newer is required.
47
+
33
48
  From PyPI:
34
49
 
35
50
  .. code-block:: bash
@@ -60,6 +75,7 @@ Use Case 1: Read points from a file
60
75
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
61
76
  Suppose you have a text file with influxDB measurement points, "my_influxDB_points.txt"::
62
77
 
78
+ # generated by sensor gateway
63
79
  myMeasurement,someTag=A temperature=37.0 1570977942581909918
64
80
  myMeasurement,someTag=A temperature=37.3 1570977942581910000
65
81
  myMeasurement,someTag=A temperature=36.9 1570977942581912345
@@ -73,7 +89,9 @@ Then you can load each line into a dicitonary to be printed like this:
73
89
  >>> from line_protocol_parser import parse_line
74
90
  >>> with open('my_influxDB_points.txt', 'r') as f_obj:
75
91
  ... for line in f_obj:
76
- ... print(parse_line(line))
92
+ ... point = parse_line(line)
93
+ ... if point is not None:
94
+ ... print(point)
77
95
 
78
96
 
79
97
  Use Case 2: InfluxDB subscriptions
@@ -123,7 +141,9 @@ Create a python file *server.py* with the following content:
123
141
  def do_POST(self):
124
142
  content_length = int(self.headers['Content-Length'])
125
143
  post_data = self.rfile.read(content_length)
126
- pprint(parse_line(post_data))
144
+ point = parse_line(post_data)
145
+ if point is not None:
146
+ pprint(point)
127
147
  self.send_response(200)
128
148
  self.end_headers()
129
149
 
@@ -167,6 +187,12 @@ If you are not interested in the Python wrapper you may find the pure-c files us
167
187
  * ``include/line_protocol_parser.h``
168
188
  * ``src/line_protocol_parser.c``
169
189
 
190
+ The C API keeps the original point-or-error contract. If you want to skip
191
+ leading ``#`` comment lines in C code, filter those lines before calling
192
+ ``LP_parse_line()``. The C API accepts NUL-terminated strings only, while the
193
+ Python wrapper rejects embedded NUL bytes instead of silently truncating
194
+ input.
195
+
170
196
  Example:
171
197
 
172
198
  .. code-block:: c
@@ -195,7 +221,7 @@ Changelog
195
221
  ^^^^^^^^^
196
222
  The changelog is maintained in the debian directory, please check there: `changelog <debian/changelog>`_.
197
223
 
198
- .. _line protocol: https://docs.influxdata.com/influxdb/latest/write_protocols/line_protocol_reference/
199
- .. _InfluxDB line protocol: https://docs.influxdata.com/influxdb/latest/write_protocols/line_protocol_reference/
224
+ .. _line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
225
+ .. _InfluxDB line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
200
226
  .. _InfluxDB Subscriptions: https://docs.influxdata.com/influxdb/latest/administration/subscription-management/
201
227
  .. _InfluxDB container: https://hub.docker.com/_/influxdb
@@ -1,6 +1,9 @@
1
1
  #ifndef LINEPROTOCOLPARSER_H
2
2
  #define LINEPROTOCOLPARSER_H
3
3
 
4
+ #include <stdbool.h>
5
+ #include <stdint.h>
6
+
4
7
  /* Error return codes of `LP_parse_line` */
5
8
  #define LP_MEMORY_ERROR 1
6
9
  #define LP_LINE_EMPTY 2
@@ -13,6 +16,7 @@
13
16
  #define LP_FIELD_VALUE_ERROR 9
14
17
  #define LP_FIELD_VALUE_TYPE_ERROR 10
15
18
  #define LP_TIME_ERROR 11
19
+ #define LP_KEY_TOO_LONG_ERROR 12
16
20
 
17
21
  /* Indicates which type a field has */
18
22
  enum LP_ValueType {
@@ -49,7 +53,9 @@ struct LP_Point {
49
53
  char *measurement;
50
54
  struct LP_Item *fields;
51
55
  struct LP_Item *tags;
52
- unsigned long long time;
56
+ /* `time` is only valid when `has_time` is true. */
57
+ bool has_time;
58
+ int64_t time;
53
59
  struct LP_Point *next_point;
54
60
  };
55
61
 
@@ -1,4 +1,4 @@
1
- """Module for parsing InfluxDB line protocol strings"""
1
+ """Parse InfluxDB line protocol strings into dictionaries or ``None``."""
2
2
  from ._line_protocol_parser import parse_line, LineFormatError
3
3
 
4
4
  # Module metadata
@@ -9,4 +9,4 @@ __contact__ = __email__
9
9
  __copyright__ = 'Copyright (c) 2019 Daniel Andersson'
10
10
  __license__ = 'MIT'
11
11
  __url__ = "https://github.com/Penlect/line-protocol-parser"
12
- __version__ = '1.1.4'
12
+ __version__ = '2.0.0'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: line-protocol-parser
3
- Version: 1.1.4
3
+ Version: 2.0.0
4
4
  Summary: Parse InfluxDB line protocol string into Python dictionary
5
5
  Home-page: https://github.com/Penlect/line-protocol-parser
6
6
  Author: Daniel Andersson
@@ -18,17 +18,13 @@ Classifier: Operating System :: POSIX :: Linux
18
18
  Classifier: Operating System :: MacOS
19
19
  Classifier: Operating System :: Microsoft :: Windows :: Windows 10
20
20
  Classifier: Programming Language :: C
21
- Classifier: Programming Language :: Python :: 3.5
22
- Classifier: Programming Language :: Python :: 3.6
23
- Classifier: Programming Language :: Python :: 3.7
24
- Classifier: Programming Language :: Python :: 3.8
25
- Classifier: Programming Language :: Python :: 3.9
26
21
  Classifier: Programming Language :: Python :: 3.10
27
22
  Classifier: Programming Language :: Python :: 3.11
28
23
  Classifier: Programming Language :: Python :: 3.12
29
24
  Classifier: Programming Language :: Python :: 3.13
30
25
  Classifier: Programming Language :: Python :: 3.14
31
26
  Classifier: Programming Language :: Python :: Implementation :: CPython
27
+ Requires-Python: >=3.10
32
28
  License-File: LICENSE.md
33
29
  Dynamic: author
34
30
  Dynamic: author-email
@@ -38,6 +34,7 @@ Dynamic: home-page
38
34
  Dynamic: keywords
39
35
  Dynamic: license
40
36
  Dynamic: license-file
37
+ Dynamic: requires-python
41
38
  Dynamic: summary
42
39
 
43
40
  Welcome to InfluxDB line-protocol-parser
@@ -68,10 +65,25 @@ The line protocol has the following format:
68
65
 
69
66
  and is documented here: `InfluxDB line protocol`_.
70
67
 
68
+ This parser is aligned with archived InfluxDB v1.2 single-line parser
69
+ semantics for standard text inputs. When an input point omits the timestamp,
70
+ ``parse_line()`` returns ``None`` for ``time`` so omission remains distinct
71
+ from an explicit ``0`` timestamp. Leading ``#`` comment lines, including
72
+ lines with leading whitespace before ``#``, are treated as valid input and
73
+ ``parse_line()`` returns ``None`` for those lines as well. The parser also
74
+ accepts the same top-level whitespace skipping before measurements, fields,
75
+ and timestamps that the archived v1.2 parser tolerated, along with trailing
76
+ spaces after the optional timestamp. The combined measurement/tag key is
77
+ limited to 65535 bytes, matching the archived parser limit.
78
+ Unsigned ``123u`` field values are retained as a package extension even though
79
+ they are not documented in the archived v1.2 reference.
80
+
71
81
  The ``line_protocol_parser`` module only contains the ``parse_line`` function and the ``LineFormatError`` exception which is raised on failure.
72
82
 
73
83
  Installation
74
84
  ^^^^^^^^^^^^
85
+ Python 3.10 or newer is required.
86
+
75
87
  From PyPI:
76
88
 
77
89
  .. code-block:: bash
@@ -102,6 +114,7 @@ Use Case 1: Read points from a file
102
114
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103
115
  Suppose you have a text file with influxDB measurement points, "my_influxDB_points.txt"::
104
116
 
117
+ # generated by sensor gateway
105
118
  myMeasurement,someTag=A temperature=37.0 1570977942581909918
106
119
  myMeasurement,someTag=A temperature=37.3 1570977942581910000
107
120
  myMeasurement,someTag=A temperature=36.9 1570977942581912345
@@ -115,7 +128,9 @@ Then you can load each line into a dicitonary to be printed like this:
115
128
  >>> from line_protocol_parser import parse_line
116
129
  >>> with open('my_influxDB_points.txt', 'r') as f_obj:
117
130
  ... for line in f_obj:
118
- ... print(parse_line(line))
131
+ ... point = parse_line(line)
132
+ ... if point is not None:
133
+ ... print(point)
119
134
 
120
135
 
121
136
  Use Case 2: InfluxDB subscriptions
@@ -165,7 +180,9 @@ Create a python file *server.py* with the following content:
165
180
  def do_POST(self):
166
181
  content_length = int(self.headers['Content-Length'])
167
182
  post_data = self.rfile.read(content_length)
168
- pprint(parse_line(post_data))
183
+ point = parse_line(post_data)
184
+ if point is not None:
185
+ pprint(point)
169
186
  self.send_response(200)
170
187
  self.end_headers()
171
188
 
@@ -209,6 +226,12 @@ If you are not interested in the Python wrapper you may find the pure-c files us
209
226
  * ``include/line_protocol_parser.h``
210
227
  * ``src/line_protocol_parser.c``
211
228
 
229
+ The C API keeps the original point-or-error contract. If you want to skip
230
+ leading ``#`` comment lines in C code, filter those lines before calling
231
+ ``LP_parse_line()``. The C API accepts NUL-terminated strings only, while the
232
+ Python wrapper rejects embedded NUL bytes instead of silently truncating
233
+ input.
234
+
212
235
  Example:
213
236
 
214
237
  .. code-block:: c
@@ -237,7 +260,7 @@ Changelog
237
260
  ^^^^^^^^^
238
261
  The changelog is maintained in the debian directory, please check there: `changelog <debian/changelog>`_.
239
262
 
240
- .. _line protocol: https://docs.influxdata.com/influxdb/latest/write_protocols/line_protocol_reference/
241
- .. _InfluxDB line protocol: https://docs.influxdata.com/influxdb/latest/write_protocols/line_protocol_reference/
263
+ .. _line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
264
+ .. _InfluxDB line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
242
265
  .. _InfluxDB Subscriptions: https://docs.influxdata.com/influxdb/latest/administration/subscription-management/
243
266
  .. _InfluxDB container: https://hub.docker.com/_/influxdb
@@ -30,6 +30,7 @@ setup(
30
30
  license=__license__,
31
31
  keywords='InfluxDB influx line protocol parser reader',
32
32
  url=__url__,
33
+ python_requires='>=3.10',
33
34
  ext_modules=[
34
35
  Extension(
35
36
  'line_protocol_parser._line_protocol_parser',
@@ -56,11 +57,6 @@ setup(
56
57
  'Operating System :: MacOS',
57
58
  'Operating System :: Microsoft :: Windows :: Windows 10',
58
59
  'Programming Language :: C',
59
- 'Programming Language :: Python :: 3.5',
60
- 'Programming Language :: Python :: 3.6',
61
- 'Programming Language :: Python :: 3.7',
62
- 'Programming Language :: Python :: 3.8',
63
- 'Programming Language :: Python :: 3.9',
64
60
  'Programming Language :: Python :: 3.10',
65
61
  'Programming Language :: Python :: 3.11',
66
62
  'Programming Language :: Python :: 3.12',