예제 #1
0
# characters written straight into this source file

import json
import sys
import os

if sys.version_info[0] == 2 and sys.version_info[1] < 7:
    from portality.ordereddict import OrderedDict
else:
    from collections import OrderedDict

# countries
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", 'country-codes.json'), 'rb') as f:
    countries = json.loads(f.read())
countries_dict = OrderedDict(sorted(countries.items(), key=lambda x: x[1]['name']))
countries = countries_dict.items()

country_options = [('','')]
country_options_two_char_code_index = []

currency_options = [('','')]
currency_options_code_index = []

for code, country_info in countries:
    country_options.append((code, country_info['name']))
    country_options_two_char_code_index.append(code)
    if 'currency_alphabetic_code' in country_info and 'currency_name' in country_info:
        if country_info['currency_alphabetic_code'] not in currency_options_code_index:
            # prevent duplicates in the currency options by checking if
            # that currency has already been added - multiple countries
            # use the same currency after all (GBP, EUR..)
예제 #2
0
파일: datasets.py 프로젝트: DOAJ/doaj
# characters written straight into this source file

import json
import sys
import os

if sys.version_info[0] == 2 and sys.version_info[1] < 7:
    from portality.ordereddict import OrderedDict
else:
    from collections import OrderedDict

# countries
with open(os.path.join(os.path.dirname(os.path.realpath(__file__)), "..", 'country-codes.json'), 'rb') as f:
    countries = json.loads(f.read())
countries_dict = OrderedDict(sorted(countries.items(), key=lambda x: x[1]['name']))
countries = countries_dict.items()

country_options = [('','')]
country_options_two_char_code_index = []

CURRENCY_DEFAULT = ''
currency_options = [(CURRENCY_DEFAULT, CURRENCY_DEFAULT)]
currency_options_code_index = []
currency_name_opts = []

for code, country_info in countries:        # FIXME: a bit of a mess - would be better to have an object that just gave us the answers on demand
    country_options.append((code, country_info['name']))
    country_options_two_char_code_index.append(code)
    if 'currency_alphabetic_code' in country_info and 'currency_name' in country_info:
        if country_info['currency_alphabetic_code'] not in currency_options_code_index:
            # prevent duplicates in the currency options by checking if
예제 #3
0
파일: app.py 프로젝트: kelly-mcdougall/doaj
        'name': 'ExLibris',
        'logo': 'exlibris.gif',
        'url': 'http://www.exlibrisgroup.com/'
    },
    'nature': {
        'name': 'Nature Publishing Group',
        'logo': 'nature.gif',
        'url': 'http://www.nature.com/npg_/index_npg.html'
    },
    'palgrave-macmillan': {
        'name': 'Palgrave Macmillan',
        'logo': 'palgrave-macmillan.gif',
        'url': 'http://www.palgrave.com/'
    },
}
SPONSORS = OrderedDict(sorted(SPONSORS.items(), key=lambda t: t[
    0]))  # create an ordered dictionary, sort by the key of the unordered one


# Redirects from previous DOAJ app.
# RJ: I have decided to put these here so that they can be managed
# alongside the DOAJ codebase.  I know they could also go into the
# nginx config, but there is a chance that they will get lost or forgotten
# some day, whereas this approach doesn't have that risk.
@app.route("/doaj")
def legacy():
    func = request.values.get("func")
    if func == "csv":
        return redirect(url_for('doaj.csv_data')), 301
    elif func == "rss":
        return redirect(url_for('atom.feed')), 301