rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.__backend_pid, self.__backend_key = unpack('!ii', self.__read_bytes(8)) | self.__backend_pid, self.__backend_key = _unpack('!ii', self.__read_bytes(8)) | def _pkt_K(self): # # Backend Key data # self.__backend_pid, self.__backend_key = unpack('!ii', self.__read_bytes(8)) #print 'Backend Key Data, pid: %d, key: %d' % (self.__backend_pid, self.__backend_key) |
code = unpack('!i', self.__read_bytes(4))[0] | code = _unpack('!i', self.__read_bytes(4))[0] | def _pkt_R(self): # # Startup Response # code = unpack('!i', self.__read_bytes(4))[0] if code == 0: self.__authenticated = 1 #print 'Authenticated!' elif code == 1: raise InterfaceError('Kerberos V4 authentication is required by server, but not supported by this client') elif code == 2: raise InterfaceError('Kerberos V... |
self.__send(pack('!i', len(self.__passwd)+5) + self.__passwd + '\0') | self.__send(_pack('!i', len(self.__passwd)+5) + self.__passwd + '\0') | def _pkt_R(self): # # Startup Response # code = unpack('!i', self.__read_bytes(4))[0] if code == 0: self.__authenticated = 1 #print 'Authenticated!' elif code == 1: raise InterfaceError('Kerberos V4 authentication is required by server, but not supported by this client') elif code == 2: raise InterfaceError('Kerberos V... |
self.__send(pack('!i', len(cpwd)+5) + cpwd + '\0') | self.__send(_pack('!i', len(cpwd)+5) + cpwd + '\0') | def _pkt_R(self): # # Startup Response # code = unpack('!i', self.__read_bytes(4))[0] if code == 0: self.__authenticated = 1 #print 'Authenticated!' elif code == 1: raise InterfaceError('Kerberos V4 authentication is required by server, but not supported by this client') elif code == 2: raise InterfaceError('Kerberos V... |
self.__send(pack('!i', len(m)+4) + m) | self.__send(_pack('!i', len(m)+4) + m) | def _pkt_R(self): # # Startup Response # code = unpack('!i', self.__read_bytes(4))[0] if code == 0: self.__authenticated = 1 #print 'Authenticated!' elif code == 1: raise InterfaceError('Kerberos V4 authentication is required by server, but not supported by this client') elif code == 2: raise InterfaceError('Kerberos V... |
nFields = unpack('!h', self.__read_bytes(2))[0] | nFields = _unpack('!h', self.__read_bytes(2))[0] | def _pkt_T(self): # # Row Description # nFields = unpack('!h', self.__read_bytes(2))[0] descr = [] for i in range(nFields): fieldname = self.__read_string() oid, type_size, type_modifier = unpack('!ihi', self.__read_bytes(10)) descr.append((fieldname, oid, type_size, type_modifier)) |
oid, type_size, type_modifier = unpack('!ihi', self.__read_bytes(10)) | oid, type_size, type_modifier = _unpack('!ihi', self.__read_bytes(10)) | def _pkt_T(self): # # Row Description # nFields = unpack('!h', self.__read_bytes(2))[0] descr = [] for i in range(nFields): fieldname = self.__read_string() oid, type_size, type_modifier = unpack('!ihi', self.__read_bytes(10)) descr.append((fieldname, oid, type_size, type_modifier)) |
result_size = unpack('!i', self.__read_bytes(4))[0] | result_size = _unpack('!i', self.__read_bytes(4))[0] | def _pkt_V(self): # # Function call response # self.__func_result = None while 1: ch = self.__read_bytes(1) if ch == '0': break if ch == 'G': result_size = unpack('!i', self.__read_bytes(4))[0] self.__func_result = self.__read_bytes(result_size) else: raise InterfaceError('Unexpected byte: [%s] in Function call reponse... |
self.__send(pack('!ihh64s32s64s64s64s', 296, 2, 0, args['dbname'], args['user'], args['options'], '', '')) | self.__send(_pack('!ihh64s32s64s64s64s', 296, 2, 0, args['dbname'], args['user'], args['options'], '', '')) | def _connect(self, dsn=None, username='', password='', host=None, dbname='', port='', opt=''): # # Come up with a reasonable default host for # win32 and presumably Unix platforms # if host == None: if sys.platform == 'win32': host = '127.0.0.1' else: host = '/tmp/.s.PGSQL.5432' |
self.__send(pack('!2sIi', 'F\0', oid, len(args))) | self.__send(_pack('!2sIi', 'F\0', oid, len(args))) | def funcall(self, oid, *args): """ Low-level call to PostgreSQL function, you must supply the oid of the function, and have the args supplied as ints or strings. |
self.__send(pack('!iI', 4, arg)) | self.__send(_pack('!iI', 4, arg)) | def funcall(self, oid, *args): """ Low-level call to PostgreSQL function, you must supply the oid of the function, and have the args supplied as ints or strings. |
self.__send(pack('!ii', 4, arg)) | self.__send(_pack('!ii', 4, arg)) | def funcall(self, oid, *args): """ Low-level call to PostgreSQL function, you must supply the oid of the function, and have the args supplied as ints or strings. |
self.__send(pack('!i', len(arg))) | self.__send(_pack('!i', len(arg))) | def funcall(self, oid, *args): """ Low-level call to PostgreSQL function, you must supply the oid of the function, and have the args supplied as ints or strings. |
return unpack('!i', r)[0] | return _unpack('!i', r)[0] | def lo_create(self, mode=INV_READ|INV_WRITE): """ Return the oid of a new Large Object, created with the specified mode |
fd = unpack('!i', r)[0] | fd = _unpack('!i', r)[0] | def lo_open(self, oid, mode=INV_READ|INV_WRITE): """ Open the Large Object with the specified oid, returns a file-like object |
self.send('\\.\n') | self.__send('\\.\n') | def _pkt_G(self): # # CopyIn Response from self.stdin if available, or # sys.stdin Supplies the final terminating line: # '\.' (one backslash followd by a period) if it # doesn't appear in the input # if hasattr(self, 'stdin') and self.stdin: stdin = self.stdin else: stdin = sys.stdin |
def __fix_arg(a): | def _fix_arg(a): | def __fix_arg(a): # # Make an argument SQL-ready: replace None with 'NULL', and escape strings # if a is None: return 'NULL' if type(a) == types.StringType: return '%s' % a.replace('\\', '\\\\').replace("'", "\\'") return a |
if null_byte_count: for ch in self.__read_bytes(null_byte_count): | if result.null_byte_count: for ch in self.__read_bytes(result.null_byte_count): | def __read_row(self, ascii=1): # # Read an ASCII or Binary Row # result = self.__current_result |
field_mask <<= (null_byte_count - 1) * 8 | field_mask <<= (result.null_byte_count - 1) * 8 | def __read_row(self, ascii=1): # # Read an ASCII or Binary Row # result = self.__current_result |
def _execute(self, str, *args): if args: argtype = type(args[0]) if argtype in [types.TupleType, types.DictType]: args = args[0] else: | def _execute(self, cmd, args=None): if args is not None: argtype = type(args) if argtype not in [types.TupleType, types.DictType]: args = (args,) | def _execute(self, str, *args): if args: argtype = type(args[0]) if argtype in [types.TupleType, types.DictType]: args = args[0] # ignore any other args else: argtype = types.TupleType |
str = str % tuple([__fix_arg(a) for a in args]) | cmd = cmd % tuple([_fix_arg(a) for a in args]) | def _execute(self, str, *args): if args: argtype = type(args[0]) if argtype in [types.TupleType, types.DictType]: args = args[0] # ignore any other args else: argtype = types.TupleType |
str = str % dict([(k, __fix_arg(v)) for k,v in args.items()]) | cmd = cmd % dict([(k, _fix_arg(v)) for k,v in args.items()]) | def _execute(self, str, *args): if args: argtype = type(args[0]) if argtype in [types.TupleType, types.DictType]: args = args[0] # ignore any other args else: argtype = types.TupleType |
self.__send('Q'+str+'\0') | self.__send('Q'+cmd+'\0') | def _execute(self, str, *args): if args: argtype = type(args[0]) if argtype in [types.TupleType, types.DictType]: args = args[0] # ignore any other args else: argtype = types.TupleType |
def execute(self, str, *params): self.description, self.__rows, self.messages = self.connection._execute(str, params) | def execute(self, cmd, args=None): self.description, self.__rows, self.messages = self.connection._execute(cmd, args) | def execute(self, str, *params): self.description, self.__rows, self.messages = self.connection._execute(str, params) |
parser.add_option( "", "--version", dest="version", help="release version" ) | parser.add_option( "-v", "--release-version", dest="release_version", metavar="release-version", help="release version (e.g. 1.32.0)") | def accept_args( args ): #( release_version, cvs_tag, sf_user, temp_dir, start_step ) = accept_args( sys.argv[ 1: ] ) parser = optparse.OptionParser() parser.add_option( "", "--version", dest="version", help="release version" ) parser.add_option( "", "--tag", dest="tag", help="CVS tag" ) parser.add_option( "", "--user... |
parser.add_option( "", "--user", dest="user", help="SourceForge user name" ) parser.add_option( "", "--toolset", dest="toolset", help="toolset to use to build needed tools" ) parser.usage = "make_tarballs [options] temp_dir [start_step]\n\n" + \ | parser.add_option( "-r", "--cvs-branch", dest="cvs_branch", metavar="cvs-branch" , help = "cvs branch to get the sources from (e.g RC_1_32_0). Important: it is case sensitive" ) parser.add_option( "-u", "--sf-user", dest="sf_user", metavar="sf-user" , help = "SourceForge user name (for CVS)" ) parser.add_option( "-t", ... | def accept_args( args ): #( release_version, cvs_tag, sf_user, temp_dir, start_step ) = accept_args( sys.argv[ 1: ] ) parser = optparse.OptionParser() parser.add_option( "", "--version", dest="version", help="release version" ) parser.add_option( "", "--tag", dest="tag", help="CVS tag" ) parser.add_option( "", "--user... |
"\tcvs - to export sources with windows newlines \n" + \ "\tbash cvs - (cygwin) to export sources with posix newlines\n" + \ "\tbjam - to build BoostBook\n" + \ "\t7z - to create zipball\n" + \ "\tuser-config.jam in user directory ($HOME/%HOME%) - to build BoostBook\n" + \ "\tmv - posix move" | " CVS:\n"+ \ " cvs - (windows) to export sources with windows newlines \n" + \ " /usr/bin/cvs - (cygwin) to export sources with posix newlines\n" + \ " Utilities:\n" + \ " mv - (cygwin) posix move\n" + \ " /usr/bin/find - (cygwin) to export sources with posix newlines\n" + \ ... | def accept_args( args ): #( release_version, cvs_tag, sf_user, temp_dir, start_step ) = accept_args( sys.argv[ 1: ] ) parser = optparse.OptionParser() parser.add_option( "", "--version", dest="version", help="release version" ) parser.add_option( "", "--tag", dest="tag", help="CVS tag" ) parser.add_option( "", "--user... |
if ( len( args ) > 1 ): start_step = args[1] | ( version, tag, user, toolset, start_step ) = ( options.release_version , options.cvs_branch , options.sf_user , options.toolset , options.start_step ) | def accept_args( args ): #( release_version, cvs_tag, sf_user, temp_dir, start_step ) = accept_args( sys.argv[ 1: ] ) parser = optparse.OptionParser() parser.add_option( "", "--version", dest="version", help="release version" ) parser.add_option( "", "--tag", dest="tag", help="CVS tag" ) parser.add_option( "", "--user... |
( version, tag, user, toolset ) = ( options.version , options.tag , options.user , options.toolset ) if ( version is None or tag is None or user is None or temp_dir is None or toolset is None ): parser.print_help() sys.exit( 1 ) | def required( value, name ): if ( value is None ): print "%s should be specified." % name parser.print_help() sys.exit( 1 ) required( version, "version" ) required( tag, "tag" ) required( user, "user" ) required( temp_dir, "temp_dir" ) required( toolset, "toolset" ) | def accept_args( args ): #( release_version, cvs_tag, sf_user, temp_dir, start_step ) = accept_args( sys.argv[ 1: ] ) parser = optparse.OptionParser() parser.add_option( "", "--version", dest="version", help="release version" ) parser.add_option( "", "--tag", dest="tag", help="CVS tag" ) parser.add_option( "", "--user... |
exported_dir = self.cvs_export( sf_user, cvs_tag, release_version, "bash -c \"PATH=/bin:$PATH;%s\"" ) | exported_dir = self.cvs_export( sf_user, cvs_tag, release_version, "bash -c \"/usr/bin/%s\"" ) | def build_unix( self, release_version, cvs_tag, sf_user, temp_dir, win_build_dir ): |
utils.checked_system( [ "bash -c PATH=/bin:$PATH;find %s -type d -exec chmod u+w {} ;" % temp_unix ] ) | utils.checked_system( [ "bash -c /usr/bin/find %s -type d -exec chmod u+w {} ;" % temp_unix ] ) | def build_unix( self, release_version, cvs_tag, sf_user, temp_dir, win_build_dir ): |
progressbar.myReportHook(counter, block_size, size) | pypt_progressbar.myReportHook(counter, block_size, size) | def download_from_web(sUrl, sFile, sSourceDir, checksum): ''' Download the required file from the web The arguments are passed everytime to the function so that, may be in future, we could reuse this function ''' try: block_size = 4096 i = 0 counter = 0 os.chdir(sSourceDir) temp = urllib2.urlopen(sUrl) headers = temp... |
from Queue import Queue from threading import Thread, currentThread | def fetcher(uri, path, cache, zip_bool, zip_type_file, arg_type = 0): ''' uri - The uri data whill will contain the information path - The path (if any) where the download needs to be done cache - The cache (if any) where we should check before downloading from the net arg_type - arg_type is basically used to identify ... | |
with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() | with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = threading.currentThread().getName() ziplock = threading.Lock() | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
compress_the_file(zip_type_file, File, sSourceDir) os.remove(File) | ziplock.acquire() try: compress_the_file(zip_type_file, File, sSourceDir) os.remove(File) finally: ziplock.release() | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
pypt_variables.errlist.append(sFile) | pypt_variables.errlist.append(File) | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
requestQueue = Queue() responseQueue = Queue() | requestQueue = Queue.Queue() responseQueue = Queue.Queue() | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
Thread( | threading.Thread( | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
for each_single_item in lRawData: (sUrl, sFile, download_size, checksum) = stripper(each_single_item) if cache is None: if download_from_web(sUrl, sFile, sSourceDir, checksum) != True: pypt_variables.errlist.append(sFile) if zip_bool: compress_the_file(zip_type_file, sFile, sSourceDir) os.unlink(sFile) else: if copy... | if pypt_variables.options.num_of_threads > 1: log.msg("WARNING: Threads is still in alpha stage. It's better to use just a single thread at the moment.\n") log.warn("Threads is still in alpha stage. It's better to use just a single thread at the moment.\n") NUMTHREADS = pypt_variables.options.num_of_threads def run(r... | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
if os.path.exists(os.path.join(cache, sFile)): | if cache is None or os.path.exists(os.path.join(cache, sFile)): | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
if zip_bool: | if zip_bool: ziplock.acquire() try: compress_the_file(zip_type_file, sFile, sSourceDir) os.remove(sFile) finally: ziplock.release() elif exit_status == True: if zip_bool: ziplock.acquire() try: | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
os.unlink(sFile) elif True: if zip_bool: compress_the_file(zip_type_file, sFile, sSourceDir) os.unlink(sFile) | os.remove(sFile) finally: ziplock.release() requestQueue = Queue.Queue() responseQueue = Queue.Queue() thread_pool = [ threading.Thread( target=run, args=(requestQueue, responseQueue) ) for i in range(NUMTHREADS) ] for t in thread_pool: t.start() for item in lRawData: requestQueue.put(item) for t in thread_... | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' name = currentThread().getName() while 1: item = request.get() if item is None: break (sUrl, sF... |
pass | sys.stderr.write("Aieeee! I got a fatal exception that I don't understand.\nPlease debug.\n") | def compress_the_file(zip_file_name, files_to_compress, sSourceDir): '''Condenses all the files into one single file for easy transfer''' try: import zipfile except ImportError: sys.stderr.write("Aieeee! module not found.\n") try: os.chdir(sSourceDir) except: #TODO: Handle this exception pass try: filename = zipfile... |
try: os.chdir(path) except: sys.stderr.write("Couldn't chdir() to %s.\n" % (path_)) try: wr_fh = open (filename, 'wb') | try: wr_fh = open (os.path.join(path, filename), 'wb') | def decompress_the_file(file, path, filename, archive_type): '''Extracts all the files from a single condensed archive file''' if archive_type is 1: try: import bz2 except ImportError: sys.stderr.write("Aieeee! Module bz2 is not available.\n") try: fh = bz2.BZ2File(file, 'r') except: sys.stderr.write("Couldn't open f... |
syncer(pypt_variables.options.install_upgrade, apt_package_target_path, 1) | syncer(pypt_variables.options.install_upgrade, pypt_variables.apt_package_target_path, 1) | def main(): # Okay!! We got all the options and arguments. # Now let's begin.... try: # The log implementation # Instantiate the class log = pypt_logger.log(pypt_variables.options.warnings, pypt_variables.options.verbose, pypt_variables.options.debug) global log log.msg("pypt-offline %s\n" % (pypt_variables.version))... |
pass | def fetcher(uri, path, cache, zip_bool, zip_type_file, arg_type = 0): ''' uri - The uri data whill will contain the information path - The path (if any) where the download needs to be done cache - The cache (if any) where we should check before downloading from the net arg_type - arg_type is basically used to identify ... | |
os.unlink(sFile) | os.unlink(os.path.join(sSourceDir, sFile)) | def fetcher(uri, path, cache, zip_bool, zip_type_file, arg_type = 0): ''' uri - The uri data whill will contain the information path - The path (if any) where the download needs to be done cache - The cache (if any) where we should check before downloading from the net arg_type - arg_type is basically used to identify ... |
os.unlink(sFile) | os.unlink(os.path.join(sSourceDir, sFile)) | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' while 1: item = request.get() if item is None: break (sUrl, sFile, download_size, checksum) = s... |
pass | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' while 1: item = request.get() if item is None: break (sUrl, sFile, download_size, checksum) = s... | |
if os.path.exists(os.path.join(cache, sFile)): pass | if os.access(os.path.join(cache, sFile), os.F_OK): log.debug("%s file is already present in cache-dir %s. Skipping copy.\n" % (sFile, cache)) log.verbose("%s file is already present in cache-dir %s. Skipping copy.\n" % (sFile, cache)) | def run(request, response, func=download_from_web): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' while 1: item = request.get() if item is None: break (sUrl, sFile, download_size, checksum) = s... |
if exit_status == False: | if exit_status == True: log.verbose("%s copied from cache-dir %s.\n" % (sFile, cache)) log.debug("%s copied from cache-dir %s.\n" % (sFile, cache)) else: log.debug("%s not available in local cache %s\n" % (sFile, cache)) | def run(request, response, func=copy_first_match): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' while 1: item = request.get() if item is None: break (sUrl, sFile, download_size, checksum) = st... |
if download_from_web(sUrl, sFile, sSourceDir, checksum) != True: log.verbose("%s not downloaded from %s and NA in local cache %s\n\n" % (sFile, sUrl, cache)) pypt_variables.errlist.append(sFile) | exit_status = download_from_web(sUrl, sFile, sSourceDir, checksum) if exit_status: if cache is None: log.debug("No cache-dir specified. Skipping copy.\n") elif os.access(os.path.join(cache, sFile), os.F_OK): log.debug("%s is already present in %s.\n" % (sFile, cache)) | def run(request, response, func=copy_first_match): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' while 1: item = request.get() if item is None: break (sUrl, sFile, download_size, checksum) = st... |
if cache is None or os.access(os.path.join(cache, sFile), os.F_OK): pass else: if os.access(cache, os.W_OK): shutil.copy(sFile, cache) log.verbose("%s copied to %s\n" % (sFile, cache)) else: log.verbose("Cannot copy %s to %s. Is %s writeable??\n" % (sFile, cache, cache)) pass if zip_bool: ziplock.acquire() try: compre... | if os.access(cache, os.W_OK): shutil.copy(sFile, cache) log.debug("%s copied to local cache-dir %s.\n" % (sFile, cache)) log.verbose("%s copied to local cache-dir %s.\n" % (sFile, cache)) | def run(request, response, func=copy_first_match): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' while 1: item = request.get() if item is None: break (sUrl, sFile, download_size, checksum) = st... |
os.unlink(sFile) | os.unlink(os.path.join(sSourceDir, sFile)) | def run(request, response, func=copy_first_match): '''Get items from the request Queue, process them with func(), put the results along with the Thread's name into the response Queue. Stop running once an item is None.''' while 1: item = request.get() if item is None: break (sUrl, sFile, download_size, checksum) = st... |
program = Group(OneOrMore(classDef)) + StringEnd() .setParseAction(AddMetaDict('program'))\ | program = Group(OneOrMore(classDef)) .setParseAction(AddMetaDict('program'))\ .setName('program') file = program + StringEnd() | def _defineLanguageSyntax(self): ''' Here is Siml's BNF Creates the objects of the pyParsing library, that do all the work. ''' #define short alias so they don't clutter the text kw = self.defineKeyword # Usage: test = kw('variable') L = Literal # Usage: L('+') |
startSymbol = program | startSymbol = file | def _defineLanguageSyntax(self): ''' Here is Siml's BNF Creates the objects of the pyParsing library, that do all the work. ''' #define short alias so they don't clutter the text kw = self.defineKeyword # Usage: test = kw('variable') L = Literal # Usage: L('+') |
if withprob(0.99): | if withprob(0.01): | def phasers(): "Fire phasers at bad guys." hits = [] kz = 0; k = 1; irec=0 # Cheating inhibitor ifast = False; no = False; itarg = True; msgflag = True; rpow=0 automode = "NOTSET" key=0 skip(1) # SR sensors and Computer are needed for automode if damaged(DSRSENS) or damaged(DCOMPTR): itarg = False if game.condition == ... |
stopegy = 50.0*course.dist/game.optime | stopegy = 50.0*course.distance/game.optime | def no_quad_change(): # No quadrant change -- compute new average enemy distances game.quad[game.sector.i][game.sector.j] = game.ship if game.enemies: for enemy in game.enemies: finald = (w-enemy.kloc).distance() enemy.kavgd = 0.5 * (finald + enemy.kdist) enemy.kdist = finald game.enemies.sort(lambda x, y: cmp(x.kdist,... |
prout(_("Checkov- \"Security reports the Galileo has reappeared in the dock!\"")) | prout(_("Chekov- \"Security reports the Galileo has reappeared in the dock!\"")) | def timwrp(): "Let's do the time warp again." prout(_("***TIME WARP ENTERED.")) if game.state.snap and withprob(0.5): # Go back in time prout(_("You are traveling backwards in time %d stardates.") % int(game.state.date-game.snapsht.date)) game.state = game.snapsht game.state.snap = False if len(game.state.kcmdr): sched... |
(os.getenv("LOGNAME"),socket.gethostname(),time.ctime())) | (getpass.getuser(),socket.gethostname(),time.ctime())) | def debugme(): "Access to the internals for debugging." proutn("Reset levels? ") if ja() == True: if game.energy < game.inenrg: game.energy = game.inenrg game.shield = game.inshld game.torps = game.intorps game.lsupres = game.inlsr proutn("Reset damage? ") if ja() == True: for i in range(NDEVICES): if game.damage[i] > ... |
proutn(_("LEGAL COMMANDS ARE:")) for (k, key) in enumerate(commands): | prout(_("LEGAL COMMANDS ARE:")) emitted = 0 for key in commands: | def listCommands(): "Generate a list of legal commands." proutn(_("LEGAL COMMANDS ARE:")) for (k, key) in enumerate(commands): if not commands[key] or (commands[key] & game.options): if k % 5 == 0: skip(1) proutn("%-12s " % key) skip(1) |
if k % 5 == 0: | proutn("%-12s " % key) emitted += 1 if emitted % 5 == 4: | def listCommands(): "Generate a list of legal commands." proutn(_("LEGAL COMMANDS ARE:")) for (k, key) in enumerate(commands): if not commands[key] or (commands[key] & game.options): if k % 5 == 0: skip(1) proutn("%-12s " % key) skip(1) |
proutn("%-12s " % key) | def listCommands(): "Generate a list of legal commands." proutn(_("LEGAL COMMANDS ARE:")) for (k, key) in enumerate(commands): if not commands[key] or (commands[key] & game.options): if k % 5 == 0: skip(1) proutn("%-12s " % key) skip(1) | |
return coord(self.x / abs(x), self.y / abs(y)); | s = coord() if self.x == 0: s.x = 0 else: s.x = self.x / abs(self.x) if self.y == 0: s.y = 0 else: s.y = self.y / abs(self.y) return s | def sgn(self): return coord(self.x / abs(x), self.y / abs(y)); |
self.ithere = False | def __init__(self): self.options = None # Game options self.state = snapshot() # A snapshot structure self.snapsht = snapshot() # Last snapshot taken for time-travel purposes self.quad = fill2d(QUADSIZE, lambda i, j: IHDOT) # contents of our quadrant self.kpower = fill2d(QUADSIZE, lambda i, j: 0.0) # enemy energy level... | |
if not game.ithere or game.justin: return | if not game.tholian or game.justin: return | def movetholian(): # move the Tholian if not game.ithere or game.justin: return if game.tholian.x == 0 and game.tholian.y == 0: idx = 0; idy = QUADSIZE-1 elif game.tholian.x == 0 and game.tholian.y == QUADSIZE-1: idx = QUADSIZE-1; idy = QUADSIZE-1 elif game.tholian.x == QUADSIZE-1 and game.tholian.y == QUADSIZE-1: idx... |
game.ithere = False | game.tholian = None | def movetholian(): # move the Tholian if not game.ithere or game.justin: return if game.tholian.x == 0 and game.tholian.y == 0: idx = 0; idy = QUADSIZE-1 elif game.tholian.x == 0 and game.tholian.y == QUADSIZE-1: idx = QUADSIZE-1; idy = QUADSIZE-1 elif game.tholian.x == QUADSIZE-1 and game.tholian.y == QUADSIZE-1: idx... |
game.ithere = False | game.tholian = None | def torpedo(course, r, incoming, i, n): # let a photon torpedo fly iquad = 0 shoved = False ac = course + 0.25*r angle = (15.0-ac)*0.5235988 bullseye = (15.0 - course)*0.5235988 deltax = -math.sin(angle); deltay = math.cos(angle); x = incoming.x; y = incoming.y w = coord(); jw = coord() w.x = w.y = jw.x = jw.y = 0 bigg... |
if game.ithere: | if game.tholian: | def attack(torps_ok): # bad guy attacks us # torps_ok == false forces use of phasers in an attack atackd = False; attempt = False; ihurt = False; hitmax=0.0; hittot=0.0; chgfac=1.0 jay = coord() where = "neither" # game could be over at this point, check if game.alldone: return if idebug: prout("=== ATTACK!") # Tholian... |
game.ithere = False | game.tholian = None | def deadkl(w, type, mv): # kill a Klingon, Tholian, Romulan, or Thingy # Added mv to allow enemy to "move" before dying crmena(True, type, sector, mv) # Decide what kind of enemy it is and update appropriately if type == IHR: # chalk up a Romulan game.state.galaxy[game.quadrant.x][game.quadrant.y].romulans -= 1 game.ir... |
hits = []; rpow=0 | hits = [] | def phasers(): # fire phasers hits = []; rpow=0 kz = 0; k = 1; irec=0 # Cheating inhibitor ifast = False; no = False; itarg = True; msgflag = True automode = "NOTSET" key=0 skip(1) # SR sensors and Computer are needed fopr automode if damaged(DSRSENS) or damaged(DCOMPTR): itarg = False if game.condition == "docked": pr... |
ifast = False; no = False; itarg = True; msgflag = True | ifast = False; no = False; itarg = True; msgflag = True; rpow=0 | def phasers(): # fire phasers hits = []; rpow=0 kz = 0; k = 1; irec=0 # Cheating inhibitor ifast = False; no = False; itarg = True; msgflag = True automode = "NOTSET" key=0 skip(1) # SR sensors and Computer are needed fopr automode if damaged(DSRSENS) or damaged(DCOMPTR): itarg = False if game.condition == "docked": pr... |
proutn(_("Manual or automatic? ")) | proutn(_("Manual or automatic? ")) chew() | def phasers(): # fire phasers hits = []; rpow=0 kz = 0; k = 1; irec=0 # Cheating inhibitor ifast = False; no = False; itarg = True; msgflag = True automode = "NOTSET" key=0 skip(1) # SR sensors and Computer are needed fopr automode if damaged(DSRSENS) or damaged(DCOMPTR): itarg = False if game.condition == "docked": pr... |
hits[i] = 0.0 | hits.append(0.0) | def phasers(): # fire phasers hits = []; rpow=0 kz = 0; k = 1; irec=0 # Cheating inhibitor ifast = False; no = False; itarg = True; msgflag = True automode = "NOTSET" key=0 skip(1) # SR sensors and Computer are needed fopr automode if damaged(DSRSENS) or damaged(DCOMPTR): itarg = False if game.condition == "docked": pr... |
if game.ithere: | if game.tholian: | def phasers(): # fire phasers hits = []; rpow=0 kz = 0; k = 1; irec=0 # Cheating inhibitor ifast = False; no = False; itarg = True; msgflag = True automode = "NOTSET" key=0 skip(1) # SR sensors and Computer are needed fopr automode if damaged(DSRSENS) or damaged(DCOMPTR): itarg = False if game.condition == "docked": pr... |
def tractorbeam(): | def tractorbeam(yank): | def tractorbeam(): # tractor beaming cases merge here yank = math.sqrt(yank) announce() game.optime = (10.0/(7.5*7.5))*yank # 7.5 is yank rate (warp 7.5) skip(1) proutn("***") crmshp() prout(_(" caught in long range tractor beam--")) # If Kirk & Co. screwing around on planet, handle atover(True) # atover(true) is Grab ... |
yank = math.sqrt(yank) | def tractorbeam(): # tractor beaming cases merge here yank = math.sqrt(yank) announce() game.optime = (10.0/(7.5*7.5))*yank # 7.5 is yank rate (warp 7.5) skip(1) proutn("***") crmshp() prout(_(" caught in long range tractor beam--")) # If Kirk & Co. screwing around on planet, handle atover(True) # atover(true) is Grab ... | |
if evcode==0: | if evcode == FSPY: | def tractorbeam(): # tractor beaming cases merge here yank = math.sqrt(yank) announce() game.optime = (10.0/(7.5*7.5))*yank # 7.5 is yank rate (warp 7.5) skip(1) proutn("***") crmshp() prout(_(" caught in long range tractor beam--")) # If Kirk & Co. screwing around on planet, handle atover(True) # atover(true) is Grab ... |
doshield(True) game.shldchg=False | doshield(shraise=True) game.shldchg = False | def tractorbeam(): # tractor beaming cases merge here yank = math.sqrt(yank) announce() game.optime = (10.0/(7.5*7.5))*yank # 7.5 is yank rate (warp 7.5) skip(1) proutn("***") crmshp() prout(_(" caught in long range tractor beam--")) # If Kirk & Co. screwing around on planet, handle atover(True) # atover(true) is Grab ... |
istract = True yank = distance(game.state.kscmdr, game.quadrant) ictbeam = True tractorbeam() | istract = ictbeam = True tractorbeam(distance(game.state.kscmdr, game.quadrant)) | def destroybase(): # Code merges here for any commander destroying base # Not perfect, but will have to do # Handle case where base is in same quadrant as starship if game.battle == game.quadrant: game.state.chart[game.battle.x][game.battle.y].starbase = False game.quad[game.base.x][game.base.y] = IHDOT game.base.x=gam... |
yank = square(game.state.kcmdr[i].x-game.quadrant.x) + square(game.state.kcmdr[i].y-game.quadrant.y) | yank = distance(game.state.kcmdr[i], game.quadrant) | def destroybase(): # Code merges here for any commander destroying base # Not perfect, but will have to do # Handle case where base is in same quadrant as starship if game.battle == game.quadrant: game.state.chart[game.battle.x][game.battle.y].starbase = False game.quad[game.base.x][game.base.y] = IHDOT game.base.x=gam... |
tractorbeam() | tractorbeam(yank) | def destroybase(): # Code merges here for any commander destroying base # Not perfect, but will have to do # Handle case where base is in same quadrant as starship if game.battle == game.quadrant: game.state.chart[game.battle.x][game.battle.y].starbase = False game.quad[game.base.x][game.base.y] = IHDOT game.base.x=gam... |
game.snapsht = game.state | game.snapsht = copy.deepcopy(game.state) | def destroybase(): # Code merges here for any commander destroying base # Not perfect, but will have to do # Handle case where base is in same quadrant as starship if game.battle == game.quadrant: game.state.chart[game.battle.x][game.battle.y].starbase = False game.quad[game.base.x][game.base.y] = IHDOT game.base.x=gam... |
q.supernova or q.status!=secure or q.klingons<=0): | q.supernova or q.status!="secure" or q.klingons<=0): | def destroybase(): # Code merges here for any commander destroying base # Not perfect, but will have to do # Handle case where base is in same quadrant as starship if game.battle == game.quadrant: game.state.chart[game.battle.x][game.battle.y].starbase = False game.quad[game.base.x][game.base.y] = IHDOT game.base.x=gam... |
logfp.write(line) | logfp.write(line + "\n") | def cgetline(): "Get a line of input." if game.options & OPTION_CURSES: line = curwnd.getstr() + "\n" curwnd.refresh() else: if replayfp and not replayfp.closed: line = replayfp.readline() else: line = raw_input() if logfp: logfp.write(line) return line |
game.optime = (0.1+0.2*random.random())*game.iplnet.pclass | game.optime = (0.1+0.2*random.random())*(ord(game.iplnet.pclass)-ord("M")) | def mine(): # strip-mine a world for dilithium skip(1) chew() if not game.landed: prout(_("Mining party not on planet.")) return if game.iplnet.crystals == "mined": prout(_("This planet has already been strip-mined for dilithium.")) return elif game.iplnet.crystals == "absent": prout(_("No dilithium crystals on this pl... |
if game.nenhere - (thing == game.quadrant) - game.ithere: | if game.nenhere - (thing == game.quadrant) - (game.tholian != None): | def setup(needprompt): # prepare to play, set up cosmos w = coord() # Decide how many of everything if choose(needprompt): return # frozen game # Prepare the Enterprise game.alldone = game.gamewon = False game.ship = IHE game.state.crew = FULLCREW game.energy = game.inenrg = 5000.0 game.shield = game.inshld = 2500.0 g... |
game.ithere = False | def newqad(shutup): # set up a new state of quadrant, for when we enter or re-enter it w = coord() game.justin = True game.klhere = 0 game.comhere = False game.ishere = False game.irhere = 0 game.iplnet = 0 game.nenhere = 0 game.neutz = False game.inorbit = False game.landed = False game.ientesc = False game.ithere = F... | |
if same(game.quadrant, game.state.kscmdr): | if game.quadrant == game.state.kscmdr: | def newqad(shutup): # set up a new state of quadrant, for when we enter or re-enter it w = coord() game.justin = True game.klhere = 0 game.comhere = False game.ishere = False game.irhere = 0 game.iplnet = 0 game.nenhere = 0 game.neutz = False game.inorbit = False game.landed = False game.ientesc = False game.ithere = F... |
game.ithere = True | def newqad(shutup): # set up a new state of quadrant, for when we enter or re-enter it w = coord() game.justin = True game.klhere = 0 game.comhere = False game.ishere = False game.irhere = 0 game.iplnet = 0 game.nenhere = 0 game.neutz = False game.inorbit = False game.landed = False game.ientesc = False game.ithere = F... | |
if game.ithere: | if game.tholian: | def newqad(shutup): # set up a new state of quadrant, for when we enter or re-enter it w = coord() game.justin = True game.klhere = 0 game.comhere = False game.ishere = False game.irhere = 0 game.iplnet = 0 game.nenhere = 0 game.neutz = False game.inorbit = False game.landed = False game.ientesc = False game.ithere = F... |
if game.nenhere-(thing==game.quadrant)-game.ithere < 2: | if game.nenhere-(thing==game.quadrant)-(game.tholian!=None) < 2: | def sortklings(): # sort Klingons by distance from us # The author liked bubble sort. So we will use it. :-( if game.nenhere-(thing==game.quadrant)-game.ithere < 2: return while True: sw = False for j in range(game.nenhere): if game.kdist[j] > game.kdist[j+1]: sw = True t = game.kdist[j] game.kdist[j] = game.kdist[j+1]... |
doshield(False) | doshield(shraise=False) | def makemoves(): # command-interpretation loop v = 0 clrscr() setwnd(message_window) while True: # command loop drawmaps(1) while True: # get a command hitme = False game.justin = False game.optime = 0.0 chew() setwnd(prompt_window) clrscr() proutn("COMMAND> ") if scan() == IHEOL: if game.options & OPTION_CURSES: make... |
imove(True) | imove(novapush=True) | def nova(nov): # star goes nova course = (0.0, 10.5, 12.0, 1.5, 9.0, 0.0, 3.0, 7.5, 6.0, 4.5) newc = coord(); scratch = coord() if random.random() < 0.05: # Wow! We've supernova'ed supernova(False, nov) return # handle initial nova game.quad[nov.x][nov.y] = IHDOT crmena(False, IHSTAR, sector, nov) prout(_(" novas.")) g... |
curses.delay_output(30) | time.sleep(0.03) | def prouts(line): "print slowly!" for c in line: curses.delay_output(30) proutn(c) if game.options & OPTION_CURSES: wrefresh(curwnd) else: sys.stdout.flush() curses.delay_output(300) |
curses.delay_output(300) | time.sleep(0.03) | def prouts(line): "print slowly!" for c in line: curses.delay_output(30) proutn(c) if game.options & OPTION_CURSES: wrefresh(curwnd) else: sys.stdout.flush() curses.delay_output(300) |
curses.delay_output(400) | time.sleep(0.4) | def tracktorpedo(w, l, i, n, iquad): "Torpedo-track animation." if not game.options & OPTION_CURSES: if l == 1: if n != 1: skip(1) proutn(_("Track for torpedo number %d- ") % i) else: skip(1) proutn(_("Torpedo track- ")) elif l==4 or l==9: skip(1) proutn("%d - %d " % (w.x, w.y)) else: if not damaged(DSRSENS) or game... |
n = 10.0*game.dist*bigger+0.5 | n = int(10.0*game.dist*bigger+0.5) | def no_quad_change(): # No quadrant change -- compute new avg enemy distances game.quad[game.sector.x][game.sector.y] = game.ship if game.nenhere: for m in range(game.nenhere): finald = distance(w, game.ks[m]) game.kavgd[m] = 0.5 * (finald+game.kdist[m]) game.kdist[m] = finald sortklings() if not game.state.galaxy[game... |
w.x = x + 0.5 w.y = y + 0.5 | w.x = int(x + 0.5) w.y = int(y + 0.5) | def no_quad_change(): # No quadrant change -- compute new avg enemy distances game.quad[game.sector.x][game.sector.y] = game.ship if game.nenhere: for m in range(game.nenhere): finald = distance(w, game.ks[m]) game.kavgd[m] = 0.5 * (finald+game.kdist[m]) game.kdist[m] = finald sortklings() if not game.state.galaxy[game... |
w.x = x+10.0*game.dist*bigger*deltax+0.5 w.y = y+10.0*game.dist*bigger*deltay+0.5 | w.x = int(x+10.0*game.dist*bigger*deltax+0.5) w.y = int(y+10.0*game.dist*bigger*deltay+0.5) | def no_quad_change(): # No quadrant change -- compute new avg enemy distances game.quad[game.sector.x][game.sector.y] = game.ship if game.nenhere: for m in range(game.nenhere): finald = distance(w, game.ks[m]) game.kavgd[m] = 0.5 * (finald+game.kdist[m]) game.kdist[m] = finald sortklings() if not game.state.galaxy[game... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.