Skip to content

Commit

Permalink
Merge pull request #728
Browse files Browse the repository at this point in the history
v4.1.2
  • Loading branch information
MatteoCampinoti94 authored Sep 25, 2024
2 parents 49672f0 + ae786cc commit bbd0e95
Show file tree
Hide file tree
Showing 19 changed files with 179 additions and 280 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v4.1.2

### Changes

* Use acacore 3.1.0

## v4.1.1

### Changes
Expand Down
2 changes: 1 addition & 1 deletion digiarch/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "4.1.1"
__version__ = "4.1.2"
2 changes: 1 addition & 1 deletion digiarch/commands/completions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import ClassVar
from typing import Type

from acacore.utils.decorators import docstring_format
from click import argument
from click import BadParameter
from click import Choice
Expand All @@ -16,7 +17,6 @@
from click.shell_completion import ZshComplete

from digiarch.common import ctx_params
from digiarch.common import docstring_format


class CompleteChoice(Choice):
Expand Down
9 changes: 5 additions & 4 deletions digiarch/commands/doctor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,20 @@

from acacore.database import FileDB
from acacore.models.history import HistoryEntry
from acacore.utils.click import check_database_version
from acacore.utils.click import end_program
from acacore.utils.click import start_program
from acacore.utils.helpers import ExceptionManager
from click import Choice
from click import command
from click import Context
from click import option
from click import pass_context

from digiarch.__version__ import __version__
from digiarch.common import argument_root
from digiarch.common import check_database_version
from digiarch.common import ctx_params
from digiarch.common import end_program
from digiarch.common import option_dry_run
from digiarch.common import start_program

invalid_characters: str = "\\#%&{}[]<>*?/$!'\":@+`|=" + bytes(range(32)).decode("ascii") + "\x7f"

Expand Down Expand Up @@ -166,7 +167,7 @@ def command_doctor(ctx: Context, root: Path, fix: tuple[str, ...], dry_run: bool
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, not dry_run, True, False)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, not dry_run, True, False)

with ExceptionManager(BaseException) as exception:
if not fix or "paths" in fix:
Expand Down
31 changes: 16 additions & 15 deletions digiarch/commands/edit/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
from acacore.models.reference_files import TActionType
from acacore.models.reference_files import TemplateTypeEnum
from acacore.models.reference_files import TTemplateType
from acacore.utils.click import check_database_version
from acacore.utils.click import end_program
from acacore.utils.click import param_callback_regex
from acacore.utils.click import start_program
from acacore.utils.decorators import docstring_format
from acacore.utils.helpers import ExceptionManager
from click import argument
from click import BadParameter
Expand All @@ -26,15 +31,11 @@
from click import Path as ClickPath
from pydantic import BaseModel

from digiarch.__version__ import __version__
from digiarch.common import argument_root
from digiarch.common import check_database_version
from digiarch.common import ctx_params
from digiarch.common import docstring_format
from digiarch.common import end_program
from digiarch.common import fetch_actions
from digiarch.common import option_dry_run
from digiarch.common import param_regex
from digiarch.common import start_program

