def test_is_yeb_format(self): """ Test is_yeb_format function """ testdir = os.path.dirname(os.path.abspath(__file__)) test_yeb = os.path.join(testdir, 'easyconfigs', 'yeb', 'bzip2-1.0.6-GCC-4.9.2.yeb') raw_yeb = read_file(test_yeb) self.assertTrue(is_yeb_format(test_yeb, None)) self.assertTrue(is_yeb_format(None, raw_yeb)) test_eb = os.path.join(testdir, 'easyconfigs', 'gzip-1.4.eb') raw_eb = read_file(test_eb) self.assertFalse(is_yeb_format(test_eb, None)) self.assertFalse(is_yeb_format(None, raw_eb))
def _set_formatter(self, filename): """Obtain instance of the formatter""" if self._formatter is None: if is_yeb_format(filename, self.rawcontent): self._formatter = FormatYeb() else: klass = self._get_format_version_class() self._formatter = klass() self._formatter.parse(self.rawcontent)
def add_easyconfig(self, cfg, name, version, stats, previous): """ Add easyconfig to repository :param cfg: location of easyconfig file :param name: software name :param version: software install version, incl. toolchain & versionsuffix :param stats: build stats, to add to archived easyconfig :param previous: list of previous build stats :return: location of archived easyconfig """ # create directory for eb file full_path = os.path.join(self.wc, self.subdir, name) yeb_format = is_yeb_format(cfg, None) if yeb_format: extension = YEB_FORMAT_EXTENSION prefix = "buildstats: [" else: extension = EB_FORMAT_EXTENSION prefix = "buildstats = [" # destination dest = os.path.join(full_path, "%s-%s%s" % (name, version, extension)) txt = "# Built with EasyBuild version %s on %s\n" % ( VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S")) # copy file txt += read_file(cfg) # append a line to the eb file so that we don't have git merge conflicts statscomment = "\n# Build statistics\n" statsprefix = prefix statssuffix = "]\n" if previous: statstxt = statscomment + statsprefix + '\n' for entry in previous + [stats]: statstxt += stats_to_str(entry, isyeb=yeb_format) + ',\n' statstxt += statssuffix else: statstxt = statscomment + statsprefix + stats_to_str( stats, isyeb=yeb_format) + statssuffix txt += statstxt write_file(dest, txt) return dest
def add_easyconfig(self, cfg, name, version, stats, previous): """ Add easyconfig to repository :param cfg: location of easyconfig file :param name: software name :param version: software install version, incl. toolchain & versionsuffix :param stats: build stats, to add to archived easyconfig :param previous: list of previous build stats :return: location of archived easyconfig """ # create directory for eb file full_path = os.path.join(self.wc, self.subdir, name) yeb_format = is_yeb_format(cfg, None) if yeb_format: extension = YEB_FORMAT_EXTENSION prefix = "buildstats: [" else: extension = EB_FORMAT_EXTENSION prefix = "buildstats = [" # destination dest = os.path.join(full_path, "%s-%s%s" % (name, version, extension)) txt = "# Built with EasyBuild version %s on %s\n" % (VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S")) # copy file txt += read_file(cfg) # append a line to the eb file so that we don't have git merge conflicts statscomment = "\n# Build statistics\n" statsprefix = prefix statssuffix = "]\n" if previous: statstxt = statscomment + statsprefix + '\n' for entry in previous + [stats]: statstxt += stats_to_str(entry, isyeb=yeb_format) + ',\n' statstxt += statssuffix else: statstxt = statscomment + statsprefix + stats_to_str(stats, isyeb=yeb_format) + statssuffix txt += statstxt write_file(dest, txt) return dest
def add_easyconfig(self, cfg, name, version, stats, previous): """ Add the eb-file for software name and version to the repository. stats should be a dict containing statistics. if previous is true -> append the statistics to the file This will return the path to the created file (for use in subclasses) """ # create directory for eb file full_path = os.path.join(self.wc, self.subdir, name) mkdir(full_path, parents=True) yeb_format = is_yeb_format(cfg, None) if yeb_format: extension = YEB_FORMAT_EXTENSION prefix = "buildstats: [" else: extension = EB_FORMAT_EXTENSION prefix = "buildstats = [" # destination dest = os.path.join(full_path, "%s-%s%s" % (name, version, extension)) txt = "# Built with EasyBuild version %s on %s\n" % ( VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S")) # copy file txt += read_file(cfg) # append a line to the eb file so that we don't have git merge conflicts statscomment = "\n# Build statistics\n" statsprefix = prefix statssuffix = "]\n" if previous: statstxt = statscomment + statsprefix + '\n' for entry in previous + [stats]: statstxt += stats_to_str(entry, isyeb=yeb_format) + ',\n' statstxt += statssuffix else: statstxt = statscomment + statsprefix + stats_to_str( stats, isyeb=yeb_format) + statssuffix txt += statstxt write_file(dest, txt) return dest
def add_easyconfig(self, cfg, name, version, stats, previous): """ Add the eb-file for software name and version to the repository. stats should be a dict containing statistics. if previous is true -> append the statistics to the file This will return the path to the created file (for use in subclasses) """ # create directory for eb file full_path = os.path.join(self.wc, self.subdir, name) mkdir(full_path, parents=True) yeb_format = is_yeb_format(cfg, None) if yeb_format: extension = YEB_FORMAT_EXTENSION prefix = "buildstats: [" else: extension = EB_FORMAT_EXTENSION prefix = "buildstats = [" # destination dest = os.path.join(full_path, "%s-%s%s" % (name, version, extension)) txt = "# Built with EasyBuild version %s on %s\n" % (VERBOSE_VERSION, time.strftime("%Y-%m-%d_%H-%M-%S")) # copy file txt += read_file(cfg) # append a line to the eb file so that we don't have git merge conflicts statscomment = "\n# Build statistics\n" statsprefix = prefix statssuffix = "]\n" if previous: statstxt = statscomment + statsprefix + '\n' for entry in previous + [stats]: statstxt += stats_to_str(entry, isyeb=yeb_format) + ',\n' statstxt += statssuffix else: statstxt = statscomment + statsprefix + stats_to_str(stats, isyeb=yeb_format) + statssuffix txt += statstxt write_file(dest, txt) return dest