diff options
Diffstat (limited to 'python-anonymizeip.spec')
-rw-r--r-- | python-anonymizeip.spec | 258 |
1 files changed, 258 insertions, 0 deletions
diff --git a/python-anonymizeip.spec b/python-anonymizeip.spec new file mode 100644 index 0000000..ac4976b --- /dev/null +++ b/python-anonymizeip.spec @@ -0,0 +1,258 @@ +%global _empty_manifest_terminate_build 0 +Name: python-anonymizeip +Version: 1.0.0 +Release: 1 +Summary: Python library for anonymizing IP addresses +License: MIT +URL: https://github.com/samuelmeuli/anonymize-ip +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/4a/05/5987ce97a2a8debfba16e35efa88975f340559337b7faabb24e78b32f8c6/anonymizeip-1.0.0.tar.gz +BuildArch: noarch + + +%description + +# anonymize_ip + +This is a simple Python library for anonymizing IP addresses. Both IPv4 and IPv6 addresses are supported. + +Examples: + +* IPv4: `95.239.169.11` → `95.239.169.0` +* IPv6: `5219:3a94:fdc5:19e1:70a3:b2c4:40ef:ae03` → `5219:3a94:fdc5:19e1::` + + +## Usage + +``` +pip install anonymizeip +``` + +```py +from anonymizeip import anonymize_ip + +address = "fe80::0202:b3ff:fe1e:8329" +anonymized = anonymize_ip(address) +print(anonymized) + +# Prints "fe80::" +``` + + +## Settings + +The number of address blocks that are set to 0 can be customized. + +Besides the IP address, the function `anonymize_ip` takes two optional parameters: + +```py +anonymize_ip( + address, + ipv4_mask="...", + ipv6_mask="..." +) +``` + +* `ipv4_mask`: Defaults to `255.255.255.0`, i.e. the last octet will be anonymized (set to 0) +* `ipv6_mask`: Defaults to `ffff:ffff:ffff:ffff::` (same as `ffff:ffff:ffff:ffff:0:0:0:0`), i.e. the last four blocks will be anonymized (set to 0) + + +## Development + +1. `git clone` +2. `pipenv install --dev` +3. Make your code modifications +4. `pipenv run test` +5. `pipenv run lint` + +Contributions are always welcome. Please first discuss changes via issue before submitting a pull request. + + +## Credits + +The implementation of this library was strongly inspired by [php-ip-anonymizer](https://github.com/geertw/php-ip-anonymizer) by Geert Wirken. + + + + +%package -n python3-anonymizeip +Summary: Python library for anonymizing IP addresses +Provides: python-anonymizeip +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-anonymizeip + +# anonymize_ip + +This is a simple Python library for anonymizing IP addresses. Both IPv4 and IPv6 addresses are supported. + +Examples: + +* IPv4: `95.239.169.11` → `95.239.169.0` +* IPv6: `5219:3a94:fdc5:19e1:70a3:b2c4:40ef:ae03` → `5219:3a94:fdc5:19e1::` + + +## Usage + +``` +pip install anonymizeip +``` + +```py +from anonymizeip import anonymize_ip + +address = "fe80::0202:b3ff:fe1e:8329" +anonymized = anonymize_ip(address) +print(anonymized) + +# Prints "fe80::" +``` + + +## Settings + +The number of address blocks that are set to 0 can be customized. + +Besides the IP address, the function `anonymize_ip` takes two optional parameters: + +```py +anonymize_ip( + address, + ipv4_mask="...", + ipv6_mask="..." +) +``` + +* `ipv4_mask`: Defaults to `255.255.255.0`, i.e. the last octet will be anonymized (set to 0) +* `ipv6_mask`: Defaults to `ffff:ffff:ffff:ffff::` (same as `ffff:ffff:ffff:ffff:0:0:0:0`), i.e. the last four blocks will be anonymized (set to 0) + + +## Development + +1. `git clone` +2. `pipenv install --dev` +3. Make your code modifications +4. `pipenv run test` +5. `pipenv run lint` + +Contributions are always welcome. Please first discuss changes via issue before submitting a pull request. + + +## Credits + +The implementation of this library was strongly inspired by [php-ip-anonymizer](https://github.com/geertw/php-ip-anonymizer) by Geert Wirken. + + + + +%package help +Summary: Development documents and examples for anonymizeip +Provides: python3-anonymizeip-doc +%description help + +# anonymize_ip + +This is a simple Python library for anonymizing IP addresses. Both IPv4 and IPv6 addresses are supported. + +Examples: + +* IPv4: `95.239.169.11` → `95.239.169.0` +* IPv6: `5219:3a94:fdc5:19e1:70a3:b2c4:40ef:ae03` → `5219:3a94:fdc5:19e1::` + + +## Usage + +``` +pip install anonymizeip +``` + +```py +from anonymizeip import anonymize_ip + +address = "fe80::0202:b3ff:fe1e:8329" +anonymized = anonymize_ip(address) +print(anonymized) + +# Prints "fe80::" +``` + + +## Settings + +The number of address blocks that are set to 0 can be customized. + +Besides the IP address, the function `anonymize_ip` takes two optional parameters: + +```py +anonymize_ip( + address, + ipv4_mask="...", + ipv6_mask="..." +) +``` + +* `ipv4_mask`: Defaults to `255.255.255.0`, i.e. the last octet will be anonymized (set to 0) +* `ipv6_mask`: Defaults to `ffff:ffff:ffff:ffff::` (same as `ffff:ffff:ffff:ffff:0:0:0:0`), i.e. the last four blocks will be anonymized (set to 0) + + +## Development + +1. `git clone` +2. `pipenv install --dev` +3. Make your code modifications +4. `pipenv run test` +5. `pipenv run lint` + +Contributions are always welcome. Please first discuss changes via issue before submitting a pull request. + + +## Credits + +The implementation of this library was strongly inspired by [php-ip-anonymizer](https://github.com/geertw/php-ip-anonymizer) by Geert Wirken. + + + + +%prep +%autosetup -n anonymizeip-1.0.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-anonymizeip -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Wed May 10 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.0-1 +- Package Spec generated |