Commit 65cfb375ff8e9fe62d4f4938be0a0fc2515f129f
1 parent
5697793b86
Exists in
master
Structure du parser finie. Plus qu'à coder les fonctions du module data.
Showing 1 changed file with 45 additions and 0 deletions Inline Diff
volia/data.py
File was created | 1 | import argparse | |
2 | import sys | ||
3 | |||
4 | from volia.utils import SubCommandRunner | ||
5 | |||
6 | # Main parser | ||
7 | parser = argparse.ArgumentParser(description="manage files") | ||
8 | subparsers = parser.add_subparsers(title="actions") | ||
9 | |||
10 | |||
11 | |||
12 | # Filter ids | ||
13 | parser_filter = subparsers.add_parser("filter", help="filter a file") | ||
14 | parser_filter.add_argument("--file", type=str, help="path of the file to filter") | ||
15 | parser_filter.add_argument("--filter", type=str, help="filter file [id_from] [id_to]") | ||
16 | parser_filter.set_defaults(which="filter") | ||
17 | |||
18 | # Convert | ||
19 | parser_convert = subparsers.add_parser("convert", help="convert a file") | ||
20 | parser_convert.add_argument("--file", type=str, help="...") | ||
21 | parser_convert.add_argument("--type-from", type=str, choices=["old-masseffect", "new-masseffect"], help="...") | ||
22 | parser_convert.add_argument("--type", choices=["old-masseffect", "new-masseffect"]) | ||
23 | parser_convert.set_defaults(which="convert") | ||
24 | |||
25 | |||
26 | # Parse | ||
27 | args = parser.parse_args() | ||
28 | |||
29 | |||
30 | |||
31 | def filter_file(file_path, filter_path): | ||
32 | pass | ||
33 | |||
34 | |||
35 | def convert(file, type_from, type): | ||
36 | pass | ||
37 | |||
38 | |||
39 | if __name__ == "__main__": | ||
40 | runner = SubCommandRunner({ | ||
41 | "convert" : convert, | ||
42 | "filter": filter_file, | ||
43 | }) | ||
44 | |||
45 | runner.run(args.which, args.__dict__, remove="which") | ||
46 |