utils

package
v0.0.0-...-bd21981 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAgent = "TenToolBot (+https://github.com/dnovikoff/tenhou/tools/tentool)"
)

Variables

This section is empty.

Functions

func Check

func Check(err error)

func FileExists

func FileExists(path string) (bool, error)

func MakeDirForFile

func MakeDirForFile(filename string) error

func MustDownload

func MustDownload(ctx context.Context, u string, opts ...Option) string

func NewDownloader

func NewDownloader(opts ...Option) *downloader

func YaDiskDownload

func YaDiskDownload(u string, location string, interactive bool, onDownloaded func(string, string) error) error
func YaDiskResourcesLink(u string) string

Types

type FileWriter

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

func CreateFile

func CreateFile(name string) (*FileWriter, error)

func (*FileWriter) Close

func (w *FileWriter) Close() error

func (*FileWriter) Commit

func (w *FileWriter) Commit() error

func (*FileWriter) CommitOnSuccess

func (w *FileWriter) CommitOnSuccess(err *error)

func (*FileWriter) Write

func (w *FileWriter) Write(data []byte) (int, error)

type InteractiveTracker

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

func NewInteractiveTracker

func NewInteractiveTracker(u, p string, i bool) *InteractiveTracker

func (*InteractiveTracker) Done

func (t *InteractiveTracker) Done(total int64, err error)

func (*InteractiveTracker) SetPath

func (t *InteractiveTracker) SetPath(p string)

func (*InteractiveTracker) Start

func (t *InteractiveTracker) Start(total int64)

func (*InteractiveTracker) Write

func (t *InteractiveTracker) Write(bytes int)

type InteractiveWriter

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

func NewInteractiveWriter

func NewInteractiveWriter(w io.Writer) *InteractiveWriter

func (*InteractiveWriter) Printf

func (w *InteractiveWriter) Printf(format string, args ...interface{}) (int, error)

func (*InteractiveWriter) Println

func (w *InteractiveWriter) Println(args ...interface{}) (int, error)

type JSONGZFile

type JSONGZFile struct {
	Path   string
	Pretty bool
}

func (*JSONGZFile) Load

func (f *JSONGZFile) Load(out interface{}) error

func (*JSONGZFile) Save

func (f *JSONGZFile) Save(data interface{}) (err error)

type Option

type Option func(*downloader)

func AddTracker

func AddTracker(f Tracker) Option

func Client

func Client(c *http.Client) Option

func Compressor

func Compressor(f func(io.Writer) io.WriteCloser) Option

func GZIP

func GZIP() Option

type ProgressWriter

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

func NewProgressWriter

func NewProgressWriter(w io.Writer, prefix string, total int) *ProgressWriter

func (*ProgressWriter) Advance

func (w *ProgressWriter) Advance(x int)

func (*ProgressWriter) Disable

func (w *ProgressWriter) Disable() *ProgressWriter

func (*ProgressWriter) Display

func (w *ProgressWriter) Display()

func (*ProgressWriter) Done

func (w *ProgressWriter) Done()

func (*ProgressWriter) Inc

func (w *ProgressWriter) Inc()

func (*ProgressWriter) Progress

func (w *ProgressWriter) Progress() int

func (*ProgressWriter) SetDelay

func (w *ProgressWriter) SetDelay(d time.Duration) *ProgressWriter

func (*ProgressWriter) SetETA

func (w *ProgressWriter) SetETA() *ProgressWriter

func (*ProgressWriter) Skip

func (w *ProgressWriter) Skip()

func (*ProgressWriter) Start

func (w *ProgressWriter) Start()

type Routines

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

func (*Routines) Error

func (r *Routines) Error() error

func (*Routines) Start

func (r *Routines) Start(f func() error)

func (*Routines) Wait

func (r *Routines) Wait() error

type Scheduler

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

func (*Scheduler) Error

func (s *Scheduler) Error() error

func (*Scheduler) Push

func (s *Scheduler) Push(t Task)

func (*Scheduler) Start

func (s *Scheduler) Start(cnt, saveSize int)

func (*Scheduler) Stop

func (s *Scheduler) Stop() error

type Task

type Task interface {
	// Called on one of worker routine
	Run() error
	// Called on single routine
	Save(blocked bool) error
}

type Tracker

type Tracker interface {
	Start(total int64)
	Write(bytes int)
	Done(total int64, err error)
}

type YADiskAnswer

type YADiskAnswer struct {
	PublicURL string `json:"public_url"`
	Embedded  struct {
		Items []YADiskItem `json:"items"`
	} `json:"_embedded"`
}

type YADiskItem

type YADiskItem struct {
	Type      string `json:"type"`
	File      string `json:"file"`
	Path      string `json:"path"`
	PublicURL string `json:"public_url"`
}

func YaDiskParseItems

func YaDiskParseItems(data string) ([]YADiskItem, error)

func (*YADiskItem) SetPublicURL

func (i *YADiskItem) SetPublicURL(parent string)

Jump to

Keyboard shortcuts

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