def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" src = File.pathname(src) dst = File.pathname(dst) if createpath: mkdirs(os.path.split(dst)[0]) ifp = open(src, 'rb') ofp = open(dst, 'wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() ifp = openrf(src, '*rb') ofp = openrf(dst, '*wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() srcfss = File.FSSpec(src) dstfss = File.FSSpec(dst) sf = srcfss.FSpGetFInfo() df = dstfss.FSpGetFInfo() df.Creator, df.Type = sf.Creator, sf.Type if forcetype != None: df.Type = forcetype df.Flags = (sf.Flags & COPY_FLAGS) dstfss.FSpSetFInfo(df) if copydates: srcfsr = File.FSRef(src) dstfsr = File.FSRef(dst) catinfo, _, _, _ = srcfsr.FSGetCatalogInfo(Files.kFSCatInfoAllDates) dstfsr.FSSetCatalogInfo(Files.kFSCatInfoAllDates, catinfo) touched(dstfss)
def copy(src, dst, createpath=0, copydates=1, forcetype=None): """Copy a file, including finder info, resource fork, etc""" src = File.pathname(src) dst = File.pathname(dst) if createpath: mkdirs(os.path.split(dst)[0]) ifp = open(src, 'rb') ofp = open(dst, 'wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() ifp = openrf(src, '*rb') ofp = openrf(dst, '*wb') d = ifp.read(BUFSIZ) while d: ofp.write(d) d = ifp.read(BUFSIZ) ifp.close() ofp.close() srcfss = File.FSSpec(src) dstfss = File.FSSpec(dst) sf = srcfss.FSpGetFInfo() df = dstfss.FSpGetFInfo() df.Creator, df.Type = sf.Creator, sf.Type if forcetype != None: df.Type = forcetype df.Flags = (sf.Flags & COPY_FLAGS) dstfss.FSpSetFInfo(df) if copydates: srcfsr = File.FSRef(src) dstfsr = File.FSRef(dst) catinfo, _, _, _ = srcfsr.FSGetCatalogInfo(Files.kFSCatInfoAllDates) dstfsr.FSSetCatalogInfo(Files.kFSCatInfoAllDates, catinfo) touched(dstfss)
def set(self, path_or_fss, start=0): self.SetPort() if self.movie: #self.GetWindow().InvalWindowRect(self.movie.GetMovieBox()) Qd.PaintRect(self.movie.GetMovieBox()) path = File.pathname(path) self.movietitle = os.path.basename(path) movieResRef = Qt.OpenMovieFile(path_or_fss, 1) self.movie, dummy, dummy = Qt.NewMovieFromFile( movieResRef, 0, QuickTime.newMovieActive) self.moviebox = self.movie.GetMovieBox() self.calcmoviebox() Qd.ObscureCursor() # XXX does this work at all? self.movie.GoToBeginningOfMovie() if start: self.movie.StartMovie() self.running = 1 else: self.running = 0 self.movie.MoviesTask(0)
# Make sure fonts are found on Mac OS X if platform.system() == 'Darwin': fontPaths = [] try: from Carbon import File, Folder, Folders # @UnresolvedImport domains = [ Folders.kUserDomain, Folders.kLocalDomain, Folders.kSystemDomain ] if not runningFromSource: domains.append(Folders.kNetworkDomain) for domain in domains: try: fsref = Folder.FSFindFolder(domain, Folders.kFontsFolderType, False) fontPaths.append(File.pathname(fsref)) except: pass # Folder probably doesn't exist. except: fontPaths.extend([ os.path.expanduser('~/Library/Fonts'), '/Library/Fonts', '/Network/Library/Fonts', '/System/Library/Fonts' ]) os.environ['OSG_FILE_PATH'] = ':'.join(fontPaths) # Set up for internationalization. import gettext as gettext_module, __builtin__ __builtin__.gettext = gettext_module.translation('Neuroptikon', fallback=True).lgettext # Install a new version of inspect.getdoc() that converts any reST formatting to plain text.
except ImportError: pass # Make sure fonts are found on Mac OS X if platform.system() == 'Darwin': fontPaths = [] try: from Carbon import File, Folder, Folders # @UnresolvedImport domains = [Folders.kUserDomain, Folders.kLocalDomain, Folders.kSystemDomain] if not runningFromSource: domains.append(Folders.kNetworkDomain) for domain in domains: try: fsref = Folder.FSFindFolder(domain, Folders.kFontsFolderType, False) fontPaths.append(File.pathname(fsref)) except: pass # Folder probably doesn't exist. except: fontPaths.extend([os.path.expanduser('~/Library/Fonts'), '/Library/Fonts', '/Network/Library/Fonts', '/System/Library/Fonts']) os.environ['OSG_FILE_PATH'] = ':'.join(fontPaths) # Set up for internationalization. import gettext as gettext_module, __builtin__ __builtin__.gettext = gettext_module.translation('Neuroptikon', fallback = True).lgettext # Install a new version of inspect.getdoc() that converts any reST formatting to plain text. import inspect, re _orig_getdoc = inspect.getdoc