From 09ce58df5ad8835fa116663b98f46e37848c31b6 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 13 2019 22:08:30 +0000
Subject: [PATCH 1/19] generate commands for all-po-to-src from site.yml


---

diff --git a/readyaml.py b/readyaml.py
new file mode 100644
index 0000000..1b479ab
--- /dev/null
+++ b/readyaml.py
@@ -0,0 +1,33 @@
+# -*- coding: utf-8 -*-
+import yaml
+import urllib.request
+import os
+from pprint import pprint
+
+# download site.yml
+
+urllib.request.urlretrieve ("https://pagure.io/fedora-docs/docs-fp-o/raw/master/f/site.yml", "site.yml")
+
+# Read site.yml
+with open("site.yml", 'r') as stream:
+    data_loaded = yaml.load(stream)
+
+# Parse site.yml
+
+for source in data_loaded['content']['sources']:
+    url   = source['url']
+
+    if 'start_path' in source:
+        src_basedir = source['start_path']
+        print("$cmd --clone-target-repo --src-basedir {basedir} {url} $output_dir".format( basedir=src_basedir, url=url ))
+
+    elif 'branches' in source:
+        for branch in source['branches']:
+            src_branch = branch
+            print("$cmd --clone-target-repo --src-branch {branch} {url} $output_dir".format( branch=src_branch, url=url ))
+    else:
+            print("$cmd --clone-target-repo {url} $output_dir".format( url=url ))
+
+# Remove site.yml
+
+os.remove("site.yml")

From ad8b302d2333942299e527cc9316dfe60c9fc3f5 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 14 2019 19:35:05 +0000
Subject: [PATCH 2/19] follow pylint advices


---

diff --git a/readyaml.py b/readyaml.py
index 1b479ab..ce12db0 100644
--- a/readyaml.py
+++ b/readyaml.py
@@ -1,33 +1,38 @@
 # -*- coding: utf-8 -*-
-import yaml
-import urllib.request
 import os
-from pprint import pprint
+import urllib.request
+import yaml
+# from pprint import pprint
 
 # download site.yml
-
-urllib.request.urlretrieve ("https://pagure.io/fedora-docs/docs-fp-o/raw/master/f/site.yml", "site.yml")
+urllib.request.urlretrieve(
+    "https://pagure.io/fedora-docs/docs-fp-o/raw/master/f/site.yml", "site.yml"
+    )
 
 # Read site.yml
 with open("site.yml", 'r') as stream:
-    data_loaded = yaml.load(stream)
+    DATA_LOADED = yaml.load(stream)
 
 # Parse site.yml
-
-for source in data_loaded['content']['sources']:
-    url   = source['url']
+for source in DATA_LOADED['content']['sources']:
+    url = source['url']
 
     if 'start_path' in source:
         src_basedir = source['start_path']
-        print("$cmd --clone-target-repo --src-basedir {basedir} {url} $output_dir".format( basedir=src_basedir, url=url ))
+        print(
+            "$cmd --clone-target-repo --src-basedir {basedir} {url} $output_dir"
+            .format(basedir=src_basedir, url=url)
+            )
 
     elif 'branches' in source:
         for branch in source['branches']:
             src_branch = branch
-            print("$cmd --clone-target-repo --src-branch {branch} {url} $output_dir".format( branch=src_branch, url=url ))
+            print(
+                "$cmd --clone-target-repo --src-branch {branch} {url} $output_dir"
+                .format(branch=src_branch, url=url)
+                )
     else:
-            print("$cmd --clone-target-repo {url} $output_dir".format( url=url ))
+        print("$cmd --clone-target-repo {url} $output_dir".format(url=url))
 
 # Remove site.yml
-
 os.remove("site.yml")

From 3a237ab1793d127e0aedf6fbda2c78341af8daf0 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 14 2019 19:41:50 +0000
Subject: [PATCH 3/19] python autopep8


---

diff --git a/readyaml.py b/readyaml.py
index ce12db0..73a75e3 100644
--- a/readyaml.py
+++ b/readyaml.py
@@ -1,4 +1,5 @@
-# -*- coding: utf-8 -*-
+#!/usr/bin/env python3
+
 import os
 import urllib.request
 import yaml
@@ -7,7 +8,7 @@ import yaml
 # download site.yml
 urllib.request.urlretrieve(
     "https://pagure.io/fedora-docs/docs-fp-o/raw/master/f/site.yml", "site.yml"
-    )
+)
 
 # Read site.yml
 with open("site.yml", 'r') as stream:
@@ -22,7 +23,7 @@ for source in DATA_LOADED['content']['sources']:
         print(
             "$cmd --clone-target-repo --src-basedir {basedir} {url} $output_dir"
             .format(basedir=src_basedir, url=url)
-            )
+        )
 
     elif 'branches' in source:
         for branch in source['branches']:
@@ -30,7 +31,7 @@ for source in DATA_LOADED['content']['sources']:
             print(
                 "$cmd --clone-target-repo --src-branch {branch} {url} $output_dir"
                 .format(branch=src_branch, url=url)
-                )
+            )
     else:
         print("$cmd --clone-target-repo {url} $output_dir".format(url=url))
 

From 6a6ecf4de1ba0f6db01a67600dc9d5f528cdc379 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 14 2019 19:43:33 +0000
Subject: [PATCH 4/19] remove pprint


---

diff --git a/readyaml.py b/readyaml.py
index 73a75e3..6a40633 100644
--- a/readyaml.py
+++ b/readyaml.py
@@ -3,7 +3,6 @@
 import os
 import urllib.request
 import yaml
