Skip to content

Commit

Permalink
merge script
Browse files Browse the repository at this point in the history
  • Loading branch information
legnaleurc committed Jan 4, 2024
1 parent ebd5834 commit f57fab0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 28 deletions.
38 changes: 38 additions & 0 deletions drive/app/unstable/listeh.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from argparse import ArgumentParser
from pathlib import Path
import asyncio
import re
import sys

from ..lib import create_default_drive


async def main(args: list[str]) -> int:
parser = ArgumentParser("lseh")
parser.add_argument("path", type=str)
kwargs = parser.parse_args(args)
path = Path(kwargs.path)

async with create_default_drive() as drive:
parent = await drive.get_node_by_path(path)
children = await drive.get_children(parent)
g = ((to_eid(_.name), _.name) for _ in children)
pair_list = [(eid, name) for eid, name in g if eid is not None]
pair_list.sort(reverse=True)
name_list = (name for _eid, name in pair_list)
for name in name_list:
print(name)

return 0


def to_eid(name: str) -> int | None:
m = re.search(r"\[(\d+)\]\.7z$", name)
if not m:
return None
eid = int(m.group(1))
return eid


if __name__ == "__main__":
sys.exit(asyncio.run(main(sys.argv[1:])))
28 changes: 0 additions & 28 deletions drive/legacy/shell/sort.py

This file was deleted.

3 changes: 3 additions & 0 deletions drive/listeh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#! /bin/sh

poetry run -- python3 -m app.unstable.listeh "$@"

0 comments on commit f57fab0

Please sign in to comment.