[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
01/89: import: utils: Add string helpers.
From: |
Ricardo Wurmus |
Subject: |
01/89: import: utils: Add string helpers. |
Date: |
Tue, 7 Nov 2017 02:44:46 -0500 (EST) |
rekado pushed a commit to branch master
in repository guix.
commit 6b46b04f919881e0122e201db4590ba5da77aa88
Author: Ricardo Wurmus <address@hidden>
Date: Mon Nov 6 16:53:39 2017 +0100
import: utils: Add string helpers.
* guix/import/utils.scm (read-lines, chunk-lines): New procedures.
---
guix/import/utils.scm | 28 +++++++++++++++++++++++++++-
1 file changed, 27 insertions(+), 1 deletion(-)
diff --git a/guix/import/utils.scm b/guix/import/utils.scm
index 1e2f0c8..d4cef6b 100644
--- a/guix/import/utils.scm
+++ b/guix/import/utils.scm
@@ -34,6 +34,8 @@
#:use-module (guix download)
#:use-module (gnu packages)
#:use-module (ice-9 match)
+ #:use-module (ice-9 rdelim)
+ #:use-module (ice-9 receive)
#:use-module (ice-9 regex)
#:use-module (srfi srfi-1)
#:use-module (srfi srfi-11)
@@ -56,7 +58,10 @@
snake-case
beautify-description
- alist->package))
+ alist->package
+
+ read-lines
+ chunk-lines))
(define (factorize-uri uri version)
"Factorize URI, a package tarball URI as a string, such that any occurrences
@@ -329,3 +334,24 @@ the expected fields of an <origin> object."
(or (module-ref (resolve-interface '(guix licenses) #:prefix 'license:)
(spdx-string->license l))
(license:fsdg-compatible l))))))
+
+(define* (read-lines #:optional (port (current-input-port)))
+ "Read lines from PORT and return them as a list."
+ (let loop ((line (read-line port))
+ (lines '()))
+ (if (eof-object? line)
+ (reverse lines)
+ (loop (read-line port)
+ (cons line lines)))))
+
+(define* (chunk-lines lines #:optional (pred string-null?))
+ "Return a list of chunks, each of which is a list of lines. The chunks are
+separated by PRED."
+ (let loop ((rest lines)
+ (parts '()))
+ (receive (before after)
+ (break pred rest)
+ (let ((res (cons before parts)))
+ (if (null? after)
+ (reverse res)
+ (loop (cdr after) res))))))
- branch master updated (89618fa -> 9ecc4c6), Ricardo Wurmus, 2017/11/07
- 01/89: import: utils: Add string helpers.,
Ricardo Wurmus <=
- 05/89: gnu: r-rgraphviz: Update to 2.22.0., Ricardo Wurmus, 2017/11/07
- 02/89: import: cran: Add support for Bioconductor 3.6., Ricardo Wurmus, 2017/11/07
- 09/89: gnu: r-dnacopy: Update to 1.52.0., Ricardo Wurmus, 2017/11/07
- 06/89: gnu: Add r-stringdist., Ricardo Wurmus, 2017/11/07
- 07/89: gnu: r-bioccheck: Update to 1.14.0., Ricardo Wurmus, 2017/11/07
- 08/89: gnu: r-biocviews: Update to 1.46.0., Ricardo Wurmus, 2017/11/07
- 12/89: gnu: r-genefilter: Update to 1.60.0., Ricardo Wurmus, 2017/11/07
- 17/89: gnu: r-rhtslib: Update to 1.10.0., Ricardo Wurmus, 2017/11/07
- 20/89: gnu: r-tximport: Update to 1.6.0., Ricardo Wurmus, 2017/11/07
- 23/89: gnu: r-copywriter: Update to 2.10.0., Ricardo Wurmus, 2017/11/07