Skip to content

Commit

Permalink
Merge pull request #58 from djotaku/devel
Browse files Browse the repository at this point in the history
Devel-merging new Package Format
  • Loading branch information
djotaku authored Feb 23, 2020
2 parents 9dceb47 + 5a58fa3 commit ee60d12
Show file tree
Hide file tree
Showing 34 changed files with 254 additions and 62 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/linttest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ jobs:
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 extralifedonations.py IPC.py readparticipantconf.py team.py donation.py donor.py extralife_IO.py --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 eldonationtracker/extralifedonations.py eldonationtracker/ipc.py eldonationtracker/readparticipantconf.py eldonationtracker/team.py eldonationtracker/donation.py eldonationtracker/donor.py eldonationtracker/extralife_IO.py --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 extralifedonations.py IPC.py readparticipantconf.py team.py donation.py donor.py extralife_IO.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 eldonationtracker/extralifedonations.py eldonationtracker/ipc.py eldonationtracker/readparticipantconf.py eldonationtracker/team.py eldonationtracker/donation.py eldonationtracker/donor.py eldonationtracker/extralife_IO.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
shell: bash
- name: Test with pytest
run: |
pip install pytest
pytest test.py
pip install pytest
pytest -v --pyargs eldonationtracker
shell: bash
12 changes: 6 additions & 6 deletions .github/workflows/linuxbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ jobs:
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 extralifedonations.py IPC.py readparticipantconf.py team.py donation.py donor.py extralife_IO.py --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 eldonationtracker/extralifedonations.py eldonationtracker/ipc.py eldonationtracker/readparticipantconf.py eldonationtracker/team.py eldonationtracker/donation.py eldonationtracker/donor.py eldonationtracker/extralife_IO.py --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 extralifedonations.py IPC.py readparticipantconf.py team.py donation.py donor.py extralife_IO.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 eldonationtracker/extralifedonations.py eldonationtracker/ipc.py eldonationtracker/readparticipantconf.py eldonationtracker/team.py eldonationtracker/donation.py eldonationtracker/donor.py eldonationtracker/extralife_IO.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install pytest
pytest test.py
pip install pytest
pytest -v --pyargs eldonationtracker
- name: Build with Pyinstaller
run: |
pip install pyinstaller
pyinstaller gui.py
cp participant.conf dist/gui/
pyinstaller -p eldonationtracker eldonationtracker/gui.py
cp participant.conf dist/gui
cp Engineer.png dist/gui
cp Donation.mp3 dist/gui
cp icon.png dist/gui
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/windowsbuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ jobs:
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 extralifedonations.py IPC.py readparticipantconf.py team.py donation.py donor.py extralife_IO.py --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 eldonationtracker/extralifedonations.py eldonationtracker/ipc.py eldonationtracker/readparticipantconf.py eldonationtracker/team.py eldonationtracker/donation.py eldonationtracker/donor.py eldonationtracker/extralife_IO.py --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 extralifedonations.py IPC.py readparticipantconf.py team.py donation.py donor.py extralife_IO.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
flake8 eldonationtracker/extralifedonations.py eldonationtracker/ipc.py eldonationtracker/readparticipantconf.py eldonationtracker/team.py eldonationtracker/donation.py eldonationtracker/donor.py eldonationtracker/extralife_IO.py --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pip install pytest
pytest test.py
pip install pytest
pytest -v --pyargs eldonationtracker
- name: Build with Pyinstaller
run: |
pip install pyinstaller
pyinstaller gui.py
cp participant.conf dist/gui/
pyinstaller -p eldonationtracker eldonationtracker/gui.py
cp participant.conf dist/gui
cp Engineer.png dist/gui
cp Donation.mp3 dist/gui
cp icon.png dist/gui
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ pyvenv.cfg
OriginalDonation.mp3
for_lots_of_donors
*.bak
_build
*egg*
20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
55 changes: 55 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('..'))


# -- Project information -----------------------------------------------------

project = 'eldonationtracker'
copyright = '2020, Eric Mesa'
author = 'Eric Mesa'

# The full version, including alpha/beta/rc tags
release = '3.3'


