Fetches the place information for input parameters from the Yahoo Placemaker service
509018
def fetch!
      fields = POST_FIELDS.reject{|f| @options[f].nil? }.map do |f|
        # Change ruby-form fields to url type, e.g., document_content => documentContent
        cgi_param = f.to_s.gsub(/\_(.)/) {|s| s.upcase}.gsub('_', '').sub(/url/i, 'URL')
        Curl::PostField.content(cgi_param, @options[f])
      end

      res         = Curl::Easy.http_post('http://wherein.yahooapis.com/v1/document', *fields)
      @xml_parser = Placemaker::XmlParser.new(res.body_str)
    end
761041
def locations(parameters)
      allowed_parameters = %w(query x y type)

      query = create_query(parameters, allowed_parameters)
      locations = perform('locations', query)

      locations['stations']
    end
1027037
def get_frontend_data_dict_for_placeholders(placeholders, request, editable=False):
    
    data_dict = {}
    for placeholder in placeholders:
        if placeholder:
            plugins = []

            # We don't use the helper method `placeholder.get_plugins()` because of the wrong order by path.
            placeholder_plugins = placeholder.cmsplugin_set.filter(language=request.LANGUAGE_CODE).order_by(
                settings.DJANGOCMS_SPA_PLUGIN_ORDER_FIELD)

            for plugin in placeholder_plugins:
                # We need the complete cascading structure of the plugins in the frontend. This is why we ignore the
                # children here and add them later in the loop.
                if not plugin.parent:
                    plugins.append(get_frontend_data_dict_for_plugin(
                        request=request,
                        plugin=plugin,
                        editable=editable)
                    )

            if plugins or editable:
                data_dict[placeholder.slot] = {
                    'type': 'cmp-%s' % placeholder.slot,
                    'plugins': plugins,
                }

            if editable:
                # This is the structure of the template `cms/toolbar/placeholder.html` that is used to register
                # the frontend editing.
                from cms.plugin_pool import plugin_pool
                plugin_types = [cls.__name__ for cls in plugin_pool.get_all_plugins(placeholder.slot, placeholder.page)]
                allowed_plugins = plugin_types + plugin_pool.get_system_plugins()

                data_dict[placeholder.slot]['cms'] = [
                    'cms-placeholder-{}'.format(placeholder.pk),
                    {
                        'type': 'placeholder',
                        'name': str(placeholder.get_label()),
                        'page_language': request.LANGUAGE_CODE,
                        'placeholder_id': placeholder.pk,
                        'plugin_language': request.LANGUAGE_CODE,
                        'plugin_restriction': [module for module in allowed_plugins],
                        'addPluginHelpTitle': 'Add plugin to placeholder {}'.format(placeholder.get_label()),
                        'urls': {
                            'add_plugin': placeholder.get_add_url(),
                            'copy_plugin': placeholder.get_copy_url()
                        }
                    }
                ]

    return data_dict
890057
def get_details(self, language=None):
        
        if self._place is None:
            if language is None:
                try:
                    language = self._query_instance._request_params['language']
                except KeyError:
                    language = lang.ENGLISH
            place = _get_place_details(
                    self.place_id, self._query_instance.api_key,
                    self._query_instance.sensor, language=language)
            self._place = Place(self._query_instance, place)
841134
def get_params(self):
        
        return self.enabled, self.size, self.chunk_delay, self.start_delay
473607
def get_location(query, format, api_key):
    """"""

    # Play nice with the API...
    sleep(1)
    geolocator = OpenCage(api_key=api_key, timeout=10)

    # Variables for storing the data
    data = {"city": None,
            "address_1": None,
            "postal_code": None,
            "country": None,
            "county": None,
            "state": None,
            "country_code": None,
            "latitude": None,
            "longitude": None,
            "continent": None}
    road = ""
    number = ""
    # Default None values
    location_data = {"city": None,
                     "road": None,
                     "house_number": None,
                     "postcode": None,
                     "country": None,
                     "county": None,
                     "state": None,
                     "ISO_3166-1_alpha-2": None,
                     "country_code": None,
                     "lat": None,
                     "lng": None}

    # Reverse geocoding ... from coordinates to address
    if format == "reverse":
        # If the query (coordinates) is not empty
        if query is None or len(query) < 3:
            pass
        else:
            location = geolocator.reverse(query)
            if location is not None:
                location_data = location[0].raw[u'components']
                location_data["lat"] = location[0].raw[u'geometry']["lat"]
                location_data["lng"] = location[0].raw[u'geometry']["lng"]
    # Direct geocoding ... from address to coordinates and full address
    if format == "direct":
        # If the query (address) is not empty
        if query is None or len(query) < 3:
            pass
        else:
            location = geolocator.geocode(query)
            if location is not None:
                location_data = location.raw[u'components']
                location_data["lat"] = location.raw[u'geometry']["lat"]
                location_data["lng"] = location.raw[u'geometry']["lng"]

    # Extract the meaningful data
    for component in location_data:
        if component == "town" or component == "city":
            data["city"] = location_data[component]
        if component == "road":
            road = location_data[component]
        if component == "house_number":
            number = location_data[component]
        if component == "postcode":
            data["postal_code"] = location_data[component]
        if component == "country":
            data["country"] = location_data[component]
        if component == "county":
            data["county"] = location_data[component]
        if component == "state":
            data["state"] = location_data[component]
        if component == "ISO_3166-1_alpha-2":
            data["country_code"] = location_data[component]
    # The address need to be reconstructed
    data["address_1"] = unicode(road) + " " + unicode(number)
    data["latitude"] = location_data["lat"]
    data["longitude"] = location_data["lng"]
    # Format the country code to three letters
    try:
        country_data = transformations.cca2_to_ccn(data["country_code"])
        data["country_code"] = transformations.ccn_to_cca3(country_data)
    except:
        data["country_code"] = None
    # Get the continent
    try:
        country_data = transformations.cc_to_cn(data["country_code"])
        data["continent"] = transformations.cn_to_ctn(country_data)
    except:
        data["continent"] = None

    # Return the final data
    return data
176231
function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
    {
        $contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
        $useSeconds = ( $contentClassAttribute->attribute( self::USE_SECONDS_FIELD ) == 1 );

        if ( $http->hasPostVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) ) and
             $http->hasPostVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) ) and
             $http->hasPostVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) ) and
             $http->hasPostVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) ) and
             $http->hasPostVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) ) and
             ( !$useSeconds or $http->hasPostVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) ) )
        {
            $year   = $http->postVariable( $base . '_datetime_year_' . $contentObjectAttribute->attribute( 'id' ) );
            $month  = $http->postVariable( $base . '_datetime_month_' . $contentObjectAttribute->attribute( 'id' ) );
            $day    = $http->postVariable( $base . '_datetime_day_' . $contentObjectAttribute->attribute( 'id' ) );
            $hour   = $http->postVariable( $base . '_datetime_hour_' . $contentObjectAttribute->attribute( 'id' ) );
            $minute = $http->postVariable( $base . '_datetime_minute_' . $contentObjectAttribute->attribute( 'id' ) );
            $second = $useSeconds ? $http->postVariable( $base . '_datetime_second_' . $contentObjectAttribute->attribute( 'id' ) ) : 0;

            if ( ( $year == '' and $month == '' and $day == '' and
                   $hour == '' and $minute == '' and ( !$useSeconds or $second == '' ) ) or
                 !checkdate( $month, $day, $year ) )
            {
                    $stamp = null;
            }
            else
            {
                $dateTime = new eZDateTime();
                $dateTime->setMDYHMS( $month, $day, $year, $hour, $minute, $second );
                $stamp = $dateTime->timeStamp();
            }

            $contentObjectAttribute->setAttribute( 'data_int', $stamp );
            return true;
        }
        return false;
    }
960912
function getQueryParams(params) {
        params = params || {};
        var url = $location.url();
        var idx = url.indexOf('?');

        // if there is a query string
        if (idx < 0) { return {}; }

        // get the query string and split the keyvals
        var query = url.substring(idx + 1);
        var keyVals = query.split('&');

        // put each key/val into the params object
        _.each(keyVals, function (keyVal) {
            var keyValArr = keyVal.split('=');
            params[keyValArr[0]] = keyValArr[1];
        });

        return params;
    }
41991
def _getParameters(self):
        """"""
        param = self.query._getParameters()                   
        param[self.__key] =  self.__value
        return param
525841
def get_bucket_location(self, bucket):
        
        details = self._details(
            method=b"GET",
            url_context=self._url_context(bucket=bucket, object_name="?location"),
        )
        d = self._submit(self._query_factory(details))
        d.addCallback(self._parse_bucket_location)
        return d
