1#!/usr/bin/python 2# -*- coding: utf-8 -*- 3# Copyright 2013 Christoph Reiter 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9 10""" 11./id3_frames_gen.py > api/id3_frames.rst 12""" 13 14import sys 15import os 16 17sys.path.insert(0, os.path.abspath('../')) 18 19import mutagen.id3 20from mutagen.id3 import Frames, Frames_2_2, Frame 21 22 23BaseFrames = dict([(k, v) for (k, v) in vars(mutagen.id3).items() 24 if v not in Frames.values() and v not in Frames_2_2.values() 25 and isinstance(v, type) and 26 (issubclass(v, Frame) or v is Frame)]) 27 28 29def print_header(header, type_="-"): 30 print(header) 31 print(type_ * len(header)) 32 print("") 33 34 35def print_frames(frames, sort_mro=False): 36 if sort_mro: 37 # less bases first, then by name 38 sort_func = lambda x: (len(x[1].__mro__), x[0]) 39 else: 40 sort_func = lambda x: x 41 42 for name, cls in sorted(frames.items(), key=sort_func): 43 print(""" 44.. autoclass:: mutagen.id3.%s 45 :show-inheritance: 46 :members: 47""" % repr(cls())) 48 49 50if __name__ == "__main__": 51 52 print_header("Frame Base Classes") 53 print_frames(BaseFrames, sort_mro=True) 54 print_header("ID3v2.3/4 Frames") 55 print_frames(Frames) 56