rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
print "__setattr__",name | print "__setattr__",name,value | def __setattr__(self, name, value): print "__setattr__",name return setattr(self.cppthing, name, value) |
m.learn(squirrel,sknowledge) | m.learn(squirrel,squirrel_goals) | #def dontrunme(): |
print "Slice.cut" | def cut_operation(self, op): """ Op handler for cut op which activates this task """ print "Slice.cut" | |
print "Slice.tick" | def tick_operation(self, op): """ Op handler for regular tick op """ print "Slice.tick" | |
print "Target is no more" | def tick_operation(self, op): """ Op handler for regular tick op """ print "Slice.tick" | |
print "Too far away" | def tick_operation(self, op): """ Op handler for regular tick op """ print "Slice.tick" | |
print "Not done yet" | def tick_operation(self, op): """ Op handler for regular tick op """ print "Slice.tick" | |
print "Nothing more to cut" | def tick_operation(self, op): """ Op handler for regular tick op """ print "Slice.tick" | |
slice_loc.bbox.near_point = Vector3D(0, slice_loc.bbox.near_point.y, slice_loc.bbox.near_point.z) slice_loc.bbox.far_point = Vector3D(self.width, slice_loc.bbox.far_point.y, slice_loc.bbox.far_point.z) | pos_offset = Vector3D(target.location.bbox.far_point.x, 0, 0) pos_offset.rotate(target.location.orientation) slice_loc.coordinates = target.location.coordinates + pos_offset slice_bbox = [0, target.location.bbox.near_point.y, target.location.bbox.near_point.z, self.width, target.location.bbox.far_point.y, target.loca... | def tick_operation(self, op): """ Op handler for regular tick op """ print "Slice.tick" |
create=Operation("create", Entity(name='wood',type='wood',location=slice_loc), to=target) | create=Operation("create", Entity(name='wood', type='wood', location=slice_loc, bbox=slice_bbox), to=target) | def tick_operation(self, op): """ Op handler for regular tick op """ print "Slice.tick" |
loc.coordinates = me_xyz + (dist_vect * multiply) | loc.coordinates = me.location.coordinates + (dist_vect * multiply) | def run(self, me): lst_of_what = me.mem.recall_place(me.location,self.range,self.what) if lst_of_what==[]: return dist_vect=distance_to(me.location,lst_of_what[0].location).unit_vector() multiply = const.base_velocity * self.direction loc = Location(me.location.parent) loc.coordinates = me_xyz + (dist_vect * multiply)... |
m.make('house3',type='house3',xyz=(150,142,22),orientation=directions[2]) m.make('house3',type='house3',xyz=(158,142,22),orientation=directions[5]) | m.make('house3',type='house3',xyz=(150,125,22),orientation=directions[2]) m.make('house3',type='house3',xyz=(171,142,22),orientation=directions[5]) | def default(mapeditor): |
xbase = uniform(12,20) ybase = uniform(12,20) | xbase = uniform(140,160) ybase = uniform(130,150) | def default(mapeditor): |
xyz=butcher_stall_xyz,age=probability.fertility_age,sex='male') | xyz=butcher_xyz,age=probability.fertility_age,sex='male') | #def dontrunme(): |
stall=m.make('Market Stall',type='stall',xyz=(17,26,settlement_height)) m.make('wall',type='wall',parent=stall.id,xyz=(0,0,0),bbox=(-0.5,-1.5,0,0.5,1.5,0.8)) m.make('wall',type='wall',parent=stall.id,xyz=(2,0,0),bbox=(0,-1.5,0,0.5,1.5,2)) | #def dontrunme(): | |
print "Got unseen op for ", obsolete_id | def unseen_operation(self, op): obsolete_id = op[0].id print "Got unseen op for ", obsolete_id self.map.delete(obsolete_id) | |
print deb | def check_goal(self, me, time): "executes goal, see top of file" if self.debug: log.thinking("GOAL desc: "+self.str) res,deb=self.check_goal_rec(me,time,0) if len(deb)!=0: deb=self.info()+"."+deb print deb if res!=None: info_ent=Entity(op=res,description=deb) return res+Operation("goal_info",info_ent) | |
set_kw(self,kw,"fruitname","seed") set_kw(self,kw,"fruitchance",fruitchance) def tick_operation(self, op): if debug_tree: print "I this big ", self.height print `self`,"Got tick operation:" opTick=Operation("tick",to=self) opTick.time.sadd=const.basic_tick*speed result = atlas.Message(opTick) fcount = self.fruits... | def __init__(self, cppthing, **kw): self.base_init(cppthing, kw) # The default height set_kw(self,kw,"height",10) | |
loc.bbox = Vector3D(13,0.5,5) | loc.bbox = Vector3D(12,0.5,5) | def setup_operation(self, op): ret = Message() # South wall |
else: print "Too much for me" | def do(self,me): thing_all=me.map.find_by_type(self.what) nearest=None neardist=self.range for thing in thing_all: distance = me.get_xyz().distance(thing.get_xyz()) if distance < neardist and thing.location.parent.id==me.location.parent.id: if self.condition(thing): nearest = thing neardist = distance else: print "Too ... | |
rotation = rotation * target.location.orientation | rotation = target.location.orientation * rotation | def tick_operation(self, op): """ Op handler for regular tick op """ print "Raise.tick" res=Message() |
m.set(world.id, terrain={'points' : points}, name="moraf", bbox=[minx, miny, minz, maxx, maxy, maxz]) | m.set(world.id, terrain={'points' : points}, name="moraf", bbox=[minx * 64, miny * 64, minz, maxx * 64, maxy * 64, maxz]) | def default(mapeditor): |
m.set(world.id, terrain={'points' : points}) | minx=0 miny=0 minz=0 maxx=0 maxy=0 maxz=0 for i in points.values(): x = i[0] y = i[1] z = i[2] if not minx or x < minx: minx = x if not miny or y < miny: miny = y if not minz or z < minz: minz = z if not maxx or x > maxx: maxx = x if not maxy or y > maxy: maxy = y if not maxz or z > maxz: maxz = z m.set(world.id, terr... | def modify_terrain(mapeditor): |
def __init__(self, place={}, location={}, goal={}, importance={}): self.place=place self.location=location self.goal=goal self.importance=importance | def __init__(self): self.place={} self.location={} self.goal={} self.importance={} | def __init__(self, place={}, location={}, goal={}, importance={}): self.place=place self.location=location self.goal=goal self.importance=importance |
return Operation("NYI",Entity(description=self.desc)) | return | def not_yet_implemented(self, me): #CHEAT! (make it so that it asks other people for knowledge) return Operation("NYI",Entity(description=self.desc)) |
warrior=m.make('Vonaa Barile',type='mercenary',xyz=(uniform(12,20),uniform(812,20),settlement_height),sex='female',orientation=directions[randint(0,7)]) | warrior=m.make('Vonaa Barile',type='mercenary',xyz=(uniform(12,20),uniform(12,20),settlement_height),sex='female',orientation=directions[randint(0,7)]) | #def dontrunme(): |
if i==5 or i==5: | if i==5 or j==5: | def modify_terrain(mapeditor): |
res.append(attacker.mind2body(self.face(attacker, defender))) | faceop=self.face(attacker, defender) if faceop: res.append(attacker.mind2body(faceop)) | def tick_operation(self, op): """ This method is called repeatedly, each time a combat turn occurs. In this example the interval is fixed, but it can be varied. self.attacker is the ID of the character that initiated the combat self.defender is the ID of the character that was initially attacked The self.attack flag is... |
if not target.location.parent: self.irrelevant() return | def tick_operation(self, op): """ Op handler for regular tick op """ # print "Raise.tick" | |
print "Got attack" | self.attack=True | def attack_operation(self, op): print "Got attack" defender = op.to if defender != self.character.id: print "Attach operation is wierd" if defender not in self.defenders: print "New defender" self.defenders.append(defender) print "Attacker", op[0].id attacker = op[0].id if attacker not in self.attackers: print "New att... |
print "Attach operation is wierd" if defender not in self.defenders: print "New defender" self.defenders.append(defender) print "Attacker", op[0].id attacker = op[0].id if attacker not in self.attackers: print "New attacker" self.attackers.append(attacker) | print "Attack operation is wierd" self.defender=defender attacker = op.from_ self.attacker=attacker a=self.character.world.get_object(self.attacker) if a: a.set_task(self.cppthing) else: self.irrelevant() return | def attack_operation(self, op): print "Got attack" defender = op.to if defender != self.character.id: print "Attach operation is wierd" if defender not in self.defenders: print "New defender" self.defenders.append(defender) print "Attacker", op[0].id attacker = op[0].id if attacker not in self.attackers: print "New att... |
def __init__(self, members=[] desc="move in herds with other animals like me"): | def __init__(self, members=[], desc="move in herds with other animals like me"): | def __init__(self, members=[] desc="move in herds with other animals like me"): DynamicGoal.__init__(self, trigger="sight_move", desc=desc) for m in members: self.herd_members[m] = 51 self.herd_members={} |
m.make('tent',type='tent',xyz=(-1,8,village_height)) | m.make('tent',type='tent',xyz=(-1,8,village_height),bbox=[2.5,2.5,3]) | def default(mapeditor): |
sty=m.make('sty',type='sty',xyz=pig_sty_xyz,status=1.0,bbox=[2.5,2.5,1]) | sty=m.make('sty',type='sty',xyz=pig_sty_xyz,status=1.0,bbox=[2.5,2.5,3]) | def default(mapeditor): |
t = [unittest.makeSuite(makeTests(os.path.join(path, arch))) for arch in sorted(os.listdir(path))] | t = [unittest.makeSuite(makeTests(os.path.join(path, arch))) for arch in sorted(os.listdir(path)) if not (arch == '.svn' and os.path.isdir(arch))] | def testdir(path): """Generate and run a set of tests for the given directory full of archives.""" path = os.path.abspath(path) print 'Testing directory "%s" ...' % os.path.split(path)[1] t = [unittest.makeSuite(makeTests(os.path.join(path, arch))) for arch in sorted(os.listdir(path))] dirSuite = unittest.TestSuite(t)... |
"""Converts a number to a sexagesimal string with 1-3 fields. | """Convert a number to a sexagesimal string with 1-3 fields. | def dmsStrFromDeg (decDeg, nFields=3, precision=1, omitExtraFields = False): """Converts a number to a sexagesimal string with 1-3 fields. Inputs: decDeg: value in decimal degrees or hours nFields: number of fields; <=1 for dddd.ddd, 2 for dddd:mm.mmm, >=3 for dddd:mm:ss.sss precision: number of digits after the decim... |
decDeg: value in decimal degrees or hours nFields: number of fields; <=1 for dddd.ddd, 2 for dddd:mm.mmm, >=3 for dddd:mm:ss.sss precision: number of digits after the decimal point in the last field """ if precision > 0: minFloatWidth = precision + 3 else: minFloatWidth = 2 if decDeg < 0: signStr = "-" decDeg = abs(d... | - decDeg: value in decimal degrees or hours - nFields: number of fields; <=1 for dddd.ddd, 2 for dddd:mm.mmm, >=3 for dddd:mm:ss.sss - precision: number of digits after the decimal point in the last field; if 0, no decimal point is printed; must be >= 0 - omitExtraFields: omit fields that are zero, starting from the ri... | def dmsStrFromDeg (decDeg, nFields=3, precision=1, omitExtraFields = False): """Converts a number to a sexagesimal string with 1-3 fields. Inputs: decDeg: value in decimal degrees or hours nFields: number of fields; <=1 for dddd.ddd, 2 for dddd:mm.mmm, >=3 for dddd:mm:ss.sss precision: number of digits after the decim... |
"""Converts a number, in seconds, to a sexagesimal string. Unlike dmsStrFromDeg, nFields is counted right to left. | """Convert a number, in seconds, to a sexagesimal string. Similar to dmsStrFromDeg, but takes seconds, not degrees, and omitExtraFields omits fields from the left, not the right. | def dmsStrFromSec (decSec, nFields=3, precision=1, omitExtraFields = True): """Converts a number, in seconds, to a sexagesimal string. Unlike dmsStrFromDeg, nFields is counted right to left. Inputs: decSec: value in decimal seconds or arc seconds nFields: number of fields; <=1 for ss.sss, 2 for mm:ss.ss, >=3 for dddd:... |
decSec: value in decimal seconds or arc seconds nFields: number of fields; <=1 for ss.sss, 2 for mm:ss.ss, >=3 for dddd:mm:ss.sss precision: number of digits after the decimal point in the seconds field omitExtraFields: omit fields that are zero, starting from the left. """ | - decSec: value in decimal seconds or arc seconds - nFields: number of fields; <=1 for ss.sss, 2 for mm:ss.ss, >= 3 for dddd:mm:ss.sss - precision: number of digits after the decimal point in the seconds field; if 0, no decimal point is printed; must be >= 0 - omitExtraFields: omit fields that are zero, starting from t... | def dmsStrFromSec (decSec, nFields=3, precision=1, omitExtraFields = True): """Converts a number, in seconds, to a sexagesimal string. Unlike dmsStrFromDeg, nFields is counted right to left. Inputs: decSec: value in decimal seconds or arc seconds nFields: number of fields; <=1 for ss.sss, 2 for mm:ss.ss, >=3 for dddd:... |
if decDeg < 0: signStr = "-" decDeg = abs(decDeg) else: signStr = "" decDeg = float ("%.*f" % (precision, decDeg * 3600.0)) / 3600.0 (numDeg, frac) = divmod (abs(decDeg), 1.0) (numMin, frac) = divmod (frac * 60.0, 1.0) numSec = frac * 60.0 if precision > 0: minFloatWidth = precision + 3 else: minFloatWidth = 2 if ... | signStr, fieldStrs = _getDMSFields(decDeg, nFields, precision) if omitExtraFields: while fieldStrs and float(fieldStrs[0]) == 0.0: fieldStrs.pop(0) return signStr + ":".join(fieldStrs) | def dmsStrFromSec (decSec, nFields=3, precision=1, omitExtraFields = True): """Converts a number, in seconds, to a sexagesimal string. Unlike dmsStrFromDeg, nFields is counted right to left. Inputs: decSec: value in decimal seconds or arc seconds nFields: number of fields; <=1 for ss.sss, 2 for mm:ss.ss, >=3 for dddd:... |
"""Converts a string of the basic form dd[:mm[:ss]] to decimal degrees. | """Convert a string of the basic form dd[:mm[:ss]] to decimal degrees. | def degFromDMSStr (dmsStr): """Converts a string of the basic form dd[:mm[:ss]] to decimal degrees. See splitDMSStr for details of the format. error conditions: raises ValueError if the string cannot be parsed """ dmsItems = splitDMSStr(dmsStr) # extract sign if dmsItems[0] == '-': signMult = -1.0 else: signMult = 1.... |
error conditions: raises ValueError if the string cannot be parsed | Error conditions: - Raises ValueError if the string cannot be parsed | def degFromDMSStr (dmsStr): """Converts a string of the basic form dd[:mm[:ss]] to decimal degrees. See splitDMSStr for details of the format. error conditions: raises ValueError if the string cannot be parsed """ dmsItems = splitDMSStr(dmsStr) # extract sign if dmsItems[0] == '-': signMult = -1.0 else: signMult = 1.... |
"""Converts a string of the basic form [[dd:]mm:]ss to decimal degrees. | """Convert a string of the basic form [[dd:]mm:]ss to decimal degrees. | def secFromDMSStr (dmsStr): """Converts a string of the basic form [[dd:]mm:]ss to decimal degrees. Note that missing fields are handled differently than degFromDMSStr! See splitDMSStr for details of the format. error conditions: raises ValueError if the string cannot be parsed """ dmsItems = splitDMSStr(dmsStr) # ex... |
"""Converts a string of the basic form [[dd:]mm:]ss to decimal seconds | """Convert a string of the basic form [[dd:]mm:]ss to decimal seconds | def secStrFromDMSStr(dmsStr): """Converts a string of the basic form [[dd:]mm:]ss to decimal seconds preserving the original accuracy of seconds Note that missing fields are handled differently than degFromDMSStr! See splitDMSStr for details of the format. error conditions: raises ValueError if the string cannot be pa... |
"""Verifies a sexagesimal string; returns 1 if valid, 0 if not | """Verify a sexagesimal string; returns True if valid, False if not | def checkDMSStr(dmsStr): """Verifies a sexagesimal string; returns 1 if valid, 0 if not """ try: splitDMSStr(dmsStr) return 1 except: return 0 |
return 1 | return True | def checkDMSStr(dmsStr): """Verifies a sexagesimal string; returns 1 if valid, 0 if not """ try: splitDMSStr(dmsStr) return 1 except: return 0 |
return 0 | return False | def checkDMSStr(dmsStr): """Verifies a sexagesimal string; returns 1 if valid, 0 if not """ try: splitDMSStr(dmsStr) return 1 except: return 0 |
"""Returns the following information about a sexagesimal string: | """Return the following information about a sexagesimal string: | def dmsStrFieldsPrec(dmsStr): """Returns the following information about a sexagesimal string: - the number of colon-separated fields - the precision of the right-most field """ if dmsStr == "": return (0, 0) precArry = dmsStr.split(".") if len(precArry) > 1: precision = len(precArry[1]) else: precision = 0 nFields = ... |
"""Finds the starting and ending index of the number | """Find the starting and ending index of the number | def findLeftNumber(astr, ind): """Finds the starting and ending index of the number enclosing or to the left of index "ind". Returns (None, None) if no number found. Warning: this is not a sophisticated routine. It looks for the a run of characters that could be present in a floating point number. It does not sanity c... |
Returns (None, None) if no number found. | Return (None, None) if no number found. | def findLeftNumber(astr, ind): """Finds the starting and ending index of the number enclosing or to the left of index "ind". Returns (None, None) if no number found. Warning: this is not a sophisticated routine. It looks for the a run of characters that could be present in a floating point number. It does not sanity c... |
"""Finds the starting and ending index of the number | """Find the starting and ending index of the number | def findRightNumber(astr, ind): """Finds the starting and ending index of the number enclosing or to the right of index "ind". Returns (None, None) if no number found. Warning: this is not a sophisticated routine. It looks for the a run of characters that could be present in a floating point number. It does not sanity... |
"""Finds the index of the first character of the number | """Find the index of the first character of the number | def _findLeftOfLeftNumber(astr, ind): """Finds the index of the first character of the number enclosing or to the left of index "ind". Returns None if no number found. Warning: this is not a sophisticated routine. It looks for the left-most of a run of characters that could be present in a floating point number. It do... |
"""Finds the index of the last character of the number | """Find the index of the last character of the number | def _findRightOfRightNumber(astr, ind): """Finds the index of the last character of the number enclosing or to the right of index "ind". Returns None if no number found. Warning: this is not a sophisticated routine. It looks for the right-most of a run of characters that could be present in a floating point number. It... |
"""Converts a sexagesimal string to a neater version. | """Convert a sexagesimal string to a neater version. | def neatenDMSStr (dmsStr): """Converts a sexagesimal string to a neater version. error conditions: raises ValueError if the string cannot be parsed """ if dmsStr == "": return "" precArry = dmsStr.split(".") if len(precArry) > 1: precision = len(precArry[1]) else: precision = 0 fieldArry = dmsStr.split(":") nFields =... |
"""Returns singStr or plStr depending if num == 1 or not. | """Return singStr or plStr depending if num == 1 or not. | def plural(num, singStr, plStr): """Returns singStr or plStr depending if num == 1 or not. A minor convenience for formatting messages (in lieu of ?: notation) """ if num == 1: return singStr return plStr |
"""Formats a dictionary in a nice way | """Format a dictionary in a nice way | def prettyDict(aDict, entrySepStr = "\n", keyValSepStr = ": "): """Formats a dictionary in a nice way Inputs: aDict: the dictionary to pretty-print entrySepStr: string separating each dictionary entry keyValSepStr: string separating key and value for each entry Returns a string containing the pretty-printed dictionar... |
"""splits a sexagesimal string into fields | """Split a sexagesimal string into fields | def splitDMSStr (dmsStr): """splits a sexagesimal string into fields returns one of the following lists: [sign, int deg, frac deg] [sign, int deg, int min, frac min] [sign, int deg, int min, int sec, frac sec] where: all values are strings sign is one of ('', '+' or '-') frac <whatever> includes a leading decimal point... |
"""converts a string representation of a number to a float; | """Convert a string representation of a number to a float; | def floatFromStr(astr, allowExp=1): """converts a string representation of a number to a float; unlike float(), partial representations (such as "", "-", "-.e") are taken as 0 and "nan" is forbidden. error conditions: raises ValueError if astr cannot be converted """ if allowExp: match = _FloatRE.match(astr) else: mat... |
"""converts a string representation of a number to an integer; | """Convert a string representation of a number to an integer; | def intFromStr(astr): """converts a string representation of a number to an integer; unlike int(), the blank string and "+" and "-" are treated as 0 error conditions: raises ValueError if astr cannot be converted """ if _IntRE.match(astr) == None: raise ValueError, "cannot convert :%s: to an integer" % (astr) try: re... |
"""Escapes all instances of quoteChar and escChar in astr | """Escape all instances of quoteChar and escChar in astr | def quoteStr(astr, escChar = '\\', quoteChar = '"'): """Escapes all instances of quoteChar and escChar in astr with a preceding escChar and surrounds the result with quoteChar. Examples: astr = 'foo" \bar' quoteStr(astr) = '"foo\" \\bar"' quoteStr(astr, escChar = '"') = '"foo"" \bar"' This prepares a string for outpu... |
['::', '', 1, ['', '', '', '', ''], 0.0, 0.0, '0:00:00', ['0:00:00', '0:00:00.0', '0:00:00.00']], ['-::', '', 1, ['-', '', '', '', ''], -0.0, -0.0, '0:00:00', ['0:00:00', '0:00:00.0', '0:00:00.00']], ['-0:00:00.01', '', 1, ['-', '0', '00', '00', '.01'], -2.77777777778e-06, -0.01, '-0:00:00.01', ['-0:00:00', '-0:00:00.0... | ['::', '', True, ['' , '', '', '', ''], 0.0, 0.0, '0:00:00', ['0:00:00', '0:00:00.0', '0:00:00.00']], ['-::', '', True, ['-', '', '', '', ''], -0.0, -0.0, '0:00:00', ['0:00:00', '0:00:00.0', '0:00:00.00']], ['-0:00:00.01', '', True, ['-', '0', '00', '00', '.01'], -2.7777777777777775e-06, -0.01, '-0:00:00.01', ['-0:00:0... | def _assertTest(): """Runs a test by comparing results to those expected and only failing if something is wrong. """ testSet = ( ['::', '', 1, ['', '', '', '', ''], 0.0, 0.0, '0:00:00', ['0:00:00', '0:00:00.0', '0:00:00.00']], ['-::', '', 1, ['-', '', '', '', ''], -0.0, -0.0, '0:00:00', ['0:00:00', '0:00:00.0', '0:00:0... |
"""Prints the results of running each routine on a set of test data. Data format is a list of tuples, each containing three elements: dmsStr to test, a comment, and isOK (true if the dmsStr is valid, false if not) | """Print the results of running each routine on a set of test data. Data format is a list of tuples, each containing two elements: dmsStr to test, a comment | def _printTest(dmsSet = None): """Prints the results of running each routine on a set of test data. Data format is a list of tuples, each containing three elements: dmsStr to test, a comment, and isOK (true if the dmsStr is valid, false if not) The output is in the format used by _assertTest, but please use this with ... |
("-2.999998639", ""), ("-2.999998583", ""), ("-2.999986139", ""), ("-2.999986083", ""), ("-2.999861139", ""), ("-2.999861083", ""), ("-123::", ""), ("-123:4", ""), ("-123:45", ""), ("-123:4.56789", ""), ("-123:45.6789", ""), ("1:2:", ""), ("1:2:3", ""), ("1:2:3.456789", ""), ("1:23:4", ""), ("1:23:45", ""), ("123:45:6.... | ('-1.2345', ''), ('-123::', ''), ('-123:4', 'make sure seconds field is not 60 from dmsStrFromDeg'), ('-123:45', ''), ('-123:4.56789', ''), ('-123:45.6789', ''), ('1:2:', ''), ('1:2:3', ''), ('1:2:3.456789', ''), ('1:23:4', ''), ('1:23:45', ''), ('123:45:6.789', ''), ('123:45:56.789', ''), ('-0::12.34', 'bug test; the ... | def _printTest(dmsSet = None): """Prints the results of running each routine on a set of test data. Data format is a list of tuples, each containing three elements: dmsStr to test, a comment, and isOK (true if the dmsStr is valid, false if not) The output is in the format used by _assertTest, but please use this with ... |
print "[%r, %r, 1, %r, %r, %r, %r, %r]," % (testStr, commentStr, itemList, deg, sec, neatStr, outDMSStr) | print "[%r, %r, True, %r, %r, %r, %r, %r]," % (testStr, commentStr, itemList, deg, sec, neatStr, outDMSStr) | def _printTest(dmsSet = None): """Prints the results of running each routine on a set of test data. Data format is a list of tuples, each containing three elements: dmsStr to test, a comment, and isOK (true if the dmsStr is valid, false if not) The output is in the format used by _assertTest, but please use this with ... |
print "[%r, %r, 0, %r, %r, %r, %r, %r]," % tuple([testStr, commentStr] + [None]*5) | print "[%r, %r, False, %r, %r, %r, %r, %r]," % tuple([testStr, commentStr] + [None]*5) | def _printTest(dmsSet = None): """Prints the results of running each routine on a set of test data. Data format is a list of tuples, each containing three elements: dmsStr to test, a comment, and isOK (true if the dmsStr is valid, false if not) The output is in the format used by _assertTest, but please use this with ... |
doPrint = 0 | doPrint = False | def _printTest(dmsSet = None): """Prints the results of running each routine on a set of test data. Data format is a list of tuples, each containing three elements: dmsStr to test, a comment, and isOK (true if the dmsStr is valid, false if not) The output is in the format used by _assertTest, but please use this with ... |
self.guideModeWdg.set(imObj.currGuideMode) self.guideModeWdg.setDefault(imObj.defGuideMode) | self.guideModeWdg.set(guideMode) self.guideModeWdg.setDefault(guideMode) | def updGuideMode(self, guideMode, isCurrent, keyVar): """New guideMode data found. """ #print "%s updGuideMode(guideMode=%r, isCurrent=%r)" % (self.actor, guideMode, isCurrent) self.setGuideState() if not isCurrent: return |
print "doScrollBarijInd=%r, scrollCmd=%r, scrollAmt=%r, c=%r)" % (ijInd, scrollCmd, scrollAmt, c) | def doScrollBar(self, ijInd, scrollCmd, scrollAmt=None, c=None): """Handle scroll bar events""" #print "doScrollBarijInd=%r, scrollCmd=%r, scrollAmt=%r, c=%r)" % (ijInd, scrollCmd, scrollAmt, c) if scrollAmt == None or self.dataArr == None: return sbWdg = (self.vsb, self.hsb)[ijInd] | |
print "currScroll=%r, newScroll=%r" % (currScroll, newScroll) | def doScrollBar(self, ijInd, scrollCmd, scrollAmt=None, c=None): """Handle scroll bar events""" #print "doScrollBarijInd=%r, scrollCmd=%r, scrollAmt=%r, c=%r)" % (ijInd, scrollCmd, scrollAmt, c) if scrollAmt == None or self.dataArr == None: return sbWdg = (self.vsb, self.hsb)[ijInd] | |
self._updImBounds() | self._updImBounds(updZoom=False) | def doScrollBar(self, ijInd, scrollCmd, scrollAmt=None, c=None): """Handle scroll bar events""" #print "doScrollBarijInd=%r, scrollCmd=%r, scrollAmt=%r, c=%r)" % (ijInd, scrollCmd, scrollAmt, c) if scrollAmt == None or self.dataArr == None: return sbWdg = (self.vsb, self.hsb)[ijInd] |
return (wdgVal.lower() == "on") | return str(int(wdgVal.lower() == "on")) | def lampValFmt(wdgVal): return (wdgVal.lower() == "on") |
cmdStr = "guide on imgFile=%r centerOn=%.2f,%.2f noGuide cradius=%.1f" % \ (self.dispImObj.imageName, pos[0], pos[1], rad) | cmdStr = "guide on imgFile=%r centerOn=%.2f,%.2f noGuide cradius=%.1f %s" % \ (self.dispImObj.imageName, pos[0], pos[1], rad, self.getExpArgStr()) | def doCenter(self, wdg=None): """Center up on the selected star. """ if not self.dispImObj: raise RuntimeError("No guide image") if not self.dispImObj.selDataColor: raise RuntimeError("No star selected") starData, color = self.dispImObj.selDataColor pos = starData[2:4] rad = starData[6] cmdStr = "guide on imgFile=%r c... |
cmdStr = "guide on imgFile=%r gstar=%.2f,%.2f cradius=%.1f" % \ (self.dispImObj.imageName, pos[0], pos[1], rad) | cmdStr = "guide on imgFile=%r gstar=%.2f,%.2f cradius=%.1f %s" % \ (self.dispImObj.imageName, pos[0], pos[1], rad, self.getExpArgStr() ) | def doGuideOn(self, wdg=None): """Guide on the selected star. """ if not self.dispImObj: raise RuntimeError("No guide image") if not self.dispImObj.selDataColor: raise RuntimeError("No star selected") starData, color = self.dispImObj.selDataColor pos = starData[2:4] rad = starData[6] cmdStr = "guide on imgFile=%r gsta... |
cmdStr = "guide on boresight" | cmdStr = "guide on boresight %s" % (self.getExpArgStr()) | def doGuideOnBoresight(self, wdg=None): """Guide on boresight. """ cmdStr = "guide on boresight" if not _LocalMode: cmdVar = RO.KeyVariable.CmdVar( actor = self.actor, cmdStr = cmdStr, ) self.statusBar.doCmd(cmdVar) else: print cmdStr |
self.dispImObj = imObj | def updFiles(self, fileData, isCurrent, keyVar): #print "%s updFiles(fileData=%r; isCurrent=%r)" % (self.actor, fileData, isCurrent) if not isCurrent: return cmdChar, isNew, baseDir, imageName, maskName = fileData[0:5] msgDict = keyVar.getMsgDict() cmdr = msgDict["cmdr"] cmdID = msgDict["cmdID"] imageName = baseDir + ... | |
isVisible = (self.dispImObj.imageName == imObj.imageName) | isVisible = (self.dispImObj and self.dispImObj.imageName == imObj.imageName) | def updStar(self, starData, isCurrent, keyVar): """New star data found. Overwrite existing findStars data if: - No existing data and cmdr, cmdID match - I generated the command else ignore. Replace existing centroid data if I generated the command, else ignore. """ #print "%s updStar(starData=%r, isCurrent=%r)" % (se... |
width = 300, height = 300, | def __init__(self, master, width = 300, height = 300, | |
gr = RO.Wdg.Gridder(self) | def __init__(self, master, width = 300, height = 300, | |
toolFrame = Tkinter.Frame(self, width = width, height = height, ) | toolFrame = Tkinter.Frame(self) | def __init__(self, master, width = 300, height = 300, |
gr.gridWdg(False, toolFrame, colSpan = 10, sticky="w") | toolFrame.pack(side="top", anchor="nw") posFrame = Tkinter.Frame(self) Tkinter.Label(posFrame, text="Position").pack(side="left") self.currPosWdg = RO.Wdg.StrLabel(posFrame) self.currPosWdg.pack(side="left") Tkinter.Label(posFrame, text="Value").pack(side="left") self.currValWdg = RO.Wdg.IntLabel(posFrame) self.currV... | def __init__(self, master, width = 300, height = 300, |
hsb = Tkinter.Scrollbar(self.scrollFrame, orient="horizontal") hsb.grid(row=1, column=0, sticky="ew") self._hscrollbar = hsb vsb = Tkinter.Scrollbar(self.scrollFrame, orient="vertical") vsb.grid(row=0, column=1, sticky="ns") | self.hsb = Tkinter.Scrollbar(self.scrollFrame, orient="horizontal") self.hsb.grid(row=1, column=0, sticky="ew") self._hscrollbar = self.hsb self.vsb = Tkinter.Scrollbar(self.scrollFrame, orient="vertical") self.vsb.grid(row=0, column=1, sticky="ns") | def __init__(self, master, width = 300, height = 300, |
xscrollcommand = hsb.set, yscrollcommand = vsb.set, | xscrollcommand = self.hsb.set, yscrollcommand = self.vsb.set, | def __init__(self, master, width = 300, height = 300, |
hsb["command"] = self.cnv.xview vsb["command"] = self.cnv.yview | self.hsb["command"] = self.cnv.xview self.vsb["command"] = self.cnv.yview | def __init__(self, master, width = 300, height = 300, |
gr.gridWdg(False, self.scrollFrame, colSpan=10, sticky="news") self.rowconfigure(1, weight=1) self.columnconfigure(9, weight=1) | self.scrollFrame.pack(side="top", expand=True, fill="both") | def __init__(self, master, width = 300, height = 300, |
self.currPosWdg = RO.Wdg.StrLabel(self) self.currValWdg = RO.Wdg.IntLabel(self) gr.gridWdg("Position", (self.currPosWdg, Tkinter.Label(self, text="Value"), self.currValWdg)) | def __init__(self, master, width = 300, height = 300, | |
self.setZoom(zoomFac) | self.setZoomFac(zoomFac) | def doZoomMenu(self, *args): """Handle new selection from zoom menu.""" strVal = self.zoomMenuWdg.getString() valueList = strVal.split("/") if len(valueList) > 1: zoomFac = float(valueList[0]) / float(valueList[1]) else: zoomFac = int(valueList[0]) self.setZoom(zoomFac) # enable or disable zoom in/out widgets as appro... |
def setZoom(self, zoomFac): | def setZoomFac(self, zoomFac): | def setZoom(self, zoomFac): """Set the zoom factor. 0.5 shows every other pixel, starting with the 2nd pixel 1 shows the image at original size 2 shows each pixel 2x as large as it should be etc. """ self.zoomFac = float(zoomFac) self.redisplay() |
imPos = self.imPosFromCnvPos((evt.x, evt.y)) | cnvPos = self.cnvPosFromEvt(evt) imPos = self.imPosFromCnvPos(cnvPos) | def _updCurrVal(self, evt): """Show the value that the mouse pointer is over. """ imPos = self.imPosFromCnvPos((evt.x, evt.y)) try: arrIJ = self.arrIJFromImPos(imPos) except IndexError: return print "evtxy=%s; ds9pos=%s; arrIJ=%s" % ((evt.x, evt.y), imPos, arrIJ) val = self.dataArr[arrIJ[0], arrIJ[1]] self.currPosWd... |
print "evtxy=%s; ds9pos=%s; arrIJ=%s" % ((evt.x, evt.y), imPos, arrIJ) | def _updCurrVal(self, evt): """Show the value that the mouse pointer is over. """ imPos = self.imPosFromCnvPos((evt.x, evt.y)) try: arrIJ = self.arrIJFromImPos(imPos) except IndexError: return print "evtxy=%s; ds9pos=%s; arrIJ=%s" % ((evt.x, evt.y), imPos, arrIJ) val = self.dataArr[arrIJ[0], arrIJ[1]] self.currPosWd... | |
arr = num.arange(256**2, shape=(256,256)) | arrSize = 255 arr = num.arange(arrSize**2, shape=(arrSize,arrSize)) ctr = (arrSize - 1) / 2 arr[ctr] = 0 arr[:,ctr] = 0 | def imPosFromCnvPos(self, cnvPos): """Convert canvas position to image pixel position. See cnvPosFromImPos for details. """ cnvLLPos = ( cnvPos[0] - self.bdWidth, self.cnvHeight - self.bdWidth - cnvPos[1] - 1, ) imPos = [(cnvLL + 0.5) / float(self.zoomFac) for cnvLL in cnvLLPos] return imPos |
self.rectCoords = (x0, y0, x1, y1) | def __init__(self, cnv, x0, y0, x1, y1, tags = None, grabSize = 3, minSize = None, width = 1, fill = "white", | |
minSize = (2 * width) + (3 * self.grabSize[0]) + self.grabSize[1] self.minSize = minSize | minSize = 3 + (3 * self.grabSize[0]) + self.grabSize[1] self.minSizeLess1 = minSize - 1 | def __init__(self, cnv, x0, y0, x1, y1, tags = None, grabSize = 3, minSize = None, width = 1, fill = "white", |
self.cnv.tag_bind(self.rectID, "<Enter>", GenericCallback(self._doEnter, "hand2")) | self.cnv.tag_bind(self.rectID, "<Enter>", GenericCallback(self._setCursor, "hand2")) | def __init__(self, cnv, x0, y0, x1, y1, tags = None, grabSize = 3, minSize = None, width = 1, fill = "white", |
sideColor = "yellow" cornerColor = "blue" cornerColor = sideColor = None self.idDict["L"] = self.cnv.create_rectangle( 0, 0, 0, 1, fill = sideColor, stipple = "gray25", width = 0, tags = tags, ) self.idDict["R"] = self.cnv.create_rectangle( 1, 0, 1, 1, fill = sideColor, stipple = "gray25", width = 0, tags = tags, ) sel... | if Debug: sideColor, cornerColor = "yellow", "blue" else: sideColor = cornerColor = None for regionName in ("L", "R", "T", "B"): self.idDict[regionName] = self.cnv.create_rectangle( 0, 0, 0, 0, fill = sideColor, stipple = "gray25", width = 0, tags = tags, ) for regionName in ("TL", "TR", "BL", "BR"): self.idDict[region... | def __init__(self, cnv, x0, y0, x1, y1, tags = None, grabSize = 3, minSize = None, width = 1, fill = "white", |
self.cnv.tag_bind(regionID, "<Enter>", GenericCallback(self._doEnter, cursor)) self.cnv.tag_bind(regionID, "<Leave>", self._doLeave) self.cnv.tag_bind(regionID, "<B1-Motion>", GenericCallback(self.doResize, regionName)) | self.cnv.tag_bind(regionID, "<Enter>", GenericCallback(self._setCursor, cursor)) self.cnv.tag_bind(regionID, "<Leave>", self._restoreDefaultCursor) self.cnv.tag_bind(regionID, "<B1-Motion>", GenericCallback(self._doResize, regionName)) | def __init__(self, cnv, x0, y0, x1, y1, tags = None, grabSize = 3, minSize = None, width = 1, fill = "white", |
self._setCoords("L", ox0, iy0, ix0, iy1) self._setCoords("R", ix1, oy0, ox1, iy1) self._setCoords("T", ix0, oy0, ix1, iy0) self._setCoords("B", ix0, iy1, ix1, oy1) self._setCoords("TL", ox0, oy0, ix0, iy0) self._setCoords("TR", ix1, oy0, ox1, iy0) self._setCoords("BL", ox0, iy1, ix0, oy1) self._setCoords("BR", ix1,... | self._setRegionCoords("L", ox0, iy0, ix0, iy1) self._setRegionCoords("R", ix1, oy0, ox1, iy1) self._setRegionCoords("T", ix0, oy0, ix1, iy0) self._setRegionCoords("B", ix0, iy1, ix1, oy1) self._setRegionCoords("TL", ox0, oy0, ix0, iy0) self._setRegionCoords("TR", ix1, oy0, ox1, iy0) self._setRegionCoords("BL", ox0,... | def redraw(self, evt=None): self.cnv.coords(self.rectID, *self.rectCoords) ix0, iy0, ix1, iy1 = self._expandRect(self.rectCoords, -self.grabSize[0]) ox0, oy0, ox1, oy1 = self._expandRect(self.rectCoords, self.grabSize[1]) self._setCoords("L", ox0, iy0, ix0, iy1) self._setCoords("R", ix1, oy0, ox1, iy1) self._setCoor... |
cnvSize = [self.cnv.winfo_width(), self.cnv.winfo_height()] | maxCoord = [self.cnv.winfo_width() - 1, self.cnv.winfo_height() - 1] | def _doMove(self, evt): """Handle <Motion> event to move the box""" newMousePos = [evt.x, evt.y] dPos = [newMousePos[ii] - self.mousePos[ii] for ii in range(2)] newRectCoords = [self.rectCoords[ii] + dPos[ii%2] for ii in range(4)] cnvSize = [self.cnv.winfo_width(), self.cnv.winfo_height()] # constrain the move for ii... |
elif newRectCoords[ii+2] > cnvSize[ii]: overshoot = newRectCoords[ii+2] - cnvSize[ii] | elif newRectCoords[ii+2] > maxCoord[ii]: overshoot = newRectCoords[ii+2] - maxCoord[ii] | def _doMove(self, evt): """Handle <Motion> event to move the box""" newMousePos = [evt.x, evt.y] dPos = [newMousePos[ii] - self.mousePos[ii] for ii in range(2)] newRectCoords = [self.rectCoords[ii] + dPos[ii%2] for ii in range(4)] cnvSize = [self.cnv.winfo_width(), self.cnv.winfo_height()] # constrain the move for ii... |
def doResize(self, regionName, evt): | def _doResize(self, regionName, evt): | def _doMove(self, evt): """Handle <Motion> event to move the box""" newMousePos = [evt.x, evt.y] dPos = [newMousePos[ii] - self.mousePos[ii] for ii in range(2)] newRectCoords = [self.rectCoords[ii] + dPos[ii%2] for ii in range(4)] cnvSize = [self.cnv.winfo_width(), self.cnv.winfo_height()] # constrain the move for ii... |
cnvSize = [self.cnv.winfo_width(), self.cnv.winfo_height()] | maxCoord = [self.cnv.winfo_width() - 1, self.cnv.winfo_height() - 1] | def doResize(self, regionName, evt): """Handle <Motion> event to resize the box""" newMousePos = [evt.x, evt.y] dPos = [newMousePos[ii] - self.mousePos[ii] for ii in range(2)] newRectCoords = list(self.rectCoords) cnvSize = [self.cnv.winfo_width(), self.cnv.winfo_height()] # compute the resize for (ii, ltr0, ltr1) in... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.