Skip to content

Commit

Permalink
pynipap: Move to Python package
Browse files Browse the repository at this point in the history
Mainly to avoid cluttering the global namespace with the name "tracing",
moved the pynipap module to its own package.

The intention is that the package should be fully compatible with the
stans-alone module and require no changes to the applications using it.
  • Loading branch information
garberg committed Jan 9, 2025
1 parent e363e73 commit 02e1a30
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 8 deletions.
18 changes: 18 additions & 0 deletions pynipap/pynipap/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
__version__ = "0.32.5"
__author__ = "Kristian Larsson, Lukas Garberg"
__author_email__= "[email protected], [email protected]"
__copyright__ = "Copyright 2011, Kristian Larsson, Lukas Garberg"
__license__ = "MIT"
__status__ = "Development"
__url__ = "http://SpriteLink.github.io/NIPAP"


# This variable holds the URI to the nipap XML-RPC service which will be used.
# It must be set before the Pynipap can be used!
xmlrpc_uri = None

# If set, the value assigned to the variable below will be used as a bearer
# token.
bearer_token = None

from .pynipap import *
9 changes: 5 additions & 4 deletions pynipap/pynipap.py → pynipap/pynipap/pynipap.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
import xmlrpc.client as xmlrpclib
import urllib.parse

from tracing import create_span
from .tracing import create_span

__version__ = "0.32.5"
__author__ = "Kristian Larsson, Lukas Garberg"
Expand Down Expand Up @@ -261,8 +261,6 @@ class XMLRPCConnection:
""" Handles a shared XML-RPC connection.
"""

__shared_state = {}

connection = None
_logger = None

Expand All @@ -275,13 +273,16 @@ def __init__(self):
variable is set.
"""

# This is not a pretty solution, but needed to maintain backwards
# compatibility.
from . import xmlrpc_uri, bearer_token
if xmlrpc_uri is None:
raise NipapError('XML-RPC URI not specified')

p = urllib.parse.urlsplit(xmlrpc_uri)

try:
from tracing import TracingXMLTransport, TracingXMLSafeTransport
from .tracing import TracingXMLTransport, TracingXMLSafeTransport
if p.scheme == "http":
xml_transport = TracingXMLTransport
elif p.scheme == "https":
Expand Down
2 changes: 1 addition & 1 deletion pynipap/tracing.py → pynipap/pynipap/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def decorated(*args, **kwargs):
"""
"""

from pynipap import AuthOptions
from . import AuthOptions
signature = inspect.signature(f)

if args[0].__class__ == type:
Expand Down
5 changes: 2 additions & 3 deletions pynipap/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
author_email = pynipap.__author_email__,
license = pynipap.__license__,
url = pynipap.__url__,
py_modules = ['pynipap','tracing'],
packages = ['pynipap'],
keywords = ['nipap'],
classifiers = [
'Development Status :: 4 - Beta',
Expand All @@ -26,7 +26,6 @@
'License :: OSI Approved :: MIT License',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Topic :: Internet :: WWW/HTTP :: WSGI :: Middleware'
'Programming Language :: Python :: 3'
]
)

0 comments on commit 02e1a30

Please sign in to comment.