rem
stringlengths
0
322k
add
stringlengths
0
2.05M
context
stringlengths
8
228k
points.append(self._readRecordPoint(fp))
points.append(self._readRecordPoint(fp)['points'])
def _readRecordPolyLine(self, fp): shape = {'bounds': self._readBounds(fp)} nParts = self._readAndUnpack(self.__SIGNED_INT, fp.read(4)) nPoints = self._readAndUnpack(self.__SIGNED_INT, fp.read(4))
points = [points['points'] for points in part['points']]
points = part['points']
def _processPartInfo(self, part): points = [points['points'] for points in part['points']] n = len(points) area = cx = cy = 0 xmin = ymin = 360 xmax = ymax = -360 pt = points[n-1] xx = pt[0] yy = pt[1]
min = bounds[0] max = bounds[1] bounds['center'] = ((min[0] + max[0]) / 2, (min[1] + max[1]) / 2)
xymin = bounds[0] xymax = bounds[1] bounds['center'] = ((xymin[0] + xymax[0]) / 2, (xymin[1] + xymax[1]) / 2)
def _processBoundCenters(self, features): for feature in features: bounds = feature['shape']['bounds'] min = bounds[0] max = bounds[1] bounds['center'] = ((min[0] + max[0]) / 2, (min[1] + max[1]) / 2)
def __init__(self):
def __init__(self, filename): self.__filename = filename
def __init__(self): self.__contentLength = 0 self.__shapeType = 0 self.__recordNum = 0
def parse(self, filename):
def parse(self):
def parse(self, filename): # Get basic shapefile configuration. fp = open(filename, 'rb')
fp = open(filename, 'rb')
fp = open(self.__filename, 'rb')
def parse(self, filename): # Get basic shapefile configuration. fp = open(filename, 'rb')
dbfile = open(filename[0:-4] + '.dbf', 'rb')
dbfile = open(self.__filename[0:-4] + '.dbf', 'rb')
def parse(self, filename): # Get basic shapefile configuration. fp = open(filename, 'rb')
import sys sf = ShapeFile() print sf.parse(sys.argv[1])
import sys, pprint sf = ShapeFile(sys.argv[1]) pp = pprint.PrettyPrinter() pp.pprint(sf.parse())
def dumpFeatureInfo(self, features): fields = [] rows = []
y, m, d = int(value[:4]), int(value[4:6]), int(value[6:8]) value = datetime.date(y, m, d)
value = value.strip() if len(value) == int(size): y, m, d = int(value[:4]), int(value[4:6]), int(value[6:8]) value = datetime.date(y, m, d)
def dbfreader(f): """ Returns an iterator over records in a Xbase DBF file. The first row returned contains the field names. The second row contains field specs: (type, size, decimal places). Subsequent rows contain the data records. If a record is marked as deleted, it is skipped. File should be opened for binary re...
value = (value in 'YyTt' and 'T') or (value in 'NnFf' and 'F') or '?'
value = (value in 'YyTt' and 'T') or \ (value in 'NnFf' and 'F') or '?'
def dbfreader(f): """ Returns an iterator over records in a Xbase DBF file. The first row returned contains the field names. The second row contains field specs: (type, size, decimal places). Subsequent rows contain the data records. If a record is marked as deleted, it is skipped. File should be opened for binary re...
filetype = self._readAndUnpack(self.__SIGNED_INT, fp.read(4))
filetype = self._readAndUnpack(self.__LE_SINT, fp.read(4))
def loadShapefile(self, filename): # Open dbf file and get features as a list. dbfile = open(filename[0:-4] + '.dbf', 'rb') self.__db[:] = list(dbfUtils.dbfreader(dbfile)) dbfile.close()
recordNumber = self._readAndUnpack( self.__BIG_ENDIAN_UNSIGNED_LONG, fp.read(4))
recordNumber = self._readAndUnpack(self.__BE_SINT, fp.read(4))
def _createRecord(self, fp): result = None # Read header recordNumber = self._readAndUnpack( self.__BIG_ENDIAN_UNSIGNED_LONG, fp.read(4))
contentLength = self._readAndUnpack( self.__BIG_ENDIAN_UNSIGNED_LONG, fp.read(4)) recType = self._readAndUnpack( self.__LITTLE_ENDIAN_UNSIGNED_LONG, fp.read(4))
contentLength = self._readAndUnpack(self.__BE_SINT, fp.read(4)) recType = self._readAndUnpack(self.__LE_SINT, fp.read(4))
def _createRecord(self, fp): result = None # Read header recordNumber = self._readAndUnpack( self.__BIG_ENDIAN_UNSIGNED_LONG, fp.read(4))
point = {'points': (self._readAndUnpack(self.__DOUBLE, fp.read(8)), self._readAndUnpack(self.__DOUBLE, fp.read(8)))}
point = {'points': (self._readAndUnpack(self.__LE_DOUBLE, fp.read(8)), self._readAndUnpack(self.__LE_DOUBLE, fp.read(8)))}
def _readRecordPoint(self, fp): point = {'points': (self._readAndUnpack(self.__DOUBLE, fp.read(8)), self._readAndUnpack(self.__DOUBLE, fp.read(8)))} self.__pointCount += 1 return point
nParts = self._readAndUnpack(self.__SIGNED_INT, fp.read(4)) nPoints = self._readAndUnpack(self.__SIGNED_INT, fp.read(4)) if self._readAndUnpack(self.__SIGNED_INT, fp.read(4)) != 0: raise ValueError('ERROR: First part offset must be 0') counts = [] prev = 0 for i in xrange(nParts - 1): nextItem = self._readAndUnpack(...
nParts = self._readAndUnpack(self.__LE_SINT, fp.read(4)) nPoints = self._readAndUnpack(self.__LE_SINT, fp.read(4)) offsetParts = [] prevRec = 0 for idx in xrange(nParts): offsetParts.append(self._readAndUnpack(self.__LE_SINT, fp.read(4))) size = len(offsetParts) for i in xrange(size): offset = offsetParts[i] if i <...
def _readRecordPolyLine(self, fp): shape = {'bounds': self._readBounds(fp)} nParts = self._readAndUnpack(self.__SIGNED_INT, fp.read(4)) nPoints = self._readAndUnpack(self.__SIGNED_INT, fp.read(4))
for j in xrange(counts[i]):
for j in xrange(offsetParts[i]):
def _readRecordPolyLine(self, fp): shape = {'bounds': self._readBounds(fp)} nParts = self._readAndUnpack(self.__SIGNED_INT, fp.read(4)) nPoints = self._readAndUnpack(self.__SIGNED_INT, fp.read(4))
nPoints = self._readAndUnpack(self.__SIGNED_INT, fp.read(4))
nPoints = self._readAndUnpack(self.__LE_SINT, fp.read(4))
def _readRecordMultiPoint(self, fp): shape = {'bounds': self._readBounds(fp)} points = shape['points'] = [] nPoints = self._readAndUnpack(self.__SIGNED_INT, fp.read(4))
points.append(self._readRecordPoint(fp))
points.append(self._readRecordPoint(fp)['points'])
def _readRecordMultiPoint(self, fp): shape = {'bounds': self._readBounds(fp)} points = shape['points'] = [] nPoints = self._readAndUnpack(self.__SIGNED_INT, fp.read(4))
(self._readAndUnpack(self.__DOUBLE, fp.read(8)), self._readAndUnpack(self.__DOUBLE, fp.read(8))), (self._readAndUnpack(self.__DOUBLE, fp.read(8)), self._readAndUnpack(self.__DOUBLE, fp.read(8)))
(self._readAndUnpack(self.__LE_DOUBLE, fp.read(8)), self._readAndUnpack(self.__LE_DOUBLE, fp.read(8))), (self._readAndUnpack(self.__LE_DOUBLE, fp.read(8)), self._readAndUnpack(self.__LE_DOUBLE, fp.read(8)))
def _readBounds(self, fp): return [ (self._readAndUnpack(self.__DOUBLE, fp.read(8)), self._readAndUnpack(self.__DOUBLE, fp.read(8))), (self._readAndUnpack(self.__DOUBLE, fp.read(8)), self._readAndUnpack(self.__DOUBLE, fp.read(8))) ]
if value and value[0] == '\x00': value = ''
def _createRecord(self, fp, shapeType): result = None # Read header recordNumber = self._readAndUnpack(self.__BE_SINT, fp.read(4)) names = self.__db[0] specs = self.__db[1]
dups = []
def _readRecordPoly(self, fp): """ Type: PolyLine (3), Polygon (5), PolyLineZ (13), PolygonZ (15), PolyLineM (23), or PolygonM (25)
dups[:] = self._deleteConsecutiveDuplicatePoints(points)
def _readRecordPoly(self, fp): """ Type: PolyLine (3), Polygon (5), PolyLineZ (13), PolygonZ (15), PolyLineM (23), or PolygonM (25)
self._deleteItemsRelatingToDuplicatePoints(zPoints, dups)
def _readRecordPoly(self, fp): """ Type: PolyLine (3), Polygon (5), PolyLineZ (13), PolygonZ (15), PolyLineM (23), or PolygonM (25)
self._deleteItemsRelatingToDuplicatePoints(measures, dups)
def _readRecordPoly(self, fp): """ Type: PolyLine (3), Polygon (5), PolyLineZ (13), PolygonZ (15), PolyLineM (23), or PolygonM (25)
def _deleteConsecutiveDuplicatePoints(self, points): size = len(points) dups = [] for i in xrange(size): idx = i + 1 if idx < size and points[i] == points[idx]: dups.append(i) dups.reverse() [points.pop(i) for i in dups] return dups def _deleteItemsRelatingToDuplicatePoints(self, items, dups): [items.pop(i) for i i...
def _deleteConsecutiveDuplicatePoints(self, parts): for part in parts: points = part.get('points') pSize = len(points) measures = part.get('measures') dups = [] for i in xrange(pSize): idx = i + 1 if idx < pSize and points[i] == points[idx]: dups.append(i) dups.reverse() badPoints = [points.pop(i) for i in dups] i...
def _deleteConsecutiveDuplicatePoints(self, points): size = len(points) dups = []
value = value.replace('\0', '').lstrip()
value = value.replace('\x00', '').lstrip()
def dbfreader(f): """ Returns an iterator over records in a Xbase DBF file. The first row returned contains the field names. The second row contains field specs: (type, size, decimal places). Subsequent rows contain the data records. If a record is marked as deleted, it is skipped. File should be opened for binary re...
if len(value) == int(size):
if len(value) == size:
def dbfreader(f): """ Returns an iterator over records in a Xbase DBF file. The first row returned contains the field names. The second row contains field specs: (type, size, decimal places). Subsequent rows contain the data records. If a record is marked as deleted, it is skipped. File should be opened for binary re...
PolyLineM (23), or PolygonM (25)
PolyLineM (23), PolygonM (25), or MultiPatch (31)
def _readRecordPoly(self, fp): """ Type: PolyLine (3), Polygon (5), PolyLineZ (13), PolygonZ (15), PolyLineM (23), or PolygonM (25)
size = len(offsetParts) for i in xrange(size): offset = offsetParts[i] if i < (size - 1): offsetParts[i] = offsetParts[i + 1] - offset nPoints -= offsetParts[i] else: offsetParts[i] = nPoints
self._processOffsetParts(offsetParts, nPoints) if shapeType == self._MULTIPATCH: partTypes = [self._readIntegers(fp, 1) for idx in xrange(nParts)]
def _readRecordPoly(self, fp): """ Type: PolyLine (3), Polygon (5), PolyLineZ (13), PolygonZ (15), PolyLineM (23), or PolygonM (25)
_MULTIPATCH: (None, 'MultiPatch'),
_MULTIPATCH: (_readRecordPoly, 'MultiPatch'),
def _readRecordMultiPoint(self, fp): """ Type: MultiPoint (8), MultiPointZ (18), and MultiPointM (28)
if recordNumber != '':
names = self.__db[0] specs = self.__db[1] if recordNumber:
def _createRecord(self, fp, shapeType): result = None # Read header recordNumber = self._readAndUnpack(self.__BE_SINT, fp.read(4))
names = self.__db[0]
def _createRecord(self, fp, shapeType): result = None # Read header recordNumber = self._readAndUnpack(self.__BE_SINT, fp.read(4))
if value[0] == '\x00': value = ''
if value and value[0] == '\x00': value = ''
def _createRecord(self, fp, shapeType): result = None # Read header recordNumber = self._readAndUnpack(self.__BE_SINT, fp.read(4))
self.__db[:] = list(dbfUtils.dbfreader(dbfile))
self.__db[:] = list(dbfutils.dbfreader(dbfile))
def parse(self): # Get basic shapefile configuration. fp = open(self.__filename, 'rb')
tolerance = 0.3
tolerance = 0.5
def areCloseEnough( self, pos1, pos2 ): tolerance = 0.3 dy = pos1[1] - pos2[1] # >= is important if (dy >= 0.0 and dy < tolerance) or (dy < 0.0 and dy > -tolerance): dz = pos1[2] - pos2[2] # >= is important if (dz >= 0.0 and dz < tolerance) or (dz < 0.0 and dz > -tolerance): return True return False
def haveRoughlySameForceDirection(self,ivec,iconstant): angle = self.angleVec3(ivec,iconstant)
def haveRoughlySameDirection(self,ivec,ivec2): if ivec.length() == 0 or ivec2.length() == 0: return False angle = self.angleVec3(ivec,ivec2)
def haveRoughlySameForceDirection(self,ivec,iconstant): angle = self.angleVec3(ivec,iconstant) #print angle if (-math.pi/4.0) < angle and angle < (math.pi/4.0): return True return False
if (-math.pi/4.0) < angle and angle < (math.pi/4.0):
if (-math.pi/8.0) < angle and angle < (math.pi/8.0):
def haveRoughlySameForceDirection(self,ivec,iconstant): angle = self.angleVec3(ivec,iconstant) #print angle if (-math.pi/4.0) < angle and angle < (math.pi/4.0): return True return False
v3.setX(0.0) v3.setZ(0.0) if self.haveRoughlySameForceDirection(self.ballBody.getLinearVel(),v3) and abs(self.ballBody.getLinearVel().length()) > self.MAX_MOVEMENT_SPEED:
lv = self.ballBody.getLinearVel() lv.setX(0.0) lv.setZ(0.0) if self.haveRoughlySameDirection(lv,v3) and abs(lv.length()) > self.MAX_MOVEMENT_SPEED:
def updateModelNode(self): ''' Update objects after one physics iteration ''' now = globalClock.getLongTime() body = self.ballBody g = self.world.getGravity() if Ball.MOVEMENT_DEBUG and now - self.lastDrawTime2 > 0.2: v = body.getLinearVel() v2 = self.perpendicularUnitVec3WithFixedX(v) self.lines.reset() self.lines3.r...
for i in range(0,len(self.menues)-1):
x = -1 for i in range(len(self.menues)):
def getActiveMenu(self): for i in range(0,len(self.menues)-1): if (self.menues[i].getVisibility()): return self.menues[i]
return self.menues[i]
x = i break if x != -1: return self.menues[x]
def getActiveMenu(self): for i in range(0,len(self.menues)-1): if (self.menues[i].getVisibility()): return self.menues[i]
output = FIG_TEMPLATE % dict(pathcode=s, colorcode=self.colorcode)
output = FIG_TEMPLATE % dict(pathcode=s, colorcode=self.colorcode,\ extraoptions=extraoptions)
def effect(self): s = "" nodes = self.selected_sorted # If no nodes is selected convert whole document. if len(nodes) == 0: nodes = self.document.getroot() graphics_state = GraphicsState(nodes) else: graphics_state = GraphicsState(None) goptions, transformation = self.convert_svgstate_to_tikz(graphics_state, graphics_s...
start_ang, end_ang, rx, ry = calc_arc(current_pos[0],current_pos[1],*params)
start_ang_o, end_ang_o, rx, ry = calc_arc(current_pos[0],current_pos[1],*params) start_ang = start_ang_o % 360 end_ang = end_ang_o % 360 if start_ang_o < end_ang_o and not (start_ang < end_ang): start_ang -= 360 elif start_ang_o > end_ang_o and not (start_ang > end_ang): end_ang -= 360
def _write_tikz_path(self, pathdata, options=[], node=None): """Convert SVG paths, shapes and text to TikZ paths""" s = pathcode = "" #print "Pathdata %s" % pathdata if not pathdata or len(pathdata) == 0: return "" if node is not None: id = node.get('id', '') else: id = '' current_pos = [0.0,0.0] for cmd,params in pat...
'onclick="javascript:refbrowser_removeReference(\'singleRef\', 0)"'
'onclick="javascript:refbrowser_removeReference(\'ref_browser_singleRef\', 0)"'
def test_multivalued(self): """ We want to support `multiValued=True/False` on fields, but need `1` or `0` for our widget, since we work with javascript there. """ context = self.portal.demo1
'<input id="singleRef_label" size="50" type="text" readonly="readonly" '
'<input id="ref_browser_singleRef_label" size="50" type="text" readonly="readonly" '
def test_basewidget(self): response = self.publish('%s/base_edit' % self.demo1_url, self.basic_auth) body = normalize(response.getBody()) assert ('<script type="text/javascript" charset="iso-8859-1" ' 'src="http://nohost/plone/referencebrowser.js"> ' '</script>') in body
assert ('<input type="hidden" name="singleRef" id="singleRef" /> ') \
assert ('<input type="hidden" name="singleRef" id="ref_browser_singleRef" /> ') \
def test_basewidget(self): response = self.publish('%s/base_edit' % self.demo1_url, self.basic_auth) body = normalize(response.getBody()) assert ('<script type="text/javascript" charset="iso-8859-1" ' 'src="http://nohost/plone/referencebrowser.js"> ' '</script>') in body
assert '''<input type="button" class="destructive" value="Clear reference" onclick="javascript:refbrowser_removeReference('singleRef', 0)" />''' in body
assert '''<input type="button" class="destructive" value="Clear reference" onclick="javascript:refbrowser_removeReference('ref_browser_singleRef', 0)" />''' in body
def test_basewidget(self): response = self.publish('%s/base_edit' % self.demo1_url, self.basic_auth) body = normalize(response.getBody()) assert ('<script type="text/javascript" charset="iso-8859-1" ' 'src="http://nohost/plone/referencebrowser.js"> ' '</script>') in body
messages.error(request, "Du kan ikke endre state til denne ordren.")
messages.error(request, "Ordren er arkivert og kan ikke forandres.")
def changeStatus(request, orderID): order = Order.objects.get(id=orderID) if order.state == "T": order.state = "O" elif order.state == "O": order.state = "F" elif order.state == "F": order.state = "A" else: messages.error(request, "Du kan ikke endre state til denne ordren.") return redirect(overview) order.save() ...
@require_perm('view', Order) def view(request, id): order = Order.objects.for_company().get(id=id) whoCanSeeThis = order.whoHasPermissionTo('view') return render_with_request(request, 'orders/view.html', {'title':'Ordre: %s' % order.order_name, 'order':order, 'whoCanSeeThis':whoCanSeeThis})
def delete(request, id): return form(request, id)
title = models.CharField(max_length=80)
title = models.CharField(max_length=80, blank=True)
def __unicode__(self): return self.title
'%s har lagt inn en ny kommentar i buggen: %s : \n\n' % (request.user.first_name+" "+request.user.last_name, ticket.title), 'time@focussecurity.no', recipients, fail_silently=False)
'%s har lagt inn en ny kommentar i buggen: %s' % (request.user.first_name, ticket.title), 'time@focussecurity.no', recipientsEmails, fail_silently=False)
def sendEmailAndUpdateNotSeenList(request, bugID): ticket = Bug.objects.get(id=bugID) recipients = set([]) recipientsEmails = set([]) notSeen = ticket.usersNotSeenChanges #Add the ticket creator to recipients list if ticket.creator not in recipients: recipients.add(ticket.creator) #Add the comment creators to recipi...
from math import sqrt
def findPrimes (worker): from math import sqrt limit = 10**4. primes = [] for n in xrange(2, int(limit)+1): for p in primes: if worker.isCancelled(): return primes if p > n**2: break if n % p == 0: break else: primes.append(n) worker.publish(n) worker.setProgress(n/limit) return primes
"\s*\d+: (B|W) (%s)\s+(Y|N) \[([a-z ]{3})\s+(\d+)\s+(\d+)\]\s+(\d+)-(\d+)\s+(W|B)(\d+)\s+(\?\?\?|[A-Z]\d+)\s+(%s)\s+(%s)\s+(\d+),\s+(\d+):(\d+)\s+([A-Z\?]+)\s+(\d{4})" %
"\s*\d+: (B|W) (%s)\s+(Y|N) \[([a-z ]{3})\s+(\d+)\s+(\d+)\]\s+(\d+)-(\d+)\s+(W|B)(\d+)\s+(---|\?\?\?|[A-Z]\d+)\s+(%s)\s+(%s)\s+(\d+),\s+(\d+):(\d+)\s+([A-Z\?]+)\s+(\d{4})" %
def __init__ (self, connection): GObject.__init__(self) self.connection = connection self.connection.expect_line (self.__onStoredResponseNO, "%s has no adjourned games\." % self.connection.username) self.connection.expect_fromto (self.__onSmovesResponse, "Move\s+(%s)\s+(%s)" % (names,names), "{(.*[gG]ame adjourned.*...
mainvbox.remove(mainvbox.get_children()[2])
centerVBox = mainvbox.get_children()[2] for child in centerVBox.get_children(): centerVBox.remove(child) mainvbox.remove(centerVBox)
def delGameWidget (gmwidg): """ Remove the widget from the GUI after the game has been terminated """ gmwidg.emit("closed") del key2gmwidg[gmwidg.notebookKey] pageNum = gmwidg.getPageNumber() headbook = getheadbook() headbook.remove_page(pageNum) for notebook in notebooks.values(): notebook.remove_page(pageNum) if h...
self.connection.fm.connect("fingeringFinished", self.onFinger)
glock.glock_connect(self.connection.fm, "fingeringFinished", lambda fm, finger: self.onFinger(fm, finger))
def __init__ (self, widgets, connection): ParrentListSection.__init__(self) self.widgets = widgets self.connection = connection self.finger = None self.connection.fm.connect("fingeringFinished", self.onFinger) self.connection.fm.finger(self.connection.getUsername()) self.widgets["untimedCheck"].connect("toggled", se...
self.chainbox.connect("clicked", self.onChainBoxClicked)
def toleranceHBoxSetter (widget, visible): assert type(visible) is bool if visible: self.widgets["toleranceHBox"].show() else: self.widgets["toleranceHBox"].hide()
title = "Edit Seek: " + self.widgets[radioname % seeknumber].get_label()[:-1]
title = _("Edit Seek: ") + self.widgets[radioname % seeknumber].get_label()[:-1]
def onResponse (dialog, response): self.widgets["editSeekDialog"].hide() self.widgets["editSeekDialog"].disconnect(handlerId) for i in range(1,4): self.widgets[buttonname % i].set_sensitive(True) self.widgets[opbuttonname % i].set_sensitive(True) if configbutton in self.connections: self.widgets[configbutton].disconnec...
self.widgets["yourRatingNameLabel"].set_label(gametype)
self.widgets["yourRatingNameLabel"].set_label("(" + gametype + ")")
def __updateYourRatingHBox (self): if self.finger == None: return gametype, ratingtype = self.__getGameTypes() self.widgets["yourRatingNameLabel"].set_label(gametype) try: rating = self.finger.getRating(type=ratingtype) except KeyError: # the user doesn't have a rating for this game type self.widgets["yourRatingImage...
def onChainBoxClicked (self, chainbox): pass
def onFinger (self, fm, finger): if not finger.getName() == self.connection.getUsername(): return self.finger = finger self.__updateYourRatingHBox()
global panels_gw from pychess.widgets.gamewidget import key2gmwidg, attachGameWidget, delGameWidget
from pychess.Utils.GameModel import GameModel from pychess.widgets.gamewidget import key2gmwidg, attachGameWidget, delGameWidget, GameWidget
def initialize(widgets): global panels_gw from pychess.widgets.gamewidget import key2gmwidg, attachGameWidget, delGameWidget def delete_event (widget, *args): widgets["preferences"].hide() if panels_gw in key2gmwidg.values(): delGameWidget(panels_gw) return True GeneralTab(widgets) EngineTab(widgets) SoundTab(widgets)...
from pychess.Utils.GameModel import GameModel from pychess.widgets.gamewidget import GameWidget panels_gw = GameWidget(GameModel())
def delete_event (widget, *args): widgets["preferences"].hide() if panels_gw in key2gmwidg.values(): delGameWidget(panels_gw) return True
lambda data: data[3].startswith("audio/"))
lambda data: data[3] and data[3].startswith("audio/"))
def __init__ (self, widgets): # Init open dialog opendialog = gtk.FileChooserDialog ( _("Open Sound File"), None, gtk.FILE_CHOOSER_ACTION_OPEN, (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_ACCEPT)) for dir in self.SOUND_DIRS: if os.path.isdir(dir): opendialog.set_current_folder(dir) break so...
if flag == "stdout":
if self.flag == "stdout":
def write (self, data): try: self.to.write(data) except IOError: if flag == "stdout": # Certainly hope we never end up here pass else: log.error("Could not write data '%s' to pipe '%s'" % (data, repr(self.to))) if log: log.debug (data, self.flag) #self.flush()
variantToRatingType = {
variants = {
# def call ():
ratingType = self.variantToRatingType[variant]
ratingType = self.variants[variant]
def __updateYourRatingHBox (self): if self.finger == None: return if self.widgets["untimedCheck"].get_active(): gameTypeName = self.__getNameOfTimeControl(0, 0) ratingType = self.__getTypeOfTimeControl(0, 0) elif self.widgets["noVariantRadio"].get_active(): min = int(self.widgets["minutesSpin"].get_value()) gain = int...
specialVariants = [v for v in variants.values() if v != NormalChess] groups = groupby(specialVariants, attrgetter("variant_group"))
ficsvariants = [v for k, v in variants.iteritems() if k in self.variants.keys()] groups = groupby(ficsvariants, attrgetter("variant_group"))
def __initVariantCombo (self, combo): model = gtk.TreeStore(str) cellRenderer = gtk.CellRendererText() combo.clear() combo.pack_start(cellRenderer, True) combo.add_attribute(cellRenderer, 'text', 0) combo.set_model(model) groupNames = {VARIANTS_BLINDFOLD: _("Blindfold"), VARIANTS_ODDS: _("Odds"), VARIANTS_SHUFFLE: _("...
self.lastratinglabel = -1
def toleranceHBoxSetter (widget, visible): assert type(visible) is bool if visible: self.widgets["toleranceHBox"].show() else: self.widgets["toleranceHBox"].hide()
self.lastdifference = conf.get("lastdifference-%d" % seeknumber, -1)
def __loadSeekEditor (self, seeknumber): for widget in self.seekEditorWidgets: if widget in self.seekEditorWidgetGettersSetters: uistuff.loadDialogWidget(self.widgets[widget], widget, seeknumber, get_value_=self.seekEditorWidgetGettersSetters[widget][0], set_value_=self.seekEditorWidgetGettersSetters[widget][1], first_...
def __updateYourRatingHBox (self): if self.finger == None: return
def __getGameTypes (self):
def __updateRatingRangeBox (self): center = int(self.widgets["ratingCenterSlider"].get_value()) * RATING_SLIDER_STEP tolerance = int(self.widgets["toleranceSlider"].get_value()) * RATING_SLIDER_STEP minRating = center - tolerance minRating = minRating > 0 and minRating or 0 maxRating = center + tolerance maxRating = ma...
gameTypeName = self.__getNameOfTimeControl(0, 0) ratingType = self.__getTypeOfTimeControl(0, 0)
gametype = self.__getNameOfTimeControl(0, 0) ratingtype = self.__getTypeOfTimeControl(0, 0)
def __updateYourRatingHBox (self): if self.finger == None: return if self.widgets["untimedCheck"].get_active(): gameTypeName = self.__getNameOfTimeControl(0, 0) ratingType = self.__getTypeOfTimeControl(0, 0) elif self.widgets["noVariantRadio"].get_active(): min = int(self.widgets["minutesSpin"].get_value()) gain = int...
gameTypeName = self.__getNameOfTimeControl(min, gain) ratingType = self.__getTypeOfTimeControl(min, gain)
gametype = self.__getNameOfTimeControl(min, gain) ratingtype = self.__getTypeOfTimeControl(min, gain)
def __updateYourRatingHBox (self): if self.finger == None: return if self.widgets["untimedCheck"].get_active(): gameTypeName = self.__getNameOfTimeControl(0, 0) ratingType = self.__getTypeOfTimeControl(0, 0) elif self.widgets["noVariantRadio"].get_active(): min = int(self.widgets["minutesSpin"].get_value()) gain = int...
gameTypeName = variants[variant].name ratingType = self.variants[variant] self.widgets["yourRatingNameLabel"].set_label(gameTypeName)
gametype = variants[variant].name ratingtype = self.variants[variant] return gametype, ratingtype def __updateYourRatingHBox (self): if self.finger == None: return gametype, ratingtype = self.__getGameTypes() self.widgets["yourRatingNameLabel"].set_label(gametype)
def __updateYourRatingHBox (self): if self.finger == None: return if self.widgets["untimedCheck"].get_active(): gameTypeName = self.__getNameOfTimeControl(0, 0) ratingType = self.__getTypeOfTimeControl(0, 0) elif self.widgets["noVariantRadio"].get_active(): min = int(self.widgets["minutesSpin"].get_value()) gain = int...
rating = self.finger.getRating(type=ratingType)
rating = self.finger.getRating(type=ratingtype)
def __updateYourRatingHBox (self): if self.finger == None: return if self.widgets["untimedCheck"].get_active(): gameTypeName = self.__getNameOfTimeControl(0, 0) ratingType = self.__getTypeOfTimeControl(0, 0) elif self.widgets["noVariantRadio"].get_active(): min = int(self.widgets["minutesSpin"].get_value()) gain = int...
oldrating = self.lastratinglabel self.lastratinglabel = rating if self.chainbox.active and self.__clamp(rating) != self.__clamp(oldrating): oldclamp = self.__clamp(oldrating) oldcenter = int(self.widgets["ratingCenterSlider"].get_value()) * RATING_SLIDER_STEP difference = oldclamp - oldcenter newclamp = self.__clamp(r...
center = int(self.widgets["ratingCenterSlider"].get_value()) * RATING_SLIDER_STEP newclamp = self.__clamp(rating) difference = newclamp - center if self.chainbox.active and difference is not self.lastdifference: newsliderval = (newclamp - self.lastdifference) / RATING_SLIDER_STEP self.widgets["ratingCenterSlider"].set_...
def __updateYourRatingHBox (self): if self.finger == None: return if self.widgets["untimedCheck"].get_active(): gameTypeName = self.__getNameOfTimeControl(0, 0) ratingType = self.__getTypeOfTimeControl(0, 0) elif self.widgets["noVariantRadio"].get_active(): min = int(self.widgets["minutesSpin"].get_value()) gain = int...
self.connections = {}
def chainboxSetter (widget, is_active): self.chainbox.active = is_active
self.connections["seek%sRadioConfigButton" % i] = \ self.widgets["seek%sRadioConfigButton" % i].connect( \
self.widgets["seek%sRadioConfigButton" % i].connect(
def chainboxSetter (widget, is_active): self.chainbox.active = is_active
self.connections["challenge%sRadioConfigButton" % i] = \ self.widgets["challenge%sRadioConfigButton" % i].connect( \
self.widgets["challenge%sRadioConfigButton" % i].connect(
def chainboxSetter (widget, is_active): self.chainbox.active = is_active
self.connection.om.challenge(playername, min, incr, rated, color, variant)
self.connection.om.challenge(self.challengee, min, incr, rated, color, variant)
def onChallengeButtonClicked (self, button): model, iter = self.widgets["playertreeview"].get_selection().get_selected() if iter == None: return playername = model.get_value(iter, 1) if self.widgets["challenge3Radio"].get_active(): self.__loadSeekEditor(3) elif self.widgets["challenge2Radio"].get_active(): self.__load...
radioname = "seek%dRadio" opradioname = "challenge%dRadio" buttonname = "seek%dRadioConfigButton" opbuttonname = "challenge%dRadioConfigButton" configbuttoncallee = self.onSeekRadioConfigButtonClicked self.widgets["strengthFrame"].show() self.widgets["manualAcceptCheck"].show() else: radioname = "challenge%dRadio" opra...
self.widgets["strengthFrame"].set_sensitive(True) self.widgets["manualAcceptCheck"].set_sensitive(True) else: self.widgets["strengthFrame"].set_sensitive(False) self.widgets["manualAcceptCheck"].set_sensitive(False)
def __showSeekEditor (self, seeknumber, challengemode=False): if not challengemode: radioname = "seek%dRadio" opradioname = "challenge%dRadio" buttonname = "seek%dRadioConfigButton" opbuttonname = "challenge%dRadioConfigButton" configbuttoncallee = self.onSeekRadioConfigButtonClicked self.widgets["strengthFrame"].show(...
configbutton = buttonname % seeknumber def onResponse (dialog, response): self.widgets["editSeekDialog"].hide() self.widgets["editSeekDialog"].disconnect(handlerId) for i in range(1,4): self.widgets[buttonname % i].set_sensitive(True) self.widgets[opbuttonname % i].set_sensitive(True) if configbutton in self.connectio...
self.widgets["seek%dRadio" % seeknumber].set_active(True) self.widgets["challenge%dRadio" % seeknumber].set_active(True)
def __showSeekEditor (self, seeknumber, challengemode=False): if not challengemode: radioname = "seek%dRadio" opradioname = "challenge%dRadio" buttonname = "seek%dRadioConfigButton" opbuttonname = "challenge%dRadioConfigButton" configbuttoncallee = self.onSeekRadioConfigButtonClicked self.widgets["strengthFrame"].show(...
handlerId = self.widgets["editSeekDialog"].connect("response", onResponse) title = _("Edit Seek: ") + self.widgets[radioname % seeknumber].get_label()[:-1]
title = _("Edit Seek: ") + self.widgets["seek%dRadio" % seeknumber].get_label()[:-1]
def onResponse (dialog, response): self.widgets["editSeekDialog"].hide() self.widgets["editSeekDialog"].disconnect(handlerId) for i in range(1,4): self.widgets[buttonname % i].set_sensitive(True) self.widgets[opbuttonname % i].set_sensitive(True) if configbutton in self.connections: self.widgets[configbutton].disconnec...
self.widgets["editSeekDialog"].show()
self.widgets["editSeekDialog"].present()
def onResponse (dialog, response): self.widgets["editSeekDialog"].hide() self.widgets["editSeekDialog"].disconnect(handlerId) for i in range(1,4): self.widgets[buttonname % i].set_sensitive(True) self.widgets[opbuttonname % i].set_sensitive(True) if configbutton in self.connections: self.widgets[configbutton].disconnec...
def __writeSavedSeeks (self, seekNumber):
def __writeSavedSeeks (self, seeknumber):
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues()
min, gain, variant, ratingrange, color, rated, manual = self.__getSeekEditorDialogValues()
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
self.savedSeekRadioTexts[seekNumber-1] = radioText
self.savedSeekRadioTexts[seeknumber-1] = radioText
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
seek = [] challenge = []
seek = {}
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
pass
seek["time"] = _("Untimed")
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
seek.append("%d min + %d sec/move" % (min, gain)) challenge.append("%d min + %d sec/move" % (min, gain)) else: seek.append("%d min" % (min)) challenge.append("%d min" % (min))
seek["time"] = "%d min + %d sec/move" % (min, gain) else: seek["time"] = "%d min" % min
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
seek.append("%s" % variants[variant].name) challenge.append("%s" % variants[variant].name) if ratingRange[0] > 0: ratingText = "%d" % ratingRange[0] if ratingRange[1] == 9999:
seek["variant"] = "%s" % variants[variant].name if ratingrange[0] > 0: ratingText = "%d" % ratingrange[0] if ratingrange[1] == 9999:
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
ratingText += "-%d" % ratingRange[1] seek.append(ratingText) elif ratingRange[1] != 9999: seek.append("%d↓" % ratingRange[1])
ratingText += "-%d" % ratingrange[1] seek["rating"] = ratingText elif ratingrange[1] != 9999: seek["rating"] = "%d↓" % ratingrange[1]
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
seek.append(_("White")) challenge.append(_("White"))
seek["color"] = _("White")
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
seek.append(_("Black")) challenge.append(_("Black"))
seek["color"] = _("Black")
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
seek.append(_("Rated")) challenge.append(_("Rated"))
seek["rated"] = _("Rated")
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
seek.append(_("Manual")) seekText = ", ".join(seek) challengeText = ", ".join(challenge) if seekNumber == 1: self.widgets["seek1RadioLabel"].set_text(seekText) self.widgets["challenge1RadioLabel"].set_text(challengeText) elif seekNumber == 2: self.widgets["seek2RadioLabel"].set_text(seekText) self.widgets["challenge2R...
seek["manual"] = _("Manual") seek_ = [] challenge = [] for key in ("time", "variant", "rating", "color", "rated", "manual"): if key in seek: seek_.append(seek[key]) if key in ("time", "variant", "color", "rated"): challenge.append("<b>" + seek[key] + "</b>") else: challenge.append(seek[key]) seektext = ", ".join(seek_...
def __writeSavedSeeks (self, seekNumber): """ Writes saved seek strings for both the Seek Panel and the Challenge Panel """ min, gain, variant, ratingRange, color, rated, manual = self.__getSeekEditorDialogValues() isUntimedGame = True if min is 0 else False radioText = self.__getNameOfTimeControl(min, gain) self.saved...
self.widgets["variantHBox"].set_sensitive(not is_untimed_game)
self.widgets["variantFrame"].set_sensitive(not is_untimed_game)
def onUntimedCheckToggled (self, check): is_untimed_game = check.get_active() self.widgets["timeControlConfigVBox"].set_sensitive(not is_untimed_game) # on FICS, untimed games can't be rated and can't be a chess variant self.widgets["variantHBox"].set_sensitive(not is_untimed_game) self.widgets["ratedGameCheck"].set_se...
gtk.Tooltips().set_tip(expander, title)
expander.set_tooltip_text(title)
def onNewsItem (self, nm, news): glock.acquire() try: weekday, month, day, title, details = news
title = title % offer.param description = description % offer.param
param = offer.param if offer.type == TAKEBACK_OFFER and \ self.gamemodel.players[1-self.color].__type__ is not REMOTE: param = self.gamemodel.ply - offer.param title = title % param description = description % param
def offer (self, offer): title, description, takesParam = OFFER_MESSAGES[offer.type] if takesParam: title = title % offer.param description = description % offer.param def responsecb (dialog, response): if response == gtk.RESPONSE_YES: self.emit("accept", offer) else: self.emit("decline", offer) self._message(title, d...
else: ratingrange = map(int, item[1].split(" → "))
else: ratingrange = map(int, item[0].split(" → "))
def onSeekButtonClicked (self, button): item = self.widgets["strengthCombobox"].get_model()[ self.widgets["strengthCombobox"].get_active()] if item[0] == _("Don't Care"): ratingrange = (0, 9999) else: ratingrange = map(int, item[1].split(" → ")) rated = self.widgets["ratedGameCheck"].get_active() color = self.widgets["...
self.widgets["challengeDialog"].connect("response", self.onSendChallengeButtonResponse) self.widgets["editSeekDialog"].connect("response", self.onSeekEditorButtonResponse)
self.widgets["challengeDialog"].connect("delete-event", self.onChallengeDialogResponse) self.widgets["challengeDialog"].connect("response", self.onChallengeDialogResponse) self.widgets["editSeekDialog"].connect("response", self.onEditSeekDialogResponse)
def chainboxSetter (widget, is_active): self.chainbox.active = is_active
def onSendChallengeButtonResponse (self, dialog, response):
def onChallengeDialogResponse (self, dialog, response):
def onSendChallengeButtonResponse (self, dialog, response): self.widgets["challengeDialog"].hide() if response is not 5: return if self.widgets["challenge3Radio"].get_active(): self.__loadSeekEditor(3) elif self.widgets["challenge2Radio"].get_active(): self.__loadSeekEditor(2) else: self.__loadSeekEditor(1) min, incr,...
return
return True
def onSendChallengeButtonResponse (self, dialog, response): self.widgets["challengeDialog"].hide() if response is not 5: return if self.widgets["challenge3Radio"].get_active(): self.__loadSeekEditor(3) elif self.widgets["challenge2Radio"].get_active(): self.__loadSeekEditor(2) else: self.__loadSeekEditor(1) min, incr,...