-
From 2d4676bdbffef26aae4f9657ee43b5c5578cbc39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simen=20Heggest=C3=B8yl?= <simenheg@gmail.com>
Date: Sun, 15 Oct 2017 18:46:04 +0200
Subject: [PATCH] Remove unused local variables
Remove local variables that were assigned to but never used.
---
mediagoblin/db/base.py | 2 +-
mediagoblin/db/migrations.py | 10 +++++-----
mediagoblin/media_types/audio/__init__.py | 2 +-
mediagoblin/media_types/audio/spectrogram.py | 1 -
mediagoblin/media_types/blog/__init__.py | 2 +-
mediagoblin/media_types/blog/views.py | 2 --
mediagoblin/moderation/views.py | 5 ++---
mediagoblin/plugins/archivalook/views.py | 2 +-
mediagoblin/plugins/basic_auth/__init__.py | 2 +-
mediagoblin/plugins/geolocation/__init__.py | 2 +-
mediagoblin/plugins/ldap/__init__.py | 2 +-
mediagoblin/plugins/openid/__init__.py | 2 +-
mediagoblin/plugins/persona/__init__.py | 2 +-
mediagoblin/processing/task.py | 2 +-
mediagoblin/tests/test_api.py | 5 ++---
mediagoblin/tests/test_collections.py | 2 +-
mediagoblin/tests/test_edit.py | 2 +-
mediagoblin/tests/test_notifications.py | 2 --
mediagoblin/tests/test_openid.py | 5 ++---
mediagoblin/tests/test_privileges.py | 1 -
mediagoblin/tests/test_reporting.py | 2 --
mediagoblin/tests/test_sql_migrations.py | 25 ++++++++++---------------
mediagoblin/tests/test_storage.py | 3 +--
mediagoblin/tests/test_video.py | 6 +++---
mediagoblin/user_pages/views.py | 1 -
25 files changed, 37 insertions(+), 55 deletions(-)
diff --git a/mediagoblin/db/base.py b/mediagoblin/db/base.py
index c59b0ebf..c989d74f 100644
a
|
b
|
class GMGTableBase(object):
|
170 | 170 | |
171 | 171 | # There will be a lot of places where the GenericForeignKey will point |
172 | 172 | # to the model, we want to remap those to our tombstone. |
173 | | gmrs = GenericModelReference.query.filter_by( |
| 173 | GenericModelReference.query.filter_by( |
174 | 174 | obj_pk=self.id, |
175 | 175 | model_type=self.__tablename__ |
176 | 176 | ).update({ |
-
diff --git a/mediagoblin/db/migrations.py b/mediagoblin/db/migrations.py
index 55d64294..a859514a 100644
a
|
b
|
class ProcessingNotification_v0(Notification_v0):
|
376 | 376 | def add_new_notification_tables(db): |
377 | 377 | metadata = MetaData(bind=db.bind) |
378 | 378 | |
379 | | user_table = inspect_table(metadata, 'core__users') |
380 | | mediaentry_table = inspect_table(metadata, 'core__media_entries') |
381 | | mediacomment_table = inspect_table(metadata, 'core__media_comments') |
| 379 | inspect_table(metadata, 'core__users') |
| 380 | inspect_table(metadata, 'core__media_entries') |
| 381 | inspect_table(metadata, 'core__media_comments') |
382 | 382 | |
383 | 383 | CommentSubscription_v0.__table__.create(db.bind) |
384 | 384 | |
… |
… |
def federation_collection_schema(db):
|
1702 | 1702 | metadata = MetaData(bind=db.bind) |
1703 | 1703 | collection_table = inspect_table(metadata, "core__collections") |
1704 | 1704 | collection_items_table = inspect_table(metadata, "core__collection_items") |
1705 | | media_entry_table = inspect_table(metadata, "core__media_entries") |
| 1705 | inspect_table(metadata, "core__media_entries") |
1706 | 1706 | gmr_table = inspect_table(metadata, "core__generic_model_reference") |
1707 | 1707 | |
1708 | 1708 | ## |
… |
… |
def federation_graveyard(db):
|
1867 | 1867 | |
1868 | 1868 | This adds a Graveyard model which is used to copy (soft-)deleted models to. |
1869 | 1869 | """ |
1870 | | metadata = MetaData(bind=db.bind) |
| 1870 | MetaData(bind=db.bind) |
1871 | 1871 | |
1872 | 1872 | # Create the graveyard table |
1873 | 1873 | Graveyard_V0.__table__.create(db.bind) |
-
diff --git a/mediagoblin/media_types/audio/__init__.py b/mediagoblin/media_types/audio/__init__.py
index 6ad473c8..a8609bf9 100644
a
|
b
|
MEDIA_TYPE = 'mediagoblin.media_types.audio'
|
27 | 27 | |
28 | 28 | |
29 | 29 | def setup_plugin(): |
30 | | config = pluginapi.get_config(MEDIA_TYPE) |
| 30 | pluginapi.get_config(MEDIA_TYPE) |
31 | 31 | |
32 | 32 | |
33 | 33 | class AudioMediaManager(MediaManagerBase): |
-
diff --git a/mediagoblin/media_types/audio/spectrogram.py b/mediagoblin/media_types/audio/spectrogram.py
index 433bb300..bd136989 100644
a
|
b
|
def create_spectrogram_image(source_filename, output_filename,
|
269 | 269 | progress_callback((x * 100) / image_size[0]) |
270 | 270 | |
271 | 271 | seek_point = int(x * samples_per_pixel) |
272 | | next_seek_point = int((x + 1) * samples_per_pixel) |
273 | 272 | |
274 | 273 | (spectral_centroid, db_spectrum) = processor.spectral_centroid(seek_point) |
275 | 274 | |
-
diff --git a/mediagoblin/media_types/blog/__init__.py b/mediagoblin/media_types/blog/__init__.py
index 859c2162..55646478 100644
a
|
b
|
MEDIA_TYPE = 'mediagoblin.media_types.blogpost'
|
28 | 28 | |
29 | 29 | |
30 | 30 | def setup_plugin(): |
31 | | config = pluginapi.get_config(MEDIA_TYPE) |
| 31 | pluginapi.get_config(MEDIA_TYPE) |
32 | 32 | _log.info("setting up blog media type plugin.") |
33 | 33 | |
34 | 34 | routes = [ |
-
diff --git a/mediagoblin/media_types/blog/views.py b/mediagoblin/media_types/blog/views.py
index f1d5c49d..01428465 100644
a
|
b
|
def blog_edit(request):
|
56 | 56 | View for editing an existing blog or creating a new blog |
57 | 57 | if user have not exceeded maximum allowed acount of blogs. |
58 | 58 | """ |
59 | | url_user = request.matchdict.get('user', None) |
60 | 59 | blog_slug = request.matchdict.get('blog_slug', None) |
61 | 60 | |
62 | 61 | config = pluginapi.get_config('mediagoblin.media_types.blog') |
… |
… |
def blog_post_listing(request, page, url_user=None):
|
295 | 294 | def draft_view(request): |
296 | 295 | blog_slug = request.matchdict.get('blog_slug', None) |
297 | 296 | blog_post_slug = request.matchdict.get('blog_post_slug', None) |
298 | | user = request.matchdict.get('user') |
299 | 297 | blog = get_blog_by_slug(request, blog_slug, author=request.user.id) |
300 | 298 | blogpost = request.db.MediaEntry.query.filter_by(state = u'failed', actor=request.user.id, slug=blog_post_slug).first() |
301 | 299 | |
-
diff --git a/mediagoblin/moderation/views.py b/mediagoblin/moderation/views.py
index ca0e6533..600fc0db 100644
a
|
b
|
def moderation_users_detail(request):
|
84 | 84 | ).first() |
85 | 85 | active_reports = user.reports_filed_on.filter( |
86 | 86 | Report.resolved==None).limit(5) |
87 | | closed_reports = user.reports_filed_on.filter( |
88 | | Report.resolved!=None).all() |
| 87 | user.reports_filed_on.filter(Report.resolved!=None).all() |
89 | 88 | privileges = Privilege.query |
90 | 89 | user_banned = UserBan.query.get(user.id) |
91 | 90 | ban_form = moderation_forms.BanForm() |
… |
… |
def give_or_take_away_privilege(request, url_user):
|
187 | 186 | ''' |
188 | 187 | form = moderation_forms.PrivilegeAddRemoveForm(request.form) |
189 | 188 | if request.method == "POST" and form.validate(): |
190 | | privilege = Privilege.query.filter( |
| 189 | Privilege.query.filter( |
191 | 190 | Privilege.privilege_name==form.privilege_name.data).one() |
192 | 191 | if not take_away_privileges( |
193 | 192 | url_user.username, form.privilege_name.data): |
-
diff --git a/mediagoblin/plugins/archivalook/views.py b/mediagoblin/plugins/archivalook/views.py
index 72424cfc..9354a775 100644
a
|
b
|
def feature_media(request, media, **kwargs):
|
126 | 126 | already_featured_media_ids = [f.media_entry.id |
127 | 127 | for f in FeaturedMedia.query.all()] |
128 | 128 | if not media.id in already_featured_media_ids: |
129 | | new_feature = automatically_add_new_feature(media) |
| 129 | automatically_add_new_feature(media) |
130 | 130 | return redirect( |
131 | 131 | request, 'index') |
132 | 132 | |
-
diff --git a/mediagoblin/plugins/basic_auth/__init__.py b/mediagoblin/plugins/basic_auth/__init__.py
index 31a4fd95..16b6c05d 100644
a
|
b
|
PLUGIN_DIR = os.path.dirname(__file__)
|
29 | 29 | |
30 | 30 | |
31 | 31 | def setup_plugin(): |
32 | | config = pluginapi.get_config('mediagoblin.plugins.basic_auth') |
| 32 | pluginapi.get_config('mediagoblin.plugins.basic_auth') |
33 | 33 | |
34 | 34 | routes = [ |
35 | 35 | ('mediagoblin.plugins.basic_auth.edit.pass', |
-
diff --git a/mediagoblin/plugins/geolocation/__init__.py b/mediagoblin/plugins/geolocation/__init__.py
index 06aab68e..67ddb72f 100644
a
|
b
|
import os
|
20 | 20 | PLUGIN_DIR = os.path.dirname(__file__) |
21 | 21 | |
22 | 22 | def setup_plugin(): |
23 | | config = pluginapi.get_config('mediagoblin.plugins.geolocation') |
| 23 | pluginapi.get_config('mediagoblin.plugins.geolocation') |
24 | 24 | |
25 | 25 | # Register the template path. |
26 | 26 | pluginapi.register_template_path(os.path.join(PLUGIN_DIR, 'templates')) |
-
diff --git a/mediagoblin/plugins/ldap/__init__.py b/mediagoblin/plugins/ldap/__init__.py
index 4673acee..5a5d3b8f 100644
a
|
b
|
PLUGIN_DIR = os.path.dirname(__file__)
|
22 | 22 | |
23 | 23 | |
24 | 24 | def setup_plugin(): |
25 | | config = pluginapi.get_config('mediagoblin.plugins.ldap') |
| 25 | pluginapi.get_config('mediagoblin.plugins.ldap') |
26 | 26 | |
27 | 27 | routes = [ |
28 | 28 | ('mediagoblin.plugins.ldap.register', |
-
diff --git a/mediagoblin/plugins/openid/__init__.py b/mediagoblin/plugins/openid/__init__.py
index b26087a2..7748d89c 100644
a
|
b
|
PLUGIN_DIR = os.path.dirname(__file__)
|
28 | 28 | |
29 | 29 | |
30 | 30 | def setup_plugin(): |
31 | | config = pluginapi.get_config('mediagoblin.plugins.openid') |
| 31 | pluginapi.get_config('mediagoblin.plugins.openid') |
32 | 32 | |
33 | 33 | routes = [ |
34 | 34 | ('mediagoblin.plugins.openid.register', |
-
diff --git a/mediagoblin/plugins/persona/__init__.py b/mediagoblin/plugins/persona/__init__.py
index 8fab726a..6920c044 100644
a
|
b
|
PLUGIN_DIR = os.path.dirname(__file__)
|
29 | 29 | |
30 | 30 | |
31 | 31 | def setup_plugin(): |
32 | | config = pluginapi.get_config('mediagoblin.plugins.persona') |
| 32 | pluginapi.get_config('mediagoblin.plugins.persona') |
33 | 33 | |
34 | 34 | routes = [ |
35 | 35 | ('mediagoblin.plugins.persona.login', |
-
diff --git a/mediagoblin/processing/task.py b/mediagoblin/processing/task.py
index bedfd32d..37c2e226 100644
a
|
b
|
def handle_push_urls(feed_url):
|
49 | 49 | for huburl in mgg.app_config["push_urls"]: |
50 | 50 | hubrequest = request.Request(huburl, hubdata, hubheaders) |
51 | 51 | try: |
52 | | hubresponse = request.urlopen(hubrequest) |
| 52 | request.urlopen(hubrequest) |
53 | 53 | except (request.HTTPError, request.URLError) as exc: |
54 | 54 | # We retry by default 3 times before failing |
55 | 55 | _log.info("PuSH url %r gave error %r", huburl, exc) |
-
diff --git a/mediagoblin/tests/test_api.py b/mediagoblin/tests/test_api.py
index 90873cb9..3bcbd872 100644
a
|
b
|
class TestAPI(object):
|
286 | 286 | request = test_app.get(object_uri) |
287 | 287 | |
288 | 288 | image = json.loads(request.body.decode()) |
289 | | entry = MediaEntry.query.filter_by(public_id=image["id"]).first() |
| 289 | MediaEntry.query.filter_by(public_id=image["id"]).first() |
290 | 290 | |
291 | 291 | assert request.status_code == 200 |
292 | 292 | |
… |
… |
class TestAPI(object):
|
432 | 432 | def test_whoami_without_login(self, test_app): |
433 | 433 | """ Test that whoami endpoint returns error when not logged in """ |
434 | 434 | with pytest.raises(AppError) as excinfo: |
435 | | response = test_app.get("/api/whoami") |
| 435 | test_app.get("/api/whoami") |
436 | 436 | |
437 | 437 | assert "401 UNAUTHORIZED" in excinfo.value.args[0] |
438 | 438 | |
… |
… |
class TestAPI(object):
|
622 | 622 | |
623 | 623 | # Verify the comment no longer exists |
624 | 624 | assert TextComment.query.filter_by(public_id=comment["object"]["id"]).first() is None |
625 | | comment_id = comment["object"]["id"] |
626 | 625 | |
627 | 626 | # Check we've got a delete activity back |
628 | 627 | assert "id" in delete |
-
diff --git a/mediagoblin/tests/test_collections.py b/mediagoblin/tests/test_collections.py
index 87782f30..68dd8c9e 100644
a
|
b
|
from mediagoblin.db.models import Collection, User
|
21 | 21 | def test_user_deletes_collection(test_app): |
22 | 22 | # Setup db. |
23 | 23 | user = fixture_add_user() |
24 | | coll = fixture_add_collection(user=user) |
| 24 | fixture_add_collection(user=user) |
25 | 25 | # Reload into session: |
26 | 26 | user = User.query.get(user.id) |
27 | 27 | |
-
diff --git a/mediagoblin/tests/test_edit.py b/mediagoblin/tests/test_edit.py
index 632c8e3c..8dbe51be 100644
a
|
b
|
class TestUserEdit(object):
|
46 | 46 | # Make sure user exists |
47 | 47 | assert LocalUser.query.filter(LocalUser.username==u'chris').first() |
48 | 48 | |
49 | | res = test_app.post('/edit/account/delete/', {'confirmed': 'y'}) |
| 49 | test_app.post('/edit/account/delete/', {'confirmed': 'y'}) |
50 | 50 | |
51 | 51 | # Make sure user has been deleted |
52 | 52 | assert LocalUser.query.filter(LocalUser.username==u'chris').first() == None |
-
diff --git a/mediagoblin/tests/test_notifications.py b/mediagoblin/tests/test_notifications.py
index 776bfc71..bbffc074 100644
a
|
b
|
class TestNotifications:
|
83 | 83 | |
84 | 84 | media_entry = fixture_media_entry(uploader=user.id, state=u'processed') |
85 | 85 | |
86 | | media_entry_id = media_entry.id |
87 | | |
88 | 86 | subscription = fixture_comment_subscription(media_entry) |
89 | 87 | |
90 | 88 | subscription_id = subscription.id |
-
diff --git a/mediagoblin/tests/test_openid.py b/mediagoblin/tests/test_openid.py
index 71767032..f318473c 100644
a
|
b
|
class TestOpenIDPlugin(object):
|
264 | 264 | |
265 | 265 | # Try and delete only OpenID url |
266 | 266 | template.clear_test_template_context() |
267 | | res = openid_plugin_app.post( |
| 267 | openid_plugin_app.post( |
268 | 268 | '/edit/openid/delete/', { |
269 | 269 | 'openid': 'http://real.myopenid.com'}) |
270 | 270 | assert 'mediagoblin/plugins/openid/delete.html' in template.TEMPLATE_TEST_CONTEXT |
… |
… |
class TestOpenIDPlugin(object):
|
272 | 272 | # Add OpenID to user |
273 | 273 | # Empty form |
274 | 274 | template.clear_test_template_context() |
275 | | res = openid_plugin_app.post( |
276 | | '/edit/openid/', {}) |
| 275 | openid_plugin_app.post('/edit/openid/', {}) |
277 | 276 | context = template.TEMPLATE_TEST_CONTEXT['mediagoblin/plugins/openid/add.html'] |
278 | 277 | form = context['form'] |
279 | 278 | assert form.openid.errors == [u'This field is required.'] |
-
diff --git a/mediagoblin/tests/test_privileges.py b/mediagoblin/tests/test_privileges.py
index 2e0b7347..3ad6cd0c 100644
a
|
b
|
class TestPrivilegeFunctionality:
|
146 | 146 | media_entry = fixture_media_entry(uploader=self.admin_user.id, |
147 | 147 | state=u'processed') |
148 | 148 | |
149 | | media_entry_id = media_entry.id |
150 | 149 | media_uri_id = '/u/{0}/m/{1}/'.format(self.admin_user.username, |
151 | 150 | media_entry.id) |
152 | 151 | media_uri_slug = '/u/{0}/m/{1}/'.format(self.admin_user.username, |
-
diff --git a/mediagoblin/tests/test_reporting.py b/mediagoblin/tests/test_reporting.py
index 803fc849..f5473db5 100644
a
|
b
|
class TestReportFiling:
|
66 | 66 | media_entry = fixture_media_entry(uploader=natalie_user.id, |
67 | 67 | state=u'processed') |
68 | 68 | |
69 | | mid = media_entry.id |
70 | 69 | media_uri_slug = '/u/{0}/m/{1}/'.format(natalie_user.username, |
71 | 70 | media_entry.slug) |
72 | 71 | |
… |
… |
class TestReportFiling:
|
95 | 94 | |
96 | 95 | media_entry = fixture_media_entry(uploader=natalie_user.id, |
97 | 96 | state=u'processed') |
98 | | mid = media_entry.id |
99 | 97 | fixture_add_comment( |
100 | 98 | media_entry=media_entry, |
101 | 99 | author=natalie_user.id |
-
diff --git a/mediagoblin/tests/test_sql_migrations.py b/mediagoblin/tests/test_sql_migrations.py
index 97d7da09..ad2e4a26 100644
a
|
b
|
def creature_powers_new_table(db_conn):
|
141 | 141 | |
142 | 142 | # We have to access the creature table so sqlalchemy can make the |
143 | 143 | # foreign key relationship |
144 | | creature_table = Table( |
145 | | 'creature', metadata, |
146 | | autoload=True, autoload_with=db_conn.bind) |
147 | | |
148 | | creature_powers = Table( |
149 | | 'creature_power', metadata, |
150 | | Column('id', Integer, primary_key=True), |
151 | | Column('creature', |
152 | | Integer, ForeignKey('creature.id'), nullable=False), |
153 | | Column('name', Unicode), |
154 | | Column('description', Unicode), |
155 | | Column('hitpower', Integer, nullable=False)) |
| 144 | Table('creature', metadata, autoload=True, autoload_with=db_conn.bind) |
| 145 | |
| 146 | Table('creature_power', metadata, |
| 147 | Column('id', Integer, primary_key=True), |
| 148 | Column('creature', |
| 149 | Integer, ForeignKey('creature.id'), nullable=False), |
| 150 | Column('name', Unicode), |
| 151 | Column('description', Unicode), |
| 152 | Column('hitpower', Integer, nullable=False)) |
156 | 153 | metadata.create_all(db_conn.bind) |
157 | 154 | |
158 | 155 | |
… |
… |
def creature_power_hitpower_to_float(db_conn):
|
314 | 311 | |
315 | 312 | # We have to access the creature table so sqlalchemy can make the |
316 | 313 | # foreign key relationship |
317 | | creature_table = Table( |
318 | | 'creature', metadata, |
319 | | autoload=True, autoload_with=db_conn.bind) |
| 314 | Table('creature', metadata, autoload=True, autoload_with=db_conn.bind) |
320 | 315 | |
321 | 316 | creature_power = Table( |
322 | 317 | 'creature_power', metadata, |
-
diff --git a/mediagoblin/tests/test_storage.py b/mediagoblin/tests/test_storage.py
index a4c3e4eb..ec1f6046 100644
a
|
b
|
def test_basic_storage_get_file():
|
190 | 190 | assert our_file.read() == 'Second file' |
191 | 191 | |
192 | 192 | # Read from an existing file |
193 | | manually_written_file = os.makedirs( |
194 | | os.path.join(tmpdir, 'testydir')) |
| 193 | os.makedirs(os.path.join(tmpdir, 'testydir')) |
195 | 194 | with open(os.path.join(tmpdir, 'testydir/testyfile.txt'), 'w') as testyfile: |
196 | 195 | testyfile.write('testy file! so testy.') |
197 | 196 | |
-
diff --git a/mediagoblin/tests/test_video.py b/mediagoblin/tests/test_video.py
index 79244515..0bffe9a8 100644
a
|
b
|
def create_data(suffix=None, make_audio=False):
|
67 | 67 | state = pipeline.get_state(3 * Gst.SECOND) |
68 | 68 | assert state[0] == Gst.StateChangeReturn.SUCCESS |
69 | 69 | bus = pipeline.get_bus() |
70 | | message = bus.timed_pop_filtered( |
71 | | 3 * Gst.SECOND, |
72 | | Gst.MessageType.ERROR | Gst.MessageType.EOS) |
| 70 | bus.timed_pop_filtered( |
| 71 | 3 * Gst.SECOND, |
| 72 | Gst.MessageType.ERROR | Gst.MessageType.EOS) |
73 | 73 | pipeline.set_state(Gst.State.NULL) |
74 | 74 | if suffix: |
75 | 75 | result = tempfile.NamedTemporaryFile(suffix=suffix) |
-
diff --git a/mediagoblin/user_pages/views.py b/mediagoblin/user_pages/views.py
index b4737ea8..9b30dd22 100644
a
|
b
|
def collection_item_confirm_remove(request, collection_item):
|
441 | 441 | form = user_forms.ConfirmCollectionItemRemoveForm(request.form) |
442 | 442 | |
443 | 443 | if request.method == 'POST' and form.validate(): |
444 | | username = collection_item.in_collection.get_actor.username |
445 | 444 | collection = collection_item.in_collection |
446 | 445 | |
447 | 446 | if form.confirm.data is True: |