本文整理汇总了Golang中github.com/richardlehane/siegfried/pkg/core.Matcher类的典型用法代码示例。如果您正苦于以下问题:Golang Matcher类的具体用法?Golang Matcher怎么用?Golang Matcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Matcher类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: contMatcher
func (p pronom) contMatcher(m core.Matcher) error {
// when no container is set
if p.c == nil {
return nil
}
var zpuids, mpuids []string
var zsigs, msigs [][]frames.Signature
var znames, mnames [][]string
cpuids := make(map[int]string)
for _, fm := range p.c.FormatMappings {
cpuids[fm.Id] = fm.Puid
}
for _, c := range p.c.ContainerSignatures {
puid := cpuids[c.Id]
// only include the included fmts
// warning - this will mean no standalone container extensions
if !p.hasPuid(puid) {
continue
}
typ := c.ContainerType
names := make([]string, 0, 1)
sigs := make([]frames.Signature, 0, 1)
for _, f := range c.Files {
names = append(names, f.Path)
sig, err := processDROID(puid, f.Signature.ByteSequences)
if err != nil {
return err
}
sigs = append(sigs, sig)
}
switch typ {
case "ZIP":
zpuids = append(zpuids, puid)
znames = append(znames, names)
zsigs = append(zsigs, sigs)
case "OLE2":
mpuids = append(mpuids, puid)
mnames = append(mnames, names)
msigs = append(msigs, sigs)
default:
return fmt.Errorf("Pronom: container parsing - unknown type %s", typ)
}
}
// apply no priority config
var zplist, mplist priority.List
if !config.NoPriority() {
zplist, mplist = p.pm.List(zpuids), p.pm.List(mpuids)
}
_, err := m.Add(containermatcher.SignatureSet{containermatcher.Zip, znames, zsigs}, zplist)
if err != nil {
return err
}
l, err := m.Add(containermatcher.SignatureSet{containermatcher.Mscfb, mnames, msigs}, mplist)
if err != nil {
return err
}
p.cPuids = append(zpuids, mpuids...)
p.cStart = l - len(p.cPuids)
return nil
}
开发者ID:jhsimpson,项目名称:siegfried,代码行数:60,代码来源:pronom.go
示例2: add
// add adds extension, bytematcher or containermatcher signatures to the identifier
func (p *pronom) add(m core.Matcher, t core.MatcherType) error {
switch t {
default:
return fmt.Errorf("Pronom: unknown matcher type %d", t)
case core.ExtensionMatcher:
if !config.NoExt() {
var exts [][]string
exts, p.ePuids = p.j.Globs()
l, err := m.Add(stringmatcher.SignatureSet(exts), nil)
if err != nil {
return err
}
p.eStart = l - len(p.ePuids)
return nil
}
case core.MIMEMatcher:
if !config.NoMIME() {
var mimes [][]string
mimes, p.mPuids = p.j.MIMEs()
l, err := m.Add(stringmatcher.SignatureSet(mimes), nil)
if err != nil {
return err
}
p.mStart = l - len(p.mPuids)
return nil
}
case core.ContainerMatcher:
return p.contMatcher(m)
case core.ByteMatcher:
var sigs []frames.Signature
var err error
sigs, p.bPuids, err = p.j.Signatures()
if err != nil {
return err
}
var plist priority.List
if !config.NoPriority() {
plist = p.pm.List(p.bPuids)
}
l, err := m.Add(bytematcher.SignatureSet(sigs), plist)
if err != nil {
return err
}
p.bStart = l - len(p.bPuids)
case core.TextMatcher:
if !config.NoText() && p.hasPuid(config.TextPuid()) {
l, _ := m.Add(textmatcher.SignatureSet{}, nil)
p.tStart = l
}
}
return nil
}
开发者ID:jhsimpson,项目名称:siegfried,代码行数:53,代码来源:pronom.go
示例3: add
// add adds extension, bytematcher or containermatcher signatures to the identifier
func (p *pronom) add(m core.Matcher) error {
switch t := m.(type) {
default:
return fmt.Errorf("Pronom: unknown matcher type %T", t)
case extensionmatcher.Matcher:
if !config.NoExt() {
var exts [][]string
exts, p.ePuids = p.j.extensions()
l, err := m.Add(extensionmatcher.SignatureSet(exts), nil)
if err != nil {
return err
}
p.eStart = l - len(p.ePuids)
return nil
}
case containermatcher.Matcher:
return p.contMatcher(m)
case *bytematcher.Matcher:
var sigs []frames.Signature
var err error
sigs, p.bPuids, err = p.j.signatures()
if err != nil {
return err
}
var plist priority.List
if !config.NoPriority() {
plist = p.pm.List(p.bPuids)
}
l, err := m.Add(bytematcher.SignatureSet(sigs), plist)
if err != nil {
return err
}
p.bStart = l - len(p.bPuids)
case *textmatcher.Matcher:
if !config.NoText() && p.hasPuid(config.TextPuid()) {
l, _ := m.Add(textmatcher.SignatureSet{}, nil)
p.tStart = l
}
}
return nil
}
开发者ID:TidyHuang,项目名称:siegfried,代码行数:42,代码来源:pronom.go
注:本文中的github.com/richardlehane/siegfried/pkg/core.Matcher类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论