当前位置: 首页>>代码示例>>Golang>>正文


Golang ProblemArchiveReader.ReadFile方法代码示例

本文整理汇总了Golang中github.com/lanior/upc/formats.ProblemArchiveReader.ReadFile方法的典型用法代码示例。如果您正苦于以下问题:Golang ProblemArchiveReader.ReadFile方法的具体用法?Golang ProblemArchiveReader.ReadFile怎么用?Golang ProblemArchiveReader.ReadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/lanior/upc/formats.ProblemArchiveReader的用法示例。


在下文中一共展示了ProblemArchiveReader.ReadFile方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: ImportArchive

func (self Format) ImportArchive(archive *formats.ProblemArchiveReader) (problems []*model.Problem, err error) {
	defer SuppressPanic(&err)

	data, err := archive.ReadFile("domjudge-problem.ini")
	PanicIf(err, "Cannot read problem settings: %s", err)

	settings := ParseSettings(data)

	p := &model.Problem{
		Title:       settings["name"],
		TimeLimit:   float32(settings.GetInt("timelimit")),
		MemoryLimit: 128,

		Solutions: make(map[string]*model.Solution),
	}

	PanicIf(archive.LoadTests(p, "(.*).in$", "(.*).out$"))
	PanicIf(archive.LoadSolutions(p, "sol_(.*)"))
	return []*model.Problem{p}, nil
}
开发者ID:lanior,项目名称:upc,代码行数:20,代码来源:import.go

示例2: importStatement

func importStatement(archive *formats.ProblemArchiveReader, problem *model.Problem, statement *Statement) {
	data, err := archive.ReadFile(statement.Path)
	PanicIf(err, "Cannot read statement %s: %s", statement.Path, err)

	getTeX := func(src []byte) model.FormattedText {
		return model.RawText(src)
	}

	if match := statementRe.FindSubmatch(data); match != nil {
		problem.Statement = getTeX(match[1])
		problem.InputFormat = getTeX(match[2])
		problem.OutputFormat = getTeX(match[3])
	}

	matches := exampleRe.FindAllSubmatch(data, -1)
	problem.Samples = make([]model.Sample, len(matches))
	for i, match := range matches {
		problem.Samples[i].Input = string(match[1])
		problem.Samples[i].Output = string(match[2])
	}
}
开发者ID:lanior,项目名称:upc,代码行数:21,代码来源:import.go

示例3: addGenerator

func addGenerator(archive *formats.ProblemArchiveReader, problem *model.Problem, generator *Generator) {
	gen := problem.Generators[generator.Name]
	if gen == nil {
		gen = new(model.Generator)
		problem.Generators[generator.Name] = gen
	}
	gen.Name = generator.Name
	if generator.OutputFile != "" {
		gen.OutputFile = generator.OutputFile
	}

	if generator.LanguageCode != 0 || generator.Source != "" {
		lang := getLanguage(generator.LanguageCode, generator.Source)
		PanicIf(lang == nil, "Unknown generator language")
		gen.Language = lang.Name
	}

	if generator.Source != "" {
		data, err := archive.ReadFile(generator.Source)
		PanicIf(err)
		gen.SourceCode = string(data)
	}
}
开发者ID:lanior,项目名称:upc,代码行数:23,代码来源:import.go


注:本文中的github.com/lanior/upc/formats.ProblemArchiveReader.ReadFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。