From 81318e5bd819f44ddbdb60115b170fc86961a1ea Mon Sep 17 00:00:00 2001 From: bkfox Date: Wed, 30 Aug 2017 18:44:39 +0200 Subject: [PATCH] sounds_monitor --- aircox/management/commands/sounds_monitor.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/aircox/management/commands/sounds_monitor.py b/aircox/management/commands/sounds_monitor.py index 327a3d4..7fccc36 100755 --- a/aircox/management/commands/sounds_monitor.py +++ b/aircox/management/commands/sounds_monitor.py @@ -80,11 +80,13 @@ class SoundInfo: self._path = value self.name = r['name'].replace('_', ' ').capitalize() - self.year = int(r.get('year')) if 'year' in r else None - self.month = int(r.get('month')) if 'month' in r else None - self.day = int(r.get('day')) if 'day' in r else None - self.hour = int(r.get('hour')) if 'hour' in r else None - self.minute = int(r.get('minute')) if 'minute' in r else None + + for key in ('year', 'month', 'day', 'hour', 'minute'): + value = r.get(key) + if value is not None: + value = int(value) + setattr(self, key, value) + self.n = r.get('n') return r