Skip to content

Commit

Permalink
Package setup and deployment, bump version to 3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Joseph Julian committed May 29, 2023
1 parent d417502 commit 4a942a3
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 58 deletions.
51 changes: 40 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,76 @@
# mcc-mnc

mcc-mnc is a tool for matching and retrieving information about Mobile Country Codes (MCC) and Mobile Network Codes (MNC). It allows you to search for MCC-MNC combinations, Country Codes (CC), Public Land Mobile Network (PLMN), or individual MCC, MNC, or CC values to retrieve details about the corresponding mobile network provider. The tool uses a JSON database that maps the MCC-MNC combinations to their associated information such as ISO country codes, country names, and network names.
mcc-mnc is a tool for matching and retrieving information about Mobile Country Codes (MCC) and Mobile Network Codes (
MNC). It allows you to search for MCC-MNC combinations, Country Codes (CC), Public Land Mobile Network (PLMN), or
individual MCC, MNC, or CC values to retrieve details about the corresponding mobile network provider. The tool uses a
JSON database that maps the MCC-MNC combinations to their associated information such as ISO country codes, country
names, and network names.

## Installation

You can install mcc-mnc using pip, the package manager for Python.
You can install mcc-mnc using pip, the Python package manager.

```bash
pip install mccmnc
```

## Usage

You can use mcc-mnc to search for MCC-MNC combinations, Country Codes (CC), PLMNs, or individual MCC, MNC, or CC values. Here are some usage examples:
You can use mcc-mnc to search for MCC-MNC combinations, Country Codes (CC), PLMNs, or individual MCC, MNC, or CC values.
Here are some usage examples:

```bash
# Search by Country Code (CC)
python mccmnc.py -cc XXX
mccmnc -cc XXX

# Search by Mobile Country Code (MCC)
python mccmnc.py -mcc XXX
mccmnc -mcc XXX

# Search by MCC and MNC
python mccmnc.py -mcc XXX -mnc XXX
mccmnc -mcc XXX -mnc XXX

# Search by CC, MCC, and MNC
python mccmnc.py -cc XXX -mcc XXX -mnc XXX
mccmnc -cc XXX -mcc XXX -mnc XXX

# Search by PLMN
python mccmnc.py -plmn XXXXX
mccmnc -plmn XXXXX

# Update the mcc-mnc database
python mccmnc.py -update
mccmnc -update
```

The `-update` option allows you to download and refresh the local JSON file that mcc-mnc uses for matching.

## Python Usage

You can also use `mccmnc` within your Python programs. First, make sure it's installed in your Python environment, then
you can import it and use its functions. Here's an example:

```python
from mccmnc import find_matches, print_matches, update

# Example of searching by MCC and MNC
matches = find_matches(user_mcc="123", user_mnc="45")
if matches:
print_matches(matches)
else:
print("No match found.")

# Example of updating the database
update()
```

These examples demonstrate how to use `find_matches` to search for MCC-MNC combinations and `print_matches` to print out
the details of the matches. The `update` function is used to update the MCC-MNC database.

## Contributing

Contributions, bug reports, and feature requests are welcome! If you would like to contribute to mcc-mnc, please open an issue to discuss your ideas or submit a pull request with your changes.
Contributions, bug reports, and feature requests are welcome! If you would like to contribute to mcc-mnc, please open an
issue to discuss your ideas or submit a pull request with your changes.

Please ensure that you update or add relevant tests for your changes.

## License

