# Path: pyipmi/fru.py
# class FruData(object):
#     def __init__(self, data=None):
#         if data:
#             if isinstance(data, str):
#                 data = [ord(c) for c in data]
#             self.data = data
#             if hasattr(self, '_from_data'):
#                 self._from_data(data)
# 
# class FruPicmgPowerModuleCapabilityRecord(FruPicmgRecord):
#     def _from_data(self, data):
#         if len(data) < 12:
#             raise DecodingError('data too short')
#         FruPicmgRecord._from_data(self, data)
#         maximum_current_output = data[10] | data[11] << 8
#         self.maximum_current_output = float(maximum_current_output/10)
# 
# class InventoryCommonHeader(FruData):
#     def _from_data(self, data):
#         if len(data) != 8:
#             raise DecodingError('InventoryCommonHeader length != 8')
#         self.format_version = data[0] & 0x0f
#         self.internal_use_area_offset = data[1] * 8 or None
#         self.chassis_info_area_offset = data[2] * 8 or None
#         self.board_info_area_offset = data[3] * 8 or None
#         self.product_info_area_offset = data[4] * 8 or None
#         self.multirecord_area_offset = data[5] * 8 or None
#         if sum(data) % 256 != 0:
#             raise DecodingError('InventoryCommonHeader checksum failed')
# 
# def get_fru_inventory_from_file(filename):
#     try:
#         file = open(filename, "rb")
#     except IOError:
#         print('Error open file "%s"' % filename)
# 
#     ################################
#     # get file size
#     file_size = os.stat(filename).st_size
#     file_data = file.read(file_size)
#     data = array.array('B', file_data)
#     file.close()
#     return FruInventory(data)


import os
import nose
from nose.tools import eq_, ok_
from pyipmi.fru import (FruData, FruPicmgPowerModuleCapabilityRecord,
                        InventoryCommonHeader, get_fru_inventory_from_file)
#!/usr/bin/env python
# -*- coding: utf-8 -*-




def test_frudata_object():
    fru_field = FruData((0, 1, 2, 3))
    eq_(fru_field.data[0], 0)
    eq_(fru_field.data[1], 1)
    eq_(fru_field.data[2], 2)
    eq_(fru_field.data[3], 3)


# Path: pyipmi/fru.py
# class FruData(object):
#     def __init__(self, data=None):
#         if data:
#             if isinstance(data, str):
#                 data = [ord(c) for c in data]
#             self.data = data
#             if hasattr(self, '_from_data'):
#                 self._from_data(data)
# 
# class FruPicmgPowerModuleCapabilityRecord(FruPicmgRecord):
#     def _from_data(self, data):
#         if len(data) < 12:
#             raise DecodingError('data too short')
#         FruPicmgRecord._from_data(self, data)
#         maximum_current_output = data[10] | data[11] << 8
#         self.maximum_current_output = float(maximum_current_output/10)
# 
# class InventoryCommonHeader(FruData):
#     def _from_data(self, data):
#         if len(data) != 8:
#             raise DecodingError('InventoryCommonHeader length != 8')
#         self.format_version = data[0] & 0x0f
#         self.internal_use_area_offset = data[1] * 8 or None
#         self.chassis_info_area_offset = data[2] * 8 or None
#         self.board_info_area_offset = data[3] * 8 or None
#         self.product_info_area_offset = data[4] * 8 or None
#         self.multirecord_area_offset = data[5] * 8 or None
#         if sum(data) % 256 != 0:
#             raise DecodingError('InventoryCommonHeader checksum failed')
# 
# def get_fru_inventory_from_file(filename):
#     try:
#         file = open(filename, "rb")
#     except IOError:
#         print('Error open file "%s"' % filename)
# 
#     ################################
#     # get file size
#     file_size = os.stat(filename).st_size
#     file_data = file.read(file_size)
#     data = array.array('B', file_data)
#     file.close()
#     return FruInventory(data)


# Path: tests/test_fru.py
import os
import nose
from nose.tools import eq_, ok_
from pyipmi.fru import (FruData, FruPicmgPowerModuleCapabilityRecord,
                        InventoryCommonHeader, get_fru_inventory_from_file)

#!/usr/bin/env python
# -*- coding: utf-8 -*-




def test_frudata_object():
    fru_field = FruData((0, 1, 2, 3))
    eq_(fru_field.data[0], 0)
    eq_(fru_field.data[1], 1)
    eq_(fru_field.data[2], 2)
    eq_(fru_field.data[3], 3)


    fru_field = FruData('\x00\x01\x02\x03')