[nat] wikipedia image scraper

This commit is contained in:
2021-08-02 21:34:34 -06:00
parent 5c1839e35c
commit 7de2a3c047
9 changed files with 68 additions and 28 deletions

View File

@@ -49,13 +49,14 @@
`(let [,@bindingList
,retValSymbol {,@body}]
,@saveList
(.refreshEntry ,archive ,e) // Check the entry in and out of systems when its components change
,retValSymbol)))
(defMacro withWritableEntry [archive e &body body]
(let [retValSymbol
(symbol)]
`(let [,retValSymbol {,@body}]
(archive.refreshEntry ,e)
(.refreshEntry ,archive ,e)
,retValSymbol)))
// Create a system that selects Entries according to a single string component (i.e. Name or Author) matching the given value
@@ -77,13 +78,14 @@
(function componentsMatch [:nat.Entry e componentsBoolExp]
(BoolExpInterp.eval componentsBoolExp (for =>cType cId e.components cType)))
(function addFile [:nat.Archive archive :nat.Entry e :String file &opt leaveOriginalCopy]
(function addFiles [:nat.Archive archive :nat.Entry e :Array<String> files &opt leaveOriginalCopy]
(withWritableEntry archive e
(let [pathWithoutDir (haxe.io.Path.withoutDirectory file)]
(unless !(= -1 (e.files.indexOf pathWithoutDir))
((if leaveOriginalCopy sys.io.File.copy sys.FileSystem.rename)
file (joinPath archive.archiveDir "files" pathWithoutDir))
(e.files.push pathWithoutDir)))))
(doFor file files
(let [pathWithoutDir (haxe.io.Path.withoutDirectory file)]
(unless !(= -1 (e.files.indexOf pathWithoutDir))
((if leaveOriginalCopy sys.io.File.copy sys.FileSystem.rename)
file (joinPath archive.archiveDir "files" pathWithoutDir))
(e.files.push pathWithoutDir))))))
(function addTags [:nat.Archive archive :nat.Entry e :Array<String> tagsToAdd]
(if (hasComponent e Tags)