-# from pprint import pprint
 
 # download site.yml
 urllib.request.urlretrieve(

From 213b98b79390eaefac3c71ee8071959b89bfdc98 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 14 2019 20:30:53 +0000
Subject: [PATCH 5/19] add arguments handling


---

diff --git a/readyaml.py b/readyaml.py
old mode 100644
new mode 100755
index 6a40633..67ed243
--- a/readyaml.py
+++ b/readyaml.py
@@ -1,38 +1,67 @@
 #!/usr/bin/env python3
+"""Calls `./po-to-src.sh` for all source repos"""
 
+import argparse
 import os
 import urllib.request
 import yaml
 
-# download site.yml
-urllib.request.urlretrieve(
-    "https://pagure.io/fedora-docs/docs-fp-o/raw/master/f/site.yml", "site.yml"
-)
-
-# Read site.yml
-with open("site.yml", 'r') as stream:
-    DATA_LOADED = yaml.load(stream)
-
-# Parse site.yml
-for source in DATA_LOADED['content']['sources']:
-    url = source['url']
-
-    if 'start_path' in source:
-        src_basedir = source['start_path']
-        print(
-            "$cmd --clone-target-repo --src-basedir {basedir} {url} $output_dir"
-            .format(basedir=src_basedir, url=url)
-        )
-
-    elif 'branches' in source:
-        for branch in source['branches']:
-            src_branch = branch
+
+def main():
+    """Handle params"""
+    parser = argparse.ArgumentParser(
+        description="Calls `./po-to-src.sh` for all source repos")
+    parser.add_argument("output_dir", help="Output directory")
+    args = parser.parse_args()
+
+    output_dir = args.output_dir
+
+    os.makedirs(output_dir, exist_ok=True)
+
+    output_dir = os.path.abspath(output_dir)
+
+    parse_yml(output_dir)
+
+
+def parse_yml(output_dir):
+    """List repositories to convert to pot from antora yaml file"""
+
+    # download site.yml
+    urllib.request.urlretrieve(
+        "https://pagure.io/fedora-docs/docs-fp-o/raw/master/f/site.yml", "site.yml"
+    )
+
+    # Read site.yml
+    with open("site.yml", 'r') as stream:
+        data_loaded = yaml.load(stream)
+
+    # Parse site.yml
+    for source in data_loaded['content']['sources']:
+        url = source['url']
+
+        if 'start_path' in source:
+            src_basedir = source['start_path']
+            print(
+                "$cmd --clone-target-repo --src-basedir {basedir} {url} {output_dir}"
+                .format(basedir=src_basedir, url=url, output_dir=output_dir)
+            )
+
+        elif 'branches' in source:
+            for branch in source['branches']:
+                src_branch = branch
+                print(
+                    "$cmd --clone-target-repo --src-branch {branch} {url} {output_dir}"
+                    .format(branch=src_branch, url=url, output_dir=output_dir)
+                )
+        else:
             print(
-                "$cmd --clone-target-repo --src-branch {branch} {url} $output_dir"
-                .format(branch=src_branch, url=url)
+                "$cmd --clone-target-repo {url} {output_dir}"
+                .format(url=url, output_dir=output_dir)
             )
-    else:
-        print("$cmd --clone-target-repo {url} $output_dir".format(url=url))
 
-# Remove site.yml
-os.remove("site.yml")
+    # Remove site.yml
+    os.remove("site.yml")
+
+
+if __name__ == '__main__':
+    main()

From ddd19fd0f7679164aa174ce3670bd7f7514d4e63 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 20 2019 08:03:50 +0000
Subject: [PATCH 6/19] call podman command


---

diff --git a/readyaml.py b/readyaml.py
index 67ed243..bff5a65 100755
--- a/readyaml.py
+++ b/readyaml.py
@@ -4,6 +4,8 @@
 import argparse
 import os
 import urllib.request
+import subprocess
+import shlex
 import yaml
 
 
@@ -23,6 +25,17 @@ def main():
     parse_yml(output_dir)
 
 
+def clone_translated_sources(output_dir, doc):
+    """Call podman and tell him to use po-to-src.sh for the specified documentation"""
+
+    command = "podman run --rm -it -v {o}:/output:z ".format(o=output_dir)
+    command += "-v {c}/src-to-pot.sh:/scripts/src-to-pot.sh:z ".format(c=os.getcwd())
+    command += "asamalik/fedora-docs-translations /scripts/src-to-pot.sh {d}".format(d=doc)
+    print(command)
+    args = shlex.split(command)
+    subprocess.call(args)
+
+
 def parse_yml(output_dir):
     """List repositories to convert to pot from antora yaml file"""
 
@@ -41,23 +54,18 @@ def parse_yml(output_dir):
 
         if 'start_path' in source:
             src_basedir = source['start_path']
-            print(
-                "$cmd --clone-target-repo --src-basedir {basedir} {url} {output_dir}"
-                .format(basedir=src_basedir, url=url, output_dir=output_dir)
-            )
+            doc = "--clone-target-repo --src-basedir \"{bd}\" {url} {o}".format(
+                bd=src_basedir, url=url, o=output_dir)
 
         elif 'branches' in source:
             for branch in source['branches']:
                 src_branch = branch
-                print(
-                    "$cmd --clone-target-repo --src-branch {branch} {url} {output_dir}"
-                    .format(branch=src_branch, url=url, output_dir=output_dir)
-                )
+                doc = "--clone-target-repo --src-branch \"{br}\" {url} {o}".format(
+                    br=src_branch, url=url, o=output_dir)
         else:
-            print(
-                "$cmd --clone-target-repo {url} {output_dir}"
-                .format(url=url, output_dir=output_dir)
-            )
+            doc = "--clone-target-repo {url} {o}".format(url=url, o=output_dir)
+
+        clone_translated_sources(output_dir, doc)
 
     # Remove site.yml
     os.remove("site.yml")

From a240fc70edcb3aa010155e1211b2c84ada7f7ce8 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 20 2019 14:47:47 +0000
Subject: [PATCH 7/19] change the way to coll podman and src-to-po


---

diff --git a/readyaml.py b/readyaml.py
index bff5a65..cd6aa04 100755
--- a/readyaml.py
+++ b/readyaml.py
@@ -21,19 +21,15 @@ def main():
     os.makedirs(output_dir, exist_ok=True)
 
     output_dir = os.path.abspath(output_dir)
-
     parse_yml(output_dir)
 
-
-def clone_translated_sources(output_dir, doc):
-    """Call podman and tell him to use po-to-src.sh for the specified documentation"""
-
+def call_podman_and_src_to_po(output_dir, doc):
     command = "podman run --rm -it -v {o}:/output:z ".format(o=output_dir)
     command += "-v {c}/src-to-pot.sh:/scripts/src-to-pot.sh:z ".format(c=os.getcwd())
     command += "asamalik/fedora-docs-translations /scripts/src-to-pot.sh {d}".format(d=doc)
     print(command)
     args = shlex.split(command)
-    subprocess.call(args)
+    subprocess.run(args, check=True)
 
 
 def parse_yml(output_dir):
@@ -65,7 +61,7 @@ def parse_yml(output_dir):
         else:
             doc = "--clone-target-repo {url} {o}".format(url=url, o=output_dir)
 
-        clone_translated_sources(output_dir, doc)
+        call_podman_and_src_to_po(output_dir, doc)
 
     # Remove site.yml
     os.remove("site.yml")

From 5919fc247d7d016fea930f30ed79798ef965d871 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 20 2019 15:09:23 +0000
Subject: [PATCH 8/19] fix output directory


---

diff --git a/readyaml.py b/readyaml.py
index cd6aa04..277fb52 100755
--- a/readyaml.py
+++ b/readyaml.py
@@ -50,16 +50,16 @@ def parse_yml(output_dir):
 
         if 'start_path' in source:
             src_basedir = source['start_path']
-            doc = "--clone-target-repo --src-basedir \"{bd}\" {url} {o}".format(
-                bd=src_basedir, url=url, o=output_dir)
+            doc = "--clone-target-repo --src-basedir \"{bd}\" {url} /output".format(
+                bd=src_basedir, url=url)
 
         elif 'branches' in source:
             for branch in source['branches']:
                 src_branch = branch
-                doc = "--clone-target-repo --src-branch \"{br}\" {url} {o}".format(
-                    br=src_branch, url=url, o=output_dir)
+                doc = "--clone-target-repo --src-branch \"{br}\" {url} /output".format(
+                    br=src_branch, url=url)
         else:
-            doc = "--clone-target-repo {url} {o}".format(url=url, o=output_dir)
+            doc = "--clone-target-repo {url} /output".format(url=url)
 
         call_podman_and_src_to_po(output_dir, doc)
 

From e40735462ade6984f95fb4713b6caee291ca2ef3 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Mar 21 2019 04:45:06 +0000
Subject: [PATCH 9/19] shellcheck fixes


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index a6d5175..436173c 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -23,7 +23,6 @@ usage () {
     echo "  --clone-target-repo         Clones the PO/POT repo into the output directory"
 }
 
-
 while true ; do
     case $1 in
         --src-branch )
