Skip to content

Commit

Permalink
pre-commit autoupdate
Browse files Browse the repository at this point in the history
  • Loading branch information
tdegeus committed Apr 11, 2023
1 parent 2edd8cb commit 57e7bc5
Show file tree
Hide file tree
Showing 21 changed files with 3 additions and 80 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.3.0
hooks:
- id: black
args: [--safe, --quiet, --line-length=100]
Expand All @@ -12,7 +12,7 @@ repos:
- id: check-yaml
- id: debug-statements
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.5.0
rev: v2.8.0
hooks:
- id: pretty-format-yaml
args: [--autofix, --indent, '2', --preserve-quotes]
Expand Down Expand Up @@ -40,7 +40,7 @@ repos:
hooks:
- id: setup-cfg-fmt
- repo: https://github.com/tdegeus/conda_envfile
rev: v0.4.1
rev: v0.4.2
hooks:
- id: conda_envfile_parse
files: environment.yaml
5 changes: 0 additions & 5 deletions shelephant/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ def shelephant_diff(args: list[str]):
remote = {"files": remote, "prefix": os.path.dirname(args.remote), "list": True}

for field in [local, remote]:

if "host" in field:
field["dirname"] = field["host"] + ":" + field["prefix"]
else:
Expand Down Expand Up @@ -119,9 +118,7 @@ def shelephant_diff(args: list[str]):
for filename, value in zip(
[args.get_new, args.get_diff, args.get_all], [ret["<-"], ret["!="], ret["<-"] + ret["!="]]
):

if filename is not None:

stop = True
tmp = {"files": value}
for key in ["host", "prefix"]:
Expand All @@ -133,9 +130,7 @@ def shelephant_diff(args: list[str]):
[args.send_new, args.send_diff, args.send_all],
[ret["->"], ret["!="], ret["->"] + ret["!="]],
):

if filename is not None:

assert "host" not in local, "Not supported by shelephant_send."
assert len(os.path.dirname(args.local)) == 0, "Not supported by shelephant_send."
stop = True
Expand Down
1 change: 0 additions & 1 deletion shelephant/checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def get(filepaths, yaml_hostinfo=None, hybrid=False, progress=False):
# Compute

if not yaml_hostinfo:

for i in tqdm.trange(n, disable=not progress, desc="Processing"):
if os.path.isfile(filepaths[i]):
ret[i] = sha256(filepaths[i])
Expand Down
1 change: 0 additions & 1 deletion shelephant/cli/shelephant_checksum.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,4 @@ def main():


if __name__ == "__main__":

main()
1 change: 0 additions & 1 deletion shelephant/cli/shelephant_cp.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,4 @@ def main():


if __name__ == "__main__":

main()
1 change: 0 additions & 1 deletion shelephant/cli/shelephant_dump.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,5 +114,4 @@ def main():


if __name__ == "__main__":

main()
1 change: 0 additions & 1 deletion shelephant/cli/shelephant_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,5 +95,4 @@ def main():


if __name__ == "__main__":

main()
4 changes: 0 additions & 4 deletions shelephant/cli/shelephant_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def print_help(self):
data = yaml.read(source)

if "host" not in data:

detail.copy(
copy_function=shutil.copy2,
files=data["files"],
Expand All @@ -129,7 +128,6 @@ def print_help(self):
)

elif args.scp:

detail.copy_ssh(
copy_function=scp.from_remote,
use_rsync=False,
Expand All @@ -153,7 +151,6 @@ def print_help(self):
)

else:

