Esempio n. 1
0
def GetType():
    """Ask user for distribution type"""
    while 1:
        d = Dlg.GetNewDialog(ID_DTYPE, -1)
        d.SetDialogDefaultItem(DTYPE_EXIST)
        d.SetDialogCancelItem(DTYPE_CANCEL)
        while 1:
            rv = ModalDialog(None)
            if rv in (DTYPE_EXIST, DTYPE_NEW, DTYPE_CANCEL):
                break
        del d
        if rv == DTYPE_CANCEL:
            sys.exit(0)
        if rv == DTYPE_EXIST:
            ##			macfs.SetFolder(':(MkDistr)')
            fss, ok = macfs.StandardGetFile('TEXT')
            if not ok:
                sys.exit(0)
            path = fss.as_pathname()
            basename = os.path.split(path)[-1]
            if basename[-8:] <> '.include':
                EasyDialogs.Message('That is not a distribution include file')
            else:
                return basename[:-8]
        else:
            name = EasyDialogs.AskString('Distribution name:')
            if name:
                return name
            sys.exit(0)
Esempio n. 2
0
def browseTTFont():
    fss, ok = macfs.StandardGetFile()
    if not ok:
        return
    path = fss.as_pathname()
    indices = macUtils.getSFNTResIndices(path)
    if indices:
        for i in indices:
            TableBrowser(path, res_index=i)
    else:
        TableBrowser(path)
Esempio n. 3
0
 def do_itemhit(self, item, event):
     if item == ITEM_INPUTURL_BROWSE:
         # XXXX This is an error in Python:
         ##fss, ok = macfs.StandardGetFile('TEXT')
         fss, ok = macfs.StandardGetFile()
         if ok:
             pathname = fss.as_pathname()
             url = MMurl.pathname2url(pathname)
             h = self._dlg.GetDialogItemAsControl(ITEM_INPUT_TEXT)
             Dlg.SetDialogItemText(h, _string2dialog(url))
             self._dlg.SelectDialogItemText(ITEM_INPUT_TEXT, 0, 32767)
         return 1
     return InputDialog.do_itemhit(self, item, event)
Esempio n. 4
0
def interact():
    d = Dlg.GetNewDialog(DIALOG_ID, -1)
    wdir = stdin = stdout = None
    pause = 0

    tp, in_c_h, rect = d.GetDialogItem(STDIN_CONS)
    tp, in_f_h, rect = d.GetDialogItem(STDIN_FILE)
    tp, out_c_h, rect = d.GetDialogItem(STDOUT_CONS)
    tp, out_f_h, rect = d.GetDialogItem(STDOUT_FILE)
    tp, pause_h, rect = d.GetDialogItem(PAUSE)
    in_c_h = in_c_h.as_Control()
    in_f_h = in_f_h.as_Control()
    out_c_h = out_c_h.as_Control()
    out_f_h = out_f_h.as_Control()
    pause_h = pause_h.as_Control()

    while 1:
        in_c_h.SetControlValue(not stdin)
        in_f_h.SetControlValue(not not stdin)
        out_c_h.SetControlValue(not stdout)
        out_f_h.SetControlValue(not not stdout)
        pause_h.SetControlValue(pause)

        n = Dlg.ModalDialog(None)
        if n == OK:
            break
        elif n == CANCEL:
            sys.exit(0)
        elif n == STDIN_CONS:
            stdin = None
        elif n == STDIN_FILE:
            fss, ok = macfs.StandardGetFile('TEXT')
            if ok:
                stdin = fss
        elif n == STDOUT_FILE:
            fss, ok = macfs.StandardPutFile('stdout:')
            if ok:
                stdout = fss
        elif n == WORKING_DIR:
            fss, ok = macfs.GetDirectory()
            if ok:
                wdir = fss
        elif n == PAUSE:
            pause = (not pause)

    tp, h, rect = d.GetDialogItem(SCRIPTNAME)
    name = Dlg.GetDialogItemText(h)
    tp, h, rect = d.GetDialogItem(ARGV)
    argv = Dlg.GetDialogItemText(h)
    return name, argv, stdin, stdout, wdir, pause
