diff -r 000000000000 -r 2e8eeb919028 configurationengine/source/plugins/symbian/ConeHCRPlugin/hcrplugin/tests/unittest_read_write_record.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/configurationengine/source/plugins/symbian/ConeHCRPlugin/hcrplugin/tests/unittest_read_write_record.py Thu Mar 11 17:04:37 2010 +0200 @@ -0,0 +1,308 @@ +# *-* coding: utf-8 *-* +# +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +# All rights reserved. +# This component and the accompanying materials are made available +# under the terms of "Eclipse Public License v1.0" +# which accompanies this distribution, and is available +# at the URL "http://www.eclipse.org/legal/epl-v10.html". +# +# Initial Contributors: +# Nokia Corporation - initial contribution. +# +# Contributors: +# +# Description: +# + +""" +When editing the hex data in the test cases, this may come in handy: + +1. Start the Python command line interpreter +2. Paste the following lines there: + +from struct import pack, unpack +bin2hex = lambda d: ''.join("%02X" % ord(c) for c in d) +hexpack = lambda fmt, *args: bin2hex(pack(fmt, *args)) +hex2bin = lambda h: ''.join([chr(int(h[i*2:i*2+2], 16)) for i in xrange(len(h)/2)]) +hexunpack = lambda fmt, data: unpack(fmt, hex2bin(data)) + +Now you can get the hex representation for any format supported by +struct.pack() easily. For example, formatting a little-endian unsigned short: + +>>> hexpack('>> hexunpack('