Commit 0baf1624addfef18c0c8b5f2d65017d803c0ad35

Authored by Quillot Mathias
1 parent 37c010cba0
Exists in master

Better main organisation of the volia.data module

Showing 1 changed file with 22 additions and 19 deletions Side-by-side Diff

... ... @@ -5,29 +5,10 @@
5 5  
6 6 import core.data
7 7  
8   -# Main parser
9   -parser = argparse.ArgumentParser(description="manage files")
10   -subparsers = parser.add_subparsers(title="actions")
11 8  
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", required=True)
15   -parser_filter.add_argument("--filter", type=str, help="filter file [id_from] [id_to]", required=True)
16   -parser_filter.add_argument("--outfile", type=str, help="output file", required=True)
17   -parser_filter.set_defaults(which="filter")
18 9  
19   -# Convert
20   -parser_convert = subparsers.add_parser("convert", help="convert a file")
21   -parser_convert.add_argument("--file", type=str, help="...", required=True)
22   -parser_convert.add_argument("--type-from", type=str, choices=["old-masseffect", "new-masseffect"], help="...", required=True)
23   -parser_convert.add_argument("--type", choices=["old-masseffect", "new-masseffect"], required=True)
24   -parser_convert.set_defaults(which="convert")
25 10  
26   -# Parse
27   -args = parser.parse_args()
28 11  
29   -
30   -
31 12 def filter_file(file, filter, outfile):
32 13 file_path = file
33 14 filter_path = filter
... ... @@ -47,6 +28,28 @@
47 28  
48 29  
49 30 if __name__ == "__main__":
  31 + # Main parser
  32 + parser = argparse.ArgumentParser(description="manage files")
  33 + subparsers = parser.add_subparsers(title="actions")
  34 +
  35 + # Filter ids
  36 + parser_filter = subparsers.add_parser("filter", help="filter a file")
  37 + parser_filter.add_argument("--file", type=str, help="path of the file to filter", required=True)
  38 + parser_filter.add_argument("--filter", type=str, help="filter file [id_from] [id_to]", required=True)
  39 + parser_filter.add_argument("--outfile", type=str, help="output file", required=True)
  40 + parser_filter.set_defaults(which="filter")
  41 +
  42 + # Convert
  43 + parser_convert = subparsers.add_parser("convert", help="convert a file")
  44 + parser_convert.add_argument("--file", type=str, help="...", required=True)
  45 + parser_convert.add_argument("--type-from", type=str, choices=["old-masseffect", "new-masseffect"], help="...", required=True)
  46 + parser_convert.add_argument("--type", choices=["old-masseffect", "new-masseffect"], required=True)
  47 + parser_convert.set_defaults(which="convert")
  48 +
  49 + # Parse
  50 + args = parser.parse_args()
  51 +
  52 + # Run commands
50 53 runner = SubCommandRunner({
51 54 "convert" : convert,
52 55 "filter": filter_file,