mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-12 22:25:44 -04:00
fix lgtm alerts
This commit is contained in:
parent
46a4197514
commit
106f6adc59
2 changed files with 10 additions and 11 deletions
|
@ -83,7 +83,7 @@ def output_hidden(show_failing=True):
|
||||||
sys.stderr.close()
|
sys.stderr.close()
|
||||||
sys.stdout = stdout
|
sys.stdout = stdout
|
||||||
sys.stderr = stderr
|
sys.stderr = stderr
|
||||||
except:
|
except Exception:
|
||||||
sys.stdout.close()
|
sys.stdout.close()
|
||||||
sys.stderr.close()
|
sys.stderr.close()
|
||||||
sys.stdout = stdout
|
sys.stdout = stdout
|
||||||
|
@ -132,7 +132,7 @@ class TestInit(unittest.TestCase):
|
||||||
try:
|
try:
|
||||||
load_main_index(out_dir=OUTPUT_DIR)
|
load_main_index(out_dir=OUTPUT_DIR)
|
||||||
assert False, 'load_main_index should raise an exception when no index is present'
|
assert False, 'load_main_index should raise an exception when no index is present'
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def test_no_dirty_state(self):
|
def test_no_dirty_state(self):
|
||||||
|
@ -216,7 +216,7 @@ class TestRemove(unittest.TestCase):
|
||||||
with output_hidden(show_failing=False):
|
with output_hidden(show_failing=False):
|
||||||
archivebox_remove.main(['--yes', '--delete', 'https://doesntexist.com'])
|
archivebox_remove.main(['--yes', '--delete', 'https://doesntexist.com'])
|
||||||
assert False, 'Should raise if no URLs match'
|
assert False, 'Should raise if no URLs match'
|
||||||
except:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -201,46 +201,46 @@ class SnapshotAdmin(SearchResultsAdminMixin, admin.ModelAdmin):
|
||||||
return rendered_response
|
return rendered_response
|
||||||
|
|
||||||
|
|
||||||
def update_snapshots(modeladmin, request, queryset):
|
def update_snapshots(self, request, queryset):
|
||||||
archive_links([
|
archive_links([
|
||||||
snapshot.as_link()
|
snapshot.as_link()
|
||||||
for snapshot in queryset
|
for snapshot in queryset
|
||||||
], out_dir=OUTPUT_DIR)
|
], out_dir=OUTPUT_DIR)
|
||||||
update_snapshots.short_description = "Archive"
|
update_snapshots.short_description = "Archive"
|
||||||
|
|
||||||
def update_titles(modeladmin, request, queryset):
|
def update_titles(self, request, queryset):
|
||||||
archive_links([
|
archive_links([
|
||||||
snapshot.as_link()
|
snapshot.as_link()
|
||||||
for snapshot in queryset
|
for snapshot in queryset
|
||||||
], overwrite=True, methods=('title','favicon'), out_dir=OUTPUT_DIR)
|
], overwrite=True, methods=('title','favicon'), out_dir=OUTPUT_DIR)
|
||||||
update_titles.short_description = "Pull title"
|
update_titles.short_description = "Pull title"
|
||||||
|
|
||||||
def overwrite_snapshots(modeladmin, request, queryset):
|
def overwrite_snapshots(self, request, queryset):
|
||||||
archive_links([
|
archive_links([
|
||||||
snapshot.as_link()
|
snapshot.as_link()
|
||||||
for snapshot in queryset
|
for snapshot in queryset
|
||||||
], overwrite=True, out_dir=OUTPUT_DIR)
|
], overwrite=True, out_dir=OUTPUT_DIR)
|
||||||
overwrite_snapshots.short_description = "Re-archive (overwrite)"
|
overwrite_snapshots.short_description = "Re-archive (overwrite)"
|
||||||
|
|
||||||
def verify_snapshots(modeladmin, request, queryset):
|
def verify_snapshots(self, request, queryset):
|
||||||
for snapshot in queryset:
|
for snapshot in queryset:
|
||||||
print(snapshot.timestamp, snapshot.url, snapshot.is_archived, snapshot.archive_size, len(snapshot.history))
|
print(snapshot.timestamp, snapshot.url, snapshot.is_archived, snapshot.archive_size, len(snapshot.history))
|
||||||
|
|
||||||
verify_snapshots.short_description = "Check"
|
verify_snapshots.short_description = "Check"
|
||||||
|
|
||||||
def delete_snapshots(modeladmin, request, queryset):
|
def delete_snapshots(self, request, queryset):
|
||||||
remove(snapshots=queryset, yes=True, delete=True, out_dir=OUTPUT_DIR)
|
remove(snapshots=queryset, yes=True, delete=True, out_dir=OUTPUT_DIR)
|
||||||
|
|
||||||
delete_snapshots.short_description = "Delete"
|
delete_snapshots.short_description = "Delete"
|
||||||
|
|
||||||
def add_tag(modeladmin, request, queryset):
|
def add_tag(self, request, queryset):
|
||||||
tag = request.POST['tag']
|
tag = request.POST['tag']
|
||||||
for obj in queryset:
|
for obj in queryset:
|
||||||
obj.tags.add(tag)
|
obj.tags.add(tag)
|
||||||
|
|
||||||
add_tag.short_description = "Add tag"
|
add_tag.short_description = "Add tag"
|
||||||
|
|
||||||
def remove_tag(modeladmin, request, queryset):
|
def remove_tag(self, request, queryset):
|
||||||
tag = request.POST['tag']
|
tag = request.POST['tag']
|
||||||
for obj in queryset:
|
for obj in queryset:
|
||||||
obj.tags.remove(tag)
|
obj.tags.remove(tag)
|
||||||
|
@ -286,7 +286,6 @@ class TagAdmin(admin.ModelAdmin):
|
||||||
)
|
)
|
||||||
for snap in obj.snapshot_set.order_by('-updated')[:10]
|
for snap in obj.snapshot_set.order_by('-updated')[:10]
|
||||||
) + (f'<br/><a href="/admin/core/snapshot/?tags__id__exact={obj.id}">and {total_count-10} more...<a>' if obj.snapshot_set.count() > 10 else ''))
|
) + (f'<br/><a href="/admin/core/snapshot/?tags__id__exact={obj.id}">and {total_count-10} more...<a>' if obj.snapshot_set.count() > 10 else ''))
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
class ArchiveResultAdmin(admin.ModelAdmin):
|
class ArchiveResultAdmin(admin.ModelAdmin):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue