sequence

package module
v0.0.0-...-780405a Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2017 License: Unlicense Imports: 6 Imported by: 0

README

sequence

sequence is a package to print sequence files.

It is mainly for vfx industry, because they have so many of them.

It's simple package, so you could just add files and print it.

Basically it look like this.

man := sequence.NewManager(sequence.DefaultSplitter, sequence.FmtSharp)
for _, f := range filenames {
	man.Add(f)
}

fmt.Println(man)

Please see example directory to see the full example.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSeqfile    = errors.New("not a sequence file")
	ErrFrameExists   = errors.New("frame exists")
	ErrNegativeFrame = errors.New("nagative frame")
)
View Source
var (
	FmtSharp = func(pre, digits, post string) string {
		return pre + strings.Repeat("#", len(digits)) + post
	}
	FmtDollarF = func(pre, digits, post string) string {
		return pre + "$F" + strconv.Itoa(len(digits)) + post
	}
	FmtPercentD = func(pre, digits, post string) string {
		return pre + "%0" + strconv.Itoa(len(digits)) + "d" + post
	}
)

Fmt{Sharp, DollarF, PrecentD} are pre-defined formatter, that covers most user's need.

View Source
var DefaultSplitter = NewSplitter(reDefaultSplit)

DefaultSplitter is a default splitter for this package.

User could create their own splitter. See NewSplitter.

Functions

This section is empty.

Types

type Manager

type Manager struct {
	Seqs map[string]*Seq
	// contains filtered or unexported fields
}

A Manager is a sequence manager.

func NewManager

func NewManager(splitter *Splitter, formatting func(pre, digits, post string) string) *Manager

NewManager creates a new sequence manager.

func (*Manager) Add

func (m *Manager) Add(fname string) error

Add adds a file to the manager.

If the file's sequence is not exist yet, it will create a new sequence automatically.

func (*Manager) SeqNames

func (m *Manager) SeqNames() []string

SeqNames returns it's sequence names in ascending order.

func (*Manager) String

func (m *Manager) String() string

String returns a string that shows it's sequences.

It will be multiple lines if it has more than one sequence.

type Range

type Range struct {
	Min int
	Max int
}

Range is a contiguous frame range, which includes Max frame.

func NewRange

func NewRange(f int) *Range

NewRange creates a new range.

func (*Range) Extend

func (r *Range) Extend(f int) bool

Extend extends a range by one, only if, input frame is bigger than current max frame by 1. When it extends, it returns true, or it returns false.

func (*Range) String

func (r *Range) String() string

String expresses the range with dash. Like "1-10". But if the min and max are same, it will just show one. Like "5".

type Seq

type Seq struct {
	// contains filtered or unexported fields
}

A Seq is a frame sequence. It does not hold a sequence name.

func NewSeq

func NewSeq() *Seq

NewSeq creates a new sequence.

func (*Seq) AddFrame

func (s *Seq) AddFrame(f int) error

AddFrame adds a frame into sequence.

It treats negative frames are invalid. So returns ErrNegativeFrame when it takes a negative frame.

func (*Seq) Ranges

func (s *Seq) Ranges() []*Range

Ranges converts a sequence to several contiguous ranges.

func (*Seq) String

func (s *Seq) String() string

String expresses a sequence using ranges.

type Splitter

type Splitter struct {
	// contains filtered or unexported fields
}

Splitter is a file name splitter.

func NewSplitter

func NewSplitter(re *regexp.Regexp) *Splitter

NewSplitter creates a new splitter.

Splitter assumes it's regular expression could catch sequence file name and groups the file name into 3 parts (pre, digits, post). When it does not match, the file will treated as non-sequece file.

Note: If the regular expression does not have 3 sub groups, it will panic.

func (*Splitter) Split

func (s *Splitter) Split(fname string) (pre, digits, post string, err error)

Split takes a file name and splits it into 3 parts, which is pre, digits, and post. It returns error if the file name does not look like a sequence file.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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