mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Move to ruff for ./setup.py check
This commit is contained in:
parent
a981e08b2c
commit
4419e7d65a
2
.gitignore
vendored
2
.gitignore
vendored
@ -41,7 +41,7 @@ setup/installer/windows/calibre/build.log
|
||||
setup/pyqt_enums
|
||||
tags
|
||||
nbproject/
|
||||
translations/
|
||||
/translations/
|
||||
*.mdproj
|
||||
*.pidb
|
||||
*.sln
|
||||
|
@ -10,6 +10,7 @@ from shutil import copyfile
|
||||
from calibre import strftime
|
||||
from calibre.ebooks.BeautifulSoup import Tag
|
||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||
from calibre.utils.resources import get_path
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@ -168,7 +169,7 @@ class DunyaHalleri(BasicNewsRecipe):
|
||||
self.cover_img_path = None
|
||||
|
||||
def draw_text(self, draw, text, text_size, top):
|
||||
font_path = P('fonts/liberation/LiberationSerif-Bold.ttf')
|
||||
font_path = get_path('fonts/liberation/LiberationSerif-Bold.ttf')
|
||||
font = ImageFont.truetype(font_path, text_size)
|
||||
width, height = draw.textsize(text, font=font)
|
||||
left = max(int((self.COVER_WIDTH - width) / 2.), 0)
|
||||
|
@ -10,6 +10,7 @@ from shutil import copyfile
|
||||
from contextlib import closing
|
||||
from calibre.ebooks.BeautifulSoup import BeautifulSoup, BeautifulStoneSoup, Tag
|
||||
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||
from calibre.utils.resources import get_path
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@ -232,7 +233,7 @@ class DunyaHalleri_HaftaninOzeti(BasicNewsRecipe):
|
||||
self.cover_img_path = None
|
||||
|
||||
def draw_text(self, draw, text, text_size, top):
|
||||
font_path = P('fonts/liberation/LiberationSerif-Bold.ttf')
|
||||
font_path = get_path('fonts/liberation/LiberationSerif-Bold.ttf')
|
||||
font = ImageFont.truetype(font_path, text_size)
|
||||
width, height = draw.textsize(text, font=font)
|
||||
left = max(int((self.COVER_WIDTH - width) / 2.), 0)
|
||||
|
@ -130,7 +130,7 @@ class elcorreo(BasicNewsRecipe):
|
||||
|
||||
# Controlamos si el artículo ha sido incluido en otro feed para eliminarlo
|
||||
|
||||
if not (link in self._processed_links):
|
||||
if link not in self._processed_links:
|
||||
self._processed_links.append(link)
|
||||
else:
|
||||
link = None
|
||||
|
@ -81,7 +81,7 @@ class ElPais_RSS(BasicNewsRecipe):
|
||||
|
||||
def get_article_url(self, article):
|
||||
url = BasicNewsRecipe.get_article_url(self, article)
|
||||
if url and (not('/album/' in url) and not('/futbol/partido/' in url)):
|
||||
if url and ('/album/' not in url and '/futbol/partido/' not in url):
|
||||
return url
|
||||
self.log('Skipping non-article', url)
|
||||
return None
|
||||
|
@ -147,7 +147,7 @@ class expansion_spanish(BasicNewsRecipe):
|
||||
|
||||
# Eliminar artículos duplicados en otros feeds
|
||||
|
||||
if not (link in self._processed_links):
|
||||
if link not in self._processed_links:
|
||||
self._processed_links.append(link)
|
||||
else:
|
||||
link = None
|
||||
|
@ -26,5 +26,16 @@ class AdvancedUserRecipe1328535130(BasicNewsRecipe):
|
||||
masthead_url = 'http://api.ning.com/files/4ot8ampp*-rYQuwL2NoaHvVqcyu7VMyWyan12a9QMsJUWxk-q5V1-34wnD-Wj9B5qWjc1yPMLGiwQg8hZJxaySeaG2lx8hpV/2009_banner_ondarock.gif' # noqa
|
||||
|
||||
extra_css = ''' # noqa
|
||||
.boxtabscontain_page {border: 1px solid #E0E0E0;clear: both;font-family: "Verdana", "Arial", "Helvetica", sans-serif;font-size: 10px;line-height: 17px;margin: 0px 0px 20px;padding: 10px 10px 10px 40px;position: relative;top: -1px;width: 258px;z-index: 1;}
|
||||
'''
|
||||
.boxtabscontain_page {
|
||||
border: 1px solid #E0E0E0;clear: both;
|
||||
font-family: "Verdana", "Arial", "Helvetica", sans-serif;
|
||||
font-size: 10px;
|
||||
line-height: 17px;
|
||||
margin: 0px 0px 20px;
|
||||
padding: 10px 10px 10px 40px;
|
||||
position: relative;
|
||||
top: -1px;
|
||||
width: 258px;
|
||||
z-index: 1;
|
||||
}
|
||||
'''
|
||||
|
@ -159,7 +159,7 @@ class respektRecipe(BasicNewsRecipe):
|
||||
for par in paragraphs[:-1]:
|
||||
prev = par.getprevious()
|
||||
# Do not indent after headings
|
||||
if hasattr(prev,'tag') and not (prev.tag in ['h2','h3']):
|
||||
if hasattr(prev,'tag') and prev.tag not in ['h2', 'h3']:
|
||||
par.attrib['class']="indent_first_line"
|
||||
# Fix subtitle for Téma
|
||||
try:
|
||||
|
@ -77,7 +77,7 @@ class Check(Command):
|
||||
def file_has_errors(self, f):
|
||||
ext = os.path.splitext(f)[1]
|
||||
if ext in {'.py', '.recipe'}:
|
||||
p2 = subprocess.Popen(['flake8', '--filename', '*.py,*.recipe', f])
|
||||
p2 = subprocess.Popen(['ruff', '--no-update-check', f])
|
||||
return p2.wait() != 0
|
||||
if ext == '.pyj':
|
||||
p = subprocess.Popen(['rapydscript', 'lint', f])
|
||||
|
@ -8,6 +8,7 @@ __copyright__ = '2008, Marshall T. Vandegrift <llasram@gmail.com>'
|
||||
import io
|
||||
from gettext import GNUTranslations
|
||||
from calibre.utils.localization import get_lc_messages_path
|
||||
from calibre.utils.resources import get_path
|
||||
from zipfile import ZipFile
|
||||
|
||||
__all__ = ['translate']
|
||||
@ -22,7 +23,7 @@ def translate(lang, text):
|
||||
else:
|
||||
mpath = get_lc_messages_path(lang)
|
||||
if mpath is not None:
|
||||
with ZipFile(P('localization/locales.zip',
|
||||
with ZipFile(get_path('localization/locales.zip',
|
||||
allow_user_override=False), 'r') as zf:
|
||||
try:
|
||||
buf = io.BytesIO(zf.read(mpath + '/messages.mo'))
|
||||
|
@ -1,14 +1,14 @@
|
||||
#!/usr/bin/env python
|
||||
# License: GPLv3 Copyright: 2009, Kovid Goyal <kovid at kovidgoyal.net>
|
||||
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2009, Kovid Goyal <kovid@kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
import os, locale, re, io
|
||||
import io
|
||||
import locale
|
||||
import os
|
||||
import re
|
||||
from gettext import GNUTranslations, NullTranslations
|
||||
from calibre.utils.resources import get_path as P
|
||||
|
||||
from calibre.utils.resources import get_path as P
|
||||
from polyglot.builtins import iteritems
|
||||
|
||||
_available_translations = None
|
||||
@ -29,7 +29,7 @@ def available_translations():
|
||||
|
||||
|
||||
def get_system_locale():
|
||||
from calibre.constants import iswindows, ismacos
|
||||
from calibre.constants import ismacos, iswindows
|
||||
lang = None
|
||||
if iswindows:
|
||||
try:
|
||||
|
Loading…
x
Reference in New Issue
Block a user