Returns: generator over all countries
506096
def countries(self) -> typing.Iterator['Country']:
        
        for coalition in self.coalitions:
            for country in coalition.countries:

                yield country
1085555
def __read_countries_file(self):
        """"""
        import csv
        import pkg_resources

        filename = pkg_resources.resource_filename('sortinghat', 'data/countries.csv')

        with open(filename, 'r') as f:
            reader = csv.DictReader(f, fieldnames=['name', 'code', 'alpha3'])
            countries = [Country(**c) for c in reader]

        return countries
104263
def all_generators(self):
        
        for arg_gen in self.arg_gens:
            yield arg_gen

        for kwarg_gen in self.kwarg_gens.values():
            yield kwarg_gen
1052719
def country_field(key='country'):
    """"""

    country_list = list(countries)
    title_map = []
    for item in country_list:
        title_map.append({'value': item.alpha_3, 'name': item.name})

    widget = {
        'key': key,
        'type': 'uiselect',
        'titleMap': title_map
    }

    return widget
653576
def get_country_by_name(self, country_name: str) -> typing.Optional['Country']:
        
        VALID_STR.validate(country_name, 'get_country_by_name', exc=ValueError)
        if country_name not in self._countries_by_name.keys():
            for country in self.countries:

                if country.country_name == country_name:
                    self._countries_by_name[country_name] = country
                    return country
            raise ValueError(country_name)
        else:
            return self._countries_by_name[country_name]
209898
def generator(self,gen,*args,**kwargs):
        
        with self(*args,**kwargs):
            for i in gen:
                yield i
1039903
def country(random=random, *args, **kwargs):
    
    return random.choice([
        "{country}",
        "{direction} {country}"
    ]).format(country=random.choice(countries),
              direction=direction(random=random))
1105345
def get_all(self) -> Iterable[Tuple[str, str]]:
        
        for name, values in self._as_list.items():
            for value in values:
                yield (name, value)
784192
function getCountryList() {
        var countries = grunt.option("countries");
        if (!countries) {
            grunt.fail.fatal("Country list not passed. Example usage: `grunt customBuild --countries=Canada,United States`");
        }

        // countries may contain commas in their names. Bit ugly, but simple. This swiches out those escaped commas
        // and replaces them later
        var commaReplaced = countries.replace(/\\,/g, '{COMMA}');
        var targetCountries = _.map(commaReplaced.split(","), function (country) {
            return country.replace(/\{COMMA\}/, ',').trim();
        });

        var countryData = [];
        var foundCountryNames = [];

        var formattedData = minifyJSON(countriesJSON);
        _.each(formattedData, function (countryInfo) {
            var countryName = countryInfo[0];
            if (_.contains(targetCountries, countryName)) {
                countryData.push(countryInfo);
                foundCountryNames.push(countryName);
            }
        });

        // if one or more of the countries wasn't found, they probably made a typo: throw a warning but continue
        if (targetCountries.length !== countryData.length) {
            grunt.log.error("The following countries weren't found (check the source/data.json file to ensure you entered the exact country string):");
            var missing = _.difference(targetCountries, foundCountryNames);
            _.each(missing, function (countryName) {
                grunt.log.error("--", countryName);
            });

            // all good! Let the user know what bundle is being created, just to remove any ambiguity
        } else {
            grunt.log.writeln("");
            grunt.log.writeln("Creating bundle with following countries:");
            _.each(targetCountries, function (country) {
                grunt.log.writeln("* " + country);
            });
        }

        config.template.customBuild.options.data.__DATA__ = "\nvar _data = " + JSON.stringify(countryData);
    }
982165
def find_all(self, **names):
        
        values = names.items()
        if len(values) != 1:
            raise ValueError('Only one query is allowed at a time')
        name, value = values[0]
        for item in self:
            if item.get(name) == value:
                yield item
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
582674
function getCountryByName(name, useAlias) {
  if (!_.isString(name)) return undefined;

  return _.find(countries, (country) => {
    if (useAlias) {
      return country.name.toUpperCase() === name.toUpperCase()
        ||  _.find(country.alias, (alias) => (alias.toUpperCase() === name.toUpperCase()));
    }
    return country.name.toUpperCase() === name.toUpperCase();
  });
}
627860
def per_country_data(self):
        
        ret = {}
        for cache_date in self.cache_dates:
            data = self._cache_get(cache_date)
            ret[cache_date] = {}
            for cc, count in data['by_country'].items():
                k = '%s (%s)' % (self._alpha2_to_country(cc), cc)
                ret[cache_date][k] = count
            if len(ret[cache_date]) == 0:
                ret[cache_date]['unknown'] = 0
        return ret
888600
def sample_all(generators, *args, **kwargs):
	''''''
	return [sample(gen, *args, **kwargs) for gen in  generators]
