Skip to content

Commit

Permalink
Ajustes
Browse files Browse the repository at this point in the history
  • Loading branch information
michelmetran committed Nov 29, 2023
1 parent f338443 commit 5c64e9d
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions my_script.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
"""
Summary
Michel Metran
29.11.2023
"""

import shutil
Expand Down Expand Up @@ -55,23 +58,31 @@ def convert2md(input_file, output_file):
project_path = Path(__file__).parent
post_path = project_path / 'collections' / '_posts'
assets_path = project_path / 'assets'
#attachments_path = assets_path / 'attachments'

# Check Path
if not post_path.is_dir():
raise Exception(f'{post_path} is not a directory')


for ipynb in list(post_path.rglob('*/*.ipynb')):
# ddd
print(ipynb)
print(ipynb.parent)

# Convert to Markdown
convert2md(input_file=ipynb, output_file=ipynb.parent / f'{ipynb.stem}.md')

# Copy File
shutil.copy2(src=ipynb, dst=assets_path)


if __name__ == '__main__':
print('Helloooooo')
for ipynb in list(post_path.rglob('*/*.ipynb')):
# Pastas
print(f'Arquivo: {ipynb}')
print(f'Pasta do Arquivo: {ipynb.parent}')

# Define Caminho Relativo dos posts pro projeto
relative = ipynb.parent.relative_to(project_path)

# Add relative path in attachments path
out_relative_path = assets_path / relative
out_relative_path.mkdir(exist_ok=True, parents=True)
print(f'Pasta Relativa: {out_relative_path}')

# Convert to Markdown
convert2md(
input_file=ipynb, output_file=ipynb.parent / f'{ipynb.stem}.md'
)

# Copy File
shutil.copy2(src=ipynb, dst=out_relative_path)

0 comments on commit 5c64e9d

Please sign in to comment.