Skip to content

Commit

Permalink
prepare for next version of inform
Browse files Browse the repository at this point in the history
  • Loading branch information
Ken Kundert authored and Ken Kundert committed Jan 3, 2023
1 parent 6834b86 commit 777895b
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 56 deletions.
1 change: 1 addition & 0 deletions clean
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
set nonomatch

(cd tests && ./clean)
rm -rf .mypy_cache

# the rest is common to all python directories
rm -f *.pyc *.pyo */*.pyc */*.pyo .test*.sum expected result install.out
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

# General information about the project.
project = u'emborg'
copyright = u'2018-2022, Ken Kundert'
copyright = u'2018-2023, Ken Kundert'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down
2 changes: 1 addition & 1 deletion emborg/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# than for large collections.

# License {{{1
# Copyright (C) 2016-2022 Kenneth S. Kundert
# Copyright (C) 2016-2023 Kenneth S. Kundert
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
12 changes: 6 additions & 6 deletions emborg/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ class DueCommand(Command):
REQUIRES_EXCLUSIVITY = False
COMPOSITE_CONFIGS = "all"
LOG_COMMAND = False
MESSAGES = {}
MESSAGES = {} # type: dict[str, str]
SHOW_CONFIG_NAME = False
OLDEST_DATE = None
OLDEST_CONFIG = None
Expand Down Expand Up @@ -1586,8 +1586,8 @@ def run(cls, command, args, settings, options):
if cmdline['--no-color']:
healthy_color = broken_color = lambda x: x
else:
healthy_color = Color("green", Color.isTTY())
broken_color = Color("red", Color.isTTY())
healthy_color = Color("green", enable=Color.isTTY())
broken_color = Color("red", enable=Color.isTTY())
total_size = 0
for values in lines:
# this loop can be quite slow. the biggest issue is arrow. parsing
Expand Down Expand Up @@ -1953,9 +1953,9 @@ def run(cls, command, args, settings, options):
show_available = cmdline["--available"]
width = 26
leader = (width+2)*' '
unknown = Color("yellow", Color.isTTY())
known = Color("cyan", Color.isTTY())
resolved = Color("magenta", Color.isTTY())
unknown = Color("yellow", enable=Color.isTTY())
known = Color("cyan", enable=Color.isTTY())
resolved = Color("magenta", enable=Color.isTTY())
color_adjust = len(known('x')) - 1

if show_available:
Expand Down
2 changes: 1 addition & 1 deletion emborg/emborg.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Emborg Settings

# License {{{1
# Copyright (C) 2018-2022 Kenneth S. Kundert
# Copyright (C) 2018-2023 Kenneth S. Kundert
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion emborg/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Output a help topic.

# License {{{1
# Copyright (C) 2018-2022 Kenneth S. Kundert
# Copyright (C) 2018-2023 Kenneth S. Kundert
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand Down
2 changes: 1 addition & 1 deletion emborg/patterns.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Patterns and Excludes

# License {{{1
# Copyright (C) 2018-2022 Kenneth S. Kundert
# Copyright (C) 2018-2023 Kenneth S. Kundert
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down
57 changes: 26 additions & 31 deletions emborg/preferences.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Emborg Preferences
#
# Copyright (C) 2018-2022 Kenneth S. Kundert
# Copyright (C) 2018-2023 Kenneth S. Kundert

