line-protocol-parser 1.1.4__tar.gz → 2.0.1__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.1}/PKG-INFO +34 -10
  2. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/README.rst +30 -4
  3. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/include/line_protocol_parser.h +7 -1
  4. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/line_protocol_parser/__init__.py +2 -2
  5. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1/line_protocol_parser.egg-info}/PKG-INFO +34 -10
  6. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/setup.py +2 -5
  7. line_protocol_parser-2.0.1/src/line_protocol_parser.c +890 -0
  8. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/src/module.c +62 -8
  9. line_protocol_parser-2.0.1/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.1}/LICENSE.md +0 -0
  13. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/MANIFEST.in +0 -0
  14. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/line_protocol_parser.egg-info/SOURCES.txt +0 -0
  15. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/line_protocol_parser.egg-info/dependency_links.txt +0 -0
  16. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/line_protocol_parser.egg-info/top_level.txt +0 -0
  17. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/setup.cfg +0 -0
  18. {line_protocol_parser-1.1.4 → line_protocol_parser-2.0.1}/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.1
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,14 @@ 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
26
+ Classifier: Programming Language :: Python :: 3.15
31
27
  Classifier: Programming Language :: Python :: Implementation :: CPython
28
+ Requires-Python: >=3.10
32
29
  License-File: LICENSE.md
33
30
  Dynamic: author
34
31
  Dynamic: author-email
@@ -38,6 +35,7 @@ Dynamic: home-page
38
35
  Dynamic: keywords
39
36
  Dynamic: license
40
37
  Dynamic: license-file
38
+ Dynamic: requires-python
41
39
  Dynamic: summary
42
40
 
43
41
  Welcome to InfluxDB line-protocol-parser
@@ -68,10 +66,25 @@ The line protocol has the following format:
68
66
 
69
67
  and is documented here: `InfluxDB line protocol`_.
70
68
 
69
+ This parser is aligned with archived InfluxDB v1.2 single-line parser
70
+ semantics for standard text inputs. When an input point omits the timestamp,
71
+ ``parse_line()`` returns ``None`` for ``time`` so omission remains distinct
72
+ from an explicit ``0`` timestamp. Leading ``#`` comment lines, including
73
+ lines with leading whitespace before ``#``, are treated as valid input and
74
+ ``parse_line()`` returns ``None`` for those lines as well. The parser also
75
+ accepts the same top-level whitespace skipping before measurements, fields,
76
+ and timestamps that the archived v1.2 parser tolerated, along with trailing
77
+ spaces after the optional timestamp. The combined measurement/tag key is
78
+ limited to 65535 bytes, matching the archived parser limit.
79
+ Unsigned ``123u`` field values are retained as a package extension even though
80
+ they are not documented in the archived v1.2 reference.
81
+
71
82
  The ``line_protocol_parser`` module only contains the ``parse_line`` function and the ``LineFormatError`` exception which is raised on failure.
72
83
 
73
84
  Installation
74
85
  ^^^^^^^^^^^^
86
+ Python 3.10 or newer is required.
87
+
75
88
  From PyPI:
76
89
 
77
90
  .. code-block:: bash
@@ -102,6 +115,7 @@ Use Case 1: Read points from a file
102
115
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103
116
  Suppose you have a text file with influxDB measurement points, "my_influxDB_points.txt"::
104
117
 
118
+ # generated by sensor gateway
105
119
  myMeasurement,someTag=A temperature=37.0 1570977942581909918
106
120
  myMeasurement,someTag=A temperature=37.3 1570977942581910000
107
121
  myMeasurement,someTag=A temperature=36.9 1570977942581912345
@@ -115,7 +129,9 @@ Then you can load each line into a dicitonary to be printed like this:
115
129
  >>> from line_protocol_parser import parse_line
116
130
  >>> with open('my_influxDB_points.txt', 'r') as f_obj:
117
131
  ... for line in f_obj:
118
- ... print(parse_line(line))
132
+ ... point = parse_line(line)
133
+ ... if point is not None:
134
+ ... print(point)
119
135
 
120
136
 
121
137
  Use Case 2: InfluxDB subscriptions
@@ -165,7 +181,9 @@ Create a python file *server.py* with the following content:
165
181
  def do_POST(self):
166
182
  content_length = int(self.headers['Content-Length'])
167
183
  post_data = self.rfile.read(content_length)
168
- pprint(parse_line(post_data))
184
+ point = parse_line(post_data)
185
+ if point is not None:
186
+ pprint(point)
169
187
  self.send_response(200)
170
188
  self.end_headers()
171
189
 
@@ -209,6 +227,12 @@ If you are not interested in the Python wrapper you may find the pure-c files us
209
227
  * ``include/line_protocol_parser.h``
210
228
  * ``src/line_protocol_parser.c``
211
229
 
230
+ The C API keeps the original point-or-error contract. If you want to skip
231
+ leading ``#`` comment lines in C code, filter those lines before calling
232
+ ``LP_parse_line()``. The C API accepts NUL-terminated strings only, while the
233
+ Python wrapper rejects embedded NUL bytes instead of silently truncating
234
+ input.
235
+
212
236
  Example:
213
237
 
214
238
  .. code-block:: c
@@ -237,7 +261,7 @@ Changelog
237
261
  ^^^^^^^^^
