]>
Commit | Line | Data |
---|---|---|
1 | # -*- coding: utf-8 -*- | |
2 | import sys | |
3 | import os | |
4 | ||
5 | class Config: | |
6 | def __init__(self, **kwargs): | |
7 | for arg in kwargs: | |
8 | setattr(self, arg, kwargs[arg]) | |
9 | ||
10 | config = Config(yml_file="config.yml") | |
11 | ||
12 | def path(): | |
13 | if getattr(sys, 'frozen', False): | |
14 | return sys._MEIPASS + "/" | |
15 | else: | |
16 | path = os.path.dirname(os.path.realpath(__file__)) | |
17 | return path + "/../" | |
18 | ||
19 | def parse_args(): | |
20 | for arg in sys.argv: | |
21 | if arg[0:2] == "-c": | |
22 | sys.argv.remove(arg) | |
23 | config.yml_file = arg[2:] | |
24 | ||
25 | if arg == "-v": | |
26 | sys.argv.remove(arg) | |
27 | ||
28 | if getattr(sys, 'frozen', False): | |
29 | f = open(path() + ".pyinstaller_commit", "r") | |
30 | print(f.read(), end="") | |
31 | f.close() | |
32 | else: | |
33 | print("option '-v' can only be used in bundled package") | |
34 | sys.exit() | |
35 | ||
36 | def yml_file(): | |
37 | return config.yml_file | |
38 | ||
39 | def duration_to_min_sec(duration): | |
40 | minutes = int(duration / 60) | |
41 | seconds = int(duration) % 60 | |
42 | if minutes < 100: | |
43 | return "{:2}:{:0>2}".format(minutes, seconds) | |
44 | else: | |
45 | return "{}:{:0>2}".format(minutes, seconds) |