mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 23:54:27 -04:00
lint: Remove unused imports around the app
This commit is contained in:
parent
13c3650637
commit
91f543ff8d
14 changed files with 30 additions and 28 deletions
|
@ -348,3 +348,6 @@ class ArchiveResult(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.extractor
|
return self.extractor
|
||||||
|
|
||||||
|
class Meta:
|
||||||
|
ordering = ["-start_ts"]
|
||||||
|
|
|
@ -5,10 +5,8 @@ from pathlib import Path
|
||||||
|
|
||||||
from typing import Optional, List, Iterable, Union
|
from typing import Optional, List, Iterable, Union
|
||||||
|
|
||||||
from datetime import datetime
|
|
||||||
from django.db.models import QuerySet, Model
|
from django.db.models import QuerySet, Model
|
||||||
|
|
||||||
from ..index.sql import write_snapshot_to_index
|
|
||||||
from ..index import (
|
from ..index import (
|
||||||
load_snapshot_details,
|
load_snapshot_details,
|
||||||
write_snapshot_details,
|
write_snapshot_details,
|
||||||
|
@ -17,10 +15,9 @@ from ..util import enforce_types
|
||||||
from ..logging_util import (
|
from ..logging_util import (
|
||||||
log_archiving_started,
|
log_archiving_started,
|
||||||
log_archiving_paused,
|
log_archiving_paused,
|
||||||
|
|
||||||
log_archiving_finished,
|
log_archiving_finished,
|
||||||
log_link_archiving_started,
|
log_snapshot_archiving_started,
|
||||||
log_link_archiving_finished,
|
log_snapshot_archiving_finished,
|
||||||
log_archive_method_started,
|
log_archive_method_started,
|
||||||
log_archive_method_finished,
|
log_archive_method_finished,
|
||||||
)
|
)
|
||||||
|
@ -91,7 +88,7 @@ def archive_snapshot(snapshot: Model, overwrite: bool=False, methods: Optional[I
|
||||||
details = snapshot.details #TODO: This can be retrieved from the sqlite database too.
|
details = snapshot.details #TODO: This can be retrieved from the sqlite database too.
|
||||||
# If that makes more sense, it can be easily changed.
|
# If that makes more sense, it can be easily changed.
|
||||||
|
|
||||||
#log_link_archiving_started(link, out_dir, is_new)
|
log_snapshot_archiving_started(snapshot, out_dir, is_new)
|
||||||
stats = {'skipped': 0, 'succeeded': 0, 'failed': 0}
|
stats = {'skipped': 0, 'succeeded': 0, 'failed': 0}
|
||||||
|
|
||||||
for method_name, should_run, method_function in ARCHIVE_METHODS:
|
for method_name, should_run, method_function in ARCHIVE_METHODS:
|
||||||
|
@ -122,15 +119,17 @@ def archive_snapshot(snapshot: Model, overwrite: bool=False, methods: Optional[I
|
||||||
# print(' ', stats)
|
# print(' ', stats)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
latest_title = link.history['title'][-1].output.strip()
|
latest_title_archive_result = snapshot.archiveresult_set.filter(extractor="title")
|
||||||
if latest_title and len(latest_title) >= len(link.title or ''):
|
if latest_title_archive_result.count() > 0:
|
||||||
|
latest_title = latest_title_archive_result.output.strip()
|
||||||
|
if len(latest_title) >= len(snapshot.title or ''):
|
||||||
snapshot.title = latest_title
|
snapshot.title = latest_title
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
write_snapshot_details(snapshot, out_dir=out_dir, skip_sql_index=False)
|
write_snapshot_details(snapshot, out_dir=out_dir, skip_sql_index=False)
|
||||||
|
|
||||||
log_link_archiving_finished(snapshot, snapshot.snapshot_dir, is_new, stats)
|
log_snapshot_archiving_finished(snapshot, snapshot.snapshot_dir, is_new, stats)
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -7,7 +7,7 @@ from collections import defaultdict
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveOutput, ArchiveError
|
from ..index.schema import ArchiveResult, ArchiveOutput, ArchiveError
|
||||||
from ..system import run, chmod_file
|
from ..system import run, chmod_file
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Optional
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveOutput, ArchiveError
|
from ..index.schema import ArchiveResult, ArchiveOutput, ArchiveError
|
||||||
from ..system import run, chmod_file, atomic_write
|
from ..system import run, chmod_file, atomic_write
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -6,7 +6,7 @@ from typing import Optional
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveOutput
|
from ..index.schema import ArchiveResult, ArchiveOutput
|
||||||
from ..system import chmod_file, run
|
from ..system import chmod_file, run
|
||||||
from ..util import enforce_types, domain
|
from ..util import enforce_types, domain
|
||||||
from ..config import (
|
from ..config import (
|
||||||
|
|
|
@ -6,7 +6,7 @@ from typing import Optional
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveOutput, ArchiveError
|
from ..index.schema import ArchiveResult, ArchiveOutput, ArchiveError
|
||||||
from ..system import run, chmod_file
|
from ..system import run, chmod_file
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -6,7 +6,7 @@ from typing import Optional
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveOutput
|
from ..index.schema import ArchiveResult, ArchiveOutput
|
||||||
from ..system import atomic_write
|
from ..system import atomic_write
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Optional
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveOutput, ArchiveError
|
from ..index.schema import ArchiveResult, ArchiveOutput, ArchiveError
|
||||||
from ..system import run, chmod_file
|
from ..system import run, chmod_file
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import json
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveError
|
from ..index.schema import ArchiveResult, ArchiveError
|
||||||
from ..system import run, atomic_write
|
from ..system import run, atomic_write
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Optional
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveOutput, ArchiveError
|
from ..index.schema import ArchiveResult, ArchiveOutput, ArchiveError
|
||||||
from ..system import run, chmod_file
|
from ..system import run, chmod_file
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import json
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveError
|
from ..index.schema import ArchiveResult, ArchiveError
|
||||||
from ..system import run, atomic_write
|
from ..system import run, atomic_write
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -5,7 +5,7 @@ from typing import Optional
|
||||||
|
|
||||||
from django.db.models import Model
|
from django.db.models import Model
|
||||||
|
|
||||||
from ..index.schema import Link, ArchiveResult, ArchiveOutput, ArchiveError
|
from ..index.schema import ArchiveResult, ArchiveOutput, ArchiveError
|
||||||
from ..system import run, chmod_file
|
from ..system import run, chmod_file
|
||||||
from ..util import (
|
from ..util import (
|
||||||
enforce_types,
|
enforce_types,
|
||||||
|
|
|
@ -47,10 +47,10 @@ def write_snapshot_to_index(snapshot: Model):
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
def write_sql_main_index(links: List[Link], out_dir: Path=OUTPUT_DIR) -> None:
|
def write_sql_main_index(snapshots: List[Model], out_dir: Path=OUTPUT_DIR) -> None:
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
for link in links:
|
for snapshot in snapshots:
|
||||||
write_snapshot_to_index(link)
|
write_snapshot_to_index(snapshot)
|
||||||
|
|
||||||
|
|
||||||
@enforce_types
|
@enforce_types
|
||||||
|
|
|
@ -303,7 +303,7 @@ def log_archiving_finished(num_links: int):
|
||||||
print(' archivebox server 0.0.0.0:8000')
|
print(' archivebox server 0.0.0.0:8000')
|
||||||
|
|
||||||
|
|
||||||
def log_link_archiving_started(link: "Link", link_dir: str, is_new: bool):
|
def log_snapshot_archiving_started(snapshot: Model, snapshot_dir: str, is_new: bool):
|
||||||
# [*] [2019-03-22 13:46:45] "Log Structured Merge Trees - ben stopford"
|
# [*] [2019-03-22 13:46:45] "Log Structured Merge Trees - ben stopford"
|
||||||
# http://www.benstopford.com/2015/02/14/log-structured-merge-trees/
|
# http://www.benstopford.com/2015/02/14/log-structured-merge-trees/
|
||||||
# > output/archive/1478739709
|
# > output/archive/1478739709
|
||||||
|
@ -312,16 +312,16 @@ def log_link_archiving_started(link: "Link", link_dir: str, is_new: bool):
|
||||||
symbol_color=ANSI['green' if is_new else 'black'],
|
symbol_color=ANSI['green' if is_new else 'black'],
|
||||||
symbol='+' if is_new else '√',
|
symbol='+' if is_new else '√',
|
||||||
now=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
now=datetime.now().strftime('%Y-%m-%d %H:%M:%S'),
|
||||||
title=link.title or link.base_url,
|
title=snapshot.title or snapshot.base_url,
|
||||||
**ANSI,
|
**ANSI,
|
||||||
))
|
))
|
||||||
print(' {blue}{url}{reset}'.format(url=link.url, **ANSI))
|
print(' {blue}{url}{reset}'.format(url=snapshot.url, **ANSI))
|
||||||
print(' {} {}'.format(
|
print(' {} {}'.format(
|
||||||
'>' if is_new else '√',
|
'>' if is_new else '√',
|
||||||
pretty_path(link_dir),
|
pretty_path(snapshot_dir),
|
||||||
))
|
))
|
||||||
|
|
||||||
def log_link_archiving_finished(link: "Link", link_dir: str, is_new: bool, stats: dict):
|
def log_snapshot_archiving_finished(snapshot: Model, snapshot_dir: str, is_new: bool, stats: dict):
|
||||||
total = sum(stats.values())
|
total = sum(stats.values())
|
||||||
|
|
||||||
if stats['failed'] > 0 :
|
if stats['failed'] > 0 :
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue