fiftyone-ipintelligence-shared 4.5.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fiftyone_ipintelligence_shared-4.5.0/MANIFEST.in +2 -0
- fiftyone_ipintelligence_shared-4.5.0/PKG-INFO +64 -0
- fiftyone_ipintelligence_shared-4.5.0/pyproject.toml +3 -0
- fiftyone_ipintelligence_shared-4.5.0/readme.md +28 -0
- fiftyone_ipintelligence_shared-4.5.0/setup.cfg +4 -0
- fiftyone_ipintelligence_shared-4.5.0/setup.py +71 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared/__init__.py +0 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared/constants.py +52 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared/example_constants.py +49 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared/key_utils.py +31 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared/utils.py +51 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared.egg-info/PKG-INFO +64 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared.egg-info/SOURCES.txt +16 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared.egg-info/dependency_links.txt +1 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared.egg-info/requires.txt +4 -0
- fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared.egg-info/top_level.txt +1 -0
- fiftyone_ipintelligence_shared-4.5.0/tests/test_shared.py +51 -0
- fiftyone_ipintelligence_shared-4.5.0/version.txt +1 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fiftyone_ipintelligence_shared
|
|
3
|
+
Version: 4.5.0
|
|
4
|
+
Summary: Shared code used by the cloud and on-premise variants of the 51Degrees IP Intelligence engines for the 51Degrees Pipeline API.
|
|
5
|
+
Home-page: https://51degrees.com/?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-setup.py&utm_term=url
|
|
6
|
+
Author: 51Degrees Engineering
|
|
7
|
+
Author-email: engineering@51degrees.com
|
|
8
|
+
License: EUPL-1.2
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: fiftyone_pipeline_core
|
|
23
|
+
Requires-Dist: fiftyone_pipeline_engines
|
|
24
|
+
Requires-Dist: fiftyone_pipeline_cloudrequestengine
|
|
25
|
+
Requires-Dist: fiftyone_pipeline_engines_fiftyone
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: home-page
|
|
32
|
+
Dynamic: license
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
# 51Degrees IP Intelligence Engines - Shared
|
|
38
|
+
|
|
39
|
+
 **Python IP Intelligence**
