scp

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 9 Imported by: 6

Documentation

Overview

Package scp provides access to the Super Check Partial (http://www.supercheckpartial.com) database stored in the SCP format. The package also provides functions to download, store and update a MASTER.SCP file. The default remote location for the MASTER.SCP file is http://www.supercheckpartial.com/MASTER.SCP.

File Format Description

1. The file is in plain text format (ASCII). 2. Each line contains one callsign. 3. Lines that begin with # are comments that can be ignored.

Index

Constants

View Source
const DefaultLocalFilename = ".config/hamradio/MASTER.SCP"

DefaultLocalFilename is the default name for the file that is used to store the contents of MASTER.SCP locally in the user's home directory.

View Source
const DefaultURL = "http://www.supercheckpartial.com/MASTER.SCP"

DefaultURL is the original URL of the MASTER.SCP file: http://www.supercheckpartial.com/MASTER.SCP

Variables

This section is empty.

Functions

func Download

func Download(remoteURL, localFilename string) error

Download downloads the database file from a remote URL and stores it locally.

func LocalFilename

func LocalFilename() (string, error)

LocalFilename returns the absolute path of the default local filename in the current user's home directory.

func Update

func Update(remoteURL, localFilename string) (bool, error)

Update updates the local copy of the database file from the given remote URL, but only if an update is needed.

Types

type Database

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

Database represents the SCP database.

func LoadLocal

func LoadLocal(localFilename string) (*Database, error)

LoadLocal loads the database from a file in the local filesystem.

func LoadRemote

func LoadRemote(remoteURL string) (*Database, error)

LoadRemote loads the database file from a remote URL.

func Read

func Read(r io.Reader) (*Database, error)

Read the database from a reader.

func (Database) FindDetailed

func (database Database) FindDetailed(s string) ([]EditScript, error)

Find all strings in database that partially match the given string with detailed information on how the string matches.

func (Database) FindStrings

func (database Database) FindStrings(s string) ([]string, error)

Find all strings in database that partially match the given string

type Edit

type Edit struct {
	OP EditOperation
	S  string
}

type EditOperation

type EditOperation int
const (
	NOP EditOperation = iota
	Insert
	Delete
	Substitute
)

type EditScript

type EditScript []Edit

func (EditScript) LongestMatch

func (s EditScript) LongestMatch() int

func (EditScript) String

func (s EditScript) String() string

Jump to

Keyboard shortcuts

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