コード例 #1
0
ファイル: app_globals.py プロジェクト: spotnetturkey/theory
    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """

        self.tc = TConfig()
        self.p = MPDPool(self)
        self.get_genres()
コード例 #2
0
ファイル: app_globals.py プロジェクト: jkliff/theory
    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """

        self.tc = TConfig()
        self.p = MPDPool(self)
        self.get_genres()
コード例 #3
0
ファイル: app_globals.py プロジェクト: jkliff/theory
class Globals(object):
    """Globals acts as a container for objects available throughout the
    life of the application
    """

    searchterms = ['Artist','Title','Album','Genre','Any']

    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """

        self.tc = TConfig()
        self.p = MPDPool(self)
        self.get_genres()

    def get_genres(self):
        """ load all tracks and create a list of every unique genre in the database"""
        self.genres = set()

        # this won't work before configuration
        try:
            m = self.p.connect()
            all_tracks = m.listallinfo()

            for t in all_tracks:
                if not 'genre' in t:
                    continue

                if type(t['genre']) == list:
                    track_genres = t['genre']
                else:
                    track_genres = [t['genre']]

                for genre in track_genres:
                    self.genres.add(genre)

            m.disconnect()
        except:
            pass
コード例 #4
0
ファイル: app_globals.py プロジェクト: spotnetturkey/theory
class Globals(object):
    """Globals acts as a container for objects available throughout the
    life of the application
    """

    searchterms = ['Artist', 'Title', 'Album', 'Genre', 'Any']

    def __init__(self):
        """One instance of Globals is created during application
        initialization and is available during requests via the 'g'
        variable
        """

        self.tc = TConfig()
        self.p = MPDPool(self)
        self.get_genres()

    def get_genres(self):
        """ load all tracks and create a list of every unique genre in the database"""
        self.genres = set()

        # this won't work before configuration
        try:
            m = self.p.connect()
            all_tracks = m.listallinfo()

            for t in all_tracks:
                if not 'genre' in t:
                    continue

                if type(t['genre']) == list:
                    track_genres = t['genre']
                else:
                    track_genres = [t['genre']]

                for genre in track_genres:
                    self.genres.add(genre)

            m.disconnect()
        except:
            pass