| @@ -45,12 +45,16 @@ def main_data(): | |||
| country_dict = {"label": "number of records", "data": country_numbers, "backgroundColor": random_colour} | |||
| else: | |||
| country = pycountry.countries.get(alpha_2=country_data[i]) | |||
| if country is None: | |||
| if country is not None: | |||
| country_labels.append(country.name) | |||
| country_data[i] = country | |||
| else: | |||
| country = pycountry.historic_countries.get(alpha_2=country_data[i]) | |||
| country_labels.append(country.name) | |||
| country_data[i] = country | |||
| if country is not None: | |||
| country_data[i] = country | |||
| country_labels.append(country.name) | |||
| else: | |||
| country_labels.append(country_data[i]) | |||
| country_dataset.append(country_dict) | |||
| germany = pycountry.countries.get(alpha_2='DE') | |||
| return render_template('data.html', total_number=total_number, year_data=year_data, year_labels=year_labels, year_dataset=year_dataset, country_data=country_data, country_labels=country_labels, country_dataset=country_dataset, germany=germany) | |||
| return render_template('data.html', total_number=total_number, year_data=year_data, year_labels=year_labels, year_dataset=year_dataset, country_data=country_data, country_labels=country_labels, country_dataset=country_dataset) | |||
| @@ -98,10 +98,14 @@ def parse_result(id, input): | |||
| # search for the country in the content element and display it | |||
| country_code = re.search('FT=D[^\s]*\s(\w{2})', input) | |||
| country = pycountry.countries.get(alpha_2=country_code.group(1)) | |||
| if country is None: | |||
| country = pycountry.historic_countries.get(alpha_2=country_code.group(1)) | |||
| if country is not None: | |||
| output['country'] = country | |||
| else: | |||
| country = pycountry.historic_countries.get(alpha_2=country_code.group(1)) | |||
| if country is not None: | |||
| output['country'] = country | |||
| else: | |||
| output['country'] = country_code.group(1) | |||
| return output | |||
| @@ -23,7 +23,11 @@ There are a total of {{ total_number }} patents. | |||
| {% if i % 2 %} | |||
| {{ country_data[i] }}<br> | |||
| {% else %} | |||
| {{ country_data[i].name }} {{ country_data[i].flag }}: | |||
| {% if country_data[i].name is defined %} | |||
| {{ country_data[i].name }} {{ country_data[i].flag }}: | |||
| {% else %} | |||
| {{ country_data[i] }}: | |||
| {% endif %} | |||
| {% endif %} | |||
| {% endfor %} | |||
| </div> | |||
| @@ -28,8 +28,11 @@ | |||
| {% if result['country'] is defined %} | |||
| <p class="mb-2"> | |||
| Country: | |||
| {{ result['country'].name }} | |||
| {{ result['country'].flag }} | |||
| {% if result['country'].name is defined %} | |||
| {{ result['country'].name }} {{ result['country'].flag }} | |||
| {% else %} | |||
| {{ result['country'] }} | |||
| {% endif %} | |||
| </p> | |||
| {% endif %} | |||
| @@ -54,8 +54,11 @@ | |||
| {% if result['country'] is defined %} | |||
| <p class="mb-2"> | |||
| <span class="emphasis">Country:</span> | |||
| {{ result['country'].name }} | |||
| {{ result['country'].flag }} | |||
| {% if result['country'].name is defined %} | |||
| {{ result['country'].name }} {{ result['country'].flag }} | |||
| {% else %} | |||
| {{ result['country'] }} | |||
| {% endif %} | |||
| </p> | |||
| {% endif %} | |||