|
|
40
|
+
|
|
41
|
+
[Developer Documentation](https://51degrees.com/ip-intelligence-python/index.html?utm_source=github&utm_medium=readme&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-readme.md&utm_term=51degrees-ip-intelligence-engines-shared "developer documentation")
|
|
42
|
+
|
|
43
|
+
## Introduction
|
|
44
|
+
|
|
45
|
+
This package contains shared code used by both the cloud and on-premise
|
|
46
|
+
variants of the 51Degrees IP intelligence engines for the
|
|
47
|
+
[51Degrees Pipeline API](https://51degrees.com/documentation/index.html?utm_source=github&utm_medium=readme&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-readme.md&utm_term=introduction).
|
|
48
|
+
|
|
49
|
+
It is not intended to be used directly. See
|
|
50
|
+
[fiftyone_ipintelligence](https://pypi.org/project/fiftyone-ipintelligence/)
|
|
51
|
+
instead.
|
|
52
|
+
|
|
53
|
+
## Folders
|
|
54
|
+
|
|
55
|
+
- `fiftyone_ipintelligence_shared` - contains evidence key constants, example
|
|
56
|
+
constants and utility functions shared by the IP intelligence packages.
|
|
57
|
+
- `tests` - unit tests.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
* Python 3.8+
|
|
62
|
+
* The `fiftyone_pipeline_core`, `fiftyone_pipeline_engines`,
|
|
63
|
+
`fiftyone_pipeline_cloudrequestengine` and
|
|
64
|
+
`fiftyone_pipeline_engines_fiftyone` packages
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# 51Degrees IP Intelligence Engines - Shared
|
|
2
|
+
|
|
3
|
+
 **Python IP Intelligence**
|
|
4
|
+
|
|
5
|
+
[Developer Documentation](https://51degrees.com/ip-intelligence-python/index.html?utm_source=github&utm_medium=readme&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-readme.md&utm_term=51degrees-ip-intelligence-engines-shared "developer documentation")
|
|
6
|
+
|
|
7
|
+
## Introduction
|
|
8
|
+
|
|
9
|
+
This package contains shared code used by both the cloud and on-premise
|
|
10
|
+
variants of the 51Degrees IP intelligence engines for the
|
|
11
|
+
[51Degrees Pipeline API](https://51degrees.com/documentation/index.html?utm_source=github&utm_medium=readme&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-readme.md&utm_term=introduction).
|
|
12
|
+
|
|
13
|
+
It is not intended to be used directly. See
|
|
14
|
+
[fiftyone_ipintelligence](https://pypi.org/project/fiftyone-ipintelligence/)
|
|
15
|
+
instead.
|
|
16
|
+
|
|
17
|
+
## Folders
|
|
18
|
+
|
|
19
|
+
- `fiftyone_ipintelligence_shared` - contains evidence key constants, example
|
|
20
|
+
constants and utility functions shared by the IP intelligence packages.
|
|
21
|
+
- `tests` - unit tests.
|
|
22
|
+
|
|
23
|
+
## Requirements
|
|
24
|
+
|
|
25
|
+
* Python 3.8+
|
|
26
|
+
* The `fiftyone_pipeline_core`, `fiftyone_pipeline_engines`,
|
|
27
|
+
`fiftyone_pipeline_cloudrequestengine` and
|
|
28
|
+
`fiftyone_pipeline_engines_fiftyone` packages
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# *********************************************************************
|
|
2
|
+
# This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
|
|
4
|
+
# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
|
|
5
|
+
#
|
|
6
|
+
# This Original Work is licensed under the European Union Public Licence
|
|
7
|
+
# (EUPL) v.1.2 and is subject to its terms as set out below.
|
|
8
|
+
#
|
|
9
|
+
# If a copy of the EUPL was not distributed with this file, You can obtain
|
|
10
|
+
# one at https://opensource.org/licenses/EUPL-1.2.
|
|
11
|
+
#
|
|
12
|
+
# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
|
|
13
|
+
# amended by the European Commission) shall be deemed incompatible for
|
|
14
|
+
# the purposes of the Work and the provisions of the compatibility
|
|
15
|
+
# clause in Article 5 of the EUPL shall not apply.
|
|
16
|
+
#
|
|
17
|
+
# If using the Work as, or as part of, a network application, by
|
|
18
|
+
# including the attribution notice(s) required under Article 5 of the EUPL
|
|
19
|
+
# in the end user terms of the application under an appropriate heading,
|
|
20
|
+
# such notice(s) shall fulfill the requirements of that article.
|
|
21
|
+
# *********************************************************************
|
|
22
|
+
|
|
23
|
+
import setuptools
|
|
24
|
+
import io
|
|
25
|
+
import os
|
|
26
|
+
|
|
27
|
+
def read(file_name):
|
|
28
|
+
|
|
29
|
+
"""Read a text file and return the content as a string."""
|
|
30
|
+
try:
|
|
31
|
+
with io.open(
|
|
32
|
+
os.path.join(os.path.dirname(__file__), file_name), encoding="utf-8"
|
|
33
|
+
) as f:
|
|
34
|
+
return f.read().strip()
|
|
35
|
+
except:
|
|
36
|
+
return "0.0.0"
|
|
37
|
+
|
|
38
|
+
setuptools.setup(
|
|
39
|
+
name="fiftyone_ipintelligence_shared",
|
|
40
|
+
version=read("version.txt"),
|
|
41
|
+
author="51Degrees Engineering",
|
|
42
|
+
author_email="engineering@51degrees.com",
|
|
43
|
+
url="https://51degrees.com/?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-setup.py&utm_term=url",
|
|
44
|
+
description=("Shared code used by the cloud and on-premise variants of the 51Degrees IP Intelligence engines for the 51Degrees Pipeline API."),
|
|
45
|
+
long_description=read("readme.md"),
|
|
46
|
+
long_description_content_type='text/markdown',
|
|
47
|
+
python_requires=">=3.10",
|
|
48
|
+
packages=["fiftyone_ipintelligence_shared"],
|
|
49
|
+
package_dir={"": "src"},
|
|
50
|
+
install_requires=[
|
|
51
|
+
"fiftyone_pipeline_core",
|
|
52
|
+
"fiftyone_pipeline_engines",
|
|
53
|
+
"fiftyone_pipeline_cloudrequestengine",
|
|
54
|
+
"fiftyone_pipeline_engines_fiftyone"
|
|
55
|
+
],
|
|
56
|
+
license="EUPL-1.2",
|
|
57
|
+
classifiers=[
|
|
58
|
+
"Development Status :: 5 - Production/Stable",
|
|
59
|
+
"Programming Language :: Python",
|
|
60
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
61
|
+
"Programming Language :: Python :: 3.10",
|
|
62
|
+
"Programming Language :: Python :: 3.11",
|
|
63
|
+
"Programming Language :: Python :: 3.12",
|
|
64
|
+
"Programming Language :: Python :: 3.13",
|
|
65
|
+
"Programming Language :: Python :: 3.14",
|
|
66
|
+
"License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)",
|
|
67
|
+
"Operating System :: OS Independent",
|
|
68
|
+
"Topic :: Software Development :: Libraries :: Python Modules"
|
|
69
|
+
],
|
|
70
|
+
include_package_data=True
|
|
71
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# *********************************************************************
|
|
2
|
+
# This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
|
|
4
|
+
# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
|
|
5
|
+
#
|
|
6
|
+
# This Original Work is licensed under the European Union Public Licence
|
|
7
|
+
# (EUPL) v.1.2 and is subject to its terms as set out below.
|
|
8
|
+
#
|
|
9
|
+
# If a copy of the EUPL was not distributed with this file, You can obtain
|
|
10
|
+
# one at https://opensource.org/licenses/EUPL-1.2.
|
|
11
|
+
#
|
|
12
|
+
# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
|
|
13
|
+
# amended by the European Commission) shall be deemed incompatible for
|
|
14
|
+
# the purposes of the Work and the provisions of the compatibility
|
|
15
|
+
# clause in Article 5 of the EUPL shall not apply.
|
|
16
|
+
#
|
|
17
|
+
# If using the Work as, or as part of, a network application, by
|
|
18
|
+
# including the attribution notice(s) required under Article 5 of the EUPL
|
|
19
|
+
# in the end user terms of the application under an appropriate heading,
|
|
20
|
+
# such notice(s) shall fulfill the requirements of that article.
|
|
21
|
+
# *********************************************************************
|
|
22
|
+
|
|
23
|
+
from fiftyone_pipeline_cloudrequestengine.constants import Constants as CoreConstants
|
|
24
|
+
|
|
25
|
+
# Class containing values for commonly used evidence keys
|
|
26
|
+
class Constants:
|
|
27
|
+
|
|
28
|
+
# The suffix that is used to identify a client IP address in evidence.
|
|
29
|
+
EVIDENCE_CLIENT_IP_SUFFIX = "client-ip"
|
|
30
|
+
|
|
31
|
+
# The complete key for supplying a client IP address as query evidence.
|
|
32
|
+
EVIDENCE_QUERY_CLIENT_IP_KEY = (
|
|
33
|
+
CoreConstants.EVIDENCE_QUERY_PREFIX +
|
|
34
|
+
CoreConstants.EVIDENCE_SEPERATOR +
|
|
35
|
+
EVIDENCE_CLIENT_IP_SUFFIX)
|
|
36
|
+
|
|
37
|
+
# The complete key for supplying a client IP address as server evidence.
|
|
38
|
+
EVIDENCE_SERVER_CLIENT_IP_KEY = (
|
|
39
|
+
"server" +
|
|
40
|
+
CoreConstants.EVIDENCE_SEPERATOR +
|
|
41
|
+
EVIDENCE_CLIENT_IP_SUFFIX)
|
|
42
|
+
|
|
43
|
+
# The suffix that is used to supply a client IP address to the
|
|
44
|
+
# 51Degrees cloud service in evidence.
|
|
45
|
+
EVIDENCE_CLIENT_IP_51D_SUFFIX = "client-ip-51d"
|
|
46
|
+
|
|
47
|
+
# The complete key for supplying a client IP address as query
|
|
48
|
+
# evidence to the 51Degrees cloud service.
|
|
49
|
+
EVIDENCE_QUERY_CLIENT_IP_51D_KEY = (
|
|
50
|
+
CoreConstants.EVIDENCE_QUERY_PREFIX +
|
|
51
|
+
CoreConstants.EVIDENCE_SEPERATOR +
|
|
52
|
+
EVIDENCE_CLIENT_IP_51D_SUFFIX)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# *********************************************************************
|
|
2
|
+
# This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
|
|
4
|
+
# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
|
|
5
|
+
#
|
|
6
|
+
# This Original Work is licensed under the European Union Public Licence
|
|
7
|
+
# (EUPL) v.1.2 and is subject to its terms as set out below.
|
|
8
|
+
#
|
|
9
|
+
# If a copy of the EUPL was not distributed with this file, You can obtain
|
|
10
|
+
# one at https://opensource.org/licenses/EUPL-1.2.
|
|
11
|
+
#
|
|
12
|
+
# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
|
|
13
|
+
# amended by the European Commission) shall be deemed incompatible for
|
|
14
|
+
# the purposes of the Work and the provisions of the compatibility
|
|
15
|
+
# clause in Article 5 of the EUPL shall not apply.
|
|
16
|
+
#
|
|
17
|
+
# If using the Work as, or as part of, a network application, by
|
|
18
|
+
# including the attribution notice(s) required under Article 5 of the EUPL
|
|
19
|
+
# in the end user terms of the application under an appropriate heading,
|
|
20
|
+
# such notice(s) shall fulfill the requirements of that article.
|
|
21
|
+
# *********************************************************************
|
|
22
|
+
|
|
23
|
+
# Example IP addresses to use as evidence. The cloud engine expects the
|
|
24
|
+
# address under "query.client-ip-51d", the on-premise engine accepts
|
|
25
|
+
# "query.client-ip" or "server.client-ip" (and other parseable evidence).
|
|
26
|
+
# These values mirror the .NET examples' ExampleUtils.EvidenceValues.
|
|
27
|
+
EVIDENCE_VALUES = [
|
|
28
|
+
# An IPv4 address.
|
|
29
|
+
{ "query.client-ip": "116.154.188.222" },
|
|
30
|
+
# An IPv4 address.
|
|
31
|
+
{ "query.client-ip": "1.3.32.31" },
|
|
32
|
+
# An IPv4 address.
|
|
33
|
+
{ "query.client-ip": "45.236.48.61" },
|
|
34
|
+
# An IPv6 address.
|
|
35
|
+
{ "query.client-ip": "2001:0db8:085a:0000:0000:8a2e:0370:7334" },
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
# Note: the .NET examples' Constants.cs still uses the legacy name
|
|
39
|
+
# "51Degrees-EnterpriseIpiV41.ipi", but the published enterprise/ASN data
|
|
40
|
+
# files use the "IPIV4" infix (cf. 51Degrees-IPIV4AsnIpiV41.ipi in the
|
|
41
|
+
# ip-intelligence-data repo), so the current name is used here.
|
|
42
|
+
ENTERPRISE_DATAFILE_NAME = '51Degrees-IPIV4EnterpriseIpiV41.ipi'
|
|
43
|
+
LITE_DATAFILE_NAME = '51Degrees-LiteIpiV41.ipi'
|
|
44
|
+
# The ASN data file is the freely available data file committed
|
|
45
|
+
# to the ip-intelligence-data submodule. It only contains the network
|
|
46
|
+
# (ASN) properties, but is useful for testing the on-premise engine against
|
|
47
|
+
# the current data format without an enterprise data file.
|
|
48
|
+
ASN_DATAFILE_NAME = '51Degrees-IPIV4AsnIpiV41.ipi'
|
|
49
|
+
EVIDENCE_FILE_NAME = 'evidence.yml'
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# *********************************************************************
|
|
2
|
+
# This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
|
|
4
|
+
# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
|
|
5
|
+
#
|
|
6
|
+
# This Original Work is licensed under the European Union Public Licence
|
|
7
|
+
# (EUPL) v.1.2 and is subject to its terms as set out below.
|
|
8
|
+
#
|
|
9
|
+
# If a copy of the EUPL was not distributed with this file, You can obtain
|
|
10
|
+
# one at https://opensource.org/licenses/EUPL-1.2.
|
|
11
|
+
#
|
|
12
|
+
# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
|
|
13
|
+
# amended by the European Commission) shall be deemed incompatible for
|
|
14
|
+
# the purposes of the Work and the provisions of the compatibility
|
|
15
|
+
# clause in Article 5 of the EUPL shall not apply.
|
|
16
|
+
#
|
|
17
|
+
# If using the Work as, or as part of, a network application, by
|
|
18
|
+
# including the attribution notice(s) required under Article 5 of the EUPL
|
|
19
|
+
# in the end user terms of the application under an appropriate heading,
|
|
20
|
+
# such notice(s) shall fulfill the requirements of that article.
|
|
21
|
+
# *********************************************************************
|
|
22
|
+
|
|
23
|
+
import os
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class KeyUtils:
|
|
27
|
+
# Obtain a key either from environment variable or from a property.
|
|
28
|
+
# Try resource key as env var, then as upper case env var, the system property
|
|
29
|
+
@staticmethod
|
|
30
|
+
def get_named_key(key_name):
|
|
31
|
+
return os.environ.get(key_name) or os.environ.get(key_name.upper())
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# *********************************************************************
|
|
2
|
+
# This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
|
|
4
|
+
# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
|
|
5
|
+
#
|
|
6
|
+
# This Original Work is licensed under the European Union Public Licence
|
|
7
|
+
# (EUPL) v.1.2 and is subject to its terms as set out below.
|
|
8
|
+
#
|
|
9
|
+
# If a copy of the EUPL was not distributed with this file, You can obtain
|
|
10
|
+
# one at https://opensource.org/licenses/EUPL-1.2.
|
|
11
|
+
#
|
|
12
|
+
# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
|
|
13
|
+
# amended by the European Commission) shall be deemed incompatible for
|
|
14
|
+
# the purposes of the Work and the provisions of the compatibility
|
|
15
|
+
# clause in Article 5 of the EUPL shall not apply.
|
|
16
|
+
#
|
|
17
|
+
# If using the Work as, or as part of, a network application, by
|
|
18
|
+
# including the attribution notice(s) required under Article 5 of the EUPL
|
|
19
|
+
# in the end user terms of the application under an appropriate heading,
|
|
20
|
+
# such notice(s) shall fulfill the requirements of that article.
|
|
21
|
+
# *********************************************************************
|
|
22
|
+
def merge_two_dicts(x, y):
|
|
23
|
+
z = x.copy()
|
|
24
|
+
z.update(y)
|
|
25
|
+
return z
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def get_value_type(value):
|
|
29
|
+
if type(value) is bool:
|
|
30
|
+
value_type = "Boolean"
|
|
31
|
+
elif type(value) is int:
|
|
32
|
+
value_type = "Int32"
|
|
33
|
+
elif type(value) is str:
|
|
34
|
+
value_type = "String"
|
|
35
|
+
elif type(value) is float:
|
|
36
|
+
value_type = "Double"
|
|
37
|
+
elif type(value) is list:
|
|
38
|
+
value_type = "Array"
|
|
39
|
+
elif isinstance(type(value), list):
|
|
40
|
+
value_type = "String[]"
|
|
41
|
+
else:
|
|
42
|
+
value_type = ""
|
|
43
|
+
return value_type
|
|
44
|
+
|
|
45
|
+
def is_same_type(value, expected_type):
|
|
46
|
+
valueType = get_value_type(value)
|
|
47
|
+
valid = (valueType == expected_type)
|
|
48
|
+
|
|
49
|
+
if not valid:
|
|
50
|
+
valid = True if valueType == "String" and expected_type == "JavaScript" else False
|
|
51
|
+
return valid
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fiftyone_ipintelligence_shared
|
|
3
|
+
Version: 4.5.0
|
|
4
|
+
Summary: Shared code used by the cloud and on-premise variants of the 51Degrees IP Intelligence engines for the 51Degrees Pipeline API.
|
|
5
|
+
Home-page: https://51degrees.com/?utm_source=pypi&utm_medium=package&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-setup.py&utm_term=url
|
|
6
|
+
Author: 51Degrees Engineering
|
|
7
|
+
Author-email: engineering@51degrees.com
|
|
8
|
+
License: EUPL-1.2
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
+
Classifier: License :: OSI Approved :: European Union Public Licence 1.2 (EUPL 1.2)
|
|
18
|
+
Classifier: Operating System :: OS Independent
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
Requires-Dist: fiftyone_pipeline_core
|
|
23
|
+
Requires-Dist: fiftyone_pipeline_engines
|
|
24
|
+
Requires-Dist: fiftyone_pipeline_cloudrequestengine
|
|
25
|
+
Requires-Dist: fiftyone_pipeline_engines_fiftyone
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: author-email
|
|
28
|
+
Dynamic: classifier
|
|
29
|
+
Dynamic: description
|
|
30
|
+
Dynamic: description-content-type
|
|
31
|
+
Dynamic: home-page
|
|
32
|
+
Dynamic: license
|
|
33
|
+
Dynamic: requires-dist
|
|
34
|
+
Dynamic: requires-python
|
|
35
|
+
Dynamic: summary
|
|
36
|
+
|
|
37
|
+
# 51Degrees IP Intelligence Engines - Shared
|
|
38
|
+
|
|
39
|
+
 **Python IP Intelligence**
|
|
40
|
+
|
|
41
|
+
[Developer Documentation](https://51degrees.com/ip-intelligence-python/index.html?utm_source=github&utm_medium=readme&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-readme.md&utm_term=51degrees-ip-intelligence-engines-shared "developer documentation")
|
|
42
|
+
|
|
43
|
+
## Introduction
|
|
44
|
+
|
|
45
|
+
This package contains shared code used by both the cloud and on-premise
|
|
46
|
+
variants of the 51Degrees IP intelligence engines for the
|
|
47
|
+
[51Degrees Pipeline API](https://51degrees.com/documentation/index.html?utm_source=github&utm_medium=readme&utm_campaign=51degrees-python&utm_content=fiftyone_ipintelligence_shared-readme.md&utm_term=introduction).
|
|
48
|
+
|
|
49
|
+
It is not intended to be used directly. See
|
|
50
|
+
[fiftyone_ipintelligence](https://pypi.org/project/fiftyone-ipintelligence/)
|
|
51
|
+
instead.
|
|
52
|
+
|
|
53
|
+
## Folders
|
|
54
|
+
|
|
55
|
+
- `fiftyone_ipintelligence_shared` - contains evidence key constants, example
|
|
56
|
+
constants and utility functions shared by the IP intelligence packages.
|
|
57
|
+
- `tests` - unit tests.
|
|
58
|
+
|
|
59
|
+
## Requirements
|
|
60
|
+
|
|
61
|
+
* Python 3.8+
|
|
62
|
+
* The `fiftyone_pipeline_core`, `fiftyone_pipeline_engines`,
|
|
63
|
+
`fiftyone_pipeline_cloudrequestengine` and
|
|
64
|
+
`fiftyone_pipeline_engines_fiftyone` packages
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
MANIFEST.in
|
|
2
|
+
pyproject.toml
|
|
3
|
+
readme.md
|
|
4
|
+
setup.py
|
|
5
|
+
version.txt
|
|
6
|
+
src/fiftyone_ipintelligence_shared/__init__.py
|
|
7
|
+
src/fiftyone_ipintelligence_shared/constants.py
|
|
8
|
+
src/fiftyone_ipintelligence_shared/example_constants.py
|
|
9
|
+
src/fiftyone_ipintelligence_shared/key_utils.py
|
|
10
|
+
src/fiftyone_ipintelligence_shared/utils.py
|
|
11
|
+
src/fiftyone_ipintelligence_shared.egg-info/PKG-INFO
|
|
12
|
+
src/fiftyone_ipintelligence_shared.egg-info/SOURCES.txt
|
|
13
|
+
src/fiftyone_ipintelligence_shared.egg-info/dependency_links.txt
|
|
14
|
+
src/fiftyone_ipintelligence_shared.egg-info/requires.txt
|
|
15
|
+
src/fiftyone_ipintelligence_shared.egg-info/top_level.txt
|
|
16
|
+
tests/test_shared.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
fiftyone_ipintelligence_shared-4.5.0/src/fiftyone_ipintelligence_shared.egg-info/top_level.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
fiftyone_ipintelligence_shared
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# *********************************************************************
|
|
2
|
+
# This Original Work is copyright of 51 Degrees Mobile Experts Limited.
|
|
3
|
+
# Copyright 2026 51 Degrees Mobile Experts Limited, Davidson House,
|
|
4
|
+
# Forbury Square, Reading, Berkshire, United Kingdom RG1 3EU.
|
|
5
|
+
#
|
|
6
|
+
# This Original Work is licensed under the European Union Public Licence
|
|
7
|
+
# (EUPL) v.1.2 and is subject to its terms as set out below.
|
|
8
|
+
#
|
|
9
|
+
# If a copy of the EUPL was not distributed with this file, You can obtain
|
|
10
|
+
# one at https://opensource.org/licenses/EUPL-1.2.
|
|
11
|
+
#
|
|
12
|
+
# The 'Compatible Licences' set out in the Appendix to the EUPL (as may be
|
|
13
|
+
# amended by the European Commission) shall be deemed incompatible for
|
|
14
|
+
# the purposes of the Work and the provisions of the compatibility
|
|
15
|
+
# clause in Article 5 of the EUPL shall not apply.
|
|
16
|
+
#
|
|
17
|
+
# If using the Work as, or as part of, a network application, by
|
|
18
|
+
# including the attribution notice(s) required under Article 5 of the EUPL
|
|
19
|
+
# in the end user terms of the application under an appropriate heading,
|
|
20
|
+
# such notice(s) shall fulfill the requirements of that article.
|
|
21
|
+
# *********************************************************************
|
|
22
|
+
|
|
23
|
+
import unittest
|
|
24
|
+
|
|
25
|
+
from fiftyone_ipintelligence_shared.constants import Constants
|
|
26
|
+
from fiftyone_ipintelligence_shared.utils import merge_two_dicts
|
|
27
|
+
from fiftyone_ipintelligence_shared.key_utils import KeyUtils
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class SharedTests(unittest.TestCase):
|
|
31
|
+
|
|
32
|
+
def test_evidence_keys(self):
|
|
33
|
+
self.assertEqual(Constants.EVIDENCE_QUERY_CLIENT_IP_KEY, "query.client-ip")
|
|
34
|
+
self.assertEqual(Constants.EVIDENCE_SERVER_CLIENT_IP_KEY, "server.client-ip")
|
|
35
|
+
self.assertEqual(Constants.EVIDENCE_QUERY_CLIENT_IP_51D_KEY, "query.client-ip-51d")
|
|
36
|
+
|
|
37
|
+
def test_merge_two_dicts(self):
|
|
38
|
+
merged = merge_two_dicts({"a": 1, "b": 2}, {"b": 3, "c": 4})
|
|
39
|
+
self.assertEqual(merged, {"a": 1, "b": 3, "c": 4})
|
|
40
|
+
|
|
41
|
+
def test_get_named_key(self):
|
|
42
|
+
import os
|
|
43
|
+
os.environ["IPINTELLIGENCETESTKEY"] = "value"
|
|
44
|
+
try:
|
|
45
|
+
self.assertEqual(KeyUtils.get_named_key("ipintelligencetestkey"), "value")
|
|
46
|
+
finally:
|
|
47
|
+
del os.environ["IPINTELLIGENCETESTKEY"]
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
if __name__ == "__main__":
|
|
51
|
+
unittest.main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
4.5.0
|