Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/snappy' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kraanzu committed Oct 1, 2024
2 parents c2d9919 + 3d5adb7 commit be9ce82
Show file tree
Hide file tree
Showing 123 changed files with 5,336 additions and 4,353 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
- name: Set up Python 3.11
uses: actions/setup-python@v3
with:
python-version: "3.10"
python-version: "3.11"

- name: Install dependencies
run: |
Expand All @@ -32,7 +32,7 @@ jobs:
- name: Package app with pyinstaller
run: |
python -c "with open('dooit.py', 'w') as f: f.write('from dooit.__main__ import main\nmain()\n')"
pyinstaller --clean -F dooit.py --add-data="dooit/utils/default_config.py:dooit/utils/"
pyinstaller --clean -F dooit.py --add-data="dooit/utils/default_config.py:dooit/utils/" --add-data="dooit/ui/styles.tcss:dooit/ui/"
# Setup File name
- name: Set Binary file name on Linux and Mac
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/pyinstaller_binary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# name: Pyinstaller Binary Run
#
# on: [push, pull_request, workflow_dispatch]
#
# jobs:
# lint:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# python-version: ["3.11"]
# steps:
# - uses: actions/checkout@v3
# - 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 .
# pip install ruff
# pip install pyinstaller
#
# - name: Package app with pyinstaller
# run: |
# python -c "with open('dooit.py', 'w') as f: f.write('from dooit.__main__ import main\nmain()\n')"
# pyinstaller --clean -F dooit.py --add-data="dooit/utils/default_config.py:dooit/utils/" --add-data="dooit/ui/styles.tcss:dooit/ui/"
# - name: Check by running
# run: |
# chmod +x ./dist/dooit
# ./dist/dooit
13 changes: 10 additions & 3 deletions .github/workflows/linting.yml → .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Ruff and Black
name: Ruff Checks (lint/format)

on: [push, pull_request]

Expand All @@ -17,8 +17,15 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff black
- name: Analysing the code with ruff and black
pip install ruff
- name: Lint Check
run: |
<<<<<<< HEAD:.github/workflows/linting.yml
ruff check $(git ls-files '*.py')
black $(git ls-files '*.py')
=======
ruff check .
- name: Format Check
run: |
ruff format --check .
>>>>>>> origin/snappy:.github/workflows/ruff.yml
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
# dooit stuf
playground/
.playground/
test.py
todos
sample_todo.yaml
snappy.py
dooit.db

# Nix
result

# VSCODE
.vscode/
Expand Down
15 changes: 11 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
repos:
- repo: local
hooks:
- id: black
name: black
entry: black
- id: ruff
name: ruff format
entry: ruff format
language: system
types: [python]
require_serial: true
Expand All @@ -13,4 +13,11 @@ repos:
entry: ruff
language: system
types: [python]
require_serial: true
args: [--check]

- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: true
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,28 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 3.0.0

## Added
- Brand new dooit api for configurations
- Faster UI and startup overall
- Event based code execution via dooit api
- Customize the columns order and visibility for todos and workspaces
- Allow addition of custom keybinds to trigger certain functions
- Better optimized bar (wont block ui)
- Custom formatters for column values to suit your needs!
- Multiple Theme support
- Custom CSS injections into the UI


## Removed
- Now todos are no longer stored in `todo.yaml`, run dooit --migrate to migrate to new format
- Old config will no longer work, see the [latest docs]() to check out the configuration
also check out [dooit community themes]() and [dooit snippet hacks]() for interesting config options

> [!NOTE]
> The support for YAML will be dropped from v3.0.0
## 2.2.0

### Added
Expand Down
63 changes: 0 additions & 63 deletions PKGBUILD

This file was deleted.

7 changes: 7 additions & 0 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
hide:
- toc
- navigation
---

# Welcome
7 changes: 4 additions & 3 deletions dooit/__main__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import argparse
from importlib.metadata import version
from dooit.ui.tui import Dooit

VERSION = "3.0.0"


def main():
Expand All @@ -8,8 +10,7 @@ def main():
args = parser.parse_args()

if args.version:
ver = version("dooit")
print(f"dooit - {ver}")
print(f"dooit - {VERSION}")
else:
from dooit.ui.tui import Dooit
Dooit().run()
Expand Down
15 changes: 12 additions & 3 deletions dooit/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from .model import Model
from .manager import Manager, manager
from .model import DooitModel, BaseModel
from .todo import Todo
from .workspace import Workspace
from .manager import manager
from .hooks import fix_hooks, validation_hooks

__all__ = ["Model", "Manager", "Todo", "Workspace", "manager"]
__all__ = [
"BaseModel",
"DooitModel",
"Todo",
"Workspace",
"manager",
"fix_hooks",
"validation_hooks",
]
6 changes: 6 additions & 0 deletions dooit/api/_vars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from pathlib import Path
from platformdirs import user_data_dir

ROOT_FOLDER = Path(user_data_dir("dooit"))
DATABASE_FILE = ROOT_FOLDER / "dooit.db"
DATABASE_CONN_STRING = f"sqlite:////{DATABASE_FILE}"
34 changes: 34 additions & 0 deletions dooit/api/exceptions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
class DooitError(Exception):
"""
Base class for all exceptions raised by the API.
"""


class NoParentError(DooitError):
"""
Raised when user tries to add a Todo object without a parent
"""


class MultipleParentError(DooitError):
"""
Raised when user tries to add a Todo object with both a workspace and a todo parent
"""


class SiblingAdditionError(DooitError):
"""
Raised when user tries to add a sibling to a non-parented node (i.e Manager Object)
"""


class WorkspaceAdditionError(DooitError):
"""
Raised when user tries to add a workspace to a todo object
"""


class TodoAdditionError(DooitError):
"""
Raised when user tries to add a todo to manager class
"""
26 changes: 26 additions & 0 deletions dooit/api/hooks/fix_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from sqlalchemy import event
from ..workspace import Workspace
from ..todo import Todo


@event.listens_for(Workspace, "before_update")
@event.listens_for(Workspace, "before_insert")
def fix_order_id_workspace(mapper, connection, target: Workspace):
if target.is_root:
return

if target.order_index is None or target.order_index == -1:
target.order_index = len(target.siblings) - 1


@event.listens_for(Todo, "before_insert")
@event.listens_for(Todo, "before_update")
def fix_order_id_todo(mapper, connection, target: Todo):
if target.order_index is None or target.order_index == -1:
target.order_index = len(target.siblings) - 1


#
# @event.listens_for(Workspace.__table__, "after_create")
# def create_root(target: Table, connection: Connection, **kw):
# connection.execute(target.insert(), {"is_root": True})
13 changes: 13 additions & 0 deletions dooit/api/hooks/validation_hooks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from sqlalchemy import event
from ..exceptions import NoParentError, MultipleParentError
from ..todo import Todo


@event.listens_for(Todo, "before_insert")
@event.listens_for(Todo, "before_update")
def validate_parent_todo(mapper, connection, target: Todo):
if target.parent_workspace is None and target.parent_todo is None:
raise NoParentError("Todo must have a parent workspace or todo")

if target.parent_workspace is not None and target.parent_todo is not None:
raise MultipleParentError("Todo cannot have both a parent workspace and todo")
Loading

0 comments on commit be9ce82

Please sign in to comment.