Exemplo n.º 1
0
def get_floor(directions):
    url = misc.get_in(directions, 'maps', 0, 'mapurl')
    if url is None:
        return ''
    url = urlparse.urlparse(url)
    params = urlparse.parse_qs(url.query)
    floor = misc.get_in(params, 'floor', 0)
    if floor is None:
        return ''
    else:
        if floor == '5':
            return 'M'
        else:
            return int(floor)
Exemplo n.º 2
0
def get_building(directions):
    """
    gets the building from an item's directions
    """
    # something like: Please proceed to the mezzanine level of the Goldfarb
    default = 'Goldfarb / Farber'
    directions = misc.get_in(directions, 'maps', 0, 'directions')
    if directions is None:
        return default
    matches = re.search(r'(Goldfarb|Farber) building', directions)
    if matches is None:
        return default
    groups = matches.groups()
    if len(groups) == 0:
        return default
    else:
        return groups[0]
Exemplo n.º 3
0
def get_raw_directions(item):
    if 'directions' in item:
        return item['directions']

    params = {
        'holding[]': '{library}$${collection}$${call}'.format(**item),
        'alt': 'true',
    }

    url = 'https://brandeis.stackmap.com/json/'

    r = requests.get(url, params=params)
    status = misc.check_internet(r)
    if status is None:
        misc.err(status)
        return

    try:
        directions = r.json()
    except json.decoder.JSONDecodeError as e:
        # ¯\_(ツ)_/¯
        return

    return misc.get_in(directions, 'results', 0)
Exemplo n.º 4
0
def get_aisle(directions):
    return misc.get_in(directions, 'maps', 0, 'ranges', 0, 'label') or ''
Exemplo n.º 5
0
def get_english(directions):
    return misc.get_in(directions, 'maps', 0, 'directions')