@@ -79,14 +78,7 @@ else
 fi
 
 # TARGET_DIR need to exist
-if [ -d "$output_dir" ]; then
-    pushd $output_dir > /dev/null
-    output_dir=$(pwd)
-    popd > /dev/null
-else
-    echo "Error. The specified output directory doesn't exist"
-    exit 1
-fi
+mkdir -p "$output_dir"
 
 if [ -z "$src_branch" ]; then
     src_branch="master"
@@ -98,7 +90,7 @@ fi
 
 tmp_english_src=$(mktemp -d)
 
-if ! git clone -b $src_branch $src_repo $tmp_english_src ; then
+if ! git clone -b $src_branch "$src_repo" "$tmp_english_src" ; then
     echo ""
     echo "Error cloning the specified git repository."
     rm -rf "$tmp_english_src"
@@ -123,7 +115,7 @@ fi
 
 
 
-pushd "$tmp_english_src/$src_basedir" > /dev/null
+pushd "$tmp_english_src/$src_basedir" > /dev/null || exit
 
 # Get component name from the antora.yml
 component=$(sed -n 's/^name: *\"*\([[:alnum:]_-]*\).*/\1/p' antora.yml)
@@ -136,7 +128,7 @@ version=$(sed -n 's/^version: *\"*\([[:alnum:]_-]*\).*/\1/p' antora.yml)
 #   2) the user specified it using --module MODULE and it exists
 # In case there are multiple modules under ./modules/
 # and the user hasn't specified one, throw an error.
-if [ ! $(ls -1 ./modules | wc -l) = 1 ] && [ -z $module ]; then
+if [ ! $(ls -1 ./modules | wc -l) = 1 ] && [ -z "$module" ]; then
     echo ""
     echo "Error. This repository contains multiple antora modules,"
     echo "and the script doesn't know which one to choose."
@@ -149,7 +141,7 @@ if [ ! $(ls -1 ./modules | wc -l) = 1 ] && [ -z $module ]; then
     exit 1
 fi
 
-if [ -z $module ]; then
+if [ -z "$module" ]; then
     module=$(ls ./modules)
 fi
 
@@ -165,15 +157,18 @@ if [ ! -d "modules/$module" ]; then
     exit 1
 fi
 
-popd > /dev/null
+popd > /dev/null || exit
 
-if [ $module = "ROOT" ]; then
+if [ "$module" = "ROOT" ]; then
     target_repo_name="$component"
 else
     target_repo_name="$component-$module"
 fi
 
-if [ "$clone_target_repo_name" ]; then
+
+echo -ne "Source: $src_repo basedir:$src_basedir branch:$src_branch is using this repository for pot/po files:https://pagure.io/fedora-l10n/$target_repo_name\n" >> "$output_dir/log.txt"
+
+if [ -n "$clone_target_repo_name" ]; then
     if [ -d "$output_dir/$target_repo_name" ]; then
         echo ""
         echo "Error. You chose to clone the target repo,"
@@ -205,10 +200,10 @@ module_dir="$output_dir/$target_repo_name/pot/$version"
 
 
 # Confert all .adoc files to .pot
-pushd "$tmp_english_src/$src_basedir/modules/$module" > /dev/null
+pushd "$tmp_english_src/$src_basedir/modules/$module" > /dev/null || exit
 
 for adoc_file in $(find . -name '*.adoc'); do
-    pot_file="$module_dir/$(dirname $adoc_file)/$(basename -s .adoc $adoc_file).pot"
+    pot_file=$module_dir/$(dirname "$adoc_file")/$(basename -s .adoc "$adoc_file").pot
 
     # generate new POT files
 
@@ -231,10 +226,10 @@ for adoc_file in $(find . -name '*.adoc'); do
 
         for lang in $(ls "$output_dir/$target_repo_name/po"); do
 
-            po_file="$output_dir/$target_repo_name/po/$lang/$version/$(dirname $adoc_file)/$(basename -s .adoc $adoc_file).po"
+            po_file="$output_dir/$target_repo_name/po/$lang/$version/$(dirname "$adoc_file")/$(basename -s .adoc "$adoc_file").po"
 
             # po4a-updatepo would be angry otherwise
-            sed -i 's/Content-Type: text\/plain; charset=CHARSET/Content-Type: text\/plain; charset=UTF-8/g' $po_file
+            sed -i 's/Content-Type: text\/plain; charset=CHARSET/Content-Type: text\/plain; charset=UTF-8/g' "$po_file"
 
             if ! po4a-updatepo \
                         --format asciidoc \
@@ -251,13 +246,13 @@ for adoc_file in $(find . -name '*.adoc'); do
     fi
 done
 
-popd > /dev/null
+popd > /dev/null || exit
 
 
 # Convert the antora.yml to antora.yml.pot
 # if this is the main module
