Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

put more variables in common py file #6

Open
PieterL75 opened this issue May 10, 2024 · 0 comments
Open

put more variables in common py file #6

PieterL75 opened this issue May 10, 2024 · 0 comments

Comments

@PieterL75
Copy link

Currently only the 'version' is in a py import file.

I would suggest to add more variables in there, those that are shared between the init.py and the setup.py

setup.py:

def get_pluginvar(variable,rel_path):
    for line in read(rel_path).splitlines():
        if line.startswith(f'__{variable}__'):
            delim = '"' if '"' in line else "'"
            return line.split(delim)[1]
    else:
        raise RuntimeError(f"Unable to find {variable} string in f{rel_path}.")

setup(
    name=get_pluginvar('name','netbox_newplugin/pluginvars.py'),
    version=get_pluginvar('version','netbox_newplugin/pluginvars.py'),
    description=get_pluginvar('description','netbox_newplugin/pluginvars.py'),
    long_description=long_description,
    long_description_content_type="text/markdown",
    url=get_pluginvar('url','netbox_newplugin/pluginvars.py'),
    author=get_pluginvar('author','netbox_newplugin/pluginvars.py'),
    author_email=get_pluginvar('author_email','netbox_newplugin/pluginvars.py'),
    install_requires=[],
    packages=find_packages(),
    include_package_data=True,
    classifiers=[
        'Development Status :: 2 - Pre-Alpha',
        'Framework :: Django',
        'Programming Language :: Python :: 3',
    ]
)

pluginvars.py:

__name__ = 'netbox_newplugin'
__version__ = '0.0.0'
__description__ = ''
__author__ = ''
__author_email__ = ''
__url__ = ''

_ _ init _ _.py

from extras.plugins import PluginConfig
from .pluginvars import __name__
from .pluginvars import __version__
from .pluginvars import __description__
from .pluginvars import __author__
from .pluginvars import __author_email__


class NewpluginConfig(PluginConfig):
    name = __name__
    verbose_name = ''
    description = __description__
    version = __version__
    author = __author__
    author_email = __author_email__
    required_settings = []
    default_settings = {}


config = NewpluginConfig # noqa

(did not test this yet, so excuse any codos or typos)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant