Return an Azure location by using an explicit `--location` argument, then by `--resource-group`, and
    finally by the subscription if neither argument was provided.
430617
def _get_location(cli_ctx, namespace):
    
    location = None
    if getattr(namespace, 'location', None):
        location = namespace.location
    elif getattr(namespace, 'resource_group_name', None):
        location = _get_location_from_resource_group(cli_ctx, namespace.resource_group_name)
    if not location:
        location = get_one_of_subscription_locations(cli_ctx)
    return location
551260
def _geolocation_extract(response):
    
    body = response.json()
    if response.status_code in (200, 404):
        return body

    try:
        error = body["error"]["errors"][0]["reason"]
    except KeyError:
        error = None

    if response.status_code == 403:
        raise exceptions._OverQueryLimit(response.status_code, error)
    else:
        raise exceptions.ApiError(response.status_code, error)
840512
def avail_locations(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudException(
            'The avail_locations function must be called with -f or --function.'
        )

    response = _query('avail', 'datacenters')

    ret = {}
    for item in response['DATA']:
        name = item['LOCATION']
        ret[name] = item

    return ret
845065
function (locationIdentifier, data) {
      var path;
      if (locationIdentifier) {
        path = this.constructPath(constants.LOCATIONS, locationIdentifier, constants.SPACES);
        return this.Core.POST(path, data);
      } else {
        return this.rejectRequest('Bad Request: A location identifier is required.');
      }
    }
11260
def location(ip=None, key=None, field=None):
    '''  
    '''

    if field and (field not in field_list):
        return 'Invalid field'

    if field:
        if ip:
            url = 'https://ipapi.co/{}/{}/'.format(ip, field)
        else:
            url = 'https://ipapi.co/{}/'.format(field)
    else:
        if ip:
            url = 'https://ipapi.co/{}/json/'.format(ip)
        else:
            url = 'https://ipapi.co/json/'

    if key or API_KEY:
        url = '{}?key={}'.format(url, (key or API_KEY))

    response = get(url, headers=headers)

    if field:
        return response.text
    else:
        return response.json()
206219
def GetSubNodeByLocation(self, location):
    
    for sub_node in self.sub_nodes:
      sub_node_location = getattr(sub_node.path_spec, 'location', None)
      if location == sub_node_location:
        return sub_node

    return None
1226962
def get_region(cls, resource=None):
        
        if resource:
            resource_info = cls.parse_remote(resource)
            if resource_info.region:
                return resource_info.region

        return os.environ.get("AWS_DEFAULT_REGION", cls._DEFAULT_REGION)
1084394
public static ResourceAddress.ResourceVersionedIdentifier parseCreateLocation(String locationResponseHeader) {
		Pattern pattern = Pattern.compile(REGEX_ID_WITH_HISTORY);
		Matcher matcher = pattern.matcher(locationResponseHeader);
		ResourceVersionedIdentifier parsedHeader = null;
		if(matcher.matches()){
			String serviceRoot = matcher.group(1);
			String resourceType = matcher.group(3);
			String id = matcher.group(5);
			String version = matcher.group(7);
			parsedHeader = new ResourceVersionedIdentifier(serviceRoot, resourceType, id, version);
		}
		return parsedHeader;
	}
467285
def get_location(conn, vm_):
    '''
    
    '''
    locations = conn.list_locations()
    # Default to Dallas if not otherwise set
    loc = config.get_cloud_config_value('location', vm_, __opts__, default=2)
    for location in locations:
        if six.text_type(loc) in (six.text_type(location.id), six.text_type(location.name)):
            return location
708812
def avail_locations(call=None):
    '''
    
    '''
    if call == 'action':
        raise SaltCloudSystemExit(
            'The avail_locations function must be called with '
            '-f or --function, or with the --list-locations option'
        )

    ret = {}

    params = {'Action': 'DescribeRegions'}
    result = aws.query(params,
                       location=get_location(),
                       provider=get_provider(),
                       opts=__opts__,
                       sigver='4')

    for region in result:
        ret[region['regionName']] = {
            'name': region['regionName'],
            'endpoint': region['regionEndpoint'],
        }

    return ret
387743
def to_location(location):
        
        if not location:
            raise SbgError('Location is required!')
        if isinstance(location, six.string_types):
            return location
        else:
            raise SbgError('Invalid location parameter!')
190719
def get(self, **params):
        '''
        
        '''
        return self.client.get('/v1/reference-data/locations/{0}'
                               .format(self.location_id), **params)
428915
def _get_service_endpoint(context, svc, region=None, public=True):
    
    region = _safe_region(region)
    # If a specific context is passed, use that. Otherwise, use the global
    # identity reference.
    context = context or identity
    url_type = {True: "public", False: "private"}[public]
    svc_obj = context.services.get(svc)
    if not svc_obj:
        return None
    ep = svc_obj.endpoints.get(region, {}).get(url_type)
    if not ep:
        # Try the "ALL" region, and substitute the actual region
        ep = svc_obj.endpoints.get("ALL", {}).get(url_type)
    return ep
711455
def GetLocation(session=None):
        
        if session is not None:
            return session['location']

        if not clc.LOCATION:  clc.v2.API._Login()
        return(clc.LOCATION)
1085955
function findResource(req, res, opts) {
        var pathname = url.parse(req.url).pathname
        var location
        if (opts.base) {
            var rest = pathname.substr(opts.base.length).split("/")
            location = path.join.apply(null, rest.filter(Boolean))
        } else {
            var parts = pathname.split("/")
            location = parts[parts.length - 1]
        }

        return path.join(opts.root, location)
    }
331114
def from_location(cls, location):
        
        if not location:
            return cls()
        try:
            if hasattr(location, 'isLocation'):
                # Ladybug location
                return location

            elif hasattr(location, 'Latitude'):
                # Revit's location
                return cls(city=str(location.Name.replace(",", " ")),
                           latitude=location.Latitude,
                           longitude=location.Longitude)

            elif location.startswith('Site:'):
                loc, city, latitude, longitude, time_zone, elevation = \
                    [x.strip() for x in re.findall(r'\r*\n*([^\r\n]*)[,|;]',
                                                   location, re.DOTALL)]
            else:
                try:
                    city, latitude, longitude, time_zone, elevation = \
                        [key.split(":")[-1].strip()
                         for key in location.split(",")]
                except ValueError:
                    # it's just the city name
                    return cls(city=location)

            return cls(city=city, country=None, latitude=latitude,
                       longitude=longitude, time_zone=time_zone,
                       elevation=elevation)

        except Exception as e:
            raise ValueError(
                "Failed to create a Location from %s!\n%s" % (location, e))
694230
def get_location(conn, vm_):
    '''
    
    '''
    locations = conn.list_locations()
    vm_location = config.get_cloud_config_value('location', vm_, __opts__)
    if not six.PY3:
        vm_location = vm_location.encode(
            'ascii', 'salt-cloud-force-ascii'
        )

    for img in locations:
        if isinstance(img.id, six.string_types) and not six.PY3:
            img_id = img.id.encode('ascii', 'salt-cloud-force-ascii')
        else:
            img_id = str(img.id)  # future lint: disable=blacklisted-function

        if isinstance(img.name, six.string_types) and not six.PY3:
            img_name = img.name.encode('ascii', 'salt-cloud-force-ascii')
        else:
            img_name = str(img.name)  # future lint: disable=blacklisted-function

        if vm_location and vm_location in (img_id, img_name):
            return img

    raise SaltCloudNotFound(
        'The specified location, \'{0}\', could not be found.'.format(
            vm_location
        )
    )