store the files in a provided folder
This commit is contained in:
parent
26119705a6
commit
60a34d2ef5
|
@ -1,11 +1,20 @@
|
||||||
|
import os.path
|
||||||
import markdownify
|
import markdownify
|
||||||
|
|
||||||
|
|
||||||
|
def _build_path(title):
|
||||||
|
ressources_folder = "~/03_documents/ressources/"
|
||||||
|
base_filename = str(title)
|
||||||
|
short_path = os.path.join(ressources_folder, base_filename + ".md")
|
||||||
|
return os.path.expanduser(short_path)
|
||||||
|
|
||||||
|
|
||||||
def write_to_file(article, header):
|
def write_to_file(article, header):
|
||||||
|
file_path = _build_path(article.title)
|
||||||
markdown = markdownify.markdownify(article.html, heading_style='ATX')
|
markdown = markdownify.markdownify(article.html, heading_style='ATX')
|
||||||
with open(str(article.title) + ".md", 'w') as f:
|
with open(file_path, 'w') as f:
|
||||||
f.write(header)
|
f.write(header)
|
||||||
f.write('------')
|
f.write('------')
|
||||||
f.write('\n')
|
f.write('\n')
|
||||||
with open(str(article.title) + ".md", 'a') as f:
|
with open(file_path, 'a') as f:
|
||||||
f.write(markdown)
|
f.write(markdown)
|
||||||
|
|
Loading…
Reference in New Issue