示例#1
0
def interact(list, pythondir):
    """Let the user interact with the dialog"""
    opythondir = pythondir
    try:
        # Try to go to the "correct" dir for GetDirectory
        os.chdir(pythondir.as_pathname())
    except os.error:
        pass
    d = GetNewDialog(DIALOG_ID, -1)
    tp, h, rect = d.GetDialogItem(1)
    SetDialogItemText(h, string.joinfields(list, '\r'))
    while 1:
        n = ModalDialog(None)
        if n == OK_ITEM:
            break
        if n == CANCEL_ITEM:
            return None
        if n == REVERT_ITEM:
            return [], pythondir
        if n == DIR_ITEM:
            fss, ok = macfs.GetDirectory('Select python home folder:')
            if ok:
                pythondir = fss
    tmp = string.splitfields(GetDialogItemText(h), '\r')
    rv = []
    for i in tmp:
        if i:
            rv.append(i)
    return rv, pythondir
示例#2
0
def GetFolder(message=None):
    """
	Select folder dialog. Returns path if one is selected. Otherwise it returns None.
	Availability: FontLab, Macintosh, PC
	"""
    path = None
    if MAC:
        if haveMacfs:
            fss, ok = macfs.GetDirectory(message)
            if ok:
                path = fss.as_pathname()
        else:
            from robofab.interface.mac.getFileOrFolder import GetFileOrFolder
            # This _also_ allows the user to select _files_, but given the
            # package/folder dichotomy, I think we have no other choice.
            path = GetFileOrFolder(message)
    elif PC:
        if inFontLab:
            if not message:
                message = ''
            path = fl.GetPathName('', message)
        else:
            myTuple = shell.SHBrowseForFolder(0, None, message, 64)
            try:
                path = shell.SHGetPathFromIDList(myTuple[0])
            except:
                pass
    else:
        _raisePlatformError('GetFile')
    return path
示例#3
0
def main():
    # Ask the user for the plugins directory
    dir, ok = macfs.GetDirectory('Where is the PlugIns folder?')
    if not ok: sys.exit(0)
    os.chdir(dir.as_pathname())

    # Remove old .slb aliases and collect a list of .slb files
    if EasyDialogs.AskYesNoCancel('Proceed with removing old aliases?') <= 0:
        sys.exit(0)
    LibFiles = []
    allfiles = os.listdir(':')
    for f in allfiles:
        if f[-4:] == '.slb':
            finfo = macfs.FSSpec(f).GetFInfo()
            if finfo.Flags & 0x8000:
                os.unlink(f)
            else:
                LibFiles.append(f)

    print LibFiles
    # Create the new aliases.
    if EasyDialogs.AskYesNoCancel('Proceed with creating new ones?') <= 0:
        sys.exit(0)
    for dst, src in goals:
        if src in LibFiles:
            macostools.mkalias(src, dst)
        else:
            EasyDialogs.Message(dst + ' not created: ' + src + ' not found')

    EasyDialogs.Message('All done!')
示例#4
0
def main():
    dir, ok = macfs.GetDirectory('Python source folder:')
    if not ok:
        sys.exit(0)
    dir = dir.as_pathname()
    for routine, arg, list in INSTRUCTIONS:
        routine(dir, arg, list)
    print "All done!"
    sys.exit(1)
示例#5
0
 def __init__(self):
     InitUI()
     fss, ok = macfs.GetDirectory('Source directory:')
     if not ok:
         sys.exit(0)
     os.chdir(fss.as_pathname())
     self.typedist = GetType()
     print 'TYPE', self.typedist
     self.inc = IncMatcher(self.typedist, '(MkDistr.include)')
     self.exc = ExcMatcher(self.typedist, '(MkDistr.exclude)')
     self.ui = MkDistrUI(self)
     self.ui.mainloop()
示例#6
0
	def __init__(self):
		InitUI()
		dir, ok = macfs.GetDirectory('Cvsgui source folder:')
		if not ok:
			sys.exit(0)
		self.root = dir.as_pathname()
		os.chdir(self.root)
		if not os.path.isdir(':MacCvs:Distrib'):
			os.mkdir(':MacCvs:Distrib')
		self.typedist = GetType()
		self.inc = IncMatcher(':MacCvs:Distrib:%s.include'%self.typedist)
		self.exc = ExcMatcher(':MacCvs:Distrib:%s.exclude'%self.typedist)
		self.ui = MkDistrUI(self)
		self.ui.mainloop()
示例#7
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
示例#8
0
def _macGetDirectory(prompt='select a directory'):
    carbon = drawer.isCarbon()
    if carbon:
        import EasyDialogs
        path = EasyDialogs.AskFolder(message=prompt)
        if path == None: return '', 0
        else: return path, 1
    else:
        import macfs
        fsspec, ok = macfs.GetDirectory(prompt)
        if ok != 1:
            return '', 0  # failure
        path = fsspec.as_pathname()
        drawer.pathScrub(path)
        return path, 1