-if [ $module = "ROOT" ]; then
-    pushd "$tmp_english_src/$src_basedir" > /dev/null
+if [ "$module" = "ROOT" ]; then
+    pushd "$tmp_english_src/$src_basedir" > /dev/null || exit
     if ! po4a-gettextize \
                 --format asciidoc \
                 --option debug split_attributelist \
@@ -269,10 +264,8 @@ if [ $module = "ROOT" ]; then
         rm -rf "$tmp_english_src"
         exit 1
     fi
-    popd > /dev/null
+    popd > /dev/null || exit
 fi
 
 
-rm -rf $tmp_english_src
-
-echo -ne "Source: $src_repo basedir:$src_basedir branch:$src_branch is using this repository for pot/po files:https://pagure.io/fedora-l10n/$target_repo_name\n" >> "$output_dir/log.txt"
\ No newline at end of file
+rm -rf "$tmp_english_src"
\ No newline at end of file

From 0f6ca4d8163077b3bc3a028ac7e546e32c602bb3 Mon Sep 17 00:00:00 2001
From: Jibec <jean-baptiste@holcroft.fr>
Date: Mar 21 2019 07:12:27 +0000
Subject: [PATCH 10/19] rename readyaml.py -> all-src-to-pot.py


---

diff --git a/all-src-to-pot.py b/all-src-to-pot.py
new file mode 100755
index 0000000..277fb52
--- /dev/null
+++ b/all-src-to-pot.py
@@ -0,0 +1,71 @@
+#!/usr/bin/env python3
+"""Calls `./po-to-src.sh` for all source repos"""
+
+import argparse
+import os
+import urllib.request
+import subprocess
+import shlex
+import yaml
+
+
+def main():
+    """Handle params"""
+    parser = argparse.ArgumentParser(
+        description="Calls `./po-to-src.sh` for all source repos")
+    parser.add_argument("output_dir", help="Output directory")
+    args = parser.parse_args()
+
+    output_dir = args.output_dir
+
+    os.makedirs(output_dir, exist_ok=True)
+
+    output_dir = os.path.abspath(output_dir)
+    parse_yml(output_dir)
+
+def call_podman_and_src_to_po(output_dir, doc):
+    command = "podman run --rm -it -v {o}:/output:z ".format(o=output_dir)
+    command += "-v {c}/src-to-pot.sh:/scripts/src-to-pot.sh:z ".format(c=os.getcwd())
+    command += "asamalik/fedora-docs-translations /scripts/src-to-pot.sh {d}".format(d=doc)
+    print(command)
+    args = shlex.split(command)
+    subprocess.run(args, check=True)
+
+
+def parse_yml(output_dir):
+    """List repositories to convert to pot from antora yaml file"""
+
+    # download site.yml
+    urllib.request.urlretrieve(
+        "https://pagure.io/fedora-docs/docs-fp-o/raw/master/f/site.yml", "site.yml"
+    )
+
+    # Read site.yml
+    with open("site.yml", 'r') as stream:
+        data_loaded = yaml.load(stream)
+
+    # Parse site.yml
+    for source in data_loaded['content']['sources']:
+        url = source['url']
+
+        if 'start_path' in source:
+            src_basedir = source['start_path']
+            doc = "--clone-target-repo --src-basedir \"{bd}\" {url} /output".format(
+                bd=src_basedir, url=url)
+
+        elif 'branches' in source:
+            for branch in source['branches']:
+                src_branch = branch
+                doc = "--clone-target-repo --src-branch \"{br}\" {url} /output".format(
+                    br=src_branch, url=url)
+        else:
+            doc = "--clone-target-repo {url} /output".format(url=url)
+
+        call_podman_and_src_to_po(output_dir, doc)
+
+    # Remove site.yml
+    os.remove("site.yml")
+
+
+if __name__ == '__main__':
+    main()
diff --git a/readyaml.py b/readyaml.py
deleted file mode 100755
index 277fb52..0000000
--- a/readyaml.py
+++ /dev/null
@@ -1,71 +0,0 @@
-#!/usr/bin/env python3
-"""Calls `./po-to-src.sh` for all source repos"""
-
-import argparse
-import os
-import urllib.request
-import subprocess
-import shlex
-import yaml
-
-
-def main():
-    """Handle params"""
-    parser = argparse.ArgumentParser(
-        description="Calls `./po-to-src.sh` for all source repos")
-    parser.add_argument("output_dir", help="Output directory")
-    args = parser.parse_args()
-
-    output_dir = args.output_dir
-
-    os.makedirs(output_dir, exist_ok=True)
-
-    output_dir = os.path.abspath(output_dir)
-    parse_yml(output_dir)
-
-def call_podman_and_src_to_po(output_dir, doc):
-    command = "podman run --rm -it -v {o}:/output:z ".format(o=output_dir)
-    command += "-v {c}/src-to-pot.sh:/scripts/src-to-pot.sh:z ".format(c=os.getcwd())
-    command += "asamalik/fedora-docs-translations /scripts/src-to-pot.sh {d}".format(d=doc)
-    print(command)
-    args = shlex.split(command)
-    subprocess.run(args, check=True)
-
-
-def parse_yml(output_dir):
-    """List repositories to convert to pot from antora yaml file"""
-
-    # download site.yml
-    urllib.request.urlretrieve(
-        "https://pagure.io/fedora-docs/docs-fp-o/raw/master/f/site.yml", "site.yml"
-    )
-
-    # Read site.yml
-    with open("site.yml", 'r') as stream:
-        data_loaded = yaml.load(stream)
-
-    # Parse site.yml
-    for source in data_loaded['content']['sources']:
-        url = source['url']
-
-        if 'start_path' in source:
-            src_basedir = source['start_path']
-            doc = "--clone-target-repo --src-basedir \"{bd}\" {url} /output".format(
-                bd=src_basedir, url=url)
-
-        elif 'branches' in source:
-            for branch in source['branches']:
-                src_branch = branch
-                doc = "--clone-target-repo --src-branch \"{br}\" {url} /output".format(
-                    br=src_branch, url=url)
-        else:
-            doc = "--clone-target-repo {url} /output".format(url=url)
-
-        call_podman_and_src_to_po(output_dir, doc)
-
-    # Remove site.yml
-    os.remove("site.yml")
-
-
-if __name__ == '__main__':
-    main()

