rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
for k in range(nenhr2): wham = hits[k] | for (k, wham) in enumerate(hits): | def hittem(hits): # register a phaser hit on Klingons and Romulans nenhr2 = game.nenhere; kk=1 w = coord() skip(1) for k in range(nenhr2): wham = hits[k] if wham==0: continue dustfac = randreal(0.9, 1.0) hit = wham*math.pow(dustfac,game.kdist[kk]) kpini = game.kpower[kk] kp = math.fabs(kpini) if PHASEFAC*hit < kp: kp =... |
kk -= 1; | kk -= 1 continue | def hittem(hits): # register a phaser hit on Klingons and Romulans nenhr2 = game.nenhere; kk=1 w = coord() skip(1) for k in range(nenhr2): wham = hits[k] if wham==0: continue dustfac = randreal(0.9, 1.0) hit = wham*math.pow(dustfac,game.kdist[kk]) kpini = game.kpower[kk] kp = math.fabs(kpini) if PHASEFAC*hit < kp: kp =... |
return; | return | def hittem(hits): # register a phaser hit on Klingons and Romulans nenhr2 = game.nenhere; kk=1 w = coord() skip(1) for k in range(nenhr2): wham = hits[k] if wham==0: continue dustfac = randreal(0.9, 1.0) hit = wham*math.pow(dustfac,game.kdist[kk]) kpini = game.kpower[kk] kp = math.fabs(kpini) if PHASEFAC*hit < kp: kp =... |
time.sleep(0.03) | if not replayfp or replayfp.closed: time.sleep(0.03) | def prouts(line): "print slowly!" for c in line: time.sleep(0.03) proutn(c) if game.options & OPTION_CURSES: wrefresh(curwnd) else: sys.stdout.flush() time.sleep(0.03) |
if not (game.options & (OPTION_PLAIN | OPTION_ALMY)): | if (game.options & OPTION_AUTOSCAN): | def chart(): # display the star chart chew() if not (game.options & (OPTION_PLAIN | OPTION_ALMY)): lrscan(silent=True) if not damaged(DRADIO): rechart() if game.lastchart < game.state.date and game.condition == "docked": prout(_("Spock- \"I revised the Star Chart from the starbase's records.\"")) rechart() prout(_(" ... |
w.x = w.y = 0 | 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 global iqengry ... | |
break if i <= game.state.remcom: game.quad[w.x][w.y] = IHC game.kpower[game.klhere] = randreal(950, 1350) + 50.0*game.skill game.comhere = True | game.quad[game.ks[i].x][game.ks[i].y] = IHC game.kpower[game.klhere] = randreal(950,1350) + 50.0*game.skill game.comhere = True break | 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 global iqengry ... |
game.quad[game.ks[0].x][game.ks[0].y] = IHS | game.quad[w.x][w.y] = IHS | 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 global iqengry ... |
for j in range(game.nenhere): | for j in range(game.nenhere-1): | 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.tholian!=None) < 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.k... |
os.exit(1) | raise SystemExit(1) | 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] > 0... |
os.exit(0) | raise SystemExit, 1 | 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] > 0... |
def snaptogrid(self): | def roundtogrid(self): return coord(int(round(self.i)), int(round(self.j))) def trunctogrid(self): | def snaptogrid(self): return coord(int(round(self.i)), int(round(self.j))) |
w = ungridded.snaptogrid() | w = ungridded.roundtogrid() | def torpedo(origin, course, dispersion, number, nburst): "Let a photon torpedo fly" if not damaged(DSRSENS) or game.condition=="docked": setwnd(srscan_window) else: setwnd(message_window) shoved = False ac = course + 0.25*dispersion angle = (15.0-ac)*0.5235988 bullseye = (15.0 - course)*0.5235988 delta = coord(-math.si... |
if game.probe.next(): | if game.probe.nextquad(): | def destroybase(): "Code merges here for any commander destroying a starbase." # 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.i][game.battle.j].starbase = False game.quad[game.base.i][game.base.j] = IHDOT game.bas... |
def next(self): "Next location on course, currently only at quadrant granularity." | def nextquad(self): "Next location on course, at quadrant granularity." | def next(self): "Next location on course, currently only at quadrant granularity." self.location += self.increment newloc = (self.location / float(QUADSIZE)).snaptogrid() if not newloc == self.loc: self.loc = newloc return True else: return False |
newloc = (self.location / float(QUADSIZE)).snaptogrid() | newloc = (self.location / float(QUADSIZE)).trunctogrid() | def next(self): "Next location on course, currently only at quadrant granularity." self.location += self.increment newloc = (self.location / float(QUADSIZE)).snaptogrid() if not newloc == self.loc: self.loc = newloc return True else: return False |
icas = 10.0+20.0*random.random() | icas = 10 + random.randrange(20) | def ram(ibumpd, ienm, w): # make our ship ram something prouts(_("***RED ALERT! RED ALERT!")) skip(1) prout(_("***COLLISION IMMINENT.")) skip(2) proutn("***") crmshp() hardness = {IHR:1.5, IHC:2.0, IHS:2.5, IHT:0.5, IHQUEST:4.0}.get(ienm, 1.0) if ibumpd: proutn(_(" rammed by ")) else: proutn(_(" rams ")) crmena(False,... |
i = random.random()*game.state.remcom+1.0 | i = random.randrange(game.state.remcom) | 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... |
num = random.random()*stars + 1 | num = random.randrange(stars) + 1 | def supernova(induced, w=None): # star goes supernova num = 0; npdead = 0 nq = coord() if w != None: nq = w else: stars = 0 # Scheduled supernova -- select star # logic changed here so that we won't favor quadrants in top # left of universe for nq.x in range(GALSIZE): for nq.y in range(GALSIZE): stars += game.state.gal... |
num = random.random()* game.state.galaxy[nq.x][nq.y].stars + 1 | num = random.randrange(game.state.galaxy[nq.x][nq.y].stars) + 1 | def supernova(induced, w=None): # star goes supernova num = 0; npdead = 0 nq = coord() if w != None: nq = w else: stars = 0 # Scheduled supernova -- select star # logic changed here so that we won't favor quadrants in top # left of universe for nq.x in range(GALSIZE): for nq.y in range(GALSIZE): stars += game.state.gal... |
w.x = int(x + 0.5) w.y = int(y + 0.5) | w.x = int(round(x)) w.y = int(round(y)) | def no_quad_change(): # No quadrant change -- compute new average 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[... |
x = QUADSIZE*(game.quadrant.x-1)+game.sector.x y = QUADSIZE*(game.quadrant.y-1)+game.sector.y w.x = int(x+10.0*game.dist*bigger*deltax+0.5) w.y = int(y+10.0*game.dist*bigger*deltay+0.5) | x = (QUADSIZE*game.quadrant.x)+game.sector.x y = (QUADSIZE*game.quadrant.y)+game.sector.y w.x = int(round(x+10.0*game.dist*bigger*deltax)) w.y = int(round(y+10.0*game.dist*bigger*deltay)) | def no_quad_change(): # No quadrant change -- compute new average 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[... |
kink = 0 if w.x <= 0: w.x = -w.x + 1 kink = 1 if w.y <= 0: w.y = -w.y + 1 kink = 1 if w.x > GALSIZE*QUADSIZE: w.x = (GALSIZE*QUADSIZE*2)+1 - w.x kink = 1 if w.y > GALSIZE*QUADSIZE: w.y = (GALSIZE*QUADSIZE*2)+1 - w.y kink = 1 | kink = False if w.x < 0: w.x = -w.x kink = True if w.y < 0: w.y = -w.y kink = True if w.x >= GALSIZE*QUADSIZE: w.x = (GALSIZE*QUADSIZE*2) - w.x kink = True if w.y >= GALSIZE*QUADSIZE: w.y = (GALSIZE*QUADSIZE*2) - w.y kink = True | def no_quad_change(): # No quadrant change -- compute new average 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[... |
kinks = 1 if not kink: break | kinks += 1 else: break | def no_quad_change(): # No quadrant change -- compute new average 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[... |
if iquad in (IHT. IHK, OHC, IHS, IHR, IHQUEST): | if iquad in (IHT, IHK, OHC, IHS, IHR, IHQUEST): | def no_quad_change(): # No quadrant change -- compute new average 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.condition.upper(), sum(map(lambda x: x > 0, damages)))) | (game.condition.upper(), sum(map(lambda x: x > 0, game.damage)))) | def status(req=0): "Emit status report lines" if not req or req == 1: prstat(_("Stardate"), _("%.1f, Time Left %.2f") \ % (game.state.date, game.state.remtime)) if not req or req == 2: if game.condition != "docked": newcnd() prstat(_("Condition"), _("%s, %i DAMAGES") % \ (game.condition.upper(), sum(map(lambda x: x > 0... |
msteps = -motion | nsteps = -motion | def movebaddy(com, loccom, ienm): # tactical movement for the bad guys next = coord(); look = coord() irun = False # This should probably be just game.comhere + game.ishere if game.skill >= SKILL_EXPERT: nbaddys = ((game.comhere*2 + game.ishere*2+game.klhere*1.23+game.irhere*1.5)/2.0) else: nbaddys = game.comhere + gam... |
msteps = motion | nsteps = motion | def movebaddy(com, loccom, ienm): # tactical movement for the bad guys next = coord(); look = coord() irun = False # This should probably be just game.comhere + game.ishere if game.skill >= SKILL_EXPERT: nbaddys = ((game.comhere*2 + game.ishere*2+game.klhere*1.23+game.irhere*1.5)/2.0) else: nbaddys = game.comhere + gam... |
lrscan() | lrscan(silent=False) | def drawmaps(mode): "Hook to be called after moving to redraw maps." if game.options & OPTION_CURSES: if mode == 1: sensor() setwnd(srscan_window) curwnd.move(0, 0) srscan() if mode != 2: setwnd(status_window) status_window.clear() status_window.move(0, 0) setwnd(report_window) report_window.clear() report_window.move(... |
def lrscan(): | def lrscan(silent): | def lrscan(): # long-range sensor scan if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": prout(_("LONG-RANGE SENSORS DAMAGED.")) return prout(_("Starbase's long-range scan")) else: prout(_("Long-range scan")) for x in range(game.quadrant.x-1, game.quadrant.x+2): proutn(" ") for y ... |
prout(_("LONG-RANGE SENSORS DAMAGED.")) | if not silent: prout(_("LONG-RANGE SENSORS DAMAGED.")) | def lrscan(): # long-range sensor scan if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": prout(_("LONG-RANGE SENSORS DAMAGED.")) return prout(_("Starbase's long-range scan")) else: prout(_("Long-range scan")) for x in range(game.quadrant.x-1, game.quadrant.x+2): proutn(" ") for y ... |
prout(_("Starbase's long-range scan")) else: | if not silent: prout(_("Starbase's long-range scan")) elif not silent: | def lrscan(): # long-range sensor scan if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": prout(_("LONG-RANGE SENSORS DAMAGED.")) return prout(_("Starbase's long-range scan")) else: prout(_("Long-range scan")) for x in range(game.quadrant.x-1, game.quadrant.x+2): proutn(" ") for y ... |
proutn(" ") | if not silent: proutn(" ") | def lrscan(): # long-range sensor scan if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": prout(_("LONG-RANGE SENSORS DAMAGED.")) return prout(_("Starbase's long-range scan")) else: prout(_("Long-range scan")) for x in range(game.quadrant.x-1, game.quadrant.x+2): proutn(" ") for y ... |
proutn(" -1") | if not silent: proutn(" -1") | def lrscan(): # long-range sensor scan if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": prout(_("LONG-RANGE SENSORS DAMAGED.")) return prout(_("Starbase's long-range scan")) else: prout(_("Long-range scan")) for x in range(game.quadrant.x-1, game.quadrant.x+2): proutn(" ") for y ... |
if game.state.galaxy[x][y].supernova: | if not silent and game.state.galaxy[x][y].supernova: | def lrscan(): # long-range sensor scan if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": prout(_("LONG-RANGE SENSORS DAMAGED.")) return prout(_("Starbase's long-range scan")) else: prout(_("Long-range scan")) for x in range(game.quadrant.x-1, game.quadrant.x+2): proutn(" ") for y ... |
else: | elif not silent: | def lrscan(): # long-range sensor scan if damaged(DLRSENS): # Now allow base's sensors if docked if game.condition != "docked": prout(_("LONG-RANGE SENSORS DAMAGED.")) return prout(_("Starbase's long-range scan")) else: prout(_("Long-range scan")) for x in range(game.quadrant.x-1, game.quadrant.x+2): proutn(" ") for y ... |
lrscan() | lrscan(silent=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... |
global line, thing, game, idebug, iqengry game = citem = aaitem = inqueue = None line = '' thing = coord() iqengry = False game = gamestate() idebug = 0 game.options = OPTION_ALL &~ (OPTION_IOMODES | OPTION_SHOWME | OPTION_PLAIN | OPTION_ALMY) game.options |= OPTION_TTY seed = int(time.time()) (options, arguments) ... | 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] > 0... | |
logfp = open("/usr/tmp/sst-input.log", "w") except IOError: sys.stderr.write("sst: warning, can't open logfile\n") if logfp: logfp.write(" logfp.write(" random.seed(seed) iostart() if arguments: inqueue = arguments else: inqueue = None while True: setwnd(fullscreen_window) clrscr() prelim() setup(needprompt=not inqueue... | global line, thing, game, idebug, iqengry game = citem = aaitem = inqueue = None line = '' thing = coord() iqengry = False game = gamestate() idebug = 0 game.options = OPTION_ALL &~ (OPTION_IOMODES | OPTION_PLAIN | OPTION_ALMY) game.options |= OPTION_TTY seed = int(time.time()) (options, arguments) = getopt.getopt(... | 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] > 0... |
print " --compile-data run the data compiler" print " --config=path path to config (.ini) file" print " --log=classes set the logging classes" print " --slog=level set the simdata logging level" print " --dump-data show the contents of sim.dar... | print " --compile-data run the data compiler" print " --config=path path to config (.ini) file" print " --logcat=categories set the logging categories (colon-delimited)" print " examples: --logcat=APP:TERRAIN:PHYSICS" print " --logcat=ALL:... | def printUsage(): print "Combat Simulator Project - CSPSim" print print " Primary options:" print " --compile-data run the data compiler" print " --config=path path to config (.ini) file" print " --log=classes set the logging classes" print " --slog=level set... |
if len(log_classes) == 0: return | if len(log_categories) == 0: return | def setLogCategory(): if len(log_classes) == 0: return flags = 0 for class_name in log_classes: try: class_flag = getattr(CSP, "CSP_"+class_name); flags = flags | class_flag except: print "Unrecognized log class:", class_name CSP.csplog().setLogCategory(flags) |
for class_name in log_classes: | for class_name in log_categories: invert = 0 if class_name.startswith('-'): class_name = class_name[1:] invert = 1 | def setLogCategory(): if len(log_classes) == 0: return flags = 0 for class_name in log_classes: try: class_flag = getattr(CSP, "CSP_"+class_name); flags = flags | class_flag except: print "Unrecognized log class:", class_name CSP.csplog().setLogCategory(flags) |
flags = flags | class_flag | if invert: flags = flags & ~class_flag else: flags = flags | class_flag | def setLogCategory(): if len(log_classes) == 0: return flags = 0 for class_name in log_classes: try: class_flag = getattr(CSP, "CSP_"+class_name); flags = flags | class_flag except: print "Unrecognized log class:", class_name CSP.csplog().setLogCategory(flags) |
print "Unrecognized option '%s'" % args[0] print | print "Unrecognized option '%s'\n" % args[0] | def runCSPSim(args): if len(args): print "Unrecognized option '%s'" % args[0] print printUsage() print sys.exit(1) cachepath = CSP.getCachePath() dar = os.path.join(cachepath, "sim.dar") if not os.path.exists(dar): print print "Static data archive '%s' not found." % dar compileData([]) import Shell app = CSP.CSPSim() s... |
archive.getObject("sim:terrain.balkan") archive.getObject("sim:theater.balkan") | def dumpData(args): cachepath = CSP.getCachePath() dar = os.path.join(cachepath, "sim.dar") for arg in args: if arg.startswith('--dump-data='): dar = arg[12:] archive = SimData.DataArchive(dar, 1) archive.dump() archive.getObject("sim:terrain.balkan") archive.getObject("sim:theater.balkan") | |
global log_classes | global log_categories global log_priority | def main(argv): global log_classes initDynamicLoading() setDefaultJoystick() action = None # process command line options program = argv[0] all_args = argv[1:] log_classes = [] other_args = [] pause = 0 simdata_loglevel = "ALERT" config = findConfig() for arg in all_args: if arg == '--compile-data': action = compi... |
log_classes = [] | log_categories = [] log_priority = None log_priority_arg = None | def main(argv): global log_classes initDynamicLoading() setDefaultJoystick() action = None # process command line options program = argv[0] all_args = argv[1:] log_classes = [] other_args = [] pause = 0 simdata_loglevel = "ALERT" config = findConfig() for arg in all_args: if arg == '--compile-data': action = compi... |
simdata_loglevel = "ALERT" | def main(argv): global log_classes initDynamicLoading() setDefaultJoystick() action = None # process command line options program = argv[0] all_args = argv[1:] log_classes = [] other_args = [] pause = 0 simdata_loglevel = "ALERT" config = findConfig() for arg in all_args: if arg == '--compile-data': action = compi... | |
elif arg.startswith("--log="): log_classes.extend(arg[6:].split(':')) elif arg.startswith("--slog="): simdata_loglevel = arg[7:] | elif arg.startswith("--logcat="): log_categories.extend(arg[9:].split(':')) elif arg.startswith("--logpri="): log_priority_arg = arg[9:] | def main(argv): global log_classes initDynamicLoading() setDefaultJoystick() action = None # process command line options program = argv[0] all_args = argv[1:] log_classes = [] other_args = [] pause = 0 simdata_loglevel = "ALERT" config = findConfig() for arg in all_args: if arg == '--compile-data': action = compi... |
try: simdata_loglevel = eval("SimData.LOG_%s" % simdata_loglevel.upper()) except: print "Invalid SimData logging level, defaulting to 'ALERT'" simdata_loglevel = SimData.LOG_ALERT SimData.log().setLogPriority(simdata_loglevel) | def main(argv): global log_classes initDynamicLoading() setDefaultJoystick() action = None # process command line options program = argv[0] all_args = argv[1:] log_classes = [] other_args = [] pause = 0 simdata_loglevel = "ALERT" config = findConfig() for arg in all_args: if arg == '--compile-data': action = compi... | |
print "Hit <ctrl-break> to temporarily exit and set breakpoints." print "When you are done, continue execution and hit <enter>." sys.stdin.readline() | print print "CSPSim has loaded all extension modules, and is now paused to give you" print "an opportunity to attach a debugging session. Under GNU/Linux run the" print "following command from a separate shell to attach a debug session:" print print " gdb python %d" % os.getpid() print print "This will run gdb and a... | def main(argv): global log_classes initDynamicLoading() setDefaultJoystick() action = None # process command line options program = argv[0] all_args = argv[1:] log_classes = [] other_args = [] pause = 0 simdata_loglevel = "ALERT" config = findConfig() for arg in all_args: if arg == '--compile-data': action = compi... |
self.archive._int(x0) | self.archive._int32(x0) | def testInt(self): """Test storage and retrieval of Int""" x0 = 42 self.archive._int(x0) self.setRead() self.assertEqual(self.size, 4) x1 = self.archive._int() self.assertEqual(x0, x1) |
x1 = self.archive._int() | x1 = self.archive._int32() | def testInt(self): """Test storage and retrieval of Int""" x0 = 42 self.archive._int(x0) self.setRead() self.assertEqual(self.size, 4) x1 = self.archive._int() self.assertEqual(x0, x1) |
def __init__(self, dlls, headers=[]): | def __init__(self, dlls=[], libs=[], headers=[]): | def __init__(self, dlls, headers=[]): if isinstance(dlls, str): dlls = [dlls] self._dlls = dlls self._headers = headers |
conf.env.AppendUnique(LIBS=self._dlls) | conf.env.AppendUnique(LIBS=self._dlls + self._libs) | def configure(self, conf): if IsWindows(conf.env): DevpackConfig._Find() dp = DevpackConfig.DEVPACK for dll in self._dlls: self._checkPath(dp, 'usr', 'bin', dll + '.dll') self._checkPath(dp, 'usr', 'lib', dll + '.lib') for header in self._headers: if isinstance(header, tuple): header = os.path.join(*header) self._check... |
dx = float(attrs["spacing"]) | def assign(self, interface, object, name): missing = filter(lambda x, f=self._keys.has_key: not f(x), self._required_members) assert len(missing)==0, "LUTHandler required tag(s) missing:\n %s" % str(missing) table = getattr(SimData, "Table%d" % self._dim)() tags = self._keys breaks = [] spacing = [] for i in range(sel... | |
SimData.log().setLogLevels(SimData.LOG_ALL, SimData.LOG_WARNING) | SimData.log().setLogPriority(SimData.LOG_WARNING) SimData.log().setLogCategory(SimData.LOG_ALL) | def parse(self, args): self._name = args[0] args = args[1:] for arg in args: if arg.startswith('-'): if arg.startswith('--warn='): try: level = int(arg[7:]) except: self.usage("invalid option '%s'" % arg) setWarningLevel(level) if level > 0: SimData.log().setLogLevels(SimData.LOG_ALL, SimData.LOG_WARNING) elif arg.star... |
SimData.log().setLogLevels(SimData.LOG_ALL, SimData.LOG_TRACE) | SimData.log().setLogPriority(SimData.LOG_TRACE) SimData.log().setLogCategory(SimData.LOG_ALL) | def parse(self, args): self._name = args[0] args = args[1:] for arg in args: if arg.startswith('-'): if arg.startswith('--warn='): try: level = int(arg[7:]) except: self.usage("invalid option '%s'" % arg) setWarningLevel(level) if level > 0: SimData.log().setLogLevels(SimData.LOG_ALL, SimData.LOG_WARNING) elif arg.star... |
SimData.log().setLogLevels(SimData.LOG_ALL, SimData.LOG_DEBUG) | SimData.log().setLogPriority(SimData.LOG_DEBUG) SimData.log().setLogCategory(SimData.LOG_ALL) | def parse(self, args): self._name = args[0] args = args[1:] for arg in args: if arg.startswith('-'): if arg.startswith('--warn='): try: level = int(arg[7:]) except: self.usage("invalid option '%s'" % arg) setWarningLevel(level) if level > 0: SimData.log().setLogLevels(SimData.LOG_ALL, SimData.LOG_WARNING) elif arg.star... |
os.system('%s -I%s -o%s %s' % (csp_input, tool_path, output, example)) | os.system('python %s -I%s -o%s %s' % (csp_input, tool_path, output, example)) | def ensureDefaultHID(hid_file): """ Verify that the specified hid input definition exists. If not, generate it from from the example input maps in ../Tools/HID/Examples """ input_path = os.path.join('..', 'Data', 'Input') if not os.path.exists(input_path): return output = os.path.join(input_path, '%s.hid' % hid_file) ... |
if os.name.startswith('win'): | if sys.platform.startswith('win') or os.name == 'nt': | def _configureModules(): if os.name.startswith('win'): # if CSPDEVPACK is defined in the environment, add the devpack bin # directory to the execution path. this ensures that devpack libraries # will be found before other (potentially incompatible) versions of the # same libraries. note that windows is currently the ... |
bin = os.path.join(devpack, 'usr', 'bin') path = [bin] if 'PATH' in os.environ: path.append(os.environ.get('PATH')) os.environ['PATH'] = os.pathsep.join(path) | path.append(os.path.join(devpack, 'usr', 'bin')) if 'PATH' in os.environ: path.append(os.environ.get('PATH')) os.environ['PATH'] = os.pathsep.join(path) | def _configureModules(): if os.name.startswith('win'): # if CSPDEVPACK is defined in the environment, add the devpack bin # directory to the execution path. this ensures that devpack libraries # will be found before other (potentially incompatible) versions of the # same libraries. note that windows is currently the ... |
if not os.path.exists('../Data/Input'): return output = '../Data/Input/%s.hid' % hid_file | input_path = os.path.join('..', 'Data', 'Input') if not os.path.exists(input_path): return output = os.path.join(input_path, '%s.hid' % hid_file) | def ensureDefaultHID(hid_file): """ Verify that the specified hid input definition exists. If not, generate it from from the example input maps in ../Tools/HID/Examples """ if not os.path.exists('../Data/Input'): return output = '../Data/Input/%s.hid' % hid_file if not os.path.exists(output): os.system('../Tools/HID/c... |
os.system('../Tools/HID/cspinput -I../Tools/HID -o%s ../Tools/HID/Examples/%s.map' % (output, hid_file)) | tool_path = os.path.join('..', 'Tools', 'HID') csp_input = os.path.join(tool_path, 'cspinput') example = os.path.join(tool_path, 'Examples', '%s.map' % hid_file) os.system('%s -I%s -o%s %s' % (csp_input, tool_path, output, example)) | def ensureDefaultHID(hid_file): """ Verify that the specified hid input definition exists. If not, generate it from from the example input maps in ../Tools/HID/Examples """ if not os.path.exists('../Data/Input'): return output = '../Data/Input/%s.hid' % hid_file if not os.path.exists(output): os.system('../Tools/HID/c... |
if not files: files = [] st = os.popen('svn st %s' % ' '.join(files)).readlines() | def svn_st(files=None): if not files: files = [] st = os.popen('svn st %s' % ' '.join(files)).readlines() root = svn_root() files = [] for line in st: path = line[1:].strip() abspath = os.path.abspath(path) assert(abspath.startswith(root)) relpath = abspath[len(root):] if os.path.isabs(relpath): relpath = relpath[1:] b... | |
sys.setdlopenflags(dl.RTLD_GLOBAL|dl.RTLD_LAZY) except ImportError: sys.stderr.write('import dl failed; lazy module loading not enabled.\n') | sys.setdlopenflags(GLOBAL_AND_LAZY) except: sys.stderr.write('warning: setdlopenflags failed; lazy module loading not enabled.\n') | def _configureModules(): if os.name == 'posix': try: import dl # enable lazy loading of shared library modules if available. sys.setdlopenflags(dl.RTLD_GLOBAL|dl.RTLD_LAZY) except ImportError: sys.stderr.write('import dl failed; lazy module loading not enabled.\n') else: # if CSPDEVPACK is defined in the environment, a... |
cxx_file = env['BUILDERS']['CXXFile'] | _, cxx_file = SCons.Tool.createCFileBuilders(env) | def AddNet(env): cxx_file = env['BUILDERS']['CXXFile'] cxx_file.add_emitter('.net', EmitNet) cxx_file.add_action('.net', '$TRC') trc = env.File('#/SimData/Tools/TaggedRecordCompiler/trc.py') env['TRC'] = '%s --source=${TARGETS[0]} --header=${TARGETS[1]} $SOURCES' % trc |
script = GetCurrentScript() | def CustomizeForPlatform(env, settings): if hasattr(settings, '__bases__'): settings = settings() script = GetCurrentScript() platform = sys.platform.lower() configs = [] customizations = [] for item in dir(settings): if item.startswith('config_'): configs.append((item[len('config_'):], getattr(settings, item))) elif ... | |
bdeps += self._bdeps | bdeps.extend(self._bdeps) | def _addSettings(self, settings, bdeps): self._makeObjects() settings.merge(self._settings) bdeps += self._bdeps |
objects += self._objects | objects.extend(self._objects) | def add(self, objects, settings, bdeps): self._makeObjects() objects += self._objects self._addSettings(settings, bdeps) |
print __doc__ % {'prog': app.programName()} | app.usage() | def help(self): print __doc__ % {'prog': app.programName()} print 'Available commands:' commands = {} for command in Command.Index.values(): primary = command._keys[0] commands[primary] = command primaries = commands.keys() primaries.sort() for primary in primaries: command = commands[primary] subcommand = primary prin... |
v = map(int, re.search(r'[0-9.]+$').group().split('.')) | v = map(int, re.search(r'[0-9.]+$', path).group().split('.')) | def _Find(): if DevpackConfig.DEVPACK: return path = os.environ.get('CSPDEVPACK', '') if not path: print 'CSPDEVPACK environment variable not set.' sys.exit(1) try: v = map(int, re.search(r'[0-9.]+$').group().split('.')) except Exception: print 'CSPDEVPACK environment variable (%s) is does not look like a valid devpack... |
cmd = env.subst('$SWIG -MM $_CPPINCFLAGS %s' % str(node)) | cmd = env.subst('$SWIG $SWIGFLAGS $SWIGINCLUDES -MM %s' % str(node)) | def SwigScanner(node, env, path, arg=None): cmd = env.subst('$SWIG -MM $_CPPINCFLAGS %s' % str(node)) stdin, stdout, stderr = os.popen3(cmd, 't') deps = ''.join(map(lambda x: x.strip(), stdout.readlines())) deps = map(lambda x: "#/"+x.strip(), deps.split('\\'))[1:] return deps |
shlib = self._env.SharedLibrary(self._target, objects, **settings) | settings.apply(self._env); shlib = self._env.SharedLibrary(self._target, objects) | def build(self): if self._output: return self._output objects = [] settings = Settings() self._findSources() bdeps = [] for group in self._groups: group.add(objects, settings, bdeps) bdeps = Flatten(bdeps) objects = Flatten(objects) settings.merge(self._options) shlib = self._env.SharedLibrary(self._target, objects, **... |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = SimData.Real() self._element.parseXML(self._c) |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = SimData.ECEF() self._element.parseXML(self._c) |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = SimData.LLA() self._element.parseXML(self._c) |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = SimData.UTM() self._element.parseXML(self._c) |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = SimData.Vector3() self._element.parseXML(self._c) |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = SimData.Matrix3() self._element.parseXML(self._c) |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = SimData.Quaternion() self._element.parseXML(self._c) |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = SimData.SimDate() self._element.parseXML(self._c) |
ext.setSource(self._element) | ext.setSource(self._element.encode('ascii')) | def assign(self, interface, obj, name): ext = SimData.External() ext.setSource(self._element) interface.set(obj, name, ext) |
self._element.parseXML(self._c) | self._element.parseXML(self._c.encode('ascii')) | def end(self): self._element = self._object self.checkAssigned() self._element.parseXML(self._c) self._element.convertXML() |
print "In source file \"%s\" [line %d, col %d]" % (path, line, column), | if column is None: print "In source file \"%s\" [line %d]" % (path, line), else: print "In source file \"%s\" [line %d, col %d]" % (path, line, column), | def loadPath(self, path, id): if not os.path.exists(path): path = path + '.xml' if not os.path.exists(path): path = path + '.gz' if not os.path.exists(path): raise IOError, "Unable to find data for %s" % id if self._cache and not self._cache.isNewer(path): obj = self._cache.getObject(id) if obj is not None: return obj ... |
type, value, traceback = sys.exc_info() | type_, value, traceback = sys.exc_info() | def loadPath(self, path, id): if not os.path.exists(path): path = path + '.xml' if not os.path.exists(path): path = path + '.gz' if not os.path.exists(path): raise IOError, "Unable to find data for %s" % id if self._cache and not self._cache.isNewer(path): obj = self._cache.getObject(id) if obj is not None: return obj ... |
print >>log, "%s[%d:%d] - %s, %s" % (path, line, column, public, system) print_exception(type, value, traceback, file=open("error.log", "wt")) | if column is None: print >>log, "%s[%d] - %s, %s" % (path, line, public, system) else: print >>log, "%s[%d:%d] - %s, %s" % (path, line, column, public, system) print_exception(type_, value, traceback, file=open("error.log", "wt")) | def loadPath(self, path, id): if not os.path.exists(path): path = path + '.xml' if not os.path.exists(path): path = path + '.gz' if not os.path.exists(path): raise IOError, "Unable to find data for %s" % id if self._cache and not self._cache.isNewer(path): obj = self._cache.getObject(id) if obj is not None: return obj ... |
re_line = re.compile(r'^(\w*:?:?\w+)(\[\])?\s+(\w*)\s*((?:\s+\w+\s*=\s*\w+)*)\s*({|})?$') | re_line = re.compile(r'^(\w*:?:?\w+)(\[\])?\s+(\w*)\s*((?:\s+\w+\s*=\s*[a-zA-Z0-9_:]+)*)\s*({|})?$') | #ifndef __%(module_guard)s_TRF_H__ |
self.__bindManifest(shlib) | self._bindManifest(shlib) | def build(self): if self._output: return self._output objects = [] settings = Settings() self._findSources() bdeps = [] for group in self._groups: group.add(objects, settings, bdeps) bdeps = Flatten(bdeps) objects = Flatten(objects) settings.merge(self._options) shlib = self._env.SharedLibrary(self._target, objects, **... |
'dist_dir': DIST_DIR | 'dist_dir': DIST_DIR, 'packages': ['encodings'], | def make_demo(version): TEMPLATE = 'template' DEMO = 'cspsim-demo-%s' % version if not os.path.exists(TEMPLATE): error('%s not found!' % TEMPLATE) if os.path.exists(DEMO): error('%s already exists! Aborting.' % DEMO) print 'Copying data from %s to %s' % (TEMPLATE, DEMO) copy_tree(TEMPLATE, DEMO, exclude=r'^\.svn$')... |
self.assertEqual(x0.getMean(), y0.getMean()) self.assertEqual(x0.getSigma(), y0.getSigma()) | self.assertEqual(x0.mean(), y0.mean()) self.assertEqual(x0.sigma(), y0.sigma()) | def testReal(self): """Test storage and retrieval of Real""" x0 = SimData.Real(10.0, 1.0) y0 = SimData.Real(10.0, 1.0) self.archive._Real(x0) self.assertEqual(x0.getMean(), y0.getMean()) self.assertEqual(x0.getSigma(), y0.getSigma()) self.setRead() self.assertEqual(self.size, 8) x1 = self.archive._Real() self.assertEqu... |
self.assertEqual(x0.getMean(), x1.getMean()) self.assertEqual(x0.getSigma(), x1.getSigma()) v = x1.getValue() | self.assertEqual(x0.mean(), x1.mean()) self.assertEqual(x0.sigma(), x1.sigma()) v = x1.value() | def testReal(self): """Test storage and retrieval of Real""" x0 = SimData.Real(10.0, 1.0) y0 = SimData.Real(10.0, 1.0) self.archive._Real(x0) self.assertEqual(x0.getMean(), y0.getMean()) self.assertEqual(x0.getSigma(), y0.getSigma()) self.setRead() self.assertEqual(self.size, 8) x1 = self.archive._Real() self.assertEqu... |
if len(self.current) > len(ybreaks): raise "fubar table" if len(self.current) == len(ybreaks): | if len(self.current) > len(xbreaks): raise "fubar table" if len(self.current) == len(xbreaks): | def process(self, data, line): xbreaks = getattr(data, self.xbreaks) ybreaks = getattr(data, self.ybreaks) self.current += map(float, line.split()) if len(self.current) > len(ybreaks): raise "fubar table" if len(self.current) == len(ybreaks): self.current = map(lambda x, s=self.scale: x*s, self.current) self.table.appe... |
if len(self.table) == len(xbreaks): | if len(self.table) == len(ybreaks): | def process(self, data, line): xbreaks = getattr(data, self.xbreaks) ybreaks = getattr(data, self.ybreaks) self.current += map(float, line.split()) if len(self.current) > len(ybreaks): raise "fubar table" if len(self.current) == len(ybreaks): self.current = map(lambda x, s=self.scale: x*s, self.current) self.table.appe... |
htable("c_l", "aero_mach_breaks", "aero_alpha_breaks"), | htable("c_l", "aero_alpha_breaks", "aero_mach_breaks"), | def process(self, data, line): xbreaks = getattr(data, self.xbreaks) ybreaks = getattr(data, self.ybreaks) self.current += map(float, line.split()) if len(self.current) > len(ybreaks): raise "fubar table" if len(self.current) == len(ybreaks): self.current = map(lambda x, s=self.scale: x*s, self.current) self.table.appe... |
htable("c_d", "aero_mach_breaks", "aero_alpha_breaks"), | htable("c_d", "aero_alpha_breaks", "aero_mach_breaks"), | def process(self, data, line): xbreaks = getattr(data, self.xbreaks) ybreaks = getattr(data, self.ybreaks) self.current += map(float, line.split()) if len(self.current) > len(ybreaks): raise "fubar table" if len(self.current) == len(ybreaks): self.current = map(lambda x, s=self.scale: x*s, self.current) self.table.appe... |
htable("c_y", "aero_mach_breaks", "aero_alpha_breaks"), | htable("c_y", "aero_alpha_breaks", "aero_mach_breaks"), | def process(self, data, line): xbreaks = getattr(data, self.xbreaks) ybreaks = getattr(data, self.ybreaks) self.current += map(float, line.split()) if len(self.current) > len(ybreaks): raise "fubar table" if len(self.current) == len(ybreaks): self.current = map(lambda x, s=self.scale: x*s, self.current) self.table.appe... |
htable("idle_thrust", "thrust_altitude_breaks", "thrust_mach_breaks", 0.4545), htable("mil_thrust", "thrust_altitude_breaks", "thrust_mach_breaks", 0.4545), htable("ab_thrust", "thrust_altitude_breaks", "thrust_mach_breaks", 0.4545), | htable("idle_thrust", "thrust_mach_breaks", "thrust_altitude_breaks", 4.545), htable("mil_thrust", "thrust_mach_breaks", "thrust_altitude_breaks", 4.545), htable("ab_thrust", "thrust_mach_breaks", "thrust_altitude_breaks", 4.545), | def process(self, data, line): xbreaks = getattr(data, self.xbreaks) ybreaks = getattr(data, self.ybreaks) self.current += map(float, line.split()) if len(self.current) > len(ybreaks): raise "fubar table" if len(self.current) == len(ybreaks): self.current = map(lambda x, s=self.scale: x*s, self.current) self.table.appe... |
tabpr("</Value>") | tabpr("</Values>") | def table_xml(self, id, table, xspacing=1, yspacing=1, indent=0): tabpr = self.Tabpr(indent) tabpr("<Table name='%s'>" % id) tabpr.indent() tabpr("<XBreaks spacing='%s'>" % str(xspacing)) tabpr.indent() tabpr(*table.x) tabpr.indent(-1) tabpr("</XBreaks>") tabpr("<YBreaks spacing='%s'>" % str(yspacing)) tabpr.indent() t... |
self.table_xml("idle_thrust", self.data.idle_thrust, 1000.0, 0.1, 1) self.table_xml("mil_thrust", self.data.mil_thrust, 1000.0, 0.1, 1) self.table_xml("ab_thrust", self.data.ab_thrust, 1000.0, 0.1, 1) | self.table_xml("idle_thrust", self.data.idle_thrust, 0.1, 1000.0, 1) self.table_xml("mil_thrust", self.data.mil_thrust, 0.1, 1000.0, 1) self.table_xml("ab_thrust", self.data.ab_thrust, 0.1, 1000.0, 1) | def engine_xml(self): self.table_xml("idle_thrust", self.data.idle_thrust, 1000.0, 0.1, 1) self.table_xml("mil_thrust", self.data.mil_thrust, 1000.0, 0.1, 1) self.table_xml("ab_thrust", self.data.ab_thrust, 1000.0, 0.1, 1) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.