| |
@@ -10,24 +10,24 @@
|
| |
|
| |
import yaml
|
| |
|
| |
- COMMIT_CHANGES = 'false'
|
| |
SELECTED_COMPONENT = None
|
| |
|
| |
def main():
|
| |
"""Handle params"""
|
| |
- global COMMIT_CHANGES, SELECTED_COMPONENT
|
| |
+ global SELECTED_COMPONENT
|
| |
|
| |
parser = argparse.ArgumentParser(
|
| |
- description="Calls `./po-to-src.sh` for all source repos")
|
| |
+ description="Calls `./src-to-pot.sh` and `./po-to-src.sh` for all source repos")
|
| |
parser.add_argument("--clone_sources", choices=['true', 'false'], required=True,
|
| |
- help="Should we clone or update source or use cache?")
|
| |
+ help="Should we clone/update sources or use local content?")
|
| |
parser.add_argument("--commit_l10n", choices=['true', 'false'], required=True,
|
| |
- help="Should we clone or update source or use cache?")
|
| |
+ help="Should we commit changes on l10n repos?")
|
| |
+ parser.add_argument("--commit_tsources", choices=['true', 'false'], required=True,
|
| |
+ help="Should we commit translated sources?")
|
| |
parser.add_argument("--component", required=False,
|
| |
- help="Antora component, all if unset")
|
| |
+ help="Antora component to convert, all if unset")
|
| |
args = parser.parse_args()
|
| |
|
| |
- COMMIT_CHANGES = args.commit_l10n
|
| |
SELECTED_COMPONENT = args.component
|
| |
|
| |
source_dir = os.path.dirname(os.path.abspath(__file__)) + "/sources/"
|
| |
@@ -44,6 +44,12 @@
|
| |
clone_translated_source()
|
| |
make_component_lists()
|
| |
|
| |
+ if args.commit_l10n == "true":
|
| |
+ commit_l10n_repos()
|
| |
+
|
| |
+ if args.commit_tsources == "true":
|
| |
+ commit_translated_sources()
|
| |
+
|
| |
def call_src_to_pot(url, branch='master', basedir='/', module="ROOT"):
|
| |
"""Call src-to-ot.sh to convert english source (adoc) content to pot files"""
|
| |
print("call_src_to_pot: "+url +" b:"+ branch +" bd:"+ basedir +" m:"+ module)
|
| |
@@ -56,10 +62,10 @@
|
| |
"""Call po-to-src.sh to convert po files to translated sources (adoc)"""
|
| |
print("call_po_to_src: "+url +" b:"+ branch +" bd:"+ basedir +" m:"+ module)
|
| |
output = os.path.dirname(os.path.abspath(__file__)) + "/translated-sources/"
|
| |
- for lang in ['fr', 'cs', 'ja']:
|
| |
- subprocess.run(['./po-to-src.sh', "--src-branch", branch,
|
| |
- "--src-basedir", basedir, "--module", module, lang, url,
|
| |
- output], check=True)
|
| |
+
|
| |
+ subprocess.run(['./po-to-src.sh', "--src-branch", branch,
|
| |
+ "--src-basedir", basedir, "--module", module, url,
|
| |
+ output], check=True)
|
| |
|
| |
def clone_source(doc_url, branch="master"):
|
| |
"""Clone english sources in sources folder (update content if existing)"""
|
| |
@@ -73,10 +79,11 @@
|
| |
else:
|
| |
subprocess.run(["git", "clone", "-b", branch, doc_url, repo_dir], check=True)
|
| |
|
| |
- def clone_l10n(url):
|
| |
+ def clone_l10n(repo_name):
|
| |
"""Clone localization repos in l10n folder (update content if existing)"""
|
| |
- print("* clone_l10n: " + url)
|
| |
- repo_name = url.rsplit('/', 1)[-1].replace('.git', '')
|
| |
+ print("* clone_l10n: " + repo_name)
|
| |
+
|
| |
+ url = "https://pagure.io/fedora-l10n/" + repo_name
|
| |
repo_dir = os.path.dirname(os.path.abspath(__file__)) + "/l10n/" + repo_name
|
| |
|
| |
if os.path.exists(repo_dir):
|
| |
@@ -98,16 +105,35 @@
|
| |
else:
|
| |
subprocess.run(["git", "clone", url, repo_dir], check=True)
|
| |
|
| |
- def commit_l10n(url):
|
| |
- """Commit and push changes of a localization repo"""
|
| |
- global COMMIT_CHANGES
|
| |
+ def commit_translated_source():
|
| |
+ """Commit translated sources"""
|
| |
+ print("* commit_translated_source")
|
| |
+ repo_dir = os.path.dirname(os.path.abspath(__file__)) + "/translated-sources/"
|
| |
|
| |
- if COMMIT_CHANGES != "true":
|
| |
- return
|
| |
+ subprocess.run(['git', 'add', '.'], check=True, cwd=repo_dir)
|
| |
+
|
| |
+ subprocess.run(["git", "commit", "-m", "automatic update of translated content"],
|
| |
+ check=True, cwd=repo_dir)
|
| |
+
|
| |
+ subprocess.run(['git', 'push'], check=True, cwd=repo_dir)
|
| |
+
|
| |
+
|
| |
+ def commit_l10n_repos():
|
| |
+ """Commit and push changes of localization repositories"""
|
| |
+
|
| |
+ print("* commit_l10n_repos")
|
| |
+ repo_dir = os.path.dirname(os.path.abspath(__file__)) + "/l10n/"
|
| |
+
|
| |
+ # commit each folders of the l10n path
|
| |
+ [commit_l10n(r) for r in next(os.walk(repo_dir))[1]]
|
| |
+
|
| |
+
|
| |
+ def commit_l10n(repo_name):
|
| |
+ """Commit and push changes of a localization repo"""
|
| |
|
| |
- print("* commit_l10n: " + url)
|
| |
+ print("* commit_l10n: " + repo_name)
|
| |
|
| |
- repo_name = url.rsplit('/', 1)[-1].replace('.git', '')
|
| |
+ url = "https://pagure.io/fedora-l10n/" + repo_name
|
| |
repo_dir = os.path.dirname(os.path.abspath(__file__)) + "/l10n/" + repo_name
|
| |
|
| |
subprocess.run(['git', 'add', '.'], check=True, cwd=repo_dir)
|
| |
@@ -177,9 +203,8 @@
|
| |
target_repo_name = component
|
| |
else:
|
| |
target_repo_name = component + "-" + module
|
| |
- clone_l10n("https://pagure.io/fedora-l10n/"+target_repo_name)
|
| |
+ clone_l10n(target_repo_name)
|
| |
call_src_to_pot(url=comp_dir, basedir=basedir, branch=branch, module=module)
|
| |
- commit_l10n("https://pagure.io/fedora-l10n/"+target_repo_name)
|
| |
call_po_to_src(url=comp_dir, basedir=basedir, branch=branch, module=module)
|
| |
|
| |
def make_component_lists():
|
| |