partialjson 0.0.5__tar.gz → 0.0.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: partialjson
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: Parse incomplete or partial json
5
5
  Home-page: https://github.com/iw4p/partialjson
6
6
  Author: Nima Akbarzadeh
@@ -1,11 +1,11 @@
1
1
  """
2
- torrentp.
2
+ Partial Json.
3
3
 
4
- A great wrapped library for downloading from torrent.
4
+ Parsing ChatGPT JSON stream response — Partial and incomplete JSON parser python library for OpenAI
5
5
  """
6
6
  from .json_parser import JSONParser
7
7
 
8
- __version__ = "0.0.5"
8
+ __version__ = "0.0.7"
9
9
  __author__ = 'Nima Akbarzadeh'
10
10
  __author_email__ = "iw4p@protonmail.com"
11
11
  __license__ = "MIT"
@@ -119,26 +119,29 @@ class JSONParser:
119
119
  i += 1
120
120
  num_str = s[:i]
121
121
  s = s[i:]
122
- if not num_str or num_str.endswith('.') or num_str.endswith('-'):
123
- return num_str, "" # Return the incomplete number as is
122
+ if not num_str or num_str == "-" or num_str == ".":
123
+ return num_str, ""
124
124
  try:
125
- num = float(num_str) if '.' in num_str or 'e' in num_str or 'E' in num_str else int(num_str)
125
+ if num_str.endswith('.'):
126
+ num = int(num_str[:-1])
127
+ else:
128
+ num = float(num_str) if '.' in num_str or 'e' in num_str or 'E' in num_str else int(num_str)
126
129
  except ValueError:
127
130
  raise e
128
131
  return num, s
129
132
 
130
133
  def parse_true(self, s, e):
131
- if s.startswith('true'):
134
+ if s.startswith('t') or s.startswith('T'):
132
135
  return True, s[4:]
133
136
  raise e
134
137
 
135
138
  def parse_false(self, s, e):
136
- if s.startswith('false'):
139
+ if s.startswith('f') or s.startswith('F'):
137
140
  return False, s[5:]
138
141
  raise e
139
142
 
140
143
  def parse_null(self, s, e):
141
- if s.startswith('null'):
144
+ if s.startswith('n'):
142
145
  return None, s[4:]
143
146
  raise e
144
147
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: partialjson
3
- Version: 0.0.5
3
+ Version: 0.0.7
4
4
  Summary: Parse incomplete or partial json
5
5
  Home-page: https://github.com/iw4p/partialjson
6
6
  Author: Nima Akbarzadeh
File without changes
File without changes
File without changes
File without changes