identifier

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2025 License: Apache-2.0 Imports: 14 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const AlphaNumericPattern = `/[a-zA-Z0-9]+/`
View Source
const CopyrightPattern = `` /* 139-byte string literal not displayed */

CopyrightPattern recognizes a block to be flagged as COPYRIGHT const COPYRIGHT_PATTERN = /^[^a-z0-9\n]*(?:All rights reserved\.?\s*)?(?:[ \t]*(?:Copyright|Copr\.?|\(c\)|[\xA9]))+\s+[^\n\r]+(?:[^a-z0-9]*All rights reserved\.?)?/gmi; The legacy pattern required one-or-more white-spaces AND one-or-more non-carriage-return chars after Copyright. Here we are minimally requiring just the one white-space (or more...).

Variables

View Source
var (
	CopyrightRegexp    = regexp.MustCompile(CopyrightPattern)
	AlphaNumericRegexp = regexp.MustCompile(AlphaNumericPattern)
)
View Source
var DefaultKeywordList = []string{
	`public domain`,
	`Affero`,
	`[a-z]*gpl`,
	`[a-z-]*commercial[a-z]*`,
	`[a-z-]*licen[cs][a-z]*`,
}
View Source
var (
	Logger *log.MiniLogger
)

Functions

func FromOptions

func FromOptions(licenseResults *IdentifierResults, enhancements Enhancements, licenseLibrary *licenses.LicenseLibrary) error

FromOptions adds enabled enhancements (in order)

func PassedStaticBlocksChecks

func PassedStaticBlocksChecks(staticBlocks []string, nd normalizer.NormalizationData) bool

PassedStaticBlocksChecks verifies static blocks are present, if any

Types

type Block

type Block struct {
	Text    string
	Matches []string
}

type Enhancements

type Enhancements struct {
	AddNotes       string
	AddTextBlocks  bool
	FlagAcceptable bool
	FlagCopyrights bool
	FlagKeywords   bool
}

type IdentifierResults

type IdentifierResults struct {
	Matches                  map[string][]Match
	Blocks                   []Block
	File                     string
	OriginalText             string
	NormalizedText           string
	Hash                     normalizer.Digest
	Notes                    string
	AcceptablePatternMatches []PatternMatch
	KeywordMatches           []PatternMatch
	CopyRightStatements      []PatternMatch
}

func Identify

func Identify(options Options, licenseLibrary *licenses.LicenseLibrary, normalizedData normalizer.NormalizationData) (IdentifierResults, error)

func IdentifyLicensesInDirectory

func IdentifyLicensesInDirectory(dirPath string, options Options, licenseLibrary *licenses.LicenseLibrary) (ret []IdentifierResults, err error)

func IdentifyLicensesInFile

func IdentifyLicensesInFile(filePath string, options Options, licenseLibrary *licenses.LicenseLibrary) (IdentifierResults, error)

func IdentifyLicensesInString

func IdentifyLicensesInString(input string, options Options, licenseLibrary *licenses.LicenseLibrary) (IdentifierResults, error)

type Match

type Match struct {
	Begins int
	Ends   int
}

func FindMatchingPatternInNormalizedData

func FindMatchingPatternInNormalizedData(matchingPattern *licenses.PrimaryPatterns, normalized normalizer.NormalizationData) (results []Match, err error)

type Options

type Options struct {
	ForceResult  bool
	OmitBlocks   bool
	Enhancements Enhancements
}

type PatternMatch

type PatternMatch struct {
	Text   string
	Begins int
	Ends   int
}

Jump to

Keyboard shortcuts

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