summaryrefslogtreecommitdiff
path: root/python-ip2location.spec
blob: ba0ff32915c95a02f367e0b1d3abe5f9039e4661 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
%global _empty_manifest_terminate_build 0
Name:		python-IP2Location
Version:	8.9.0
Release:	1
Summary:	This is an IP geolocation library that enables the user to find the country, region, city, latitude and longitude, ZIP code, time zone, ISP, domain name, area code, weather info, mobile info, elevation, usage type, address type and IAB category from an IP address. It supports both IPv4 and IPv6 lookup.
License:	MIT License
URL:		https://github.com/chrislim2888/ip2location-python
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/11/9c/4d3856df231385ab5bafe1df68d8a794afb49f6444e33035a514e3b34d4e/IP2Location-8.9.0.tar.gz
BuildArch:	noarch


%description
# IP2Location 8.9.0


This is a IP2Location Python library that enables the user to find the country, region or state, city, latitude and longitude, ZIP code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type and IAB category by IP address or hostname originates from. The library reads the geo location information from **IP2Location BIN data** file.

Supported IPv4 and IPv6 address.

For more details, please visit:
[https://www.ip2location.com/developers/python](https://www.ip2location.com/developers/python)

# Requirements

1. Python 3.5 and above.

# Installation

1. Unzip the package.
2. Execute python setup.py build
3. Execute python setup.py install

or

To install this module type the following (for PyPI):

```bash
pip install IP2Location
```

# Usage

You can check the **sample.py** file to learn more about usage.

## BIN Database

Below is the description of the functions available in the **BIN Database** lookup.

| Method Name       | Description                                                  |
| ----------------- | ------------------------------------------------------------ |
| open              | Open the IP2Location BIN data for lookup. Default mode: File I/O. |
| close             | Close and clean up the file pointer.                         |
| get_all           | Return the geolocation information in array.                 |
| get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
| get_country_long  | Return the ISO3166-1 country name of the IP address.         |
| get_region        | Return the ISO3166-2 region name of the IP address. Please visit [ISO3166-2 Subdivision Code](https://www.ip2location.com/free/iso3166-2) for the information of ISO3166-2 supported |
| get_city          | Return the city name of the IP address.                      |
| get_latitude      | Return the city latitude of the IP address.                  |
| get_longitude     | Return the city longtitude of the IP address.                |
| get_isp           | Return the ISP name of the IP address.                       |
| get_domain        | Return the domain name of IP address.                        |
| get_zipcode       | Return the zipcode of the city.                              |
| get_timezone      | Return the UTC time zone (with DST supported).               |
| get_netspeed      | Return the Internet connection type. Please see [Internet Connection Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#internet-connection-type) for details. |
| get_idd_code      | Return the IDD prefix to call the city from another country. |
| get_area_code     | Return the area code of the city.                            |
| get_weather_code  | Return the nearest weather observation station code.         |
| get_weather_name  | Return the nearest weather observation station name.         |
| get_mcc           | Return the Mobile Country Codes (MCC).                       |
| get_mnc           | Return the Mobile Network Code (MNC).                        |
| get_mobile_brand  | Commercial brand associated with the mobile carrier. Please visit [Mobile Carrier Coverage](https://www.ip2location.com/mobile-carrier-coverage) to view the coverage report. |
| get_elevation     | Return average height of city above sea level in meters (m). |
| get_usage_type    | Return the ISP's usage type of IP address. Please see [Usage Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#usage-type) for details. |
| get_address_type  | Return the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
| get_category      | Return the IAB content taxonomy category of IP address or domain name. You can get a full list of IAB content taxonomy category from [here](https://www.ip2location.com/free/iab-categories). |

## Web Service

Below is the description of the functions available in the **Web Service** lookup.

| Function Name | Description                                                  |
| ------------- | ------------------------------------------------------------ |
| Constructor   | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS25)</li><li>Use HTTPS or HTTP</li></ol> |
| lookup        | Return the IP information in array.  <ul><li>country_code</li><li>country_name</li><li>region_name</li><li>city_name</li><li>latitude</li><li>longitude</li><li>zip_code</li><li>time_zone</li><li>isp</li><li>domain</li><li>net_speed</li><li>idd_code</li><li>area_code</li><li>weather_station_code</li><li>weather_station_name</li><li>mcc</li><li>mnc</li><li>mobile_brand</li><li>elevation</li><li>usage_type</li><li>address_type</li><li>category</li><li>category_name</li><li>continent<ul><li>name</li><li>code</li><li>hemisphere</li><li>translations</li></ul></li><li>country<ul><li>name</li><li>alpha3_code</li><li>numeric_code</li><li>demonym</li><li>flag</li><li>capital</li><li>total_area</li><li>population</li><li>currency<ul><li>code</li><li>name</li><li>symbol</li></ul></li><li>language<ul><li>code</li><li>name</li></ul></li><li>idd_code</li><li>tld</li><li>translations</li></ul></li><li>region<ul><li>name</li><li>code</li><li>translations</li></ul></li><li>city<ul><li>name</li><li>translations</li></ul></li><li>geotargeting<ul><li>metro</li></ul></li><li>country_groupings</li><li>time_zone_info<ul><li>olson</li><li>current_time</li><li>gmt_offset</li><li>is_dst</li><li>sunrise</li><li>sunset</li></ul></li><ul> |
| get_credit    | Return remaining credit of the web service account.          |

### IP Tools

Below is the description of the functions available in the **IP Tools** class.

| Function Name   | Description                                                  |
| --------------- | ------------------------------------------------------------ |
| is_ipv4         | Return either **true** or **false**. Verify if a string is a valid IPv4 address. |
| is_ipv6         | Return either **true** or **false**. Verify if a string is a valid IPv6 address. |
| ipv4_to_decimal | Translate IPv4 address from dotted-decimal address to decimal format. |
| decimal_to_ipv4 | Translate IPv4 address from decimal number to dotted-decimal address. |
| ipv6_to_decimal | Translate IPv6 address from hexadecimal address to decimal format. |
| decimal_to_ipv6 | Translate IPv6 address from decimal number into hexadecimal address. |
| ipv4_to_cidr    | Convert IPv4 range into a list of IPv4 CIDR notation.        |
| cidr_to_ipv4    | Convert IPv4 CIDR notation into a list of IPv4 addresses.    |
| ipv6_to_cidr    | Convert IPv6 range into a list of IPv6 CIDR notation.        |
| cidr_to_ipv6    | Convert IPv6 CIDR notation into a list of IPv6 addresses.    |
| compressed_ipv6 | Compress a IPv6 to shorten the length.                       |
| expand_ipv6     | Expand a shorten IPv6 to full length.                       

### Country Class

Below is the description of the functions available in the **Country** class.

| Function Name                          | Description                                                  |
| -------------------------------------- | ------------------------------------------------------------ |
| Constructor                            | Expect a IP2Location Country Information CSV file. This database is free for download at https://www.ip2location.com/free/country-information |
| get_country_info | Provide a ISO 3166 country code to get the country information in array. Will return a full list of countries information if country code not provided. Below is the information returned: <ul><li>country_code</li><li>country_alpha3_code</li><li>country_numeric_code</li><li>capital</li><li>country_demonym</li><li>total_area</li><li>population</li><li>idd_code</li><li>currency_code</li><li>currency_name</li><li>currency_symbol</li><li>lang_code</li><li>lang_name</li><li>cctld</li></ul> |

### Region Class

Below is the description of the functions available in the **Region** class.

| Function Name                                       | Description                                                  |
| --------------------------------------------------- | ------------------------------------------------------------ |
| Constructor                                         | Expect a IP2Location ISO 3166-2 Subdivision Code CSV file. This database is free for download at https://www.ip2location.com/free/iso3166-2 |
| get_region_code | Provide a ISO 3166 country code and the region name to get ISO 3166-2 subdivision code for the region. | |

# Testing

    python sample.py
    python test.py
    python lookup.py <ip_address>

# Sample BIN Databases
* Download free IP2Location LITE databases at [https://lite.ip2location.com](https://lite.ip2location.com)  
* Download IP2Location sample databases at [https://www.ip2location.com/developers](https://www.ip2location.com/developers)

# IPv4 BIN vs IPv6 BIN
* Use the IPv4 BIN file if you just need to query IPv4 addresses.
* Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.

# Internet Connection Type

| Internet Connection Type | Description                  |
| ------------------------ | ---------------------------- |
| DIAL                     | Dial Up                      |
| DSL                      | Broadband/Cable/Fiber/Mobile |
| COMP                     | Company/T1                   |

# Usage Type

| Usage Type | Description                     |
| ---------- | ------------------------------- |
| COM        | Commercial                      |
| ORG        | Organization                    |
| GOV        | Government                      |
| MIL        | Military                        |
| EDU        | University/College/School       |
| LIB        | Library                         |
| CDN        | Content Delivery Network        |
| ISP        | Fixed Line ISP                  |
| MOB        | Mobile ISP                      |
| DCH        | Data Center/Web Hosting/Transit |
| SES        | Search Engine Spider            |
| RSV        | Reserved                        |

# Support

Email: support@ip2location.com.  
URL: [https://www.ip2location.com](https://www.ip2location.com)


%package -n python3-IP2Location
Summary:	This is an IP geolocation library that enables the user to find the country, region, city, latitude and longitude, ZIP code, time zone, ISP, domain name, area code, weather info, mobile info, elevation, usage type, address type and IAB category from an IP address. It supports both IPv4 and IPv6 lookup.
Provides:	python-IP2Location
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-IP2Location
# IP2Location 8.9.0


This is a IP2Location Python library that enables the user to find the country, region or state, city, latitude and longitude, ZIP code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type and IAB category by IP address or hostname originates from. The library reads the geo location information from **IP2Location BIN data** file.

Supported IPv4 and IPv6 address.

For more details, please visit:
[https://www.ip2location.com/developers/python](https://www.ip2location.com/developers/python)

# Requirements

1. Python 3.5 and above.

# Installation

1. Unzip the package.
2. Execute python setup.py build
3. Execute python setup.py install

or

To install this module type the following (for PyPI):

```bash
pip install IP2Location
```

# Usage

You can check the **sample.py** file to learn more about usage.

## BIN Database

Below is the description of the functions available in the **BIN Database** lookup.

| Method Name       | Description                                                  |
| ----------------- | ------------------------------------------------------------ |
| open              | Open the IP2Location BIN data for lookup. Default mode: File I/O. |
| close             | Close and clean up the file pointer.                         |
| get_all           | Return the geolocation information in array.                 |
| get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
| get_country_long  | Return the ISO3166-1 country name of the IP address.         |
| get_region        | Return the ISO3166-2 region name of the IP address. Please visit [ISO3166-2 Subdivision Code](https://www.ip2location.com/free/iso3166-2) for the information of ISO3166-2 supported |
| get_city          | Return the city name of the IP address.                      |
| get_latitude      | Return the city latitude of the IP address.                  |
| get_longitude     | Return the city longtitude of the IP address.                |
| get_isp           | Return the ISP name of the IP address.                       |
| get_domain        | Return the domain name of IP address.                        |
| get_zipcode       | Return the zipcode of the city.                              |
| get_timezone      | Return the UTC time zone (with DST supported).               |
| get_netspeed      | Return the Internet connection type. Please see [Internet Connection Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#internet-connection-type) for details. |
| get_idd_code      | Return the IDD prefix to call the city from another country. |
| get_area_code     | Return the area code of the city.                            |
| get_weather_code  | Return the nearest weather observation station code.         |
| get_weather_name  | Return the nearest weather observation station name.         |
| get_mcc           | Return the Mobile Country Codes (MCC).                       |
| get_mnc           | Return the Mobile Network Code (MNC).                        |
| get_mobile_brand  | Commercial brand associated with the mobile carrier. Please visit [Mobile Carrier Coverage](https://www.ip2location.com/mobile-carrier-coverage) to view the coverage report. |
| get_elevation     | Return average height of city above sea level in meters (m). |
| get_usage_type    | Return the ISP's usage type of IP address. Please see [Usage Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#usage-type) for details. |
| get_address_type  | Return the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
| get_category      | Return the IAB content taxonomy category of IP address or domain name. You can get a full list of IAB content taxonomy category from [here](https://www.ip2location.com/free/iab-categories). |

## Web Service

Below is the description of the functions available in the **Web Service** lookup.

| Function Name | Description                                                  |
| ------------- | ------------------------------------------------------------ |
| Constructor   | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS25)</li><li>Use HTTPS or HTTP</li></ol> |
| lookup        | Return the IP information in array.  <ul><li>country_code</li><li>country_name</li><li>region_name</li><li>city_name</li><li>latitude</li><li>longitude</li><li>zip_code</li><li>time_zone</li><li>isp</li><li>domain</li><li>net_speed</li><li>idd_code</li><li>area_code</li><li>weather_station_code</li><li>weather_station_name</li><li>mcc</li><li>mnc</li><li>mobile_brand</li><li>elevation</li><li>usage_type</li><li>address_type</li><li>category</li><li>category_name</li><li>continent<ul><li>name</li><li>code</li><li>hemisphere</li><li>translations</li></ul></li><li>country<ul><li>name</li><li>alpha3_code</li><li>numeric_code</li><li>demonym</li><li>flag</li><li>capital</li><li>total_area</li><li>population</li><li>currency<ul><li>code</li><li>name</li><li>symbol</li></ul></li><li>language<ul><li>code</li><li>name</li></ul></li><li>idd_code</li><li>tld</li><li>translations</li></ul></li><li>region<ul><li>name</li><li>code</li><li>translations</li></ul></li><li>city<ul><li>name</li><li>translations</li></ul></li><li>geotargeting<ul><li>metro</li></ul></li><li>country_groupings</li><li>time_zone_info<ul><li>olson</li><li>current_time</li><li>gmt_offset</li><li>is_dst</li><li>sunrise</li><li>sunset</li></ul></li><ul> |
| get_credit    | Return remaining credit of the web service account.          |

### IP Tools

Below is the description of the functions available in the **IP Tools** class.

| Function Name   | Description                                                  |
| --------------- | ------------------------------------------------------------ |
| is_ipv4         | Return either **true** or **false**. Verify if a string is a valid IPv4 address. |
| is_ipv6         | Return either **true** or **false**. Verify if a string is a valid IPv6 address. |
| ipv4_to_decimal | Translate IPv4 address from dotted-decimal address to decimal format. |
| decimal_to_ipv4 | Translate IPv4 address from decimal number to dotted-decimal address. |
| ipv6_to_decimal | Translate IPv6 address from hexadecimal address to decimal format. |
| decimal_to_ipv6 | Translate IPv6 address from decimal number into hexadecimal address. |
| ipv4_to_cidr    | Convert IPv4 range into a list of IPv4 CIDR notation.        |
| cidr_to_ipv4    | Convert IPv4 CIDR notation into a list of IPv4 addresses.    |
| ipv6_to_cidr    | Convert IPv6 range into a list of IPv6 CIDR notation.        |
| cidr_to_ipv6    | Convert IPv6 CIDR notation into a list of IPv6 addresses.    |
| compressed_ipv6 | Compress a IPv6 to shorten the length.                       |
| expand_ipv6     | Expand a shorten IPv6 to full length.                       

### Country Class

Below is the description of the functions available in the **Country** class.

| Function Name                          | Description                                                  |
| -------------------------------------- | ------------------------------------------------------------ |
| Constructor                            | Expect a IP2Location Country Information CSV file. This database is free for download at https://www.ip2location.com/free/country-information |
| get_country_info | Provide a ISO 3166 country code to get the country information in array. Will return a full list of countries information if country code not provided. Below is the information returned: <ul><li>country_code</li><li>country_alpha3_code</li><li>country_numeric_code</li><li>capital</li><li>country_demonym</li><li>total_area</li><li>population</li><li>idd_code</li><li>currency_code</li><li>currency_name</li><li>currency_symbol</li><li>lang_code</li><li>lang_name</li><li>cctld</li></ul> |

### Region Class

Below is the description of the functions available in the **Region** class.

| Function Name                                       | Description                                                  |
| --------------------------------------------------- | ------------------------------------------------------------ |
| Constructor                                         | Expect a IP2Location ISO 3166-2 Subdivision Code CSV file. This database is free for download at https://www.ip2location.com/free/iso3166-2 |
| get_region_code | Provide a ISO 3166 country code and the region name to get ISO 3166-2 subdivision code for the region. | |

# Testing

    python sample.py
    python test.py
    python lookup.py <ip_address>

# Sample BIN Databases
* Download free IP2Location LITE databases at [https://lite.ip2location.com](https://lite.ip2location.com)  
* Download IP2Location sample databases at [https://www.ip2location.com/developers](https://www.ip2location.com/developers)

# IPv4 BIN vs IPv6 BIN
* Use the IPv4 BIN file if you just need to query IPv4 addresses.
* Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.

# Internet Connection Type

| Internet Connection Type | Description                  |
| ------------------------ | ---------------------------- |
| DIAL                     | Dial Up                      |
| DSL                      | Broadband/Cable/Fiber/Mobile |
| COMP                     | Company/T1                   |

# Usage Type

| Usage Type | Description                     |
| ---------- | ------------------------------- |
| COM        | Commercial                      |
| ORG        | Organization                    |
| GOV        | Government                      |
| MIL        | Military                        |
| EDU        | University/College/School       |
| LIB        | Library                         |
| CDN        | Content Delivery Network        |
| ISP        | Fixed Line ISP                  |
| MOB        | Mobile ISP                      |
| DCH        | Data Center/Web Hosting/Transit |
| SES        | Search Engine Spider            |
| RSV        | Reserved                        |

# Support

Email: support@ip2location.com.  
URL: [https://www.ip2location.com](https://www.ip2location.com)


%package help
Summary:	Development documents and examples for IP2Location
Provides:	python3-IP2Location-doc
%description help
# IP2Location 8.9.0


This is a IP2Location Python library that enables the user to find the country, region or state, city, latitude and longitude, ZIP code, time zone, Internet Service Provider (ISP) or company name, domain name, net speed, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC) and carrier brand, elevation, usage type, address type and IAB category by IP address or hostname originates from. The library reads the geo location information from **IP2Location BIN data** file.

Supported IPv4 and IPv6 address.

For more details, please visit:
[https://www.ip2location.com/developers/python](https://www.ip2location.com/developers/python)

# Requirements

1. Python 3.5 and above.

# Installation

1. Unzip the package.
2. Execute python setup.py build
3. Execute python setup.py install

or

To install this module type the following (for PyPI):

```bash
pip install IP2Location
```

# Usage

You can check the **sample.py** file to learn more about usage.

## BIN Database

Below is the description of the functions available in the **BIN Database** lookup.

| Method Name       | Description                                                  |
| ----------------- | ------------------------------------------------------------ |
| open              | Open the IP2Location BIN data for lookup. Default mode: File I/O. |
| close             | Close and clean up the file pointer.                         |
| get_all           | Return the geolocation information in array.                 |
| get_country_short | Return the ISO3166-1 country code (2-digits) of the IP address. |
| get_country_long  | Return the ISO3166-1 country name of the IP address.         |
| get_region        | Return the ISO3166-2 region name of the IP address. Please visit [ISO3166-2 Subdivision Code](https://www.ip2location.com/free/iso3166-2) for the information of ISO3166-2 supported |
| get_city          | Return the city name of the IP address.                      |
| get_latitude      | Return the city latitude of the IP address.                  |
| get_longitude     | Return the city longtitude of the IP address.                |
| get_isp           | Return the ISP name of the IP address.                       |
| get_domain        | Return the domain name of IP address.                        |
| get_zipcode       | Return the zipcode of the city.                              |
| get_timezone      | Return the UTC time zone (with DST supported).               |
| get_netspeed      | Return the Internet connection type. Please see [Internet Connection Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#internet-connection-type) for details. |
| get_idd_code      | Return the IDD prefix to call the city from another country. |
| get_area_code     | Return the area code of the city.                            |
| get_weather_code  | Return the nearest weather observation station code.         |
| get_weather_name  | Return the nearest weather observation station name.         |
| get_mcc           | Return the Mobile Country Codes (MCC).                       |
| get_mnc           | Return the Mobile Network Code (MNC).                        |
| get_mobile_brand  | Commercial brand associated with the mobile carrier. Please visit [Mobile Carrier Coverage](https://www.ip2location.com/mobile-carrier-coverage) to view the coverage report. |
| get_elevation     | Return average height of city above sea level in meters (m). |
| get_usage_type    | Return the ISP's usage type of IP address. Please see [Usage Type](https://github.com/[chrislim2888/IP2Location-Python](https://github.com/chrislim2888/IP2Location-Python)#usage-type) for details. |
| get_address_type  | Return the IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name. |
| get_category      | Return the IAB content taxonomy category of IP address or domain name. You can get a full list of IAB content taxonomy category from [here](https://www.ip2location.com/free/iab-categories). |

## Web Service

Below is the description of the functions available in the **Web Service** lookup.

| Function Name | Description                                                  |
| ------------- | ------------------------------------------------------------ |
| Constructor   | Expect 3 input parameters:<ol><li>IP2Location API Key.</li><li>Package (WS1 - WS25)</li><li>Use HTTPS or HTTP</li></ol> |
| lookup        | Return the IP information in array.  <ul><li>country_code</li><li>country_name</li><li>region_name</li><li>city_name</li><li>latitude</li><li>longitude</li><li>zip_code</li><li>time_zone</li><li>isp</li><li>domain</li><li>net_speed</li><li>idd_code</li><li>area_code</li><li>weather_station_code</li><li>weather_station_name</li><li>mcc</li><li>mnc</li><li>mobile_brand</li><li>elevation</li><li>usage_type</li><li>address_type</li><li>category</li><li>category_name</li><li>continent<ul><li>name</li><li>code</li><li>hemisphere</li><li>translations</li></ul></li><li>country<ul><li>name</li><li>alpha3_code</li><li>numeric_code</li><li>demonym</li><li>flag</li><li>capital</li><li>total_area</li><li>population</li><li>currency<ul><li>code</li><li>name</li><li>symbol</li></ul></li><li>language<ul><li>code</li><li>name</li></ul></li><li>idd_code</li><li>tld</li><li>translations</li></ul></li><li>region<ul><li>name</li><li>code</li><li>translations</li></ul></li><li>city<ul><li>name</li><li>translations</li></ul></li><li>geotargeting<ul><li>metro</li></ul></li><li>country_groupings</li><li>time_zone_info<ul><li>olson</li><li>current_time</li><li>gmt_offset</li><li>is_dst</li><li>sunrise</li><li>sunset</li></ul></li><ul> |
| get_credit    | Return remaining credit of the web service account.          |

### IP Tools

Below is the description of the functions available in the **IP Tools** class.

| Function Name   | Description                                                  |
| --------------- | ------------------------------------------------------------ |
| is_ipv4         | Return either **true** or **false**. Verify if a string is a valid IPv4 address. |
| is_ipv6         | Return either **true** or **false**. Verify if a string is a valid IPv6 address. |
| ipv4_to_decimal | Translate IPv4 address from dotted-decimal address to decimal format. |
| decimal_to_ipv4 | Translate IPv4 address from decimal number to dotted-decimal address. |
| ipv6_to_decimal | Translate IPv6 address from hexadecimal address to decimal format. |
| decimal_to_ipv6 | Translate IPv6 address from decimal number into hexadecimal address. |
| ipv4_to_cidr    | Convert IPv4 range into a list of IPv4 CIDR notation.        |
| cidr_to_ipv4    | Convert IPv4 CIDR notation into a list of IPv4 addresses.    |
| ipv6_to_cidr    | Convert IPv6 range into a list of IPv6 CIDR notation.        |
| cidr_to_ipv6    | Convert IPv6 CIDR notation into a list of IPv6 addresses.    |
| compressed_ipv6 | Compress a IPv6 to shorten the length.                       |
| expand_ipv6     | Expand a shorten IPv6 to full length.                       

### Country Class

Below is the description of the functions available in the **Country** class.

| Function Name                          | Description                                                  |
| -------------------------------------- | ------------------------------------------------------------ |
| Constructor                            | Expect a IP2Location Country Information CSV file. This database is free for download at https://www.ip2location.com/free/country-information |
| get_country_info | Provide a ISO 3166 country code to get the country information in array. Will return a full list of countries information if country code not provided. Below is the information returned: <ul><li>country_code</li><li>country_alpha3_code</li><li>country_numeric_code</li><li>capital</li><li>country_demonym</li><li>total_area</li><li>population</li><li>idd_code</li><li>currency_code</li><li>currency_name</li><li>currency_symbol</li><li>lang_code</li><li>lang_name</li><li>cctld</li></ul> |

### Region Class

Below is the description of the functions available in the **Region** class.

| Function Name                                       | Description                                                  |
| --------------------------------------------------- | ------------------------------------------------------------ |
| Constructor                                         | Expect a IP2Location ISO 3166-2 Subdivision Code CSV file. This database is free for download at https://www.ip2location.com/free/iso3166-2 |
| get_region_code | Provide a ISO 3166 country code and the region name to get ISO 3166-2 subdivision code for the region. | |

# Testing

    python sample.py
    python test.py
    python lookup.py <ip_address>

# Sample BIN Databases
* Download free IP2Location LITE databases at [https://lite.ip2location.com](https://lite.ip2location.com)  
* Download IP2Location sample databases at [https://www.ip2location.com/developers](https://www.ip2location.com/developers)

# IPv4 BIN vs IPv6 BIN
* Use the IPv4 BIN file if you just need to query IPv4 addresses.
* Use the IPv6 BIN file if you need to query BOTH IPv4 and IPv6 addresses.

# Internet Connection Type

| Internet Connection Type | Description                  |
| ------------------------ | ---------------------------- |
| DIAL                     | Dial Up                      |
| DSL                      | Broadband/Cable/Fiber/Mobile |
| COMP                     | Company/T1                   |

# Usage Type

| Usage Type | Description                     |
| ---------- | ------------------------------- |
| COM        | Commercial                      |
| ORG        | Organization                    |
| GOV        | Government                      |
| MIL        | Military                        |
| EDU        | University/College/School       |
| LIB        | Library                         |
| CDN        | Content Delivery Network        |
| ISP        | Fixed Line ISP                  |
| MOB        | Mobile ISP                      |
| DCH        | Data Center/Web Hosting/Transit |
| SES        | Search Engine Spider            |
| RSV        | Reserved                        |

# Support

Email: support@ip2location.com.  
URL: [https://www.ip2location.com](https://www.ip2location.com)


%prep
%autosetup -n IP2Location-8.9.0

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-IP2Location -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Tue Apr 11 2023 Python_Bot <Python_Bot@openeuler.org> - 8.9.0-1
- Package Spec generated