diff options
author | Georg Brandl <georg@python.org> | 2014-09-16 16:08:41 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-09-16 16:08:41 +0200 |
commit | aa1e7d94fdc1722809a8f045edec4a3454c58ad0 (patch) | |
tree | 9da1d3581e7190a68939ce048b30ee542e36490d /pygments/lexers/_mapping.py | |
parent | 39eb79a325171a943af3fb74c031f42be1bc78c8 (diff) | |
download | pygments-aa1e7d94fdc1722809a8f045edec4a3454c58ad0.tar.gz |
support submodules in _mapping regeneration
Diffstat (limited to 'pygments/lexers/_mapping.py')
-rw-r--r-- | pygments/lexers/_mapping.py | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/pygments/lexers/_mapping.py b/pygments/lexers/_mapping.py index d505dcf5..631a893a 100644 --- a/pygments/lexers/_mapping.py +++ b/pygments/lexers/_mapping.py @@ -367,20 +367,22 @@ if __name__ == '__main__': # lookup lexers found_lexers = [] sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..')) - for filename in os.listdir('.'): - if filename.endswith('.py') and not filename.startswith('_'): - module_name = 'pygments.lexers.%s' % filename[:-3] - print(module_name) - module = __import__(module_name, None, None, ['']) - for lexer_name in module.__all__: - lexer = getattr(module, lexer_name) - found_lexers.append( - '%r: %r' % (lexer_name, - (module_name, - lexer.name, - tuple(lexer.aliases), - tuple(lexer.filenames), - tuple(lexer.mimetypes)))) + for root, dirs, files in os.walk('.'): + for filename in files: + if filename.endswith('.py') and not filename.startswith('_'): + module_name = 'pygments.lexers%s.%s' % ( + root[1:].replace('/', '.'), filename[:-3]) + print(module_name) + module = __import__(module_name, None, None, ['']) + for lexer_name in module.__all__: + lexer = getattr(module, lexer_name) + found_lexers.append( + '%r: %r' % (lexer_name, + (module_name, + lexer.name, + tuple(lexer.aliases), + tuple(lexer.filenames), + tuple(lexer.mimetypes)))) # sort them, that should make the diff files for svn smaller found_lexers.sort() |