cleanup
This commit is contained in:
parent
2e09859cd9
commit
00686d7dad
@ -3,8 +3,8 @@
|
|||||||
import os,sys
|
import os,sys
|
||||||
import argparse
|
import argparse
|
||||||
import pathlib
|
import pathlib
|
||||||
from pathlib import Path
|
|
||||||
import itertools
|
import itertools
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser(description="Show diff in vim tab pages")
|
parser = argparse.ArgumentParser(description="Show diff in vim tab pages")
|
||||||
@ -23,21 +23,18 @@ def get_dir_info(dirname: Path):
|
|||||||
files.append(p)
|
files.append(p)
|
||||||
return dirs, files
|
return dirs, files
|
||||||
|
|
||||||
def get_chunks(aItems, bItems):
|
def get_pairs(aItems, bItems):
|
||||||
aItems = [(item, 'A') for item in aItems]
|
aItems = [(item, 'A') for item in aItems]
|
||||||
bItems = [(item, 'B') for item in bItems]
|
bItems = [(item, 'B') for item in bItems]
|
||||||
items = sorted(aItems + bItems)
|
items = sorted(aItems + bItems)
|
||||||
for name, items in itertools.groupby(items, lambda item: item[0].name):
|
for _, items in itertools.groupby(items, lambda item: item[0].name):
|
||||||
items = list(items)
|
items = list(items)
|
||||||
if len(items) == 2:
|
if len(items) == 2:
|
||||||
aItem, bItem = items
|
(aItem, _), (bItem, _) = items
|
||||||
aItem, _ = aItem
|
|
||||||
bItem, _ = bItem
|
|
||||||
yield aItem, bItem
|
yield aItem, bItem
|
||||||
else:
|
else:
|
||||||
assert(len(items) == 1)
|
assert(len(items) == 1)
|
||||||
item, = items
|
(item, tag), = items
|
||||||
item, tag = item
|
|
||||||
if tag == 'A':
|
if tag == 'A':
|
||||||
yield item, None
|
yield item, None
|
||||||
else:
|
else:
|
||||||
@ -46,19 +43,16 @@ def get_chunks(aItems, bItems):
|
|||||||
def get_file_pairs(a, b):
|
def get_file_pairs(a, b):
|
||||||
aDirs, aFiles = get_dir_info(Path(a))
|
aDirs, aFiles = get_dir_info(Path(a))
|
||||||
bDirs, bFiles = get_dir_info(Path(b))
|
bDirs, bFiles = get_dir_info(Path(b))
|
||||||
print(f"{a=}, {aDirs=}, {aFiles=}, {b=}, {bDirs=}, {bFiles=}")
|
yield from get_pairs(aFiles, bFiles)
|
||||||
yield from get_chunks(aFiles, bFiles)
|
for aDir, bDir in get_pairs(aDirs, bDirs):
|
||||||
for aDir, bDir in get_chunks(aDirs, bDirs):
|
|
||||||
yield from get_file_pairs(aDir, bDir)
|
yield from get_file_pairs(aDir, bDir)
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
dirs, files = get_dir_info(Path('.'))
|
|
||||||
print(f"{dirs=} {files=}")
|
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
print("Helloworld")
|
print("Helloworld")
|
||||||
print(f"{args.pathA=} {args.pathB=}")
|
|
||||||
for a, b in get_file_pairs(args.pathA, args.pathB):
|
for a, b in get_file_pairs(args.pathA, args.pathB):
|
||||||
print(f"{a=}, {b=}")
|
print(f"{a=}, {b=}")
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user