Detect if a module is imported from a DrawBot script?
jens last edited by gferreira
I have an external module that can be imported from commandline, or from inside RoboFont, or from inside DrawBot. How can the module detect it’s being imported from DrawBot?
For RoboFont, this works:
try: from mojo.drawingTools import * inRoboFont = True except: inRoboFont = False
jens last edited by
OK, I think I got it:
try: from drawBot.drawBotDrawingTools import _drawBotDrawingTool strokeWidth = _drawBotDrawingTool.strokeWidth except ImportError: print("... must be used either inside RoboFont or inside DrawBot")
DrawBot could be installed as module, so the import could be available.
import AppKit appName = AppKit.NSBundle.mainBundle().infoDictionary().get("CFBundleDisplayName") print(appName)
mina9000 last edited by mina9000
I have an outer module that can be imported from commandline, or from inside RoboFont, or from inside DrawBot. In what capacity can the module distinguish it's being imported from DrawBot?
I guess there is a piece missing...
you can use the code above, if you are inside an application the
NSBundlehas a display name. In Terminal it will be