from .common import argument_query
from .common import find_files
Expand Down Expand Up @@ -99,7 +100,7 @@ def group_action():
"--outputs",
type=str,
multiple=True,
callback=param_regex("^(.[a-zA-Z0-9]+)+$"),
callback=param_callback_regex("^(.[a-zA-Z0-9]+)+$"),
help='The file extensions to generate. [multiple; required for tools other than "copy"]',
)
@option("--lock", is_flag=True, default=False, help="Lock the edited files.")
Expand Down Expand Up @@ -134,7 +135,7 @@ def action_convert(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand All @@ -153,7 +154,7 @@ def action_convert(
@option(
"--extension",
type=str,
callback=param_regex(r"^(.[a-zA-Z0-9]+)+$"),
callback=param_callback_regex(r"^(.[a-zA-Z0-9]+)+$"),
help="The extension the file must have for extraction to succeed.",
)
@option("--lock", is_flag=True, default=False, help="Lock the edited files.")
Expand Down Expand Up @@ -183,7 +184,7 @@ def action_extract(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand All @@ -203,14 +204,14 @@ def action_extract(
"data_reason",
type=str,
required=True,
callback=param_regex(r"^.*\S.*$"),
callback=param_callback_regex(r"^.*\S.*$"),
help="The reason why the file must be processed manually.",
)
@option(
"--process",
type=str,
required=True,
callback=param_regex(r"^.*\S.*$"),
callback=param_callback_regex(r"^.*\S.*$"),
help="The steps to take to process the file.",
)
@option("--lock", is_flag=True, default=False, help="Lock the edited files.")
Expand Down Expand Up @@ -240,7 +241,7 @@ def action_manual(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand All @@ -266,7 +267,7 @@ def action_manual(
"--reason",
"data_reason",
type=str,
callback=param_regex(r"^.*\S.*$"),
callback=param_callback_regex(r"^.*\S.*$"),
help='The reason why the file is ignored. [required for "text" template]',
)
@option("--lock", is_flag=True, default=False, help="Lock the edited files.")
Expand Down Expand Up @@ -306,7 +307,7 @@ def action_ignore(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand Down Expand Up @@ -378,7 +379,7 @@ def command_copy(
raise BadParameter(f"Action {action} not found in {puid}.", ctx, ctx_params(ctx)["puid"])

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand Down
9 changes: 5 additions & 4 deletions digiarch/commands/edit/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@

from acacore.database import FileDB
from acacore.models.history import HistoryEntry
from acacore.utils.click import check_database_version
from acacore.utils.click import end_program
from acacore.utils.click import start_program
from acacore.utils.helpers import ExceptionManager
from click import argument
from click import command
from click import Context
from click import option
from click import pass_context

from digiarch.__version__ import __version__
from digiarch.common import argument_root
from digiarch.common import check_database_version
from digiarch.common import ctx_params
from digiarch.common import end_program
from digiarch.common import option_dry_run
from digiarch.common import start_program

from .common import argument_query
from .common import find_files
Expand Down Expand Up @@ -49,7 +50,7 @@ def command_lock(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand Down
9 changes: 5 additions & 4 deletions digiarch/commands/edit/processed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@

from acacore.database import FileDB
from acacore.models.history import HistoryEntry
from acacore.utils.click import check_database_version
from acacore.utils.click import end_program
from acacore.utils.click import start_program
from acacore.utils.helpers import ExceptionManager
from click import argument
from click import command
from click import Context
from click import option
from click import pass_context

from digiarch.__version__ import __version__
from digiarch.common import argument_root
from digiarch.common import check_database_version
from digiarch.common import ctx_params
from digiarch.common import end_program
from digiarch.common import option_dry_run
from digiarch.common import start_program

from .common import argument_query
from .common import find_files
Expand Down Expand Up @@ -55,7 +56,7 @@ def command_processed(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand Down
9 changes: 5 additions & 4 deletions digiarch/commands/edit/remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@

from acacore.database import FileDB
from acacore.models.history import HistoryEntry
from acacore.utils.click import check_database_version
from acacore.utils.click import end_program
from acacore.utils.click import start_program
from acacore.utils.helpers import ExceptionManager
from click import argument
from click import command
from click import Context
from click import option
from click import pass_context

from digiarch.__version__ import __version__
from digiarch.common import argument_root
from digiarch.common import check_database_version
from digiarch.common import ctx_params
from digiarch.common import end_program
from digiarch.common import option_dry_run
from digiarch.common import start_program

from .common import argument_query
from .common import find_files
Expand Down Expand Up @@ -64,7 +65,7 @@ def command_remove(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand Down
13 changes: 7 additions & 6 deletions digiarch/commands/edit/rename.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@

from acacore.database import FileDB
from acacore.models.history import HistoryEntry
from acacore.utils.click import check_database_version
from acacore.utils.click import end_program
from acacore.utils.click import param_callback_regex
from acacore.utils.click import start_program
from acacore.utils.helpers import ExceptionManager
from click import argument
from click import command
from click import Context
from click import option
from click import pass_context

from digiarch.__version__ import __version__
from digiarch.common import argument_root
from digiarch.common import check_database_version
from digiarch.common import ctx_params
from digiarch.common import end_program
from digiarch.common import option_dry_run
from digiarch.common import param_regex
from digiarch.common import start_program

from .common import argument_query
from .common import find_files
Expand All @@ -33,7 +34,7 @@
nargs=1,
type=str,
required=True,
callback=param_regex(r"^((\.[a-zA-Z0-9]+)+| +)$"),
callback=param_callback_regex(r"^((\.[a-zA-Z0-9]+)+| +)$"),
)
@argument("reason", nargs=1, type=str, required=True)
@option("--append", "replace_mode", flag_value="append", default=True, help="Append the new extension. [default]")
Expand Down Expand Up @@ -65,7 +66,7 @@ def command_rename(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, not dry_run, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, not dry_run, True, dry_run)

with ExceptionManager(BaseException) as exception:
for file in find_files(database, query):
Expand Down
13 changes: 7 additions & 6 deletions digiarch/commands/edit/rollback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
from acacore.models.history import HistoryEntry
from acacore.models.reference_files import ActionData
from acacore.models.reference_files import TActionType
from acacore.utils.click import check_database_version
from acacore.utils.click import end_program
from acacore.utils.click import param_callback_regex
from acacore.utils.click import start_program
from acacore.utils.helpers import ExceptionManager
from click import argument
from click import command
Expand All @@ -17,13 +21,10 @@
from click import option
from click import pass_context

from digiarch.__version__ import __version__
from digiarch.common import argument_root
from digiarch.common import check_database_version
from digiarch.common import ctx_params
from digiarch.common import end_program
from digiarch.common import option_dry_run
from digiarch.common import param_regex
from digiarch.common import start_program


def rollback_edit_action(database: FileDB, event: HistoryEntry, dry_run: bool) -> tuple[File | None, str | None]:
Expand Down Expand Up @@ -166,7 +167,7 @@ def rollback_doctor_files(
"commands",
type=str,
multiple=True,
callback=param_regex(r"^[a-z-]+(.[a-z-]+)*$"),
callback=param_callback_regex(r"^[a-z-]+(.[a-z-]+)*$"),
help="Specify commands to roll back. [multiple]",
)
@option_dry_run()
Expand Down Expand Up @@ -206,7 +207,7 @@ def command_rollback(
check_database_version(ctx, ctx_params(ctx)["root"], (db_path := root / "_metadata" / "files.db"))

with FileDB(db_path) as database:
log_file, log_stdout, _ = start_program(ctx, database, None, True, True, dry_run)
log_file, log_stdout, _ = start_program(ctx, database, __version__, None, True, True, dry_run)

with ExceptionManager(BaseException) as exception:
where = "uuid is not null and time >= ? and time <= ?"
Expand Down
Loading

0 comments on commit bbd0e95

Please sign in to comment.