def main(): i = Enum(enum_dict) assert i.A == 1 assert i.B == 2 assert i.C == 3 assert i[1] == 'A' assert i[2] == 'B' assert i[3] == 'C' assert i[4] == ''
def test_main(self): i = Enum(enum_dict) self.assertEqual(i.A, 1) self.assertEqual(i.B, 2) self.assertEqual(i.C, 3) self.assertEqual(i[1], 'A') self.assertEqual(i[2], 'B') self.assertEqual(i[3], 'C') self.assertEqual(i[4], '') a = Enum(A=1, B=2, C=3) self.assertEqual(a.A, 1) self.assertEqual(a.B, 2) self.assertEqual(a.C, 3) self.assertEqual(a[1], 'A') self.assertEqual(a[2], 'B') self.assertEqual(a[3], 'C') self.assertEqual(a[4], '') self.assertEqual(smc.WRITE_BUFFER.value, 0x3b) self.assertEqual(smc.WRITE_BUFFER.name, 'WRITE_BUFFER')
def main(): i = Enum(enum_dict) assert i.A == 1 assert i.B == 2 assert i.C == 3 assert i[1] == 'A' assert i[2] == 'B' assert i[3] == 'C' assert i[4] == '' a = Enum(A=1, B=2, C=3) assert a.A == 1 assert a.B == 2 assert a.C == 3 assert a[1] == 'A' assert a[2] == 'B' assert a[3] == 'C' assert a[4] == '' assert smc.WRITE_BUFFER.value == 0x3b assert smc.WRITE_BUFFER.name == 'WRITE_BUFFER'
def __init__(self, name, code, serviceaction): """ initialize a new instance :param name: a string representing the name of the operation code :param code: a hexadecimal value representing the value associated with the operation code :param serviceaction: a Enum with service actions supported by the command associtaed with the operation code """ self._name = name self._code = code self._serviceaction = Enum(serviceaction)
'GOOD': 0x00, 'CHECK_CONDITION': 0x02, 'CONDITIONS_MET': 0x04, 'BUSY': 0x08, 'RESERVATION_CONFLICT': 0x18, 'TASK_SET_FULL': 0x28, 'ACA_ACTIVE': 0x30, 'TASK_ABORTED': 0x40, 'SGIO_ERROR': 0xff, } #------------------------------------------------------------------------------ # Instantiate the Enum Objects #------------------------------------------------------------------------------ SCSI_STATUS = Enum(scsi_status) spc = Enum(spc_opcodes) sbc = Enum(sbc_opcodes) ssc = Enum(ssc_opcodes) smc = Enum(smc_opcodes) mmc = Enum(mmc_opcodes) #------------------------------------------------------------------------------ # Obsolete Dictionaries and Enums #------------------------------------------------------------------------------ opcodes = { 'INQUIRY': 0x12, 'MODE_SENSE_6': 0x1a, 'MOVE_MEDIUM': 0xa5,
# coding: utf-8 from pyscsi.utils.enum import Enum # # P_STATUS # _p_status = { 'MAPPED': 0x00, 'DEALLOCATED': 0x01, 'ANCHORED': 0x02, } P_STATUS = Enum(_p_status)
# This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. __all__ = [ 'ELEMENT_TYPE', ] from pyscsi.utils.enum import Enum # # Element Type Code # _element_type = { 'ALL': 0x00, 'MEDIUM_TRANSPORT': 0x01, 'STORAGE': 0x02, 'IMPORT_EXPORT': 0x03, 'DATA_TRANSFER': 0x04, } ELEMENT_TYPE = Enum(_element_type)
'CODE_SET', 'ASSOCIATION', 'DESIGNATOR', 'NAA', 'VPD', ] # # Provisioning type # _provisioning_type = { 'NO_PROVISIONING_REPORTED': 0x00, 'RESOURCE_PROVISIONED': 0x01, 'THIN_PROVISIONED': 0x02, } PROVISIONING_TYPE = Enum(_provisioning_type) # # Device qualifier # _qualifiers = { 'CONNECTED': 0x00, 'NOT_CONNECTED': 0x01, 'NOT_CAPABLE': 0x03, } QUALIFIER = Enum(_qualifiers) # # Device type #
# coding: utf-8 # Copyright (C) 2014 by Ronnie Sahlberg<*****@*****.**> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program; if not, see <http://www.gnu.org/licenses/>. from pyscsi.utils.enum import Enum # # P_TYPE # _p_types = {'TYPE_1_PROTECTION': 0x00, 'TYPE_2_PROTECTION': 0x01, 'TYPE_3_PROTECTION': 0x02, } P_TYPE = Enum(_p_types)
def __init__(self, name, code, serviceaction): self._name = name self._code = code self._serviceaction = Enum(serviceaction)
#------------------------------------------------------------------------------ # Page Control #------------------------------------------------------------------------------ pc = { 'CURRENT': 0x00, 'CHANGEABLE': 0x01, 'DEFAULT': 0x02, 'SAVED': 0x03, } #------------------------------------------------------------------------------ # Page Codes #------------------------------------------------------------------------------ page_code = { 'DISCONNECT_RECONNECT': 0x02, 'CONTROL': 0x0a, 'ELEMENT_ADDRESS_ASSIGNMENT': 0x1d, } #------------------------------------------------------------------------------ # Instantiate the Enum Objects #------------------------------------------------------------------------------ PC = Enum(pc) PAGE_CODE = Enum(page_code) MODESENSE6 = Enum(modepage6bits) MODESENSE10 = Enum(modepage10bits)
#------------------------------------------------------------------------------ # Page Control #------------------------------------------------------------------------------ pc = { 'CURRENT': 0x00, 'CHANGEABLE': 0x01, 'DEFAULT': 0x02, 'SAVED': 0x03, } #------------------------------------------------------------------------------ # Page Codes #------------------------------------------------------------------------------ page_code = { 'DISCONNECT_RECONNECT': 0x02, 'CONTROL': 0x0a, 'ELEMENT_ADDRESS_ASSIGNMENT': 0x1d, } #------------------------------------------------------------------------------ # Instantiate the Enum Objects #------------------------------------------------------------------------------ PC = Enum(pc) PAGE_CODE = Enum(page_code) MODESENSE6 = Enum(modepagebits) MODESELECT6 = Enum(modeselectbits)
#------------------------------------------------------------------------------ # Page Control #------------------------------------------------------------------------------ pc = { 'CURRENT': 0x00, 'CHANGEABLE': 0x01, 'DEFAULT': 0x02, 'SAVED': 0x03, } #------------------------------------------------------------------------------ # Page Codes #------------------------------------------------------------------------------ page_code = { 'DISCONNECT_RECONNECT': 0x02, 'CONTROL': 0x0a, 'ELEMENT_ADDRESS_ASSIGNMENT': 0x1d, } #------------------------------------------------------------------------------ # Instantiate the Enum Objects #------------------------------------------------------------------------------ PC = Enum(pc) PAGE_CODE = Enum(page_code) MODESENSE6 = Enum(modepage6bits) MODESELECT6 = Enum(modeselect6bits) MODESENSE10 = Enum(modepage10bits) MODESELECT10 = Enum(modeselect10bits)