Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 2aa2308

Browse files
committed
Merge branch 'config-options'
2 parents 64ac533 + 305a2df commit 2aa2308

3 files changed

Lines changed: 18 additions & 10 deletions

File tree

device_inventory/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
VERSION = (7, 0, 3, 'alpha', 4)
1+
VERSION = (7, 0, 3, 'alpha', 5)
22

33

44
def get_version():

device_inventory/config.ini

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[DEFAULT]
2-
EQUIP = 1
3-
DONOR = no
4-
ID = no
2+
EQUIP = 0
3+
PID = no
4+
_ID = no
55
TIME = no
66
LABEL = yes
7-
OBS = yes
7+
COMMENT = yes
88
SAVE = yes
99
OFFLINE = yes
1010
MOVE = no

device_inventory/donator.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,30 @@ def is_connected():
3030

3131

3232
def get_user_input():
33-
# XXX configurable user input fields
34-
label = raw_input("Label ID: ")
35-
comment = raw_input("Comment: ")
33+
user_input = {}
34+
for field in ['label', 'comment', 'pid', '_id']:
35+
if settings.getboolean('DEFAULT', field):
36+
value = raw_input("%s: " % field).strip()
37+
if value:
38+
user_input[field] = value
3639

3740
# Ask user for choosing the Device.type
41+
do_equip = settings.get('DEFAULT', 'EQUIP')
3842
CHOICES = dict((key, value) for value, key in Computer.TYPES)
3943
formated_choices = "\n".join(["{0}. {1}".format(k,v) for k, v in CHOICES.items()])
4044
choose_msg = "Choose device type \n{0}\nType: ".format(formated_choices)
4145
device_type = None
4246
while device_type not in CHOICES.keys():
4347
try:
44-
device_type = int(raw_input(choose_msg))
48+
if do_equip in ["1", "2", "3", "4", "5"]:
49+
device_type = int(do_equip)
50+
else:
51+
device_type = int(raw_input(choose_msg))
4552
except ValueError:
4653
print("Invalid choice.")
54+
user_input['device_type'] = CHOICES[device_type]
4755

48-
return dict(label=label, comment=comment, device_type=CHOICES[device_type])
56+
return user_input
4957

5058

5159
def main(argv=None):

0 commit comments

Comments
 (0)