Skip to content

Commit

Permalink
run isort on scripts folder
Browse files Browse the repository at this point in the history
  • Loading branch information
RayBB committed Nov 27, 2024
1 parent 97ea3c1 commit 694bd37
Show file tree
Hide file tree
Showing 33 changed files with 70 additions and 63 deletions.
2 changes: 1 addition & 1 deletion scripts/_init_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"""

import os
from os.path import abspath, realpath, join, dirname, pardir
import sys
from os.path import abspath, dirname, join, pardir, realpath

path = __file__.replace('.pyc', '.py')
scripts_root = dirname(realpath(path))
Expand Down
6 changes: 2 additions & 4 deletions scripts/affiliate_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,16 @@
import sys
import threading
import time

from collections.abc import Callable, Collection
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
from typing import Any, Final

import _init_path # noqa: F401 Imported for its side effect of setting PYTHONPATH
import requests
import web

import _init_path # noqa: F401 Imported for its side effect of setting PYTHONPATH

import infogami
from infogami import config
from openlibrary.config import load_config as openlibrary_load_config
Expand All @@ -61,8 +59,8 @@
from openlibrary.core.vendors import AmazonAPI, clean_amazon_metadata_for_load
from openlibrary.utils.dateutil import WEEK_SECS
from openlibrary.utils.isbn import (
normalize_identifier,
isbn_10_to_isbn_13,
normalize_identifier,
)

logger = logging.getLogger("affiliate-server")
Expand Down
2 changes: 1 addition & 1 deletion scripts/copydocs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#!/usr/bin/env python
from __future__ import annotations
from collections import namedtuple

import json
import os
import sys
from collections import namedtuple
from collections.abc import Iterator

import web
Expand Down
3 changes: 1 addition & 2 deletions scripts/delete_import_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@

import argparse
import time

from configparser import ConfigParser
from pathlib import Path

import _init_path # noqa: F401 Imported for its side effect of setting PYTHONPATH

from openlibrary.config import load_config
from openlibrary.core.imports import ImportItem
from openlibrary.core.edits import (
CommunityEditsQueue, # noqa: F401 side effects may be needed
)
from openlibrary.core.imports import ImportItem


class DeleteImportItemJob:
Expand Down
8 changes: 5 additions & 3 deletions scripts/detect_missing_i18n.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
#!/usr/bin/env python
"""Utility script to list html files which might be missing i18n strings."""
import _init_path # noqa: F401 Imported for its side effect of setting PYTHONPATH
import glob
import re
import sys
from pathlib import Path
from enum import Enum
from pathlib import Path

import _init_path # noqa: F401 Imported for its side effect of setting PYTHONPATH

from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI
import glob

# This is a list of files that are intentionally excluded from the i18n process
EXCLUDE_LIST = {
Expand Down
3 changes: 2 additions & 1 deletion scripts/generate-api-docs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import web
import os
import re
import shutil
from collections import defaultdict

import web

template = """\
$def with (mod, submodules)
$ name = mod.split(".")[-1]
Expand Down
1 change: 0 additions & 1 deletion scripts/gh_scripts/issue_comment_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import os
import sys
import time

from datetime import datetime, timedelta
from typing import Any

Expand Down
8 changes: 5 additions & 3 deletions scripts/import_open_textbook_library.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
#!/usr/bin/env python
import json
import requests
import time
from collections.abc import Generator
from itertools import islice
from typing import Any
from collections.abc import Generator

import requests

from openlibrary.config import load_config
from openlibrary.core.imports import Batch
from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI
from openlibrary.config import load_config

FEED_URL = 'https://open.umn.edu/opentextbooks/textbooks.json?'

