Datasets:
AutoOntologyBench / source_data /pinned /gatekeeper-library /commit-a8d4799d8daf /scripts /validate /validate.go
Download source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/scripts/validate/validate.go from Vinyeh/AutoOntologyBench: direct link, hf CLI and curl.
- Browser
- Download file 1.89 kB
-
https://huggingface.co/datasets/Vinyeh/AutoOntologyBench/resolve/refs%2Fpr%2F2/source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/scripts/validate/validate.go
- Command line
-
hf download hf://datasets/Vinyeh/AutoOntologyBench@refs/pr/2/source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/scripts/validate/validate.go
-
curl -L -o validate.go https://huggingface.co/datasets/Vinyeh/AutoOntologyBench/resolve/refs%2Fpr%2F2/source_data/pinned/gatekeeper-library/commit-a8d4799d8daf/scripts/validate/validate.go
1.89 kB
| package main | |
| import ( | |
| "fmt" | |
| "os" | |
| "path/filepath" | |
| "strings" | |
| ) | |
| const ( | |
| docsDirEntry = "website/docs" | |
| ) | |
| func main() { | |
| pwd, err := os.Getwd() | |
| if err != nil { | |
| fmt.Println("error while getting pwd") | |
| panic(err) | |
| } | |
| rootDir := filepath.Join(pwd, "..", "..") | |
| err = validateDocsDirStructure(rootDir) | |
| if err != nil { | |
| fmt.Println("error while validating docs directory structure") | |
| panic(err) | |
| } | |
| } | |
| func validateDocsDirStructure(rootDir string) error { | |
| docsDirPath := filepath.Join(rootDir, docsDirEntry) | |
| // expected directory structure | |
| expectedDirs := []string{"mutation-examples", "validation"} | |
| expectedFiles := []string{"intro.md", "pspintro.md"} | |
| // Get the list of files and directories in the docs directory | |
| files, err := os.ReadDir(docsDirPath) | |
| if err != nil { | |
| return err | |
| } | |
| // Validate the directory structure | |
| for _, file := range files { | |
| if file.IsDir() { | |
| if !contains(expectedDirs, file.Name()) { | |
| err = fmt.Errorf("unexpected directory: %s, found at: %s", file.Name(), filepath.Join(docsDirPath, file.Name())) | |
| return err | |
| } | |
| } else { | |
| if !contains(expectedFiles, file.Name()) { | |
| err = fmt.Errorf("unexpected file: %s, found at: %s", file.Name(), filepath.Join(docsDirPath, file.Name())) | |
| return err | |
| } | |
| } | |
| } | |
| // Check for missing directories and files | |
| for _, expectedDir := range expectedDirs { | |
| if _, err := os.Stat(filepath.Join(docsDirPath, expectedDir)); os.IsNotExist(err) { | |
| err = fmt.Errorf("missing directory: %s", expectedDir) | |
| return err | |
| } | |
| } | |
| for _, expectedFile := range expectedFiles { | |
| if _, err := os.Stat(filepath.Join(docsDirPath, expectedFile)); os.IsNotExist(err) { | |
| err = fmt.Errorf("missing file: %s", expectedFile) | |
| return err | |
| } | |
| } | |
| return nil | |
| } | |
| func contains(items []string, item string) bool { | |
| for _, i := range items { | |
| if strings.EqualFold(i, item) { | |
| return true | |
| } | |
| } | |
| return false | |
| } | |