mirror of
				https://github.com/ProjectSynthoria/SynthoriaArchive.git
				synced 2025-11-04 09:55:46 +02:00 
			
		
		
		
	PEP8 (a run of lint.sh)
This commit is contained in:
		
							parent
							
								
									00c768c722
								
							
						
					
					
						commit
						a79c0f8a93
					
				
					 6 changed files with 24 additions and 12 deletions
				
			
		| 
						 | 
					@ -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()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -209,7 +209,7 @@ class UploadForm(FlaskForm):
 | 
				
			||||||
        # Decode and ensure data is bencoded data
 | 
					        # Decode and ensure data is bencoded data
 | 
				
			||||||
        try:
 | 
					        try:
 | 
				
			||||||
            torrent_dict = bencode.decode(field.data)
 | 
					            torrent_dict = bencode.decode(field.data)
 | 
				
			||||||
            #field.data.close()
 | 
					            # field.data.close()
 | 
				
			||||||
        except (bencode.MalformedBencodeException, UnicodeError):
 | 
					        except (bencode.MalformedBencodeException, UnicodeError):
 | 
				
			||||||
            raise ValidationError('Malformed torrent file')
 | 
					            raise ValidationError('Malformed torrent 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')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					@ -619,7 +618,7 @@ def site_help():
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#################################### API ROUTES ####################################
 | 
					#################################### API ROUTES ####################################
 | 
				
			||||||
# DISABLED FOR NOW
 | 
					# DISABLED FOR NOW
 | 
				
			||||||
@app.route('/api/upload', methods = ['POST'])
 | 
					@app.route('/api/upload', methods=['POST'])
 | 
				
			||||||
def api_upload():
 | 
					def api_upload():
 | 
				
			||||||
    api_response = api_handler.api_upload(flask.request)
 | 
					    api_response = api_handler.api_upload(flask.request)
 | 
				
			||||||
    return api_response
 | 
					    return api_response
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue