Returns alerts for a ()single) SAME geocode. Only useful if you didn't specify samecodes when the WeatherAlerts
        object was created.
326967
def samecode_alerts(self, samecode):
        """"""
        return [x for x in self._alerts if samecode in x.samecodes]
1297436
def postcode(self):
        
        postcode = ''
        pattern = self.random_element(self.postcode_formats)
        for placeholder in pattern:
            postcode += self.random_element(self._postcode_sets[placeholder])
        return postcode
388060
def get_all_sensor_codes(si, wild_sensor_code):
    
    mtype_and_ory, x, y, z = wild_sensor_code.split("-")
    if mtype_and_ory == "*":
        mtypes = list(si)
    elif mtype_and_ory[-1] in "XYZ" and "ACCX" not in si:  # Need to support old sensor_file.json files.
        mtypes = [mtype_and_ory[:-1]]
    else:
        mtypes = [mtype_and_ory]

    all_sensor_codes = []
    for mtype in mtypes:
        for m_number in si[mtype]:
            if x in ["*", si[mtype][m_number]['X-CODE']] and \
                    y in ["*", si[mtype][m_number]['Y-CODE']] and \
                    z in ["*", si[mtype][m_number]['Z-CODE']]:
                cc = get_sensor_code_by_number(si, mtype, m_number)
                all_sensor_codes.append(cc)

    return all_sensor_codes
767148
function geocode(address, callback) {
  var query = qs.stringify({ address: address, sensor: false, components: 'country:US' })
    , reqtmpl = "http://maps.googleapis.com/maps/api/geocode/json?%s"
    , req = util.format(reqtmpl, query)
    , geo
    ;
  
  request(req, function(err, res, body) {
    if (err) {
      console.log('ERROR: ' + err);
      return callback(err);
    }

    console.log(body);

    geo = parseGoogleGeocodes(JSON.parse(body));

    if (!geo) {
      return callback("can't determine address");
    } else {
      return callback(null, geo);
    }
  });
}
1149915
function mapMongoAlertsToResponseObj(alerts){

  // Base response, regardless of whether we have alerts or not
  var res = {"list":[],"status":"ok"};

  // Filter and add alerts to response if we have them
  if (alerts){
    res.list = _.map(alerts, function(alert){
      var al = alert.toJSON();
      al.guid = alert._id;
      al.enabled = alert.alertEnabled;
      return al;
    });
  }
  // Return the response
  return res;
}
967144
def getErrorCorrectMapping(cell_barcodes, whitelist, threshold=1):
    ''' '''

    true_to_false = collections.defaultdict(set)

    whitelist = set([str(x).encode("utf-8") for x in whitelist])

    for cell_barcode in cell_barcodes:
        match = None
        barcode_in_bytes = str(cell_barcode).encode("utf-8")
        for white_cell in whitelist:

            if barcode_in_bytes in whitelist:  # don't check if whitelisted
                continue

            if edit_distance(barcode_in_bytes, white_cell) <= threshold:
                if match is not None:  # already matched one barcode
                    match = None  # set match back to None
                    break  # break and don't add to maps
                else:
                    match = white_cell.decode("utf-8")

        if match is not None:
            true_to_false[match].add(cell_barcode)

    return true_to_false
413196
def check_geo(geo):
    
    geo = copy.copy(geo)

    def fix_item(item):
        if isinstance(item, six.binary_type):
            return item.decode()
        return item

    def fix_list(lst):
        return [fix_item(i) for i in lst]
    if isinstance(geo.reduce, six.binary_type):
        geo.reduce = geo.reduce.decode()
    for key in geo.kwargs.keys():
        if geo.kwargs[key] is not None:
            if isinstance(geo.kwargs[key], (list, np.ndarray)):
                geo.kwargs[key] = fix_list(geo.kwargs[key])
            elif isinstance(geo.kwargs[key], six.binary_type):
                geo.kwargs[key] = fix_item(geo.kwargs[key])
    return geo
184227
def alerts(self):
        
        if self._alerts is None:
            self._alerts = AlertList(self)
        return self._alerts
663841
def geocode(self, location) :
		url = QtCore.QUrl("http://maps.googleapis.com/maps/api/geocode/xml")
		url.addQueryItem("address", location)
		url.addQueryItem("sensor", "false")
		
		request = QtNetwork.QNetworkRequest(url)
		reply = self.get(request)
		while reply.isRunning() :
			QtGui.QApplication.processEvents()

		reply.deleteLater()
		self.deleteLater()
		return self._parseResult(reply)
1280405
def get_alert(self, alert):
        
        if alert > self.alerts_count() or self.alerts_count() is None:
            return None
        else:
            return self.get()[alert-1]
1130158
def get_alert(thing_name, key, session=None):
    
    return _request('get', '/get/alert/for/{0}'.format(thing_name), params={'key': key}, session=session)
475508
def geocode(location, *args, **kwargs):
    
    location = LOCATIONS.get(location, location)
    if len(args):
        location = [location] + args
    try:
        llr = location.split(',')
    except:
        llr = [str(s).strip.lower() for s in location]
    llr = [s for s in llr if s]
    for i in range(len(LOCATIONS['Portland'])):
        if len(llr) < i + 1:
            llr += [LOCATIONS['Portland'][i]]
    if str(llr[-1])[-2:] not in DISTANCE_UNITS:
        llr[-1] = str(llr[-1]) + DISTANCE_UNITS[0]
    return ','.join([str(value) for value in llr])
1115134
def Get(self,key):
		

		for alert in self.alerts:
			if alert.id == key:  return(alert)
			elif alert.name == key:  return(alert)
1072140
def local_latlng(self, country_code='US', coords_only=False):
        
        results = [loc for loc in self.land_coords if loc[3] == country_code]
        if results:
            place = self.random_element(results)
            return (place[0], place[1]) if coords_only else place
406228
public Collection<AlertCondition> list(List<String> queryParams)
    {
        return HTTP.GET("/v2/alerts_conditions.json", null, queryParams, ALERT_CONDITIONS).get();
    }
628404
function parseGoogleGeocodes(response) {
  // the result has a results property that is an array
  // there may be more than one result when the address is ambiguous
  // for pragmatic reasons, only use the first result
  // if the result does not have a zip code, then assume the user
  // did not provide a valid address

  var result = response.results[0]
    , zipComponent = findAddressComponent(result.address_components, 'postal_code')
    , simple = {}
    ;

  simple.zip5 = zipComponent ? zipComponent.short_name : null;
  simple.address = result.formatted_address.replace(/,\s*USA/, '');
  simple.localAddress = getLocalAddress(result) || simple.address;
  simple.location = result.geometry.location;
  return simple;
}
1324893
def get_cached(location, **kwargs):
    
    result = cache.get(location)

    # Result is not cached or wrong
    if not result or not result.ok:
        result = geocoder.get(location, **kwargs)
        if result.ok:
            cache.set(location, result)

    return result