コード例 #1
0
ファイル: config.py プロジェクト: dnapoletano/smpdf
    def parse_pdfsets(self, pdfs):
        pdfsets = []
        for pdf in pdfs:
            if isinstance(pdf, dict):
                try:
                    names = pdf["name"]
                except KeyError:
                    raise ConfigError("Unrecognized " "format for pdfsets: %s" % pdfs)
            elif isinstance(pdf, str):
                names = pdf
            else:
                raise ConfigError("Unrecognized format for pdfsets: %s" % pdfs)

            newsets = [
                PDF(name) for name in (lhaindex.expand_local_names(names) + fnmatch.filter(self._grid_names, names))
            ]
            if not newsets:
                raise ConfigError("pdfset is empty for specification '%s'. " "Is it in the LHAPDF path?" % names)

            if isinstance(pdf, dict) and "label" in pdf:
                if len(newsets) == 1:
                    newsets[0].label = pdf["label"]
                else:
                    raise ConfigError("Label can only be set for a single pdf:\n" "%s" % pdf)
            remote_sets = {PDF(name) for name in lhaindex.expand_index_names(names)}
            diff = remote_sets - set(newsets)
            if diff:
                logging.warn(
                    "The specification '%s' matches "
                    "some official PDF sets that are not locally installed. "
                    "They are:\n%s" % (names, "\n".join(str(d) for d in diff))
                )
            pdfsets += newsets
        return pdfsets
コード例 #2
0
ファイル: config.py プロジェクト: dnapoletano/smpdf
 def parse_base_pdf(self, base):
     label = None
     if isinstance(base, dict):
         try:
             name = base["name"]
         except KeyError:
             raise ConfigError("Unrecognized format for pdfsets: %s" % base)
         else:
             if "label" in base:
                 label = base["label"]
     elif isinstance(base, str):
         name = base
     else:
         raise ConfigError("Unrecognized format for pdfsets: %s" % base)
     existing = lhaindex.expand_local_names(name)
     if not existing:
         raise ConfigError("No PDF set %s. Is it in the LHAPDF path?" % name)
     if len(existing) > 1:
         raise ConfigError("Only one base_pdf allowed. Matches were %s" % existing)
     return PDF(name, label=label)