Esempio n. 5
0
def main():
	import sys
	sys.stdout = sys.stderr
	del sys.argv[:1]
	if not sys.argv:
		import macfs
		srcfss, ok = macfs.StandardGetFile('TEXT')
		if not ok:
			return
		filename = srcfss.as_pathname()
		sys.argv.append(filename)
	import __main__
	try:
		execfile(sys.argv[0], __main__.__dict__)
	except SystemExit, msg:
		if msg:
			message("Exit status: %s" % str(msg))
		print "exit", `msg`
Esempio n. 6
0
def mac_getargs(args):
    inputs = []
    output = None
    commands = None
    ramprefix = None
    switched = 0

    import macfs
    import EasyDialogs
    if args[1:]:
        inputs = args[1:]
    else:
        fss, ok = macfs.StandardGetFile()
        if not ok:
            sys.exit(0)
        inputs = [fss.as_pathname()]
    dir = os.path.split(inputs[0])[0]
    os.chdir(dir)
    for i in range(len(inputs)):
        filename = inputs[i]
        if filename[:len(dir)] == dir:
            inputs[i] = filename[len(dir):]
    if len(inputs) == 1:
        dft = 'g2_' + inputs[0][1:]
        fss, ok = macfs.StandardPutFile("G2 output file", dft)
        if not ok:
            sys.exit(0)
        output = fss.as_pathname()
    fss, ok = macfs.StandardPutFile("Script output (cancel for text)", "Conversion script")
    if ok:
        commands = fss.as_pathname()
    reply = EasyDialogs.AskString("URL prefix for use in .ram file (cancel for no ram file)")
    if reply:
        ramprefix = reply
    reply = EasyDialogs.AskYesNoCancel("Create G2/GRiNS switch statements?")
    if reply > 0:
        switched = 1
    return inputs, output, commands, ramprefix, switched
Esempio n. 7
0
		Res.UseResFile(resref)
		if not nameOrID:
			# just take the first in the file
			res = Res.Get1IndResource(resType, 1)
		elif type(nameOrID) == types.IntType:
			res = Res.Get1Resource(resType, nameOrID)
		else:
			res = Res.Get1NamedResource(resType, nameOrID)
		theID, theType, name = res.GetResInfo()
		data = res.data
	finally:
		Res.CloseResFile(resref)
	return data


def fromFile(pathOrFSSpec, nameOrID="", resType='NFNT'):
	data = dataFromFile(pathOrFSSpec, nameOrID, resType)
	return NFNT(data)


if __name__ == "__main__":
	import macfs
	fss, ok = macfs.StandardGetFile('FFIL')
	if ok:
		data = dataFromFile(fss)
		font = NFNT(data)
		font.unpackGlyphs()
		font.packGlyphs()
		data2 = font.compile()
		print "xxxxx", data == data2, len(data) == len(data2)
Esempio n. 8
0
		sep = sep + '\r'	# mac or dos
	if '\n' in data:
		sep = sep + '\n'	# unix or dos
	return string.split(data, sep)

def writelines(path, lines, sep='\r'):
	f = open(path, 'wb')
	for line in lines:
		f.write(line + sep)
	f.close()
	
	

if __name__ == "__main__":
	import macfs
	fss, ok = macfs.StandardGetFile('TEXT')
	if ok:
		path = fss.as_pathname()
		afm = AFM(path)
		char = 'A'
		if afm.has_char(char):
			print(afm[char])	# print charnum, width and boundingbox
		pair = ('A', 'V')
		if afm.has_kernpair(pair):
			print(afm[pair])	# print kerning value for pair
		print(afm.Version)	# various other afm entries have become attributes
		print(afm.Weight)
		# afm.comments() returns a list of all Comment lines found in the AFM
		print(afm.comments())
		#print afm.chars()
		#print afm.kernpairs()
