mirror of
https://forge.chapril.org/tykayn/orgmode-to-gemini-blog
synced 2025-06-20 09:04:42 +02:00
up paths
This commit is contained in:
parent
895996cf6b
commit
8daf1e23e4
2055 changed files with 119377 additions and 31850 deletions
51
utils.py
51
utils.py
|
@ -13,9 +13,9 @@ org_roam_dir: str = '/home/tykayn/Nextcloud/textes/orgmode/org-roam/'
|
|||
# Trouver l'identifiant OrgROAM
|
||||
pattern_roam_id_search = r':ID:(?:\s+)?([a-zA-Z0-9-]+)'
|
||||
# Expression régulière pour extraire la date et le slug du nom de fichier org
|
||||
regex = r"^(\d{14})(-[a-zA-Z0-9_-]+)\.gmi$"
|
||||
regex = r"^([a-zA-Z0-9_-]+)\_\_(-[a-zA-Z0-9_-]+)\.org$"
|
||||
# Recherche de date de création du fichier org-roam dans un article gemini
|
||||
regex_orgroam = r"^(\d{14})_([a-zA-Z0-9_-]+)\.gmi$"
|
||||
regex_orgroam = regex
|
||||
|
||||
# show_logs=True
|
||||
show_logs = global_config["show_logs"]
|
||||
|
@ -24,7 +24,8 @@ show_logs = global_config["show_logs"]
|
|||
def mylog(*content):
|
||||
"""Fonction qui imprime tous les arguments passés selon le niveau de debug souhaité."""
|
||||
if show_logs:
|
||||
print(content)
|
||||
for c in content:
|
||||
print(' ',c)
|
||||
|
||||
|
||||
def trouver_nom_article(fichier_org, blog_name, format="html"):
|
||||
|
@ -63,43 +64,33 @@ def trouver_nom_article(fichier_org, blog_name, format="html"):
|
|||
return nom_article.replace(blog_name + '_', '').replace('_', ' ')
|
||||
|
||||
|
||||
def find_year_and_slug(fichier):
|
||||
def find_year_and_slug_on_filename(fichier):
|
||||
fichier = fichier.replace('..', '.')
|
||||
mylog(f" ------------ build_indexes: find in {fichier} -------------")
|
||||
slug = fichier.replace('.gmi', '').replace('.org', '')
|
||||
# mylog(f" ------------ find_year_and_slug in {fichier} -------------")
|
||||
slug = ''
|
||||
annee = '2024'
|
||||
date_str = '2024-00-00'
|
||||
date = '2024-00-00'
|
||||
match = re.match(regex_orgroam, fichier)
|
||||
boom = fichier.split('__')
|
||||
# print(boom)
|
||||
|
||||
if match:
|
||||
date_str = match.group(1)
|
||||
if boom :
|
||||
date_str = boom[0]
|
||||
annee = date_str[:4]
|
||||
slug = match.group(2)
|
||||
slug = boom[1].replace('.org', '')
|
||||
# date = datetime.strptime(date_str, "%Y%m%dT%H%M%S")
|
||||
|
||||
match = re.match(regex, fichier)
|
||||
if match:
|
||||
date_str = match.group(1)
|
||||
# Convertir la date en objet datetime
|
||||
if "-" in date_str:
|
||||
date = datetime.strptime(date_str, "%Y-%m-%d")
|
||||
else:
|
||||
date = datetime.strptime(date_str, "%Y%m%d%H%M%S")
|
||||
date_string_replaced = str(date).replace(' 00:00:00', '')
|
||||
slug = slug.replace(date_string_replaced, '')
|
||||
slug = enlever_premier_tiret_ou_underscore(slug)
|
||||
slug = enlever_premier_tiret_ou_underscore(slug)
|
||||
|
||||
annee = str(date.year).replace(' 00:00:00', '')
|
||||
# else:
|
||||
# print('ERREUR aucun slug trouvé')
|
||||
|
||||
mylog(f" ------------ build_indexes: ")
|
||||
mylog(f" ------------ build_indexes: Fichier: {fichier}")
|
||||
mylog(f" ------------ build_indexes: année: {annee}")
|
||||
mylog(f" ------------ build_indexes: str(date): {str(date)}")
|
||||
mylog(f" ------------ build_indexes: slug: {slug}")
|
||||
mylog(f" ------------ build_indexes: chemin: {annee}/{slug}/")
|
||||
return [date_str, annee, slug]
|
||||
# mylog(f" find_year_and_slug : Fichier: {fichier}")
|
||||
# mylog(f" find_year_and_slug : année: {annee}")
|
||||
# mylog(f" find_year_and_slug : str(date): {str(date)}")
|
||||
# mylog(f" find_year_and_slug : slug: {slug}")
|
||||
mylog(f" find_year_and_slug : chemin: {annee}/{slug}/")
|
||||
return [date_str, annee, slug]
|
||||
return [date_str, annee, fichier.replace(' ', '-').replace('.org', '')]
|
||||
|
||||
|
||||
def enlever_premier_tiret_ou_underscore(chaîne):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue