package catala
Install
dune-project
Dependency
Authors
Maintainers
Sources
md5=8f891209d18b6540df9c34b2d1a6a783
sha512=737770b87a057674bceefe77e8526720732552f51f424afcebcb6a628267eab522c4fd993caca1ae8ed7ace65a4a87e485af10c1676e51ca5939509a1b841ac2
doc/catala.catala_utils/Catala_utils/File/index.html
Module Catala_utils.FileSource
Utility functions used for file manipulation.
Runs the given function with the provided file opened, ensuring it is properly closed afterwards. May raise just as open_out.
Runs the given function with the provided file opened, ensuring it is properly closed afterwards. May raise just as open_in.
Formatter wrappers
with_formatter_of_out_channel oc f creates an flushes the formatter used in f from the given out_channel oc.
with_formatter_of_file filename f manages the formatter created from the file filename used in f -- i.e. closes the corresponding out_channel and flushes the formatter.
with_formatter_of_opt_file filename_opt f manages the formatter created from the file filename_opt if there is some (see with_formatter_of_file), otherwise, uses the Format.std_formatter.
val get_out_channel :
source_file:Cli.input_src ->
output_file:t option ->
?ext:string ->
unit ->
t option * ((out_channel -> 'a) -> 'a)get_output ~source_file ~output_file ?ext () returns the inferred filename and its corresponding with_out_channel function. If the output_file is equal to Some "-" returns a wrapper around stdout.
val get_formatter_of_out_channel :
source_file:Cli.input_src ->
output_file:t option ->
?ext:string ->
unit ->
t option * ((Format.formatter -> 'a) -> 'a)get_output_format ~source_file ~output_file ?ext () returns the inferred filename and its corresponding with_formatter_of_out_channel function. If the output_file is equal to Some "-" returns a wrapper around stdout.
Like Filename.temp_file, but registers the file for deletion at program exit unless Cli.debug_flag is set.
Creates a temp file (with prefix and suffix like temp_file, optionally with the given contents, for the lifetime of the supplied function, then remove it unconditionally
process_out cmd args executes the given command with the specified arguments, and returns the stdout of the process as a string. check_exit is called on the return code of the sub-process, the default is to fail on anything but 0.
Checks if the given directory exists and returns it normalised (as per Unix.realpath).
Returns its argument if it exists and is a plain file, None otherwise. Does not do resolution like check_directory.
Resolves a command:
- if
tis a plain name, resolve in PATH - if
tis relative, returns its absolute path - fails with an error explaining that
twas not found
Filename.concat: Sugar to allow writing File.("some" / "relative" / "path"). As an exception, if the lhs is ., returns the rhs unchanged.
Extension replacement: chops the given filename extension, and replaces it with the given one (which shouldn't contain a dot)
Empty elements or current-directory (".") are skipped in the resulting list
Formats a filename in a consistent style, with double-quotes and color (when the output supports)
Recursively scans a directory for files. Directories or files matching ".*" or "_*" are ignored. Unreadable files or subdirectories are ignored with a debug message. If t is a plain file, scan just that non-recursively.
The matching results are returned grouped by directory, case-insensitively ordered by filename, as a list of non-empty subdirs and a list of extracted items.