8.35. platformids.custom.pentoo

Module ParrotLinux [doc].

8.35.1. Module

Example for a dynamic added custom platform.

Here Pentoo Linux, which has the same encoding as Gentoo.

8.35.2. Data

8.35.2.1. RTE_PENTOO

Registration of the dist value:

RTE_PENTOO        = RTE_LINUX   + custom_dist.add_enum()

8.35.2.2. rte2num

Mapping of the rte string and numeric representation to the numeric value.

8.35.2.3. num2rte

Mapping of the rte numeric representation to the string value.

8.35.2.4. num2pretty

Mapping of the rte numeric representation to the pretty string value.

8.35.2.5. custom_rte_distrel2tuple

Registered callbacks for special handling of custom layout.

custom_rte_distrel2tuple.update(
    {
        RTE_PENTOO: my_distrel2tuple,  #: the callback to be registered
    }
)

8.35.3. Functions

8.35.3.1. my_distrel2tuple

platformids.custom.pentoo.my_distrel2tuple(rte=276917248)[source]

A custom example only.

Requires the same encoding as Gentoo - so currently some work to do in order to detect the version of the versionless…

Convert the Pentoo specific distrel version layout to a tuple.

A callback to be used by the function:

platformids.decode_rte_distrel_to_segments(rte=RTE)

Decodes the compressed distrel from the 32bit integer bitmask rte into the corresponding tuple of integer segments.

Args:
rte:

The comppressed runtime environment identifier bitmask.

default := RTE

Returns:

Tuple of Integer values of the encoded segments, either as defined by the default layout, or any known as defined by additional extended and/or custom criteria.

Raises

pass-through

Examples

decode_rte_distrel_to_segments()
=>  (2018, 0, 0)  # on PENTOO-2018.0
=>  (2019, 0, 0)  # on PENTOO-2019.0

8.35.4. Source

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# -*- coding: utf-8 -*-
"""Example for a dynamic added custom platform.

Here *Pentoo* Linux, which has the same encoding as *Gentoo*.

"""
from __future__ import absolute_import

from platformids import RTE, rte2num, num2rte, num2pretty, custom_rte_distrel2tuple, custom_dist, \
    PlatformIDsUnknownError, \
    RTE_LINUX, RTE_OSTYPE, RTE_DIST


__author__ = 'Arno-Can Uestuensoez'
__license__ = "Artistic-License-2.0 + Forced-Fairplay-Constraints"
__copyright__ = "Copyright (C) 2019 Arno-Can Uestuensoez" \
                " @Ingenieurbuero Arno-Can Uestuensoez"
__version__ = '0.0.1'
__uuid__ = "7add5ded-c39b-4b6e-8c87-1b3a1c150ee9"


RTE_PENTOO           = RTE_LINUX   + custom_dist.add_enum()     #: PENTOO

    
#: mapping of the rte string and numeric representation to the numeric value
rte2num.update(
    {
        'pentoo':               RTE_PENTOO,
        RTE_PENTOO:             RTE_PENTOO,
    }
)


#: mapping of the rte numeric representation to the string value
num2rte.update(
    {
        RTE_PENTOO:             'pentoo',
    }
)

#: mapping of the rte numeric representation to the string value
num2pretty.update(
    {
        RTE_PENTOO:             'Pentoo',
    }
)


#-----------------------------------------------#
#                                               #
# optional constants for convenience            #
#                                               #
#-----------------------------------------------#


RTE_PENTOO20180      = RTE_PENTOO  + 0x00006000                              #: PENTOO-2018.0 - offset 1970.1.1
RTE_PENTOO20190      = RTE_PENTOO  + 0x00006200                              #: PENTOO-2019.0 - offset 1970.1.1

    
#: mapping of the rte string and numeric representation to the numeric value
rte2num.update(
    {
        'pentoo20180':          RTE_PENTOO20180,
        'pentoo20190':          RTE_PENTOO20190,
        RTE_PENTOO20180:        RTE_PENTOO20180,
        RTE_PENTOO20190:        RTE_PENTOO20190,
    }
)


#: mapping of the rte numeric representation to the string value
num2rte.update(
    {
        RTE_PENTOO20180:        'pentoo20180',
        RTE_PENTOO20190:        'pentoo20190',
    }
)

#: mapping of the rte numeric representation to the string value
num2pretty.update(
    {
        RTE_PENTOO20180:        'Pentoo-2018.0',
        RTE_PENTOO20190:        'Pentoo-2019.0',
    }
)



def my_distrel2tuple(rte=RTE):
    """
    A custom example only.
    
    Requires the same encoding as Gentoo - so currently some
    work to do in order to detect the version of the versionless...

    Convert the *Pentoo* specific *distrel* version layout
    to a tuple.
    
    A callback to be used by the function:
    
       platformids.decode_rte_distrel_to_segments(rte=RTE)
    
    Decodes the compressed *distrel* from the 32bit integer
    bitmask *rte* into the corresponding tuple of integer
    segments.

    Args:
       rte:
           The comppressed runtime environment identifier bitmask.
            
           default := RTE

    Returns:
       Tuple of Integer values of the encoded segments, either
       as defined by the default layout, or any known as defined
       by additional extended and/or custom criteria.
    
   Raises:
       pass-through

   Examples:
     ::

        decode_rte_distrel_to_segments()     
        =>  (2018, 0, 0)  # on PENTOO-2018.0
        =>  (2019, 0, 0)  # on PENTOO-2019.0

    """
    if rte & RTE_DIST != RTE_PENTOO:
        raise PlatformIDsUnknownError("Not Gentoo:  rte = " + str(rte))
        
    try:
        # handle string input
        _rte = rte2num[rte]
    except KeyError:
        # non-registered release
        
        if type(rte) is int:
            # can split basically any number, let's see...
            _rte = rte

        else:
            raise PlatformIDsUnknownError("Unknown Gentoo release rte = " + str(rte))

    # represents the ArchLinux layout for rolling distro
    return (
        ((_rte & 0xfe00) >> 9) + 1970, 
        ((_rte & 0x01e0) >> 5), 
        _rte & 0x001f, 
        )

#: registered callbacks for special handling of custom layout
custom_rte_distrel2tuple.update(
    {
        # e.g. RTE_PENTOO: PENTOO.platformids.my_distrel2tuple,
        
        RTE_PENTOO: my_distrel2tuple,  #: the callback to be registered
    }
)

8.35.5. Download

custom pentoo.py