-
Notifications
You must be signed in to change notification settings - Fork 8
Python error resolution (Sourcery refactored) #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,7 +74,7 @@ def write(self, name, value): | |
| return | ||
|
|
||
| if data[5] == 'ro': | ||
| raise ValueError('{} is read-only'.format(name)) | ||
| raise ValueError(f'{name} is read-only') | ||
|
|
||
| id = data[0] | ||
|
|
||
|
|
@@ -106,14 +106,9 @@ def read(self, name): | |
| usb.util.CTRL_IN | usb.util.CTRL_TYPE_VENDOR | usb.util.CTRL_RECIPIENT_DEVICE, | ||
| 0, cmd, id, length, self.TIMEOUT) | ||
|
|
||
| response = struct.unpack(b'ii', response.tostring()) | ||
| response = struct.unpack(b'ii', response.tobytes()) | ||
|
|
||
| if data[2] == 'int': | ||
| result = response[0] | ||
| else: | ||
| result = response[0] * (2.**response[1]) | ||
|
|
||
| return result | ||
| return response[0] if data[2] == 'int' else response[0] * (2.**response[1]) | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| def set_vad_threshold(self, db): | ||
| self.write('GAMMAVAD_SR', db) | ||
|
|
@@ -139,20 +134,19 @@ def close(self): | |
|
|
||
|
|
||
| def find(vid=0x2886, pid=0x0018): | ||
| dev = usb.core.find(idVendor=vid, idProduct=pid) | ||
| if not dev: | ||
| return | ||
| if dev := usb.core.find(idVendor=vid, idProduct=pid): | ||
| # configuration = dev.get_active_configuration() | ||
|
|
||
| # configuration = dev.get_active_configuration() | ||
| # interface_number = None | ||
| # for interface in configuration: | ||
| # interface_number = interface.bInterfaceNumber | ||
|
|
||
| # interface_number = None | ||
| # for interface in configuration: | ||
| # interface_number = interface.bInterfaceNumber | ||
| # if dev.is_kernel_driver_active(interface_number): | ||
| # dev.detach_kernel_driver(interface_number) | ||
|
|
||
| # if dev.is_kernel_driver_active(interface_number): | ||
| # dev.detach_kernel_driver(interface_number) | ||
|
|
||
| return Tuning(dev) | ||
|
Comment on lines
-142
to
-155
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| return Tuning(dev) | ||
| else: | ||
| return | ||
|
|
||
|
|
||
|
|
||
|
|
@@ -165,7 +159,7 @@ def main(): | |
| data = PARAMETERS[name] | ||
| print('{:16}\t{}'.format(name, b'\t'.join([str(i) for i in data[2:7]]))) | ||
| for extra in data[7:]: | ||
| print('{}{}'.format(' '*60, extra)) | ||
| print(f"{' ' * 60}{extra}") | ||
|
Comment on lines
-168
to
+162
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| else: | ||
| dev = find() | ||
| if not dev: | ||
|
|
@@ -184,10 +178,10 @@ def main(): | |
| if name in PARAMETERS: | ||
| if len(sys.argv) > 2: | ||
| dev.write(name, sys.argv[2]) | ||
| print('{}: {}'.format(name, dev.read(name))) | ||
|
|
||
| print(f'{name}: {dev.read(name)}') | ||
| else: | ||
| print('{} is not a valid name'.format(name)) | ||
| print(f'{name} is not a valid name') | ||
|
|
||
| dev.close() | ||
| else: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
Tuning.writerefactored with the following changes:use-fstring-for-formatting)