<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def do_attr(self, args):
 """Get or set the state for a visa attribute. List all attributes: attr Get an attribute state: attr <name> Set an attribute state: attr <name> <state> """


        if not self.current:
            print('There are no resources in use. Use the command "open".')
            return

        args = args.strip()

        if not args:
            self.print_attribute_list()
            return

        args = args.split(' ')

        if len(args) > 2:
            print('Invalid syntax, use `attr <name>` to get; or `attr <name> <value>` to set')
        elif len(args) == 1:
            # Get
            attr_name = args[0]
            if attr_name.startswith('VI_'):
                try:
                    print(self.current.get_visa_attribute(getattr(constants, attr_name)))
                except Exception as e:
                    print(e)
            else:
                try:
                    print(getattr(self.current, attr_name))
                except Exception as e:
                    print(e)
        else:
            attr_name, attr_state = args[0], args[1]
            if attr_name.startswith('VI_'):
                try:
                    attributeId = getattr(constants, attr_name)
                    attr = attributes.AttributesByID[attributeId]
                    datatype = attr.visa_type
                    retcode = None
                    if datatype == 'ViBoolean':
                        if attr_state == 'True':
                            attr_state = True
                        elif attr_state == 'False':
                            attr_state = False
                        else:
                            retcode = constants.StatusCode.error_nonsupported_attribute_state
                    elif datatype in ['ViUInt8', 'ViUInt16', 'ViUInt32', 'ViInt8', 'ViInt16', 'ViInt32']:
                        try:
                            attr_state = int(attr_state)
                        except ValueError:
                            retcode = constants.StatusCode.error_nonsupported_attribute_state
                    if not retcode:
                        retcode = self.current.set_visa_attribute(attributeId, attr_state)
                    if retcode:
                        print('Error {}'.format(str(retcode)))
                    else:
                        print('Done')
                except Exception as e:
                    print(e)
            else:
                print('Setting Resource Attributes by python name is not yet supported.')
                return
                try:
                    print(getattr(self.current, attr_name))
                    print('Done')
                except Exception as e:
                    print(e)