convert.py (9827:f47274776aa0) convert.py (10427:26fee6c20087)
1# Copyright (c) 2005 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 297 unchanged lines hidden (view full) ---

306
307 if value.endswith('mV'):
308 return float(value[:-2]) * milli
309 elif value.endswith('V'):
310 return float(value[:-1])
311
312 raise ValueError, "cannot convert '%s' to voltage" % value
313
1# Copyright (c) 2005 The Regents of The University of Michigan
2# Copyright (c) 2010 Advanced Micro Devices, Inc.
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions are
7# met: redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer;

--- 297 unchanged lines hidden (view full) ---

306
307 if value.endswith('mV'):
308 return float(value[:-2]) * milli
309 elif value.endswith('V'):
310 return float(value[:-1])
311
312 raise ValueError, "cannot convert '%s' to voltage" % value
313
314def toCurrent(value):
315 if not isinstance(value, str):
316 raise TypeError, "wrong type '%s' should be str" % type(value)
317
318 if value.endswith('A'):
319 return toFloat(value[:-1])
320
321 raise ValueError, "cannot convert '%s' to current" % value