Skip to content

Commit

Permalink
Implement --overwrite to --force workspace add, OCR-D/core#522
Browse files Browse the repository at this point in the history
  • Loading branch information
kba committed Jun 17, 2020
1 parent 31eb2ae commit dcea9af
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions ocrd-im6convert
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,13 @@ MIMETYPE_PAGE=$(ocrd bashlib constants MIMETYPE_PAGE)
declare -A MIME_TO_EXT
eval "MIME_TO_EXT=( $(ocrd bashlib constants MIME_TO_EXT) )"

# FIXME: add a bashlib wrapper for logging to use here
function log {
echo >&2 "$(date +%T.%3N) $LEVEL ocrd-im6convert - $1"
}
function critical { LEVEL=CRITICAL log "$1"; }
function error { LEVEL=ERROR log "$1"; }
function warning { LEVEL=WARNING log "$1"; }
function info { LEVEL=INFO log "$1"; }
function debug { LEVEL=DEBUG log "$1"; }

main () {
# Load ocrd bashlib functions
# shellcheck source=../core/ocrd/bashlib/lib.bash
source $(ocrd bashlib filename)

ocrd__minversion 2.10.4

# Describe calling script to lib.bash
ocrd__wrap "$SHAREDIR/ocrd-tool.json" "ocrd-im6convert" "$@"

Expand Down Expand Up @@ -68,7 +60,7 @@ main () {
local pageid="${fields[2]:-}"

if ! test -f "$in_file"; then
error "input file \"$in_file\" ID=${in_id} (pageId=${pageid}) is not on disk"
ocrd log error "input file \"$in_file\" ID=${in_id} (pageId=${pageid}) is not on disk"
continue
fi

Expand All @@ -80,7 +72,7 @@ main () {
local out_file="$out_file_grp/${out_id}$output_extension"

# Actual conversion
info "processing image input file $in_id ($pageid)"
ocrd log info "processing image input file $in_id ($pageid)"
convert "${input_options[@]}" "$in_file" "${output_options[@]}" "$out_file"

# Add the output files
Expand All @@ -90,6 +82,10 @@ main () {
else
options=()
fi

if [[ "${ocrd__argv[overwrite]}" = true ]];then
options+=( --force )
fi
options+=( -G $out_file_grp
-m "${params['output-format']}"
-i "$out_id"
Expand Down

0 comments on commit dcea9af

Please sign in to comment.