529848
function fetch(params) {
    let fetchObj = null;
    if (/^http(s{0,1}):\/\//.test(params.url)) {
        const pageLoc = location.href.match(/^https{0,1}:\/\/(.+?)(?=\/|$)/);
        const ajaxLoc = params.url.match(/^https{0,1}:\/\/(.+?)(?=\/|$)/);
        if (pageLoc.length === 2 && ajaxLoc.length === 2 && ajaxLoc[1] === pageLoc[1]) {
            fetchObj = this.ajax(params);
        } else {
            fetchObj = this.jsonp(params);
        }
    } else {
        fetchObj = this.ajax(params);
    }
    return fetchObj;
}
467669
def parse_placeholder(parser, token):
    """"""
    bits = token.split_contents()
    count = len(bits)
    error_string = '%r tag requires at least one argument' % bits[0]
    if count <= 1:
        raise TemplateSyntaxError(error_string)
    name = bits[1]
    remaining = bits[2:]
    params = {}
    simple_options = ['parsed', 'inherited', 'untranslated']
    param_options = ['as', 'on', 'with']
    all_options = simple_options + param_options
    while remaining:
        bit = remaining[0]
        if bit not in all_options:
            raise TemplateSyntaxError(
                "%r is not an correct option for a placeholder" % bit)
        if bit in param_options:
            if len(remaining) < 2:
                raise TemplateSyntaxError(
                "Placeholder option '%s' need a parameter" % bit)
            if bit == 'as':
                params['as_varname'] = remaining[1]
            if bit == 'with':
                params['widget'] = remaining[1]
            if bit == 'on':
                params['page'] = remaining[1]
            remaining = remaining[2:]
        elif bit == 'parsed':
            params['parsed'] = True
            remaining = remaining[1:]
        elif bit == 'inherited':
            params['inherited'] = True
            remaining = remaining[1:]
        elif bit == 'untranslated':
            params['untranslated'] = True
            remaining = remaining[1:]
    return name, params
1228313
public function details($placeId, $query = [])
    {
        if( ! $placeId) {
            throw new InvalidArgumentException('placeId must be a string');
        }

        try {
            $response = $this->httpClient->request('GET', $this->url, [
                'query' => array_merge([
                    'placeid' => $placeId,
                    'key' => $this->auth->key(),
                ], $query)
            ]);

        } catch (Exception $e) {
            throw new ResourceRequestException(null, sprintf('Failed to request place details for place id %s', $placeId), 0, $e);
        }

        if( $response->getStatusCode() > 299) {
            throw new ResourceRequestException($response, sprintf('Failed to request place details for place id %s', $placeId));
        }

        return PlaceDetailsResponse::fromResponse($response);
    }
31014
def _parse_place(place, is_freeform=None):
        
        # When freeform already so full address
        if is_freeform == 'true':
            location = place.get('freeformaddress')
        else:
            # For parcelle
            if place.get('numero'):
                location = place.get('street')
            else:
                # When classic geocoding
                # or when reverse geocoding
                location = "%s %s" % (
                    place.get('postal_code', ''),
                    place.get('commune', ''),
                )
                if place.get('street'):
                    location = "%s, %s" % (
                        place.get('street', ''),
                        location,
                    )
                if place.get('building'):
                    location = "%s %s" % (
                        place.get('building', ''),
                        location,
                    )

        return Location(location, (place.get('lat'), place.get('lng')), place)
670628
def _fetch(self, searchtype, fields, **kwargs):
        ''''''
        fields['vintage'] = self.vintage
        fields['benchmark'] = self.benchmark
        fields['format'] = 'json'

        if 'layers' in kwargs:
            fields['layers'] = kwargs['layers']

        returntype = kwargs.get('returntype', 'geographies')
        url = self._geturl(searchtype, returntype)

        try:
            with requests.get(url, params=fields, timeout=kwargs.get('timeout')) as r:
                content = r.json()
                if "addressMatches" in content.get('result', {}):
                    return AddressResult(content)

                if "geographies" in content.get('result', {}):
                    return GeographyResult(content)

                raise ValueError()

        except (ValueError, KeyError):
            raise ValueError("Unable to parse response from Census")

        except RequestException as e:
            raise e
395797
def prepare_place_layer(self):
        """"""
        if os.path.exists(self.input_place.text()):
            self.place_layer = QgsVectorLayer(
                self.input_place.text(),
                tr('Nearby Cities'),
                'ogr'
            )
            if self.place_layer.isValid():
                LOGGER.debug('Get field information')
                self.name_field.setLayer(self.place_layer)
                self.population_field.setLayer(self.place_layer)
            else:
                LOGGER.debug('failed to set name field')
465911
def _getParameters(self):
        """"""
        param = self.query._getParameters()        
        sortingNames = []
        for outputCol in self.__columns:
            sort_dictionary={"field" : outputCol, "direction" : "ASC"}
            sortingNames.append(sort_dictionary)            
        param.update({'sort' : {"ordersList" : sortingNames}})
        return param