1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-10-31 23:55:54 +00:00

PEP8 (a run of lint.sh)

This commit is contained in:
sharkykh 2017-05-14 09:25:01 +03:00 committed by Kfir Hadas
parent 00c768c722
commit a79c0f8a93
6 changed files with 24 additions and 12 deletions

View file

@ -304,7 +304,8 @@ def api_upload(upload_request):
if app.config.get('BACKUP_TORRENT_FOLDER'): if app.config.get('BACKUP_TORRENT_FOLDER'):
torrent_file.seek(0, 0) torrent_file.seek(0, 0)
torrent_path = os.path.join(app.config['BACKUP_TORRENT_FOLDER'], '{}.{}'.format(torrent.id, secure_filename(torrent_file.filename))) torrent_path = os.path.join(app.config['BACKUP_TORRENT_FOLDER'], '{}.{}'.format(
torrent.id, secure_filename(torrent_file.filename)))
torrent_file.save(torrent_path) torrent_file.save(torrent_path)
torrent_file.close() torrent_file.close()

View file

@ -156,7 +156,8 @@ def handle_torrent_upload(upload_form, uploading_user=None):
if not os.path.exists(torrent_dir): if not os.path.exists(torrent_dir):
os.makedirs(torrent_dir) os.makedirs(torrent_dir)
torrent_path = os.path.join(torrent_dir, '{}.{}'.format(torrent.id, secure_filename(torrent_file.filename))) torrent_path = os.path.join(torrent_dir, '{}.{}'.format(
torrent.id, secure_filename(torrent_file.filename)))
torrent_file.save(torrent_path) torrent_file.save(torrent_path)
torrent_file.close() torrent_file.close()

View file

@ -1,6 +1,7 @@
from flask_sqlalchemy import Pagination, BaseQuery from flask_sqlalchemy import Pagination, BaseQuery
from flask import abort from flask import abort
def paginate_faste(self, page=1, per_page=50, max_page=None, step=5): def paginate_faste(self, page=1, per_page=50, max_page=None, step=5):
if page < 1: if page < 1:
abort(404) abort(404)
@ -25,4 +26,5 @@ def paginate_faste(self, page=1, per_page=50, max_page=None, step=5):
return Pagination(self, page, per_page, total, items) return Pagination(self, page, per_page, total, items)
BaseQuery.paginate_faste = paginate_faste BaseQuery.paginate_faste = paginate_faste

View file

@ -266,7 +266,12 @@ class TorrentFileData(object):
# https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure # https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure
<<<<<<< master
def _validate_trackers(torrent_dict, tracker_to_check_for=None): def _validate_trackers(torrent_dict, tracker_to_check_for=None):
=======
def _validate_trackers(torrent_dict):
>>>>>>> PEP8 (a run of lint.sh)
announce = torrent_dict.get('announce') announce = torrent_dict.get('announce')
announce_string = _validate_bytes(announce, 'announce', 'utf-8') announce_string = _validate_bytes(announce, 'announce', 'utf-8')

View file

@ -41,8 +41,10 @@ class TorrentFlags(IntEnum):
COMPLETE = 16 COMPLETE = 16
DELETED = 32 DELETED = 32
DB_TABLE_PREFIX = app.config['TABLE_PREFIX'] DB_TABLE_PREFIX = app.config['TABLE_PREFIX']
class Torrent(db.Model): class Torrent(db.Model):
__tablename__ = DB_TABLE_PREFIX + 'torrents' __tablename__ = DB_TABLE_PREFIX + 'torrents'
@ -118,7 +120,6 @@ class Torrent(db.Model):
# Escaped # Escaped
return escape_markup(self.information) return escape_markup(self.information)
@property @property
def magnet_uri(self): def magnet_uri(self):
return create_magnet(self) return create_magnet(self)
@ -224,7 +225,8 @@ class Trackers(db.Model):
__tablename__ = 'trackers' __tablename__ = 'trackers'
id = db.Column(db.Integer, primary_key=True) id = db.Column(db.Integer, primary_key=True)
uri = db.Column(db.String(length=255, collation=COL_UTF8_GENERAL_CI), nullable=False, unique=True) uri = db.Column(db.String(length=255, collation=COL_UTF8_GENERAL_CI),
nullable=False, unique=True)
disabled = db.Column(db.Boolean, nullable=False, default=False) disabled = db.Column(db.Boolean, nullable=False, default=False)
@classmethod @classmethod
@ -235,8 +237,10 @@ class Trackers(db.Model):
class TorrentTrackers(db.Model): class TorrentTrackers(db.Model):
__tablename__ = DB_TABLE_PREFIX + 'torrent_trackers' __tablename__ = DB_TABLE_PREFIX + 'torrent_trackers'
torrent_id = db.Column(db.Integer, db.ForeignKey(DB_TABLE_PREFIX + 'torrents.id', ondelete="CASCADE"), primary_key=True) torrent_id = db.Column(db.Integer, db.ForeignKey(
tracker_id = db.Column(db.Integer, db.ForeignKey('trackers.id', ondelete="CASCADE"), primary_key=True) DB_TABLE_PREFIX + 'torrents.id', ondelete="CASCADE"), primary_key=True)
tracker_id = db.Column(db.Integer, db.ForeignKey(
'trackers.id', ondelete="CASCADE"), primary_key=True)
order = db.Column(db.Integer, nullable=False, index=True) order = db.Column(db.Integer, nullable=False, index=True)
tracker = db.relationship('Trackers', uselist=False, lazy='joined') tracker = db.relationship('Trackers', uselist=False, lazy='joined')

View file

@ -60,7 +60,6 @@ def filter_truthy(input_list):
the search_results.html template ''' the search_results.html template '''
return [item for item in input_list if item] return [item for item in input_list if item]
@app.errorhandler(404) @app.errorhandler(404)
def not_found(error): def not_found(error):
return flask.render_template('404.html'), 404 return flask.render_template('404.html'), 404