mocnik-science / osm-python-tools

A library to access OpenStreetMap related services
GNU General Public License v3.0
440 stars 48 forks source link

Update statusString index in _waitForReady function #56

Closed huyphan2612 closed 2 years ago

huyphan2612 commented 2 years ago

Update statusString index to match with status string returned from Overpass API endpoint's status.

ZaraGi commented 2 years ago

Hello, may I propose a more generic approach? With this solution the problem will recur whenever the order of the elements within the statusString list is changed, instead turning the list into a dictionary and checking the keys would be more robust.

Something like this:

tmp = statusString.copy()
statusString = {}
for element in tmp:
    if element == '':
        continue
    if element.endswith('slots available now.'):
        element = f'{element[-20:-1]}: {element[:-21]}'
    splits = element.split(': ')
    if len(splits) == 1:
        statusString[splits[0]] = ''
    else:
        statusString[splits[0]] = splits[1]

if ('Rate limit' in statusString.keys()) and  (statusString['Rate limit'] == ' 0'):
    return True
mocnik-science commented 2 years ago

done in 0.3.5 (see the discussion to issue #55)