Esempio n. 9
0
# A minimal text editor.
Esempio n. 10
0
# Extract files from a SHAR archive.
        waver = WaveWriter(fpOut, bitStream)
        if self.volumeMin > 0: waver.SetVolumeMin(self.volumeMin)
        if self.volumeMax > 0: waver.SetVolumeMax(self.volumeMax)
        waver.WriteWave()

        fpOut.close()


# main

if sys.platform == "mac":

    # Mac has no command-line (pre OS X)

    fsSpecIn, ok = macfs.StandardGetFile()
    if not ok: sys.exit(1)

    fsSpecOut, ok = macfs.StandardPutFile("Save wave file as:")
    if not ok: sys.exit(1)

    convertor = Convertor(fsSpecIn.as_pathname(), fsSpecOut.as_pathname())

else:

    # a command-line is assumed here

    if len(sys.argv) != 3:
        print "Syntax:", sys.argv[0], "<inputfile.uef> <outputfile.wav>"
        sys.exit(1)
Esempio n. 12
0
"""imgconvert - A very simple image converter."""
import img
import sys
import os
# Set trace, so we can see what happens
img.settrace(1)
if os.name == 'mac':
    import macfs
    fss, ok = macfs.StandardGetFile()
    if not ok: sys.exit(0)
    infile = fss.as_pathname()
    fss, ok = macfs.StandardPutFile('Output?')
    if not ok: sys.exit(0)
    outfile = fss.as_pathname()
else:
    if len(sys.argv) <> 3:
        print 'Usage:', sys.argv[0], 'inimage outimage'
        sys.exit(1)
    infile = sys.argv[1]
    outfile = sys.argv[2]
#
# Create a non-converting writer (we do conversion in the reader)
#
writer = img.writer(None, outfile)
#
# Create a reader that converts to the preferred output format
#
reader = img.reader(writer.format, infile)
#
# Set output file parameters
Esempio n. 13
0
from Carbon import Qt
Esempio n. 14
0
    m = re.search(r"/FontName\s+/([^ \t\n\r]+)\s+def", data)
    if m:
        fontName = m.group(1)
    else:
        fontName = None
    interpreter = PSInterpreter()
    interpreter.interpret(
        "/Helvetica 4 dict dup /Encoding StandardEncoding put definefont pop")
    interpreter.interpret(data)
    fontdir = interpreter.dictstack[0]['FontDirectory'].value
    if fontdir.has_key(fontName):
        rawfont = fontdir[fontName]
    else:
        # fall back, in case fontName wasn't found
        fontNames = fontdir.keys()
        if len(fontNames) > 1:
            fontNames.remove("Helvetica")
        fontNames.sort()
        rawfont = fontdir[fontNames[0]]
    interpreter.close()
    return unpack_item(rawfont)


if __name__ == "__main__":
    import macfs
    fss, ok = macfs.StandardGetFile("LWFN")
    if ok:
        from fontTools import t1Lib
        data, kind = t1Lib.read(fss.as_pathname())
        font = suckfont(data)
Esempio n. 15
0
"""MovieInWindow converted to python
Esempio n. 16
0
# Script (applet) to run any Python command
Esempio n. 17
0
 def domenu_open(self, *args):
     fss, ok = macfs.StandardGetFile()
     if ok:
         self.opendocument(fss.as_pathname())
Esempio n. 18
0
"""Import a module while pretending its name is __main__. This
Esempio n. 19
0
# A minimal text editor.
Esempio n. 20
0
#
Esempio n. 21
0
"""VerySimplePlayer converted to python
Esempio n. 22
0
"""Easy to use dialogs.
Esempio n. 23
0
# A minimal text editor using MLTE. Based on wed.py.
Esempio n. 24
0
# A minimal text editor.
Esempio n. 25
0
"""imgbrowse - Display pictures using img"""