rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
if os.path.isfile(os.path.join(MEDIA_ROOT, DIRECTORY, folder, filedata.name)): old_file = os.path.join(abs_path, filedata.name) new_file = os.path.join(abs_path, uploadedfile) | if os.path.isfile(smart_str(os.path.join(MEDIA_ROOT, DIRECTORY, folder, filedata.name))): old_file = smart_str(os.path.join(abs_path, filedata.name)) new_file = smart_str(os.path.join(abs_path, uploadedfile)) | def _upload_file(request): """ Upload file to the server. """ from django.core.files.move import file_move_safe if request.method == 'POST': folder = request.POST.get('folder') fb_uploadurl_re = re.compile(r'^.*(%s)' % reverse("fb_upload")) folder = fb_uploadurl_re.sub('', folder) abs_path = os.path.join(MEDIA_ROOT, ... |
filebrowser_post_upload.send(sender=request, path=request.POST.get('folder'), file=FileObject(os.path.join(DIRECTORY, folder, filedata.name))) | filebrowser_post_upload.send(sender=request, path=request.POST.get('folder'), file=FileObject(smart_str(os.path.join(DIRECTORY, folder, filedata.name)))) | def _upload_file(request): """ Upload file to the server. """ from django.core.files.move import file_move_safe if request.method == 'POST': folder = request.POST.get('folder') fb_uploadurl_re = re.compile(r'^.*(%s)' % reverse("fb_upload")) folder = fb_uploadurl_re.sub('', folder) abs_path = os.path.join(MEDIA_ROOT, ... |
file_move_safe(new_file, old_file) | file_move_safe(new_file, old_file, allow_overwrite=True) | def _upload_file(request): """ Upload file to the server. """ from django.core.files.move import file_move_safe if request.method == 'POST': folder = request.POST.get('folder') fb_uploadurl_re = re.compile(r'^.*(%s)' % reverse("fb_upload")) folder = fb_uploadurl_re.sub('', folder) abs_path = os.path.join(MEDIA_ROOT, ... |
name = forms.CharField(widget=forms.TextInput(attrs=dict({ 'class': 'vTextField' }, max_length=50, min_length=3)), label=_(u'New Name'), help_text=_('Only letters, numbers, underscores, spaces and hyphens are allowed.'), required=True) | name = forms.CharField(widget=forms.TextInput(attrs=dict({ 'class': 'vTextField' }, min_length=1)), label=_(u'New Name'), help_text=_('Only letters, numbers, underscores, spaces and hyphens are allowed.'), required=True) | def __init__(self, path, file_extension, *args, **kwargs): self.path = path self.file_extension = file_extension super(RenameForm, self).__init__(*args, **kwargs) |
if bar_middle_y+self.bar_height < self.y or bar_middle_y-self.bar_height>self.y+self.height: return 1 | def _draw_timechart(self,gc,tc,label,base_y,fill_colors): bar_middle_y = self.first_bar_y+(base_y+.5)*self.bar_height if bar_middle_y+self.bar_height < self.y or bar_middle_y-self.bar_height>self.y+self.height: return 1 #quickly decide we are not on the screen points = self._gather_timechart_points(tc.start_ts,tc.end_... | |
self.plot.value_range.high = self.plot.max_y+1 self.plot.value_range.low = self.plot.min_y self.plot.invalidate_draw() self.plot.request_redraw() | self.plot.auto_zoom_y() self.auto_zoom_timer.Stop() def _auto_zoom_y_delayed(self): self.plot.auto_zoom_y() self.auto_zoom_timer.Stop() | def _auto_zoom_y_changed(self,val): self.plot.value_range.high = self.plot.max_y+1 self.plot.value_range.low = self.plot.min_y self.plot.invalidate_draw() self.plot.request_redraw() |
self.last_label = bar_middle_y-12 | self.last_label = bar_middle_y-8 | def _draw_timechart(self,gc,tc,label,base_y,fill_colors): bar_middle_y = self.first_bar_y+(base_y+.5)*self.bar_height points = self._gather_timechart_points(tc.start_ts,tc.end_ts,base_y,.2) if self.options.remove_pids_not_on_screen and points.size == 0: return 0 if bar_middle_y+self.bar_height < self.y or bar_middle_y... |
'timestamp' : int(float(groups[3])*1000000), | 'timestamp' : int(Decimal(groups[3])*1000000), | def parse_ftrace(filename,callback): if filename.endswith(".dat"): return load_tracecmd(filename,callback) fid = open(filename,"r") # the base regular expressions event_re = re.compile( r'\s*(.+)-([0-9]+)\s+\[([0-9]+)\]\s+([0-9.]+): (.*): (.*)') function_re = re.compile( r'\s*(.+)-([0-9]+)\s+\[([0-9]+)\]\s+([0-9.]+): ... |
if last_timestamp == event['timestamp']: event['timestamp']+=1 | def parse_ftrace(filename,callback): if filename.endswith(".dat"): return load_tracecmd(filename,callback) fid = open(filename,"r") # the base regular expressions event_re = re.compile( r'\s*(.+)-([0-9]+)\s+\[([0-9]+)\]\s+([0-9.]+): (.*): (.*)') function_re = re.compile( r'\s*(.+)-([0-9]+)\s+\[([0-9]+)\]\s+([0-9.]+): ... | |
if irole == role]) | if role in irole]) | def getEmailsForRole(self, role): |
else: | elif group_or_user is not None: | def recursiveGetGroupUsers(mtool, gtool, group): users = set() for group_or_user in group.getGroupMembers(): if IGroupData.providedBy(group_or_user): users = users.union(recursiveGetGroupUsers(mtool, gtool, group_or_user)) else: users.add(group_or_user) |
members.add(member) | if member is not None: members.add(member) | def recursiveGetGroupUsers(mtool, gtool, group): users = set() for group_or_user in group.getGroupMembers(): if IGroupData.providedBy(group_or_user): users = users.union(recursiveGetGroupUsers(mtool, gtool, group_or_user)) else: users.add(group_or_user) |
if symbol.GetUnicode(): continue | uni = symbol.GetUnicode() if uni and (u"+" in uni): continue | def _WriteNamesList(writer): writer.write(_HEADER) symbols = emoji4unicode.GetSymbolsInProposalSortedByUnicode() prev_subcategory_name = "" for symbol in symbols: code_points = symbol[0] symbol = symbol[1] if symbol.GetUnicode(): continue block_heading = _BLOCK_HEADINGS.get(code_points[0]) if block_heading: writer.writ... |
writer.write("\n@\t\t%s\n" % subcategory_name) | writer.write("@\t\t%s\n" % subcategory_name) | def _WriteNamesList(writer): writer.write(_HEADER) symbols = emoji4unicode.GetSymbolsInProposalSortedByUnicode() prev_subcategory_name = "" for symbol in symbols: code_points = symbol[0] symbol = symbol[1] if symbol.GetUnicode(): continue block_heading = _BLOCK_HEADINGS.get(code_points[0]) if block_heading: writer.writ... |
uni = symbol.GetProposedUnicode() | if not uni: uni = symbol.GetProposedUnicode() | def _WriteNamesList(writer): writer.write(_HEADER) symbols = emoji4unicode.GetSymbolsInProposalSortedByUnicode() prev_subcategory_name = "" for symbol in symbols: code_points = symbol[0] symbol = symbol[1] if symbol.GetUnicode(): continue block_heading = _BLOCK_HEADINGS.get(code_points[0]) if block_heading: writer.writ... |
writer.write(";\t= e-%s\n" % symbol.id) | def _WriteNamesList(writer): writer.write(_HEADER) symbols = emoji4unicode.GetSymbolsInProposalSortedByUnicode() prev_subcategory_name = "" for symbol in symbols: code_points = symbol[0] symbol = symbol[1] if symbol.GetUnicode(): continue block_heading = _BLOCK_HEADINGS.get(code_points[0]) if block_heading: writer.writ... | |
self.assertRaises(Exception, test_view('sale_price_list')) | test_view('sale_price_list') | def test0005views(self): ''' Test views. ''' self.assertRaises(Exception, test_view('sale_price_list')) |
self.queue_keeper[song_id] = {"label": song, "text": text} | self.queue_keeper[song_id] = {"requester": requester, "label": song, "text": text} | def add(self, requester, song_id, text): # We want to ignore songs we've already seen, but they don't # always come the same way. for stored_id, song in self.queue_keeper.items(): # Since the album is what generally gets lost, look for the front. if song["text"].startswith(text) or text.startswith(song["text"]): return... |
print "Trying to remove '%s'" % text | def remove(self, song_id="", text=""): if not song_id == "": self._queue_box.remove(self.queue_keeper[song_id]["label"]) return elif not text == "": print "Trying to remove '%s'" % text for id, song in self.queue_keeper.items(): print "Is it %s ?" % song["text"] if text.startswith(song["text"]): print "Found song id %s... | |
print "Is it %s ?" % song["text"] | def remove(self, song_id="", text=""): if not song_id == "": self._queue_box.remove(self.queue_keeper[song_id]["label"]) return elif not text == "": print "Trying to remove '%s'" % text for id, song in self.queue_keeper.items(): print "Is it %s ?" % song["text"] if text.startswith(song["text"]): print "Found song id %s... | |
print "Found song id %s" % id | def remove(self, song_id="", text=""): if not song_id == "": self._queue_box.remove(self.queue_keeper[song_id]["label"]) return elif not text == "": print "Trying to remove '%s'" % text for id, song in self.queue_keeper.items(): print "Is it %s ?" % song["text"] if text.startswith(song["text"]): print "Found song id %s... | |
self.apt_radio_off() | self.api_radio_off() | def queue_song(self, id): self.apt_radio_off() if self.__last_mode == "stopped" and len(self.__queue) == 0: self.play_song(id) else: self.__queue.append(id) |
if self.__last_mode == "stopped": | if self.__last_mode == "stopped" and len(self.__queue) == 0: | def queue_song(self, id): if self.__last_mode == "stopped": self.play_song(id) else: self.__queue.append(id) |
time.sleep(1) | sleep(1) | def queue_song(self, id): if self.__last_mode == "stopped" and len(self.__queue) == 0: self.play_song(id) else: self.__queue.append(id) |
class odict(dict): """An ordered dict (odict). This is a dict which maintains an order to its items; the order is rather like that of a list, in that new items are, by default, added to the end, but items can be rearranged. Note that updating an item (setting a value where the key is already in the dict) is not conside... | from warnings import warn as _warn def copy_baseclass_docs(classname, bases, dict, metaclass=type): """Copy docstrings from baseclass. When overriding methods in a derived class the docstrings can frequently be copied from the base class unmodified. According to the DRY principle (Don't Repeat Yourself) this shoul... | def write_transpose(self): fp = open(self.filename, 'w') fp.write(self.row1col1) for r in self.rows: fp.write(self.delimiter + r) fp.write('\n') |
dict.clear(self) self._order[:] = [] def __iter__(self): return self.iterkeys() def keys(self): return list(self._order) def iterkeys(self): return iter(self._order) def values(self): return [self[k] for k in self._order] def itervalues(self): for k in self.iterkeys(): yield self[k] def items(self): return [(k, self[k]... | super(StableDict, self).clear() self.__ksl = [] def copy(self): return StableDict(self) def pop(self, k, *default): if k in self.__ksl: self.__ksl.remove(k) return super(StableDict, self).pop(k, *default) def popitem(self): item = super(StableDict, self).popitem() try: self.__ksl.remove(item[0]) except: raise ValueE... | def clear(self): dict.clear(self) self._order[:] = [] |
version='1.1', | version='1.2', | def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() |
url='http://svn.plone.org/svn/collective/buildout/buildout.bootsrap', | url='http://svn.plone.org/svn/collective/buildout/buildout.bootstrap', | def read(*rnames): return open(os.path.join(os.path.dirname(__file__), *rnames)).read() |
try: return self.getChildren()[0] except IndexError: return None | typ = self.getType() query=None for child in self.getChildren(): if ('error' != typ) or ('error' != child.getName()): query=child break return query | def getQuery(self): """ Return the IQ's child element if it exists, None otherwise.""" try: return self.getChildren()[0] except IndexError: return None |
reqstr = txrequest.content.read() | reqstr = txrequest.content.getvalue() | def render_POST(self, txrequest): reqstr = txrequest.content.read() target = self.get_target() return jsonrpc_server_call(target, reqstr, self.json_decoder) |
if os.path.isdir (fileInFolder): | fileName = FILES_FOLDER + '/' + fileInFolder if os.path.isdir (fileName): | def install_ZPsycopg(context, data, params, id): """Install a Z Psycopg 2 Database connection. """ dataS = "".join(data) factory = context.manage_addProduct['ZPsycopgDA'] factory.manage_addZPsycopgConnection(id,params.get('title','').strip(),dataS.strip(),zdatetime=params.get('zdatetime','').strip(), encoding=params.ge... |
fileName = FILES_FOLDER + '/' + fileInFolder | def install_ZPsycopg(context, data, params, id): """Install a Z Psycopg 2 Database connection. """ dataS = "".join(data) factory = context.manage_addProduct['ZPsycopgDA'] factory.manage_addZPsycopgConnection(id,params.get('title','').strip(),dataS.strip(),zdatetime=params.get('zdatetime','').strip(), encoding=params.ge... | |
return [e for e in self if e.translated() and not e.obsolete] | return [e for e in self if e.translated()] | def translated_entries(self): """ Convenience method that return a list of translated entries. |
6 """ return [e for e in self if not e.translated() and not e.obsolete] | 4 """ return [e for e in self if not e.translated() and not e.obsolete \ and not 'fuzzy' in e.flags] | def untranslated_entries(self): """ Convenience method that return a list of untranslated entries. |
def __str__(self): """ String representation of the file. | def __unicode__(self): """ Unicode representation of the file. | def __str__(self): """ String representation of the file. """ ret = [] entries = [self.metadata_as_entry()] + \ [e for e in self if not e.obsolete] for entry in entries: ret.append(entry.__str__(self.wrapwidth)) for entry in self.obsolete_entries(): ret.append(entry.__str__(self.wrapwidth)) return '\n'.join(ret) |
ret.append(entry.__str__(self.wrapwidth)) | ret.append(entry.__unicode__(self.wrapwidth)) | def __str__(self): """ String representation of the file. """ ret = [] entries = [self.metadata_as_entry()] + \ [e for e in self if not e.obsolete] for entry in entries: ret.append(entry.__str__(self.wrapwidth)) for entry in self.obsolete_entries(): ret.append(entry.__str__(self.wrapwidth)) return '\n'.join(ret) |
ret.append(entry.__str__(self.wrapwidth)) return '\n'.join(ret) | ret.append(entry.__unicode__(self.wrapwidth)) ret = '\n'.join(ret) if type(ret) != types.UnicodeType: return unicode(ret, self.encoding) return ret def __str__(self): """ String representation of the file. """ return unicode(self).encode(self.encoding) | def __str__(self): """ String representation of the file. """ ret = [] entries = [self.metadata_as_entry()] + \ [e for e in self if not e.obsolete] for entry in entries: ret.append(entry.__str__(self.wrapwidth)) for entry in self.obsolete_entries(): ret.append(entry.__str__(self.wrapwidth)) return '\n'.join(ret) |
... msgstr="Pace سلام שלום Hasîtî 和平" | ... msgstr="Pace سلام שלום Hasîtî 和平", | def _encode(self, mixed): """ Encode the given argument with the file encoding if the type is unicode and return the encoded string. """ if type(mixed) == types.UnicodeType: return mixed.encode(self.encoding) return mixed |
def __str__(self): | def __unicode__(self): | def __str__(self): """Return the string representation of the po file""" ret, headers = '', self.header.split('\n') for header in headers: if header[:1] in [',', ':']: ret += '#%s\n' % header else: ret += '# %s\n' % header return ret + _BaseFile.__str__(self) |
return ret + _BaseFile.__str__(self) | if type(ret) != types.UnicodeType: ret = unicode(ret, self.encoding) return ret + _BaseFile.__unicode__(self) | def __str__(self): """Return the string representation of the po file""" ret, headers = '', self.header.split('\n') for header in headers: if header[:1] in [',', ':']: ret += '#%s\n' % header else: ret += '# %s\n' % header return ret + _BaseFile.__str__(self) |
def __str__(self, wrapwidth=78): """ Common string representation of the POEntry and MOEntry objects. | def __unicode__(self, wrapwidth=78): """ Unicode representation of the entry. | def __str__(self, wrapwidth=78): """ Common string representation of the POEntry and MOEntry objects. """ if self.obsolete: delflag = '#~ ' else: delflag = '' ret = [] # write the msgctxt if any if self.msgctxt is not None: ret += self._str_field("msgctxt", delflag, "", self.msgctxt) # write the msgid ret += self._str_... |
return '\n'.join(ret) | ret = '\n'.join(ret) if type(ret) != types.UnicodeType: return unicode(ret, self.encoding) return ret def __str__(self): """ String representation of the entry. """ return unicode(self).encode(self.encoding) | def __str__(self, wrapwidth=78): """ Common string representation of the POEntry and MOEntry objects. """ if self.obsolete: delflag = '#~ ' else: delflag = '' ret = [] # write the msgctxt if any if self.msgctxt is not None: ret += self._str_field("msgctxt", delflag, "", self.msgctxt) # write the msgid ret += self._str_... |
def __str__(self, wrapwidth=78): | def __unicode__(self, wrapwidth=78): | def __str__(self, wrapwidth=78): """ Return the string representation of the entry. """ if self.obsolete: return _BaseEntry.__str__(self) ret = [] # comment first, if any (with text wrapping as xgettext does) if self.comment != '': for comment in self.comment.split('\n'): if wrapwidth > 0 and len(comment) > wrapwidth-3... |
return _BaseEntry.__str__(self) | return _BaseEntry.__unicode__(self) | def __str__(self, wrapwidth=78): """ Return the string representation of the entry. """ if self.obsolete: return _BaseEntry.__str__(self) ret = [] # comment first, if any (with text wrapping as xgettext does) if self.comment != '': for comment in self.comment.split('\n'): if wrapwidth > 0 and len(comment) > wrapwidth-3... |
ret.append(_BaseEntry.__str__(self)) return '\n'.join(ret) | ret.append(_BaseEntry.__unicode__(self)) ret = '\n'.join(ret) if type(ret) != types.UnicodeType: return unicode(ret, self.encoding) return ret | def __str__(self, wrapwidth=78): """ Return the string representation of the entry. """ if self.obsolete: return _BaseEntry.__str__(self) ret = [] # comment first, if any (with text wrapping as xgettext does) if self.comment != '': for comment in self.comment.split('\n'): if wrapwidth > 0 and len(comment) > wrapwidth-3... |
def __str__(self, wrapwidth=78): """ Return the string representation of the entry. """ return _BaseEntry.__str__(self, wrapwidth) | pass | def merge(self, other): """ Merge the current entry with the given pot entry. """ self.msgid = other.msgid self.occurrences = other.occurrences self.comment = other.comment self.flags = other.flags self.msgid_plural = other.msgid_plural if other.msgstr_plural: for pos in other.msgstr_plural: try: # ... |
e._multiline_str['msgstr'] = '' | def metadata_as_entry(self): """ Return the metadata as an entry: | |
e._multiline_str['msgstr'] = '__POLIB__NL__'.join( [s + '\n' for s in strs]) | def metadata_as_entry(self): """ Return the metadata as an entry: | |
self._multiline_str = {} | def __init__(self, *args, **kwargs): """Base Entry constructor.""" self.msgid = kwargs.get('msgid', '') self.msgstr = kwargs.get('msgstr', '') self.msgid_plural = kwargs.get('msgid_plural', '') self.msgstr_plural = kwargs.get('msgstr_plural', {}) self.obsolete = kwargs.get('obsolete', False) self.encoding = kwargs.get(... | |
if (fieldname + plural_index) in self._multiline_str: field = self._multiline_str[fieldname + plural_index] lines = [''] + field.split('__POLIB__NL__') | lines = field.splitlines(True) if len(lines) > 1: lines = ['']+lines | def _str_field(self, fieldname, delflag, plural_index, field): if (fieldname + plural_index) in self._multiline_str: field = self._multiline_str[fieldname + plural_index] lines = [''] + field.split('__POLIB__NL__') else: lines = field.splitlines(True) if len(lines) > 1: lines = ['']+lines # start with initial empty lin... |
lines = field.splitlines(True) if len(lines) > 1: lines = ['']+lines else: lines = [field] | lines = [field] | def _str_field(self, fieldname, delflag, plural_index, field): if (fieldname + plural_index) in self._multiline_str: field = self._multiline_str[fieldname + plural_index] lines = [''] + field.split('__POLIB__NL__') else: lines = field.splitlines(True) if len(lines) > 1: lines = ['']+lines # start with initial empty lin... |
if typ not in self.current_entry._multiline_str: self.current_entry._multiline_str[typ] = token else: self.current_entry._multiline_str[typ] += "__POLIB__NL__" + token | def handle_mc(self): """Handle a msgid or msgstr continuation line.""" token = unescape(self.current_token[1:-1]) if self.current_state == 'CT': typ = 'msgctxt' self.current_entry.msgctxt += token elif self.current_state == 'MI': typ = 'msgid' self.current_entry.msgid += token elif self.current_state == 'MP': typ = 'ms... | |
def find(self, st, by='msgid', include_obsolete_entries=False): | def find(self, st, by='msgid', include_obsolete_entries=False, msgctxt=False): | def find(self, st, by='msgid', include_obsolete_entries=False): """ Find entry which msgid (or property identified by the *by* attribute) matches the string *st*. |
entries that are obsolete. | entries that are obsolete - *msgctxt*: string, allows to specify a specific message context for the search. | def find(self, st, by='msgid', include_obsolete_entries=False): """ Find entry which msgid (or property identified by the *by* attribute) matches the string *st*. |
0, 0) | 0, keystart) | def cmp(_self, other): if _self.msgid > other.msgid: return 1 elif _self.msgid < other.msgid: return -1 else: return 0 |
model = modelClass(4,True) | self.legChoice = self.legCount.GetValue() model = modelClass(int(self.legChoice),True) | def loadModel(self): """ Load the model for our IK solution. """ modelClassName = iKmodels[self.ikType.GetValue()].folder if "tools/models/"+modelClassName not in sys.path: sys.path.append("tools/models/"+modelClassName) modelModule = __import__(modelClassName, globals(), locals(), [modelClassName]) modelClass = getatt... |
def __init__(self, parent, ser): | def __init__(self, parent, ser, debug = False): | def __init__(self, parent, ser): wx.Frame.__init__(self, parent, -1, "ArbotiX Commander", style = wx.DEFAULT_FRAME_STYLE & ~ (wx.RESIZE_BORDER | wx.MAXIMIZE_BOX)) self.ser = ser |
frame = Commander(None, ser) | frame = Commander(None, ser, True) | def sendPacket(self, Xspeed, Rspeed, Tilt, Pan, Buttons): # send output self.ser.write('\xFF') self.ser.write(chr(Xspeed)) self.ser.write(chr(Rspeed)) self.ser.write(chr(Tilt)) self.ser.write(chr(Pan)) self.ser.write(chr(Buttons)) self.ser.write(chr(0)) self.ser.write(chr(255 - ((Xspeed+Rspeed+Tilt+Pan+Buttons)%256))) |
if self.port != None and self.curpose != "": print "Capturing pose..." errors = "could not read servos: " errCount = 0.0 dlg = wx.ProgressDialog("capturing pose","this may take a few seconds, please wait...",self.parent.project.count + 1) dlg.Update(1) for servo in range(self.parent.project.count): pos = self.port.getR... | if self.port != None: if self.curpose != "": print "Capturing pose..." errors = "could not read servos: " errCount = 0.0 dlg = wx.ProgressDialog("capturing pose","this may take a few seconds, please wait...",self.parent.project.count + 1) dlg.Update(1) for servo in range(self.parent.project.count): pos = self.port.getR... | def capturePose(self, e=None): """ Downloads the current pose from the robot to the GUI. """ if self.port != None and self.curpose != "": print "Capturing pose..." errors = "could not read servos: " errCount = 0.0 dlg = wx.ProgressDialog("capturing pose","this may take a few seconds, please wait...",self.parent.project... |
self.parent.sb.SetStatusText("captured pose!",0) dlg.Destroy() self.parent.project.save = True | self.parent.sb.SetBackgroundColour('RED') self.parent.sb.SetStatusText("Please Select a Pose",0) self.parent.timer.Start(20) | def capturePose(self, e=None): """ Downloads the current pose from the robot to the GUI. """ if self.port != None and self.curpose != "": print "Capturing pose..." errors = "could not read servos: " errCount = 0.0 dlg = wx.ProgressDialog("capturing pose","this may take a few seconds, please wait...",self.parent.project... |
if self.port != None and self.curpose != "": for servo in range(self.parent.project.count): self.parent.project.poses[self.curpose][servo] = self.servos[servo].position.GetValue() print "Setting pose..." if self.port.hasInterpolation == True: print "Setting pose size at " + str(self.parent.project.count) self.port.ex... | if self.port != None: if self.curpose != "": for servo in range(self.parent.project.count): self.parent.project.poses[self.curpose][servo] = self.servos[servo].position.GetValue() print "Setting pose..." if self.port.hasInterpolation == True: print "Setting pose size at " + str(self.parent.project.count) self.port.ex... | def setPose(self, e=None): """ Write a pose out to the robot. """ if self.port != None and self.curpose != "": # update pose in project for servo in range(self.parent.project.count): self.parent.project.poses[self.curpose][servo] = self.servos[servo].position.GetValue() print "Setting pose..." if self.port.hasInterpola... |
for servo in range(self.parent.project.count): pos = self.servos[servo].position.GetValue() self.port.setReg(servo+1, P_GOAL_POSITION_L, [pos%256, pos>>8]) self.parent.project.poses[self.curpose][servo] = self.servos[servo].position.GetValue() | self.parent.sb.SetBackgroundColour('RED') self.parent.sb.SetStatusText("Please Select a Pose",0) self.parent.timer.Start(20) | def setPose(self, e=None): """ Write a pose out to the robot. """ if self.port != None and self.curpose != "": # update pose in project for servo in range(self.parent.project.count): self.parent.project.poses[self.curpose][servo] = self.servos[servo].position.GetValue() print "Setting pose..." if self.port.hasInterpola... |
line = template[i][template[i].find("@IF")+3:].strip() | line = template[i][template[i].find("@IF")+3:].strip().rstrip() | def doExport(self, e=None): if self.doChecks(["project","ik"]) == 0: return else: # get directory name to save to dlg = wx.DirDialog(self,'Directory for Sketch Export' ) if dlg.ShowModal() == wx.ID_OK: skDir = dlg.GetPath() else: return print "Writing a NUKE sketch to:",skDir |
i = i + 1 | if template[i].find("@ELSE") >= 0: i = i + 1 | def doExport(self, e=None): if self.doChecks(["project","ik"]) == 0: return else: # get directory name to save to dlg = wx.DirDialog(self,'Directory for Sketch Export' ) if dlg.ShowModal() == wx.ID_OK: skDir = dlg.GetPath() else: return print "Writing a NUKE sketch to:",skDir |
self.append(line[0:line.index(",")].strip().rstrip().replace("|",",")) | self.append(line[0:line.index(",")].strip().rstrip()) | def __init__(self, line=None): # load the name, (pose,time) pairs for this sequence try: if line == None: return while True: if line.find(",") > 0: self.append(line[0:line.index(",")].strip().rstrip().replace("|",",")) elif line != "": self.append(line.strip().rstrip().replace("|",",")) line = line[line.index(",")+1:] ... |
self.append(line.strip().rstrip().replace("|",",")) | self.append(line.strip().rstrip()) | def __init__(self, line=None): # load the name, (pose,time) pairs for this sequence try: if line == None: return while True: if line.find(",") > 0: self.append(line[0:line.index(",")].strip().rstrip().replace("|",",")) elif line != "": self.append(line.strip().rstrip().replace("|",",")) line = line[line.index(",")+1:] ... |
print>>posefile, ",{" + t[0:t.find(",")] + "," + t[t.find(",")+1:] + "}", | print>>posefile, ",{" + t[0:t.find("|")] + "," + t[t.find("|")+1:] + "}", | print>>posefile, "#ifndef " + self.name.upper() + "_POSES" |
return | return if self.filename[-4:] != ".ppr": self.filename = self.filename + ".ppr" | def saveFile(self, e=None): """ Save a robot file from the GUI. """ if self.filename == "": dlg = wx.FileDialog(self, "Choose a file", self.dirname,"","*.ppr",wx.SAVE) if dlg.ShowModal() == wx.ID_OK: self.filename = dlg.GetPath() self.dirname = dlg.GetDirectory() dlg.Destroy() else: return self.project.saveFile(self.fi... |
Buttons = BUT_RT | Buttons = BUT_LT | def onTimer(self, event=None): # configure output Xspeed = self.forward + 128 Rspeed = self.turn + 128 Pan = self.pan.GetValue() + 128 Tilt = self.tilt.GetValue() + 128 Buttons = 0 if self.selStrafe.GetValue(): Buttons = BUT_RT #print Xspeed, Rspeed, Pan, Tilt self.sendPacket(Xspeed, Rspeed, Tilt, Pan, Buttons) self.... |
self.sendPacket(Xspeed, Rspeed, Tilt, Pan, Buttons) | self.sendPacket(Tilt, Pan, Xspeed, Rspeed, Buttons) | def onTimer(self, event=None): # configure output Xspeed = self.forward + 128 Rspeed = self.turn + 128 Pan = self.pan.GetValue() + 128 Tilt = self.tilt.GetValue() + 128 Buttons = 0 if self.selStrafe.GetValue(): Buttons = BUT_RT #print Xspeed, Rspeed, Pan, Tilt self.sendPacket(Xspeed, Rspeed, Tilt, Pan, Buttons) self.... |
self.default_config() | def read_file(self, file_path): if self.metadata['mime_type'] != 'text/plain': self.default_config() return | |
if (type(w), w.network, w.id) == (windowclass, network, id): | if (type(w).__name__, w.network, w.id) == (windowclass.__name__, network, id): | def get(windowclass, network, id, core): if network: id = network.norm_case(id) for w in core.manager: if (type(w), w.network, w.id) == (windowclass, network, id): return w |
win = purk.windows.new(windows.ChannelWindow, | win = purk.windows.new(purk.windows.ChannelWindow, | def read_file(self, file_path): if self.metadata['mime_type'] != 'text/plain': return |
win = purk.windows.new(windows.QueryWindow, | win = purk.windows.new(purk.windows.QueryWindow, | def read_file(self, file_path): if self.metadata['mime_type'] != 'text/plain': return |
_debugPrint('%s (%s)' % (self.temppath, self.tempfd)) | _debugPrint('tempfile: %s (fd %s)' % (self.temppath, self.tempfd)) | def on_record(self, *args): # Create temporary file (self.tempfd, self.temppath) = tempfile.mkstemp(prefix='%s-tmp.' % (NAME)) self.tempfile = os.fdopen(self.tempfd) _debugPrint('%s (%s)' % (self.temppath, self.tempfd)) # Adjust UI self.user_vox.set_sensitive(False) self.subject_vox.set_sensitive(False) self.close.set_... |
self.main_logo = self.builder.get_object('logo') self.main_logo.set_from_icon_name('pulsecaster', gtk.ICON_SIZE_DIALOG) self.main.set_icon_list(self.logo) | def __init__(self): self.builder = gtk.Builder() try: self.builder.add_from_file(os.path.join(os.getcwd(),'data','pulsecaster.glade') | |
if response == gtk.RESPONSE_NO: | if response == gtk.RESPONSE_YES: self._remove_tempfile(self.tempfile, self.temppath) else: | def hideFileChooser(self, *args): if not self.filesinkpath: confirm = gtk.MessageDialog(type=gtk.MESSAGE_WARNING, buttons=gtk.BUTTONS_YES_NO, message_format=_('Are you sure you want to cancel ' + 'saving your work? If you choose "Yes" ' + 'your audio recording will be erased ' + 'permanently.')) response = confirm.run(... |
print (text) | print ('%s: %s' % (NAME, text)) | def _debugPrint(text): if _debug: print (text) |
for karg in build_sh_spec['kargs'][0]: build_sh_options += ' -k "%s"'%karg | if len(build_sh_spec['kargs']) > 0: for karg in build_sh_spec['kargs'][0]: build_sh_options += ' -k "%s"'%karg | def build_command(self, node_type, build_sh_spec, node_image, type, floppy_file, log_file): |
def message_verbose(to_print=None): message(to_print,verbose_only=True) | def message_verbose(to_print=None, header='VERBOSE'): message("%s> %r"%(header,to_print),verbose_only=True) | def message_verbose(to_print=None): message(to_print,verbose_only=True) |
def sync(objects, peer_objects, classobj): | def sync(objects, peer_objects, classobj, columns): | def sync(objects, peer_objects, classobj): """ Synchronizes two dictionaries of objects. objects should be a dictionary of local objects keyed on their foreign identifiers. peer_objects should be a dictionary of foreign objects keyed on their local (i.e., foreign to us) identifiers. Returns a final dictionary of local ... |
message_verbose('Entering sync on %s'%classname) | primary_key=getattr(classobj,'primary_key') secondary_keys={'Node':'hostname','Slice':'name','Person':'email','Site':'login_base'} secondary_key=None if classname in secondary_keys: secondary_key=secondary_keys[classname] message_verbose('Entering sync on %s (%s)'%(classname,primary_key)) | def sync(objects, peer_objects, classobj): """ Synchronizes two dictionaries of objects. objects should be a dictionary of local objects keyed on their foreign identifiers. peer_objects should be a dictionary of foreign objects keyed on their local (i.e., foreign to us) identifiers. Returns a final dictionary of local ... |
message("%s %s %s deleted"%(peer['peername'],classname, object[object.primary_key])) | message("%s %s %s deleted"%(peer['peername'],classname, object[primary_key])) | def sync(objects, peer_objects, classobj): """ Synchronizes two dictionaries of objects. objects should be a dictionary of local objects keyed on their foreign identifiers. peer_objects should be a dictionary of foreign objects keyed on their local (i.e., foreign to us) identifiers. Returns a final dictionary of local ... |
trace_type="Node" trace_ids=[] def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) | def message_focus (message): if classname != focus_type: return if peer_object_id in focus_ids or \ (object and primary_key in object and object[primary_key] in focus_ids): message_verbose("peer_obj : %d [[%r]]"%(peer_object_id,peer_object), header='FOCUS '+message) if object: message_verbose("local_obj : <<%r>>"%(ob... | def sync(objects, peer_objects, classobj): """ Synchronizes two dictionaries of objects. objects should be a dictionary of local objects keyed on their foreign identifiers. peer_objects should be a dictionary of foreign objects keyed on their local (i.e., foreign to us) identifiers. Returns a final dictionary of local ... |
message_verbose ('DBG %s peer_object_id=%d (%d/%d)'%(classname,peer_object_id,count,total)) | peer_object_name="" if secondary_key: peer_object_name="(%s)"%peer_object[secondary_key] message_verbose ('%s peer_object_id=%d %s (%d/%d)'%(classname,peer_object_id,peer_object_name,count,total)) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
if classname == 'Node': message_verbose ('DBG>> hostname=%s'%peer_object['hostname']) elif classname == "Slice": message_verbose ('DBG>> slicename=%s'%peer_object['name']) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) | |
peer_object[object.primary_key] = object[object.primary_key] trace ("in objects : comparing") if not object.__eq__(peer_object): | peer_object[primary_key] = object[primary_key] if equal_fields(object,peer_object, columns): | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
trace ("updating") | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) | |
trace ("updated") | message_focus ("DIFFERENCES : updated / syncing") | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
dbg = "changed" | action = "changed" | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
trace ("intact") | message_focus ("UNCHANGED - left intact / not syncing") | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
dbg = None | action = None | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
peer_object[object.primary_key] = peer_object_id | peer_object[primary_key] = peer_object_id | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
trace ("not in objects -- creating") | object=None | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
trace ("created") | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) | |
del object[object.primary_key] trace ("forced clean id") | del object[primary_key] message_focus ("NEW -- created with clean id - syncing") | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
dbg = "added" | action = "added" | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
message_verbose("DBG>> syncing %s %d - commit_mode=%r"%(classname,peer_object_id,commit_mode)) | message_verbose("syncing %s %d - commit_mode=%r"%(classname,peer_object_id,commit_mode)) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
if dbg: message("%s: %s %d %s"%(peer['peername'], classname, object[object.primary_key], dbg)) | if action: message("%s: %s %d %s %s"%(peer['peername'], classname, object[primary_key], peer_object_name, action)) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
peer_sites = sync(old_peer_sites, sites_at_peer, Site) | peer_sites = sync(old_peer_sites, sites_at_peer, Site, columns) | def trace (message): if classname == trace_type and peer_object_id in trace_ids: message_verbose('TRACE>>'+message) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.