BlinkenArea - GitList
Repositories
Blog
Wiki
stage_director
Code
Commits
Branches
Tags
Search
Tree:
ab7eb54
Branches
Tags
master
stage_director
playlist.py
reading playlist
Stefan Schuermans
commited
ab7eb54
at 2013-11-14 22:23:33
playlist.py
Blame
History
Raw
#! /usr/bin/env python import re import time_fmt class Playlist: def __init__(self): self.entries = [] self.reEntry = re.compile('^\s*([A-Za-z0-9_]+)\s+([0-9:.]+)\s*$') def read(self, filename): self.entries = [] f = open(filename, "r") for line in f: mEntry = self.reEntry.match(line) if mEntry: name = mEntry.group(1) duration = time_fmt.str2sec(mEntry.group(2)) self.entries.append({'type': 'normal', 'name': name, 'duration': duration}) print("entry normal %s %f" % (self.entries[-1]['name'], self.entries[-1]['duration'])) else: self.entries.append({'type': 'stop'}) print("entry stop") f.close()