fix/todo: use match_state_for_country! w/ !!! why? why not?
198350
def match_state_for_country( value, country_id )  ## NB: required country_id 
    if value =~ /^state:/   ## state:
      state_key = value[6..-1]  ## cut off state: prefix
      state = WorldDb::Model::State.find_by_key_and_country_id!( state_key, country_id )
      yield( state )
      true  # bingo - match found
    elsif is_state?( value )  ## assume state code e.g. TX or N
      state = WorldDb::Model::State.find_by_key_and_country_id!( value.downcase, country_id )
      yield( state )
      true  # bingo - match found
    else
      false # no match found
    end
  end
289932
def match(*args)
      # Localize simple match only if there is no resource scope.
      if @locales and (args.size >= 1) and !parent_resource and
             args.last.is_a?(Hash) # In both variants Hash should be present as last parameter

        # Make deep copy of last argument (Hash)
        options = Marshal.load(Marshal.dump(args.last)) # Dump is dirty but how to make deep cloning easily ? :/

        # Now handle parameters
        if (args.first.is_a?(Hash))
          path, to = options.find { |name, value| name.is_a?(String) }
          options.merge!(:to => to).delete(path)
        else
          path = args[0]
          options[:as] ||= path
        end

        if (options[:as])
          @locales.each do |locale|
            mapping = LocalizedMapping.new(locale, @set, @scope, path, options)
            if mapping.localizable?
              puts("[I18n] > localize %-10s: %40s (%s) => %s" % ['route', options[:as], locale, mapping.path]) if @i18n_verbose
              @set.add_route(*mapping.to_route)
            end
          end

          # Now, create the real match :
          return set_localizable_route(options[:as]) do
            super
          end
        end
      end

      super
    end
537645
def match(self, other_version):
    
    major, minor, patch = _str_to_version(other_version, allow_wildcard=True)
    return (major in [self.major, "*"] and minor in [self.minor, "*"]
            and patch in [self.patch, "*"])
930120
function could_phone_number_belong_to_country(phone_number, country_code, metadata)
{
	// Strip the leading `+`
	const phone_number_digits = phone_number.slice('+'.length)

	for (const country_phone_code of Object.keys(metadata.country_phone_code_to_countries))
	{
		const possible_country_phone_code = phone_number_digits.substring(0, country_phone_code.length)
		if (country_phone_code.indexOf(possible_country_phone_code) === 0)
		{
			// This country phone code is possible.
			// Does the given country correspond to this country phone code.
			if (metadata.country_phone_code_to_countries[country_phone_code].indexOf(country_code) >= 0)
			{
				return true
			}
		}
	}
}
1266482
protected function match($phone='', $countries=array()) {
		r_cast::string($phone, true);
		r_cast::array($countries);

		foreach ($countries as $c) {
			if (! $c || ! \is_string($c) || isset($this->tried[$c])) {
				continue;
			}

			// There are too many damn countries! To prevent autoloader
			// overload, these classes are stored as innocent text files
			// and included here as needed.
			$this->tried[$c] = true;
			$func = "\\blobfolio\\phone\\data\\data$c";
			@require_once __DIR__ . "/data/src/data$c.txt";

			if (false !== ($tmp = $func::match($phone))) {
				$this->phone = $tmp;
				return true;
			}
		}

		return false;
	}
1358878
function getCountryByNameOrShortName(name, useAlias) {
  if (!_.isString(name)) return undefined;

  return _.find(countries, (country) => {
    if (useAlias) {
      return country.name.toUpperCase() === name.toUpperCase()
        || country.alpha2.toUpperCase() === name.toUpperCase()
        ||  _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
    }
    return country.name.toUpperCase() === name.toUpperCase() || country.alpha2.toUpperCase() === name.toUpperCase();
  });
}
174017
def match(ctx, features, profile, gps_precision):
    
    access_token = (ctx.obj and ctx.obj.get('access_token')) or None

    features = list(features)
    if len(features) != 1:
        raise click.BadParameter(
            "Mapmatching requires a single LineString feature")

    service = mapbox.MapMatcher(access_token=access_token)
    try:
        res = service.match(
            features[0],
            profile=profile,
            gps_precision=gps_precision)
    except mapbox.errors.ValidationError as exc:
        raise click.BadParameter(str(exc))

    if res.status_code == 200:
        stdout = click.open_file('-', 'w')
        click.echo(res.text, file=stdout)
    else:
        raise MapboxCLIException(res.text.strip())
539981
def country(anon, obj, field, val):
    
    return anon.faker.country(field=field)
905
def is_country(self, text):
        """"""
        ct_list = self._just_cts.keys()
        if text in ct_list:
            return True
        else:
            return False
908050
function countryNameToCode (name) {
  const country = countries.find((country) => country.name === name)

  if (!country) {
    return name
  }

  return country.code
}
1181211
static function fetchCountry( $value, $fetchBy = false )
    {
        $fetchBy = !$fetchBy ? 'Name' : $fetchBy;

        $allCountries = eZCountryType::fetchCountryList();
        $result = false;
        if ( $fetchBy == 'Alpha2' and isset( $allCountries[strtoupper( $value )] ) )
        {
            $result = $allCountries[$value];
            return $result;
        }

        foreach ( $allCountries as $country )
        {
            if ( isset( $country[$fetchBy] ) and $country[$fetchBy] == $value )
            {
                $result = $country;
                break;
            }
        }

        return $result;
    }
916097
def _set_country(self, c):
        

        self.location.countrycode = c.split()[0].split('=')[1].strip().upper()
1172016
def process(self, pq):
        
        # Map country, but don't let map overwrite
        if pq.country not in self.acceptable_countries and pq.country in self.country_map:
            pq.country = self.country_map[pq.country]
        if pq.country != '' and \
           self.acceptable_countries != [] and \
           pq.country not in self.acceptable_countries:
            return False
        return pq
1156272
def country_or_default_country(country)
      country ||= (original_starts_with_plus? ? nil : Phonelib.default_country)
      country && country.to_s.upcase
    end
108524
def match_us_state(state_string):
    """"""
    if state_string:
        state_string = state_string.upper().replace('.', '').strip()
        if us_state_to_iso_code.get(state_string):
            return us_state_to_iso_code.get(state_string)
        else:
            for code, state_spellings in us_states_alternative_spellings.items():
                for spelling in state_spellings:
                    if state_string == spelling:
                        return code
    return None
618792
function(state){
			var match = this.model.get('data');

			var countryA = match.teamA ? match.teamA.country : null;
			this.setFlagsState(state, countryA, this.$('.flag-3d-left'));

			var countryB = match.teamB ? match.teamB.country : null;
			this.setFlagsState(state, countryB, this.$('.flag-3d-right'));
		}
1254937
protected function validateCountryState()
    {
        $id = $this->getUpdatingId();

        if ($id === false) {
            return null;
        }

        $data = $this->state->get($id);

        if (empty($data)) {
            $this->setErrorUnavailable('update', $this->translation->text('Country state'));
            return false;
        }

        $this->setUpdating($data);
        return true;
    }