Build the OS/platform components of the User-Agent header string. For recognized platform names that match or map to an entry in the list of standardized OS names, a single component with prefix "os" is returned. Otherwise, one component "os/other" is returned and a
(self)
| 458 | return sdk_md |
| 459 | |
| 460 | def _build_os_metadata(self): |
| 461 | """ |
| 462 | Build the OS/platform components of the User-Agent header string. |
| 463 | |
| 464 | For recognized platform names that match or map to an entry in the list |
| 465 | of standardized OS names, a single component with prefix "os" is |
| 466 | returned. Otherwise, one component "os/other" is returned and a second |
| 467 | with prefix "md" and the raw platform name. |
| 468 | |
| 469 | String representations of example return values: |
| 470 | * ``os/macos#10.13.6`` |
| 471 | * ``os/linux`` |
| 472 | * ``os/other`` |
| 473 | * ``os/other md/foobar#1.2.3`` |
| 474 | """ |
| 475 | if self._platform_name is None: |
| 476 | return [UserAgentComponent('os', 'other')] |
| 477 | |
| 478 | plt_name_lower = self._platform_name.lower() |
| 479 | if plt_name_lower in _USERAGENT_ALLOWED_OS_NAMES: |
| 480 | os_family = plt_name_lower |
| 481 | elif plt_name_lower in _USERAGENT_PLATFORM_NAME_MAPPINGS: |
| 482 | os_family = _USERAGENT_PLATFORM_NAME_MAPPINGS[plt_name_lower] |
| 483 | else: |
| 484 | os_family = None |
| 485 | |
| 486 | if os_family is not None: |
| 487 | return [ |
| 488 | UserAgentComponent('os', os_family, self._platform_version) |
| 489 | ] |
| 490 | else: |
| 491 | return [ |
| 492 | UserAgentComponent('os', 'other'), |
| 493 | UserAgentComponent( |
| 494 | 'md', self._platform_name, self._platform_version |
| 495 | ), |
| 496 | ] |
| 497 | |
| 498 | def _build_architecture_metadata(self): |
| 499 | """ |
no test coverage detected