Expand Down
5 changes: 3 additions & 2 deletions scripts/import_pressbooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
PYTHONPATH=. python ./scripts/import_pressbooks.py /olsystem/etc/openlibrary.yml ./path/to/pressbooks.json
"""

import json
import datetime
import html
import json
import logging

import requests
import html

from infogami import config # noqa: F401 side effects may be needed
from openlibrary.config import load_config
Expand Down
8 changes: 4 additions & 4 deletions scripts/import_standard_ebooks.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/usr/bin/env python
import json
import requests
from requests.auth import AuthBase, HTTPBasicAuth
import time
from typing import Any

import feedparser
import requests
from requests.auth import AuthBase, HTTPBasicAuth

from infogami import config
from openlibrary.config import load_config
from openlibrary.core.imports import Batch
from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI
from openlibrary.config import load_config
from infogami import config

FEED_URL = 'https://standardebooks.org/opds/all'
IMAGE_REL = 'http://opds-spec.org/image'
Expand Down
16 changes: 9 additions & 7 deletions scripts/lc_marc_update.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
#!/usr/bin/env python

from openlibrary.catalog.importer.scribe import BadImport
from openlibrary.catalog.read_rc import read_rc # noqa: F401 side effects may be needed
from openlibrary import config
import argparse
import json
import sys
from ftplib import FTP
from time import sleep
from lxml import etree
import sys

import httplib
import json
import argparse
import lxml.etree
from lxml import etree

from openlibrary import config
from openlibrary.catalog.importer.scribe import BadImport
from openlibrary.catalog.read_rc import read_rc # noqa: F401 side effects may be needed

parser = argparse.ArgumentParser(description='Library of Congress MARC update')
parser.add_argument('--config', default='openlibrary.yml')
Expand Down
3 changes: 2 additions & 1 deletion scripts/mail_bad_author_query.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/usr/bin/env python
import web
import os
import smtplib
import sys
from email.mime.text import MIMEText

import web

password = open(os.path.expanduser('~/.openlibrary_db_password')).read()
if password.endswith('\n'):
password = password[:-1]
Expand Down
3 changes: 1 addition & 2 deletions scripts/obfi/hide.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
import os
import struct
import sys
from typing import Final
import urllib.request

from typing import Final

SEED_PATH: Final = os.getenv("SEED_PATH", "")
if not SEED_PATH:
Expand Down
2 changes: 1 addition & 1 deletion scripts/obfi/mktable.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
import struct
import sys
import time
from typing import Final
import urllib.request
from typing import Final

SEED_PATH: Final = os.getenv("SEED_PATH", "")
if not SEED_PATH:
Expand Down
3 changes: 1 addition & 2 deletions scripts/oclc_to_marc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
Usage: python oclc_to_marc.py oclc_1 oclc_2
"""

import requests

import urllib

import requests

root = "https://openlibrary.org"

Expand Down
1 change: 1 addition & 0 deletions scripts/oldump.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def log(*args) -> None:

if __name__ == "__main__":
from contextlib import redirect_stdout

from infogami import config
from openlibrary.config import load_config
from openlibrary.data import dump
Expand Down
2 changes: 1 addition & 1 deletion scripts/partner_batch_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
PYTHONPATH=. python ./scripts/partner_batch_imports.py /olsystem/etc/openlibrary.yml
"""

from collections.abc import Mapping
import datetime
import logging
import os
import re
from collections.abc import Mapping
from typing import cast

import requests
Expand Down
3 changes: 2 additions & 1 deletion scripts/pr_slack_digest.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
from datetime import datetime

import requests
import os


def send_slack_message(message: str):
Expand Down
7 changes: 4 additions & 3 deletions scripts/promise_batch_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@
"""

from __future__ import annotations

import datetime
import json
import ijson
import requests
import logging

from typing import Any
from urllib.parse import urlencode

import _init_path # noqa: F401 Imported for its side effect of setting PYTHONPATH
import ijson
import requests

from infogami import config # noqa: F401 side effects may be needed
from openlibrary.config import load_config
from openlibrary.core import stats
Expand Down
6 changes: 3 additions & 3 deletions scripts/providers/isbndb.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import re
import json
import logging
import os
import re
from json import JSONDecodeError
from typing import Any, Final
import requests

from json import JSONDecodeError
import requests

from openlibrary.config import load_config
from openlibrary.core.imports import Batch
Expand Down
6 changes: 3 additions & 3 deletions scripts/pull-templates.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env python
"""Script to pull templates and macros from an openlibrary instance to repository.
"""
import _init_path # noqa: F401 Imported for its side effect of setting PYTHONPATH

import os
import web
from optparse import OptionParser

import _init_path # noqa: F401 Imported for its side effect of setting PYTHONPATH
import web

from openlibrary.api import OpenLibrary, marshal


Expand Down
3 changes: 2 additions & 1 deletion scripts/solr_builder/setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from pathlib import Path
from setuptools import setup

from Cython.Build import cythonize
from setuptools import setup

setup(
py_modules=['solr_builder'],
Expand Down
4 changes: 2 additions & 2 deletions scripts/solr_builder/solr_builder/fn_to_cli.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import asyncio
from pathlib import Path
import types
import typing
from argparse import (
ArgumentParser,
ArgumentDefaultsHelpFormatter,
ArgumentParser,
BooleanOptionalAction,
Namespace,
)
from pathlib import Path


class FnToCLI:
Expand Down
2 changes: 1 addition & 1 deletion scripts/solr_builder/solr_builder/solr_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

import json
import logging
from pathlib import Path
import time
import uuid
from collections import namedtuple
from collections.abc import Awaitable, Iterator
from configparser import ConfigParser
from pathlib import Path
from typing import Any, Literal, Self

import aiofiles
Expand Down
3 changes: 2 additions & 1 deletion scripts/solr_builder/tests/test_fn_to_cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import typing
from argparse import BooleanOptionalAction
from pathlib import Path
import typing

from scripts.solr_builder.solr_builder.fn_to_cli import FnToCLI


Expand Down
2 changes: 1 addition & 1 deletion scripts/solr_dump_xisbn.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
"""
import asyncio
import sys
from typing import Literal
from collections.abc import AsyncGenerator
from typing import Literal

import httpx

Expand Down
Loading

0 comments on commit 694bd37

Please sign in to comment.