Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App: implement managing multiple projects (#107) #109

Merged
merged 38 commits into from
Dec 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
05f13c4
App: implement managing multiple projects (#107)
keggsmurph21 Dec 18, 2019
ca46724
App: save `project_hash` after initializing a Project
keggsmurph21 Dec 18, 2019
7c46ccb
Project: change constructor pattern & save location
keggsmurph21 Dec 18, 2019
1c15aca
Create directories in 0o755 mode (instead of default 0o777)
keggsmurph21 Dec 18, 2019
fd59bfd
Project: remove old comments
keggsmurph21 Dec 18, 2019
b2d62bf
Project: check if root_path is a directory
keggsmurph21 Dec 18, 2019
746f9ac
App: Add types to constructor args, allow "headless" mode
keggsmurph21 Dec 19, 2019
274beae
App: add tests
keggsmurph21 Dec 19, 2019
30c5c7a
Trace+XHair: fix type errors when running `pytest`
keggsmurph21 Dec 19, 2019
61a18b6
Update ultratrace2/model/files/bundle.py
keggsmurph21 Dec 19, 2019
f0f6154
FileBundleList: Make `cls.exclude_dirs` a `FrozenSet`
keggsmurph21 Dec 19, 2019
5ef78a0
Merge branch 'manage-multiple-projects' of https://github.com/swatpho…
keggsmurph21 Dec 19, 2019
6235875
Update ultratrace2/model/files/bundle.py
keggsmurph21 Dec 19, 2019
25aae65
Update ultratrace2/model/files/bundle.py
keggsmurph21 Dec 19, 2019
67424ae
Update ultratrace2/model/project.py
keggsmurph21 Dec 19, 2019
2ea02f0
Update ultratrace2/model/project.py
keggsmurph21 Dec 19, 2019
2bee499
Project: Use more descriptive error messages in ::get_by_path()
keggsmurph21 Dec 19, 2019
3929e00
Merge branch 'manage-multiple-projects' of https://github.com/swatpho…
keggsmurph21 Dec 19, 2019
935d941
Update ultratrace2/model/project.py
keggsmurph21 Dec 19, 2019
cc4b696
Update ultratrace2/model/project.py
keggsmurph21 Dec 19, 2019
5f2b6f8
Update ultratrace2/model/project.py
keggsmurph21 Dec 19, 2019
dc181b5
Update ultratrace2/model/project.py
keggsmurph21 Dec 19, 2019
f7b7f7a
App: be more explicit about allowed parameters to App constructor
keggsmurph21 Dec 19, 2019
0cb2668
App: change parameter name in one test
keggsmurph21 Dec 19, 2019
c6b590a
Project: add tests for ::load()
keggsmurph21 Dec 19, 2019
be61113
nox: Also calculate test coverage when running pytest
keggsmurph21 Dec 19, 2019
a518eb8
FileBundle: Simplify logic of `has_*_impl` initialization
keggsmurph21 Dec 19, 2019
318c618
Files: simplify inheritance of file implementations
keggsmurph21 Dec 19, 2019
04c8af2
Remove `python-magic` dependency in favor of `mimetypes`
keggsmurph21 Dec 19, 2019
cf17cff
Registry: Implement plugin-based architecture for loading files
keggsmurph21 Dec 19, 2019
a452e98
FileLoaderBase: constrain ::from_file return type
keggsmurph21 Dec 20, 2019
e38b084
Update ultratrace2/model/files/loaders/base.py
keggsmurph21 Dec 20, 2019
336f414
DICOMLoader: raise FileLoadError from InvalidDicomError
keggsmurph21 Dec 20, 2019
fa457a1
Registry: remove unnecessary `global` statements
keggsmurph21 Dec 20, 2019
7450611
Project: Don't funnel ::load() errors into RuntimeErrors
keggsmurph21 Dec 20, 2019
e6895ba
FileBundle: Pass responsibility for handling FileLoadError to caller
keggsmurph21 Dec 20, 2019
2669b54
FileLoaderBase: Require `path: str` abstract attribute
keggsmurph21 Dec 20, 2019
d2b3759
Merge branch 'master' into manage-multiple-projects
keggsmurph21 Dec 20, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ __pycache__
*.pyc
.mypy_cache
.nox
.coverage
3 changes: 1 addition & 2 deletions install.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env bash

if which brew &> /dev/null; then
brew install portaudio libmagic ffmpeg libav
brew install portaudio ffmpeg libav
elif which apt-get &> /dev/null; then
sudo apt-get update
sudo apt-get install \
portaudio19-dev libportaudio2 \
libmagic-dev \
ffmpeg \
libav-tools
else
Expand Down
2 changes: 1 addition & 1 deletion noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def lint(session):
@nox.session
def tests(session):
session.install(".[dev]")
session.run("pytest", "ultratrace2")
session.run("pytest", "ultratrace2")
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ pydicom==1.3.0
pydub==0.23.1
pyparsing==2.4.5
python-dateutil==2.8.1
python-magic==0.4.15
six==1.13.0
TextGrid==1.5
tqdm==4.40.2
Expand Down
3 changes: 3 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[tool:pytest]
addopts =
--cov=ultratrace2
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def get_requirement(line):
"mypy",
"pytest",
"numpy-stubs @ git+https://github.com/numpy/numpy-stubs.git@master",
"pytest-cov",
"pytest-mock",
]
},
Expand Down
14 changes: 13 additions & 1 deletion ultratrace2/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,22 @@ def main():
parser = argparse.ArgumentParser(prog="ultratrace")

