files

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DoReplacements

func DoReplacements(patterns []Replacement, fullpath string) (result string, err error)

DoReplacements return the result of a series of replacements

func Download

func Download(
	file io.WriterTo,
	filename string,
	stdout, stderr io.Writer,
) (err error)

Download will download a canvas file and write it to a file named by filename if it does not already exist.

Types

type CourseDownloader

type CourseDownloader struct {
	Stdout, Stderr io.Writer
	// contains filtered or unexported fields
}

CourseDownloader will download files from a canvas course.

func DownloaderFromWG

func DownloaderFromWG(basedir string, wg *sync.WaitGroup) *CourseDownloader

DownloaderFromWG will create a course downloader form an existing waitgroup.

func NewDownloader

func NewDownloader(basedir string) *CourseDownloader

NewDownloader creates a new CourseDownloader

func (*CourseDownloader) CheckReplacements

func (cd *CourseDownloader) CheckReplacements(
	course *canvas.Course,
	reps []Replacement,
) (err error)

CheckReplacements will print the result of replacement patterns on the files in a course.

func (*CourseDownloader) Download

func (cd *CourseDownloader) Download(course *canvas.Course, replacements []Replacement) error

Download will download all the files for a course and perform the replacement patterns.

func (*CourseDownloader) Wait

func (cd *CourseDownloader) Wait()

Wait calls wait on the internal waitgroup

type Replacement

type Replacement struct {
	Pattern     string `yaml:"pattern"`
	Replacement string `yaml:"replacement"`
	Lower       bool   `yaml:"lower"`
}

Replacement is a regex pattern replacement

func (Replacement) Replace

func (r Replacement) Replace(path string) (result string, err error)

Replace will perform a replacement

func (Replacement) String added in v0.0.4

func (r Replacement) String() string

Jump to

Keyboard shortcuts

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