mcc-mnc is licensed under the [MIT License](https://choosealicense.com/licenses/mit/). Feel free to use, modify, and distribute this project under the terms of this license.
mcc-mnc is licensed under the [MIT License](https://choosealicense.com/licenses/mit/). Feel free to use, modify, and
distribute this project under the terms of this license.
Binary file added dist/mccmnc-3.2.tar.gz
Binary file not shown.
90 changes: 90 additions & 0 deletions mccmnc.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
Metadata-Version: 2.1
Name: mccmnc
Version: 3.2
Summary: A tool for matching and retrieving information about MCC-MNC combinations.
Home-page: https://github.com/jbjulia/mcc-mnc
Author: Joseph Julian
Author-email: jbjulian@pm.me
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE

# mcc-mnc

mcc-mnc is a tool for matching and retrieving information about Mobile Country Codes (MCC) and Mobile Network Codes (
MNC). It allows you to search for MCC-MNC combinations, Country Codes (CC), Public Land Mobile Network (PLMN), or
individual MCC, MNC, or CC values to retrieve details about the corresponding mobile network provider. The tool uses a
JSON database that maps the MCC-MNC combinations to their associated information such as ISO country codes, country
names, and network names.

## Installation

You can install mcc-mnc using pip, the Python package manager.

```bash
pip install mccmnc
```

## Usage

You can use mcc-mnc to search for MCC-MNC combinations, Country Codes (CC), PLMNs, or individual MCC, MNC, or CC values.
Here are some usage examples:

```bash
# Search by Country Code (CC)
mccmnc -cc XXX

# Search by Mobile Country Code (MCC)
mccmnc -mcc XXX

# Search by MCC and MNC
mccmnc -mcc XXX -mnc XXX

# Search by CC, MCC, and MNC
mccmnc -cc XXX -mcc XXX -mnc XXX

# Search by PLMN
mccmnc -plmn XXXXX

# Update the mcc-mnc database
mccmnc -update
```

The `-update` option allows you to download and refresh the local JSON file that mcc-mnc uses for matching.

## Python Usage

You can also use `mccmnc` within your Python programs. First, make sure it's installed in your Python environment, then
you can import it and use its functions. Here's an example:

```python
from mccmnc import find_matches, print_matches, update

# Example of searching by MCC and MNC
matches = find_matches(user_mcc="123", user_mnc="45")
if matches:
print_matches(matches)
else:
print("No match found.")

# Example of updating the database
update()
```

These examples demonstrate how to use `find_matches` to search for MCC-MNC combinations and `print_matches` to print out
the details of the matches. The `update` function is used to update the MCC-MNC database.

## Contributing

Contributions, bug reports, and feature requests are welcome! If you would like to contribute to mcc-mnc, please open an
issue to discuss your ideas or submit a pull request with your changes.

Please ensure that you update or add relevant tests for your changes.

## License

mcc-mnc is licensed under the [MIT License](https://choosealicense.com/licenses/mit/). Feel free to use, modify, and
distribute this project under the terms of this license.
12 changes: 12 additions & 0 deletions mccmnc.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
LICENSE
README.md
setup.py
mccmnc/__init__.py
mccmnc/cli.py
mccmnc/mccmnc.py
mccmnc.egg-info/PKG-INFO
mccmnc.egg-info/SOURCES.txt
mccmnc.egg-info/dependency_links.txt
mccmnc.egg-info/entry_points.txt
mccmnc.egg-info/requires.txt
mccmnc.egg-info/top_level.txt
1 change: 1 addition & 0 deletions mccmnc.egg-info/dependency_links.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions mccmnc.egg-info/entry_points.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[console_scripts]
mccmnc = mccmnc.cli:main
2 changes: 2 additions & 0 deletions mccmnc.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
beautifulsoup4
tqdm
1 change: 1 addition & 0 deletions mccmnc.egg-info/top_level.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mccmnc
37 changes: 37 additions & 0 deletions mccmnc/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import argparse
import sys

from .mccmnc import find_matches, print_matches, update


def get_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description='MCC-MNC match and update tool.')
parser.add_argument('-cc', metavar='CC', type=str, help='Country Code (CC)')
parser.add_argument('-mcc', metavar='MCC', type=str, help='Mobile Country Code (MCC)')
parser.add_argument('-mnc', metavar='MNC', type=str, help='Mobile Network Code (MNC)')
parser.add_argument('-plmn', metavar='PLMN', type=str, help='Public Land Mobile Network (PLMN)')
parser.add_argument('-update', action='store_true', help='Downloads and refreshes local CSV and JSON')
return parser.parse_args()


def main():
args = get_args()
try:
if args.update:
update()
else:
matches = find_matches(args.cc, args.mcc, args.mnc, args.plmn)
if matches:
print_matches(matches)
else:
print("No match found.")
except Exception as e:
print(f"Error: {e}")
sys.exit(1)


if __name__ == "__main__":
main()
38 changes: 0 additions & 38 deletions mccmnc/mccmnc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import argparse
import json
import os
import sys
Expand All @@ -12,19 +11,6 @@
JSON_PATH = os.path.join(os.path.dirname(__file__), "mccmnc.json")


def get_args():
"""
Parse command-line arguments.
"""
parser = argparse.ArgumentParser(description='MCC-MNC match and update tool.')
parser.add_argument('-cc', metavar='CC', type=str, help='Country Code (CC)')
parser.add_argument('-mcc', metavar='MCC', type=str, help='Mobile Country Code (MCC)')
parser.add_argument('-mnc', metavar='MNC', type=str, help='Mobile Network Code (MNC)')
parser.add_argument('-plmn', metavar='PLMN', type=str, help='Public Land Mobile Network (PLMN)')
parser.add_argument('-update', action='store_true', help='Downloads and refreshes local CSV and JSON')
return parser.parse_args()


def find_matches(user_cc=None, user_mcc=None, user_mnc=None, user_plmn=None):
"""
Match the given criteria against the JSON data.
Expand Down Expand Up @@ -117,27 +103,3 @@ def update():
except URLError as e:
print(f"Error downloading file: {e}")
sys.exit(1)


def main(args):
"""
Main entry point of the program.
:param args: Command-line arguments
"""
try:
if args.update:
update()
else:
matches = find_matches(args.cc, args.mcc, args.mnc, args.plmn)
if matches:
print_matches(matches)
else:
print("No match found.")
except Exception as e:
print(f"Error: {e}")
sys.exit(1)


if __name__ == "__main__":
main(get_args())
35 changes: 26 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,29 @@
from setuptools import setup
from setuptools import setup, find_packages

with open("README.md", "r") as fh:
long_description = fh.read()

setup(
name='mcc-mnc',
version='3.0',
packages=[''],
url='https://github.com/jbjulia/mcc-mnc',
license='MIT',
author='Joseph Julian',
author_email='jbjulian@pm.me',
description='A published Python package for country network queries, used for mobile subscriber identification.'
name="mccmnc",
version="3.2",
author="Joseph Julian",
author_email="jbjulian@pm.me",
description="A tool for matching and retrieving information about MCC-MNC combinations.",
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/jbjulia/mcc-mnc",
packages=find_packages(),
include_package_data=True,
python_requires='>=3.6',
install_requires=["beautifulsoup4", "tqdm"],
entry_points={
'console_scripts': [
'mccmnc=mccmnc.cli:main',
],
},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
)

0 comments on commit 4a942a3

Please sign in to comment.