From ad0ad3c932ff3660dc8585456d9ee9224df252b0 Mon Sep 17 00:00:00 2001
From: Jibec <jean-baptiste@holcroft.fr>
Date: Mar 22 2019 20:22:36 +0000
Subject: [PATCH 11/19] don't crash if folder exists


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index 436173c..bc052f1 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -168,33 +168,47 @@ fi
 
 echo -ne "Source: $src_repo basedir:$src_basedir branch:$src_branch is using this repository for pot/po files:https://pagure.io/fedora-l10n/$target_repo_name\n" >> "$output_dir/log.txt"
 
-if [ -n "$clone_target_repo_name" ]; then
-    if [ -d "$output_dir/$target_repo_name" ]; then
-        echo ""
-        echo "Error. You chose to clone the target repo,"
-        echo "but the directory '$target_repo_name' already exist"
-        echo "under '$output_dir'."
-        echo ""
-        echo "Either delete it, or run this command without"
-        echo "the --clone-target-repo option"
+get_url="https://pagure.io/fedora-l10n/$target_repo_name.git"
+push_url="ssh://git@pagure.io/fedora-l10n/$target_repo_name.git"
+
+if [ -d "$output_dir/$target_repo_name" ]; then
+    pushd "$output_dir/$target_repo_name"
+    echo "$output_dir/$target_repo_name"
+    push_url_current=$(git config --get remote.origin.pushurl)
+    get_url_current=$(git remote get-url origin)
+    popd
+
+    if [ "$get_url" != "$get_url_current" ] ; then
+        echo "Git repository already exists"
+        echo "But the fetch remote url doesn't match $get_url"
+        echo "Current value is: $get_url_current"
         rm -rf "$tmp_english_src"
         exit 1
     fi
 
-    # if I run this in a container that doesn't have push permissions, I need to be able to clone it
-    # while still configuring the right URL for push later
-    if ! git clone \
-                --config "remote.origin.pushurl=ssh://git@pagure.io/fedora-l10n/$target_repo_name.git" \
-                "https://pagure.io/fedora-l10n/$target_repo_name.git" "$output_dir/$target_repo_name" ; then
-        echo ""
-        echo "Error cloning the target repository."
-        echo "It might not exist. It should be here:"
-        echo "https://pagure.io/fedora-l10n/$target_repo_name"
+    if [ "$push_url" != "$push_url_current" ] ; then
+        echo "Git repository already exists"
+        echo "But the push remote url doesn't match $push_url"
+        echo "Current value is: $push_url_current"
         rm -rf "$tmp_english_src"
         exit 1
     fi
+
+    pushd "$output_dir/$target_repo_name"
+    git pull
+    popd
+
+# if I run this in a container that doesn't have push permissions, I need to be able to clone it
+# while still configuring the right URL for push later
+elif ! git clone \
+    --config "remote.origin.pushurl=$push_url" "$get_url" "$output_dir/$target_repo_name" ; then
+    echo ""
+    echo "Error cloning the target repository."
+    echo "It might not exist. It should be here:"
+    echo "https://pagure.io/fedora-l10n/$target_repo_name"
+    rm -rf "$tmp_english_src"
+    exit 1
 fi
-    
 
 module_dir="$output_dir/$target_repo_name/pot/$version"
 

From c202701758a05f98241eedec25f8a8de7170a08e Mon Sep 17 00:00:00 2001
From: Jibec <jean-baptiste@holcroft.fr>
Date: Mar 22 2019 20:33:07 +0000
Subject: [PATCH 12/19] skip if po doesn't exist for this lang


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index bc052f1..2759ed8 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -242,6 +242,14 @@ for adoc_file in $(find . -name '*.adoc'); do
 
             po_file="$output_dir/$target_repo_name/po/$lang/$version/$(dirname "$adoc_file")/$(basename -s .adoc "$adoc_file").po"
 
+            # before the translation platform sends it, the language may not
+            # exists, most of the time because the branch exists in EN
+            # but not for the target language
+            if [ ! -e "$po_file" ] ; then
+                echo "missing po file: $po_file"
+                break
+            fi
+
             # po4a-updatepo would be angry otherwise
             sed -i 's/Content-Type: text\/plain; charset=CHARSET/Content-Type: text\/plain; charset=UTF-8/g' "$po_file"
 

From 824add543524c47c4808dea407794b6e3fe9886d Mon Sep 17 00:00:00 2001
From: Jibec <jean-baptiste@holcroft.fr>
Date: Mar 22 2019 20:34:28 +0000
Subject: [PATCH 13/19] make pushd/popd quiet


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index 2759ed8..7d97a6e 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -172,11 +172,11 @@ get_url="https://pagure.io/fedora-l10n/$target_repo_name.git"
 push_url="ssh://git@pagure.io/fedora-l10n/$target_repo_name.git"
 
 if [ -d "$output_dir/$target_repo_name" ]; then
-    pushd "$output_dir/$target_repo_name"
+    pushd "$output_dir/$target_repo_name" > /dev/null || exit
     echo "$output_dir/$target_repo_name"
     push_url_current=$(git config --get remote.origin.pushurl)
     get_url_current=$(git remote get-url origin)
-    popd
+    popd > /dev/null || exit
 
     if [ "$get_url" != "$get_url_current" ] ; then
         echo "Git repository already exists"
@@ -194,9 +194,9 @@ if [ -d "$output_dir/$target_repo_name" ]; then
         exit 1
     fi
 
-    pushd "$output_dir/$target_repo_name"
+    pushd "$output_dir/$target_repo_name" > /dev/null || exit
     git pull
-    popd
+    popd > /dev/null || exit
 
 # if I run this in a container that doesn't have push permissions, I need to be able to clone it
 # while still configuring the right URL for push later

From 2a1b76c6767b5da1d06ccd496b3c291311acfdfe Mon Sep 17 00:00:00 2001
From: Jibec <jean-baptiste@holcroft.fr>
Date: Apr 07 2019 12:28:56 +0000
Subject: [PATCH 14/19] move checks to prepare temporary clonage removal


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index 7d97a6e..a890717 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -97,25 +97,31 @@ if ! git clone -b $src_branch "$src_repo" "$tmp_english_src" ; then
     exit 1
 fi
 
