Multiple modules

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Multiple modules

Postby BackRaw » Sat Sep 13, 2014 1:53 pm

Hi,

I have a question about putting more than 1 module, e.g. <scriptname>.py in the plugin's folder.
I want to update my FlashFun.SP plugin, so it looks cleaner: https://bitbucket.org/backraw/source.python/src/7a3ac1d69371807abede5215f234fdb340ed55e3/flashfunsp/?at=master

In info.py I have a PluginInfo() instance which is stored in the global variable 'info'.
In flashfunsp.py I do

Syntax: Select all

from flashfunsp.info import info

from flashfunsp.config import config_manager
which results in the following error:

Code: Select all

[SP] Caught an Exception:
Traceback (most recent call last):
  File '../addons/source-python/packages/source-python/plugins/manager.py', line 72, in __missing__
    instance = self.instance(plugin_name, self.base_import)
  File '../addons/source-python/packages/source-python/plugins/instance.py', line 82, in __init__
    self._plugin = import_module(import_name)
  File '../addons/source-python/plugins/flashfunsp/flashfunsp.py', line 32, in <module>
    from flashfunsp.config import config_manager
  File '../addons/source-python/plugins/flashfunsp/config.py', line 74, in <module>
    config_manager = _ConfigManager()
  File '../addons/source-python/plugins/flashfunsp/config.py', line 30, in __init__
    super(_ConfigManager, self).__init__(info.basename)
 
AttributeError: 'module' object has no attribute 'basename'
 
 
[SP] Plugin 'flashfunsp' was unable to be loaded.
Which is caused by this line 30 in config.py

How would I go about that? Could I put the 'info' instance in the __init__.py file, would that make a difference? =)
My Github repositories:

Source.Python: https://github.com/backraw
User avatar
Ayuto
Project Leader
Posts: 2209
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Sat Sep 13, 2014 2:04 pm

Check this line. https://bitbucket.org/backraw/source.python/src/7a3ac1d69371807abede5215f234fdb340ed55e3/flashfunsp/config.py?at=master#cl-12

It should actually be

Syntax: Select all

from flashfunsp.info import info
or even shorter

Syntax: Select all

from info import info
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Sat Sep 13, 2014 2:16 pm

Ayuto wrote:Check this line. https://bitbucket.org/backraw/source.python/src/7a3ac1d69371807abede5215f234fdb340ed55e3/flashfunsp/config.py?at=master#cl-12

It should actually be[python]from flashfunsp.info import info[/python]or even shorter[python]from info import info[/python]


A typo, omg. Thanks! :) Yeah I wanted it to be like the first example you provided. Going to change that :D
Edit: works fine :)
My Github repositories:

Source.Python: https://github.com/backraw

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 156 guests