MCPcopy
hub / github.com/deadc0de6/dotdrop / _workdir_enum

Function _workdir_enum

dotdrop/dotdrop.py:384–419  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

382
383
384def _workdir_enum(opts):
385 workdir_files = []
386 for root, _, files in os.walk(opts.workdir):
387 for file in files:
388 fpath = os.path.join(root, file)
389 workdir_files.append(fpath)
390
391 for dotfile in opts.dotfiles:
392 src = os.path.join(opts.dotpath, dotfile.src)
393 if dotfile.link == LinkTypes.NOLINK:
394 # ignore not link files
395 continue
396 if not Templategen.path_is_template(src):
397 # ignore not template
398 continue
399 newpath = pivot_path(dotfile.dst, opts.workdir,
400 striphome=True, logger=None)
401 if os.path.isdir(newpath):
402 # recursive
403 pattern = f'{newpath}/*'
404 files = workdir_files.copy()
405 for file in files:
406 if fnmatch.fnmatch(file, pattern):
407 workdir_files.remove(file)
408 # only checks children
409 children = [f.path for f in os.scandir(newpath)]
410 for child in children:
411 if child in workdir_files:
412 workdir_files.remove(child)
413 else:
414 if newpath in workdir_files:
415 workdir_files.remove(newpath)
416 for wfile in workdir_files:
417 line = f'=> \"{wfile}\" does not exist in dotdrop'
418 LOG.log(line)
419 return len(workdir_files)
420
421
422def cmd_compare(opts, tmp):

Callers 1

cmd_compareFunction · 0.85

Calls 4

pivot_pathFunction · 0.90
path_is_templateMethod · 0.80
logMethod · 0.80
copyMethod · 0.45

Tested by

no test coverage detected