Home Download Buy Blog Forum Support

Recursive module recognition

Recursive module recognition

Postby jlanza on Thu Aug 02, 2012 2:21 pm

Hi,

I'm using a markdown-preview plugin but is seems that ST2 doesn't make it to load the extensions of the python markdown package that is embedded in the plugin code.

When running the
Code: Select all
sys.modules
command on ST2 console I get:
Code: Select all
'markdown': <module 'markdown' from '.\markdown\__init__.py'>
'markdown.serializers': <module 'markdown.serializers' from '.\markdown\serializers.pyc'>
'markdown.inlinepatterns': <module 'markdown.inlinepatterns' from '.\markdown\inlinepatterns.pyc'>
'markdown.blockparser': <module 'markdown.blockparser' from '.\markdown\blockparser.pyc'>
'markdown.blockprocessors': <module 'markdown.blockprocessors' from '.\markdown\blockprocessors.pyc'>
'markdown.odict': <module 'markdown.odict' from '.\markdown\odict.pyc'>
'markdown.treeprocessors': <module 'markdown.treeprocessors' from '.\markdown\treeprocessors.pyc'>
'markdown.postprocessors': <module 'markdown.postprocessors' from '.\markdown\postprocessors.pyc'>
'markdown.preprocessors': <module 'markdown.preprocessors' from '.\markdown\preprocessors.pyc'>
'MarkdownPreview': <module 'MarkdownPreview' from '.\MarkdownPreview.pyc'>
'markdown.etree_loader': <module 'markdown.etree_loader' from '.\markdown\etree_loader.pyc'>
'markdown.util': <module 'markdown.util' from '.\markdown\util.pyc'>


As said the markdown preview plugin uses python markdown which has an extension subpackage, and other modules. Running
Code: Select all
sys.modules
on an ordinary python installation with markdown modules reports all the subpackages or submodules (extensions):
Code: Select all
'markdown': <module 'markdown' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\__init__.py'>,
'markdown.blockparser': <module 'markdown.blockparser' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\blockparser.py'>,
'markdown.blockprocessors': <module 'markdown.blockprocessors' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\blockprocessors.py'>,
'markdown.etree_loader': <module 'markdown.etree_loader' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\etree_loader.py'>,
'markdown.extensions': <module 'markdown.extensions' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\__init__.py'>,
'markdown.extensions.abbr': <module 'markdown.extensions.abbr' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\abbr.py'>,
'markdown.extensions.attr_list': <module 'markdown.extensions.attr_list' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\attr_list.py'>,
'markdown.extensions.codehilite': <module 'markdown.extensions.codehilite' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\codehilite.py'>,
'markdown.extensions.def_list': <module 'markdown.extensions.def_list' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\def_list.py'>,
'markdown.extensions.extra': <module 'markdown.extensions.extra' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\extra.py'>,
'markdown.extensions.fenced_code': <module 'markdown.extensions.fenced_code' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\fenced_code.py'>,
'markdown.extensions.footnotes': <module 'markdown.extensions.footnotes' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\footnotes.py'>,
'markdown.extensions.smart_strong': <module 'markdown.extensions.smart_strong' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\smart_strong.py'>,
'markdown.extensions.tables': <module 'markdown.extensions.tables' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\extensions\tables.py'>,
'markdown.inlinepatterns': <module 'markdown.inlinepatterns' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\inlinepatterns.py'>,
'markdown.odict': <module 'markdown.odict' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\odict.py'>,
'markdown.postprocessors': <module 'markdown.postprocessors' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\postprocessors.py'>,
'markdown.preprocessors': <module 'markdown.preprocessors' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\preprocessors.py'>,
'markdown.serializers': <module 'markdown.serializers' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\serializers.py'>,
'markdown.treeprocessors': <module 'markdown.treeprocessors' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\treeprocessors.py'>,
'markdown.util': <module 'markdown.util' from 'C:\Desarrollo\Python32\lib\site-packages\markdown-2.2.0-py3.2.egg\markdown\util.py'>,


It seems ST2 only gets the first directory and not recursively. I guess this is implemented in
Code: Select all
sublime-plugin.py
or maybe in the main source code. By including some debug messages in the
Code: Select all
sublime-plugin.py-->reload_plugin(fname)
function I noticed (not an expert in python) that it only recognize markdown module and not all the ones inside it.

Any hint on how to modified it.

See you
jlanza
 
Posts: 6
Joined: Fri Apr 06, 2012 9:44 am

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 5 guests