Skip to content

Commit

Permalink
feat: Adds e4edm ls
Browse files Browse the repository at this point in the history
  • Loading branch information
ntlhui committed Sep 23, 2024
1 parent 935ad65 commit d302d46
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion e4e_data_management/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def __init__(self):
'push',
'zip',
'unzip',
'prune'
'prune',
'ls',
]
self.parameters = [
Parameter(
Expand Down Expand Up @@ -85,6 +86,7 @@ def __init__(self):
self.__configure_prune_parser(parsers['prune'])
self.__configure_config_parser(parsers['config'])
self.__configure_activate_parser(parsers['activate'])
self.__configure_ls_parser(parsers['ls'])
# self.__configure_validate_parser(parsers['validate'])
# self.__configure_zip_parser(parsers['zip'])
# self.__configure_unzip_parser(parsers['unzip'])
Expand Down Expand Up @@ -219,6 +221,18 @@ def status_cmd(self):
"""
print(self.app.status())

def ls_dir(self, path: Path):
local_tz = dt.datetime.now().astimezone().tzinfo
print(path.as_posix())
dirs = sorted([node for node in path.glob('*') if node.is_dir()])
files = sorted([node for node in path.glob('*') if node.is_file()])
dir_times = [dt.datetime.fromtimestamp(node.stat().st_mtime, local_tz) for node in dirs]
file_times = [dt.datetime.fromtimestamp(node.stat().st_mtime, local_tz) for node in files]
for idx, dir in enumerate(dirs):
print(f'{dir_times[idx].isoformat()} {dir.name}')
for idx, file in enumerate(files):
print(f'{file_times[idx].isoformat()} {file.name}')

def main(self):
"""Main function
"""
Expand All @@ -231,6 +245,10 @@ def main(self):

arg_fn(**arg_dict)

def __configure_ls_parser(self, parser: argparse.ArgumentParser):
parser.add_argument('path', type=Path, default=Path('.'))
parser.set_defaults(func=self.ls_dir)

def __configure_config_parser(self, parser: argparse.ArgumentParser):
parser.add_argument('parameter',
type=str,
Expand Down

0 comments on commit d302d46

Please sign in to comment.