dotstrings 3.0.0__tar.gz → 3.1.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.
@@ -1,12 +1,12 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dotstrings
3
- Version: 3.0.0
3
+ Version: 3.1.0
4
4
  Summary: Tools for dealing with the .strings files for iOS and macOS
5
5
  Home-page: https://github.com/Microsoft/dotstrings
6
6
  License: MIT
7
7
  Keywords: localization,iOS,macOS,strings
8
8
  Author: Dale Myers
9
- Author-email: dalemy@microsoft.com
9
+ Author-email: dalemyers@microsoft.com
10
10
  Requires-Python: >=3.10,<4.0
11
11
  Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Environment :: Console
@@ -17,6 +17,7 @@ Classifier: Programming Language :: Python :: 3
17
17
  Classifier: Programming Language :: Python :: 3.10
18
18
  Classifier: Programming Language :: Python :: 3.11
19
19
  Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
20
21
  Classifier: Programming Language :: Python :: 3.8
21
22
  Classifier: Programming Language :: Python :: 3.9
22
23
  Classifier: Topic :: Software Development
@@ -15,6 +15,7 @@ class Patterns:
15
15
  comment = re.compile(r"(\'(?:[^\'\\]|\\[\s\S])*\')|//.*|/\*(?:[^*]|\*(?!/))*\*/", re.MULTILINE)
16
16
  whitespace = re.compile(r"\s*", re.MULTILINE)
17
17
  entry = re.compile(r'"(.*)"\s*=\s*"(.*)";')
18
+ quoteless_key_entry = re.compile(r'(.*?)\s*=\s*"(.*)";')
18
19
 
19
20
 
20
21
  class Scanner:
@@ -137,18 +138,32 @@ def loads(contents: str) -> list[DotStringsEntry]:
137
138
  # Pull out any whitespace
138
139
  _ = scanner.scan(Patterns.whitespace)
139
140
 
140
- # Get the entry line
141
+ # Get the entry line. Always try with quotes first to avoid matching
142
+ # the "quoteless" style and then including the quotes in the key.
141
143
  entry = scanner.scan(Patterns.entry)
144
+ regular_entry = True
142
145
 
143
146
  if entry is None:
144
- if scanner.has_more():
145
- raise DotStringsException(f"Expected an entry at offset {scanner.offset}")
146
- break
147
+ entry = scanner.scan(Patterns.quoteless_key_entry)
148
+ regular_entry = False
149
+
150
+ if entry is None:
151
+ if scanner.has_more():
152
+ raise DotStringsException(
153
+ f"Expected an entry at offset {scanner.offset}"
154
+ )
155
+ break
147
156
 
148
157
  # Now extract the key and value
149
- entry_matches = Patterns.entry.search(entry)
158
+ if regular_entry:
159
+ entry_matches = Patterns.entry.search(entry)
160
+ else:
161
+ entry_matches = Patterns.quoteless_key_entry.search(entry)
162
+
150
163
  if not entry_matches:
151
- raise DotStringsException(f"Failed to parse entry at offset {scanner.offset}")
164
+ raise DotStringsException(
165
+ f"Failed to parse entry at offset {scanner.offset}"
166
+ )
152
167
 
153
168
  key = entry_matches.group(1)
154
169
  value = entry_matches.group(2)
@@ -1,12 +1,12 @@
1
1
  [tool.poetry]
2
2
  name = "dotstrings"
3
- version = "3.0.0"
3
+ version = "3.1.0"
4
4
  description = "Tools for dealing with the .strings files for iOS and macOS"
5
5
 
6
6
  license = "MIT"
7
7
 
8
8
  authors = [
9
- "Dale Myers <dalemy@microsoft.com>"
9
+ "Dale Myers <dalemyers@microsoft.com>"
10
10
  ]
11
11
 
12
12
  readme = 'README.md'
File without changes
File without changes