mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
13552bef07
commit
8fd6d2ee5d
@ -2040,11 +2040,13 @@ class SMART_DEVICE_APP(DeviceConfig, DevicePlugin):
|
|||||||
# Function to monkeypatch zeroconf to remove the 15 character name length restriction.
|
# Function to monkeypatch zeroconf to remove the 15 character name length restriction.
|
||||||
# Copied from https://github.com/jstasiak/python-zeroconf version 0.28.1
|
# Copied from https://github.com/jstasiak/python-zeroconf version 0.28.1
|
||||||
|
|
||||||
|
|
||||||
from zeroconf import (BadTypeInNameException, _HAS_A_TO_Z,
|
from zeroconf import (BadTypeInNameException, _HAS_A_TO_Z,
|
||||||
_HAS_ONLY_A_TO_Z_NUM_HYPHEN_UNDERSCORE,
|
_HAS_ONLY_A_TO_Z_NUM_HYPHEN_UNDERSCORE,
|
||||||
_HAS_ASCII_CONTROL_CHARS,
|
_HAS_ASCII_CONTROL_CHARS,
|
||||||
_HAS_ONLY_A_TO_Z_NUM_HYPHEN)
|
_HAS_ONLY_A_TO_Z_NUM_HYPHEN)
|
||||||
|
|
||||||
|
|
||||||
def service_type_name(type_: str, *, allow_underscores: bool = False) -> str:
|
def service_type_name(type_: str, *, allow_underscores: bool = False) -> str:
|
||||||
"""
|
"""
|
||||||
Validate a fully qualified service name, instance or subtype. [rfc6763]
|
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.') :]
|
return '_' + name + type_[-len('._tcp.local.') :]
|
||||||
|
|
||||||
|
@ -468,7 +468,7 @@ class Quickview(QDialog, Ui_Quickview):
|
|||||||
'''
|
'''
|
||||||
if (not ignore_lock and self.lock_qv.isChecked()):
|
if (not ignore_lock and self.lock_qv.isChecked()):
|
||||||
return
|
return
|
||||||
if not idx.isValid():
|
if not idx.isValid():
|
||||||
from calibre.constants import DEBUG
|
from calibre.constants import DEBUG
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
@ -477,10 +477,9 @@ class Quickview(QDialog, Ui_Quickview):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.current_column = (
|
self.current_column = (
|
||||||
self.view.column_map.index('authors')
|
self.view.column_map.index('authors') if (
|
||||||
if self.current_column is None
|
self.current_column is None and self.view.column_map[idx.column()] == 'title'
|
||||||
and self.view.column_map[idx.column()] == 'title'
|
) else idx.column())
|
||||||
else idx.column())
|
|
||||||
key = self.view.column_map[self.current_column]
|
key = self.view.column_map[self.current_column]
|
||||||
book_id = self.view.model().id(idx.row())
|
book_id = self.view.model().id(idx.row())
|
||||||
if self.current_book_id == book_id and self.current_key == key:
|
if self.current_book_id == book_id and self.current_key == key:
|
||||||
|
@ -206,17 +206,17 @@ class _Parser(object):
|
|||||||
return val
|
return val
|
||||||
|
|
||||||
INFIX_OPS = {
|
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,
|
||||||
">#": 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([
|
lex_scanner = re.Scanner([
|
||||||
(r'(==#|!=#|<=#|<#|>=#|>#|==|!=|<=|<|>=|>)',
|
(r'(==#|!=#|<=#|<#|>=#|>#|==|!=|<=|<|>=|>)',
|
||||||
lambda x,t: (_Parser.LEX_INFIX, t)),
|
lambda x,t: (_Parser.LEX_INFIX, t)),
|
||||||
(r'if\b', lambda x,t: (_Parser.LEX_IF, t)),
|
(r'if\b', lambda x,t: (_Parser.LEX_IF, t)), # noqa
|
||||||
(r'then\b', lambda x,t: (_Parser.LEX_THEN, t)),
|
(r'then\b', lambda x,t: (_Parser.LEX_THEN, t)), # noqa
|
||||||
(r'else\b', lambda x,t: (_Parser.LEX_ELSE, t)),
|
(r'else\b', lambda x,t: (_Parser.LEX_ELSE, t)), # noqa
|
||||||
(r'fi\b', lambda x,t: (_Parser.LEX_FI, t)),
|
(r'fi\b', lambda x,t: (_Parser.LEX_FI, t)), # noqa
|
||||||
(r'[(),=;]', lambda x,t: (_Parser.LEX_OP, t)),
|
(r'[(),=;]', lambda x,t: (_Parser.LEX_OP, t)), # noqa
|
||||||
(r'-?[\d\.]+', lambda x,t: (_Parser.LEX_CONST, t)),
|
(r'-?[\d\.]+', lambda x,t: (_Parser.LEX_CONST, t)), # noqa
|
||||||
(r'\$', lambda x,t: (_Parser.LEX_ID, t)),
|
(r'\$', lambda x,t: (_Parser.LEX_ID, t)), # noqa
|
||||||
(r'\w+', lambda x,t: (_Parser.LEX_ID, t)),
|
(r'\w+', lambda x,t: (_Parser.LEX_ID, t)), # noqa
|
||||||
(r'".*?((?<!\\)")', lambda x,t: (_Parser.LEX_CONST, t[1:-1])),
|
(r'".*?((?<!\\)")', lambda x,t: (_Parser.LEX_CONST, t[1:-1])), # noqa
|
||||||
(r'\'.*?((?<!\\)\')', lambda x,t: (_Parser.LEX_CONST, t[1:-1])),
|
(r'\'.*?((?<!\\)\')', lambda x,t: (_Parser.LEX_CONST, t[1:-1])), # noqa
|
||||||
(r'\n#.*?(?:(?=\n)|$)', None),
|
(r'\n#.*?(?:(?=\n)|$)', None),
|
||||||
(r'\s', None),
|
(r'\s', None),
|
||||||
], flags=re.DOTALL)
|
], flags=re.DOTALL)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user