Skip to content

Commit

Permalink
Use report data builder via function
Browse files Browse the repository at this point in the history
  • Loading branch information
konraddysput committed Sep 27, 2024
1 parent 722e645 commit 00523be
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 23 deletions.
4 changes: 2 additions & 2 deletions backtracepython/attributes/attribute_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from .machine_attribute_provider import MachineAttributeProvider
from .machineId_attribute_provider import MachineIdAttributeProvider
from .process_attribute_provider import ProcessAttributeProvider
from .report_data_builder import ReportDataBuilder
from .report_data_builder import get_report_attributes
from .session_attribute_provider import SessionAttributeProvider
from .system_attribute_provider import SystemAttributeProvider
from .user_attribute_provider import UserAttributeProvider
Expand All @@ -24,7 +24,7 @@ def get(self):
for attribute_provider in self.attribute_providers:
try:
provider_attributes = attribute_provider.get()
generated_attributes, generated_annotations = ReportDataBuilder.get(
generated_attributes, generated_annotations = get_report_attributes(
provider_attributes
)
attributes.update(generated_attributes)
Expand Down
39 changes: 18 additions & 21 deletions backtracepython/attributes/report_data_builder.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import sys

# unicode is not available in Python3. However due to the Python2 support
# We need to use it to verify primitive values.
primitive_types = (
(int, float, bool, type(None), str)
if sys.version_info.major >= 3
else (int, float, bool, type(None), str, unicode)
)

class ReportDataBuilder:

# unicode is not available in Python3. However due to the Python2 support
# We need to use it to verify primitive values.
primitive_types = (
(int, float, bool, type(None), str)
if sys.version_info.major >= 3
else (int, float, bool, type(None), str, unicode)
)
def get_report_attributes(provider_attributes):
attributes = {}
annotations = {}

@staticmethod
def get(provider_attributes):
attributes = {}
annotations = {}
# Iterate through input_dict and split based on value types
for key, value in provider_attributes.items():
if isinstance(value, primitive_types):
attributes[key] = value
else:
annotations[key] = value

# Iterate through input_dict and split based on value types
for key, value in provider_attributes.items():
if isinstance(value, ReportDataBuilder.primitive_types):
attributes[key] = value
else:
annotations[key] = value

# Return both dictionaries
return attributes, annotations
# Return both dictionaries
return attributes, annotations

0 comments on commit 00523be

Please sign in to comment.