From 8fd6d2ee5dcccb0fbb8b754d81bc829ed6f6714a Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 9 Sep 2020 15:50:46 +0530 Subject: [PATCH] pep8 --- .../devices/smart_device_app/driver.py | 3 +- src/calibre/gui2/dialogs/quickview.py | 9 +++-- src/calibre/utils/formatter.py | 36 +++++++++---------- 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/calibre/devices/smart_device_app/driver.py b/src/calibre/devices/smart_device_app/driver.py index e66879ae24..7613cb4837 100644 --- a/src/calibre/devices/smart_device_app/driver.py +++ b/src/calibre/devices/smart_device_app/driver.py @@ -2040,11 +2040,13 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin): # Function to monkeypatch zeroconf to remove the 15 character name length restriction. # Copied from https://github.com/jstasiak/python-zeroconf version 0.28.1 + from zeroconf import (BadTypeInNameException, _HAS_A_TO_Z, _HAS_ONLY_A_TO_Z_NUM_HYPHEN_UNDERSCORE, _HAS_ASCII_CONTROL_CHARS, _HAS_ONLY_A_TO_Z_NUM_HYPHEN) + def service_type_name(type_: str, *, allow_underscores: bool = False) -> str: """ Validate a fully qualified service name, instance or subtype. [rfc6763] @@ -2143,4 +2145,3 @@ def service_type_name(type_: str, *, allow_underscores: bool = False) -> str: ) return '_' + name + type_[-len('._tcp.local.') :] - diff --git a/src/calibre/gui2/dialogs/quickview.py b/src/calibre/gui2/dialogs/quickview.py index d9677bfe7e..e679343226 100644 --- a/src/calibre/gui2/dialogs/quickview.py +++ b/src/calibre/gui2/dialogs/quickview.py @@ -468,7 +468,7 @@ class Quickview(QDialog, Ui_Quickview): ''' if (not ignore_lock and self.lock_qv.isChecked()): return - if not idx.isValid(): + if not idx.isValid(): from calibre.constants import DEBUG if DEBUG: from calibre import prints @@ -477,10 +477,9 @@ class Quickview(QDialog, Ui_Quickview): try: self.current_column = ( - self.view.column_map.index('authors') - if self.current_column is None - and self.view.column_map[idx.column()] == 'title' - else idx.column()) + self.view.column_map.index('authors') if ( + self.current_column is None and self.view.column_map[idx.column()] == 'title' + ) else idx.column()) key = self.view.column_map[self.current_column] book_id = self.view.model().id(idx.row()) if self.current_book_id == book_id and self.current_key == key: diff --git a/src/calibre/utils/formatter.py b/src/calibre/utils/formatter.py index 731bf9f447..102ecb1347 100644 --- a/src/calibre/utils/formatter.py +++ b/src/calibre/utils/formatter.py @@ -206,17 +206,17 @@ class _Parser(object): return val INFIX_OPS = { - "==": lambda x, y: strcmp(x, y) == 0, - "!=": lambda x, y: strcmp(x, y) != 0, - "<": lambda x, y: strcmp(x, y) < 0, - "<=": lambda x, y: strcmp(x, y) <= 0, - ">": lambda x, y: strcmp(x, y) > 0, - ">=": lambda x, y: strcmp(x, y) >= 0, + "==": lambda x, y: strcmp(x, y) == 0, + "!=": lambda x, y: strcmp(x, y) != 0, + "<": lambda x, y: strcmp(x, y) < 0, + "<=": lambda x, y: strcmp(x, y) <= 0, + ">": lambda x, y: strcmp(x, y) > 0, + ">=": lambda x, y: strcmp(x, y) >= 0, "==#": lambda x, y: float(x) == float(y) if x and y else False, "!=#": lambda x, y: float(x) != float(y) if x and y else False, - "<#": lambda x, y: float(x) < float(y) if x and y else False, + "<#": lambda x, y: float(x) < float(y) if x and y else False, "<=#": lambda x, y: float(x) <= float(y) if x and y else False, - ">#": lambda x, y: float(x) > float(y) if x and y else False, + ">#": lambda x, y: float(x) > float(y) if x and y else False, ">=#": lambda x, y: float(x) >= float(y) if x and y else False, } @@ -357,16 +357,16 @@ class TemplateFormatter(string.Formatter): lex_scanner = re.Scanner([ (r'(==#|!=#|<=#|<#|>=#|>#|==|!=|<=|<|>=|>)', lambda x,t: (_Parser.LEX_INFIX, t)), - (r'if\b', lambda x,t: (_Parser.LEX_IF, t)), - (r'then\b', lambda x,t: (_Parser.LEX_THEN, t)), - (r'else\b', lambda x,t: (_Parser.LEX_ELSE, t)), - (r'fi\b', lambda x,t: (_Parser.LEX_FI, t)), - (r'[(),=;]', lambda x,t: (_Parser.LEX_OP, t)), - (r'-?[\d\.]+', lambda x,t: (_Parser.LEX_CONST, t)), - (r'\$', lambda x,t: (_Parser.LEX_ID, t)), - (r'\w+', lambda x,t: (_Parser.LEX_ID, t)), - (r'".*?((?