Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove dependeny on frontmatter #416

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +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
python-frontmatter==1.0.0
22 changes: 17 additions & 5 deletions utils/transifex_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
import glob
import frontmatter
import re

TX_ORGANIZATION = "opengisch"
TX_PROJECT = "qfield-documentation"
Expand All @@ -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])}.<lang>.md\n")
f.write(
f"file_filter = {''.join(relative_path.split('.')[:-2])}.<lang>.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")
Expand Down
Loading