# License {{{1
# This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -108,133 +108,128 @@
# Borg settings {{{2
BORG_SETTINGS = dict(
append_only = dict(
cmds = "init",
cmds = ["init"],
desc = "create an append-only mode repository"
),
chunker_params = dict(
cmds = "create",
cmds = ["create"],
arg = "PARAMS",
desc = "specify the chunker parameters"
),
compression = dict(
cmds = "create",
cmds = ["create"],
arg = "COMPRESSION",
desc = "compression algorithm"
),
exclude_caches = dict(
cmds = "create",
cmds = ["create"],
desc = "exclude directories that contain a CACHEDIR.TAG file"
),
exclude_nodump = dict(
cmds = "create",
cmds = ["create"],
desc = "exclude files flagged NODUMP"
),
exclude_if_present = dict(
cmds = "create",
cmds = ["create"],
arg = "NAME",
desc = "exclude directories that are tagged by containing a filesystem object with the given NAME",
),
lock_wait = dict(
cmds = "all",
cmds = ["all"],
arg = "SECONDS",
desc = "wait at most SECONDS for acquiring a repository/cache lock (default: 1)",
),
keep_within = dict(
cmds = "prune",
cmds = ["prune"],
arg = "INTERVAL",
desc = "keep all archives within this time interval"
),
keep_last = dict(
cmds = "prune",
cmds = ["prune"],
arg = "NUM",
desc = "number of the most recent archives to keep"
),
keep_minutely = dict(
cmds = "prune",
cmds = ["prune"],
arg = "NUM",
desc = "number of minutely archives to keep"
),
keep_hourly = dict(
cmds = "prune",
cmds = ["prune"],
arg = "NUM",
desc = "number of hourly archives to keep"
),
keep_daily = dict(
cmds = "prune",
cmds = ["prune"],
arg = "NUM",
desc = "number of daily archives to keep"
),
keep_weekly = dict(
cmds = "prune",
cmds = ["prune"],
arg = "NUM",
desc = "number of weekly archives to keep"
),
keep_monthly = dict(
cmds = "prune",
cmds = ["prune"],
arg = "NUM",
desc = "number of monthly archives to keep"
),
keep_yearly = dict(
cmds = "prune",
cmds = ["prune"],
arg = "NUM",
desc = "number of yearly archives to keep"
),
one_file_system = dict(
cmds = "create",
cmds = ["create"],
desc = "stay in the same file system and do not store mount points of other file systems",
),
remote_path = dict(
cmds = "all",
cmds = ["all"],
arg = "CMD",
desc = "name of borg executable on remote platform",
),
remote_ratelimit = dict(
cmds = "all",
cmds = ["all"],
arg = "RATE",
desc = "set remote network upload rate limit in kiB/s (default: 0=unlimited)",
),
sparse = dict(
cmds = "create",
cmds = ["create"],
desc = "detect sparse holes in input (supported only by fixed chunker)"
),
threshold = dict(
cmds = "compact",
cmds = ["compact"],
arg = "PERCENT",
desc = "set minimum threshold in percent for saved space when compacting (default: 10)",
),
umask = dict(
cmds = "all",
cmds = ["all"],
arg = "M",
desc = "set umask to M (local and remote, default: 0077)"
),
upload_buffer = dict(
cmds = "all",
cmds = ["all"],
arg = "UPLOAD_BUFFER",
desc = "set network upload buffer size in MiB (default: 0=no buffer)",
),
upload_ratelimit = dict(
cmds = "all",
cmds = ["all"],
arg = "RATE",
desc = "set rate limit in kiB/s, used when writing to a remote network (default: 0=unlimited)",
),
prefix = dict(
cmds = "check delete info list mount prune",
cmds = ["check", "delete", "info", "list", "mount", "prune"],
arg = "PREFIX",
desc = "only consider archive names starting with this prefix",
),
glob_archives = dict(
cmds = "check delete info list mount prune",
cmds = ["check", "delete", "info", "list", "mount", "prune"],
arg = "GLOB",
desc = "only consider archive names matching the glob",
),
)

# Utilities {{{2
# convert args to lists
for opt, attrs in BORG_SETTINGS.items():
attrs["cmds"] = attrs["cmds"].split()


# utility function that converts setting names to borg option names
def convert_name_to_option(name):
return "--" + name.replace("_", "-")
Expand Down
2 changes: 1 addition & 1 deletion emborg/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# Package for reading and writing Python files.

# License {{{1
# Copyright (C) 2018-2022 Kenneth S. Kundert
# Copyright (C) 2018-2023 Kenneth S. Kundert
#
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
Expand Down
18 changes: 9 additions & 9 deletions emborg/shlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# shell-script-like things relatively easily in Python.

# License {{{1
# Copyright (C) 2016-2022 Kenneth S. Kundert
# Copyright (C) 2016-2023 Kenneth S. Kundert
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -111,12 +111,12 @@ def quote_arg(arg):
import re
except ImportError:

def quote(arg):
if not arg:
def quote(s): # type: (str) -> str
if not s:
return "''"
if re.search(r"[^\w@%+=:,./-]", arg, re.ASCII) is None:
return arg
return "'" + arg.replace("'", "'\"'\"'") + "'"
if re.search(r"[^\w@%+=:,./-]", s, re.ASCII) is None:
return s
return "'" + s.replace("'", "'\"'\"'") + "'"

return quote(str(arg))

Expand Down Expand Up @@ -257,17 +257,17 @@ def mkdir(*paths):
class mount:
def __init__(self, path):
self.path = to_path(path)
self.mounted_externally = is_mounted(self.path)
self.previously_mounted = is_mounted(self.path)
modes = 'sOEW0' if PREFERENCES["use_inform"] else 'soeW0'

if not self.mounted_externally:
if not self.previously_mounted:
Run(["mount", self.path], modes=modes)

def __enter__(self):
pass

def __exit__(self, exc_type, exc_value, exc_traceback):
if not self.mounted_externally:
if not self.previously_mounted:
umount(self.path)


Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name = "emborg"
version = "1.34"
description = "Borg front end."
readme = "README.rst"
license = {file = "LICENSE"}
keywords = ["emborg", "borg", "borgmatic", "backups"]
authors = [
{name = "Ken Kundert"},
Expand Down
20 changes: 17 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = lint,pytest
envlist = lint, pytest, mypy
isolated_build = True

[testenv:lint]
Expand All @@ -8,14 +8,28 @@ skip_install = true
commands = pylama --ignore C901,E116,E251,E203,E501,E741,E731 emborg/*.py

# Test environment
[testenv:pytest]
[testenv]
deps =
nestedtext
pytest
pytest-cov
parametrize-from-file
shlib
voluptuous
# commands = py.test -vv --cov {posargs} --cov-branch --cov-report html

[testenv:pytest]
# commands = py.test -vv --cov {posargs} --cov-branch --cov-report term-missing
commands = py.test -vv --cov {posargs} --cov-branch --cov-report term

[testenv:mypy]
description = Run mypy
deps =
mypy
quantiphy
{[testenv]deps}
commands =
mypy \
--install-types \
--non-interactive \
--disable-error-code import \
{toxinidir}/emborg

0 comments on commit 777895b

Please sign in to comment.