Ejemplo n.º 1
0
    def file(cls, sheet, filename):
        """Constructs a new cuesheet string from a compatible object.

        sheet must have catalog(), indexes() and ISRCs() methods.
        filename is a string to the filename the cuesheet is created for.
        Although we don't care whether the filename points to a real file,
        other tools sometimes do.
        """

        import cStringIO

        catalog = sheet.catalog()  # a catalog string, or None
        indexes = list(sheet.indexes())  # a list of index tuples
        ISRCs = sheet.ISRCs()  # a track_number->ISRC dict

        data = cStringIO.StringIO()

        if (catalog is not None):
            data.write("CATALOG %s\r\n" % (catalog))
        data.write("FILE \"%s\" WAVE\r\n" % (filename))

        for (i, current) in enumerate(indexes):
            tracknum = i + 1

            data.write("  TRACK %2.2d AUDIO\r\n" % (tracknum))

            if (tracknum in ISRCs.keys()):
                data.write("    ISRC %s\r\n" % (ISRCs[tracknum]))

            for (j, index) in enumerate(current):
                data.write("    INDEX %2.2d %s\r\n" %
                           (j, build_timestamp(index)))

        return data.getvalue()
Ejemplo n.º 2
0
    def file(cls, sheet, filename):
        """Constructs a new cuesheet string from a compatible object.

        sheet must have catalog(), indexes() and ISRCs() methods.
        filename is a string to the filename the cuesheet is created for.
        Although we don't care whether the filename points to a real file,
        other tools sometimes do.
        """

        import cStringIO

        catalog = sheet.catalog()        # a catalog string, or None
        indexes = list(sheet.indexes())  # a list of index tuples
        ISRCs = sheet.ISRCs()            # a track_number->ISRC dict

        data = cStringIO.StringIO()

        if (catalog is not None):
            data.write("CATALOG %s\r\n" % (catalog))
        data.write("FILE \"%s\" WAVE\r\n" % (filename))

        for (i, current) in enumerate(indexes):
            tracknum = i + 1

            data.write("  TRACK %2.2d AUDIO\r\n" % (tracknum))

            if (tracknum in ISRCs.keys()):
                data.write("    ISRC %s\r\n" % (ISRCs[tracknum]))

            for (j, index) in enumerate(current):
                data.write("    INDEX %2.2d %s\r\n" % (j,
                                                       build_timestamp(index)))

        return data.getvalue()
Ejemplo n.º 3
0
    def file(cls,sheet,filename):
        import cStringIO

        catalog = sheet.catalog()       #a catalog string, or None
        indexes = list(sheet.indexes()) #a list of index tuples
        ISRCs = sheet.ISRCs()           #a track_number->ISRC dict

        data = cStringIO.StringIO()

        if (catalog is not None):
            data.write("CATALOG %s\r\n" % (catalog))
        data.write("FILE \"%s\" WAVE\r\n" % (filename))

        for (i,current) in enumerate(indexes):
            tracknum = i + 1

            data.write("  TRACK %2.2d AUDIO\r\n" % (tracknum))

            if (tracknum in ISRCs.keys()):
                data.write("    ISRC %s\r\n" % (ISRCs[tracknum]))

            for (j,index) in enumerate(current):
                data.write("    INDEX %2.2d %s\r\n" % (j,
                                                       build_timestamp(index)))

        return data.getvalue()
