Skip to content

Commit

Permalink
feat: clear metadata directory on each run
Browse files Browse the repository at this point in the history
  • Loading branch information
kmcconnell committed Sep 14, 2024
1 parent 472fd67 commit 79fd6cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
name: Publish Python Package

on:
push:
branches:
- main
release:
types: [created]

jobs:
publish:
Expand All @@ -22,7 +21,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine keyring
pip install setuptools wheel twine
- name: Build package
run: python setup.py sdist bdist_wheel
Expand All @@ -34,7 +33,6 @@ jobs:
run: twine upload --repository-url https://test.pypi.org/legacy/ dist/*

- name: Publish package to PyPI
if: github.ref == 'refs/heads/main'
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
Expand Down
15 changes: 12 additions & 3 deletions Recipyzer/compile_metadata.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import frontmatter
import shutil
import urllib.parse
from collections import defaultdict
import frontmatter

# Base directory for your recipe collection
BASE_DIR = 'recipes'
Expand All @@ -19,6 +20,12 @@ def ensure_dir(directory):
if not os.path.exists(directory):
os.makedirs(directory)

# Function to clear the index directory
def clear_index_directory():
if os.path.exists(METADATA_DIR):
shutil.rmtree(METADATA_DIR)
ensure_dir(METADATA_DIR)

# Function to update metadata files with a table format
def update_metadata(metadata, base_dir, type_):
for key, items in metadata.items():
Expand Down Expand Up @@ -124,9 +131,11 @@ def compile_metadata(base_dir):
update_metadata(holidays_metadata, HOLIDAYS_DIR, 'holiday')

def main():
print('Compiling metadata...')
print('Clearing the metadata directory...')
clear_index_directory()
print('Compiling the metadata directory...')
compile_metadata(BASE_DIR)
print('Metadata compilation complete.')
print('The metadata has been compiled successfully!')

# Run the metadata compilation
if __name__ == '__main__':
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="recipyzer",
version="0.1.0-alpha.2",
version="0.1.0-alpha.3",
author="Kane McConnell",
description="A toolkit for managing and organizing the Recipyzer recipe repository.",
long_description=open('./Recipyzer/README.md', encoding='utf-8').read(),
Expand Down

0 comments on commit 79fd6cd

Please sign in to comment.