Coverage for d7a/system_files/access_profile.py: 79%
19 statements
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-24 08:03 +0200
« prev ^ index » next coverage.py v7.5.0, created at 2024-05-24 08:03 +0200
1#
2# Copyright (c) 2015-2021 University of Antwerp, Aloxy NV.
3#
4# This file is part of pyd7a.
5# See https://github.com/Sub-IoT/pyd7a for further info.
6#
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19from d7a.dll.access_profile import AccessProfile
20from d7a.support.schema import Validatable, Types
21from d7a.system_files.file import File
22from d7a.system_files.system_file_ids import SystemFileIds
25class AccessProfileFile(File, Validatable):
26 SCHEMA = [{
27 "access_specifier": Types.INTEGER(min=0, max=14),
28 "access_profile": Types.OBJECT(AccessProfile, nullable=True)
29 }]
31 def __init__(self, access_specifier=0, access_profile=None):
32 self.access_specifier = access_specifier
33 self.access_profile = access_profile
34 Validatable.__init__(self)
35 File.__init__(self, SystemFileIds.ACCESS_PROFILE_0.value + access_specifier, 65)
37 def __iter__(self):
38 for byte in self.access_profile:
39 yield byte
41 @staticmethod
42 def parse(s, offset=0, length=65):
43 return AccessProfileFile(access_specifier=0, access_profile=AccessProfile.parse(s)) # TODO access_specifier?
45 def __str__(self):
46 return "active_specifier={}, access_profile={}".format(self.access_specifier, self.access_profile)