-# Make sure the basedir exists
-if [ ! -d "$tmp_english_src/$src_basedir" ]; then
-    echo ""
-    echo "Error. The specified basedir doesn't exist in the git repository."
-    rm -rf "$tmp_english_src"
-    exit 1
-fi
+check_dir() (
+    local basedir=$1
 
-# Make sure it's an Antora source
-if [ ! -f "$tmp_english_src/$src_basedir/antora.yml" ]; then
-    echo ""
-    echo "Error. There is no Antora source. (no antora.yml found)"
-    rm -rf "$tmp_english_src"
-    exit 1
-fi
+    # Make sure the basedir exists
+    if [ ! -d "$basedir" ]; then
+        echo ""
+        echo "Error. The specified basedir doesn't exist in the git repository."
+        rm -rf "$tmp_english_src"
+        exit 1
+    fi
+
+    # Make sure it's an Antora source
+    if [ ! -f "$basedir/antora.yml" ]; then
+        echo ""
+        echo "Error. There is no Antora source. (no antora.yml found)"
+        rm -rf "$tmp_english_src"
+        exit 1
+    fi
+)
+basedir="$tmp_english_src/$src_basedir"
 
+check_dir "$basedir"
 
 
-pushd "$tmp_english_src/$src_basedir" > /dev/null || exit
+pushd "$basedir" > /dev/null || exit
 
 # Get component name from the antora.yml
 component=$(sed -n 's/^name: *\"*\([[:alnum:]_-]*\).*/\1/p' antora.yml)
@@ -128,6 +134,7 @@ version=$(sed -n 's/^version: *\"*\([[:alnum:]_-]*\).*/\1/p' antora.yml)
 #   2) the user specified it using --module MODULE and it exists
 # In case there are multiple modules under ./modules/
 # and the user hasn't specified one, throw an error.
+# TODO: use antora.yml file if existing, if not, site.yml
 if [ ! $(ls -1 ./modules | wc -l) = 1 ] && [ -z "$module" ]; then
     echo ""
     echo "Error. This repository contains multiple antora modules,"
@@ -214,7 +221,7 @@ module_dir="$output_dir/$target_repo_name/pot/$version"
 
 
 # Confert all .adoc files to .pot
-pushd "$tmp_english_src/$src_basedir/modules/$module" > /dev/null || exit
+pushd "$basedir/modules/$module" > /dev/null || exit
 
 for adoc_file in $(find . -name '*.adoc'); do
     pot_file=$module_dir/$(dirname "$adoc_file")/$(basename -s .adoc "$adoc_file").pot
@@ -274,7 +281,7 @@ popd > /dev/null || exit
 # Convert the antora.yml to antora.yml.pot
 # if this is the main module
 if [ "$module" = "ROOT" ]; then
-    pushd "$tmp_english_src/$src_basedir" > /dev/null || exit
+    pushd "$basedir" > /dev/null || exit
     if ! po4a-gettextize \
                 --format asciidoc \
                 --option debug split_attributelist \

