Skip to content

Commit

Permalink
moved main to __init__.py
Browse files Browse the repository at this point in the history
  • Loading branch information
bortok committed Mar 13, 2024
1 parent 4513b7b commit f5e99ea
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 9 deletions.
2 changes: 1 addition & 1 deletion nrx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ repo_directory = os.path.dirname(os.path.abspath(__file__))
# Append to the system path for module imports
sys.path.append(f"{repo_directory}/src")
# Import the main function and execute
from nrx.nrx import main
from nrx import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Homepage = "https://github.com/netreplica/nrx"
Issues = "https://github.com/netreplica/nrx/issues"

[project.scripts]
nrx = "nrx.nrx:main"
nrx = "nrx:main"

[tool.hatch.build.targets.wheel]
sources = ["src"]
Expand Down
2 changes: 1 addition & 1 deletion src/nrx/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@
"""
Metadata for the nrx package
"""
__version__ = "0.4.15"
__version__ = "0.4.16"
27 changes: 27 additions & 0 deletions src/nrx/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/env python3

# nrx - network topology exporter by netreplica

# Copyright 2024 Netreplica Team
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
Main function for nrx
"""

from nrx.nrx import cli

def main():
"""Main"""
return cli()
8 changes: 2 additions & 6 deletions src/nrx/nrx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1247,8 +1247,8 @@ def load_config(args):

return config

def main():
"""Main"""
def cli():
"""Main entry for CLI execution, called from main() in __init__.py"""
# Parameters
args = parse_args()
config = load_config(args)
Expand Down Expand Up @@ -1289,7 +1289,3 @@ def main():
error(f"Only --input netbox is supported for this type of export format: {config['output_format']}")

return 0


if __name__ == '__main__':
sys.exit(main())

0 comments on commit f5e99ea

Please sign in to comment.