identifier

package
v0.0.0-...-69261f7 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

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.NewLogger(log.INFO)
)

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