<commit_before>#!/bin/sh

set -e

usage() {
    echo "Usage: bup import-duplicity [-n]" \
        "<duplicity target url> <backup name>"
    echo "-n,--dry-run: just print what would be done"
    exit -1
}

control_c() {
    echo "bup import-duplicity: signal 2 received" 1>&2
    exit 128
}

trap control_c INT

dry_run=
while [ "$1" = "-n" -o "$1" = "--dry-run" ]; do
    dry_run=echo
    shift
done

bup()
{
    $dry_run "${BUP_MAIN_EXE:=bup}" "$@"
}

duplicity_target_url=$1
branch=$2

[ -n "$duplicity_target_url" -a "$#" = 2 ] || usage

dup_timestamps=$(duplicity collection-status --log-fd=3 \
                 "$duplicity_target_url" 3>&1 1>/dev/null 2>/dev/null |
                 grep "[[:digit:]][[:digit:]]T" |
                 cut -d" " -f 3)
backups_count=$(echo "$dup_timestamp" | wc -l)
counter=1
echo "$dup_timestamps" |
while read dup_timestamp; do
  timestamp=$(python -c "import time,calendar; " \
      "print str(int(calendar.timegm(time.strptime('$dup_timestamp', " \
      "'%Y%m%dT%H%M%SZ'))))")
  echo "Importing backup from $(date --date=@$timestamp +%c) " \
      "($counter / $backups_count)" 1>&2
  echo 1>&2

  tmpdir=$(mktemp -d)<commit_msg>Quote command arguments in import-duplicity-cmd.sh.<commit_after>#!/bin/sh

set -e

usage() {
    echo "Usage: bup import-duplicity [-n]" \
        "<duplicity target url> <backup name>"
    echo "-n,--dry-run: just print what would be done"
    exit -1
}

control_c() {
    echo "bup import-duplicity: signal 2 received" 1>&2
    exit 128
}

trap control_c INT

dry_run=
while [ "$1" = "-n" -o "$1" = "--dry-run" ]; do
    dry_run=echo
    shift
done

bup()
{
    $dry_run "${BUP_MAIN_EXE:=bup}" "$@"
}

duplicity_target_url="$1"
branch="$2"

[ -n "$duplicity_target_url" -a "$#" = 2 ] || usage

dup_timestamps=$(duplicity collection-status --log-fd=3 \
                 "$duplicity_target_url" 3>&1 1>/dev/null 2>/dev/null |
                 grep "[[:digit:]][[:digit:]]T" |
                 cut -d" " -f 3)
backups_count=$(echo "$dup_timestamp" | wc -l)
counter=1
echo "$dup_timestamps" |
while read dup_timestamp; do
  timestamp=$(python -c "import time,calendar; " \
      "print str(int(calendar.timegm(time.strptime('$dup_timestamp', " \
      "'%Y%m%dT%H%M%SZ'))))")
  echo "Importing backup from $(date --date=@$timestamp +%c) " \
      "($counter / $backups_count)" 1>&2
  echo 1>&2

  tmpdir=$(mktemp -d)
{'fraction_non_alphanumeric': 0.19011725293132328, 'fraction_numerical': 0.019262981574539362, 'mean_word_length': 2.922824302134647, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6857908', 'n_tokens_mistral': 961, 'n_tokens_neox': 906, 'n_words': 209}