]>
git.immae.eu Git - perso/Immae/Projets/Python/MusicSampler.git/blob - helpers/__init__.py
3b97f2fb435d5837c803895e479184b9c16b694d
1 # -*- coding: utf-8 -*-
7 def __init__(self
, **kwargs
):
9 setattr(self
, arg
, kwargs
[arg
])
11 config
= Config(yml_file
="config.yml")
14 if getattr(sys
, 'frozen', False):
15 return sys
._MEIPASS
+ "/"
17 path
= os
.path
.dirname(os
.path
.realpath(__file__
))
22 sys
.argv
= sys
.argv
[:1]
24 index
= argv
.index("--")
25 kivy_args
= argv
[index
+1:]
28 sys
.argv
.extend(kivy_args
)
30 parser
= argparse
.ArgumentParser(description
="A Music Sampler application.")
31 parser
.add_argument("-c", "--config",
34 help="Config file to load")
35 parser
.add_argument("-V", "--version",
37 help="Displays the current version and exits. Only use in bundled package",
38 version
=show_version())
39 parser
.add_argument('--',
41 help="Kivy arguments. All arguments after this are interpreted by Kivy. Pass \"-- --help\" to get Kivy's usage.")
42 args
= parser
.parse_args(argv
)
44 config
.yml_file
= args
.config
47 if getattr(sys
, 'frozen', False):
48 with open(path() + ".pyinstaller_commit", "r") as f
:
51 return "option '-v' can only be used in bundled package"
54 return config
.yml_file
56 def duration_to_min_sec(duration
):
57 minutes
= int(duration
/ 60)
58 seconds
= int(duration
) % 60
60 return "{:2}:{:0>2}".format(minutes
, seconds
)
62 return "{}:{:0>2}".format(minutes
, seconds
)