-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/0.1.9' into main
- Loading branch information
Showing
18 changed files
with
200 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions | ||
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions | ||
|
||
name: Test Python Package | ||
|
||
on: | ||
push: | ||
branches: [ develop ] | ||
pull_request: | ||
branches: [ develop ] | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: [3.6, 3.7, 3.8] | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8 pytest pytest-cov codecov | ||
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics | ||
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide | ||
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics | ||
- name: Test with pytest | ||
run: | | ||
pytest | ||
- name: Coverage by codecov | ||
run: | | ||
codecov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# This workflows will upload a Python Package using Twine when a release is created | ||
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries | ||
|
||
name: Upload Python Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
deploy: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.x' | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install setuptools wheel twine | ||
- name: Build and publish | ||
env: | ||
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python setup.py sdist bdist_wheel | ||
twine upload dist/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
codecov: | ||
archive: | ||
uploads: no | ||
|
||
coverage: | ||
precision: 0 | ||
range: 80...100 | ||
|
||
comment: | ||
layout: "header, diff, changes" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,9 @@ | ||
import argparse, os, shutil | ||
|
||
from pathlib import Path | ||
from .cute_python import snek | ||
|
||
FILE_NAME = 'settings_local.py' | ||
|
||
"""Entry-point for the :program:`dsl` command.""" | ||
import sys | ||
|
||
def main(): | ||
print(snek) | ||
|
||
parser = argparse.ArgumentParser(description='Create Django Local Settings') | ||
parser.add_argument('-p', metavar='PATH', help='Django Project Application Path') | ||
parser.add_argument('-f', action='store_true', help='Show Django Local Settings Format') | ||
args = parser.parse_args() | ||
|
||
WORKING_DIR = Path(args.p or os.getcwd()) | ||
PACKAGE_DIR = Path(__file__).resolve(strict=True).parent | ||
|
||
GIT_IGNORE = WORKING_DIR.parent/'.gitignore' | ||
DJANGO_SETTINGS = WORKING_DIR/'settings.py' | ||
|
||
if args.f: | ||
with open(PACKAGE_DIR/FILE_NAME, 'r') as fb: | ||
print(fb.read()) | ||
elif os.path.isfile(WORKING_DIR/FILE_NAME): | ||
print(f"{FILE_NAME} is already there at {WORKING_DIR}") | ||
else: | ||
shutil.copyfile(PACKAGE_DIR/FILE_NAME, WORKING_DIR/FILE_NAME) | ||
if os.path.isfile(GIT_IGNORE): | ||
fp = open(GIT_IGNORE, 'a') | ||
else: | ||
fp = open(GIT_IGNORE, 'w') | ||
fp.write('\n# Added by `dsl` (Django Setting Local) \nsettings_local*\n') | ||
fp.close() | ||
|
||
fp = open(DJANGO_SETTINGS, 'a') | ||
fp.write("\n\n\n\n") | ||
fp.write("\n##################### END OF SETTINGS ################################") | ||
fp.write("\nfrom django_settings_local import import_local;import_local(globals())") | ||
fp.write("\n##################### END OF SETTINGS ################################") | ||
fp.close() | ||
from .dsl import main as _main | ||
sys.exit(_main()) | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import argparse, os, shutil | ||
|
||
from pathlib import Path | ||
from .cute_python import snek | ||
|
||
|
||
FILE_NAME = 'settings_local.py' | ||
|
||
|
||
def main(): | ||
print(snek) | ||
|
||
parser = argparse.ArgumentParser(description='Create Django Local Settings') | ||
parser.add_argument('-p', metavar='PATH', help='Django Project Application Path') | ||
parser.add_argument('-f', action='store_true', help='Show Django Local Settings Format') | ||
args = parser.parse_args() | ||
|
||
WORKING_DIR = Path(args.p or os.getcwd()) | ||
PACKAGE_DIR = Path(__file__).resolve(strict=True).parent | ||
|
||
GIT_IGNORE = WORKING_DIR.parent/'.gitignore' | ||
DJANGO_SETTINGS = WORKING_DIR/'settings.py' | ||
|
||
if args.f: | ||
with open(PACKAGE_DIR/FILE_NAME, 'r') as fb: | ||
print(fb.read()) | ||
elif os.path.isfile(WORKING_DIR/FILE_NAME): | ||
print(f"{FILE_NAME} is already there at {WORKING_DIR}") | ||
else: | ||
shutil.copyfile(PACKAGE_DIR/FILE_NAME, WORKING_DIR/FILE_NAME) | ||
if os.path.isfile(GIT_IGNORE): | ||
fp = open(GIT_IGNORE, 'a') | ||
else: | ||
fp = open(GIT_IGNORE, 'w') | ||
fp.write('\n# Added by `dsl` (Django Setting Local) \nsettings_local*\n') | ||
fp.close() | ||
|
||
fp = open(DJANGO_SETTINGS, 'a') | ||
fp.write("\n\n\n\n") | ||
fp.write("\n##################### END OF SETTINGS ################################") | ||
fp.write("\nfrom django_settings_local import import_local;import_local(globals())") | ||
fp.write("\n##################### END OF SETTINGS ################################") | ||
fp.close() | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEBUG = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DEBUG = True | ||
ALLOWED_HOSTS = ['*'] | ||
|
||
patch_globals = "Not a function" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from src.django_settings_local import import_local | ||
|
||
def test_import_local(): | ||
import_local(globals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
DEBUG = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from src.django_settings_local import import_local | ||
|
||
def test_import_local(): | ||
import_local(globals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import importlib, os | ||
from src.django_settings_local import dsl, import_local, settings_local | ||
|
||
def test_import_local(): | ||
import_local(globals()) | ||
|
||
def test_valid_patch_globals(): | ||
settings_local.patch_globals(globals()) | ||
|
||
def test_invalid_patch_globals(): | ||
try: | ||
settings_local.patch_globals(1,2) | ||
except TypeError: | ||
pass | ||
|
||
def test_main_module(): | ||
main_module = importlib.import_module("src.django_settings_local.__main__") | ||
try: | ||
os.chdir("tests/django_project_app") | ||
main_module.main() | ||
except SystemExit: | ||
os.chdir("../../") | ||
|
||
def test_main_script(): | ||
os.chdir("tests/django_project_app") | ||
dsl.main(); dsl.main() | ||
os.chdir("../../") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
DEBUG = True | ||
ALLOWED_HOSTS = ['*'] | ||
|
||
def patch_globals(g): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
from src.django_settings_local import import_local | ||
|
||
def test_import_local(): | ||
import_local(globals()) |