Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbalcaen committed Apr 26, 2024
1 parent d712d43 commit 1250f65
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
"lambda": {
"runtime": "python3.11",
"payload": {
"json": {}
"json": {
"doc_s3_arn": "arn:aws:s3:::levio-demo-fev-esta-ses-bucket-dev/rfp/pv7jfmrt7rb5713phc1nbujbiprs8kep6jq6cm01/attachments/MESS_700001817_Gouv_Arch_Securite_extracted_pdf_content.txt",
"replacements": []
}
}
}
},
Expand Down
6 changes: 3 additions & 3 deletions lambdas/document_filler/src/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

def lambda_handler(event, context):
"""
Downloads the given docx and for each replacement item it replaces the matching document_key with the text_to_fill
Downloads the given docx and for each replacement item it replaces the matching replacement_key with the replacement_text
"""
s3_arn = event['doc_s3_arn']
replacements = event['replacements']
Expand All @@ -23,8 +23,8 @@ def lambda_handler(event, context):

for paragraph in doc.paragraphs:
for replacement in replacements:
if replacement['document_key'] in paragraph.text:
paragraph.text = paragraph.text.replace(replacement['document_key'], replacement['text_to_fill'])
if replacement['replacement_key'] in paragraph.text:
paragraph.text = paragraph.text.replace(replacement['replacement_key'], replacement['replacement_text'])

output_stream = BytesIO()
doc.save(output_stream)
Expand Down
2 changes: 1 addition & 1 deletion lambdas/document_filler/src/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
docx
python-docx

0 comments on commit 1250f65

Please sign in to comment.