Add logging configuration and info statements for content updates and reference extraction
Browse files- controllers/utils.py +7 -0
controllers/utils.py
CHANGED
@@ -37,6 +37,11 @@ with open('xpath.json', 'r', encoding='UTF-8') as f:
|
|
37 |
with open('patterns.json', 'r', encoding='UTF-8') as f:
|
38 |
patterns = json.load(f)
|
39 |
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
def datemodifier(date_string, date_format):
|
42 |
"""Date Modifier Function
|
@@ -218,6 +223,7 @@ def update_content(report):
|
|
218 |
Returns:
|
219 |
None
|
220 |
"""
|
|
|
221 |
dynamodb = get_client_connection()
|
222 |
response = dynamodb.update_item(
|
223 |
TableName="article_china",
|
@@ -429,6 +435,7 @@ def extract_reference(row):
|
|
429 |
None
|
430 |
"""
|
431 |
try:
|
|
|
432 |
pattern = next(
|
433 |
(elem for elem in patterns if elem['site'] == row['site']), None)
|
434 |
extracted_text = extract_from_pdf_by_pattern(row['attachment'],
|
|
|
37 |
with open('patterns.json', 'r', encoding='UTF-8') as f:
|
38 |
patterns = json.load(f)
|
39 |
|
40 |
+
logging.basicConfig(
|
41 |
+
format='%(asctime)s - %(levelname)s - %(funcName)s - %(message)s',
|
42 |
+
datefmt="%Y-%m-%d %H:%M:%S",
|
43 |
+
level=logging.INFO
|
44 |
+
)
|
45 |
|
46 |
def datemodifier(date_string, date_format):
|
47 |
"""Date Modifier Function
|
|
|
223 |
Returns:
|
224 |
None
|
225 |
"""
|
226 |
+
logging.info("Updating content for %s", report['id'])
|
227 |
dynamodb = get_client_connection()
|
228 |
response = dynamodb.update_item(
|
229 |
TableName="article_china",
|
|
|
435 |
None
|
436 |
"""
|
437 |
try:
|
438 |
+
logging.info("Extracting reference for %s", row['id'])
|
439 |
pattern = next(
|
440 |
(elem for elem in patterns if elem['site'] == row['site']), None)
|
441 |
extracted_text = extract_from_pdf_by_pattern(row['attachment'],
|