os-normalizer 0.4.2__py3-none-any.whl → 0.4.3__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.

Potentially problematic release.


This version of os-normalizer might be problematic. Click here for more details.

@@ -20,7 +20,8 @@ if TYPE_CHECKING:
20
20
 
21
21
  VERSION_PATTERN = re.compile(r"\b(\d+)\.(\d+)\.(\d+)(?:\.(\d+))?\b")
22
22
  NT_PATTERN = re.compile(r"\bnt\s*(\d+)(?:\.(\d+))?", re.IGNORECASE)
23
- BUILD_PATTERN = re.compile(r"\bbuild\s*(?:number\s*)?(\d{3,5})\b", re.IGNORECASE)
23
+ BUILD_PATTERN = re.compile(r"\bbuild\s*(?:number\s*)?[:=\s-]*?(\d{3,5})\b", re.IGNORECASE)
24
+ KERNEL_PATTERN = re.compile(r"\bkernel\s*[:=\s-]*?(\d+)(?:\.(\d+))?", re.IGNORECASE)
24
25
  SP_PATTERN = re.compile(r"\bsp(\d)\b", re.IGNORECASE)
25
26
 
26
27
  EDITION_KEYWORDS: list[tuple[str, str]] = [
@@ -141,6 +142,13 @@ def _extract_version_state(text: str) -> VersionState:
141
142
  state.nt_minor = state.nt_minor if state.nt_minor is not None else minr
142
143
  state.explicit = True
143
144
 
145
+ if state.nt_major is None:
146
+ kernel_match = KERNEL_PATTERN.search(text)
147
+ if kernel_match:
148
+ state.nt_major = int(kernel_match.group(1))
149
+ state.nt_minor = int(kernel_match.group(2)) if kernel_match.group(2) else 0
150
+ state.explicit = True
151
+
144
152
  if state.build is None:
145
153
  build_match = BUILD_PATTERN.search(text)
146
154
  if build_match:
@@ -157,11 +165,8 @@ def _apply_build_context(state: VersionState, product: str | None, server_hint:
157
165
  return product, server_hint
158
166
 
159
167
  product_from_build, channel, is_server_build = _lookup_build(build_num, server_hint)
160
- if product_from_build:
161
- if not product:
162
- product = product_from_build
163
- elif product != product_from_build and _build_inference_is_more_precise(product, product_from_build):
164
- product = product_from_build
168
+ if product_from_build and (not product or _build_inference_should_replace(product, product_from_build)):
169
+ product = product_from_build
165
170
  if is_server_build:
166
171
  server_hint = True
167
172
  state.channel = channel
@@ -192,11 +197,18 @@ def _apply_version_numbers(p: OSData, defaults: ProductDefaults, state: VersionS
192
197
  def _set_kernel_version(p: OSData, defaults: ProductDefaults | None, state: VersionState) -> None:
193
198
  """Populate kernel_version using explicit tokens, build channel, or defaults."""
194
199
  kernel_version: str | None = None
195
- if state.explicit and state.nt_major is not None:
196
- if state.nt_major >= 10 and state.channel:
197
- kernel_version = state.channel
198
- elif state.nt_minor is not None:
200
+ if (
201
+ state.explicit
202
+ and state.channel
203
+ and (state.nt_major is None or state.nt_major >= 10)
204
+ and (defaults is None or defaults.kernel_version is None)
205
+ ):
206
+ kernel_version = state.channel
207
+ elif state.explicit and state.nt_major is not None:
208
+ if state.nt_minor is not None:
199
209
  kernel_version = f"{state.nt_major}.{state.nt_minor}"
210
+ elif state.nt_major >= 10 and state.channel:
211
+ kernel_version = state.channel
200
212
  if kernel_version is None and defaults and defaults.kernel_version:
201
213
  kernel_version = defaults.kernel_version
202
214
  if kernel_version:
@@ -253,13 +265,16 @@ def _lookup_build(build_num: int, server_hint: bool) -> tuple[str | None, str |
253
265
  return candidate
254
266
 
255
267
 
256
- def _build_inference_is_more_precise(existing: str, inferred: str) -> bool:
257
- """Return True when the build map provides a more specific client SKU."""
258
- if existing in {"Windows 10", "Windows 10/11"} and inferred.startswith("Windows 11"):
259
- return True
260
- if existing == "Windows 10/11" and inferred == "Windows 10":
261
- return True
262
- return False
268
+ def _build_inference_should_replace(existing: str, inferred: str) -> bool:
269
+ """Return True when build metadata should override a detected product label."""
270
+ existing_lower = existing.lower()
271
+ inferred_lower = inferred.lower()
272
+
273
+ if existing_lower == inferred_lower:
274
+ return False
275
+ if inferred_lower.startswith(existing_lower):
276
+ return False
277
+ return True
263
278
 
264
279
 
265
280
  def _product_from_nt(major: int, minor: int, server_hint: bool) -> str | None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: os-normalizer
3
- Version: 0.4.2
3
+ Version: 0.4.3
4
4
  Summary: Normalize raw OS strings/metadata into structured data (family, product, version, arch).
5
5
  Project-URL: Homepage, https://github.com/johnscillieri/os-normalizer
6
6
  Project-URL: Repository, https://github.com/johnscillieri/os-normalizer
@@ -9,14 +9,14 @@ os_normalizer/parsers/bsd.py,sha256=Umm7RSXjQfv6pfziJ8BYlmOc80VlLRueTrYw1iR-UjY,
9
9
  os_normalizer/parsers/linux.py,sha256=kSIYZ_hRJxJieV21u8TRcWfAjYOIXlCLBSwyINkuyA4,3867
10
10
  os_normalizer/parsers/macos.py,sha256=fU1YyiijzBdDAxUBSL2EQLhUu3JbOSx-N_KYvOg0XsI,3627
11
11
  os_normalizer/parsers/mobile.py,sha256=Ca864JhrO9zW5fs0zbs2VcMypKIkFHqZtxpJDbi12q0,1033
12
- os_normalizer/parsers/windows.py,sha256=-dWS2KJltDXThsQL78ulyn6S4Q7QW5QMRklKosvQF30,10930
12
+ os_normalizer/parsers/windows.py,sha256=ugs7Y5mDir5eSTJ7eBHJkeFD8RfLGQsOebjnxVNO53M,11465
13
13
  os_normalizer/parsers/network/__init__.py,sha256=TvRz08lNDZbr6yG8O3M7cLNu0hWAbtE1y7_9SwhP4g4,1596
14
14
  os_normalizer/parsers/network/cisco.py,sha256=ivhw85IHnHVT4sW-65F-ZGCR7yvu0mMMBfXRT4EzUfc,3203
15
15
  os_normalizer/parsers/network/fortinet.py,sha256=i6PVRxzO_onaCvo3_eI4csXFwGp4ZpQY0d1y2-Wodn0,1783
16
16
  os_normalizer/parsers/network/huawei.py,sha256=Su3eCRlmOCmpOPA_TGeH8gHY3-ZdXKFW4O3_W0SOPmk,1158
17
17
  os_normalizer/parsers/network/juniper.py,sha256=gskbaY4-LYWauM9yrvGMuCxPrNBKmUfIRPd1zsUUY7w,1275
18
18
  os_normalizer/parsers/network/netgear.py,sha256=idVD7VTxb07LdhFPwb-sT3586ARoBrd1OmWpADAZUVc,1190
19
- os_normalizer-0.4.2.dist-info/METADATA,sha256=ipNU2HGD2BpwGh9jj0v5a6hYgvjR5qJN1M8apT0FwKk,6455
20
- os_normalizer-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
- os_normalizer-0.4.2.dist-info/licenses/LICENSE,sha256=DN0enoiHxVkJ-hxmIchPaCQWrDsZwva5LY8XvG3UK8w,1083
22
- os_normalizer-0.4.2.dist-info/RECORD,,
19
+ os_normalizer-0.4.3.dist-info/METADATA,sha256=Pwj2AdX_9bvzcklztIWEvgUMmjiEmMHn6UZ8Qi1yGyM,6455
20
+ os_normalizer-0.4.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
21
+ os_normalizer-0.4.3.dist-info/licenses/LICENSE,sha256=DN0enoiHxVkJ-hxmIchPaCQWrDsZwva5LY8XvG3UK8w,1083
22
+ os_normalizer-0.4.3.dist-info/RECORD,,