format

package
v0.0.0-...-7eedc68 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 4, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

package format handles Guppy's miniature formatting languages for snapshot file, e.g:

Input = "snapdir{%03d,snapshot}/snap{%03d,snapshot}.{%d,0..512}"
Output = "snapdir{%04d,snapshot}/snap{%04d,snapshot}.{%d,output}.gup"
Snapshots = 0..100 - 63

The exact rules are as follows: File format strings are a combination of fixed text and variables. Fixed text is always the same, and variables can change from file to file. Variables are written as {verb,rule}. "verb" is a printf() verb (e.g. %03d) that specifies how the variable should be printed. "rule" is text that specifies what values the variable should take on. There are currently three rules:

"snapshot" - The variable is equal to the currently-analysed snapshot.
"output" - The variable ranges over Guppy output file indices.
sequence format - The variable ranges over a user-specified range.

Sequence formats are a generic way to specify non-contiguous sequences of natural numbers. They consist of a series of n tokens separated by "+" or "-". Each token can be either a number or two numbers separted by "..". E.g.:

100
0..100
0..10 + 100
0..100 - 63 - 10..20

These strings build up sequences of numbers by adding/removing individual numbers and contiguous sequences. For example, 0 through 10 would be 0..10, 1, 2, 3, 15, 16, 17 could be written as 1..17 - 4..13. This is useful for skipping corrupted snapshots or specifying a subset of snapshots/files.

All spaces around "-", "+", and "," symbols are ignored.

Index

Constants

View Source
const (
	// Any expanded formats which would have more than BigNumber elements are
	// assumed to be bugs.
	BigNumber = 1 << 20
)

Variables

View Source
var (
	LowerCase  = "abcdefghijklmnopqrstuvwxyz"
	AllLetters = LowerCase + strings.ToUpper(LowerCase)
)

Functions

func ExpandFormatString

func ExpandFormatString(format string, vals map[string]int) ([]string, error)

ExpandFormatString expands a format string into n unique versions. Named variables are given the values specified in vals. Sequence variables are expanded individually, meaning that n = \prod n_i, where n_i is the length of each sequence.

func ExpandSequenceFormat

func ExpandSequenceFormat(format string) ([]int, error)

ExpandSequenceFormat expands a sequence format string into a sorted sequence of integers.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL