From e20bf9b97fe60ebe18b8972b2b56fe681fce64a8 Mon Sep 17 00:00:00 2001 From: Doug Coleman Date: Sun, 24 Mar 2024 16:21:30 -0500 Subject: [PATCH] factor: update download to return path and using lists fix dead url for unixdict.txt --- .../bootstrap/image/download/download.factor | 8 ++++---- basis/math/primes/factors/factors.factor | 4 ++-- basis/unicode/breaks/breaks-tests.factor | 10 +++++----- .../unicode/collation/collation-tests.factor | 8 ++++---- basis/unicode/collation/collation.factor | 6 +++--- .../unicode/normalize/normalize-tests.factor | 11 +++++------ basis/unicode/normalize/normalize.factor | 5 ++--- .../build-from-source.factor | 13 +++++++------ extra/bunny/model/model.factor | 4 ++-- extra/gpu/demos/bunny/bunny.factor | 12 ++++++------ extra/macho/macho-tests.factor | 8 ++++---- extra/project-euler/098/098.factor | 2 +- .../anagrams-deranged.factor | 10 +++++----- .../ordered-words/ordered-words.factor | 9 ++++----- extra/spelling/spelling.factor | 4 ++-- extra/tldr/tldr.factor | 4 ++-- extra/zealot/factor/factor.factor | 19 +++++++++---------- 17 files changed, 67 insertions(+), 70 deletions(-) diff --git a/basis/bootstrap/image/download/download.factor b/basis/bootstrap/image/download/download.factor index 739b968f35..6f440b9732 100644 --- a/basis/bootstrap/image/download/download.factor +++ b/basis/bootstrap/image/download/download.factor @@ -1,7 +1,8 @@ ! Copyright (C) 2008, 2010 Slava Pestov. ! See https://factorcode.org/license.txt for BSD license. USING: assocs bootstrap.image checksums checksums.md5 -http.client io.files kernel math.parser splitting urls ; +http.client http.download io.files kernel math.parser splitting +urls ; IN: bootstrap.image.download CONSTANT: download-url URL" https://downloads.factorcode.org/images/master/" @@ -26,9 +27,8 @@ CONSTANT: download-url URL" https://downloads.factorcode.org/images/master/" need-new-image? [ "Boot image corrupt" throw ] when ; : download-image ( image -- ) - [ download-url swap >url derive-url download ] - [ verify-image ] - bi ; + [ download-url ] dip >url derive-url + download verify-image ; : maybe-download-image ( image -- ? ) dup need-new-image? [ download-image t ] [ drop f ] if ; diff --git a/basis/math/primes/factors/factors.factor b/basis/math/primes/factors/factors.factor index 20a485e46f..a0626143db 100644 --- a/basis/math/primes/factors/factors.factor +++ b/basis/math/primes/factors/factors.factor @@ -2,8 +2,8 @@ ! See https://factorcode.org/license.txt for BSD license. USING: arrays combinators command-line io kernel math math.functions math.parser math.primes.pollard-rho-brent -ranges math.statistics namespaces sequences -sequences.product sets sorting splitting ; +math.statistics namespaces ranges sequences sequences.product +sets sorting splitting ; IN: math.primes.factors : factors ( n -- seq ) pollard-rho-brent-factors ; flushable diff --git a/basis/unicode/breaks/breaks-tests.factor b/basis/unicode/breaks/breaks-tests.factor index c0954f3545..2fef15c601 100644 --- a/basis/unicode/breaks/breaks-tests.factor +++ b/basis/unicode/breaks/breaks-tests.factor @@ -1,6 +1,6 @@ -USING: tools.test unicode sequences math http.client kernel -splitting unicode.categories io.pathnames io.encodings.utf8 -io.files io.files.temp strings quotations math.parser locals ; +USING: http.download io.encodings.utf8 io.files io.files.temp +kernel math.parser quotations sequences splitting strings +tools.test unicode ; IN: unicode.breaks.tests { "\u001112\u001161\u0011abA\u000300a\r\r\n" } @@ -21,11 +21,11 @@ IN: unicode.breaks.tests : grapheme-break-test ( -- filename ) "https://downloads.factorcode.org/misc/UCD/15.1.0/auxiliary/GraphemeBreakTest.txt" - "GraphemeBreakTest-15.1.0.txt" cache-file [ ?download-to ] keep ; + "GraphemeBreakTest-15.1.0.txt" cache-file download-to ; : word-break-test ( -- filename ) "https://downloads.factorcode.org/misc/UCD/15.1.0/auxiliary/WordBreakTest.txt" - "WordBreakTest-15.1.0.txt" cache-file [ ?download-to ] keep ; + "WordBreakTest-15.1.0.txt" cache-file download-to ; : parse-test-file ( file-name -- tests ) utf8 file-lines diff --git a/basis/unicode/collation/collation-tests.factor b/basis/unicode/collation/collation-tests.factor index eb9438a12f..2cf37e1b1e 100644 --- a/basis/unicode/collation/collation-tests.factor +++ b/basis/unicode/collation/collation-tests.factor @@ -1,7 +1,7 @@ USING: arrays assocs grouping hash-sets http.client -io.encodings.binary io.encodings.string io.encodings.utf8 -io.files io.files.temp kernel math math.order math.parser -sequences sets splitting strings tools.test unicode ; +http.download io.encodings.binary io.encodings.string +io.encodings.utf8 io.files io.files.temp kernel math math.order +math.parser sequences sets splitting strings tools.test unicode ; IN: unicode.collation.tests : test-equality ( str1 str2 -- ? ? ? ? ) @@ -19,7 +19,7 @@ IN: unicode.collation.tests : collation-test-lines ( -- lines ) "https://downloads.factorcode.org/misc/UCA/15.1.0/CollationTest_SHIFTED.txt" - "CollationTest_SHIFTED_15.1.0.txt" cache-file [ ?download-to ] keep + "CollationTest_SHIFTED_15.1.0.txt" cache-file download-to utf8 file-lines [ "#" head? ] reject harvest ; : parse-collation-test-shifted ( -- lines ) diff --git a/basis/unicode/collation/collation.factor b/basis/unicode/collation/collation.factor index a059bb184d..9b5e051ec0 100644 --- a/basis/unicode/collation/collation.factor +++ b/basis/unicode/collation/collation.factor @@ -1,9 +1,9 @@ ! Copyright (C) 2008 Daniel Ehrenberg. ! See https://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs combinators -combinators.short-circuit combinators.smart fry kernel make -math math.order math.parser namespaces sequences -simple-flat-file splitting strings unicode.data ; +combinators.short-circuit combinators.smart kernel make math +math.order math.parser namespaces sequences simple-flat-file +splitting strings unicode.data ; IN: unicode.collation [ first2 [ first ] dip 2array ] map diff --git a/basis/unicode/normalize/normalize.factor b/basis/unicode/normalize/normalize.factor index 0bf4b08c71..c5d4dabcb1 100644 --- a/basis/unicode/normalize/normalize.factor +++ b/basis/unicode/normalize/normalize.factor @@ -1,9 +1,8 @@ ! Copyright (C) 2008 Daniel Ehrenberg. ! See https://factorcode.org/license.txt for BSD license. USING: accessors arrays ascii combinators -combinators.short-circuit hints kernel make math -math.order sbufs sequences sorting.insertion strings -unicode.data vectors ; +combinators.short-circuit hints kernel make math math.order +sbufs sequences sorting.insertion strings unicode.data vectors ; IN: unicode.normalize float ; SPECIALIZED-ARRAY: float SPECIALIZED-VECTOR: uint @@ -149,7 +149,7 @@ CONSTANT: bunny-model-url "https://downloads.factorcode.org/misc/bun_zipper.ply" : download-bunny ( -- path ) - bunny-model-url bunny-model-path [ ?download-to ] keep ; + bunny-model-url bunny-model-path download-to ; : get-bunny-data ( bunny-state -- ) download-bunny bunny-data diff --git a/extra/macho/macho-tests.factor b/extra/macho/macho-tests.factor index 00f008ec10..48626fcaf3 100644 --- a/extra/macho/macho-tests.factor +++ b/extra/macho/macho-tests.factor @@ -1,8 +1,8 @@ ! Copyright (C) 2010 Erik Charlebois. ! See https://factorcode.org/license.txt for BSD license. -USING: accessors alien http.client io io.files.temp +USING: accessors alien http.download io.files.temp io.streams.string kernel literals macho multiline sequences -strings system tools.test urls ; +system tools.test urls ; IN: macho.tests STRING: validation-output @@ -24,11 +24,11 @@ STRING: validation-output : a.macho ( -- path ) URL" https://downloads.factorcode.org/misc/a.macho" - "a.macho" cache-file [ ?download-to ] keep ; + "a.macho" cache-file download-to ; : a2.macho ( -- path ) URL" https://downloads.factorcode.org/misc/a2.macho" - "a2.macho" cache-file [ ?download-to ] keep ; + "a2.macho" cache-file download-to ; cpu ppc? [ { $ validation-output } diff --git a/extra/project-euler/098/098.factor b/extra/project-euler/098/098.factor index d43eaf8fb8..27db0b8cf5 100644 --- a/extra/project-euler/098/098.factor +++ b/extra/project-euler/098/098.factor @@ -42,7 +42,7 @@ IN: project-euler.098 : wordlist ( -- seq ) "https://projecteuler.net/project/resources/p098_words.txt" - "p098_words.txt" temp-file [ ?download-to ] keep + "p098_words.txt" temp-file download-to utf8 file-contents "," split [ rest-slice but-last ] map ; : squarelist ( n -- seq ) diff --git a/extra/rosetta-code/anagrams-deranged/anagrams-deranged.factor b/extra/rosetta-code/anagrams-deranged/anagrams-deranged.factor index 284e85c4c6..d65f06a8a9 100644 --- a/extra/rosetta-code/anagrams-deranged/anagrams-deranged.factor +++ b/extra/rosetta-code/anagrams-deranged/anagrams-deranged.factor @@ -1,6 +1,6 @@ ! Copyright (c) 2012 Anonymous ! See https://factorcode.org/license.txt for BSD license. -USING: assocs http.client io.encodings.utf8 io.files +USING: assocs http.download io.encodings.utf8 io.files io.files.temp kernel math math.combinatorics sequences sorting strings urls ; @@ -15,8 +15,8 @@ IN: rosettacode.anagrams-deranged ! in the same position in both words. ! The task is to use the word list at -! https://www.puzzlers.org/pub/wordlists/unixdict.txt to find and -! show the longest deranged anagram. +! https://raw.githubusercontent.com/quinnj/Rosetta-Julia/master/unixdict.txt +! to find and show show the longest deranged anagram. : derangement? ( str1 str2 -- ? ) [ = not ] 2all? ; @@ -41,8 +41,8 @@ IN: rosettacode.anagrams-deranged deranged-anagrams [ first length ] sort-by last ; : default-word-list ( -- path ) - URL" https://puzzlers.org/pub/wordlists/unixdict.txt" - "unixdict.txt" temp-file [ ?download-to ] keep ; + URL" https://raw.githubusercontent.com/quinnj/Rosetta-Julia/master/unixdict.txt" + "unixdict.txt" temp-file download-to ; : longest-deranged-anagrams ( -- anagrams ) default-word-list (longest-deranged-anagrams) ; diff --git a/extra/rosetta-code/ordered-words/ordered-words.factor b/extra/rosetta-code/ordered-words/ordered-words.factor index b1ca4c3301..0ce7c4319e 100644 --- a/extra/rosetta-code/ordered-words/ordered-words.factor +++ b/extra/rosetta-code/ordered-words/ordered-words.factor @@ -1,8 +1,7 @@ ! Copyright (c) 2012 Anonymous ! See https://factorcode.org/license.txt for BSD license. -USING: grouping http.client io io.encodings.utf8 io.files -io.files.temp kernel math sequences sequences.extras -unicode urls ; +USING: grouping http.download io io.encodings.utf8 io.files +io.files.temp math sequences sequences.extras unicode urls ; IN: rosetta-code.ordered-words ! https://rosettacode.org/wiki/Ordered_words @@ -18,9 +17,9 @@ IN: rosetta-code.ordered-words ! this page. MEMO: word-list ( -- seq ) - URL" https://puzzlers.org/pub/wordlists/unixdict.txt" + URL" https://raw.githubusercontent.com/quinnj/Rosetta-Julia/master/unixdict.txt" "unixdict.txt" temp-file - [ ?download-to ] [ utf8 file-lines ] bi ; + download-to utf8 file-lines ; : ordered-word? ( word -- ? ) >lower [ <= ] monotonic? ; diff --git a/extra/spelling/spelling.factor b/extra/spelling/spelling.factor index 3e9f091132..d48bffdc84 100644 --- a/extra/spelling/spelling.factor +++ b/extra/spelling/spelling.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2010 John Benediktsson ! See https://factorcode.org/license.txt for BSD license USING: arrays ascii assocs combinators combinators.smart -http.client io.encodings.ascii io.files io.files.temp kernel +http.download io.encodings.ascii io.files io.files.temp kernel math math.statistics ranges sequences sequences.private sorting splitting urls ; IN: spelling @@ -58,7 +58,7 @@ CONSTANT: ALPHABET "abcdefghijklmnopqrstuvwxyz" MEMO: default-dictionary ( -- counts ) URL" https://norvig.com/big.txt" "big.txt" temp-file - [ ?download-to ] [ load-dictionary ] bi ; + download-to load-dictionary ; : (correct) ( word dictionary -- word/f ) corrections ?first ; diff --git a/extra/tldr/tldr.factor b/extra/tldr/tldr.factor index a64fbc2c9f..5fc08b8af5 100644 --- a/extra/tldr/tldr.factor +++ b/extra/tldr/tldr.factor @@ -1,7 +1,7 @@ ! Copyright (C) 2021 John Benediktsson ! See https://factorcode.org/license.txt for BSD license -USING: assocs combinators command-line http.client io +USING: assocs combinators command-line http.download io io.directories io.encodings.utf8 io.files io.files.temp io.launcher io.pathnames json kernel namespaces regexp sequences splitting system urls wrap.strings ; @@ -26,7 +26,7 @@ CONSTANT: tldr-zip URL" https://tldr-pages.github.io/assets/tldr.zip" : download-tldr ( -- ) "tldr" cache-file dup make-directory [ - tldr-zip "tldr.zip" download-to + tldr-zip "tldr.zip" download-to drop { "unzip" "tldr.zip" } try-process ] with-directory ; diff --git a/extra/zealot/factor/factor.factor b/extra/zealot/factor/factor.factor index bd13fc93dc..dbf172aa47 100644 --- a/extra/zealot/factor/factor.factor +++ b/extra/zealot/factor/factor.factor @@ -2,13 +2,12 @@ ! See https://factorcode.org/license.txt for BSD license. USING: accessors arrays assocs bootstrap.image calendar cli.git combinators combinators.short-circuit concurrency.combinators -environment formatting http.client io io.directories -io.encodings.utf8 io.launcher io.pathnames kernel math.parser -memory modern.paths namespaces parser.notes prettyprint -regexp.classes sequences sequences.extras sets splitting system -system-info threads tools.test tools.test.private vocabs -vocabs.hierarchy vocabs.hierarchy.private vocabs.loader -vocabs.metadata zealot ; +environment formatting http.download io io.directories +io.launcher io.pathnames kernel math.parser memory modern.paths +namespaces parser.notes prettyprint regexp.classes sequences +sequences.extras sets splitting system system-info threads +tools.test tools.test.private vocabs vocabs.hierarchy +vocabs.hierarchy.private vocabs.loader vocabs.metadata zealot ; IN: zealot.factor ! XXX: Could check if it's a branch instead with a git command @@ -16,10 +15,10 @@ IN: zealot.factor { [ length 40 = ] [ [ hex-digit? ] all? ] } 1&& ; : download-boot-checksum-branch ( path branch -- ) - '[ _ "https://downloads.factorcode.org/images/%s/checksums.txt" sprintf download ] with-directory ; + '[ _ "https://downloads.factorcode.org/images/%s/checksums.txt" sprintf download drop ] with-directory ; : download-boot-checksum-git-checksum ( path checksum -- ) - '[ _ "https://downloads.factorcode.org/images/build/checksums.txt.%s" sprintf download ] with-directory ; + '[ _ "https://downloads.factorcode.org/images/build/checksums.txt.%s" sprintf download drop ] with-directory ; : download-boot-checksums ( path branch/checksum -- ) dup git-checksum? @@ -27,7 +26,7 @@ IN: zealot.factor [ download-boot-checksum-branch ] if ; : download-boot-image ( path url -- ) - '[ _ my-arch-name "boot.%s.image" sprintf download-to ] with-directory ; + '[ _ my-arch-name "boot.%s.image" sprintf download-to drop ] with-directory ; : arch-git-boot-image-path ( arch git-id -- str ) "https://downloads.factorcode.org/images/build/boot.%s.image.%s" sprintf ; -- 2.34.1