convert.py (7778:6a7207241112) | convert.py (9827:f47274776aa0) |
---|---|
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; --- 285 unchanged lines hidden (view full) --- 294 if not isinstance(value, str): 295 raise TypeError, "wrong type '%s' should be str" % type(value) 296 297 (ip, port) = value.split(':') 298 ip = toIpAddress(ip) 299 if not 0 <= int(port) <= 0xffff: 300 raise ValueError, 'invalid port %s' % port 301 return (ip, int(port)) | 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; --- 285 unchanged lines hidden (view full) --- 294 if not isinstance(value, str): 295 raise TypeError, "wrong type '%s' should be str" % type(value) 296 297 (ip, port) = value.split(':') 298 ip = toIpAddress(ip) 299 if not 0 <= int(port) <= 0xffff: 300 raise ValueError, 'invalid port %s' % port 301 return (ip, int(port)) |
302 303def toVoltage(value): 304 if not isinstance(value, str): 305 raise TypeError, "wrong type '%s' should be str" % type(value) 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 |
|