| 380 | | #register datasources |
| 381 | | from mapnik import DatasourceCache |
| 382 | | DatasourceCache.instance().register_datasources('%s' % inputpluginspath) |
| 383 | | #register some fonts |
| 384 | | from mapnik import FontEngine |
| 385 | | from glob import glob |
| 386 | | fonts = glob('%s/*.ttf' % fontscollectionpath) |
| 387 | | if len( fonts ) == 0: |
| 388 | | print "### WARNING: No ttf files found in '%s'." % fontscollectionpath |
| 389 | | else: |
| 390 | | map(FontEngine.instance().register_font, fonts) |
| | 381 | def register_plugins(path=inputpluginspath): |
| | 382 | """Register plugins located by specified path""" |
| | 383 | DatasourceCache.instance().register_datasources(path) |
| | 384 | |
| | 385 | def register_fonts(path=fontscollectionpath): |
| | 386 | """Recursively register fonts using path argument as base directory""" |
| | 387 | for dirpath, _, filenames in os.walk(path): |
| | 388 | for filename in filenames: |
| | 389 | if os.path.splitext(filename)[1] == '.ttf': |
| | 390 | FontEngine.instance().register_font(os.path.join(dirpath, filename)) |
| | 391 | |
| | 392 | # auto-register known plugins and fonts |
| | 393 | register_plugins() |
| | 394 | register_fonts() |