Compare commits

...

14 Commits

Author SHA1 Message Date
6095290195 test: check if destination exists 2021-06-25 21:37:16 +02:00
afd46ee7d2 Move import to top 2021-06-25 20:45:49 +02:00
59f8adf860 Add test_argument_required 2021-06-25 19:58:08 +02:00
4623f63bed Move files out of 'src' 2021-06-25 19:57:46 +02:00
074cb16b1c Update .gitignore 2021-06-25 19:57:09 +02:00
92dace165b Add Makefile 2021-06-25 19:56:52 +02:00
e65e16d37b Add basic arguments
--destination
--chapter-start
--notify
2021-06-24 23:21:36 +02:00
5df275fba9 Add .editorconfig 2021-06-24 23:21:03 +02:00
cd426cdcb2 ci: switch to custom python-pypi image
Some checks failed
continuous-integration/drone/tag Build is failing
2021-06-24 20:49:29 +00:00
a3c53cd015 Remove redundant license info 2021-06-24 22:17:33 +02:00
2cc4ff1b85 ci: use twine instead of plugin
Some checks failed
continuous-integration/drone/tag Build is failing
2021-06-24 22:04:46 +02:00
f994988fdd ci: change setupfile
Some checks failed
continuous-integration/drone/tag Build is failing
2021-06-24 21:55:12 +02:00
81bc1886fd ci: remove main branch limit
Some checks failed
continuous-integration/drone/tag Build is failing
2021-06-24 21:52:13 +02:00
ebd4e8c9dc ci: install python build 2021-06-24 21:51:14 +02:00
10 changed files with 89 additions and 13 deletions

View File

@ -5,18 +5,18 @@ name: build and publish
steps: steps:
- name: build - name: build
image: python image: registry.kucharczyk.tech/python-pypi
commands: commands:
- python -m build - python -m build
- name: publish - name: publish
image: plugins/pypi image: registry.kucharczyk.tech/python-pypi
settings: commands:
username: - python -m twine upload -u $USERNAME -p $PASSWORD dist/*
environment:
USERNAME:
from_secret: pypi_username from_secret: pypi_username
password: PASSWORD:
from_secret: pypi_password from_secret: pypi_password
trigger: trigger:
branch:
- main
event: event:
- tag - tag

14
.editorconfig Normal file
View File

@ -0,0 +1,14 @@
root = true
[*]
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = false
charset = utf-8
[*.py]
indent_style = space
indent_size = 2
[Makefile]
indent_size = tab

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
.vscode .vscode
dist dist
src/*.egg-info src/*.egg-info
__pycache__
.pytest_cache

7
Makefile Normal file
View File

@ -0,0 +1,7 @@
init:
pip install -r requirements.txt
test:
py.test tests
.PHONY: init test

29
manga_up/__main__.py Normal file
View File

@ -0,0 +1,29 @@
"""
Manga checker and downloader
"""
import argparse
import os
if __name__ == '__main__':
parser = argparse.ArgumentParser(
description="Check for manga updates and download them."
)
parser.add_argument(
'-d', '--destination', type=str, required=True, help="Target destination where the download file should be saved."
)
parser.add_argument(
'-s', '--chapter-start', type=int, default=1, help="From which chapter should the program check."
)
parser.add_argument(
'-n', '--notify', type=str, default=None, help="Apprise notification string."
)
args = parser.parse_args()
destination = os.path.abspath(args.destination)
if not os.path.exists(destination):
print(f'Destination {destination} does not exist.')
if not os.path.isdir(destination):
print(f'Destination {destination} is not a directory.')

View File

@ -6,7 +6,6 @@ author_email = lukas@kucharczyk.xyz
description = A simple manga update checker and downloader description = A simple manga update checker and downloader
long_description = file: README.md long_description = file: README.md
long_description_content_type = text/markdown long_description_content_type = text/markdown
license = GPLv3+
url = https://git.kucharczyk.xyz/lukas/manga-up url = https://git.kucharczyk.xyz/lukas/manga-up
project_urls = project_urls =
Bug Tracker = https://git.kucharczyk.xyz/lukas/manga-up/issues Bug Tracker = https://git.kucharczyk.xyz/lukas/manga-up/issues

View File

@ -1,4 +0,0 @@
import requests
response = requests.get('https://httpbin.org/ip')
print('Code is {0}.'.format(response.status_code))

0
tests/__init__.py Normal file
View File

29
tests/test_arguments.py Normal file
View File

@ -0,0 +1,29 @@
from subprocess import CalledProcessError
import unittest
import subprocess
import os
class ArgumentTestClass(unittest.TestCase):
def setUp(self):
import tempfile
self.existing_dir = tempfile.mkdtemp()
def test_argument_required(self):
with self.assertRaises(CalledProcessError):
subprocess.check_output(['python', 'manga_up'])
def test_destination_exists(self):
result = subprocess.check_output(['python', 'manga_up', '--destination', 'nonexistent'])
self.assertIn('does not exist', str(result))
def test_destination_is_not_directory(self):
result = subprocess.check_output(['python', 'manga_up', '--destination', self.existing_file])
self.assertIn('not a directory', str(result))
def tearDown(self) -> None:
os.rmdir(self.existing_dir)
if __name__ == '__main__':
unittest.main()