diff --git a/build/templates/__init__.py.mako b/build/templates/__init__.py.mako index a376b3d30..aa14cc9fe 100644 --- a/build/templates/__init__.py.mako +++ b/build/templates/__init__.py.mako @@ -10,7 +10,7 @@ module_name = config['module_name'] registry_name = config['driver_registry'] if 'driver_registry' in config else config['driver_name'] %> -__version__ = '${config['module_version']}' +__version__ = "${config['module_version']}" % if len(enums) > 0: from ${module_name}.enums import * # noqa: F403,F401,H303 @@ -59,12 +59,12 @@ from ${module_name}.${c['file_name']} import ${c['ctypes_type']} # noqa: F401 def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -72,73 +72,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\${registry_name}\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\${registry_name}\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "${config['driver_name']}" - info['driver']['version'] = driver_version - info['module']['name'] = '${module_name}' - info['module']['version'] = "${config['module_version']}" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "${config['driver_name']}" + info["driver"]["version"] = driver_version + info["module"]["name"] = "${module_name}" + info["module"]["version"] = "${config['module_version']}" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/build/templates/_attributes.py.mako b/build/templates/_attributes.py.mako index b37ebbcdd..9bcbfb264 100644 --- a/build/templates/_attributes.py.mako +++ b/build/templates/_attributes.py.mako @@ -10,14 +10,13 @@ import hightime class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -26,16 +25,19 @@ class AttributeViInt32(Attribute): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -44,7 +46,6 @@ class AttributeViInt64(Attribute): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -53,16 +54,19 @@ class AttributeViReal64(Attribute): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -71,16 +75,17 @@ class AttributeViString(Attribute): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -89,31 +94,36 @@ class AttributeViBoolean(Attribute): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from ${module_name}.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/build/templates/_converters.py.mako b/build/templates/_converters.py.mako index 5c63b2e63..4b53bb968 100644 --- a/build/templates/_converters.py.mako +++ b/build/templates/_converters.py.mako @@ -18,7 +18,7 @@ from functools import singledispatch @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -45,36 +45,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -90,7 +92,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -99,7 +101,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -108,16 +110,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -125,15 +133,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -149,8 +159,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -163,7 +173,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -200,34 +217,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -256,11 +275,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -272,14 +291,20 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] <% # Beginning of module-specific converters %>\ @@ -287,14 +312,16 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): # nitclk is different. Only nitclk needs to be able to convert sessions like this %>\ % if config['module_name'] == 'nitclk': + + # nitclk specific converters def convert_to_nitclk_session_number(item): - '''Convert from supported objects to NI-TClk Session Num + """Convert from supported objects to NI-TClk Session Num Supported objects are: - class with .tclk object of type nitclk.SessionReference - nitclk.SessionReference - ''' + """ try: return item.tclk._get_tclk_session_reference() except AttributeError: @@ -305,22 +332,20 @@ def convert_to_nitclk_session_number(item): except AttributeError: pass - raise TypeError('Unsupported type for nitclk session: {}'.format(type(item))) + raise TypeError("Unsupported type for nitclk session: {}".format(type(item))) def convert_to_nitclk_session_number_list(item_list): - '''Converts a list of items to nitclk session nums''' + """Converts a list of items to nitclk session nums""" return [convert_to_nitclk_session_number(i) for i in item_list] - - % endif <% # This converter is only needed for nifake testing %>\ % if config['module_name'] == 'nifake': + + # nifake specific converter(s) - used only for testing def convert_double_each_element(numbers): return [x * 2 for x in numbers] - - % endif diff --git a/generated/nidcpower/nidcpower/__init__.py b/generated/nidcpower/nidcpower/__init__.py index b4c976047..6204442ad 100644 --- a/generated/nidcpower/nidcpower/__init__.py +++ b/generated/nidcpower/nidcpower/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from nidcpower.enums import * # noqa: F403,F401,H303 from nidcpower.errors import DriverWarning # noqa: F401 @@ -11,12 +11,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -24,73 +24,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-DCPower\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-DCPower\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-DCPower" - info['driver']['version'] = driver_version - info['module']['name'] = 'nidcpower' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-DCPower" + info["driver"]["version"] = driver_version + info["module"]["name"] = "nidcpower" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/nidcpower/nidcpower/_attributes.py b/generated/nidcpower/nidcpower/_attributes.py index 1ca78bd23..f7cb3fcda 100644 --- a/generated/nidcpower/nidcpower/_attributes.py +++ b/generated/nidcpower/nidcpower/_attributes.py @@ -6,14 +6,13 @@ class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -22,16 +21,19 @@ def __set__(self, session, value): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -40,7 +42,6 @@ def __set__(self, session, value): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -49,16 +50,19 @@ def __set__(self, session, value): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -67,16 +71,17 @@ def __set__(self, session, value): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -85,31 +90,36 @@ def __set__(self, session, value): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from nidcpower.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/generated/nidcpower/nidcpower/_converters.py b/generated/nidcpower/nidcpower/_converters.py index 3da843692..f4c70b5c3 100644 --- a/generated/nidcpower/nidcpower/_converters.py +++ b/generated/nidcpower/nidcpower/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,11 +286,17 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] diff --git a/generated/nidigital/nidigital/__init__.py b/generated/nidigital/nidigital/__init__.py index 815b17ddc..b7576a221 100644 --- a/generated/nidigital/nidigital/__init__.py +++ b/generated/nidigital/nidigital/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from nidigital.enums import * # noqa: F403,F401,H303 from nidigital.errors import DriverWarning # noqa: F401 @@ -13,12 +13,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -26,73 +26,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-Digital Pattern Driver\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-Digital Pattern Driver\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-Digital Pattern Driver" - info['driver']['version'] = driver_version - info['module']['name'] = 'nidigital' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-Digital Pattern Driver" + info["driver"]["version"] = driver_version + info["module"]["name"] = "nidigital" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/nidigital/nidigital/_attributes.py b/generated/nidigital/nidigital/_attributes.py index 277b4b001..5a20ca61f 100644 --- a/generated/nidigital/nidigital/_attributes.py +++ b/generated/nidigital/nidigital/_attributes.py @@ -6,14 +6,13 @@ class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -22,16 +21,19 @@ def __set__(self, session, value): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -40,7 +42,6 @@ def __set__(self, session, value): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -49,16 +50,19 @@ def __set__(self, session, value): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -67,16 +71,17 @@ def __set__(self, session, value): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -85,31 +90,36 @@ def __set__(self, session, value): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from nidigital.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/generated/nidigital/nidigital/_converters.py b/generated/nidigital/nidigital/_converters.py index b36b311d8..a6c2c8434 100644 --- a/generated/nidigital/nidigital/_converters.py +++ b/generated/nidigital/nidigital/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,11 +286,17 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] diff --git a/generated/nidmm/nidmm/__init__.py b/generated/nidmm/nidmm/__init__.py index 6df35e03c..33492769b 100644 --- a/generated/nidmm/nidmm/__init__.py +++ b/generated/nidmm/nidmm/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from nidmm.enums import * # noqa: F403,F401,H303 from nidmm.errors import DriverWarning # noqa: F401 @@ -11,12 +11,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -24,73 +24,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-DMM\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-DMM\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-DMM" - info['driver']['version'] = driver_version - info['module']['name'] = 'nidmm' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-DMM" + info["driver"]["version"] = driver_version + info["module"]["name"] = "nidmm" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/nidmm/nidmm/_attributes.py b/generated/nidmm/nidmm/_attributes.py index c4df48ab4..c282889a3 100644 --- a/generated/nidmm/nidmm/_attributes.py +++ b/generated/nidmm/nidmm/_attributes.py @@ -6,14 +6,13 @@ class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -22,16 +21,19 @@ def __set__(self, session, value): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -40,7 +42,6 @@ def __set__(self, session, value): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -49,16 +50,19 @@ def __set__(self, session, value): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -67,16 +71,17 @@ def __set__(self, session, value): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -85,31 +90,36 @@ def __set__(self, session, value): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from nidmm.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/generated/nidmm/nidmm/_converters.py b/generated/nidmm/nidmm/_converters.py index 5248b0b4b..a9c4436af 100644 --- a/generated/nidmm/nidmm/_converters.py +++ b/generated/nidmm/nidmm/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,11 +286,17 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] diff --git a/generated/nifake/nifake/__init__.py b/generated/nifake/nifake/__init__.py index ae0e67e8e..646bbfef1 100644 --- a/generated/nifake/nifake/__init__.py +++ b/generated/nifake/nifake/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from nifake.enums import * # noqa: F403,F401,H303 from nifake.errors import DriverWarning # noqa: F401 @@ -15,12 +15,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -28,73 +28,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-FAKE\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-FAKE\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-FAKE" - info['driver']['version'] = driver_version - info['module']['name'] = 'nifake' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-FAKE" + info["driver"]["version"] = driver_version + info["module"]["name"] = "nifake" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/nifake/nifake/_attributes.py b/generated/nifake/nifake/_attributes.py index 1b8c55874..00744f460 100644 --- a/generated/nifake/nifake/_attributes.py +++ b/generated/nifake/nifake/_attributes.py @@ -6,14 +6,13 @@ class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -22,16 +21,19 @@ def __set__(self, session, value): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -40,7 +42,6 @@ def __set__(self, session, value): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -49,16 +50,19 @@ def __set__(self, session, value): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -67,16 +71,17 @@ def __set__(self, session, value): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -85,31 +90,36 @@ def __set__(self, session, value): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from nifake.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/generated/nifake/nifake/_converters.py b/generated/nifake/nifake/_converters.py index 608ae5753..8b81598c1 100644 --- a/generated/nifake/nifake/_converters.py +++ b/generated/nifake/nifake/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,16 +286,22 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] # nifake specific converter(s) - used only for testing def convert_double_each_element(numbers): return [x * 2 for x in numbers] - - diff --git a/generated/nifgen/nifgen/__init__.py b/generated/nifgen/nifgen/__init__.py index 072fbdf5b..061ff0f45 100644 --- a/generated/nifgen/nifgen/__init__.py +++ b/generated/nifgen/nifgen/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from nifgen.enums import * # noqa: F403,F401,H303 from nifgen.errors import DriverWarning # noqa: F401 @@ -11,12 +11,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -24,73 +24,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-FGEN\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-FGEN\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-FGEN" - info['driver']['version'] = driver_version - info['module']['name'] = 'nifgen' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-FGEN" + info["driver"]["version"] = driver_version + info["module"]["name"] = "nifgen" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/nifgen/nifgen/_attributes.py b/generated/nifgen/nifgen/_attributes.py index 13fb143f1..acb2517c0 100644 --- a/generated/nifgen/nifgen/_attributes.py +++ b/generated/nifgen/nifgen/_attributes.py @@ -6,14 +6,13 @@ class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -22,16 +21,19 @@ def __set__(self, session, value): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -40,7 +42,6 @@ def __set__(self, session, value): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -49,16 +50,19 @@ def __set__(self, session, value): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -67,16 +71,17 @@ def __set__(self, session, value): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -85,31 +90,36 @@ def __set__(self, session, value): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from nifgen.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/generated/nifgen/nifgen/_converters.py b/generated/nifgen/nifgen/_converters.py index a20b22b28..77a87d2cd 100644 --- a/generated/nifgen/nifgen/_converters.py +++ b/generated/nifgen/nifgen/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,11 +286,17 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] diff --git a/generated/nimodinst/nimodinst/__init__.py b/generated/nimodinst/nimodinst/__init__.py index 2419dd9ac..649a9858b 100644 --- a/generated/nimodinst/nimodinst/__init__.py +++ b/generated/nimodinst/nimodinst/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from nimodinst.errors import DriverWarning # noqa: F401 from nimodinst.errors import Error # noqa: F401 @@ -10,12 +10,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -23,73 +23,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-ModInst\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-ModInst\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-ModInst" - info['driver']['version'] = driver_version - info['module']['name'] = 'nimodinst' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-ModInst" + info["driver"]["version"] = driver_version + info["module"]["name"] = "nimodinst" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/nimodinst/nimodinst/_converters.py b/generated/nimodinst/nimodinst/_converters.py index 8851ba799..f58b2d776 100644 --- a/generated/nimodinst/nimodinst/_converters.py +++ b/generated/nimodinst/nimodinst/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,11 +286,17 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] diff --git a/generated/niscope/niscope/__init__.py b/generated/niscope/niscope/__init__.py index cb3b1a12e..bcc8677f0 100644 --- a/generated/niscope/niscope/__init__.py +++ b/generated/niscope/niscope/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from niscope.enums import * # noqa: F403,F401,H303 from niscope.errors import DriverWarning # noqa: F401 @@ -17,12 +17,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -30,73 +30,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-SCOPE\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-SCOPE\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-SCOPE" - info['driver']['version'] = driver_version - info['module']['name'] = 'niscope' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-SCOPE" + info["driver"]["version"] = driver_version + info["module"]["name"] = "niscope" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/niscope/niscope/_attributes.py b/generated/niscope/niscope/_attributes.py index 4647d930d..d1522c6ef 100644 --- a/generated/niscope/niscope/_attributes.py +++ b/generated/niscope/niscope/_attributes.py @@ -6,14 +6,13 @@ class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -22,16 +21,19 @@ def __set__(self, session, value): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -40,7 +42,6 @@ def __set__(self, session, value): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -49,16 +50,19 @@ def __set__(self, session, value): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -67,16 +71,17 @@ def __set__(self, session, value): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -85,31 +90,36 @@ def __set__(self, session, value): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from niscope.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/generated/niscope/niscope/_converters.py b/generated/niscope/niscope/_converters.py index 223d8e26b..8839d84e2 100644 --- a/generated/niscope/niscope/_converters.py +++ b/generated/niscope/niscope/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,11 +286,17 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] diff --git a/generated/nise/nise/__init__.py b/generated/nise/nise/__init__.py index 982f424d6..02110c498 100644 --- a/generated/nise/nise/__init__.py +++ b/generated/nise/nise/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from nise.enums import * # noqa: F403,F401,H303 from nise.errors import DriverWarning # noqa: F401 @@ -11,12 +11,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -24,73 +24,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\Switch Executive\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\Switch Executive\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI Switch Executive" - info['driver']['version'] = driver_version - info['module']['name'] = 'nise' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI Switch Executive" + info["driver"]["version"] = driver_version + info["module"]["name"] = "nise" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/nise/nise/_converters.py b/generated/nise/nise/_converters.py index 63de67487..577411557 100644 --- a/generated/nise/nise/_converters.py +++ b/generated/nise/nise/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,11 +286,17 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] diff --git a/generated/niswitch/niswitch/__init__.py b/generated/niswitch/niswitch/__init__.py index a3318b471..200a683a6 100644 --- a/generated/niswitch/niswitch/__init__.py +++ b/generated/niswitch/niswitch/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from niswitch.enums import * # noqa: F403,F401,H303 from niswitch.errors import DriverWarning # noqa: F401 @@ -11,12 +11,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -24,73 +24,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-SWITCH\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-SWITCH\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-SWITCH" - info['driver']['version'] = driver_version - info['module']['name'] = 'niswitch' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-SWITCH" + info["driver"]["version"] = driver_version + info["module"]["name"] = "niswitch" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/niswitch/niswitch/_attributes.py b/generated/niswitch/niswitch/_attributes.py index ea564a33e..c003081d8 100644 --- a/generated/niswitch/niswitch/_attributes.py +++ b/generated/niswitch/niswitch/_attributes.py @@ -6,14 +6,13 @@ class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -22,16 +21,19 @@ def __set__(self, session, value): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -40,7 +42,6 @@ def __set__(self, session, value): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -49,16 +50,19 @@ def __set__(self, session, value): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -67,16 +71,17 @@ def __set__(self, session, value): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -85,31 +90,36 @@ def __set__(self, session, value): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from niswitch.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/generated/niswitch/niswitch/_converters.py b/generated/niswitch/niswitch/_converters.py index 02af41b77..a336125ed 100644 --- a/generated/niswitch/niswitch/_converters.py +++ b/generated/niswitch/niswitch/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,11 +286,17 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] - - + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] diff --git a/generated/nitclk/nitclk/__init__.py b/generated/nitclk/nitclk/__init__.py index f17a5e9c1..fbf2200ef 100644 --- a/generated/nitclk/nitclk/__init__.py +++ b/generated/nitclk/nitclk/__init__.py @@ -2,7 +2,7 @@ # This file was generated -__version__ = '1.4.2.dev0' +__version__ = "1.4.2.dev0" from nitclk.errors import DriverWarning # noqa: F401 from nitclk.errors import Error # noqa: F401 @@ -20,12 +20,12 @@ def get_diagnostic_information(): - '''Get diagnostic information about the system state that is suitable for printing or logging + """Get diagnostic information about the system state that is suitable for printing or logging returns: dict note: Python bitness may be incorrect when running in a virtual environment - ''' + """ import os import pkg_resources import platform @@ -33,73 +33,80 @@ def get_diagnostic_information(): import sys def is_python_64bit(): - return (struct.calcsize("P") == 8) + return struct.calcsize("P") == 8 def is_os_64bit(): - return platform.machine().endswith('64') + return platform.machine().endswith("64") def is_venv(): - return 'VIRTUAL_ENV' in os.environ + return "VIRTUAL_ENV" in os.environ info = {} - info['os'] = {} - info['python'] = {} - info['driver'] = {} - info['module'] = {} - if platform.system() == 'Windows': + info["os"] = {} + info["python"] = {} + info["driver"] = {} + info["module"] = {} + if platform.system() == "Windows": try: import winreg as winreg except ImportError: import _winreg as winreg - os_name = 'Windows' + os_name = "Windows" try: - driver_version_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\National Instruments\NI-TClk\CurrentVersion") + driver_version_key = winreg.OpenKey( + winreg.HKEY_LOCAL_MACHINE, + r"SOFTWARE\National Instruments\NI-TClk\CurrentVersion", + ) driver_version = winreg.QueryValueEx(driver_version_key, "Version")[0] except WindowsError: - driver_version = 'Unknown' - elif platform.system() == 'Linux': - os_name = 'Linux' - driver_version = 'Unknown' + driver_version = "Unknown" + elif platform.system() == "Linux": + os_name = "Linux" + driver_version = "Unknown" else: - raise SystemError('Unsupported platform: {}'.format(platform.system())) + raise SystemError("Unsupported platform: {}".format(platform.system())) installed_packages = pkg_resources.working_set - installed_packages_list = [{'name': i.key, 'version': i.version, } for i in installed_packages] - - info['os']['name'] = os_name - info['os']['version'] = platform.version() - info['os']['bits'] = '64' if is_os_64bit() else '32' - info['driver']['name'] = "NI-TClk" - info['driver']['version'] = driver_version - info['module']['name'] = 'nitclk' - info['module']['version'] = "1.4.2.dev0" - info['python']['version'] = sys.version - info['python']['bits'] = '64' if is_python_64bit() else '32' - info['python']['is_venv'] = is_venv() - info['python']['packages'] = installed_packages_list + installed_packages_list = [ + { + "name": i.key, + "version": i.version, + } + for i in installed_packages + ] + + info["os"]["name"] = os_name + info["os"]["version"] = platform.version() + info["os"]["bits"] = "64" if is_os_64bit() else "32" + info["driver"]["name"] = "NI-TClk" + info["driver"]["version"] = driver_version + info["module"]["name"] = "nitclk" + info["module"]["version"] = "1.4.2.dev0" + info["python"]["version"] = sys.version + info["python"]["bits"] = "64" if is_python_64bit() else "32" + info["python"]["is_venv"] = is_venv() + info["python"]["packages"] = installed_packages_list return info def print_diagnostic_information(): - '''Print diagnostic information in a format suitable for issue report + """Print diagnostic information in a format suitable for issue report note: Python bitness may be incorrect when running in a virtual environment - ''' + """ info = get_diagnostic_information() - row_format = ' {:<10} {}' - for type in ['OS', 'Driver', 'Module', 'Python']: + row_format = " {:<10} {}" + for type in ["OS", "Driver", "Module", "Python"]: typename = type.lower() - print(type + ':') + print(type + ":") for item in info[typename]: - if item != 'packages': - print(row_format.format(item.title() + ':', info[typename][item])) - print(' Installed Packages:') - for p in info['python']['packages']: - print((' ' * 8) + p['name'] + '==' + p['version']) + if item != "packages": + print(row_format.format(item.title() + ":", info[typename][item])) + print(" Installed Packages:") + for p in info["python"]["packages"]: + print((" " * 8) + p["name"] + "==" + p["version"]) return info - - diff --git a/generated/nitclk/nitclk/_attributes.py b/generated/nitclk/nitclk/_attributes.py index 73c7c66fe..33ac0b907 100644 --- a/generated/nitclk/nitclk/_attributes.py +++ b/generated/nitclk/nitclk/_attributes.py @@ -6,14 +6,13 @@ class Attribute(object): - '''Base class for all typed attributes.''' + """Base class for all typed attributes.""" def __init__(self, attribute_id): self._attribute_id = attribute_id class AttributeViInt32(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int32(self._attribute_id) @@ -22,16 +21,19 @@ def __set__(self, session, value): class AttributeViInt32TimeDeltaMilliseconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(milliseconds=session._get_attribute_vi_int32(self._attribute_id)) + return hightime.timedelta( + milliseconds=session._get_attribute_vi_int32(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_int32(self._attribute_id, _converters.convert_timedelta_to_milliseconds_int32(value).value) + session._set_attribute_vi_int32( + self._attribute_id, + _converters.convert_timedelta_to_milliseconds_int32(value).value, + ) class AttributeViInt64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_int64(self._attribute_id) @@ -40,7 +42,6 @@ def __set__(self, session, value): class AttributeViReal64(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_real64(self._attribute_id) @@ -49,16 +50,19 @@ def __set__(self, session, value): class AttributeViReal64TimeDeltaSeconds(Attribute): - def __get__(self, session, session_type): - return hightime.timedelta(seconds=session._get_attribute_vi_real64(self._attribute_id)) + return hightime.timedelta( + seconds=session._get_attribute_vi_real64(self._attribute_id) + ) def __set__(self, session, value): - session._set_attribute_vi_real64(self._attribute_id, _converters.convert_timedelta_to_seconds_real64(value).value) + session._set_attribute_vi_real64( + self._attribute_id, + _converters.convert_timedelta_to_seconds_real64(value).value, + ) class AttributeViString(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) @@ -67,16 +71,17 @@ def __set__(self, session, value): class AttributeViStringRepeatedCapability(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_string(self._attribute_id) def __set__(self, session, value): - session._set_attribute_vi_string(self._attribute_id, _converters.convert_repeated_capabilities_without_prefix(value)) + session._set_attribute_vi_string( + self._attribute_id, + _converters.convert_repeated_capabilities_without_prefix(value), + ) class AttributeViBoolean(Attribute): - def __get__(self, session, session_type): return session._get_attribute_vi_boolean(self._attribute_id) @@ -85,31 +90,36 @@ def __set__(self, session, value): class AttributeEnum(object): - def __init__(self, underlying_attribute_meta_class, enum_meta_class, attribute_id): self._underlying_attribute = underlying_attribute_meta_class(attribute_id) self._attribute_type = enum_meta_class self._attribute_id = attribute_id def __get__(self, session, session_type): - return self._attribute_type(self._underlying_attribute.__get__(session, session_type)) + return self._attribute_type( + self._underlying_attribute.__get__(session, session_type) + ) def __set__(self, session, value): if type(value) is not self._attribute_type: - raise TypeError('must be ' + str(self._attribute_type.__name__) + ' not ' + str(type(value).__name__)) + raise TypeError( + "must be " + + str(self._attribute_type.__name__) + + " not " + + str(type(value).__name__) + ) return self._underlying_attribute.__set__(session, value.value) # nitclk specific attribute type class AttributeSessionReference(Attribute): - def __get__(self, session, session_type): # Import here to avoid a circular dependency when initial import happens from nitclk.session import SessionReference + return SessionReference(session._get_attribute_vi_session(self._attribute_id)) def __set__(self, session, value): - session._set_attribute_vi_session(self._attribute_id, _converters.convert_to_nitclk_session_number(value)) - - - + session._set_attribute_vi_session( + self._attribute_id, _converters.convert_to_nitclk_session_number(value) + ) diff --git a/generated/nitclk/nitclk/_converters.py b/generated/nitclk/nitclk/_converters.py index 45f76e0d2..9d5ae352f 100644 --- a/generated/nitclk/nitclk/_converters.py +++ b/generated/nitclk/nitclk/_converters.py @@ -13,7 +13,7 @@ @singledispatch def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - '''Base version that should not be called + """Base version that should not be called Overall purpose is to convert the repeated capabilities to a list of strings with prefix from what ever form @@ -40,36 +40,38 @@ def _convert_repeated_capabilities(arg, prefix): # noqa: F811 - ('0-1', 4) --> ['0', '1', '4'] - (slice(0, 1), '2', [4, '5-6'], '7-9', '11:14', '16, 17') --> ['0', '2', '4', '5', '6', '7', '8', '9', '11', '12', '13', '14', '16', '17'] - ''' - raise errors.InvalidRepeatedCapabilityError('Invalid type', type(arg)) + """ + raise errors.InvalidRepeatedCapabilityError("Invalid type", type(arg)) @_convert_repeated_capabilities.register(numbers.Integral) # noqa: F811 def _(repeated_capability, prefix): - '''Integer version''' + """Integer version""" return [str(repeated_capability)] # This parsing function duplicate the parsing in the driver, so if changes to the allowed format are made there, they will need to be replicated here. @_convert_repeated_capabilities.register(str) # noqa: F811 def _(repeated_capability, prefix): - '''String version (this is the most complex) + """String version (this is the most complex) We need to deal with a range ('0-3' or '0:3'), a list ('0,1,2,3') and a single item - ''' + """ # First we deal with a list - rep_cap_list = repeated_capability.split(',') + rep_cap_list = repeated_capability.split(",") if len(rep_cap_list) > 1: # We have a list so call ourselves again to let the iterable instance handle it return _convert_repeated_capabilities(rep_cap_list, prefix) # Now we deal with ranges # We remove any prefix and change ':' to '-' - r = repeated_capability.strip().replace(prefix, '').replace(':', '-') - rc = r.split('-') + r = repeated_capability.strip().replace(prefix, "").replace(":", "-") + rc = r.split("-") if len(rc) > 1: if len(rc) > 2: - raise errors.InvalidRepeatedCapabilityError("Multiple '-' or ':'", repeated_capability) + raise errors.InvalidRepeatedCapabilityError( + "Multiple '-' or ':'", repeated_capability + ) try: start = int(rc[0]) end = int(rc[1]) @@ -85,7 +87,7 @@ def _(repeated_capability, prefix): return _convert_repeated_capabilities(rng, prefix) # If we made it here, it must be a simple item so we remove any prefix and return - return [repeated_capability.replace(prefix, '').strip()] + return [repeated_capability.replace(prefix, "").strip()] # We cannot use collections.abc.Iterable here because strings are also iterable and then this @@ -94,7 +96,7 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(range) # noqa: F811 @_convert_repeated_capabilities.register(tuple) # noqa: F811 def _(repeated_capability, prefix): - '''Iterable version - can handle lists, ranges, and tuples''' + """Iterable version - can handle lists, ranges, and tuples""" rep_cap_list = [] for r in repeated_capability: rep_cap_list += _convert_repeated_capabilities(r, prefix) @@ -103,16 +105,22 @@ def _(repeated_capability, prefix): @_convert_repeated_capabilities.register(slice) # noqa: F811 def _(repeated_capability, prefix): - '''slice version''' + """slice version""" + def ifnone(a, b): return b if a is None else a + # Turn the slice into a list and call ourselves again to let the iterable instance handle it - rng = range(ifnone(repeated_capability.start, 0), repeated_capability.stop, ifnone(repeated_capability.step, 1)) + rng = range( + ifnone(repeated_capability.start, 0), + repeated_capability.stop, + ifnone(repeated_capability.step, 1), + ) return _convert_repeated_capabilities(rng, prefix) -def convert_repeated_capabilities(repeated_capability, prefix=''): - '''Convert a repeated capabilities object to a comma delimited list +def convert_repeated_capabilities(repeated_capability, prefix=""): + """Convert a repeated capabilities object to a comma delimited list Args: repeated_capability (str, list, tuple, slice, None) - @@ -120,15 +128,17 @@ def convert_repeated_capabilities(repeated_capability, prefix=''): Returns: rep_cap_list (list of str) - list of each repeated capability item with ranges expanded and prefix added - ''' + """ # We need to explicitly handle None here. Everything else we can pass on to the singledispatch functions if repeated_capability is None: return [] - return [prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix)] + return [ + prefix + r for r in _convert_repeated_capabilities(repeated_capability, prefix) + ] def convert_repeated_capabilities_without_prefix(repeated_capability): - '''Convert a repeated capabilities object, without any prefix, to a comma delimited list + """Convert a repeated capabilities object, without any prefix, to a comma delimited list Args: repeated_capability - Supported types: @@ -144,8 +154,8 @@ def convert_repeated_capabilities_without_prefix(repeated_capability): Returns: rep_cap (str) - comma delimited string of each repeated capability item with ranges expanded - ''' - return ','.join(convert_repeated_capabilities(repeated_capability, '')) + """ + return ",".join(convert_repeated_capabilities(repeated_capability, "")) def _convert_timedelta(value, library_type, scaling): @@ -158,7 +168,14 @@ def _convert_timedelta(value, library_type, scaling): scaled_value = float(value) * scaling # ctype integer types don't convert to int from float so we need to - if library_type in [_visatype.ViInt64, _visatype.ViInt32, _visatype.ViUInt32, _visatype.ViInt16, _visatype.ViUInt16, _visatype.ViInt8]: + if library_type in [ + _visatype.ViInt64, + _visatype.ViInt32, + _visatype.ViUInt32, + _visatype.ViInt16, + _visatype.ViUInt16, + _visatype.ViInt8, + ]: scaled_value = int(scaled_value) return library_type(scaled_value) @@ -195,34 +212,36 @@ def convert_init_with_options_dictionary(values): init_with_options_string = values else: good_keys = { - 'rangecheck': 'RangeCheck', - 'queryinstrstatus': 'QueryInstrStatus', - 'cache': 'Cache', - 'simulate': 'Simulate', - 'recordcoercions': 'RecordCoercions', - 'interchangecheck': 'InterchangeCheck', - 'driversetup': 'DriverSetup', - 'range_check': 'RangeCheck', - 'query_instr_status': 'QueryInstrStatus', - 'record_coercions': 'RecordCoercions', - 'interchange_check': 'InterchangeCheck', - 'driver_setup': 'DriverSetup', + "rangecheck": "RangeCheck", + "queryinstrstatus": "QueryInstrStatus", + "cache": "Cache", + "simulate": "Simulate", + "recordcoercions": "RecordCoercions", + "interchangecheck": "InterchangeCheck", + "driversetup": "DriverSetup", + "range_check": "RangeCheck", + "query_instr_status": "QueryInstrStatus", + "record_coercions": "RecordCoercions", + "interchange_check": "InterchangeCheck", + "driver_setup": "DriverSetup", } init_with_options = [] for k in sorted(values.keys()): value = None - if k.lower() in good_keys and not good_keys[k.lower()] == 'DriverSetup': - value = good_keys[k.lower()] + ('=1' if values[k] is True else '=0') - elif k.lower() in good_keys and good_keys[k.lower()] == 'DriverSetup': + if k.lower() in good_keys and not good_keys[k.lower()] == "DriverSetup": + value = good_keys[k.lower()] + ("=1" if values[k] is True else "=0") + elif k.lower() in good_keys and good_keys[k.lower()] == "DriverSetup": if not isinstance(values[k], dict): - raise TypeError('DriverSetup must be a dictionary') - value = 'DriverSetup=' + (';'.join([key + ':' + values[k][key] for key in sorted(values[k])])) + raise TypeError("DriverSetup must be a dictionary") + value = "DriverSetup=" + ( + ";".join([key + ":" + values[k][key] for key in sorted(values[k])]) + ) else: - value = k + ('=1' if values[k] is True else '=0') + value = k + ("=1" if values[k] is True else "=0") init_with_options.append(value) - init_with_options_string = ','.join(init_with_options) + init_with_options_string = ",".join(init_with_options) return init_with_options_string @@ -251,11 +270,11 @@ def convert_to_bytes(value): # noqa: F811 def convert_comma_separated_string_to_list(comma_separated_string): - return [x.strip() for x in comma_separated_string.split(',')] + return [x.strip() for x in comma_separated_string.split(",")] def convert_chained_repeated_capability_to_parts(chained_repeated_capability): - '''Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. + """Convert a chained repeated capabilities string to a list of comma-delimited repeated capabilities string. Converter assumes that the input contains the full cartesian product of its parts. e.g. If chained_repeated_capability is 'site0/PinA,site0/PinB,site1/PinA,site1/PinB', @@ -267,22 +286,30 @@ def convert_chained_repeated_capability_to_parts(chained_repeated_capability): Returns: rep_cap_list (list of str) - list of comma-delimited repeated capabilities string - ''' - chained_repeated_capability_items = convert_comma_separated_string_to_list(chained_repeated_capability) - repeated_capability_lists = [[] for _ in range(chained_repeated_capability_items[0].count('/') + 1)] + """ + chained_repeated_capability_items = convert_comma_separated_string_to_list( + chained_repeated_capability + ) + repeated_capability_lists = [ + [] for _ in range(chained_repeated_capability_items[0].count("/") + 1) + ] for item in chained_repeated_capability_items: - repeated_capability_lists = [x + [y] for x, y in zip(repeated_capability_lists, item.split('/'))] - return [','.join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists] + repeated_capability_lists = [ + x + [y] for x, y in zip(repeated_capability_lists, item.split("/")) + ] + return [ + ",".join(collections.OrderedDict.fromkeys(x)) for x in repeated_capability_lists + ] # nitclk specific converters def convert_to_nitclk_session_number(item): - '''Convert from supported objects to NI-TClk Session Num + """Convert from supported objects to NI-TClk Session Num Supported objects are: - class with .tclk object of type nitclk.SessionReference - nitclk.SessionReference - ''' + """ try: return item.tclk._get_tclk_session_reference() except AttributeError: @@ -293,11 +320,9 @@ def convert_to_nitclk_session_number(item): except AttributeError: pass - raise TypeError('Unsupported type for nitclk session: {}'.format(type(item))) + raise TypeError("Unsupported type for nitclk session: {}".format(type(item))) def convert_to_nitclk_session_number_list(item_list): - '''Converts a list of items to nitclk session nums''' + """Converts a list of items to nitclk session nums""" return [convert_to_nitclk_session_number(i) for i in item_list] - -