# -- General configuration ---------------------------------------------------

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = ['sphinx.ext.autodoc'
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
22 changes: 22 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.. eldonationtracker documentation master file, created by
sphinx-quickstart on Sun Feb 23 13:14:19 2020.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to eldonationtracker's documentation!
=============================================

.. toctree::
:maxdepth: 2
:caption: Contents:

modules/donation
modules/donor


Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
35 changes: 35 additions & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%

:end
popd
8 changes: 8 additions & 0 deletions docs/modules/donation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
==============
donation
==============

.. automodule:: eldonationtracker.donation
:members:
:undoc-members:
:show-inheritance:
8 changes: 8 additions & 0 deletions docs/modules/donor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
==============
donor
==============

.. automodule:: eldonationtracker.donor
:members:
:undoc-members:
:show-inheritance:
Empty file added eldonationtracker/__init__.py
Empty file.
File renamed without changes.
4 changes: 2 additions & 2 deletions call_tracker.py → eldonationtracker/call_tracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from PyQt5.QtCore import pyqtSlot, QUrl
from PyQt5.QtMultimedia import QMediaPlayer, QMediaContent

import IPC
import ipc


class MyForm(QDialog):
Expand Down Expand Up @@ -101,7 +101,7 @@ def _loadElements(self):
def _unloadElements(self):
self.scene.removeItem(self.item)
self.ui.Donation_label.setText("")
IPC.writeIPC(self.folders, "0")
ipc.writeIPC(self.folders, "0")


def main(participant_conf):
Expand Down
File renamed without changes.
File renamed without changes.
17 changes: 9 additions & 8 deletions donation.py → eldonationtracker/donation.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,16 @@ class Donation:
from the JSON so that it doesn't have to be traversed each time a donor
action needs to be taken.
API Variables:
name: the name of the donor for this donation.
If the donor wished to stay anonymous,
the variable is set to "Anonymous"
:param name: the name of the donor for this donation. If the donor wished\
to stay anonymous, the variable is set to "Anonymous"
:type name: str
message: the message associated with the donation.
:param message: the message associated with the donation.
:type message: str
amount: the amount of the donation. If they blocked it from showing
it is set to 0.
:param amount: the amount of the donation. If they blocked it from showing\
it is set to 0.
:type amount: int
"""

def __init__(self, name, message, amount):
Expand All @@ -34,7 +35,7 @@ def __init__(self, name, message, amount):
def __lt__(self, object):
"""Donation less than comparison.
Returns True if this donation has a donation
:return: Returns True if this donation has a donation\
amount less than comparision.
"""
return self.amount < object.amount
21 changes: 14 additions & 7 deletions donor.py → eldonationtracker/donor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@ class Donor:
the JSON so that it doesn't have to be traversed each time a donor action
needs to be taken.
API Variables:
name: donor's name if provided, else Anonymous
donor_id: the ID assigned by the API (currently not used)
image_url: the URL for the donor's avatar (currently not used)
amount: the sum of all donations the donor has made this campaign
number_of_dononations: the number of donations the donor has made
this campaign
:param json: JSON attributes from the API
:type json: json
:param name: donor's name if provided, else Anonymous
:type name: str
:param donor_id: the ID assigned by the API (currently not used)
:type donor_id: str
:param image_url: the URL for the donor's avatar (currently not used)
:type image_url: str
:param amount: the sum of all donations the donor has made this\
campaign number_of_dononations: the number of donations the donor has\
made this campaign
"""

def __init__(self, json):
Expand All @@ -25,6 +29,9 @@ def json_to_attributes(self, json):
"""Convert JSON to Donor attributes.
May be overwritten by child classes.
:param json: JSON attributes from the API
:type json: json
"""
if json.get('displayName') is not None:
self.name = json.get('displayName')
Expand Down
17 changes: 14 additions & 3 deletions extralife_IO.py → eldonationtracker/extralife_IO.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Holds all the file and internet input and output."""

import json
import pathlib
import ssl
from urllib.request import HTTPError, Request, URLError, urlopen

Expand Down Expand Up @@ -77,7 +78,7 @@ def __init__(self):
def load_JSON(self):
"""Load in the config file."""
# by using pedantic, it'll create the directory if it's not there

try:
print(f"Looking for persistent settings at {self.xdg.XDG_CONFIG_HOME}")
with open(f'{self.xdg.XDG_CONFIG_HOME}/participant.conf') as file:
Expand All @@ -86,11 +87,21 @@ def load_JSON(self):
print("Persistent settings found.")
return config
except FileNotFoundError:
print("Persistent settings not found. Using defaults...")
with open('participant.conf') as file:
print("Persistent settings not found. Checking current directory")
try:
with open(pathlib.PurePath(__file__).parent.joinpath('.')/'participant.conf') as file:
config = json.load(file)
file.close()
return config
except FileNotFoundError:
print("Settings not found in current dir. Checking up one level.")
try:
with open(pathlib.PurePath(__file__).parent.joinpath('..')/'participant.conf') as file:
config = json.load(file)
file.close()
return config
except FileNotFoundError:
print("Giving up. Put settings in current directory.")

def update_fields(self):
"""Update fields with data from JSON."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

import time

import IPC
import team
import extralife_IO
import donor
import ipc
import donation
import donor
import extralife_IO
import team

# api info at https://github.com/DonorDrive/PublicAPI

Expand Down Expand Up @@ -75,7 +75,7 @@ def __init__(self, participant_conf):

# misc
self.loop = True
IPC.writeIPC(self.textFolder, "0")
ipc.writeIPC(self.textFolder, "0")
self.myteam = team.Team(self.TeamID,
self.textFolder,
self.CurrencySymbol)
Expand Down Expand Up @@ -175,7 +175,7 @@ def run(self):
self._get_donations()
self._donor_calculations()
self.write_text_files(self.donorcalcs)
IPC.writeIPC(self.textFolder, "1")
ipc.writeIPC(self.textFolder, "1")
if self.TeamID:
self.myteam.team_run()
print(time.strftime("%H:%M:%S"))
Expand Down
Loading

0 comments on commit ee60d12

Please sign in to comment.