Gitlab Community Edition Instance

Commit 4d18629e authored by Marcel Hellkamp's avatar Marcel Hellkamp
Browse files

Make linter happy

parent c56d1090
......@@ -32,9 +32,7 @@ def register(subparsers):
def ls(ctx, args):
client, vault, archive, prefix = ctx.resolve(args.REF)
opts = {}
opts["order"] = args.order
opts["reverse"] = args.reverse
opts = {"order": args.order, "reverse": args.reverse}
if prefix.strip('/'):
opts['include_glob'] = ["/{}/**".format(prefix.strip('/'))]
if args.include:
......@@ -53,26 +51,27 @@ def ls(ctx, args):
# Load metadata only if requested
opts["meta"] = True
def file2str(file):
attrs = defaultdict(lambda: "-")
attrs.update(file)
attrs.update(file['digests'])
if '{hsize' in fmt:
attrs["hsize"] = hbytes(attrs["size"])
if '{created' in fmt:
attrs["created"] = iso8601.parse_date(attrs["created"])
if '{modified' in fmt:
attrs["modified"] = iso8601.parse_date(attrs["modified"])
if '{meta' in fmt:
meta = defaultdict(lambda: "-")
meta.update(attrs["meta"])
attrs["meta"] = meta
return fmt.format_map(attrs)
with client.begin(readonly=True):
n = b = 0
for file in client.iter_files(vault, archive, **opts):
n += 1
b += file['size']
print(file2str(file))
print(file2str(fmt, file))
printer("\nTotal: {:,} files {:,} bytes", n, b)
def file2str(fmt, file):
attrs = defaultdict(lambda: "-")
attrs.update(file)
attrs.update(file['digests'])
if '{hsize' in fmt:
attrs["hsize"] = hbytes(attrs["size"])
if '{created' in fmt:
attrs["created"] = iso8601.parse_date(attrs["created"])
if '{modified' in fmt:
attrs["modified"] = iso8601.parse_date(attrs["modified"])
if '{meta' in fmt:
meta = defaultdict(lambda: "-")
meta.update(attrs["meta"])
attrs["meta"] = meta
return fmt.format_map(attrs)
......@@ -17,7 +17,7 @@ import os
from pycdstar3 import FormUpdate
from pycdstar3.cli import printer, CliError
from pycdstar3.cli._utils import compile_glob, hbytes, kvtype, globtype
from pycdstar3.cli._utils import hbytes, kvtype, globtype
def register(subparsers):
......@@ -62,7 +62,6 @@ def collect_files(path, hidden=False):
if os.path.isfile(path):
yield path
elif os.path.isdir(path):
files = []
for (root, dlist, flist) in os.walk(path):
if not hidden:
dlist[:] = [name for name in dlist if not name.startswith('.')]
......
......@@ -341,7 +341,7 @@ class ApiError(Exception):
try:
self.json = rs.json()
except JSONDecodeError as e:
except JSONDecodeError:
raise AssertionError("Failed to decode server error response (invalid JSON) for: " + rs.request)
@property
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment