inicio de links en python

This commit is contained in:
sejo 2021-06-15 23:37:46 -05:00
parent 9fc2fc8c73
commit 4cafced81a
1 changed files with 30 additions and 0 deletions

30
links.py Normal file
View File

@ -0,0 +1,30 @@
import re
import os
def filename2Wikilink( s ):
s = s.replace('_',' ')
s = s.replace('.gmo','')
return '{'+s+'}'
os.chdir('src/')
matches = {}
for filename in os.listdir():
if filename.endswith('.gmo') and filename != 'pages.gmo' and filename != 'index.gmo':
wikilink=filename2Wikilink(filename)
with open(filename) as f:
for line in f:
m=re.search("\{.+\}",line)
if m:
# print(m)
match = m.group(0)
if match not in matches:
matches[match] = set()
matches[match].add(wikilink)
for k,v in matches.items():
print(k)
print(v)
print('')