def parse(str, flags=0, pattern=None): # parse 're' pattern into list of (opcode, argument) tuples source = Tokenizer(str) if pattern is None: pattern = Pattern() pattern.flags = flags pattern.str = str p = _parse_sub(source, pattern, 0) if (sys.py3kwarning and (p.pattern.flags & SRE_FLAG_LOCALE) and (p.pattern.flags & SRE_FLAG_UNICODE)): import warnings warnings.warnpy3k("LOCALE and UNICODE flags are incompatible", DeprecationWarning, stacklevel=5) tail = source.get() if tail == ")": raise error, "unbalanced parenthesis" elif tail: raise error, "bogus characters at end of regular expression" if not (flags & SRE_FLAG_VERBOSE) and p.pattern.flags & SRE_FLAG_VERBOSE: # the VERBOSE flag was switched on inside the pattern. to be # on the safe side, we'll parse the whole thing again... return parse(str, p.pattern.flags) if flags & SRE_FLAG_DEBUG: p.dump() return p
def walk(top, func, arg): """Directory tree walk with callback function. For each directory in the directory tree rooted at top (including top itself, but excluding '.' and '..'), call func(arg, dirname, fnames). dirname is the name of the directory, and fnames a list of the names of the files and subdirectories in dirname (excluding '.' and '..'). func may modify the fnames list in-place (e.g. via del or slice assignment), and walk will only recurse into the subdirectories whose names remain in fnames; this can be used to implement a filter, or to impose a specific order of visiting. No semantics are defined for, or required of, arg, beyond that arg is always passed to func. It can be used, e.g., to pass a filename pattern, or a mutable object designed to accumulate statistics. Passing None for arg is common.""" warnings.warnpy3k("In 3.x, os.path.walk is removed in favor of os.walk.", stacklevel=2) try: names = os.listdir(top) except os.error: return func(arg, top, names) for name in names: name = join(top, name) if isdir(name): walk(name, func, arg)
def _escape(source, escape, state, nested): # handle escape code in expression code = CATEGORIES.get(escape) if code: return code code = ESCAPES.get(escape) if code: return code try: c = escape[1:2] if c == "x": # hexadecimal escape while source.next in HEXDIGITS and len(escape) < 4: escape = escape + source.get() if len(escape) != 4: raise ValueError return LITERAL, int(escape[2:], 16) & 0xff elif c == "0": # octal escape while source.next in OCTDIGITS and len(escape) < 4: escape = escape + source.get() return LITERAL, int(escape[1:], 8) & 0xff elif c in DIGITS: # octal escape *or* decimal group reference (sigh) if source.next in DIGITS: escape = escape + source.get() if (escape[1] in OCTDIGITS and escape[2] in OCTDIGITS and source.next in OCTDIGITS): # got three octal digits; this is an octal escape escape = escape + source.get() return LITERAL, int(escape[1:], 8) & 0xff # not an octal escape, so this is a group reference group = int(escape[1:]) if group < state.groups: if not state.checkgroup(group): raise error, "cannot refer to open group" if state.lookbehind: import warnings warnings.warn('group references in lookbehind ' 'assertions are not supported', RuntimeWarning, stacklevel=nested + 6) return GROUPREF, group raise ValueError if len(escape) == 2: if sys.py3kwarning and c in ASCIILETTERS: import warnings if c in 'Uu': warnings.warn('bad escape %s; Unicode escapes are ' 'supported only since Python 3.3' % escape, FutureWarning, stacklevel=nested + 6) else: warnings.warnpy3k('bad escape %s' % escape, DeprecationWarning, stacklevel=nested + 6) return LITERAL, ord(escape[1]) except ValueError: pass raise error, "bogus escape: %s" % repr(escape)
def readPlistFromResource(path, restype = 'plst', resid = 0): warnings.warnpy3k('In 3.x, readPlistFromResource is removed.', stacklevel=2) from Carbon.File import FSRef, FSGetResourceForkName from Carbon.Files import fsRdPerm from Carbon import Res fsRef = FSRef(path) resNum = Res.FSOpenResourceFile(fsRef, FSGetResourceForkName(), fsRdPerm) Res.UseResFile(resNum) plistData = Res.Get1Resource(restype, resid).data Res.CloseResFile(resNum) return readPlistFromString(plistData)
def mkarg(x): from warnings import warnpy3k warnpy3k("in 3.x, mkarg has been removed.") if '\'' not in x: return ' \'' + x + '\'' s = ' "' for c in x: if c in '\\$"`': s = s + '\\' s = s + c s = s + '"' return s
def walk(top, func, arg): warnings.warnpy3k('In 3.x, os.path.walk is removed in favor of os.walk.', stacklevel=2) try: names = os.listdir(top) except os.error: return func(arg, top, names) for name in names: name = join(top, name) if isdir(name): walk(name, func, arg)
def __init__(self, attr, parent=None, imagetype=None): # replace standard MutableString init to not overwrite self.data from warnings import warnpy3k warnpy3k('the class UserString.MutableString has been removed in ' 'Python 3.0', stacklevel=2) self.attr = attr if imagetype is None: imagetype = self._types[attr] self.imagetype = imagetype self.parent = parent if parent: self.hostname = parent.get('hostname', parent.get('host', None))
def urlopen(url, data = None, proxies = None): global _urlopener from warnings import warnpy3k warnpy3k('urllib.urlopen() has been removed in Python 3.0 in favor of urllib2.urlopen()', stacklevel=2) if proxies is not None: opener = FancyURLopener(proxies=proxies) elif not _urlopener: opener = FancyURLopener() _urlopener = opener else: opener = _urlopener if data is None: return opener.open(url) else: return opener.open(url, data)
def walk(top, func, arg): warnings.warnpy3k('In 3.x, os.path.walk is removed in favor of os.walk.', stacklevel=2) try: names = os.listdir(top) except os.error: return func(arg, top, names) for name in names: name = join(top, name) try: st = os.lstat(name) except os.error: continue if stat.S_ISDIR(st.st_mode): walk(name, func, arg)
def writePlistToResource(rootObject, path, restype = 'plst', resid = 0): warnings.warnpy3k('In 3.x, writePlistToResource is removed.', stacklevel=2) from Carbon.File import FSRef, FSGetResourceForkName from Carbon.Files import fsRdWrPerm from Carbon import Res plistData = writePlistToString(rootObject) fsRef = FSRef(path) resNum = Res.FSOpenResourceFile(fsRef, FSGetResourceForkName(), fsRdWrPerm) Res.UseResFile(resNum) try: Res.Get1Resource(restype, resid).RemoveResource() except Res.Error: pass res = Res.Resource(plistData) res.AddResource(restype, resid, '') res.WriteResource() Res.CloseResFile(resNum)
def myurlopen(self,url,data = None, proxies = None): #///////////// # Shortcut for basic usage _urlopener = None """Create a file-like object for the specified URL to read from.""" from warnings import warnpy3k warnings.warnpy3k("urllib.urlopen() has been removed in Python 3.0 in " "favor of urllib2.urlopen()", stacklevel=2) if proxies is not None: opener = myURLopener(proxies=proxies) elif not _urlopener: opener = myURLopener() _urlopener = opener else: opener = _urlopener if data is None: return opener.open(url) else: return opener.open(url, data)
def _class_escape(source, escape, nested): # handle escape code inside character class code = ESCAPES.get(escape) if code: return code code = CATEGORIES.get(escape) if code and code[0] == IN: return code try: c = escape[1:2] if c == "x": # hexadecimal escape (exactly two digits) while source.next in HEXDIGITS and len(escape) < 4: escape = escape + source.get() escape = escape[2:] if len(escape) != 2: raise error, "bogus escape: %s" % repr("\\" + escape) return LITERAL, int(escape, 16) & 0xff elif c in OCTDIGITS: # octal escape (up to three digits) while source.next in OCTDIGITS and len(escape) < 4: escape = escape + source.get() escape = escape[1:] return LITERAL, int(escape, 8) & 0xff elif c in DIGITS: raise error, "bogus escape: %s" % repr(escape) if len(escape) == 2: if sys.py3kwarning and c in ASCIILETTERS: import warnings if c in 'Uu': warnings.warn('bad escape %s; Unicode escapes are ' 'supported only since Python 3.3' % escape, FutureWarning, stacklevel=nested + 6) else: warnings.warnpy3k('bad escape %s' % escape, DeprecationWarning, stacklevel=nested + 6) return LITERAL, ord(escape[1]) except ValueError: pass raise error, "bogus escape: %s" % repr(escape)
# Embedded file name: scripts/common/Lib/plat-mac/macostools.py """macostools - Various utility functions for MacOS. mkalias(src, dst) - Create a finder alias 'dst' pointing to 'src' copy(src, dst) - Full copy of 'src' to 'dst' """ from warnings import warnpy3k warnpy3k('In 3.x, the macostools module is removed.', stacklevel=2) from Carbon import Res from Carbon import File, Files import os import errno import MacOS try: openrf = MacOS.openrf except AttributeError: openrf = open Error = 'macostools.Error' BUFSIZ = 524288 COPY_FLAGS = Files.kIsStationary | Files.kNameLocked | Files.kHasBundle | Files.kIsInvisible | Files.kIsAlias def mkalias(src, dst, relative = None): """Create a finder alias""" srcfsr = File.FSRef(src) dstdir, dstname = os.path.split(dst) if not dstdir: dstdir = os.curdir dstdirfsr = File.FSRef(dstdir) if relative: relativefsr = File.FSRef(relative)
# Python bytecode 2.7 (decompiled from Python 2.7) # Embedded file name: scripts/common/Lib/plat-mac/EasyDialogs.py from warnings import warnpy3k warnpy3k('In 3.x, the EasyDialogs module is removed.', stacklevel=2) from Carbon.Dlg import GetNewDialog, SetDialogItemText, GetDialogItemText, ModalDialog from Carbon import Qd from Carbon import QuickDraw from Carbon import Dialogs from Carbon import Windows from Carbon import Dlg, Win, Evt, Events from Carbon import Ctl from Carbon import Controls from Carbon import Menu from Carbon import AE import Nav import MacOS import string from Carbon.ControlAccessor import * import Carbon.File import macresource import os import sys __all__ = [ 'Message', 'AskString', 'AskPassword', 'AskYesNoCancel', 'GetArgv', 'AskFileForOpen', 'AskFileForSave', 'AskFolder', 'ProgressBar' ] _initialized = 0 def _initialize(): global _initialized
# 2016.05.01 15:31:32 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/plat-mac/applesingle.py """Routines to decode AppleSingle files """ from warnings import warnpy3k warnpy3k('In 3.x, the applesingle module is removed.', stacklevel=2) import struct import sys try: import MacOS import Carbon.File except: class MacOS: def openrf(path, mode): return open(path + '.rsrc', mode) openrf = classmethod(openrf) class Carbon: class File: class FSSpec: pass class FSRef: pass
# 2016.08.04 20:01:02 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/plat-mac/cfmfile.py """codefragments.py -- wrapper to modify code fragments.""" __version__ = '0.8b3' __author__ = 'jvr' import warnings warnings.warnpy3k('the cfmfile module is deprecated and is removed in 3,0', stacklevel=2) import Carbon.File import struct from Carbon import Res import os import sys DEBUG = 0 error = 'cfm.error' BUFSIZE = 524288 def mergecfmfiles(srclist, dst, architecture='fat'): """Merge all files in srclist into a new file dst. If architecture is given, only code fragments of that type will be used: "pwpc" for PPC, "m68k" for cfm68k. This does not work for "classic" 68k code, since it does not use code fragments to begin with. If architecture is None, all fragments will be used, enabling FAT binaries. """ srclist = list(srclist) for i in range(len(srclist)): srclist[i] = Carbon.File.pathname(srclist[i]) dst = Carbon.File.pathname(dst)
def parse_template(source, pattern): # parse 're' replacement string into list of literals and # group references s = Tokenizer(source) sget = s.get p = [] a = p.append def literal(literal, p=p, pappend=a): if p and p[-1][0] is LITERAL: p[-1] = LITERAL, p[-1][1] + literal else: pappend((LITERAL, literal)) sep = source[:0] if type(sep) is type(""): makechar = chr else: makechar = chr while 1: this = sget() if this is None: break # end of replacement string if this and this[0] == "\\": # group c = this[1:2] if c == "g": name = "" if s.match("<"): while 1: char = sget() if char is None: raise error("unterminated group name") if char == ">": break name = name + char if not name: raise error("missing group name") try: index = int(name) if index < 0: raise error("negative group number") except ValueError: if not isname(name): raise error("bad character in group name") try: index = pattern.groupindex[name] except KeyError: msg = "unknown group name: {0!r}".format(name) raise IndexError(msg) a((MARK, index)) elif c == "0": if s.next in OCTDIGITS: this = this + sget() if s.next in OCTDIGITS: this = this + sget() literal(makechar(int(this[1:], 8) & 0xff)) elif c in DIGITS: isoctal = False if s.next in DIGITS: this = this + sget() if (c in OCTDIGITS and this[2] in OCTDIGITS and s.next in OCTDIGITS): this = this + sget() isoctal = True literal(makechar(int(this[1:], 8) & 0xff)) if not isoctal: a((MARK, int(this[1:]))) else: try: this = makechar(ESCAPES[this][1]) except KeyError: if sys.py3kwarning and c in ASCIILETTERS: import warnings warnings.warnpy3k('bad escape %s' % this, DeprecationWarning, stacklevel=4) literal(this) else: literal(this) # convert template to groups and literals lists i = 0 groups = [] groupsappend = groups.append literals = [None] * len(p) for c, s in p: if c is MARK: groupsappend((i, s)) # literal[i] is already None else: literals[i] = s i = i + 1 return groups, literals
# Python bytecode 2.7 (decompiled from Python 2.7) # Embedded file name: scripts/common/Lib/plat-mac/PixMapWrapper.py from warnings import warnpy3k warnpy3k('In 3.x, the PixMapWrapper module is removed.', stacklevel=2) from Carbon import Qd from Carbon import QuickDraw import struct import MacOS import img import imgformat _pmElemFormat = {'baseAddr': 'l', 'rowBytes': 'H', 'bounds': 'hhhh', 'top': 'h', 'left': 'h', 'bottom': 'h', 'right': 'h', 'pmVersion': 'h', 'packType': 'h', 'packSize': 'l', 'hRes': 'l', 'vRes': 'l', 'pixelType': 'h', 'pixelSize': 'h', 'cmpCount': 'h', 'cmpSize': 'h', 'planeBytes': 'l', 'pmTable': 'l', 'pmReserved': 'l'} _pmElemOffset = {'baseAddr': 0, 'rowBytes': 4,
# Video file reader, using QuickTime # # This module was quickly ripped out of another software package, so there is a good # chance that it does not work as-is and it needs some hacking. # # Jack Jansen, August 2000 # from warnings import warnpy3k warnpy3k("In 3.x, the videoreader module is removed.", stacklevel=2) import sys from Carbon import Qt from Carbon import QuickTime from Carbon import Qd from Carbon import Qdoffs from Carbon import QDOffscreen from Carbon import Res try: from Carbon import MediaDescr except ImportError: def _audiodescr(data): return None else: def _audiodescr(data): return MediaDescr.SoundDescription.decode(data) try:
"""Classes for manipulating audio devices (currently only for Sun and SGI)""" from __future__ import print_function from warnings import warnpy3k warnpy3k("the audiodev module has been removed in Python 3.0", stacklevel=2) del warnpy3k __all__ = ["error", "AudioDev"] class error(Exception): pass class Play_Audio_sgi: # Private instance variables ## if 0: access frameratelist, nchannelslist, sampwidthlist, oldparams, \ ## params, config, inited_outrate, inited_width, \ ## inited_nchannels, port, converter, classinited: private classinited = 0 frameratelist = nchannelslist = sampwidthlist = None def initclass(self): import AL self.frameratelist = [ (48000, AL.RATE_48000), (44100, AL.RATE_44100), (32000, AL.RATE_32000), (22050, AL.RATE_22050), (16000, AL.RATE_16000), (11025, AL.RATE_11025),
# Symbolic constants for use with sunaudiodev module # The names are the same as in audioio.h with the leading AUDIO_ # removed. from warnings import warnpy3k warnpy3k("the SUNAUDIODEV module has been removed in Python 3.0", stacklevel=2) del warnpy3k # Not all values are supported on all releases of SunOS. # Encoding types, for fields i_encoding and o_encoding ENCODING_NONE = 0 # no encoding assigned ENCODING_ULAW = 1 # u-law encoding ENCODING_ALAW = 2 # A-law encoding ENCODING_LINEAR = 3 # Linear PCM encoding # Gain ranges for i_gain, o_gain and monitor_gain MIN_GAIN = 0 # minimum gain value MAX_GAIN = 255 # maximum gain value # Balance values for i_balance and o_balance LEFT_BALANCE = 0 # left channel only MID_BALANCE = 32 # equal left/right channel RIGHT_BALANCE = 64 # right channel only BALANCE_SHIFT = 3 # Port names for i_port and o_port PORT_A = 1
""" Package generated from /Volumes/Sap/System Folder/Extensions/AppleScript Resource aeut resid 0 Standard Event Suites for English """ from warnings import warnpy3k warnpy3k("In 3.x, the StdSuites package is removed.", stacklevel=2) import aetools Error = aetools.Error import Text_Suite import AppleScript_Suite import Standard_Suite import Macintosh_Connectivity_Clas import QuickDraw_Graphics_Suite import QuickDraw_Graphics_Suppleme import Required_Suite import Table_Suite import Type_Names_Suite _code_to_module = { 'TEXT' : Text_Suite, 'ascr' : AppleScript_Suite, 'core' : Standard_Suite, 'macc' : Macintosh_Connectivity_Clas, 'qdrw' : QuickDraw_Graphics_Suite, 'qdsp' : QuickDraw_Graphics_Suppleme, 'reqd' : Required_Suite, 'tbls' : Table_Suite, 'tpnm' : Type_Names_Suite,
# Python bytecode 2.7 (decompiled from Python 2.7) # Embedded file name: scripts/common/Lib/plat-mac/macerrors.py from warnings import warnpy3k warnpy3k('In 3.x, the macerrors module is removed.', stacklevel=2) svTempDisable = -32768 svDisabled = -32640 fontNotOutlineErr = -32615 kURL68kNotSupportedError = -30788 kURLAccessNotAvailableError = -30787 kURLInvalidConfigurationError = -30786 kURLExtensionFailureError = -30785 kURLFileEmptyError = -30783 kURLInvalidCallError = -30781 kURLUnsettablePropertyError = -30780 kURLPropertyBufferTooSmallError = -30779 kURLUnknownPropertyError = -30778 kURLPropertyNotYetKnownError = -30777 kURLAuthenticationError = -30776 kURLServerBusyError = -30775 kURLUnsupportedSchemeError = -30774 kURLInvalidURLError = -30773 kURLDestinationExistsError = -30772 kURLProgressAlreadyDisplayedError = -30771 kURLInvalidURLReferenceError = -30770 controlHandleInvalidErr = -30599 controlInvalidDataVersionErr = -30597 errItemNotControl = -30596 errCantEmbedRoot = -30595 errCantEmbedIntoSelf = -30594 errWindowRegionCodeInvalid = -30593 errControlHiddenOrDisabled = -30592
# 2017.08.29 21:58:27 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/plat-mac/appletrawmain.py from warnings import warnpy3k warnpy3k('In 3.x, the appletrawmain module is removed.', stacklevel=2) import argvemulator import os import sys import marshal if not sys.argv or sys.argv[0][:1] == '-': _dir = os.path.split(sys.executable)[0] _dir = os.path.split(_dir)[0] _dir = os.path.join(_dir, 'Resources') sys.argv.insert(0, '__rawmain__') else: _dir = os.path.split(sys.argv[0])[0] sys.path.insert(0, _dir) argvemulator.ArgvCollector().mainloop() __file__ = os.path.join(_dir, '__main__.py') if os.path.exists(__file__): sys.argv[0] = __file__ del argvemulator del os del sys del _dir execfile(__file__) else: __file__ = os.path.join(_dir, '__main__.pyc') if os.path.exists(__file__): sys.argv[0] = __file__ _fp = open(__file__, 'rb') _fp.read(8)
# Python bytecode 2.7 (decompiled from Python 2.7) # Embedded file name: scripts/common/Lib/plat-mac/appletrunner.py from warnings import warnpy3k warnpy3k('In 3.x, the appletrunner module is removed.', stacklevel=2) import os import sys for name in [ '__rawmain__.py', '__rawmain__.pyc', '__main__.py', '__main__.pyc' ]: realmain = os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'Resources', name) if os.path.exists(realmain): break else: sys.stderr.write('%s: cannot find applet main program\n' % sys.argv[0]) sys.exit(1) sys.argv.insert(1, realmain) os.execve(sys.executable, sys.argv, os.environ)
"A sort of application framework for the Mac" DEBUG = 0 from warnings import warnpy3k warnpy3k("In 3.x, the FrameWork module is removed.", stacklevel=2) import MacOS import traceback from Carbon.AE import * from Carbon.AppleEvents import * from Carbon.Ctl import * from Carbon.Controls import * from Carbon.Dlg import * from Carbon.Dialogs import * from Carbon.Evt import * from Carbon.Events import * from Carbon.Help import * from Carbon.Menu import * from Carbon.Menus import * from Carbon.Qd import * from Carbon.QuickDraw import * #from Carbon.Res import * #from Carbon.Resources import * #from Carbon.Snd import * #from Carbon.Sound import * from Carbon.Win import * from Carbon.Windows import * import types
# 2016.08.04 20:00:50 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/plat-irix5/cdplayer.py from warnings import warnpy3k warnpy3k('the cdplayer module has been removed in Python 3.0', stacklevel=2) del warnpy3k cdplayerrc = '.cdplayerrc' class Cdplayer: def __init__(self, tracklist): import string self.artist = '' self.title = '' if type(tracklist) == type(''): t = [] for i in range(2, len(tracklist), 4): t.append((None, (string.atoi(tracklist[i:i + 2]), string.atoi(tracklist[i + 2:i + 4])))) tracklist = t self.track = [None] + [''] * len(tracklist) self.id = 'd' + string.zfill(len(tracklist), 2) for track in tracklist: start, length = track self.id = self.id + string.zfill(length[0], 2) + string.zfill( length[1], 2) try: import posix f = open(posix.environ['HOME'] + '/' + cdplayerrc, 'r') except IOError:
# 2016.02.14 12:50:01 Støední Evropa (bìžný èas) # Embedded file name: scripts/common/Lib/plat-mac/macerrors.py from warnings import warnpy3k warnpy3k("In 3.x, the macerrors module is removed.", stacklevel=2) svTempDisable = -32768 svDisabled = -32640 fontNotOutlineErr = -32615 kURL68kNotSupportedError = -30788 kURLAccessNotAvailableError = -30787 kURLInvalidConfigurationError = -30786 kURLExtensionFailureError = -30785 kURLFileEmptyError = -30783 kURLInvalidCallError = -30781 kURLUnsettablePropertyError = -30780 kURLPropertyBufferTooSmallError = -30779 kURLUnknownPropertyError = -30778 kURLPropertyNotYetKnownError = -30777 kURLAuthenticationError = -30776 kURLServerBusyError = -30775 kURLUnsupportedSchemeError = -30774 kURLInvalidURLError = -30773 kURLDestinationExistsError = -30772 kURLProgressAlreadyDisplayedError = -30771 kURLInvalidURLReferenceError = -30770 controlHandleInvalidErr = -30599 controlInvalidDataVersionErr = -30597 errItemNotControl = -30596 errCantEmbedRoot = -30595 errCantEmbedIntoSelf = -30594 errWindowRegionCodeInvalid = -30593
exec, eval(), execfile() and import, but executing the code in an environment that only exposes those built-in operations that are deemed safe. To this end, a modest collection of 'fake' modules is created which mimics the standard modules by the same names. It is a policy decision which built-in modules and operations are made available; this module provides a reasonable default, but derived classes can change the policies e.g. by overriding or extending class variables like ok_builtin_modules or methods like make_sys(). XXX To do: - r_open should allow writing tmp dir - r_exec etc. with explicit globals/locals? (Use rexec("exec ... in ...")?) """ from warnings import warnpy3k warnpy3k("the rexec module has been removed in Python 3.0", stacklevel=2) del warnpy3k import sys import __builtin__ import os import ihooks import imp __all__ = ["RExec"] class FileBase: ok_file_methods = ('fileno', 'flush', 'isatty', 'read', 'readline', 'readlines', 'seek', 'tell', 'write', 'writelines', 'xreadlines',
# 2017.08.29 21:58:27 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/plat-mac/argvemulator.py """argvemulator - create sys.argv from OSA events. Used by applets that want unix-style arguments. """ from warnings import warnpy3k warnpy3k('In 3.x, the argvemulator module is removed.', stacklevel=2) import sys import traceback from Carbon import AE from Carbon.AppleEvents import * from Carbon import Evt from Carbon import File from Carbon.Events import * import aetools class ArgvCollector: """A minimal FrameWork.Application-like class""" def __init__(self): self.quitting = 0 if len(sys.argv) > 1 and sys.argv[1][:4] == '-psn': del sys.argv[1] AE.AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, self.__runapp) AE.AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, self.__openfiles) def close(self): AE.AERemoveEventHandler(kCoreEventClass, kAEOpenApplication) AE.AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments)
"""Various tools used by MIME-reading or MIME-writing programs.""" import os import sys import tempfile from warnings import filterwarnings, catch_warnings with catch_warnings(): if sys.py3kwarning: filterwarnings("ignore", ".*rfc822 has been removed", DeprecationWarning) import rfc822 from warnings import warnpy3k warnpy3k("in 3.x, mimetools has been removed in favor of the email package", stacklevel=2) __all__ = ["Message","choose_boundary","encode","decode","copyliteral", "copybinary"] class Message(rfc822.Message): """A derived class of rfc822.Message that knows about MIME headers and contains some hooks for decoding encoded and multipart messages.""" def __init__(self, fp, seekable = 1): rfc822.Message.__init__(self, fp, seekable) self.encodingheader = \ self.getheader('content-transfer-encoding') self.typeheader = \ self.getheader('content-type') self.parsetype() self.parseplist()
There are a number of possible implementations of bastions. We use a 'lazy' approach where the bastion's __getattr__() discipline does all the work for a particular method the first time it is used. This is usually fastest, especially if the user doesn't call all available methods. The retrieved methods are stored as instance variables of the bastion, so the overhead is only occurred on the first use of each method. Detail: the bastion class has a __repr__() discipline which includes the repr() of the original object. This is precomputed when the bastion is created. """ from warnings import warnpy3k warnpy3k('the Bastion module has been removed in Python 3.0', stacklevel=2) del warnpy3k __all__ = ['BastionClass', 'Bastion'] from types import MethodType class BastionClass: """Helper class used by the Bastion() function. You could subclass this and pass the subclass as the bastionclass argument to the Bastion() function, as long as the constructor has the same signature (a get() function and a name for the object). """ def __init__(self, get, name): """Constructor.
"""General floating point formatting functions. Functions: fix(x, digits_behind) sci(x, digits_behind) Each takes a number or a string and a number of digits as arguments. Parameters: x: number to be formatted; or a string resembling a number digits_behind: number of digits behind the decimal point """ from warnings import warnpy3k warnpy3k("the fpformat module has been removed in Python 3.0", stacklevel=2) del warnpy3k import re __all__ = ["fix","sci","NotANumber"] # Compiled regular expression to "decode" a number decoder = re.compile(r'^([-+]?)0*(\d*)((?:\.\d*)?)(([eE][-+]?\d+)?)$') # \0 the whole thing # \1 leading sign or empty # \2 digits left of decimal point # \3 fraction (empty or begins with point) # \4 exponent part (empty or begins with 'e' or 'E') try: class NotANumber(ValueError): pass
"""Support for Berkeley DB 4.3 through 5.3 with a simple interface. For the full featured object oriented interface use the bsddb.db module instead. It mirrors the Oracle Berkeley DB C API. """ import sys absolute_import = (sys.version_info[0] >= 3) if (sys.version_info >= (2, 6)) and (sys.version_info < (3, 0)) : import warnings if sys.py3kwarning and (__name__ != 'bsddb3') : warnings.warnpy3k("in 3.x, the bsddb module has been removed; " "please use the pybsddb project instead", DeprecationWarning, 2) warnings.filterwarnings("ignore", ".*CObject.*", DeprecationWarning, "bsddb.__init__") try: if __name__ == 'bsddb3': # import _pybsddb binary as it should be the more recent version from # a standalone pybsddb addon package than the version included with # python as bsddb._bsddb. if absolute_import : # Because this syntaxis is not valid before Python 2.5 exec("from . import _pybsddb") else : import _pybsddb _bsddb = _pybsddb
# Python bytecode 2.7 (decompiled from Python 2.7) # Embedded file name: scripts/common/Lib/plat-irix6/GLWS.py from warnings import warnpy3k warnpy3k('the GLWS module has been removed in Python 3.0', stacklevel=2) del warnpy3k NOERROR = 0 NOCONTEXT = -1 NODISPLAY = -2 NOWINDOW = -3 NOGRAPHICS = -4 NOTTOP = -5 NOVISUAL = -6 BUFSIZE = -7 BADWINDOW = -8 ALREADYBOUND = -100 BINDFAILED = -101 SETFAILED = -102
def __init__(self, string=""): from warnings import warnpy3k warnpy3k('the class UserString.MutableString has been removed in ' 'Python 3.0', stacklevel=2) self.data = string
#Embedded file name: e:\jenkins\workspace\client_SERENITY\branches\release\SERENITY\carbon\common\stdlib\htmllib.py from warnings import warnpy3k warnpy3k('the htmllib module has been removed in Python 3.0', stacklevel=2) del warnpy3k import sgmllib from formatter import AS_IS __all__ = ['HTMLParser', 'HTMLParseError'] class HTMLParseError(sgmllib.SGMLParseError): pass class HTMLParser(sgmllib.SGMLParser): from htmlentitydefs import entitydefs def __init__(self, formatter, verbose = 0): sgmllib.SGMLParser.__init__(self, verbose) self.formatter = formatter def error(self, message): raise HTMLParseError(message) def reset(self): sgmllib.SGMLParser.reset(self) self.savedata = None self.isindex = 0 self.title = None self.base = None self.anchor = None self.anchorlist = [] self.nofill = 0
# uncompyle6 version 2.9.10 # Python bytecode 2.7 (62211) # Decompiled from: Python 3.6.0b2 (default, Oct 11 2016, 05:27:10) # [GCC 6.2.0 20161005] # Embedded file name: sunaudio.py """Interpret sun audio headers.""" from warnings import warnpy3k warnpy3k( 'the sunaudio module has been removed in Python 3.0; use the sunau module instead', stacklevel=2) del warnpy3k MAGIC = '.snd' class error(Exception): pass def get_long_be(s): """Convert a 4-char value to integer.""" return ord(s[0]) << 24 | ord(s[1]) << 16 | ord(s[2]) << 8 | ord(s[3]) def gethdr(fp): """Read a sound header from an open file.""" if fp.read(4) != MAGIC: raise error, 'gethdr: bad magic word' hdr_size = get_long_be(fp.read(4)) data_size = get_long_be(fp.read(4)) encoding = get_long_be(fp.read(4)) sample_rate = get_long_be(fp.read(4))
# Python bytecode 2.7 (decompiled from Python 2.7) # Embedded file name: scripts/common/Lib/dbhash.py import sys import warnings warnings.warnpy3k('in 3.x, the dbhash module has been removed', stacklevel=2) try: import bsddb except ImportError: del sys.modules[__name__] raise __all__ = ['error', 'open'] error = bsddb.error def open(file, flag='r', mode=438): return bsddb.hashopen(file, flag, mode)
# 2016.02.14 12:50:02 Støední Evropa (bìžný èas) # Embedded file name: scripts/common/Lib/plat-mac/macresource.py """macresource - Locate and open the resources needed for a script.""" from warnings import warnpy3k warnpy3k('In 3.x, the macresource module is removed.', stacklevel=2) from Carbon import Res import os import sys import MacOS import macostools class ArgumentError(TypeError): pass class ResourceFileNotFoundError(ImportError): pass def need(restype, resid, filename = None, modname = None): """Open a resource file, if needed. restype and resid are required parameters, and identify the resource for which to test. If it is available we are done. If it is not available we look for a file filename (default: modname with .rsrc appended) either in the same folder as where modname was loaded from, or otherwise across sys.path. Returns the refno of the resource file opened (or None)""" if modname is None and filename is None: raise ArgumentError, 'Either filename or modname argument (or both) must be given' if type(resid) is type(1): try:
# 2015.11.18 12:05:46 Støední Evropa (bìžný èas) # Embedded file name: scripts/common/Lib/plat-mac/Audio_mac.py QSIZE = 100000 error = 'Audio_mac.error' from warnings import warnpy3k warnpy3k('In 3.x, the Play_Audio_mac module is removed.', stacklevel=2) class Play_Audio_mac: def __init__(self, qsize = QSIZE): self._chan = None self._qsize = qsize self._outrate = 22254 self._sampwidth = 1 self._nchannels = 1 self._gc = [] self._usercallback = None return def __del__(self): self.stop() self._usercallback = None return def wait(self): import time while self.getfilled(): time.sleep(0.1) self._chan = None self._gc = []
def __init__(self, string=''): from warnings import warnpy3k warnpy3k( 'the class UserString.MutableString has been removed in Python 3.0', stacklevel=2) self.data = string
# 2016.05.01 15:27:12 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/audiodev.py """Classes for manipulating audio devices (currently only for Sun and SGI)""" from warnings import warnpy3k warnpy3k('the audiodev module has been removed in Python 3.0', stacklevel=2) del warnpy3k __all__ = ['error', 'AudioDev'] class error(Exception): pass class Play_Audio_sgi: classinited = 0 frameratelist = nchannelslist = sampwidthlist = None def initclass(self): import AL self.frameratelist = [(48000, AL.RATE_48000), (44100, AL.RATE_44100), (32000, AL.RATE_32000), (22050, AL.RATE_22050), (16000, AL.RATE_16000), (11025, AL.RATE_11025), (8000, AL.RATE_8000)] self.nchannelslist = [(1, AL.MONO), (2, AL.STEREO), (4, AL.QUADRO)] self.sampwidthlist = [(1, AL.SAMPLE_8), (2, AL.SAMPLE_16), (3, AL.SAMPLE_24)] self.classinited = 1 def __init__(self): import al, AL
time = m.getdate(name) which parses a Date-like field and returns a time-compatible tuple, i.e. a tuple such as returned by time.localtime() or accepted by time.mktime(). See the class definition for lower level access methods. There are also some utility functions here. """ # Cleanup and extensions by Eric S. Raymond <*****@*****.**> import time from warnings import warnpy3k warnpy3k("in 3.x, rfc822 has been removed in favor of the email package", stacklevel=2) __all__ = ["Message", "AddressList", "parsedate", "parsedate_tz", "mktime_tz"] _blanklines = ('\r\n', '\n') # Optimization for islast() class Message: """Represents a single RFC 2822-compliant message.""" def __init__(self, fp, seekable=1): """Initialize the class instance and read the headers.""" if seekable == 1: # Exercise tell() to make sure it works # (and then assume seek() works, too) try: fp.tell()
""" Import utilities Exported classes: ImportManager Manage the import process Importer Base class for replacing standard import functions BuiltinImporter Emulate the import mechanism for builtin and frozen modules DynLoadSuffixImporter """ from warnings import warnpy3k warnpy3k("the imputil module has been removed in Python 3.0", stacklevel=2) del warnpy3k # note: avoid importing non-builtin modules import imp ### not available in Jython? import sys import __builtin__ # for the DirectoryImporter import struct import marshal __all__ = ["ImportManager","Importer","BuiltinImporter"] _StringType = type('') _ModuleType = type(sys) ### doesn't work in Jython... class ImportManager: "Manage the import process."
"""Common string manipulations. Public module variables: whitespace -- a string containing all characters considered whitespace lowercase -- a string containing all characters considered lowercase letters uppercase -- a string containing all characters considered uppercase letters letters -- a string containing all characters considered letters digits -- a string containing all characters considered decimal digits hexdigits -- a string containing all characters considered hexadecimal digits octdigits -- a string containing all characters considered octal digits """ from warnings import warnpy3k warnpy3k('the stringold module has been removed in Python 3.0', stacklevel=2) del warnpy3k whitespace = ' \t\n\r\x0b\x0c' lowercase = 'abcdefghijklmnopqrstuvwxyz' uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' letters = lowercase + uppercase digits = '0123456789' hexdigits = digits + 'abcdef' + 'ABCDEF' octdigits = '01234567' _idmap = '' for i in range(256): _idmap = _idmap + chr(i) del i index_error = ValueError atoi_error = ValueError
# 2015.11.10 21:33:24 Støední Evropa (bìžný èas) # Embedded file name: scripts/common/Lib/new.py """Create new objects of various types. Deprecated. This module is no longer required except for backward compatibility. Objects of most types can now be created by calling the type object. """ from warnings import warnpy3k warnpy3k("The 'new' module has been removed in Python 3.0; use the 'types' module instead.", stacklevel=2) del warnpy3k from types import ClassType as classobj from types import FunctionType as function from types import InstanceType as instance from types import MethodType as instancemethod from types import ModuleType as module from types import CodeType as code # okay decompyling c:\Users\PC\wotsources\files\originals\res_bw\scripts\common\lib\new.pyc # decompiled 1 files: 1 okay, 0 failed, 0 verify failed # 2015.11.10 21:33:24 Støední Evropa (bìžný èas)
# Module 'parser' # # Parse S-expressions output by the Panel Editor # (which is written in Scheme so it can't help writing S-expressions). # # See notes at end of file. from warnings import warnpy3k warnpy3k("the panelparser module has been removed in Python 3.0", stacklevel=2) del warnpy3k whitespace = ' \t\n' operators = '()\'' separators = operators + whitespace + ';' + '"' # Tokenize a string. # Return a list of tokens (strings). # def tokenize_string(s): tokens = [] while s: c = s[:1] if c in whitespace: s = s[1:] elif c == ';': s = '' elif c == '"': n = len(s) i = 1 while i < n: c = s[i]
# Embedded file name: scripts/common/Lib/plat-mac/gensuitemodule.py """ gensuitemodule - Generate an AE suite module from an aete/aeut resource Based on aete.py. Reading and understanding this code is left as an exercise to the reader. """ from warnings import warnpy3k warnpy3k('In 3.x, the gensuitemodule module is removed.', stacklevel=2) import MacOS import EasyDialogs import os import string import sys import types import StringIO import keyword import macresource import aetools import distutils.sysconfig import OSATerminology from Carbon.Res import * import Carbon.Folder import MacOS import getopt import plistlib _MAC_LIB_FOLDER = os.path.dirname(aetools.__file__) DEFAULT_STANDARD_PACKAGEFOLDER = os.path.join(_MAC_LIB_FOLDER, 'lib-scriptpackages') DEFAULT_USER_PACKAGEFOLDER = distutils.sysconfig.get_python_lib()
# 2017.08.29 21:58:36 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/plat-mac/MiniAEFrame.py """MiniAEFrame - A minimal AppleEvent Application framework. There are two classes: AEServer -- a mixin class offering nice AE handling. MiniApplication -- a very minimal alternative to FrameWork.py, only suitable for the simplest of AppleEvent servers. """ from warnings import warnpy3k warnpy3k('In 3.x, the MiniAEFrame module is removed.', stacklevel=2) import traceback import MacOS from Carbon import AE from Carbon.AppleEvents import * from Carbon import Evt from Carbon.Events import * from Carbon import Menu from Carbon import Win from Carbon.Windows import * from Carbon import Qd import aetools import EasyDialogs kHighLevelEvent = 23 class MiniApplication: """A minimal FrameWork.Application-like class""" def __init__(self): self.quitting = 0 self.appleid = 1
# Embedded file name: scripts/common/Lib/plat-mac/Carbon/__init__.py import warnings warnings.filterwarnings('ignore', '', FutureWarning, '.*Controls') warnings.filterwarnings('ignore', '', FutureWarning, '.*MacTextEditor') from warnings import warnpy3k warnpy3k('In 3.x, the Carbon package is removed.', stacklevel=2)
# Convert "arbitrary" image files to rgb files (SGI's image format). # Input may be compressed. # The uncompressed file type may be PBM, PGM, PPM, GIF, TIFF, or Sun raster. # An exception is raised if the file is not of a recognized type. # Returned filename is either the input filename or a temporary filename; # in the latter case the caller must ensure that it is removed. # Other temporary files used are removed by the function. from warnings import warnpy3k warnpy3k("the torgb module has been removed in Python 3.0", stacklevel=2) del warnpy3k import os import tempfile import pipes import imghdr table = {} t = pipes.Template() t.append('fromppm $IN $OUT', 'ff') table['ppm'] = t t = pipes.Template() t.append('(PATH=$PATH:/ufs/guido/bin/sgi; exec pnmtoppm)', '--') t.append('fromppm $IN $OUT', 'ff') table['pnm'] = t table['pgm'] = t table['pbm'] = t t = pipes.Template() t.append('fromgif $IN $OUT', 'ff')
#Embedded file name: e:\jenkins\workspace\client_SERENITY\branches\release\SERENITY\carbon\common\stdlib\rfc822.py import time from warnings import warnpy3k warnpy3k('in 3.x, rfc822 has been removed in favor of the email package', stacklevel=2) __all__ = ['Message', 'AddressList', 'parsedate', 'parsedate_tz', 'mktime_tz'] _blanklines = ('\r\n', '\n') class Message(): def __init__(self, fp, seekable = 1): if seekable == 1: try: fp.tell() except (AttributeError, IOError): seekable = 0 self.fp = fp self.seekable = seekable self.startofheaders = None self.startofbody = None if self.seekable: try: self.startofheaders = self.fp.tell() except IOError: self.seekable = 0 self.readheaders()
"""macostools - Various utility functions for MacOS. mkalias(src, dst) - Create a finder alias 'dst' pointing to 'src' copy(src, dst) - Full copy of 'src' to 'dst' """ from warnings import warnpy3k warnpy3k("In 3.x, the macostools module is removed.", stacklevel=2) from Carbon import Res from Carbon import File, Files import os import errno import MacOS try: openrf = MacOS.openrf except AttributeError: # Backward compatibility openrf = open Error = 'macostools.Error' BUFSIZ = 0x80000 # Copy in 0.5Mb chunks COPY_FLAGS = (Files.kIsStationary | Files.kNameLocked | Files.kHasBundle | Files.kIsInvisible | Files.kIsAlias) # # Not guaranteed to be correct or stay correct (Apple doesn't tell you # how to do this), but it seems to work.
# 2016.05.01 15:31:29 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/plat-irix6/panel.py from warnings import warnpy3k warnpy3k('the panel module has been removed in Python 3.0', stacklevel=2) del warnpy3k import pnl debug = 0 def is_list(x): return type(x) == type([]) def reverse(list): res = [] for item in list: res.insert(0, item) return res def getattrlist(list, name): for item in list: if item and is_list(item) and item[0] == name: return item[1:] return [] def getproplist(list, name): for item in list: if item and is_list(item) and item[0] == 'prop':
# 2016.11.19 20:00:57 Støední Evropa (bìžný èas) # Embedded file name: scripts/common/Lib/plat-mac/Carbon/__init__.py import warnings warnings.filterwarnings('ignore', '', FutureWarning, '.*Controls') warnings.filterwarnings('ignore', '', FutureWarning, '.*MacTextEditor') from warnings import warnpy3k warnpy3k('In 3.x, the Carbon package is removed.', stacklevel=2) # okay decompyling c:\Users\PC\wotsources\files\originals\res\scripts\common\Lib\plat-mac\Carbon\__init__.pyc # decompiled 1 files: 1 okay, 0 failed, 0 verify failed # 2016.11.19 20:00:57 Støední Evropa (bìžný èas)
"""PixMapWrapper - defines the PixMapWrapper class, which wraps an opaque QuickDraw PixMap data structure in a handy Python class. Also provides methods to convert to/from pixel data (from, e.g., the img module) or a Python Imaging Library Image object. J. Strout <*****@*****.**> February 1999""" from warnings import warnpy3k warnpy3k("In 3.x, the PixMapWrapper module is removed.", stacklevel=2) from Carbon import Qd from Carbon import QuickDraw import struct import MacOS import img import imgformat # PixMap data structure element format (as used with struct) _pmElemFormat = { 'baseAddr':'l', # address of pixel data 'rowBytes':'H', # bytes per row, plus 0x8000 'bounds':'hhhh', # coordinates imposed over pixel data 'top':'h', 'left':'h', 'bottom':'h', 'right':'h', 'pmVersion':'h', # flags for Color QuickDraw 'packType':'h', # format of compression algorithm 'packSize':'l', # size after compression 'hRes':'l', # horizontal pixels per inch
# 2016.08.04 19:57:29 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/sgmllib.py """A parser for SGML, using the derived class as a static DTD.""" from warnings import warnpy3k warnpy3k('the sgmllib module has been removed in Python 3.0', stacklevel=2) del warnpy3k import markupbase import re __all__ = ['SGMLParser', 'SGMLParseError'] interesting = re.compile('[&<]') incomplete = re.compile( '&([a-zA-Z][a-zA-Z0-9]*|#[0-9]*)?|<([a-zA-Z][^<>]*|/([a-zA-Z][^<>]*)?|![^<>]*)?' ) entityref = re.compile('&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]') charref = re.compile('&#([0-9]+)[^0-9]') starttagopen = re.compile('<[>a-zA-Z]') shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/') shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/') piclose = re.compile('>') endbracket = re.compile('[<>]') tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*') attrfind = re.compile( '\\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\\s*=\\s*(\\\'[^\\\']*\\\'|"[^"]*"|[][\\-a-zA-Z0-9./,:;+*%?!&$\\(\\)_#=~\\\'"@]*))?' ) class SGMLParseError(RuntimeError): """Exception raised for all parse errors.""" pass
# 2016.05.01 15:31:25 Støední Evropa (letní èas) # Embedded file name: scripts/common/Lib/plat-irix5/readcd.py from warnings import warnpy3k warnpy3k('the readcd module has been removed in Python 3.0', stacklevel=2) del warnpy3k import cd, CD class Error(Exception): pass class _Stop(Exception): pass def _doatime(self, cb_type, data): if (data[0] * 60 + data[1]) * 75 + data[2] > self.end: raise _Stop func, arg = self.callbacks[cb_type] if func: func(arg, cb_type, data) def _dopnum(self, cb_type, data): if data > self.end: raise _Stop func, arg = self.callbacks[cb_type] if func: func(arg, cb_type, data)
# Class interface to the CD module. from warnings import warnpy3k warnpy3k("the readcd module has been removed in Python 3.0", stacklevel=2) del warnpy3k import cd, CD class Error(Exception): pass class _Stop(Exception): pass def _doatime(self, cb_type, data): if ((data[0] * 60) + data[1]) * 75 + data[2] > self.end: ## print 'done with list entry', repr(self.listindex) raise _Stop func, arg = self.callbacks[cb_type] if func: func(arg, cb_type, data) def _dopnum(self, cb_type, data): if data > self.end: ## print 'done with list entry', repr(self.listindex) raise _Stop func, arg = self.callbacks[cb_type]