Package platformids ::
Package custom ::
Module pentoo
1
2 """Example for a dynamic added custom platform.
3
4 Here *Pentoo* Linux, which has the same encoding as *Gentoo*.
5
6 """
7 from __future__ import absolute_import
8
9 from platformids import RTE, rte2num, num2rte, num2pretty, custom_rte_distrel2tuple, custom_dist, \
10 PlatformIDsUnknownError, \
11 RTE_LINUX, RTE_OSTYPE, RTE_DIST
12
13
14 __author__ = 'Arno-Can Uestuensoez'
15 __license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
16 __copyright__ = "Copyright (C) 2019 Arno-Can Uestuensoez" \
17 " @Ingenieurbuero Arno-Can Uestuensoez"
18 __version__ = '0.0.1'
19 __uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"
20
21
22 RTE_PENTOO = RTE_LINUX + custom_dist.add_enum()
23
24
25
26 rte2num.update(
27 {
28 'pentoo': RTE_PENTOO,
29 RTE_PENTOO: RTE_PENTOO,
30 }
31 )
32
33
34
35 num2rte.update(
36 {
37 RTE_PENTOO: 'pentoo',
38 }
39 )
40
41
42 num2pretty.update(
43 {
44 RTE_PENTOO: 'Pentoo',
45 }
46 )
47
48
49
50
51
52
53
54
55
56 RTE_PENTOO20180 = RTE_PENTOO + 0x00006000
57 RTE_PENTOO20190 = RTE_PENTOO + 0x00006200
58
59
60
61 rte2num.update(
62 {
63 'pentoo20180': RTE_PENTOO20180,
64 'pentoo20190': RTE_PENTOO20190,
65 RTE_PENTOO20180: RTE_PENTOO20180,
66 RTE_PENTOO20190: RTE_PENTOO20190,
67 }
68 )
69
70
71
72 num2rte.update(
73 {
74 RTE_PENTOO20180: 'pentoo20180',
75 RTE_PENTOO20190: 'pentoo20190',
76 }
77 )
78
79
80 num2pretty.update(
81 {
82 RTE_PENTOO20180: 'Pentoo-2018.0',
83 RTE_PENTOO20190: 'Pentoo-2019.0',
84 }
85 )
86
87
88
90 """
91 A custom example only.
92
93 Requires the same encoding as Gentoo - so currently some
94 work to do in order to detect the version of the versionless...
95
96 Convert the *Pentoo* specific *distrel* version layout
97 to a tuple.
98
99 A callback to be used by the function:
100
101 platformids.decode_rte_distrel_to_segments(rte=RTE)
102
103 Decodes the compressed *distrel* from the 32bit integer
104 bitmask *rte* into the corresponding tuple of integer
105 segments.
106
107 Args:
108 rte:
109 The comppressed runtime environment identifier bitmask.
110
111 default := RTE
112
113 Returns:
114 Tuple of Integer values of the encoded segments, either
115 as defined by the default layout, or any known as defined
116 by additional extended and/or custom criteria.
117
118 Raises:
119 pass-through
120
121 Examples:
122 ::
123
124 decode_rte_distrel_to_segments()
125 => (2018, 0, 0) # on PENTOO-2018.0
126 => (2019, 0, 0) # on PENTOO-2019.0
127
128 """
129 if rte & RTE_DIST != RTE_PENTOO:
130 raise PlatformIDsUnknownError("Not Gentoo: rte = " + str(rte))
131
132 try:
133
134 _rte = rte2num[rte]
135 except KeyError:
136
137
138 if type(rte) is int:
139
140 _rte = rte
141
142 else:
143 raise PlatformIDsUnknownError("Unknown Gentoo release rte = " + str(rte))
144
145
146 return (
147 ((_rte & 0xfe00) >> 9) + 1970,
148 ((_rte & 0x01e0) >> 5),
149 _rte & 0x001f,
150 )
151
152
153 custom_rte_distrel2tuple.update(
154 {
155
156
157 RTE_PENTOO: my_distrel2tuple,
158 }
159 )
160