Skip to content

Commit

Permalink
Merge pull request #32 from jessedp/structure
Browse files Browse the repository at this point in the history
Rework Project Structure
  • Loading branch information
jessedp committed Oct 26, 2020
2 parents cc1f076 + cd771df commit 8c3814c
Show file tree
Hide file tree
Showing 14 changed files with 57 additions and 28 deletions.
18 changes: 14 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,19 @@ build: clean-build lint


lint:
black --target-version py36 .
pylint *.py
black --target-version py36 ph5lt
pylint ph5lt

test: clean-pyc lint
python3 -m pytest
coverage run -m pytest
# coverage report --include=ph5lt\/*
# python3 -m pytest

covreport:
coverage report --include=ph5lt\/* -m

run:
python3 ph5lt.py
python3 ph5lt/app.py

update:
python3 -m pip install --user --upgrade setuptools wheel
Expand All @@ -32,6 +37,11 @@ package: build
publishTest: package
python3 -m twine upload --repository testpypi dist/*

installTest:
pip3 install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple pihole5-list-tool --upgrade

uninstall:
pip3 uninstall pihole5-list-tool

publish: package
python3 -m twine upload dist/*
Expand Down
Empty file added ph5lt/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions ph5lt/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import re
import sys
from ph5lt.app import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
6 changes: 3 additions & 3 deletions allowlists.py → ph5lt/allowlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import requests
from PyInquirer import Separator

import prompts
import constants
import utils
from ph5lt import prompts
from ph5lt import constants
from ph5lt import utils

ANUDEEP_ALLOWLIST = (
"https://raw.githubusercontent.com/anudeepND/whitelist/master/domains/whitelist.txt"
Expand Down
14 changes: 7 additions & 7 deletions ph5lt.py → ph5lt/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import sys
import sqlite3

import constants
import prompts
import allowlists
import blocklists
import utils
import banner
import stats
from ph5lt import constants
from ph5lt import prompts
from ph5lt import allowlists
from ph5lt import blocklists
from ph5lt import utils
from ph5lt import banner
from ph5lt import stats


def main():
Expand Down
3 changes: 2 additions & 1 deletion banner.py → ph5lt/banner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
""" silly ansi banner"""

from colors import color
import utils

from ph5lt import utils

__version__ = "0.6.0"

Expand Down
6 changes: 3 additions & 3 deletions blocklists.py → ph5lt/blocklists.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import requests
from PyInquirer import Separator

import prompts
import constants
import utils
from ph5lt import prompts
from ph5lt import constants
from ph5lt import utils

# PiHole 5.1 installation defaults
DEFAULT_LISTS = [
Expand Down
File renamed without changes.
5 changes: 3 additions & 2 deletions prompts.py → ph5lt/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
import os
import sqlite3
from PyInquirer import prompt, Validator, ValidationError, Separator
import constants
import utils

from ph5lt import constants
from ph5lt import utils


def check_db(path):
Expand Down
3 changes: 2 additions & 1 deletion stats.py → ph5lt/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from terminaltables import AsciiTable, SingleTable
from colors import color
import utils

from ph5lt import utils

stats = {
"total_adlist": "SELECT COUNT(*) FROM adlist",
Expand Down
3 changes: 2 additions & 1 deletion utils.py → ph5lt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
from urllib.parse import urlparse
from json.decoder import JSONDecodeError
from colors import color
import constants

from ph5lt import constants


def valid_url(url):
Expand Down
14 changes: 10 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

def version():
"""Return version string."""
with io.open("banner.py") as input_file:
with io.open("ph5lt/banner.py") as input_file:
for line in input_file:
if line.startswith("__version__"):
return ast.parse(line).body[0].value.s
Expand All @@ -21,7 +21,8 @@ def version():
long_description=readme.read(),
long_description_content_type="text/markdown",
package_dir="",
packages=find_packages(exclude=("tests", "tests.*")),
packages1=find_packages(exclude=("tests", "tests.*")),
packages=["ph5lt"],
url="https://github.com/jessedp/pihole5-list-tool",
classifiers=[
"Programming Language :: Python :: 3",
Expand All @@ -30,10 +31,15 @@ def version():
"Topic :: Utilities",
"Topic :: Internet :: Name Service (DNS)",
],
project_urls={
"Bug Tracker": "https://github.com/jessedp/pihole5-list-tool/issues",
"Source Code": "https://github.com/jessedp/pihole5-list-tool",
},
keywords="pihole, pi-hole, blacklist, blocklist, whitelist, allowlist, adlist",
python_requires=">=3.6",
install_requires=["PyInquirer", "ansicolors", "requests", "terminaltables"],
py_modules=[
packages2=["ph5lt"],
py_modules2=[
"ph5lt",
"prompts",
"constants",
Expand All @@ -43,5 +49,5 @@ def version():
"blocklists",
"stats",
],
entry_points={"console_scripts": ["pihole5-list-tool = ph5lt:main"]},
entry_points={"console_scripts": ["pihole5-list-tool = ph5lt.app:main"]},
)
3 changes: 2 additions & 1 deletion tests/test_prompts.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import sqlite3
from unittest.mock import patch
import prompts

from ph5lt import prompts


@patch("os.path.exists")
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import utils
import subprocess
import os
from subprocess import CalledProcessError
from unittest.mock import patch

from ph5lt import utils

class TestUtils:
def test_valid_url(self):
Expand Down

0 comments on commit 8c3814c

Please sign in to comment.