Page 1 of 1

Multiple modules

Posted: Sat Sep 13, 2014 1:53 pm
by BackRaw
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? =)

Posted: Sat Sep 13, 2014 2:04 pm
by Ayuto
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

Posted: Sat Sep 13, 2014 2:16 pm
by BackRaw
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 :)