Ejemplo n.º 4
0
    def file(cls, sheet, filename):
        """constructs a new TOC file string from a compatible object

        sheet must have catalog(), indexes() and ISRCs() methods
        filename is a string to the filename the TOC file is created for
        although we don't care whether the filename points to a real file,
        other tools sometimes do
        """

        import cStringIO

        catalog = sheet.catalog()        # a catalog string, or None
        indexes = list(sheet.indexes())  # a list of index tuples
        ISRCs = sheet.ISRCs()            # a track_number->ISRC dict

        data = cStringIO.StringIO()
        data.write("CD_DA\n\n")

        if ((catalog is not None) and (len(catalog) > 0)):
            data.write("CATALOG \"%s\"\n\n" % (catalog))

        for (i, (current, next)) in enumerate(zip(indexes,
                                                  indexes[1:] + [None])):
            tracknum = i + 1

            data.write("TRACK AUDIO\n")

            if (tracknum in ISRCs.keys()):
                data.write("ISRC \"%s\"\n" % (ISRCs[tracknum]))

            if (next is not None):
                data.write("AUDIOFILE \"%s\" %s %s\n" % \
                               (filename,
                                build_timestamp(current[0]),
                                build_timestamp(next[0] - current[0])))
            else:
                data.write("AUDIOFILE \"%s\" %s\n" % \
                               (filename,
                                build_timestamp(current[0])))
            if (len(current) > 1):
                data.write("START %s\n" % \
                               (build_timestamp(current[-1] - current[0])))

            if (next is not None):
                data.write("\n")

        return data.getvalue()
Ejemplo n.º 5
0
    def file(cls, sheet, filename):
        """Constructs a new TOC file string from a compatible object.

        sheet must have catalog(), indexes() and ISRCs() methods.
        filename is a string to the filename the TOC file is created for.
        Although we don't care whether the filename points to a real file,
        other tools sometimes do.
        """

        import cStringIO

        catalog = sheet.catalog()  # a catalog string, or None
        indexes = list(sheet.indexes())  # a list of index tuples
        ISRCs = sheet.ISRCs()  # a track_number->ISRC dict

        data = cStringIO.StringIO()
        data.write("CD_DA\n\n")

        if ((catalog is not None) and (len(catalog) > 0)):
            data.write("CATALOG \"%s\"\n\n" % (catalog))

        for (i, (current,
                 next)) in enumerate(zip(indexes, indexes[1:] + [None])):
            tracknum = i + 1

            data.write("TRACK AUDIO\n")

            if (tracknum in ISRCs.keys()):
                data.write("ISRC \"%s\"\n" % (ISRCs[tracknum]))

            if (next is not None):
                data.write("AUDIOFILE \"%s\" %s %s\n" % \
                               (filename,
                                build_timestamp(current[0]),
                                build_timestamp(next[0] - current[0])))
            else:
                data.write("AUDIOFILE \"%s\" %s\n" % \
                               (filename,
                                build_timestamp(current[0])))
            if (len(current) > 1):
                data.write("START %s\n" % \
                               (build_timestamp(current[-1] - current[0])))

            if (next is not None):
                data.write("\n")

        return data.getvalue()
Ejemplo n.º 6
0
    def file(cls, sheet, filename):
        import cStringIO

        catalog = sheet.catalog()  #a catalog string, or None
        indexes = list(sheet.indexes())  #a list of index tuples
        ISRCs = sheet.ISRCs()  #a track_number->ISRC dict

        data = cStringIO.StringIO()
        data.write("CD_DA\n\n")

        if ((catalog is not None) and (len(catalog) > 0)):
            data.write("CATALOG \"%s\"\n\n" % (catalog))

        for (i, (current,
                 next)) in enumerate(zip(indexes, indexes[1:] + [None])):
            tracknum = i + 1

            data.write("TRACK AUDIO\n")

            if (tracknum in ISRCs.keys()):
                data.write("ISRC \"%s\"\n" % (ISRCs[tracknum]))

            if (next is not None):
                data.write("AUDIOFILE \"%s\" %s %s\n" % \
                               (filename,
                                build_timestamp(current[0]),
                                build_timestamp(next[0] - current[0])))
            else:
                data.write("AUDIOFILE \"%s\" %s\n" % \
                               (filename,
                                build_timestamp(current[0])))
            if (len(current) > 1):
                data.write("START %s\n" % \
                               (build_timestamp(current[-1] - current[0])))

            if (next is not None):
                data.write("\n")

        return data.getvalue()