# noqa: E128
parser.add_argument(
"--headless",
action="store_true",
default=False,
help="run ultratrace without a GUI interface",
)
parser.add_argument(
"path",
default=None,
help="path (unique to a participant) where subdirectories contain raw data",
)
parser.add_argument(
"theme", # FIXME: not yet supported
default=None,
help="name of Ttk theme to use for widgets",
)
parser.add_argument(
"--no-audio",
dest="audio",
Expand Down Expand Up @@ -56,7 +67,8 @@ def main():

args = parser.parse_args()

app = initialize_app(args)
app = initialize_app(headless=args.headless, path=args.path, theme=args.theme)

app.main()


Expand Down
32 changes: 20 additions & 12 deletions ultratrace2/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,35 @@


class App:
def __init__(self, args): # FIXME: be more granular here

if args.path is None:
def __init__(
self,
headless: bool = False,
path: Optional[str] = None,
theme: Optional[str] = None,
):

if path is None and not headless:
path = choose_dir()
if not path:
raise ValueError("You must choose a directory to open")
else:
path = args.path
if not path:
raise ValueError("You must choose a directory to open")

self.project: Project = Project.get_by_path(path)

self.project = Project(path)
self.gui = GUI(theme=args.theme)
if not headless:
self.gui = GUI(theme=theme)

def main(self):
def main(self) -> None:
pass


# singleton
app: Optional[App] = None


def initialize_app(args) -> App: # FIXME: be more granular here
def initialize_app(
headless: bool = False, path: Optional[str] = None, theme: Optional[str] = None
) -> App:

global app
app = App(args)
app = App(headless=headless, path=path, theme=theme,)
return app
89 changes: 0 additions & 89 deletions ultratrace2/model/files/ADT.py

This file was deleted.

32 changes: 32 additions & 0 deletions ultratrace2/model/files/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from .registry import register_loader_for_extensions_and_mime_types as __register

from .loaders import DICOMLoader
from .loaders import FLACLoader
from .loaders import MeasurementLoader
from .loaders import MP3Loader
from .loaders import OggLoader
from .loaders import TextGridLoader
from .loaders import WAVLoader


__register(
[".dicom", ".dcm"], ["application/dicom"], DICOMLoader,
)
__register(
[], [], FLACLoader,
)
__register(
[], [], MeasurementLoader,
)
__register(
[], [], MP3Loader,
)
__register(
[], [], OggLoader,
)
__register(
[".textgrid"], ["text/plain"], TextGridLoader,
)
__register(
[".wav"], ["audio/x-wav", "audio/wav"], WAVLoader,
)
Loading