Skip to content

Commit

Permalink
Merge pull request #21 from MiguelGuthridge/v0.5.0
Browse files Browse the repository at this point in the history
Release Version 0.5.0
  • Loading branch information
MaddyGuthridge authored Apr 17, 2022
2 parents 2d202df + a3a6ff4 commit bb67a8b
Show file tree
Hide file tree
Showing 146 changed files with 4,165 additions and 1,221 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
exclude = .git,__pycache__,.venv,.env,old,build,dist
; max-complexity = 10
58 changes: 53 additions & 5 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# This workflow will install Python dependencies, run tests and lint with a single version of Python
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions

name: Pytest
name: Test and Lint

on: [push]

jobs:
pytest:

Pytest:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
Expand All @@ -19,11 +17,61 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest coverage
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test with pytest
run: |
coverage run -m pytest
- name: Generate code coverage report
run: |
coverage report
Flake8:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
flake8
Mypy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with mypy
run: |
mypy .
Load:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install dependencies
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Test script load
run: |
python device_universal.py
python device_eventforward.py
5 changes: 2 additions & 3 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
"ms-python.python",
"streetsidesoftware.code-spell-checker",
"njpwerner.autodocstring",
"kevinrose.vsc-python-indent",
"matangover.mypy"
"kevinrose.vsc-python-indent"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": [

]
}
15 changes: 12 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
// Link up docstring template
"autoDocstring.customTemplatePath": "resources/docstring_template.mustache",

// Switch off Pylance and use MyPy instead
// Switch off Pylance, since we're using MyPy instead
"python.analysis.typeCheckingMode": "off",
"mypy.runUsingActiveInterpreter": true,