示例#9
0
def main():
    if len(sys.argv) != 2:
        if sys.platform == 'mac':
            import macfs
            fss, ok = macfs.GetDirectory("Where are the interop documents?")
            if not ok:
                sys.exit(0)
            dirname = fss.as_pathname()
        else:
            print >> sys.stderr, "Usage: %s interopdirname" % sys.argv[0]
            sys.exit(1)
    else:
        dirname = sys.argv[1]
    files = getsmilfiles(dirname)
    for testlog in TESTLOGS:
        updatetestlog(testlog, files[:])
示例#10
0
def main():
    if len(sys.argv) > 1:
        for dir in sys.argv[1:]:
            dodir(dir)
    elif os.name == 'mac':
        import macfs
        dir, ok = macfs.GetDirectory('Folder to search:')
        if not ok:
            sys.exit(0)
        dodir(dir.as_pathname())
    else:
        print 'Usage: hexbintree dir ...'
        sys.exit(1)
    if os.name == 'mac':
        sys.exit(1)  # Keep window
    else:
        sys.exit(0)
示例#11
0
# fixgusidir - Modify filenames in the CWGUSI source tree, so
示例#12
0
#
# Turn a pyc file into a resource file containing it in 'PYC ' resource form
from Carbon.Res import *
from Carbon import Res
from Carbon.Resources import *
import os
import macfs
import sys
import py_resource
error = 'mkpycresourcefile.error'

def mkpycresourcefile(src, dst):
    """Copy pyc file/dir src to resource file dst."""
    if not os.path.isdir(src) and src[-4:] <> '.pyc':
        raise error, 'I can only handle .pyc files or directories'
    fsid = py_resource.create(dst)
    if os.path.isdir(src):
        handlesubdir(src)
    else:
        id, name = py_resource.frompycfile(src)
        print 'Wrote %d: %s %s' % (id, name, src)
    CloseResFile(fsid)

def handlesubdir(srcdir):
    """Recursively scan a directory for pyc files and copy to resources"""
    src = os.listdir(srcdir)
    for file in src:
        file = os.path.join(srcdir, file)
        if os.path.isdir(file):
            handlesubdir(file)
示例#13
0
"""	  ***DANGEROUS***
	  script to remove 
	  all results of a 
	   build process. 
	    ***Don't*** 
	run this if you are
	     ***not***
	  building Python 
	  from the source
	        !!!
"""
import macfs
import os
import sys
import re
sweepfiletypes = [
    'APPL',  # applications
    'Atmp',  # applet template
    'shlb',  # shared libs
    'MPSY',  # SYM and xSYM files
    'PYC ',  # .pyc files
]
sweepfolderre = re.compile(r"(.*) Data$")

def remove(top):
    if os.path.isdir(top):
        for name in os.listdir(top):
            path = os.path.join(top, name)
            remove(path)
    os.remove(top)
示例#14
0
"""Easy to use dialogs.
示例#15
0
"""findgremlins - Search through a folder and subfolders for
示例#16
0
    writemodule(name, id, open(file, 'rb').read())
    return id + 1


def handlesubdir(handle, id, srcdir):
    """Recursively scan a directory for pyc files and copy to resources"""
    print 'Directory', srcdir
    src = os.listdir(srcdir)
    for file in src:
        file = os.path.join(srcdir, file)
        if os.path.isdir(file):
            id = handlesubdir(handle, id, file)
        elif file[-4:] == '.pyc':
            id = handleonepycfile(handle, id, file)
    return id


if __name__ == '__main__':
    args = sys.argv[1:]
    if not args:
        ifss, ok = macfs.GetDirectory('Select root of tree to pack:')
        if not ok:
            sys.exit(0)
        args = [ifss.as_pathname()]
    for ifn in args:
        ofss, ok = macfs.StandardPutFile('Output for ' + os.path.split(ifn)[1])
        if not ok:
            sys.exit(0)
        mkpycresourcefile(ifn, ofss.as_pathname())
    sys.exit(1)  # So we can see something...
示例#17
0
"""
示例#18
0
def run(change):
    fss, ok = macfs.GetDirectory('Folder to search:')
    if not ok:
        sys.exit(0)
    walktree(fss.as_pathname(), change)
示例#19
0
# Extract files from a SHAR archive.
示例#20
0
#
示例#21
0
"""Utility routines depending on the finder,
示例#22
0
"""Edit the Python Preferences file."""
示例#23
0
# Zap .pyc files
示例#24
0
#
示例#25
0
#
示例#26
0
#
示例#27
0
# Test List module.
示例#28
0
"""Import a module while pretending its name is __main__. This