gnucash maint: Multiple changes pushed
Christopher Lam
clam at code.gnucash.org
Sat Mar 2 06:28:24 EST 2019
Updated via https://github.com/Gnucash/gnucash/commit/47cdcade (commit)
via https://github.com/Gnucash/gnucash/commit/11742530 (commit)
via https://github.com/Gnucash/gnucash/commit/a6296314 (commit)
via https://github.com/Gnucash/gnucash/commit/613adfe8 (commit)
from https://github.com/Gnucash/gnucash/commit/d9c83523 (commit)
commit 47cdcaded35612ba8a5e4dca6d37c9150a2e20b7
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Mar 2 15:40:18 2019 +0800
[standard-reports] drop (process-file-list)
The list of reports is obtained by scanning the standard-reports
folder for *.scm, then processes the filenames by removing
".scm". Process the removal directly.
diff --git a/gnucash/report/standard-reports/standard-reports.scm b/gnucash/report/standard-reports/standard-reports.scm
index 0902bae42..235f763c8 100644
--- a/gnucash/report/standard-reports/standard-reports.scm
+++ b/gnucash/report/standard-reports/standard-reports.scm
@@ -99,40 +99,21 @@
(else
(loop (readdir dir-stream)
(if (string-suffix? ".scm" fname)
- (cons fname acc)
+ (cons (string-drop-right fname 4) acc)
acc)))))))
(else
(gnc:warn "Can't access " dir ".\nEmpty list will be returned.")
'())))
-;; Process a list of files by removing the ".scm" suffix if it exists
-;;
-;; Param:
-;; l - list of files
-;;
-;; Return value:
-;; List of files with .scm suffix removed
-(define (process-file-list l)
- (map
- (lambda (s)
- (if (string-suffix? ".scm" s)
- (string-drop-right s 4)
- s))
- l))
-
;; Return a list of symbols representing reports in the standard reports directory
;;
;; Return value:
;; List of symbols for reports
(define (get-report-list)
- (map
- (lambda (s)
- (string->symbol s))
- (process-file-list (directory-files (gnc-path-get-stdreportsdir)))))
+ (map string->symbol (directory-files (gnc-path-get-stdreportsdir))))
(gnc:debug "stdrpt-dir=" (gnc-path-get-stdreportsdir))
(gnc:debug "dir-files=" (directory-files (gnc-path-get-stdreportsdir)))
-(gnc:debug "processed=" (process-file-list (directory-files (gnc-path-get-stdreportsdir))))
(gnc:debug "report-list=" (get-report-list))
(for-each
commit 117425305babfe40b8a964227297505fc3842a0f
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Mar 2 15:01:44 2019 +0800
[standard-reports] compact (directory-files) and remove regex
use string-suffix? instead.
diff --git a/gnucash/report/standard-reports/standard-reports.scm b/gnucash/report/standard-reports/standard-reports.scm
index 2c13ee09a..0902bae42 100644
--- a/gnucash/report/standard-reports/standard-reports.scm
+++ b/gnucash/report/standard-reports/standard-reports.scm
@@ -87,23 +87,23 @@
;; list of files in the directory
(define (directory-files dir)
- (if (file-exists? dir)
- (let ((fname-regexp (make-regexp "\\.scm$"))
- ;; Regexp that matches the desired filenames
- (dir-stream (opendir dir)))
- (let loop ((fname (readdir dir-stream))
- (acc '()))
- (if (eof-object? fname)
- (begin
- (closedir dir-stream)
- acc)
- (loop (readdir dir-stream)
- (if (regexp-exec fname-regexp fname)
- (cons fname acc)
- acc)))))
- (begin
- (gnc:warn "Can't access " dir ".\nEmpty list will be returned.")
- '())))
+ (cond
+ ((file-exists? dir)
+ (let ((dir-stream (opendir dir)))
+ (let loop ((fname (readdir dir-stream))
+ (acc '()))
+ (cond
+ ((eof-object? fname)
+ (closedir dir-stream)
+ acc)
+ (else
+ (loop (readdir dir-stream)
+ (if (string-suffix? ".scm" fname)
+ (cons fname acc)
+ acc)))))))
+ (else
+ (gnc:warn "Can't access " dir ".\nEmpty list will be returned.")
+ '())))
;; Process a list of files by removing the ".scm" suffix if it exists
;;
commit a6296314a0b090d7fa5a660ef7257f352772d854
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Mar 2 14:47:16 2019 +0800
[standard-reports] compact functions
diff --git a/gnucash/report/standard-reports/standard-reports.scm b/gnucash/report/standard-reports/standard-reports.scm
index 03f9cebe1..2c13ee09a 100644
--- a/gnucash/report/standard-reports/standard-reports.scm
+++ b/gnucash/report/standard-reports/standard-reports.scm
@@ -60,9 +60,7 @@
(record-modifier acct-type-info 'non-split))
(define (gnc:register-report-hook acct-type split? create-fcn)
- (let ((type-info (hash-ref gnc:*register-report-hash* acct-type)))
- (if (not type-info)
- (set! type-info (make-acct-type)))
+ (let ((type-info (hash-ref gnc:*register-report-hash* acct-type (make-acct-type))))
(if split?
(set-split type-info create-fcn)
(set-non-split type-info create-fcn))
@@ -74,11 +72,10 @@
(gnc:debug "ref: " type-info)
(gnc:debug "hash: " gnc:*register-report-hash*)
(gnc:debug "split: " split)
- (if type-info
- (if (and split (not (null? split)))
- (begin (gnc:debug "get-split...") (get-split type-info))
- (begin (gnc:debug "get-non-split...") (get-non-split type-info)))
- #f)))
+ (and type-info
+ (if (and split (not (null? split)))
+ (begin (gnc:debug "get-split...") (get-split type-info))
+ (begin (gnc:debug "get-non-split...") (get-non-split type-info))))))
;; Returns a list of files in a directory
@@ -142,7 +139,7 @@
(lambda (x)
(module-use!
(current-module)
- (resolve-interface (append '(gnucash report standard-reports) (list x)))))
+ (resolve-interface `(gnucash report standard-reports ,x))))
(get-report-list))
(use-modules (gnucash gnc-module))
commit 613adfe82497c5e82c70ab7f7368e63705849992
Author: Christopher Lam <christopher.lck at gmail.com>
Date: Sat Mar 2 14:45:19 2019 +0800
[standard-reports] reindent/untabify/delete-trailing-whitespace
diff --git a/gnucash/report/standard-reports/standard-reports.scm b/gnucash/report/standard-reports/standard-reports.scm
index 97ab8c8f6..03f9cebe1 100644
--- a/gnucash/report/standard-reports/standard-reports.scm
+++ b/gnucash/report/standard-reports/standard-reports.scm
@@ -26,7 +26,7 @@
(define-module (gnucash report standard-reports))
(use-modules (srfi srfi-13))
-(use-modules (gnucash utilities))
+(use-modules (gnucash utilities))
(use-modules (gnucash core-utils))
(export gnc:register-report-create)
@@ -61,14 +61,11 @@
(define (gnc:register-report-hook acct-type split? create-fcn)
(let ((type-info (hash-ref gnc:*register-report-hash* acct-type)))
-
(if (not type-info)
- (set! type-info (make-acct-type)))
-
+ (set! type-info (make-acct-type)))
(if split?
- (set-split type-info create-fcn)
- (set-non-split type-info create-fcn))
-
+ (set-split type-info create-fcn)
+ (set-non-split type-info create-fcn))
(hash-set! gnc:*register-report-hash* acct-type type-info)))
(define (lookup-register-report acct-type split)
@@ -78,10 +75,10 @@
(gnc:debug "hash: " gnc:*register-report-hash*)
(gnc:debug "split: " split)
(if type-info
- (if (and split (not (null? split)))
- (begin (gnc:debug "get-split...") (get-split type-info))
- (begin (gnc:debug "get-non-split...") (get-non-split type-info)))
- #f)))
+ (if (and split (not (null? split)))
+ (begin (gnc:debug "get-split...") (get-split type-info))
+ (begin (gnc:debug "get-non-split...") (get-non-split type-info)))
+ #f)))
;; Returns a list of files in a directory
@@ -94,30 +91,22 @@
(define (directory-files dir)
(if (file-exists? dir)
- (let ((fname-regexp (make-regexp "\\.scm$")) ;; Regexp that matches the desired filenames
+ (let ((fname-regexp (make-regexp "\\.scm$"))
+ ;; Regexp that matches the desired filenames
(dir-stream (opendir dir)))
-
- (let loop ((fname (readdir dir-stream))
- (acc '()))
- (if (eof-object? fname)
- (begin
- (closedir dir-stream)
- acc
- )
- (loop (readdir dir-stream)
- (if (regexp-exec fname-regexp fname)
- (cons fname acc)
- acc
- )
- )
- )
- ))
+ (let loop ((fname (readdir dir-stream))
+ (acc '()))
+ (if (eof-object? fname)
+ (begin
+ (closedir dir-stream)
+ acc)
+ (loop (readdir dir-stream)
+ (if (regexp-exec fname-regexp fname)
+ (cons fname acc)
+ acc)))))
(begin
- (gnc:warn "Can't access " dir ".\nEmpty list will be returned.")
- '() ;; return empty list
- )
- )
-)
+ (gnc:warn "Can't access " dir ".\nEmpty list will be returned.")
+ '())))
;; Process a list of files by removing the ".scm" suffix if it exists
;;
@@ -127,19 +116,22 @@
;; Return value:
;; List of files with .scm suffix removed
(define (process-file-list l)
- (map (lambda (s) (if (string-suffix? ".scm" s) (string-drop-right s 4) s))
- l
- )
-)
+ (map
+ (lambda (s)
+ (if (string-suffix? ".scm" s)
+ (string-drop-right s 4)
+ s))
+ l))
;; Return a list of symbols representing reports in the standard reports directory
;;
;; Return value:
;; List of symbols for reports
(define (get-report-list)
- (map (lambda (s) (string->symbol s))
- (process-file-list (directory-files (gnc-path-get-stdreportsdir))))
-)
+ (map
+ (lambda (s)
+ (string->symbol s))
+ (process-file-list (directory-files (gnc-path-get-stdreportsdir)))))
(gnc:debug "stdrpt-dir=" (gnc-path-get-stdreportsdir))
(gnc:debug "dir-files=" (directory-files (gnc-path-get-stdreportsdir)))
@@ -147,22 +139,22 @@
(gnc:debug "report-list=" (get-report-list))
(for-each
- (lambda (x)
- (module-use!
- (current-module)
- (resolve-interface (append '(gnucash report standard-reports) (list x)))))
- (get-report-list))
+ (lambda (x)
+ (module-use!
+ (current-module)
+ (resolve-interface (append '(gnucash report standard-reports) (list x)))))
+ (get-report-list))
(use-modules (gnucash gnc-module))
(gnc:module-load "gnucash/engine" 0)
(define (gnc:register-report-create account split query journal? ledger-type?
- double? title debit-string credit-string)
+ double? title debit-string credit-string)
(let* ((acct-type (xaccAccountGetType account))
- (create-fcn (lookup-register-report acct-type split)))
+ (create-fcn (lookup-register-report acct-type split)))
(gnc:debug "create-fcn: " create-fcn)
(if create-fcn
- (create-fcn account split query journal? double? title
- debit-string credit-string)
- (gnc:register-report-create-internal #f query journal? ledger-type? double?
- title debit-string credit-string))))
+ (create-fcn account split query journal? double? title
+ debit-string credit-string)
+ (gnc:register-report-create-internal #f query journal? ledger-type? double?
+ title debit-string credit-string))))
Summary of changes:
.../report/standard-reports/standard-reports.scm | 104 ++++++++-------------
1 file changed, 37 insertions(+), 67 deletions(-)
More information about the gnucash-changes
mailing list