예제 #1
0
    def __init__(
        self, text, title=None, base_dir=None):
        # TODO: ???
        #       I have the impression this "info" stuff
        #       is not used at all. And *if* it is used,
        #       shouldn't it be implemented in LilyPondJob???
        # Initialize default LilyPond version
        info = lilypondinfo.preferred()
        # Optionally infer a suitable LilyPond version from the content
        if QSettings().value("lilypond_settings/autoversion", True, bool):
            version = ly.docinfo.DocInfo(ly.document.Document(text, 'lilypond')).version()
            if version:
                info = lilypondinfo.suitable(version)
        # Create temporary (document.Document object and file)
        self.directory = util.tempdir()
        filename = os.path.join(self.directory, 'document.ly')
        with open(filename, 'wb') as f:
            f.write(text.encode('utf-8'))
        url = QUrl(filename)
        url.setScheme('file')
        super(VolatileTextJob, self).__init__(url, title=title)

        if title:
            self.set_title(title)
        if base_dir:
            self.add_include_path(base_dir)
예제 #2
0
def info(document):
    """Returns a LilyPondInfo instance that should be used by default to engrave the document."""
    version = documentinfo.docinfo(document).version()
    if version and QSettings().value("lilypond_settings/autoversion", False,
                                     bool):
        return lilypondinfo.suitable(version)
    return lilypondinfo.preferred()
예제 #3
0
 def __init__(self, text, title=None):
     super(MusicPreviewJob, self).__init__()
     self.directory = util.tempdir()
     self.document = os.path.join(self.directory, 'document.ly')
     with open(self.document, 'w') as f:
         f.write(text.encode('utf-8'))
         
     info = lilypondinfo.preferred()
     if QSettings().value("lilypond_settings/autoversion", True, bool):
         version = ly.parse.version(ly.lex.state('lilypond').tokens(text))
         if version:
             info = lilypondinfo.suitable(version)
     
     self.command = [info.abscommand(), '-dno-point-and-click', '--pdf', self.document]
     if title:
         self.setTitle(title)
예제 #4
0
    def __init__(self, text, title=None):
        super(MusicPreviewJob, self).__init__()
        self.directory = util.tempdir()
        self.document = os.path.join(self.directory, "document.ly")
        with open(self.document, "w") as f:
            f.write(text.encode("utf-8"))

        info = lilypondinfo.preferred()
        if QSettings().value("lilypond_settings/autoversion", True) in (True, "true"):
            version = ly.parse.version(ly.lex.state("lilypond").tokens(text))
            if version:
                info = lilypondinfo.suitable(version)

        self.command = [info.command, "-dno-point-and-click", "--pdf", self.document]
        if title:
            self.setTitle(title)
예제 #5
0
 def __init__(self, text, title=""):
     # Initialize default LilyPond version
     info = lilypondinfo.preferred()
     # Optionally infer a suitable LilyPond version from the content
     if QSettings().value("lilypond_settings/autoversion", True, bool):
         version = ly.docinfo.DocInfo(ly.document.Document(text, 'lilypond')).version()
         if version:
             info = lilypondinfo.suitable(version)
     # Create temporary (document.Document object and file)
     directory = util.tempdir()
     filename = os.path.join(directory, 'document.ly')
     with open(filename, 'wb') as f:
         f.write(text.encode('utf-8'))
     url = QUrl(filename)
     url.setScheme('file')
     doc = document.Document(url)
     super(VolatileTextJob, self).__init__(doc, title=title)
예제 #6
0
 def __init__(self, text, title=""):
     # Initialize default LilyPond version
     info = lilypondinfo.preferred()
     # Optionally infer a suitable LilyPond version from the content
     if QSettings().value("lilypond_settings/autoversion", True, bool):
         version = ly.docinfo.DocInfo(ly.document.Document(
             text, 'lilypond')).version()
         if version:
             info = lilypondinfo.suitable(version)
     # Create temporary (document.Document object and file)
     directory = util.tempdir()
     filename = os.path.join(directory, 'document.ly')
     with open(filename, 'wb') as f:
         f.write(text.encode('utf-8'))
     url = QUrl(filename)
     url.setScheme('file')
     doc = document.Document(url)
     super(VolatileTextJob, self).__init__(doc, title=title)
예제 #7
0
    def __init__(self, text, title=None):
        super(MusicPreviewJob, self).__init__()
        self.decode_errors = 'replace'
        self.decoder_stdout = self.decoder_stderr = codecs.getdecoder('utf-8')
        self.directory = util.tempdir()
        self.document = os.path.join(self.directory, 'document.ly')
        with open(self.document, 'wb') as f:
            f.write(text.encode('utf-8'))

        info = lilypondinfo.preferred()
        if QSettings().value("lilypond_settings/autoversion", True, bool):
            version = ly.docinfo.DocInfo(ly.document.Document(text, 'lilypond')).version()
            if version:
                info = lilypondinfo.suitable(version)

        lilypond = info.abscommand() or info.command
        self.command = [lilypond, '-dno-point-and-click', '--pdf', self.document]
        if title:
            self.set_title(title)
예제 #8
0
 def __init__(self, text, title=None):
     super(MusicPreviewJob, self).__init__()
     self.decode_errors = 'replace'
     self.decoder_stdout = self.decoder_stderr = codecs.getdecoder('utf-8')
     self.directory = util.tempdir()
     self.document = os.path.join(self.directory, 'document.ly')
     with open(self.document, 'wb') as f:
         f.write(text.encode('utf-8'))
         
     info = lilypondinfo.preferred()
     if QSettings().value("lilypond_settings/autoversion", True, bool):
         version = ly.docinfo.DocInfo(ly.document.Document(text, 'lilypond')).version()
         if version:
             info = lilypondinfo.suitable(version)
     
     lilypond = info.abscommand() or info.command
     self.command = [lilypond, '-dno-point-and-click', '--pdf', self.document]
     if title:
         self.set_title(title)
예제 #9
0
def info(document):
    """Returns a LilyPondInfo instance that should be used by default to engrave the document."""
    version = documentinfo.docinfo(document).version()
    if version and QSettings().value("lilypond_settings/autoversion", False, bool):
        return lilypondinfo.suitable(version)
    return lilypondinfo.preferred()