Skip to content

Commit 8625611

Browse files
authored
moc module: fix type mismatch in moc_data (#2288)
1 parent a742454 commit 8625611

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

py3status/modules/moc.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,25 @@ def _get_moc_data(self):
110110
is_started = False
111111
return is_started, data
112112

113+
def _organize_data(self, data):
114+
temporary = {}
115+
for line in data.splitlines():
116+
category, value = line.split(": ", 1)
117+
temporary[category.lower()] = value
118+
return temporary
119+
113120
def moc(self):
114121
is_paused = is_playing = is_stopped = None
115122
cached_until = self.sleep_timeout
116123
color = self.py3.COLOR_BAD
117-
data = {}
118124

119125
is_started, moc_data = self._get_moc_data()
120126

121127
if is_started:
122128
cached_until = self.cache_timeout
129+
moc_data = self._organize_data(moc_data)
123130

124-
for line in moc_data.splitlines():
125-
category, value = line.split(": ", 1)
126-
data[category.lower()] = value
127-
128-
self.state = data["state"]
131+
self.state = moc_data["state"]
129132
if self.state == "PLAY":
130133
is_playing = True
131134
color = self.color_playing

0 commit comments

Comments
 (0)