257285
def country_list_maker():
    
    cts = {"Afghanistan":"AFG", "Åland Islands":"ALA", "Albania":"ALB", "Algeria":"DZA",
    "American Samoa":"ASM", "Andorra":"AND", "Angola":"AGO", "Anguilla":"AIA",
    "Antarctica":"ATA", "Antigua Barbuda":"ATG", "Argentina":"ARG",
    "Armenia":"ARM", "Aruba":"ABW", "Ascension Island":"NA", "Australia":"AUS",
    "Austria":"AUT", "Azerbaijan":"AZE", "Bahamas":"BHS", "Bahrain":"BHR",
    "Bangladesh":"BGD", "Barbados":"BRB", "Belarus":"BLR", "Belgium":"BEL",
    "Belize":"BLZ", "Benin":"BEN", "Bermuda":"BMU", "Bhutan":"BTN",
    "Bolivia":"BOL", "Bosnia Herzegovina":"BIH",
    "Botswana":"BWA", "Bouvet Island":"BVT", "Brazil":"BRA",
    "Britain":"GBR", "Great Britain":"GBR",
    "British Virgin Islands":"VGB", "Brunei":"BRN", "Bulgaria":"BGR", "Burkina Faso":"BFA",
    "Burundi":"BDI", "Cambodia":"KHM", "Cameroon":"CMR",
    "Canada":"CAN","Cape Verde":"CPV", "Cayman Islands":"CYM",
    "Central African Republic":"CAF", "Chad":"TCD", "Chile":"CHL", "China":"CHN",
    "Cocos Islands":"CCK", "Colombia":"COL",
    "Comoros":"COM",     "Republic of Congo":"COG", "Cook Islands":"COK",
    "Costa Rica":"CRI", "Cote Ivoire":"CIV", "Ivory Coast":"CIV","Croatia":"HRV", "Cuba":"CUB",
    "Curaçao":"CUW", "Cyprus":"CYP", "Czech Republic":"CZE", "Denmark":"DNK",
    "Djibouti":"DJI", "Dominica":"DMA", "Dominican Republic":"DOM", "Democratic Republic of Congo" : "COD",
    "Ecuador":"ECU", "Egypt":"EGY", "El Salvador":"SLV", "England" : "GBR",
    "Equatorial Guinea":"GNQ", "Eritrea":"ERI", "Estonia":"EST", "Ethiopia":"ETH",
    "Falkland Islands":"FLK", "Faroe Islands":"FRO",
    "Fiji":"FJI", "Finland":"FIN", "France":"FRA", "French Guiana":"GUF",
    "French Polynesia":"PYF","Gabon":"GAB",
    "Gambia":"GMB", "Georgia":"GEO", "Germany":"DEU", "Ghana":"GHA",
    "Gibraltar":"GIB", "Greece":"GRC", "Greenland":"GRL", "Grenada":"GRD",
    "Guadeloupe":"GLP", "Guam":"GUM", "Guatemala":"GTM", "Guernsey":"GGY",
    "Guinea":"GIN", "Guinea Bissau":"GNB", "Guyana":"GUY", "Haiti":"HTI","Honduras":"HND",
    "Hong Kong":"HKG",  "Hungary":"HUN", "Iceland":"ISL",
    "India":"IND", "Indonesia":"IDN", "Iran":"IRN", "Iraq":"IRQ", "Ireland":"IRL",
    "Israel":"ISR", "Italy":"ITA", "Jamaica":"JAM", "Japan":"JPN",
    "Jordan":"JOR", "Kazakhstan":"KAZ", "Kenya":"KEN",
    "Kiribati":"KIR", "Kosovo": "XKX", "Kuwait":"KWT", "Kyrgyzstan":"KGZ", "Laos":"LAO",
    "Latvia":"LVA", "Lebanon":"LBN", "Lesotho":"LSO", "Liberia":"LBR",
    "Libya":"LBY", "Liechtenstein":"LIE", "Lithuania":"LTU", "Luxembourg":"LUX",
    "Macau":"MAC", "Macedonia":"MKD", "Madagascar":"MDG", "Malawi":"MWI",
    "Malaysia":"MYS", "Maldives":"MDV", "Mali":"MLI", "Malta":"MLT", "Marshall Islands":"MHL",
    "Martinique":"MTQ", "Mauritania":"MRT", "Mauritius":"MUS",
    "Mayotte":"MYT", "Mexico":"MEX", "Micronesia":"FSM", "Moldova":"MDA",
    "Monaco":"MCO", "Mongolia":"MNG", "Montenegro":"MNE", "Montserrat":"MSR",
    "Morocco":"MAR", "Mozambique":"MOZ", "Myanmar":"MMR", "Burma":"MMR", "Namibia":"NAM",
    "Nauru":"NRU", "Nepal":"NPL", "Netherlands":"NLD", "Netherlands Antilles":"ANT",
    "New Caledonia":"NCL", "New Zealand":"NZL", "Nicaragua":"NIC",
    "Niger":"NER", "Nigeria":"NGA", "Niue":"NIU", "North Korea":"PRK",
    "Northern Ireland":"IRL", "Northern Mariana Islands":"MNP",
    "Norway":"NOR", "Oman":"OMN", "Pakistan":"PAK",
    "Palau":"PLW", "Palestine":"PSE","Panama":"PAN", "Papua New Guinea":"PNG",
    "Paraguay":"PRY", "Peru":"PER", "Philippines":"PHL", "Pitcairn Islands":"PCN",
    "Poland":"POL", "Portugal":"PRT", "Puerto Rico":"PRI",
    "Qatar":"QAT", "Réunion":"REU", "Romania":"ROU", "Russia":"RUS",
    "Rwanda":"RWA", "Saint Barthélemy":"BLM", "Saint Helena":"SHN",
    "Saint Kitts Nevis":"KNA", "Saint Lucia":"LCA",
    "Saint Pierre Miquelon":"SPM", "Saint Vincent Grenadines":"VCT",
    "Samoa":"WSM", "San Marino":"SMR", "São Tomé Príncipe":"STP", "Saudi Arabia":"SAU",
    "Senegal":"SEN", "Serbia":"SRB",
    "Seychelles":"SYC", "Sierra Leone":"SLE", "Singapore":"SGP", "Sint Maarten":"SXM",
    "Slovakia":"SVK", "Slovenia":"SVN", "Solomon Islands":"SLB",
    "Somalia":"SOM", "South Africa":"ZAF",
    "South Korea":"KOR", "South Sudan":"SSD", "Spain":"ESP", "Sri Lanka":"LKA", "Sudan":"SDN",
    "Suriname":"SUR", "Svalbard Jan Mayen":"SJM",
    "Swaziland":"SWZ", "Sweden":"SWE", "Switzerland":"CHE", "Syria":"SYR",
    "Taiwan":"TWN", "Tajikistan":"TJK", "Tanzania":"TZA", "Thailand":"THA",
    "Timor Leste":"TLS", "East Timor":"TLS","Togo":"TGO", "Tokelau":"TKL", "Tonga":"TON", "Trinidad Tobago":"TTO",
    "Tunisia":"TUN", "Turkey":"TUR",
    "Turkmenistan":"TKM", "Turks Caicos Islands":"TCA", "Tuvalu":"TUV", "U.S. Minor Outlying Islands":"UMI",
    "Virgin Islands":"VIR", "Uganda":"UGA",
    "Ukraine":"UKR", "United Arab Emirates":"ARE", "United Kingdom":"GBR",
    "United States":"USA",    "Uruguay":"URY", "Uzbekistan":"UZB", "Vanuatu":"VUT", "Vatican":"VAT",
    "Venezuela":"VEN",
    "Vietnam":"VNM", "Wallis Futuna":"WLF",
    "Western Sahara":"ESH", "Yemen":"YEM", "Zambia":"ZMB", "Zimbabwe":"ZWE",
    "UK":"GBR",  "USA":"USA", "America":"USA",  "Palestinian Territories":"PSE",
    "Congo Brazzaville":"COG", "Congo Kinshasa":"COD", "Wales" : "GBR",
    "Scotland" : "GBR", "Britain" : "GBR",}

    return cts
1048157
def generate_all(sumlevel, d):
    

    from geoid.civick import GVid
    from geoid.tiger import TigerGeoid
    from geoid.acs import AcsGeoid

    sumlevel = int(sumlevel)

    d = dict(d.items())

    # Map common name variants
    if 'cousub' in d:
        d['cosub'] = d['cousub']
        del d['cousub']

    if 'blkgrp' in d:
        d['blockgroup'] = d['blkgrp']
        del d['blkgrp']

    if 'zcta5' in d:
        d['zcta'] = d['zcta5']
        del d['zcta5']

    gvid_class = GVid.resolve_summary_level(sumlevel)

    if not gvid_class:
        return {}

    geoidt_class = TigerGeoid.resolve_summary_level(sumlevel)
    geoid_class = AcsGeoid.resolve_summary_level(sumlevel)

    try:
        return dict(
            gvid=str(gvid_class(**d)),
            geoid=str(geoid_class(**d)),
            geoidt=str(geoidt_class(**d))
        )
    except:
        raise
21199
def fetchall(self):
        
        rows = []
        while True:
            row = yield self.fetchone()
            if row is None:
                break
            rows.append(row)
        raise gen.Return(rows)