[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
165/197: installer: New procedure key-value-slurp.
From: |
Danny Milosavljevic |
Subject: |
165/197: installer: New procedure key-value-slurp. |
Date: |
Mon, 3 Jul 2017 20:37:19 -0400 (EDT) |
dannym pushed a commit to branch wip-installer-2
in repository guix.
commit 9418604261236dd99569b5591f4d46c0a18b6804
Author: John Darrington <address@hidden>
Date: Thu Feb 2 08:13:24 2017 +0100
installer: New procedure key-value-slurp.
* gnu/system/installer/utils.scm (key-value-slurp): New procedure.
* gnu/system/installer/format.scm: Use it where appropriate.
---
gnu/system/installer/format.scm | 12 +-----------
gnu/system/installer/utils.scm | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/gnu/system/installer/format.scm b/gnu/system/installer/format.scm
index f0a9aaf..b8c5f5e 100644
--- a/gnu/system/installer/format.scm
+++ b/gnu/system/installer/format.scm
@@ -36,17 +36,7 @@
(include "i18n.scm")
(define (device-attributes dev)
- (slurp (string-append "blkid -o export " dev)
- (lambda (x)
- (let ((idx (string-index x #\=)))
- (cons (string->symbol (string-fold
- (lambda (c acc)
- (string-append
- acc
- (make-string 1 (char-downcase c))))
- ""
- (substring x 0 idx)))
- (substring x (1+ idx) (string-length x)))))))
+ (key-value-slurp (string-append "blkid -o export " dev)))
(define (device-fs-uuid dev)
"Retrieve the UUID of the filesystem on DEV, where DEV is the name of the
diff --git a/gnu/system/installer/utils.scm b/gnu/system/installer/utils.scm
index e88524f..082dcc7 100644
--- a/gnu/system/installer/utils.scm
+++ b/gnu/system/installer/utils.scm
@@ -21,6 +21,7 @@
justify*
addstr*
slurp
+ key-value-slurp
quit-key?
push-cursor
@@ -162,6 +163,22 @@ This version assumes some external entity puts in the
carriage returns."
result
#f)))
+(define (key-value-slurp cmd)
+ "Slurp CMD, which is expected to give an output of key-value pairs -
+each pair terminated with a newline and the key/value delimited with ="
+ (slurp cmd
+ (lambda (x)
+ (let ((idx (string-index x #\=)))
+ (cons (string->symbol (string-fold
+ (lambda (c acc)
+ (string-append
+ acc
+ (make-string 1 (char-downcase c))))
+ ""
+ (substring x 0 idx)))
+ (substring x (1+ idx) (string-length x)))))))
+
+
(define (slurp-real port proc)
"Execute CMD in a shell and return a list of strings from its standard
output,
one per line. If PROC is not #f then it must be a procedure taking a string
- 146/197: gurses: Use match instead of car/cdr in line-split., (continued)
- 146/197: gurses: Use match instead of car/cdr in line-split., Danny Milosavljevic, 2017/07/03
- 147/197: gurses: In paragraph-format avoid use of car and cdr., Danny Milosavljevic, 2017/07/03
- 144/197: gurses: Avoid one more use of car and cdr., Danny Milosavljevic, 2017/07/03
- 143/197: gurses: Add predicate to test if a complex char is blank., Danny Milosavljevic, 2017/07/03
- 149/197: gurses: Add new procedure "word-endings"., Danny Milosavljevic, 2017/07/03
- 155/197: installer: Use _ instead of M_ for host-name-refresh., Danny Milosavljevic, 2017/07/03
- 160/197: installer: New convenience procedures., Danny Milosavljevic, 2017/07/03
- 158/197: installer: Correct placement of gettext call., Danny Milosavljevic, 2017/07/03
- 163/197: gurses: Cache the windows of buttons., Danny Milosavljevic, 2017/07/03
- 172/197: gurses: Update the cursor position when posting the form., Danny Milosavljevic, 2017/07/03
- 165/197: installer: New procedure key-value-slurp.,
Danny Milosavljevic <=
- 175/197: gurses: Don't crash if asked for an item by an invalid index., Danny Milosavljevic, 2017/07/03
- 171/197: installer: New page to edit user accounts., Danny Milosavljevic, 2017/07/03
- 187/197: installer: Add procudure for starting a wireless interface., Danny Milosavljevic, 2017/07/03
- 192/197: installer: Only build if guile-ncurses is available., Danny Milosavljevic, 2017/07/03
- 68/197: installer: Add new page to set the system role., Danny Milosavljevic, 2017/07/03
- 117/197: installer: Remove unnecessary "begin"., Danny Milosavljevic, 2017/07/03
- 113/197: installer: Explicitly set the #:panel parameter for window creation procedures., Danny Milosavljevic, 2017/07/03
- 122/197: gurses: Populate the choices box in forms., Danny Milosavljevic, 2017/07/03
- 128/197: installer: Remove redundant list of file system types., Danny Milosavljevic, 2017/07/03
- 115/197: installer: New procedure refresh*., Danny Milosavljevic, 2017/07/03