def location_errors(request, return_values = 4): """find invalid locations""" try: longitude = float(str_replace(request.POST['longitude'], ",", ".")) assert -180 <= longitude <= 180 except KeyError: return ( __('Longitude'), '3', __('Please provide a longitude'), "locationerror" )[0:return_values] except Exception: return ( __('Longitude'), '3', __('"%(LONGITUDE)s" is not a valid longitude') % {"LONGITUDE":str(request.POST['longitude'])}, "locationerror" )[0:return_values] try: latitude = float(str_replace(request.POST['latitude'], ",", ".")) assert -90 <= latitude <= 90 except KeyError: return ( __('Latitude'), '3', __('Please provide a latitude'), "locationerror" )[0:return_values] except Exception: return ( __('Latitude'), '3', '"%s" is not a valid latitude' % str(request.POST['latitude']), "locationerror" )[0:return_values]
def checkout(client, url, base_dir, svn_repo, is_directory=True): if base_dir is not None: section_path = left_strip(str_replace(url, svn_repo, ''), '/') basedir = right_strip(base_dir, '/') full_checkout_path = os.path.join(basedir, section_path) client.export(url, full_checkout_path, recurse=is_directory)