126 lines
3 KiB
Markdown
126 lines
3 KiB
Markdown
# Utility modules
|
|
|
|
These are various utility modules for other HackerBase libraries.
|
|
|
|
## util-time [module]
|
|
|
|
(import util-time)
|
|
|
|
Compatibility module for the differences between chicken scheme
|
|
version 5.2 and earlier and 5.3 and on.
|
|
|
|
### current-util-milliseconds [procedure]
|
|
|
|
(current-util-milliseconds)
|
|
|
|
Returns the number of milliseconds since process startup.
|
|
|
|
Under chicken scheme <5.3 it uses ```current-milliseconds``` and for
|
|
chicken scheme >=5.3 it uses ```current-process-milliseconds```.
|
|
|
|
Without this module compilation with ```current-milliseconds```
|
|
results in warnings on chicken scheme >=5.3 and compilation under
|
|
chicken scheme <5.3 results in error with
|
|
```current-process-milliseconds```.
|
|
|
|
### seconds->iso-date-string [procedure]
|
|
|
|
(seconds->iso-date-string . args)
|
|
|
|
Converts given seconds to ISO date string YYYY-MM-DD. Defaults to ```(current-seconds)```.
|
|
|
|
### today/iso [procedure]
|
|
|
|
(today/iso)
|
|
|
|
Returns today as ISO date string YYYY-MM-DD.
|
|
|
|
## util-csv [module]
|
|
|
|
(import util-csv)
|
|
|
|
This module provides a very simple, incomplete and incorrect but fast
|
|
CSV loader.
|
|
|
|
### (make-csv-line-parser separator string-delimiter) [procedure]
|
|
|
|
((make-csv-line-parser line)
|
|
separator
|
|
string-delimiter)
|
|
|
|
Curried version of fast CSV line parser with given separator and string delimiter.
|
|
|
|
* ```separator``` - separator character
|
|
* ```string-delimiger``` - string quotation character
|
|
* ```line``` - line to parse
|
|
|
|
### csv-parse-lines [procedure]
|
|
|
|
(csv-parse-lines lines
|
|
#:separator (separator #\;)
|
|
#:string-delimiter (string-delimiter #\"))
|
|
|
|
Parses given lines and returns list of lists of strings.
|
|
|
|
### csv-parse [procedure]
|
|
|
|
(csv-parse fn
|
|
. args)
|
|
|
|
Uses ```csv-parse-lines``` on lines read from given file ```fn```.
|
|
|
|
### csv-split-header [procedure]
|
|
|
|
(csv-split-header csv)
|
|
|
|
Splits given loaded CSV into two tables at the first empty row.
|
|
|
|
## util-git [module]
|
|
|
|
(import util-git)
|
|
|
|
This module provides basic git repository querying functionality.
|
|
|
|
### git [procedure]
|
|
|
|
(git repo
|
|
(defmodesym (quote output)))
|
|
|
|
|
|
* ```repo``` - a path to repository
|
|
* ```mode``` - return values mode for operations
|
|
|
|
Returns a procedure that allows invocation of git in given ```repo```
|
|
repository returning one or two values based on ```mode``` given:
|
|
|
|
* ```'exit``` - returns exit code
|
|
* ```'output``` - returns the output lines (default)
|
|
* ```'exit+output``` - returns both exit code and output lines
|
|
|
|
|
|
### git-status [procedure]
|
|
|
|
(git-status repo)
|
|
|
|
|
|
* ```repo``` - git repository
|
|
|
|
Returns a dictionary with the following keys:
|
|
|
|
* ```'modified``` - list of modified files
|
|
* ```'untracked``` - list of untracked files
|
|
* ```'unknown``` - list of files with unknown status
|
|
|
|
|
|
### git-blame [procedure]
|
|
|
|
(git-blame repo
|
|
fname)
|
|
|
|
|
|
* ```repo``` - git repository
|
|
* ```fname``` - file name (path) relative to the git repository
|
|
|
|
Returns annotated source with information about originating commits
|
|
for each line.
|
|
|