From cdade7089a13e0b5e36b63622d11fa516427ffbb Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Tue, 13 Feb 2024 13:46:40 +0100 Subject: [PATCH 1/3] remove dependeny on frontmatter --- utils/transifex_utils.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/utils/transifex_utils.py b/utils/transifex_utils.py index 8b836ee03..c8ac58aa7 100644 --- a/utils/transifex_utils.py +++ b/utils/transifex_utils.py @@ -1,6 +1,6 @@ import os import glob -import frontmatter +import re TX_ORGANIZATION = "opengisch" TX_PROJECT = "qfield-documentation" @@ -27,12 +27,24 @@ def create_transifex_config(): # Get relative path of file relative_path = os.path.relpath(file, start = root) - tx_slug = frontmatter.load(file).get('tx_slug', None) + tx_slugs = [re.match(r"^tx_slug: +(.*)", line) for line in open(file)] + tx_slugs = [t for t in tx_slugs if t] - if tx_slug: - print(f"Found file with tx_slug defined: {relative_path}, {tx_slug}") + if not tx_slugs: + print(f"No TX slug found for {relative_path}") + + if len(tx_slugs) > 1: + print(f"More than 1 TX slug found for {relative_path}") + + if tx_slugs: + tx_slug = tx_slugs[0].group(1) + print( + f"Found file with tx_slug defined: `{relative_path}`, `{tx_slug}`" + ) f.write(f"[o:{TX_ORGANIZATION}:p:{TX_PROJECT}:r:{tx_slug}]\n") - f.write(f"file_filter = {''.join(relative_path.split('.')[:-2])}..md\n") + f.write( + f"file_filter = {''.join(relative_path.split('.')[:-2])}..md\n" + ) f.write(f"source_file = {relative_path}\n") f.write(f"source_lang = {TX_SOURCE_LANG}\n") f.write(f"type = {TX_TYPE}\n\n") From f9a5f713e5841a531dbbcf6f0925a726d1cc7861 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Tue, 13 Feb 2024 14:08:57 +0100 Subject: [PATCH 2/3] Update requirements.txt --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index cb3d62148..69a67f74c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,3 @@ mkdocs-static-i18n==1.1.1 mkdocs-video==1.5.0 PyGithub==2.1.1 python-dotenv==1.0.0 -python-frontmatter==1.0.0 From 63d299bccb0632507a5adefdc9fb026cb028c151 Mon Sep 17 00:00:00 2001 From: Denis Rouzaud Date: Tue, 13 Feb 2024 14:15:04 +0100 Subject: [PATCH 3/3] remove dotenv too --- requirements.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 69a67f74c..43db87286 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,3 @@ mkdocs-material==9.4.6 mkdocs-static-i18n==1.1.1 mkdocs-video==1.5.0 PyGithub==2.1.1 -python-dotenv==1.0.0