Skip to content

Commit

Permalink
Merge pull request #6 from barun-saha/issue-5
Browse files Browse the repository at this point in the history
Fix issue 5: remove unused code and packages
  • Loading branch information
barun-saha committed Mar 31, 2024
2 parents b8e6557 + 08aca02 commit 437a6f6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 93 deletions.
1 change: 0 additions & 1 deletion app.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ def generate_slide_deck(json_str: str, pptx_template: str, progress_bar) -> List
logging.info('Creating PPTX file...')
all_headers = pptx_helper.generate_powerpoint_presentation(
json_str,
as_yaml=False,
slides_template=pptx_template,
output_file_path=path
)
Expand Down
71 changes: 0 additions & 71 deletions clarifai_grpc_helper.py

This file was deleted.

24 changes: 6 additions & 18 deletions pptx_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import json5
import pptx
import yaml

from global_config import GlobalConfig

Expand Down Expand Up @@ -51,31 +50,20 @@ def remove_slide_number_from_heading(header: str) -> str:

def generate_powerpoint_presentation(
structured_data: str,
as_yaml: bool,
slides_template: str,
output_file_path: pathlib.Path
) -> List:
"""
Create and save a PowerPoint presentation file containing the contents in JSON or YAML format.
Create and save a PowerPoint presentation file containing the content in JSON format.
:param structured_data: The presentation contents as "JSON" (may contain trailing commas) or
YAML
:param as_yaml: True if the input data is in YAML format; False if it is in JSON format
:param structured_data: The presentation contents as "JSON" (may contain trailing commas)
:param slides_template: The PPTX template to use
:param output_file_path: The path of the PPTX file to save as
:return A list of presentation title and slides headers
"""

if as_yaml:
# Avoid YAML mode: nested bullets can lead to incorrect YAML generation
try:
parsed_data = yaml.safe_load(structured_data)
except yaml.parser.ParserError as ype:
logging.error('*** YAML parse error: %s', str(ype))
parsed_data = {'title': '', 'slides': []}
else:
# The structured "JSON" might contain trailing commas, so using json5
parsed_data = json5.loads(structured_data)
# The structured "JSON" might contain trailing commas, so using json5
parsed_data = json5.loads(structured_data)

logging.debug(
"*** Using PPTX template: %s",
Expand Down Expand Up @@ -134,7 +122,8 @@ def generate_powerpoint_presentation(

def get_flat_list_of_contents(items: list, level: int) -> List[Tuple]:
"""
Flatten a (hierarchical) list of bullet points to a single list containing each item and its level.
Flatten a (hierarchical) list of bullet points to a single list containing each item and
its level.
:param items: A bullet point (string or list)
:param level: The current level of hierarchy
Expand Down Expand Up @@ -248,7 +237,6 @@ def get_flat_list_of_contents(items: list, level: int) -> List[Tuple]:

generate_powerpoint_presentation(
json5.loads(json_data),
as_yaml=False,
output_file_path=path,
slides_template='Blank'
)
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ python-dotenv[cli]~=1.0.0
langchain~=0.1.13
# huggingface_hub
streamlit~=1.32.2
clarifai==9.7.4

python-pptx
metaphor-python
json5~=0.9.14
PyYAML~=6.0.1
# curlify
requests~=2.31.0

0 comments on commit 437a6f6

Please sign in to comment.