aboutsummaryrefslogtreecommitdiff
path: root/helpers/__init__.py
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-14 13:25:41 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-07-14 13:25:41 +0200
commit9b9dd12a0253f2e65c5934068d91b544f7679f12 (patch)
treeccc7c762c877a6b6447936317ed20510ac69ed92 /helpers/__init__.py
parent60979de4e9f5f3f249f4887b8fecfe94f233b3d4 (diff)
downloadMusicSampler-9b9dd12a0253f2e65c5934068d91b544f7679f12.tar.gz
MusicSampler-9b9dd12a0253f2e65c5934068d91b544f7679f12.tar.zst
MusicSampler-9b9dd12a0253f2e65c5934068d91b544f7679f12.zip
Add config file option to the command line
Diffstat (limited to 'helpers/__init__.py')
-rw-r--r--helpers/__init__.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/helpers/__init__.py b/helpers/__init__.py
index f3e5967..2131c2a 100644
--- a/helpers/__init__.py
+++ b/helpers/__init__.py
@@ -2,6 +2,13 @@
2import sys 2import sys
3import os 3import os
4 4
5class Config:
6 def __init__(self, **kwargs):
7 for arg in kwargs:
8 setattr(self, arg, kwargs[arg])
9
10config = Config(yml_file="config.yml")
11
5def path(): 12def path():
6 if getattr(sys, 'frozen', False): 13 if getattr(sys, 'frozen', False):
7 return sys._MEIPASS + "/" 14 return sys._MEIPASS + "/"
@@ -11,6 +18,10 @@ def path():
11 18
12def parse_args(): 19def parse_args():
13 for arg in sys.argv: 20 for arg in sys.argv:
21 if arg[0:2] == "-c":
22 sys.argv.remove(arg)
23 config.yml_file = arg[2:]
24
14 if arg == "-v": 25 if arg == "-v":
15 sys.argv.remove(arg) 26 sys.argv.remove(arg)
16 27
@@ -22,6 +33,9 @@ def parse_args():
22 print("option '-v' can only be used in bundled package") 33 print("option '-v' can only be used in bundled package")
23 sys.exit() 34 sys.exit()
24 35
36def yml_file():
37 return config.yml_file
38
25def duration_to_min_sec(duration): 39def duration_to_min_sec(duration):
26 minutes = int(duration / 60) 40 minutes = int(duration / 60)
27 seconds = int(duration) % 60 41 seconds = int(duration) % 60