From 886c38651f0894950b2818043a673c0303e6c741 Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Apr 07 2019 21:10:28 +0000
Subject: [PATCH 15/19] remove temporary clone


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index a890717..01b8cce 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-
+set -x
 usage () {
     echo "Converting an Antora source repo into a POT repo for transations"
     echo ""
@@ -88,14 +88,14 @@ if [ -z "$src_basedir" ]; then
     src_basedir=""
 fi
 
-tmp_english_src=$(mktemp -d)
+# tmp_english_src=$(mktemp -d)
 
-if ! git clone -b $src_branch "$src_repo" "$tmp_english_src" ; then
-    echo ""
-    echo "Error cloning the specified git repository."
-    rm -rf "$tmp_english_src"
-    exit 1
-fi
+# if ! git clone -b $src_branch "$src_repo" "$tmp_english_src" ; then
+#     echo ""
+#     echo "Error cloning the specified git repository."
+#     rm -rf "$tmp_english_src"
+#     exit 1
+# fi
 
 check_dir() (
     local basedir=$1
@@ -104,7 +104,7 @@ check_dir() (
     if [ ! -d "$basedir" ]; then
         echo ""
         echo "Error. The specified basedir doesn't exist in the git repository."
-        rm -rf "$tmp_english_src"
+        # rm -rf "$tmp_english_src"
         exit 1
     fi
 
@@ -112,59 +112,60 @@ check_dir() (
     if [ ! -f "$basedir/antora.yml" ]; then
         echo ""
         echo "Error. There is no Antora source. (no antora.yml found)"
-        rm -rf "$tmp_english_src"
+        # rm -rf "$tmp_english_src"
         exit 1
     fi
+
+    # check if module dir exists
+    if [ ! -d "$basedir/modules/$module" ]; then
+	    echo ""
+	    echo "Error. The module you have specified doesn't exist."
+	    echo ""
+	    echo "There are:"
+	    ls -1 ./modules
+	    echo ""
+	    echo "Tip: You don't have to specify a module if there is just one"
+	    # rm -rf "$tmp_english_src"
+	    exit 1
+	fi
 )
-basedir="$tmp_english_src/$src_basedir"
+#basedir="$tmp_english_src/$src_basedir"
+
+#check_dir "$basedir"
 
-check_dir "$basedir"
 
+tmp_folder=$(mktemp -d)
 
-pushd "$basedir" > /dev/null || exit
+antora_file="$src_repo/raw/$src_branch/f/$src_basedir/antora.yml"
+# wget -q "$antora_file" -O "$tmp_folder/antora.yml"
+curl --silent -o "$tmp_folder/antora.yml" "$antora_file"
+
+site_file="$src_repo/raw/$src_branch/f/$src_basedir/site.yml"
+curl --silent -o "$tmp_folder/site.yml" "$site_file"
 
 # Get component name from the antora.yml
-component=$(sed -n 's/^name: *\"*\([[:alnum:]_-]*\).*/\1/p' antora.yml)
+component=$(sed -n 's/^name: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/antora.yml")
 
 # Get version name from the antora.yml
-version=$(sed -n 's/^version: *\"*\([[:alnum:]_-]*\).*/\1/p' antora.yml)
+version=$(sed -n 's/^version: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/antora.yml")
+
 
 # I also need a module name. Two ways how to get it:
-#   1) exactly one module exists under ./module/
+#   1) use the module from site.yml if existing
+#   2) use the module from antora.yml
 #   2) the user specified it using --module MODULE and it exists
 # In case there are multiple modules under ./modules/
 # and the user hasn't specified one, throw an error.
-# TODO: use antora.yml file if existing, if not, site.yml
-if [ ! $(ls -1 ./modules | wc -l) = 1 ] && [ -z "$module" ]; then
-    echo ""
-    echo "Error. This repository contains multiple antora modules,"
-    echo "and the script doesn't know which one to choose."
-    echo ""
-    echo "There are:"
-    ls -1 ./modules
-    echo ""
-    echo "Choose one and specify it using --module MODULE"
-    rm -rf "$tmp_english_src"
-    exit 1
-fi
 
-if [ -z "$module" ]; then
-    module=$(ls ./modules)
-fi
-
-if [ ! -d "modules/$module" ]; then
-    echo ""
-    echo "Error. The module you have specified doesn't exist."
-    echo ""
-    echo "There are:"
-    ls -1 ./modules
-    echo ""
-    echo "Tip: You don't have to specify a module if there is just one"
-    rm -rf "$tmp_english_src"
-    exit 1
+if [ -z "$module" ] || [ "$module" = "" ]; then
+    if [ -s "$tmp_folder/site.yml" ] ; then
+        module=$(sed -n 's/.*start_page: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/site.yml")
+    else
+        module=$(sed -n 's/^start_page: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/antora.yml")
+    fi
 fi
 
-popd > /dev/null || exit
+rm -rf "$tmp_folder"
 
 if [ "$module" = "ROOT" ]; then
     target_repo_name="$component"
@@ -217,6 +218,8 @@ elif ! git clone \
     exit 1
 fi
 
+check_dir "$output_dir/$target_repo_name"
+
 module_dir="$output_dir/$target_repo_name/pot/$version"
 
 

From d4bf760dd0ba4286a8b7fa53e70dcd08ce61cded Mon Sep 17 00:00:00 2001
From: Jean-Baptiste Holcroft <jean-baptiste@holcroft.fr>
Date: Apr 07 2019 21:11:07 +0000
Subject: [PATCH 16/19] use Loader=yaml.SafeLoader


---

diff --git a/all-src-to-pot.py b/all-src-to-pot.py
index 277fb52..aabcaab 100755
--- a/all-src-to-pot.py
+++ b/all-src-to-pot.py
@@ -42,7 +42,7 @@ def parse_yml(output_dir):
 
     # Read site.yml
     with open("site.yml", 'r') as stream:
-        data_loaded = yaml.load(stream)
+        data_loaded = yaml.load(stream, Loader=yaml.SafeLoader)
 
     # Parse site.yml
     for source in data_loaded['content']['sources']:

From 6f52e40001234839ba7c9ca72a4a35f3de835055 Mon Sep 17 00:00:00 2001
From: Jibec <jean-baptiste@holcroft.fr>
Date: Apr 10 2019 16:31:40 +0000
Subject: [PATCH 17/19] store source content


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index 01b8cce..15f4961 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -79,6 +79,8 @@ fi
 
 # TARGET_DIR need to exist
 mkdir -p "$output_dir"
+source_dir="$output_dir/_sources"
+mkdir -p "$source_dir"
 
 if [ -z "$src_branch" ]; then
     src_branch="master"
@@ -89,13 +91,18 @@ if [ -z "$src_basedir" ]; then
 fi
 
 # tmp_english_src=$(mktemp -d)
+tmp_english_src=$(echo "$src_repo-$src_repo" | sed "s/[\/:]/-/g")
 
-# if ! git clone -b $src_branch "$src_repo" "$tmp_english_src" ; then
-#     echo ""
-#     echo "Error cloning the specified git repository."
-#     rm -rf "$tmp_english_src"
-#     exit 1
-# fi
+if [ -d "$source_dir/$tmp_english_src" ]; then
+    pushd "$source_dir/$tmp_english_src" > /dev/null || exit
+    git pull
+    popd > /dev/null || exit
+elif ! git clone -b $src_branch "$src_repo" "$source_dir/$tmp_english_src" ; then
+    echo ""
+    echo "Error cloning the specified git repository."
+    rm -rf "$tmp_english_src"
+    exit 1
+fi
 
 check_dir() (
     local basedir=$1
@@ -104,7 +111,6 @@ check_dir() (
     if [ ! -d "$basedir" ]; then
         echo ""
         echo "Error. The specified basedir doesn't exist in the git repository."
-        # rm -rf "$tmp_english_src"
         exit 1
     fi
 
@@ -112,7 +118,6 @@ check_dir() (
     if [ ! -f "$basedir/antora.yml" ]; then
         echo ""
         echo "Error. There is no Antora source. (no antora.yml found)"
-        # rm -rf "$tmp_english_src"
         exit 1
     fi
 
@@ -125,29 +130,16 @@ check_dir() (
 	    ls -1 ./modules
 	    echo ""
 	    echo "Tip: You don't have to specify a module if there is just one"
-	    # rm -rf "$tmp_english_src"
 	    exit 1
 	fi
 )
-#basedir="$tmp_english_src/$src_basedir"
-
-#check_dir "$basedir"
-
-
-tmp_folder=$(mktemp -d)
-
-antora_file="$src_repo/raw/$src_branch/f/$src_basedir/antora.yml"
-# wget -q "$antora_file" -O "$tmp_folder/antora.yml"
-curl --silent -o "$tmp_folder/antora.yml" "$antora_file"
-
-site_file="$src_repo/raw/$src_branch/f/$src_basedir/site.yml"
-curl --silent -o "$tmp_folder/site.yml" "$site_file"
+basedir="$source_dir/$tmp_english_src/$src_basedir"
 
 # Get component name from the antora.yml
-component=$(sed -n 's/^name: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/antora.yml")
+component=$(sed -n 's/^name: *\"*\([[:alnum:]_-]*\).*/\1/p' "$basedir/antora.yml")
 
 # Get version name from the antora.yml
-version=$(sed -n 's/^version: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/antora.yml")
+version=$(sed -n 's/^version: *\"*\([[:alnum:]_-]*\).*/\1/p' "$basedir/antora.yml")
 
 
 # I also need a module name. Two ways how to get it:
@@ -158,14 +150,31 @@ version=$(sed -n 's/^version: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/antora
 # and the user hasn't specified one, throw an error.
 
 if [ -z "$module" ] || [ "$module" = "" ]; then
-    if [ -s "$tmp_folder/site.yml" ] ; then
-        module=$(sed -n 's/.*start_page: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/site.yml")
-    else
-        module=$(sed -n 's/^start_page: *\"*\([[:alnum:]_-]*\).*/\1/p' "$tmp_folder/antora.yml")
+    if [ -s "$basedir/site.yml" ] ; then
+        module=$(sed -n 's/.*start_page: *\"*\([[:alnum:]_-]*\).*/\1/p' "$basedir/site.yml")
+        module=$(ls $basedir/modules)
+    fi
+
+    # documentation-contributors-guide site.yml contains a site.yml but multiple repo
+    if [[ "$module" =~ $'\r' ]] || [[ "$module" =~ $'\n' ]]; then
+        module=""
+    fi
+fi
+
+if [ -z "$module" ] || [ "$module" = "" ]; then
+    module=$(sed -n 's/^start_page: *\"*\([[:alnum:]_-]*\).*/\1/p' "$basedir/antora.yml")
+    if [ "$module" = "" ]; then
+        # TODO: https://pagure.io/fedora-docs/docs-fp-o/ in pages/homepage
+        module=$(sed -n 's/^start-page: *\"*\([[:alnum:]_-]*\).*/\1/p' "$basedir/antora.yml")
+    fi
+
+    if [ "$module" = "" ]; then
+        # TODO: https://pagure.io/fedora-docs/release-docs-home/tree/f26
+        module="ROOT"
     fi
 fi
 
-rm -rf "$tmp_folder"
+check_dir "$basedir"
 
 if [ "$module" = "ROOT" ]; then
     target_repo_name="$component"
@@ -190,7 +199,6 @@ if [ -d "$output_dir/$target_repo_name" ]; then
         echo "Git repository already exists"
         echo "But the fetch remote url doesn't match $get_url"
         echo "Current value is: $get_url_current"
-        rm -rf "$tmp_english_src"
         exit 1
     fi
 
@@ -198,7 +206,6 @@ if [ -d "$output_dir/$target_repo_name" ]; then
         echo "Git repository already exists"
         echo "But the push remote url doesn't match $push_url"
         echo "Current value is: $push_url_current"
-        rm -rf "$tmp_english_src"
         exit 1
     fi
 
@@ -214,12 +221,9 @@ elif ! git clone \
     echo "Error cloning the target repository."
     echo "It might not exist. It should be here:"
     echo "https://pagure.io/fedora-l10n/$target_repo_name"
-    rm -rf "$tmp_english_src"
     exit 1
 fi
 
-check_dir "$output_dir/$target_repo_name"
-
 module_dir="$output_dir/$target_repo_name/pot/$version"
 
 
@@ -233,14 +237,12 @@ for adoc_file in $(find . -name '*.adoc'); do
 
     if ! po4a-gettextize \
                 --format asciidoc \
-                --option debug split_attributelist \
                 --master "$adoc_file" \
                 --master-charset "UTF-8" \
                 --localized-charset "UTF-8" \
                 --po "$pot_file" ; then
         echo ""
         echo "Error converting an adoc file: $adoc_file"
-        rm -rf "$tmp_english_src"
         exit 1
     fi
 
@@ -265,13 +267,11 @@ for adoc_file in $(find . -name '*.adoc'); do
 
             if ! po4a-updatepo \
                         --format asciidoc \
-                        --option debug split_attributelist \
                         --master "$adoc_file" \
                         --master-charset "UTF-8" \
                         --po "$po_file" ; then
                 echo ""
                 echo "Error updating $lang PO file for: $adoc_file"
-                #rm -rf "$tmp_english_src"
                 #exit 1
             fi
         done
@@ -286,18 +286,13 @@ popd > /dev/null || exit
 if [ "$module" = "ROOT" ]; then
     pushd "$basedir" > /dev/null || exit
     if ! po4a-gettextize \
-                --format asciidoc \
-                --option debug split_attributelist \
+                --format yaml \
                 --master "antora.yml" \
                 --master-charset "UTF-8" \
                 --po "$module_dir/antora.yml.pot" ; then
         echo ""
         echo "Error converting the antora.yml file"
-        rm -rf "$tmp_english_src"
         exit 1
     fi
     popd > /dev/null || exit
 fi
-
-
-rm -rf "$tmp_english_src"
\ No newline at end of file

From 00ae545cfc52ff8f3cef67e5a6349a8dd7eeef16 Mon Sep 17 00:00:00 2001
From: Jibec <jean-baptiste@holcroft.fr>
Date: Apr 10 2019 16:37:04 +0000
Subject: [PATCH 18/19] accept filenames with spaces


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index 15f4961..8e1c736 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -230,7 +230,8 @@ module_dir="$output_dir/$target_repo_name/pot/$version"
 # Confert all .adoc files to .pot
 pushd "$basedir/modules/$module" > /dev/null || exit
 
-for adoc_file in $(find . -name '*.adoc'); do
+while IFS= read -r -d '' adoc_file
+do
     pot_file=$module_dir/$(dirname "$adoc_file")/$(basename -s .adoc "$adoc_file").pot
 
     # generate new POT files
@@ -276,7 +277,7 @@ for adoc_file in $(find . -name '*.adoc'); do
             fi
         done
     fi
-done
+done <   <(find . -name '*.adoc' -print0)
 
 popd > /dev/null || exit
 

From a748ad84e2f7da341024edf36540457d31ae7357 Mon Sep 17 00:00:00 2001
From: Jibec <jean-baptiste@holcroft.fr>
Date: Apr 10 2019 20:19:08 +0000
Subject: [PATCH 19/19] allow spaces in po files


---

diff --git a/src-to-pot.sh b/src-to-pot.sh
index 8e1c736..4f732ec 100755
--- a/src-to-pot.sh
+++ b/src-to-pot.sh
@@ -1,5 +1,5 @@
 #!/bin/bash
-set -x
+#set -x
 usage () {
     echo "Converting an Antora source repo into a POT repo for transations"
     echo ""
@@ -190,7 +190,7 @@ push_url="ssh://git@pagure.io/fedora-l10n/$target_repo_name.git"
 
 if [ -d "$output_dir/$target_repo_name" ]; then
     pushd "$output_dir/$target_repo_name" > /dev/null || exit
-    echo "$output_dir/$target_repo_name"
+
     push_url_current=$(git config --get remote.origin.pushurl)
     get_url_current=$(git remote get-url origin)
     popd > /dev/null || exit
@@ -251,8 +251,9 @@ do
 
     if [ -d "$output_dir/$target_repo_name/po" ] ; then
 
-        for lang in $(ls "$output_dir/$target_repo_name/po"); do
-
+        for lang in "$output_dir/$target_repo_name/po"/*
+        do
+            [[ -d "$output_dir/$target_repo_name/po/$lang" ]] || break  # handle the case of no *.wav files
             po_file="$output_dir/$target_repo_name/po/$lang/$version/$(dirname "$adoc_file")/$(basename -s .adoc "$adoc_file").po"
 
             # before the translation platform sends it, the language may not

