mirror of
https://gitlab.com/SIGBUS/nyaa.git
synced 2024-12-22 07:50:01 +00:00
PEP8 (a run of lint.sh)
This commit is contained in:
parent
00c768c722
commit
a79c0f8a93
|
@ -297,14 +297,15 @@ def api_upload(upload_request):
|
|||
# Store tracker refs in DB
|
||||
for order, tracker in enumerate(db_trackers):
|
||||
torrent_tracker = models.TorrentTrackers(torrent_id=torrent.id,
|
||||
tracker_id=tracker.id, order=order)
|
||||
tracker_id=tracker.id, order=order)
|
||||
db.session.add(torrent_tracker)
|
||||
|
||||
db.session.commit()
|
||||
|
||||
if app.config.get('BACKUP_TORRENT_FOLDER'):
|
||||
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.close()
|
||||
|
||||
|
|
|
@ -142,7 +142,7 @@ def handle_torrent_upload(upload_form, uploading_user=None):
|
|||
# Store tracker refs in DB
|
||||
for order, tracker in enumerate(db_trackers):
|
||||
torrent_tracker = models.TorrentTrackers(torrent_id=torrent.id,
|
||||
tracker_id=tracker.id, order=order)
|
||||
tracker_id=tracker.id, order=order)
|
||||
db.session.add(torrent_tracker)
|
||||
|
||||
db.session.commit()
|
||||
|
@ -156,8 +156,9 @@ def handle_torrent_upload(upload_form, uploading_user=None):
|
|||
if not os.path.exists(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.close()
|
||||
|
||||
return torrent
|
||||
return torrent
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
from flask_sqlalchemy import Pagination, BaseQuery
|
||||
from flask import abort
|
||||
|
||||
|
||||
def paginate_faste(self, page=1, per_page=50, max_page=None, step=5):
|
||||
if page < 1:
|
||||
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)
|
||||
|
||||
|
||||
BaseQuery.paginate_faste = paginate_faste
|
||||
|
|
|
@ -209,7 +209,7 @@ class UploadForm(FlaskForm):
|
|||
# Decode and ensure data is bencoded data
|
||||
try:
|
||||
torrent_dict = bencode.decode(field.data)
|
||||
#field.data.close()
|
||||
# field.data.close()
|
||||
except (bencode.MalformedBencodeException, UnicodeError):
|
||||
raise ValidationError('Malformed torrent file')
|
||||
|
||||
|
@ -266,7 +266,12 @@ class TorrentFileData(object):
|
|||
|
||||
# https://wiki.theory.org/BitTorrentSpecification#Metainfo_File_Structure
|
||||
|
||||
<<<<<<< master
|
||||
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_string = _validate_bytes(announce, 'announce', 'utf-8')
|
||||
|
||||
|
|
|
@ -41,8 +41,10 @@ class TorrentFlags(IntEnum):
|
|||
COMPLETE = 16
|
||||
DELETED = 32
|
||||
|
||||
|
||||
DB_TABLE_PREFIX = app.config['TABLE_PREFIX']
|
||||
|
||||
|
||||
class Torrent(db.Model):
|
||||
__tablename__ = DB_TABLE_PREFIX + 'torrents'
|
||||
|
||||
|
@ -118,7 +120,6 @@ class Torrent(db.Model):
|
|||
# Escaped
|
||||
return escape_markup(self.information)
|
||||
|
||||
|
||||
@property
|
||||
def magnet_uri(self):
|
||||
return create_magnet(self)
|
||||
|
@ -224,7 +225,8 @@ class Trackers(db.Model):
|
|||
__tablename__ = 'trackers'
|
||||
|
||||
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)
|
||||
|
||||
@classmethod
|
||||
|
@ -235,8 +237,10 @@ class Trackers(db.Model):
|
|||
class TorrentTrackers(db.Model):
|
||||
__tablename__ = DB_TABLE_PREFIX + 'torrent_trackers'
|
||||
|
||||
torrent_id = db.Column(db.Integer, db.ForeignKey(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)
|
||||
torrent_id = db.Column(db.Integer, db.ForeignKey(
|
||||
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)
|
||||
|
||||
tracker = db.relationship('Trackers', uselist=False, lazy='joined')
|
||||
|
|
|
@ -60,7 +60,6 @@ def filter_truthy(input_list):
|
|||
the search_results.html template '''
|
||||
return [item for item in input_list if item]
|
||||
|
||||
|
||||
@app.errorhandler(404)
|
||||
def not_found(error):
|
||||
return flask.render_template('404.html'), 404
|
||||
|
@ -619,7 +618,7 @@ def site_help():
|
|||
|
||||
#################################### API ROUTES ####################################
|
||||
# DISABLED FOR NOW
|
||||
@app.route('/api/upload', methods = ['POST'])
|
||||
@app.route('/api/upload', methods=['POST'])
|
||||
def api_upload():
|
||||
api_response = api_handler.api_upload(flask.request)
|
||||
return api_response
|
Loading…
Reference in a new issue