本文整理匯總了Golang中cgt/name/pkg/go-mwclient.Client.NewQuery方法的典型用法代碼示例。如果您正苦於以下問題:Golang Client.NewQuery方法的具體用法?Golang Client.NewQuery怎麽用?Golang Client.NewQuery使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cgt/name/pkg/go-mwclient.Client
的用法示例。
在下文中一共展示了Client.NewQuery方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: processGenerator
func processGenerator(params params.Values, client *mwclient.Client, flags flags, verbose *log.Logger, categoryMap map[string]string, allCategories map[string]bool, catRegex []catRegex, stats *stats) {
catCounts := make(map[string]int32)
warnings := make(warnings, 0, 200)
if flags.Gallery != "" {
// try to write gallery even if there's a panic while processing files.
defer checkWarnings(flags.Gallery, &warnings, client)
}
query := client.NewQuery(params)
for query.Next() {
json := query.Resp()
pages, err := json.GetObject("query", "pages")
if err != nil {
// result set may be empty due to "miser mode" in the
// the Mediawiki server.
continue
}
pagesMap := pages.Map()
if len(pagesMap) > 0 {
files := make([]fileData, len(pagesMap))
idx := 0
for id, page := range pagesMap {
if id == "-1" {
// Empty result set.
return
}
files[idx].pageObj, err = page.Object()
if err != nil {
panic(err)
}
idx++
stats.examined++
}
if idx > 0 {
processFiles(files, client, flags, verbose, categoryMap, allCategories, catRegex, catCounts, stats)
warnings.Append(files)
}
}
if flags.FileLimit > 0 && stats.examined >= flags.FileLimit {
break
}
if flags.WarningLimit > 0 && stats.warnings >= flags.WarningLimit {
break
}
}
if query.Err() != nil {
panic(query.Err())
}
}