// Pytest configuration
"python.testing.pytestArgs": [
Expand All @@ -18,6 +17,13 @@
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,

// Enable linters
"python.linting.enabled": true,
"python.linting.flake8CategorySeverity.E": "Warning",
"python.linting.flake8CategorySeverity.F": "Warning",
"python.linting.flake8Enabled": true,
"python.linting.mypyEnabled": true,

// Spell checker
"cSpell.words": [
"buttondatastrat",
Expand All @@ -27,6 +33,7 @@
"controlmatcher",
"controlsurfaces",
"deinitialise",
"deinitialised",
"deviceconfigs",
"deviceshadow",
"dicttools",
Expand All @@ -36,7 +43,9 @@
"eventfilters",
"eventpattern",
"flmidimsg",
"hintmsg",
"ieventpattern",
"INCONTROL",
"ivaluestrategy",
"launchkey",
"mappingstrategy",
Expand All @@ -54,5 +63,5 @@
"sysex",
"Tytel",
"valuestrategy"
]
],
}
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ FL Studio.
# Supported Devices
If your device isn't on the list and you know Python, feel free to
[contribute](docs/contributing/README.md). If your device has solid documentation,
another contributor might be able to help you out too -
another contributor might be able to help you out too -
[join the Discord Server](https://discord.gg/6vpfJUF) and ask!

* Novation
Expand All @@ -22,6 +22,6 @@ Refer to the [documentation](docs/setup.md).
Documentation is available [here](docs/README.md), and contains information for
users, as well as contributors.

If you have any ideas for the development of the script, or want to contribute,
please [join the Discord Server](https://discord.gg/6vpfJUF). I'm excited
If you have any ideas for the development of the script, or want to contribute,
please [join the Discord Server](https://discord.gg/6vpfJUF). I'm excited
to see where this project will go in the future: I have huge plans for it!
40 changes: 22 additions & 18 deletions common/__init__.py
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
"""
common
Contains common functions and code required to initialise and manage the script.
Contains common functions and code required to initialise and manage the
script.
Authors:
* Miguel Guthridge [[email protected], HDSQ#2154]
"""

# Check minimum version
import general
from . import consts
if general.getVersion() < consts.MIN_API_VERSION:
# raise RuntimeError(
# f"Your FL Studio version is out of date: expected API "
# f"v{consts.MIN_API_VERSION}, got {general.getVersion()}"
# )
pass
del general
__all__ = [
'getVersionString',
'exceptions',
'log',
'verbosity',
'ProfilerContext',
'profilerDecoration',
'getContext',
'resetContext',
'unsafeResetContext',
'catchContextResetException',
'ExtensionManager',
]

from .consts import getVersionString

from . import exceptions
from .logger import log, verbosity
from .profiler import ProfilerContext, profilerDecoration

from .contextmanager import getContext, resetContext, catchContextResetException

from .eventpattern import BasicPattern, IEventPattern

from . import util

from .types import EventData, Color
from .contextmanager import (
getContext,
resetContext,
unsafeResetContext,
catchContextResetException
)

from .extensionmanager import ExtensionManager
37 changes: 25 additions & 12 deletions common/activitystate.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
common > activitystate
Contains the definition for the ActivityState class which manages what plugin or
window should be active.
Contains the definition for the ActivityState class which manages what plugin
or window should be active.
Authors:
* Miguel Guthridge [[email protected], HDSQ#2154]
Expand All @@ -18,10 +18,12 @@
)
from common.util.apifixes import getFocusedPluginIndex, getFocusedWindowIndex


class ActivityState:
"""
Maintains the currently selected plugin or window
"""

def __init__(self) -> None:
"""
Create an ActivityState object
Expand Down Expand Up @@ -54,16 +56,20 @@ def _forcePlugUpdate(self) -> None:
plugin = getFocusedPluginIndex(force=True)
if plugin is None:
if not self._plug_unsafe:
log("state.active", "Using plugin not from selected channel rack group", verbosity.WARNING)
log(
"state.active",
"Using plugin not from selected channel rack group",
verbosity.WARNING
)
self._plug_unsafe = True
self._plugin = (-1,)
self._generator = (-1,)
return
self._plugin = plugin
if len(plugin) == 1:
self._generator = plugin # type: ignore
self._generator = plugin # type: ignore
else:
self._effect = plugin # type: ignore
self._effect = plugin # type: ignore

def tick(self) -> None:
"""
Expand All @@ -77,19 +83,24 @@ def tick(self) -> None:
self._changed = True
self._window = window
if not self._split:
if self._plug_active:
self._changed = True
self._plug_active = False
self._forcePlugUpdate()
elif (plugin := getFocusedPluginIndex()) is not None:
self._plug_unsafe = False
if plugin != self._plugin:
self._changed = True
self._plugin = plugin
# Ignore typing because len(plugin) doesn't narrow types in mypy
# Ignore typing because len(plugin) doesn't narrow types in
# mypy
if len(plugin) == 1:
self._generator = plugin # type: ignore
self._generator = plugin # type: ignore
else:
self._effect = plugin # type: ignore
self._effect = plugin # type: ignore
if not self._split:
if not self._plug_active:
self._changed = True
self._plug_active = True
else:
self._forcePlugUpdate()
Expand Down Expand Up @@ -153,8 +164,8 @@ def playPause(self, value: bool = None) -> bool:
Pause or resume updating the active plugin
### Args:
* `value` (`bool`, optional): Whether the updating should happen or not.
Defaults to `None` (toggle).
* `value` (`bool`, optional): Whether the updating should happen or
not. Defaults to `None` (toggle).
### Returns:
* `bool`: whether updating will happen
Expand Down Expand Up @@ -187,7 +198,8 @@ def toggleWindowsPlugins(self, value: bool = None) -> bool:
### Args:
* `value` (`bool`, optional): whether the active plugin should be a
plugin (True) or a window (False), or toggled (None). Defaults to `None`.
plugin (True) or a window (False), or toggled (None). Defaults to
`None`.
### Raises:
* `ValueError`: setSplitWindowsPlugins() hasn't been called
Expand All @@ -200,5 +212,6 @@ def toggleWindowsPlugins(self, value: bool = None) -> bool:
"they are being addressed independently")
else:
self._changed = True
self._plug_active = not self._plug_active if value is None else value
self._plug_active = \
not self._plug_active if value is None else value
return self._plug_active
24 changes: 14 additions & 10 deletions common/consts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,27 @@
"""

# Version info
VERSION = (0, 4, 1)
VERSION = (0, 5, 0)

# Sub versions
VERSION_MAJOR = VERSION[0]
VERSION_MINOR = VERSION[1]
VERSION_REVISION = VERSION[2]
VERSION_SUFFIX = ""

# Minimum API version required to run script
MIN_API_VERSION = 19


def getVersionString() -> str:
"""
Returns the version string of the script
Eg: "1.2.3"
Eg: "1.2.3-beta"
"""
return ".".join(map(str, VERSION))
suffix = f"-{VERSION_SUFFIX}" if VERSION_SUFFIX else ""
return ".".join(map(str, VERSION)) + suffix


# Website
WEBSITE = "https://github.com/MiguelGuthridge/Universal-Controller-Script"
Expand All @@ -51,19 +55,19 @@ def getVersionString() -> str:
';;'
;;'
',;/\\\\/;, ,L,
,\FFFFFFFFFF; ;L'
,\\FFFFFFFFFF; ;L'
;FFFFFFFFFFFFFFF/;;;,, ',,;;;;;/;;'
.FLL\LFFFFFFFFFFFFFFFFFFLL;;,.'' ',L,
;//;/FFFFFFFFFFFFFFFFF\ L;
.FLL\\LFFFFFFFFFFFFFFFFFFLL;;,.'' ',L,
;//;/FFFFFFFFFFFFFFFFF\\ L;
;FFFFFFFFFFFFFFFFF/ 'L/
';LFFFFFFFFFFFFFFFFL ';L,
.;;;.'/LFFFL\;;,;LL\FF/ ./L,
.;;;.'/LFFFL\\;;,;LL\\FF/ ./L,
.;;,' '.' ;; ,; ;L/,
',;,' ;' ,\\\\;
.;;. ,,';\\\\;'
.;;' ';L\/,
;;' ',/\L;'
;/ ',;/\/,'..
.;;' ';L\\/,
;;' ',/\\L;'
;/ ',;/\\/,'..
/; '.,;///;;. ,'
,;;;;;;//;;,. ,
.'
Expand Down
Loading

0 comments on commit bb67a8b

Please sign in to comment.