CSIT-1110: Use jumpavg library from pip
[csit.git] / PyPI / jumpavg / jumpavg / ClassifiedMetadataFactory.py
1 # Copyright (c) 2018 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 """Module holding ClassifiedBitCountingMetadata class."""
15
16 from ClassifiedBitCountingMetadata import ClassifiedBitCountingMetadata
17
18
19 class ClassifiedMetadataFactory(object):
20     """Class for factory which adds classification to bit counting metadata."""
21
22     @staticmethod
23     def with_classification(metadata, classification):
24         """Return new metadata object with added classification.
25
26         TODO: Is there a way to add classification to any metadata,
27         without messing up constructors and __repr__()?
28
29         FIXME: Factories take raw resources. Find a name for the thing
30         which takes semi-finished products. Transformer?
31
32         :param metadata: Existing metadata without classification.
33         :param classification: Arbitrary object classifying this group.
34         :type metadata: BitCountingMetadata
35         :type classification: object
36         :returns: The metadata with added classification.
37         :rtype: ClassifiedBitCountingMetadata
38         """
39         return ClassifiedBitCountingMetadata(
40             max_value=metadata.max_value, size=metadata.size, avg=metadata.avg,
41             stdev=metadata.stdev, prev_avg=metadata.prev_avg,
42             classification=classification)