formatting change. replaced setuptools with poetry

This commit is contained in:
Eddy Hintze
2024-07-31 19:59:58 -04:00
parent e6fa9e93ee
commit 623a64d501
12 changed files with 1037 additions and 251 deletions

View File

@@ -5,17 +5,17 @@ import argparse
logger = logging.getLogger(__name__)
LOG_LEVEL = os.environ.get('HBD_LOGLEVEL', 'INFO').upper()
LOG_LEVEL = os.environ.get("HBD_LOGLEVEL", "INFO").upper()
logging.basicConfig(
level=LOG_LEVEL,
format='%(message)s',
format="%(message)s",
)
# Ignore unwanted logs from the requests lib when debuging
logging.getLogger('urllib3.connectionpool').setLevel(logging.WARNING)
logging.getLogger("urllib3.connectionpool").setLevel(logging.WARNING)
def parse_args(args):
if len(args) > 0 and args[0].lower() == 'download':
if len(args) > 0 and args[0].lower() == "download":
args = args[1:]
raise DeprecationWarning("`download` argument is no longer used")
@@ -23,55 +23,75 @@ def parse_args(args):
cookie = parser.add_mutually_exclusive_group(required=True)
cookie.add_argument(
'-c', '--cookie-file', type=str,
"-c",
"--cookie-file",
type=str,
help="Location of the cookies file",
)
cookie.add_argument(
'-s', '--session-auth', type=str,
"-s",
"--session-auth",
type=str,
help="Value of the cookie _simpleauth_sess. WRAP IN QUOTES",
)
parser.add_argument(
'-l', '--library-path', type=str,
"-l",
"--library-path",
type=str,
help="Folder to download all content to",
required=True,
)
parser.add_argument(
'-t', '--trove', action='store_true',
"-t",
"--trove",
action="store_true",
help="Only check and download Humble Trove content",
)
parser.add_argument(
'-u', '--update', action='store_true',
help=("Check to see if products have been updated "
"(still get new products)"),
"-u",
"--update",
action="store_true",
help=("Check to see if products have been updated " "(still get new products)"),
)
parser.add_argument(
'-p', '--platform',
type=str, nargs='*',
help=("Only get content in a platform. Values can be seen in your "
"humble bundle's library dropdown. Ex: -p ebook video"),
"-p",
"--platform",
type=str,
nargs="*",
help=(
"Only get content in a platform. Values can be seen in your "
"humble bundle's library dropdown. Ex: -p ebook video"
),
)
parser.add_argument(
'--progress',
action='store_true',
"--progress",
action="store_true",
help="Display progress bar for downloads",
)
filter_ext = parser.add_mutually_exclusive_group()
filter_ext.add_argument(
'-e', '--exclude',
type=str, nargs='*',
help=("File extensions to ignore when downloading files. "
"Ex: -e pdf mobi"),
"-e",
"--exclude",
type=str,
nargs="*",
help=("File extensions to ignore when downloading files. " "Ex: -e pdf mobi"),
)
filter_ext.add_argument(
'-i', '--include',
type=str, nargs='*',
"-i",
"--include",
type=str,
nargs="*",
help="Only download files with these extensions. Ex: -i pdf mobi",
)
parser.add_argument(
'-k', '--keys',
type=str, nargs='*',
help=("The purchase download key. Find in the url on the "
"products/bundle download page. Can set multiple"),
"-k",
"--keys",
type=str,
nargs="*",
help=(
"The purchase download key. Find in the url on the "
"products/bundle download page. Can set multiple"
),
)
return parser.parse_args(args)
@@ -81,6 +101,7 @@ def cli():
cli_args = parse_args(sys.argv[1:])
from .download_library import DownloadLibrary
DownloadLibrary(
cli_args.library_path,
cookie_path=cli_args.cookie_file,