mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2024-11-22 04:03:06 +00:00
fix lint errors
This commit is contained in:
parent
1d9e7ec66a
commit
6a6ae7468e
12 changed files with 16 additions and 35 deletions
|
@ -2,7 +2,6 @@ __package__ = 'archivebox.api'
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
from django.contrib.auth import authenticate
|
|
||||||
from ninja import Router, Schema
|
from ninja import Router, Schema
|
||||||
|
|
||||||
from api.models import APIToken
|
from api.models import APIToken
|
||||||
|
|
|
@ -157,7 +157,7 @@ def cli_update(request, args: UpdateCommandSchema):
|
||||||
|
|
||||||
|
|
||||||
@router.post("/schedule", response=CLICommandResponseSchema, summary='archivebox schedule [args] [import_path]')
|
@router.post("/schedule", response=CLICommandResponseSchema, summary='archivebox schedule [args] [import_path]')
|
||||||
def cli_add(request, args: ScheduleCommandSchema):
|
def cli_schedule(request, args: ScheduleCommandSchema):
|
||||||
result = schedule(
|
result = schedule(
|
||||||
import_path=args.import_path,
|
import_path=args.import_path,
|
||||||
add=args.add,
|
add=args.add,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
__package__ = 'archivebox.api'
|
__package__ = 'archivebox.api'
|
||||||
|
|
||||||
from uuid import UUID
|
from uuid import UUID
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
__package__ = 'archivebox.core'
|
__package__ = 'archivebox.core'
|
||||||
|
|
||||||
import os
|
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
from ..config import (
|
from ..config import (
|
||||||
LDAP
|
LDAP
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
from django.conf import settings
|
|
||||||
from ..config import (
|
from ..config import (
|
||||||
LDAP_CREATE_SUPERUSER
|
LDAP_CREATE_SUPERUSER
|
||||||
)
|
)
|
||||||
|
|
||||||
def create_user(sender, user=None, ldap_user=None, **kwargs):
|
def create_user(sender, user=None, ldap_user=None, **kwargs):
|
||||||
|
|
||||||
if not user.id and LDAP_CREATE_SUPERUSER:
|
if not user.id and LDAP_CREATE_SUPERUSER:
|
||||||
user.is_superuser = True
|
user.is_superuser = True
|
||||||
|
|
||||||
|
|
|
@ -494,12 +494,12 @@ def log_removal_started(links: List["Link"], yes: bool, delete: bool):
|
||||||
if delete:
|
if delete:
|
||||||
file_counts = [link.num_outputs for link in links if Path(link.link_dir).exists()]
|
file_counts = [link.num_outputs for link in links if Path(link.link_dir).exists()]
|
||||||
print(
|
print(
|
||||||
f' {len(links)} Links will be de-listed from the main index, and their archived content folders will be deleted from disk.\n' +
|
f' {len(links)} Links will be de-listed from the main index, and their archived content folders will be deleted from disk.\n'
|
||||||
f' ({len(file_counts)} data folders with {sum(file_counts)} archived files will be deleted!)'
|
f' ({len(file_counts)} data folders with {sum(file_counts)} archived files will be deleted!)'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
print(
|
print(
|
||||||
' Matching links will be de-listed from the main index, but their archived content folders will remain in place on disk.\n' +
|
' Matching links will be de-listed from the main index, but their archived content folders will remain in place on disk.\n'
|
||||||
' (Pass --delete if you also want to permanently delete the data folders)'
|
' (Pass --delete if you also want to permanently delete the data folders)'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,6 @@ For examples of supported import formats see tests/.
|
||||||
|
|
||||||
__package__ = 'archivebox.parsers'
|
__package__ = 'archivebox.parsers'
|
||||||
|
|
||||||
import re
|
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
from typing import IO, Tuple, List, Optional
|
from typing import IO, Tuple, List, Optional
|
||||||
|
@ -28,7 +27,6 @@ from ..util import (
|
||||||
htmldecode,
|
htmldecode,
|
||||||
download_url,
|
download_url,
|
||||||
enforce_types,
|
enforce_types,
|
||||||
find_all_urls,
|
|
||||||
)
|
)
|
||||||
from ..index.schema import Link
|
from ..index.schema import Link
|
||||||
from ..logging_util import TimedProgress, log_source_saved
|
from ..logging_util import TimedProgress, log_source_saved
|
||||||
|
|
|
@ -72,21 +72,13 @@ def parse_generic_json_export(json_file: IO[str], **_kwargs) -> Iterable[Link]:
|
||||||
|
|
||||||
json_file.seek(0)
|
json_file.seek(0)
|
||||||
|
|
||||||
try:
|
|
||||||
links = json.load(json_file)
|
links = json.load(json_file)
|
||||||
if type(links) != list:
|
if type(links) != list:
|
||||||
raise Exception('JSON parser expects list of objects, maybe this is JSONL?')
|
raise Exception('JSON parser expects list of objects, maybe this is JSONL?')
|
||||||
except json.decoder.JSONDecodeError:
|
|
||||||
# sometimes the first line is a comment or other junk, so try without
|
|
||||||
json_file.seek(0)
|
|
||||||
first_line = json_file.readline()
|
|
||||||
#print(' > Trying JSON parser without first line: "', first_line.strip(), '"', sep= '')
|
|
||||||
links = json.load(json_file)
|
|
||||||
# we may fail again, which means we really don't know what to do
|
|
||||||
|
|
||||||
for link in links:
|
for link in links:
|
||||||
if link:
|
if link:
|
||||||
yield jsonObjectToLink(link,json_file.name)
|
yield jsonObjectToLink(link, json_file.name)
|
||||||
|
|
||||||
KEY = 'json'
|
KEY = 'json'
|
||||||
NAME = 'Generic JSON'
|
NAME = 'Generic JSON'
|
||||||
|
|
|
@ -3,11 +3,9 @@ __package__ = 'archivebox.parsers'
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from typing import IO, Iterable
|
from typing import IO, Iterable
|
||||||
from datetime import datetime, timezone
|
|
||||||
|
|
||||||
from ..index.schema import Link
|
from ..index.schema import Link
|
||||||
from ..util import (
|
from ..util import (
|
||||||
htmldecode,
|
|
||||||
enforce_types,
|
enforce_types,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
__package__ = 'archivebox.parsers'
|
__package__ = 'archivebox.parsers'
|
||||||
__description__ = 'Plain Text'
|
__description__ = 'Plain Text'
|
||||||
|
|
||||||
import re
|
|
||||||
|
|
||||||
from typing import IO, Iterable
|
from typing import IO, Iterable
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
|
@ -62,12 +62,12 @@ COLOR_REGEX = re.compile(r'\[(?P<arg_1>\d+)(;(?P<arg_2>\d+)(;(?P<arg_3>\d+))?)?m
|
||||||
|
|
||||||
# https://mathiasbynens.be/demo/url-regex
|
# https://mathiasbynens.be/demo/url-regex
|
||||||
URL_REGEX = re.compile(
|
URL_REGEX = re.compile(
|
||||||
r'(?=(' +
|
r'(?=('
|
||||||
r'http[s]?://' + # start matching from allowed schemes
|
r'http[s]?://' # start matching from allowed schemes
|
||||||
r'(?:[a-zA-Z]|[0-9]' + # followed by allowed alphanum characters
|
r'(?:[a-zA-Z]|[0-9]' # followed by allowed alphanum characters
|
||||||
r'|[-_$@.&+!*\(\),]' + # or allowed symbols (keep hyphen first to match literal hyphen)
|
r'|[-_$@.&+!*\(\),]' # or allowed symbols (keep hyphen first to match literal hyphen)
|
||||||
r'|[^\u0000-\u007F])+' + # or allowed unicode bytes
|
r'|[^\u0000-\u007F])+' # or allowed unicode bytes
|
||||||
r'[^\]\[<>"\'\s]+' + # stop parsing at these symbols
|
r'[^\]\[<>"\'\s]+' # stop parsing at these symbols
|
||||||
r'))',
|
r'))',
|
||||||
re.IGNORECASE | re.UNICODE,
|
re.IGNORECASE | re.UNICODE,
|
||||||
)
|
)
|
||||||
|
|
|
@ -15,7 +15,7 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && cd .. && pwd )"
|
||||||
source "$DIR/.venv/bin/activate"
|
source "$DIR/.venv/bin/activate"
|
||||||
|
|
||||||
echo "[*] Running flake8..."
|
echo "[*] Running flake8..."
|
||||||
cd archivebox
|
cd "$DIR/archivebox"
|
||||||
flake8 . && echo "√ No errors found."
|
flake8 . && echo "√ No errors found."
|
||||||
|
|
||||||
echo
|
echo
|
||||||
|
|
Loading…
Reference in a new issue