Skip to content

Commit

Permalink
copy report to html tree
Browse files Browse the repository at this point in the history
  • Loading branch information
OllyButters committed Jul 25, 2024
1 parent f54dc1d commit 2459fb1
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
22 changes: 11 additions & 11 deletions source/analyse/analyse.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,59 +514,59 @@ def mesh(papers):
################################################################################
# output a csv file with some general info in
################################################################################
def output_csv(papers):
def output_summary(papers):

print('\n###Outputting CSV file###')
with open(config.data_dir + '/all.csv', 'w') as csvfile:
with open(config.data_dir + '/summary.csv', 'w') as csvfile:
all_file = csv.writer(csvfile)
all_file.writerow(['year', 'authors', 'title', 'first_author', 'journal', 'citations', 'tags'])

for this_paper in papers:
try:
title = this_paper['clean']['title']
except:
except Exception:
title = '???'

try:
first_author = this_paper['clean']['full_author_list'][0]['family']
except:
except Exception:
first_author = '???'

try:
all_authors = this_paper['clean']['full_author_list']
author_string = ''
for this_author in all_authors:
author_string = author_string + this_author['family'] + ', '
except:
except Exception:
author_string = '???'

try:
journal = this_paper['clean']['journal']['journal_name']
except:
except Exception:
journal = '???'

try:
citations = this_paper['clean']['citations']['scopus']['count']
except:
except Exception:
citations = '???'

try:
year = this_paper['clean']['clean_date']['year']
except:
except Exception:
year = '???'

try:
tags = []
tag_string = ''
for this_tag in this_paper['clean']['zotero_tags']:
tags.append(this_tag['tag'])
tag_string = ', '.join(tags)
except:
tag_string = ' | '.join(tags)
except Exception:
tag_string = '???'

try:
all_file.writerow([year, author_string, title, first_author, journal, citations, tag_string])
except:
except Exception:
pass


Expand Down
5 changes: 3 additions & 2 deletions source/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,15 @@
logging_loglevel = config.get('logging', 'loglevel', fallback = 'DEBUG')

# Metrics
metrics_study_start_year = int(config.get('metrics', 'metrics_study_start_year'))
metrics_study_current_year = int(config.get('metrics', 'metrics_study_current_year'))
#metrics_study_start_year = int(config.get('metrics', 'metrics_study_start_year'))
#metrics_study_current_year = int(config.get('metrics', 'metrics_study_current_year'))

# Pages
WEB_PAGE_SHOW_INSTITUTE_UK_MAP = config.getboolean('pages', 'web_page_show_institute_UK_map', fallback = True)
WEB_PAGE_SHOW_INSTITUTE_COUNTRY_MAP = config.getboolean('pages', 'web_page_show_institute_country_map', fallback = True)
WEB_PAGE_SHOW_ZOTERO_TAGS = config.getboolean('pages', 'web_page_show_zotero_tags', fallback = True)
web_page_is_in_iframe = config.getboolean('pages', 'web_page_is_in_iframe', fallback = False)
WEB_PAGE_REPORTS = config.get('pages', 'web_page_reports', fallback = None)

except Exception as e:
print('Problem with the settings file')
Expand Down
4 changes: 3 additions & 1 deletion source/papers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
from analyse import analyse
from analyse import coverage_report
from config import config
import web_pages.reports

__author__ = "Olly Butters, Hugh Garner, Tom Burton, Becca Wilson"
__date__ = 16/4/2024
Expand Down Expand Up @@ -125,7 +126,7 @@
analyse.first_authors(papers)
analyse.inst(papers)
# analyse.mesh(papers)
analyse.output_csv(papers)
analyse.output_summary(papers)
analyse.dates(papers)

###########################################################
Expand All @@ -141,6 +142,7 @@
#web_pages.build_htmlv2.build_search(papers)

web_pages.build_htmlv2.build_all(papers, papers_with_keywords, papers_with_abstract_text)
web_pages.reports.copy_reports()

#if config.WEB_PAGE_SHOW_ZOTERO_TAGS:
# web_pages.build_htmlv2.build_zotero_tags(papers)
Expand Down
2 changes: 1 addition & 1 deletion source/setup/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def build_file_tree():
if not os.path.exists(config.html_dir):
os.makedirs(config.html_dir)

html_directories = {"/mesh", "/css", "/papers", "/tags", "/keywords", "/country", "/institute", "/metrics", "/keyword_wordcloud", "/abstractwordcloud", "/authornetwork", "/help", "/search", "/status"}
html_directories = {"/mesh", "/css", "/papers", "/tags", "/keywords", "/country", "/institute", "/metrics", "/keyword_wordcloud", "/abstractwordcloud", "/help", "/search", "/reports"}

for direct in html_directories:
if not os.path.exists(config.html_dir + direct):
Expand Down
14 changes: 14 additions & 0 deletions source/web_pages/reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os
import shutil
from config import config

# Copy specified reports to the html directory
def copy_reports():
print('Copying reports to html directory.')

if config.WEB_PAGE_REPORTS:
print('Copying ', config.WEB_PAGE_REPORTS, ' to html directory.')

if os.path.exists(config.data_dir + '/' + config.WEB_PAGE_REPORTS):

shutil.copy(config.data_dir + '/' + config.WEB_PAGE_REPORTS, config.html_dir + '/reports/')

0 comments on commit 2459fb1

Please sign in to comment.