detail.copy_ssh(
copy_function=rsync.from_remote,
use_rsync=True,
Expand Down Expand Up @@ -182,5 +179,4 @@ def main():


if __name__ == "__main__":

main()
5 changes: 0 additions & 5 deletions shelephant/cli/shelephant_hostinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@


def remove(data, rm):

files = np.array(data["files"])
sorter = np.argsort(files)
files = files[sorter]
Expand All @@ -88,7 +87,6 @@ def remove(data, rm):


def main_impl():

# Parse command-line arguments

class Parser(argparse.ArgumentParser):
Expand Down Expand Up @@ -161,9 +159,7 @@ def print_help(self):
args_dict = vars(args)

for item in ["files", "checksum"]:

if args_dict[item]:

key = list(filter(None, args_dict[item + "_key"].split("/")))
filename = args_dict[item]

Expand Down Expand Up @@ -206,5 +202,4 @@ def main():


if __name__ == "__main__":

main()
5 changes: 0 additions & 5 deletions shelephant/cli/shelephant_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ def print_help(self):
output_dir = os.path.dirname(output)

if not args.no_path:

paths = [os.path.dirname(args.main), os.path.dirname(args.branch)]

for var, path in zip([main, branch], paths):
Expand All @@ -94,7 +93,6 @@ def print_help(self):
raise OSError("Files have an incompatible structure")

if type(main) == list and type(branch) == list:

if args.skip:
pass
elif args.replace:
Expand All @@ -103,7 +101,6 @@ def print_help(self):
main += branch

elif type(main) == dict and type(branch) == dict:

if args.skip:
mergedeep.merge(branch, main, strategy=mergedeep.Strategy.REPLACE)
main = branch
Expand All @@ -113,7 +110,6 @@ def print_help(self):
mergedeep.merge(main, branch, strategy=mergedeep.Strategy.ADDITIVE)

else:

raise OSError("Files have an incompatible structure")

yaml.dump(output, main, args.force)
Expand All @@ -124,5 +120,4 @@ def main():


if __name__ == "__main__":

main()
1 change: 0 additions & 1 deletion shelephant/cli/shelephant_mv.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,4 @@ def main():


if __name__ == "__main__":

main()
1 change: 0 additions & 1 deletion shelephant/cli/shelephant_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,4 @@ def main():


if __name__ == "__main__":

main()
1 change: 0 additions & 1 deletion shelephant/cli/shelephant_rm.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,4 @@ def main():


if __name__ == "__main__":

main()
4 changes: 0 additions & 4 deletions shelephant/cli/shelephant_send.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def print_help(self):
dest_dir = data["prefix"]

if "host" not in data:

detail.copy(
copy_function=shutil.copy2,
files=files,
Expand All @@ -141,7 +140,6 @@ def print_help(self):
)

elif args.scp:

detail.copy_ssh(
copy_function=scp.to_remote,
use_rsync=False,
Expand All @@ -164,7 +162,6 @@ def print_help(self):
)

else:

detail.copy_ssh(
copy_function=rsync.to_remote,
use_rsync=True,
Expand Down Expand Up @@ -192,5 +189,4 @@ def main():


if __name__ == "__main__":

main()
1 change: 0 additions & 1 deletion shelephant/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ def _squash_detail(data, parent_key="", sep="_"):
items = []

for k, v in data.items():

new_key = parent_key + sep + k if parent_key else k

if isinstance(v, collections.abc.MutableMapping):
Expand Down
6 changes: 0 additions & 6 deletions shelephant/detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,9 @@ def copy(
raise OSError(f'Input file "{file:s}" does not exists')

if not os.path.isdir(dest_dir):

create = [True for i in range(n)]

elif check_rsync:

tmp = diff(
source_dir=src_dir,
dest_dir=dest_dir,
Expand All @@ -111,7 +109,6 @@ def copy(
overwrite = tmp["overwrite"]

else:

if checksum:
src_checksums = get(src, yaml_hostinfo_src, progress=not quiet)
dest_checksums = get(dest, yaml_hostinfo_dest, progress=not quiet)
Expand Down Expand Up @@ -292,11 +289,9 @@ def copy_ssh(
color = theme(theme_name.lower())

if not os.path.isdir(dest_dir) and not to_remote:

create = [True for i in range(n)]

elif check_rsync:

tmp = diff(
source_dir=src_dir if to_remote else host + ":" + src_dir,
dest_dir=host + ":" + dest_dir if to_remote else dest_dir,
Expand All @@ -310,7 +305,6 @@ def copy_ssh(
overwrite = tmp["overwrite"]

else:

if checksum is True:
src_checksums = get(src, yaml_hostinfo_src, progress=not quiet)
dest_checksums = get(dest, yaml_hostinfo_dest, progress=not quiet)
Expand Down
1 change: 0 additions & 1 deletion shelephant/rich.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ class String:
"""

def __init__(self, data, width=None, align="<", color=None, dummy=0):

self.data = data
self.width = width
self.color = color
Expand Down
3 changes: 0 additions & 3 deletions shelephant/rsync.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def _rsync(source_dir, dest_dir, files, verbose=False, progress=True):
"""

with tempfile.TemporaryDirectory() as temp_dir:

temp_file = os.path.join(temp_dir, "rsync.txt")

with open(temp_file, "w") as file:
Expand All @@ -35,7 +34,6 @@ def _rsync(source_dir, dest_dir, files, verbose=False, progress=True):
# Run without printing output

if not progress:

cmd = 'rsync -a --files-from="{files:s}" "{source_dir:s}" "{dest_dir:s}"'.format(
source_dir=source_dir, dest_dir=dest_dir, files=temp_file
)
Expand Down Expand Up @@ -141,7 +139,6 @@ def diff(
"""

with tempfile.TemporaryDirectory() as temp_dir:

temp_file = os.path.join(temp_dir, "rsync.txt")
files = [os.path.normpath(file) for file in files]

Expand Down
1 change: 0 additions & 1 deletion tests/ssh_generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ def run(cmd):


for dirname in ["myssh_send", "myssh_get"]:

if os.path.isdir(dirname):
shutil.rmtree(dirname)

Expand Down
2 changes: 0 additions & 2 deletions tests/ssh_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def run(cmd):

class Test_ssh(unittest.TestCase):
def test_all(self):

operations = [
"bar.txt -> bar.txt",
"foo.txt == foo.txt",
Expand Down Expand Up @@ -105,7 +104,6 @@ def test_all(self):


if __name__ == "__main__":

Test_ssh.PREFIX = sys.argv.pop()
Test_ssh.HOST = sys.argv.pop()

Expand Down
Loading

0 comments on commit 57e7bc5

Please sign in to comment.