Coverage for d7a/dll/sub_profile.py: 95%
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#
19import pprint
21from d7a.support.schema import Validatable, Types
22from d7a.types.ct import CT
25class SubProfile(Validatable):
27 SCHEMA = [{
28 "subband_bitmap": Types.BYTE(),
29 "scan_automation_period": Types.OBJECT(CT)
30 }]
32 def __init__(self, subband_bitmap=0, scan_automation_period=CT()):
33 self.subband_bitmap = subband_bitmap
34 self.scan_automation_period = scan_automation_period
35 super(SubProfile, self).__init__()
37 @staticmethod
38 def parse(s):
39 subband_bitmap = s.read("uint:8")
40 scan_automation_period = CT.parse(s)
41 return SubProfile(subband_bitmap=subband_bitmap, scan_automation_period=scan_automation_period)
43 def __iter__(self):
44 yield self.subband_bitmap
45 for byte in self.scan_automation_period: yield byte
47 def __str__(self):
48 return pprint.PrettyPrinter().pformat(self.as_dict())