2008-01-07 17:40:34 +00:00
|
|
|
import os, sys
|
|
|
|
from robofab import RoboFabError, version, numberVersion
|
|
|
|
|
|
|
|
|
|
|
|
class RFWorld:
|
2011-06-14 15:46:01 +00:00
|
|
|
|
2008-01-07 17:40:34 +00:00
|
|
|
"""All parameters about platforms, versions and environments included in one object."""
|
2011-06-14 15:46:01 +00:00
|
|
|
|
2008-01-07 17:40:34 +00:00
|
|
|
def __init__(self):
|
|
|
|
self.mac = None
|
|
|
|
self.pc = None
|
|
|
|
self.platform = sys.platform
|
2011-05-07 12:55:44 +00:00
|
|
|
self.applicationName = None # name of the application we're running in
|
2008-01-07 17:40:34 +00:00
|
|
|
self.name = os.name
|
|
|
|
self.version = version # the robofab version
|
|
|
|
self.numberVersion = numberVersion
|
|
|
|
self.run = True
|
|
|
|
|
|
|
|
# get some platform information
|
|
|
|
if self.name == 'mac' or self.name == 'posix':
|
|
|
|
if self.platform == "darwin":
|
|
|
|
self.mac = "X"
|
|
|
|
else:
|
|
|
|
self.mac = "pre-X"
|
|
|
|
elif self.name == 'nt':
|
|
|
|
# if you know more about PC & win stuff, add it here!
|
|
|
|
self.pc = True
|
|
|
|
else:
|
|
|
|
raise RoboFabError, "We're running on an unknown platform."
|
2011-06-14 15:46:01 +00:00
|
|
|
|
2008-01-07 17:40:34 +00:00
|
|
|
# collect versions
|
|
|
|
self.pyVersion = sys.version[:3]
|
|
|
|
self.inPython = False
|
|
|
|
self.inFontLab = False
|
2011-06-14 15:44:18 +00:00
|
|
|
self.flVersion = None
|
2011-06-14 15:54:41 +00:00
|
|
|
self.inGlyphs = False
|
|
|
|
self.glyphsVersion = None
|
2011-06-14 15:44:18 +00:00
|
|
|
|
2008-01-07 17:40:34 +00:00
|
|
|
# are we in FontLab?
|
|
|
|
try:
|
|
|
|
from FL import fl
|
|
|
|
self.applicationName = fl.filename
|
|
|
|
self.inFontLab = True
|
|
|
|
self.flVersion = fl.version
|
|
|
|
except ImportError: pass
|
2011-06-14 15:44:18 +00:00
|
|
|
# are we in Glyphs?
|
|
|
|
try:
|
|
|
|
import objectsGS
|
|
|
|
from AppKit import NSBundle
|
|
|
|
bundle = NSBundle.mainBundle()
|
|
|
|
self.applicationName = bundle.infoDictionary()["CFBundleName"]
|
2011-06-14 15:54:41 +00:00
|
|
|
self.inGlyphs = True
|
|
|
|
self.glyphsVersion = bundle.infoDictionary()["CFBundleVersion"]
|
2011-06-14 15:44:18 +00:00
|
|
|
except ImportError: pass
|
|
|
|
# we are in NoneLab
|
2008-01-07 17:40:34 +00:00
|
|
|
if not self.inFontLab:
|
|
|
|
self.inPython = True
|
|
|
|
|
2011-05-07 12:55:44 +00:00
|
|
|
# see if we have DialogKit
|
|
|
|
self.supportsDialogKit = False
|
2011-06-14 15:44:18 +00:00
|
|
|
|
2008-01-07 17:40:34 +00:00
|
|
|
def __repr__(self):
|
2011-06-14 15:53:08 +00:00
|
|
|
s = [
|
|
|
|
"["
|
|
|
|
"Robofab is running on %s. " % self.platform,
|
|
|
|
"Python version: %s, " % self.pyVersion,
|
|
|
|
"Mac stuff: %s, " % self.mac,
|
|
|
|
"PC stuff: %s, " % self.pc,
|
|
|
|
"FontLab stuff: %s, " % self.inFontLab,
|
|
|
|
"FLversion: %s, " % self.flVersion,
|
2011-06-14 15:54:41 +00:00
|
|
|
"Glyphs stuff: %s, " % self.inGlyphs,
|
|
|
|
"Glyphs version: %s" % self.glyphsVersion
|
2011-06-14 15:53:08 +00:00
|
|
|
]
|
|
|
|
return "".join(s)
|
2008-01-07 17:40:34 +00:00
|
|
|
|
|
|
|
|
|
|
|
world = RFWorld()
|
|
|
|
|
|
|
|
lineBreak = os.linesep
|
|
|
|
|
|
|
|
if world.inFontLab:
|
2011-05-07 08:07:37 +00:00
|
|
|
from robofab.interface.all.dialogs import SelectFont, SelectGlyph
|
2008-01-08 19:18:06 +00:00
|
|
|
from robofab.objects.objectsFL import CurrentFont, CurrentGlyph, RFont, RGlyph, OpenFont, NewFont, AllFonts
|
2008-01-07 17:40:34 +00:00
|
|
|
lineBreak = "\n"
|
2011-06-14 15:54:41 +00:00
|
|
|
elif world.inGlyphs:
|
2011-06-14 17:42:58 +00:00
|
|
|
from objectsGS import CurrentFont, CurrentGlyph, RFont, RGlyph, OpenFont, NewFont, AllFonts
|
2008-01-07 17:40:34 +00:00
|
|
|
elif world.inPython:
|
2008-01-08 19:18:06 +00:00
|
|
|
from robofab.objects.objectsRF import CurrentFont, CurrentGlyph, RFont, RGlyph, OpenFont, NewFont, AllFonts
|
2008-01-07 17:40:34 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
f = RFWorld()
|
|
|
|
print f
|