コード例 #1
0
 def test_version_to_semver_segments(self):
     """Check `version_to_semver_segments` implementation"""
     self.assertTupleEqual(Utility.version_to_semver_segments('v1.2.3'),
                           (1, 2, 3))
     self.assertTupleEqual(
         Utility.version_to_semver_segments('1.2.3.4-beta5'), (1, 2, 3, 4))
     self.assertTupleEqual(Utility.version_to_semver_segments('1'), (1, ))
コード例 #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        self.value = {
            'name': platform.system(),
            'release': platform.release(),
            'latest': None,
            'is_outdated': None
        }

        # On GNU/Linux systems, if `check_version` has been enabled and `DO_NOT_TRACK` isn't set,
        #  retrieve the latest kernel release in order to compare the current one against it.
        if not self.options.get('check_version') \
            or self.value['name'] != 'Linux' \
            or Environment.DO_NOT_TRACK:
            return

        self.value['latest'] = self._fetch_latest_linux_release()
        if self.value['latest']:
            self.value['is_outdated'] = (Utility.version_to_semver_segments(
                self.value['release']) < Utility.version_to_semver_segments(
                    self.value['latest']))
コード例 #3
0
ファイル: api.py プロジェクト: HorlogeSkynet/archey4
    def json_serialization(self, indent: int = 0) -> str:
        """
        JSON serialization of entries.
        Set `indent` to the number of wanted output indentation tabs (2-space long).
        """
        document = {
            'data': {entry.name: entry.value
                     for entry in self.entries},
            'meta': {
                'version': Utility.version_to_semver_segments(__version__),
                'date': datetime.now().isoformat(),
                'count': len(self.entries),
                'distro': Distributions.get_local().value,
            }
        }

        return json.dumps(document, indent=((indent * 2) or None))
コード例 #4
0
ファイル: api.py プロジェクト: pombredanne/archey4
    def json_serialization(self, indent: int = 0) -> str:
        """
        JSON serialization of entries.
        Set `indent` to the number of wanted output indentation tabs (2-space long).

        Note: For Python < 3.6, the keys order is not guaranteed.
        """
        document = {
            'data': {entry.name: entry.value
                     for entry in self.entries},
            'meta': {
                'version': Utility.version_to_semver_segments(__version__),
                'date': datetime.now().isoformat(),
                'count': len(self.entries)
            }
        }

        return json.dumps(document, indent=((indent * 2) or None))