Restructured project to better run as a package.
This should have been setup correctly, but now try to better follow structure for python modules, which this is supposed to be. - Renamed folder from src -> seasonedParser - Moved test/ into seasonedParser/ - test has __init__.py script which sets location to the project folder (seasonedParser/). - Removed cli.py and moved contents to __main__.py - Updated drone to run pytest without test folder parameter
This commit is contained in:
@@ -13,14 +13,14 @@ steps:
|
|||||||
commands:
|
commands:
|
||||||
- python --version
|
- python --version
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- py.test test
|
- py.test
|
||||||
|
|
||||||
- name: test-python3.8
|
- name: test-python3.8
|
||||||
image: python:3.8-alpine
|
image: python:3.8-alpine
|
||||||
commands:
|
commands:
|
||||||
- python --version
|
- python --version
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- py.test test
|
- py.test
|
||||||
|
|
||||||
- name: codecov
|
- name: codecov
|
||||||
image: python:3.6-alpine
|
image: python:3.6-alpine
|
||||||
@@ -29,9 +29,7 @@ steps:
|
|||||||
from_secret: CODECOV_TOKEN
|
from_secret: CODECOV_TOKEN
|
||||||
commands:
|
commands:
|
||||||
- pip install -r requirements.txt
|
- pip install -r requirements.txt
|
||||||
- py.test --cov-report=xml --cov=src test
|
- py.test --cov-report=xml --cov=seasonedParserseasonedParserseasonedParserseasonedParserseasonedParserseasonedParserseasonedParserseasonedParser
|
||||||
- apk add curl
|
|
||||||
- apk add bash
|
|
||||||
- apk add git
|
- apk add git
|
||||||
- bash -c "$(curl -s https://codecov.io/bash)"
|
- bash -c "$(curl -s https://codecov.io/bash)"
|
||||||
trigger:
|
trigger:
|
||||||
|
|||||||
7
seasonedParser/__init__.py
Normal file
7
seasonedParser/__init__.py
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
print('hello from init')
|
||||||
|
import sys,os
|
||||||
|
# sys.path.append(os.path.join(os.path.dirname(__file__),os.pardir))
|
||||||
|
|
||||||
|
# from
|
||||||
|
|
||||||
|
from .__version__ import __version__
|
||||||
22
src/cli.py → seasonedParser/__main__.py
Executable file → Normal file
22
src/cli.py → seasonedParser/__main__.py
Executable file → Normal file
@@ -1,4 +1,9 @@
|
|||||||
#!usr/bin/env python3.6
|
#!/usr/bin/env python3.6
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Entry point module
|
||||||
|
"""
|
||||||
|
|
||||||
import click
|
import click
|
||||||
from guessit import guessit
|
from guessit import guessit
|
||||||
import logging
|
import logging
|
||||||
@@ -7,7 +12,22 @@ from core import scan_folder
|
|||||||
from video import Video
|
from video import Video
|
||||||
from exceptions import InsufficientNameError
|
from exceptions import InsufficientNameError
|
||||||
|
|
||||||
|
import env_variables as env
|
||||||
|
|
||||||
|
logging.basicConfig(filename=env.logfile, level=logging.INFO)
|
||||||
logger = logging.getLogger('seasonedParser')
|
logger = logging.getLogger('seasonedParser')
|
||||||
|
fh = logging.FileHandler(env.logfile)
|
||||||
|
fh.setLevel(logging.INFO)
|
||||||
|
sh = logging.StreamHandler()
|
||||||
|
sh.setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
fh_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
sh_formatter = logging.Formatter('%(levelname)s: %(message)s')
|
||||||
|
fh.setFormatter(fh_formatter)
|
||||||
|
sh.setFormatter(sh_formatter)
|
||||||
|
|
||||||
|
logger.addHandler(fh)
|
||||||
|
logger.addHandler(sh)
|
||||||
|
|
||||||
def tweet(video):
|
def tweet(video):
|
||||||
pass
|
pass
|
||||||
6
seasonedParser/__version__.py
Normal file
6
seasonedParser/__version__.py
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env python
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
"""
|
||||||
|
Version module
|
||||||
|
"""
|
||||||
|
__version__ = '0.2.0'
|
||||||
@@ -10,7 +10,6 @@ from babelfish import Language, LanguageReverseError
|
|||||||
import hashlib
|
import hashlib
|
||||||
import os, errno
|
import os, errno
|
||||||
import shutil
|
import shutil
|
||||||
import logging
|
|
||||||
import re
|
import re
|
||||||
import tvdb_api
|
import tvdb_api
|
||||||
import click
|
import click
|
||||||
@@ -20,26 +19,13 @@ import langdetect
|
|||||||
|
|
||||||
import env_variables as env
|
import env_variables as env
|
||||||
from exceptions import InsufficientNameError
|
from exceptions import InsufficientNameError
|
||||||
|
import logging
|
||||||
|
logger = logging.getLogger('seasonedParser')
|
||||||
|
|
||||||
from video import VIDEO_EXTENSIONS, Episode, Movie, Video
|
from video import VIDEO_EXTENSIONS, Episode, Movie, Video
|
||||||
from subtitle import SUBTITLE_EXTENSIONS, Subtitle, get_subtitle_path
|
from subtitle import SUBTITLE_EXTENSIONS, Subtitle, get_subtitle_path
|
||||||
from utils import sanitize, refine
|
from utils import sanitize, refine
|
||||||
|
|
||||||
logging.basicConfig(filename=env.logfile, level=logging.INFO)
|
|
||||||
logger = logging.getLogger('seasonedParser')
|
|
||||||
fh = logging.FileHandler(env.logfile)
|
|
||||||
fh.setLevel(logging.INFO)
|
|
||||||
sh = logging.StreamHandler()
|
|
||||||
sh.setLevel(logging.WARNING)
|
|
||||||
|
|
||||||
fh_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
|
||||||
sh_formatter = logging.Formatter('%(levelname)s: %(message)s')
|
|
||||||
fh.setFormatter(fh_formatter)
|
|
||||||
sh.setFormatter(sh_formatter)
|
|
||||||
|
|
||||||
logger.addHandler(fh)
|
|
||||||
logger.addHandler(sh)
|
|
||||||
|
|
||||||
def search_external_subtitles(path, directory=None):
|
def search_external_subtitles(path, directory=None):
|
||||||
dirpath, filename = os.path.split(path)
|
dirpath, filename = os.path.split(path)
|
||||||
dirpath = dirpath or '.'
|
dirpath = dirpath or '.'
|
||||||
17
seasonedParser/logger.py
Normal file
17
seasonedParser/logger.py
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import logging
|
||||||
|
import env_variables as env
|
||||||
|
|
||||||
|
logging.basicConfig(filename=env.logfile, level=logging.INFO)
|
||||||
|
logger = logging.getLogger('seasonedParser')
|
||||||
|
fh = logging.FileHandler(env.logfile)
|
||||||
|
fh.setLevel(logging.INFO)
|
||||||
|
sh = logging.StreamHandler()
|
||||||
|
sh.setLevel(logging.WARNING)
|
||||||
|
|
||||||
|
fh_formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
||||||
|
sh_formatter = logging.Formatter('%(levelname)s: %(message)s')
|
||||||
|
fh.setFormatter(fh_formatter)
|
||||||
|
sh.setFormatter(sh_formatter)
|
||||||
|
|
||||||
|
logger.addHandler(fh)
|
||||||
|
logger.addHandler(sh)
|
||||||
2
seasonedParser/test/__init__.py
Normal file
2
seasonedParser/test/__init__.py
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import sys, os
|
||||||
|
sys.path.append(os.path.realpath(os.path.dirname(__file__)+"/.."))
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import sys, os
|
import sys, os
|
||||||
sys.path.append(os.path.realpath(os.path.dirname(__file__)+"/../src"))
|
|
||||||
|
|
||||||
def test_import_env_variables():
|
def test_import_env_variables():
|
||||||
import env_variables as env
|
import env_variables as env
|
||||||
Reference in New Issue
Block a user