Skip to content

Commit cc6433f

Browse files
committed
fix spelling errors
1 parent 104f7c3 commit cc6433f

File tree

4 files changed

+49
-49
lines changed

4 files changed

+49
-49
lines changed

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,41 @@ pip install fifacodes
1717
You can query like using dict:
1818

1919
```pycon
20-
>>> from fifacodes import Counties
21-
>>> counties = Counties()
22-
>>> counties.get('ENG')
20+
>>> from fifacodes import Countries
21+
>>> countries = Countries()
22+
>>> countries.get('ENG')
2323
Country(code='ENG', name='England')
24-
>>> len(counties)
24+
>>> len(countries)
2525
211
26-
>>> list(counties.items())[0]
26+
>>> list(countries.items())[0]
2727
('AFG', Country(code='AFG', name='Afghanistan'))
2828
```
2929

3030
Query by name:
3131

3232
```pycon
33-
>>> counties['England']
33+
>>> countries['England']
3434
Country(code='ENG', name='England')
3535
```
3636

3737
Search for a country by name or code, the search uses fuzzy string matching to find potential results.
3838

3939
```pycon
40-
>>> counties.search('ARG')
40+
>>> countries.search('ARG')
4141
[Country(code='ARG', name='Argentina'), Country(code='AFG', name='Afghanistan'), Country(code='ALG', name='Algeria')]
4242
```
4343

4444
Results can be adjusted using parameters:
4545

4646
```pycon
47-
>>> counties.search('Fran', limit=2, score_cutoff=70)
47+
>>> countries.search('Fran', limit=2, score_cutoff=70)
4848
[Country(code='FRA', name='France'), Country(code='IRN', name='Iran')]
4949
```
5050

5151
Search for a country by name or code and return the first result.
5252

5353
```pycon
54-
>>> counties.search_one('Argent')
54+
>>> countries.search_one('Argent')
5555
Country(code='ARG', name='Argentina')
5656
```
5757

fifacodes/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Country(NamedTuple):
2020
_DataTypes = dict[str, Country]
2121

2222

23-
class Counties(Mapping[str, Country]):
23+
class Countries(Mapping[str, Country]):
2424
"""
2525
A mapping of FIFA country codes to country names.
2626
@@ -99,4 +99,4 @@ def search_one(self, key: str) -> Country | None:
9999
return None
100100

101101

102-
__all__ = ("Counties", "Country")
102+
__all__ = ("Countries", "Country")

scrape.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,30 +20,30 @@ def fetch(client: Client) -> Response:
2020

2121
def parse(response: Response) -> CountriesTypes:
2222
selector = Selector(response.text)
23-
counties: CountriesTypes = []
23+
countries: CountriesTypes = []
2424
tables = selector.xpath('//*[@id="mf-section-1"]/table')
2525
for table in tables:
2626
trs = table.xpath(".//tr")
2727
for tr in trs[1:]:
2828
code = tr.xpath("./td[2]/text()").get()
2929
name = tr.xpath("./td[1]//a/text()").get()
3030
if code and name:
31-
counties.append(Country(code=code.strip(), name=name.strip()))
32-
return counties
31+
countries.append(Country(code=code.strip(), name=name.strip()))
32+
return countries
3333

3434

35-
def export(counties: CountriesTypes) -> None:
35+
def export(countries: CountriesTypes) -> None:
3636
with open(EXPORT_PATH, "w") as f:
3737
writer = csv.writer(f)
3838
writer.writerow(Country._fields)
39-
writer.writerows(counties)
39+
writer.writerows(countries)
4040

4141

4242
def main() -> None:
4343
client = Client()
4444
response = fetch(client)
45-
counties = parse(response)
46-
export(counties)
45+
countries = parse(response)
46+
export(countries)
4747

4848

4949
if __name__ == "__main__":

tests/test_fifacodes.py

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,69 @@
11
import pytest
22

3-
from fifacodes import Counties
3+
from fifacodes import Countries
44

55

6-
class TestCounties:
6+
class TestCountries:
77
@pytest.fixture(scope="class")
8-
def counties(self) -> Counties:
9-
return Counties()
8+
def countries(self) -> Countries:
9+
return Countries()
1010

11-
def test_read_data(self, counties: Counties) -> None:
12-
assert len(counties._default_data) == 211
13-
assert len(counties._data) == 423
11+
def test_read_data(self, countries: Countries) -> None:
12+
assert len(countries._default_data) == 211
13+
assert len(countries._data) == 423
1414

15-
def test_init(self, counties: Counties) -> None:
16-
assert len(counties) == 211
15+
def test_init(self, countries: Countries) -> None:
16+
assert len(countries) == 211
1717

18-
def test_get_key(self, counties: Counties) -> None:
19-
country = counties.get("ENG")
18+
def test_get_key(self, countries: Countries) -> None:
19+
country = countries.get("ENG")
2020
if country is not None:
2121
assert country.code == "ENG"
2222
assert country.name == "England"
2323

24-
def test_get_value(self, counties: Counties) -> None:
25-
country = counties.get("England")
24+
def test_get_value(self, countries: Countries) -> None:
25+
country = countries.get("England")
2626
if country is not None:
2727
assert country.code == "ENG"
2828
assert country.name == "England"
2929

30-
def test_get_custom_value(self, counties: Counties) -> None:
31-
country = counties["China PR"]
30+
def test_get_custom_value(self, countries: Countries) -> None:
31+
country = countries["China PR"]
3232
assert country.code == "CHN"
3333
assert country.name == "China"
3434

35-
def test_get_none(self, counties: Counties) -> None:
36-
country = counties.get("foo")
35+
def test_get_none(self, countries: Countries) -> None:
36+
country = countries.get("foo")
3737
assert country is None
3838

39-
def test_raise_keyerror(self, counties: Counties) -> None:
39+
def test_raise_keyerror(self, countries: Countries) -> None:
4040
with pytest.raises(KeyError):
41-
counties["foo"]
41+
countries["foo"]
4242

43-
def test_search(self, counties: Counties) -> None:
44-
results = counties.search("ENG")
43+
def test_search(self, countries: Countries) -> None:
44+
results = countries.search("ENG")
4545
assert len(results) == 3
4646
country = results[0]
4747
assert country.name == "England"
4848

49-
def test_search_limit_one(self, counties: Counties) -> None:
50-
results = counties.search("ENG", limit=1)
49+
def test_search_limit_one(self, countries: Countries) -> None:
50+
results = countries.search("ENG", limit=1)
5151
assert len(results) == 1
5252

53-
def test_search_score_cutoff(self, counties: Counties) -> None:
54-
results = counties.search("ENG", score_cutoff=90.0)
53+
def test_search_score_cutoff(self, countries: Countries) -> None:
54+
results = countries.search("ENG", score_cutoff=90.0)
5555
assert len(results) == 1
5656

57-
def test_search_none(self, counties: Counties) -> None:
58-
results = counties.search("foobar")
57+
def test_search_none(self, countries: Countries) -> None:
58+
results = countries.search("foobar")
5959
assert len(results) == 0
6060

61-
def test_search_one(self, counties: Counties) -> None:
62-
country = counties.search_one("ENG")
61+
def test_search_one(self, countries: Countries) -> None:
62+
country = countries.search_one("ENG")
6363
assert country is not None
6464
assert country.code == "ENG"
6565
assert country.name == "England"
6666

67-
def test_search_one_none(self, counties: Counties) -> None:
68-
country = counties.search_one("foobar")
67+
def test_search_one_none(self, countries: Countries) -> None:
68+
country = countries.search_one("foobar")
6969
assert country is None

0 commit comments

Comments
 (0)