Skip to content

Commit

Permalink
Improve project structure for the sake of packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
mjenczmyk committed Sep 23, 2020
1 parent 93a792a commit 7133d81
Show file tree
Hide file tree
Showing 12 changed files with 19 additions and 20 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/api.py → packt/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import requests

from utils.logger import get_logger
from .utils.logger import get_logger

logger = get_logger(__name__)
logging.getLogger("requests").setLevel(logging.WARNING) # downgrading logging level for requests
Expand Down
4 changes: 2 additions & 2 deletions src/claimer.py → packt/claimer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from math import ceil
from operator import itemgetter

from api import (
from .api import (
DEFAULT_PAGINATION_SIZE,
PACKT_API_FREE_LEARNING_CLAIM_URL,
PACKT_API_FREE_LEARNING_OFFERS_URL,
PACKT_API_PRODUCTS_URL,
PACKT_API_USER_URL,
PACKT_PRODUCT_SUMMARY_URL
)
from utils.logger import get_logger
from .utils.logger import get_logger

logger = get_logger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/configuration.py → packt/configuration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import configparser
import os

from utils.logger import get_logger
from .utils.logger import get_logger

logger = get_logger(__name__)

Expand Down
4 changes: 2 additions & 2 deletions src/downloader.py → packt/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from requests.exceptions import ConnectionError
from slugify import slugify

from api import (
from .api import (
PACKT_API_PRODUCT_FILE_DOWNLOAD_URL,
PACKT_API_PRODUCT_FILE_TYPES_URL
)
from utils.logger import get_logger
from .utils.logger import get_logger


logger = get_logger(__name__)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
import os
import sys

from api import PacktAPIClient
from claimer import claim_product, get_all_books_data
from configuration import ConfigurationModel
from downloader import download_products, slugify_product_name
from utils.anticaptcha import solve_recaptcha
from utils.logger import get_logger
from .api import PacktAPIClient
from .claimer import claim_product, get_all_books_data
from .configuration import ConfigurationModel
from .downloader import download_products, slugify_product_name
from .utils.anticaptcha import solve_recaptcha
from .utils.logger import get_logger

logger = get_logger(__name__)

Expand Down Expand Up @@ -63,7 +63,7 @@ def packt_cli(cfgpath, grab, grabd, dall, sgd, mail, status_mail, folder, noauth
# Send email about successful book grab. Do it only when book
# isn't going to be emailed as we don't want to send email twice.
if status_mail and not mail:
from utils.mail import MailBook
from .utils.mail import MailBook
mb = MailBook(config_file_path)
mb.send_info(
subject=SUCCESS_EMAIL_SUBJECT.format(
Expand Down Expand Up @@ -100,11 +100,11 @@ def packt_cli(cfgpath, grab, grabd, dall, sgd, mail, status_mail, folder, noauth
if os.path.isfile(path) and slugify_product_name(product_data['title']) in path
]
if sgd:
from utils.google_drive import GoogleDriveManager
from .utils.google_drive import GoogleDriveManager
google_drive = GoogleDriveManager(config_file_path)
google_drive.send_files(paths)
else:
from utils.mail import MailBook
from .utils.mail import MailBook
mb = MailBook(config_file_path)
pdf_path = None
mobi_path = None
Expand All @@ -124,7 +124,7 @@ def packt_cli(cfgpath, grab, grabd, dall, sgd, mail, status_mail, folder, noauth
except Exception as e:
logger.error("Exception occurred {}".format(e))
if status_mail:
from utils.mail import MailBook
from .utils.mail import MailBook
mb = MailBook(config_file_path)
mb.send_info(
subject=FAILURE_EMAIL_SUBJECT.format(dt.datetime.now().strftime(DATE_FORMAT)),
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,20 @@
setup(
name='packt',
version=package_version,
packages=find_packages(),
license='MIT',
description='Script for grabbing daily Packt Free Learning ebooks',
author='Łukasz Uszko',
author_email='[email protected]',
url='https://github.com/luk6xff/Packt-Publishing-Free-Learning',
long_description=long_description,
long_description_content_type='text/markdown',
package_dir={'': 'src'},
packages=find_packages('src'),
py_modules=['packtPublishingFreeEbook', 'api', 'claimer', 'configuration', 'downloader'],
py_modules=['packt'],
install_requires=requirements,
extras_require={'dev': dev_requirements},
entry_points={
'console_scripts': [
'packt-cli = packtPublishingFreeEbook:packt_cli',
'packt-cli = packt.packtPublishingFreeEbook:packt_cli',
],
},
download_url='https://github.com/luk6xff/Packt-Publishing-Free-Learning/archive/v1.5.3.tar.gz',
Expand Down

0 comments on commit 7133d81

Please sign in to comment.