238
262
  The changelog is maintained in the debian directory, please check there: `changelog <debian/changelog>`_.
239
263
 
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/
264
+ .. _line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
265
+ .. _InfluxDB line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
242
266
  .. _InfluxDB Subscriptions: https://docs.influxdata.com/influxdb/latest/administration/subscription-management/
243
267
  .. _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.1'
@@ -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.1
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,14 @@ 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
26
+ Classifier: Programming Language :: Python :: 3.15
31
27
  Classifier: Programming Language :: Python :: Implementation :: CPython
28
+ Requires-Python: >=3.10
32
29
  License-File: LICENSE.md
33
30
  Dynamic: author
34
31
  Dynamic: author-email
@@ -38,6 +35,7 @@ Dynamic: home-page
38
35
  Dynamic: keywords
39
36
  Dynamic: license
40
37
  Dynamic: license-file
38
+ Dynamic: requires-python
41
39
  Dynamic: summary
42
40
 
43
41
  Welcome to InfluxDB line-protocol-parser
@@ -68,10 +66,25 @@ The line protocol has the following format:
68
66
 
69
67
  and is documented here: `InfluxDB line protocol`_.
70
68
 
69
+ This parser is aligned with archived InfluxDB v1.2 single-line parser
70
+ semantics for standard text inputs. When an input point omits the timestamp,
71
+ ``parse_line()`` returns ``None`` for ``time`` so omission remains distinct
72
+ from an explicit ``0`` timestamp. Leading ``#`` comment lines, including
73
+ lines with leading whitespace before ``#``, are treated as valid input and
74
+ ``parse_line()`` returns ``None`` for those lines as well. The parser also
75
+ accepts the same top-level whitespace skipping before measurements, fields,
76
+ and timestamps that the archived v1.2 parser tolerated, along with trailing
77
+ spaces after the optional timestamp. The combined measurement/tag key is
78
+ limited to 65535 bytes, matching the archived parser limit.
79
+ Unsigned ``123u`` field values are retained as a package extension even though
80
+ they are not documented in the archived v1.2 reference.
81
+
71
82
  The ``line_protocol_parser`` module only contains the ``parse_line`` function and the ``LineFormatError`` exception which is raised on failure.
72
83
 
73
84
  Installation
74
85
  ^^^^^^^^^^^^
86
+ Python 3.10 or newer is required.
87
+
75
88
  From PyPI:
76
89
 
77
90
  .. code-block:: bash
@@ -102,6 +115,7 @@ Use Case 1: Read points from a file
102
115
  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
103
116
  Suppose you have a text file with influxDB measurement points, "my_influxDB_points.txt"::
104
117
 
118
+ # generated by sensor gateway
105
119
  myMeasurement,someTag=A temperature=37.0 1570977942581909918
106
120
  myMeasurement,someTag=A temperature=37.3 1570977942581910000
107
121
  myMeasurement,someTag=A temperature=36.9 1570977942581912345
@@ -115,7 +129,9 @@ Then you can load each line into a dicitonary to be printed like this:
115
129
  >>> from line_protocol_parser import parse_line
116
130
  >>> with open('my_influxDB_points.txt', 'r') as f_obj:
117
131
  ... for line in f_obj:
118
- ... print(parse_line(line))
132
+ ... point = parse_line(line)
133
+ ... if point is not None:
134
+ ... print(point)
119
135
 
120
136
 
121
137
  Use Case 2: InfluxDB subscriptions
@@ -165,7 +181,9 @@ Create a python file *server.py* with the following content:
165
181
  def do_POST(self):
166
182
  content_length = int(self.headers['Content-Length'])
167
183
  post_data = self.rfile.read(content_length)
168
- pprint(parse_line(post_data))
184
+ point = parse_line(post_data)
185
+ if point is not None:
186
+ pprint(point)
169
187
  self.send_response(200)
170
188
  self.end_headers()
171
189
 
@@ -209,6 +227,12 @@ If you are not interested in the Python wrapper you may find the pure-c files us
209
227
  * ``include/line_protocol_parser.h``
210
228
  * ``src/line_protocol_parser.c``
211
229
 
230
+ The C API keeps the original point-or-error contract. If you want to skip
231
+ leading ``#`` comment lines in C code, filter those lines before calling
232
+ ``LP_parse_line()``. The C API accepts NUL-terminated strings only, while the
233
+ Python wrapper rejects embedded NUL bytes instead of silently truncating
234
+ input.
235
+
212
236
  Example:
213
237
 
214
238
  .. code-block:: c
@@ -237,7 +261,7 @@ Changelog
237
261
  ^^^^^^^^^
238
262
  The changelog is maintained in the debian directory, please check there: `changelog <debian/changelog>`_.
239
263
 
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/
264
+ .. _line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
265
+ .. _InfluxDB line protocol: https://archive.docs.influxdata.com/influxdb/v1.2/write_protocols/line_protocol_reference/
242
266
  .. _InfluxDB Subscriptions: https://docs.influxdata.com/influxdb/latest/administration/subscription-management/
243
267
  .. _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,16 +57,12 @@ 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',
67
63
  'Programming Language :: Python :: 3.13',
68
64
  'Programming Language :: Python :: 3.14',
65
+ 'Programming Language :: Python :: 3.15',
69
66
  'Programming Language :: Python :: Implementation :: CPython'
70
67
  ]
71
68
  )