rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
Return a deep copy of the object. | Return a deep copy of the object. Monitor callbacks are not copied. | def copy(self): """ Return a deep copy of the object. """ return copy.deepcopy(self) |
if not callable(monitor): o._monitors.remove(monitor) continue | def _notify_monitors(self, oldval, newval): o = self name = self._get_fqname() or None while o: for monitor in o._monitors: if not callable(monitor): # Happens when deepcopying, callables don't get copied, # they become None. So remove them now. o._monitors.remove(monitor) continue monitor(name, oldval, newval) o = o.... | |
def copy(self): """ Make a deepcopy of the config. Reset the filename so we don't clobber the original config object's config file, and recreate the timers for the new object. """ copy = Group.copy(self) copy._filename = None copy._watch_timer = WeakTimer(copy._check_file_changed) copy._autosave_timer = WeakOneShotTim... | def __getstate__(self): state = super(Config, self).__getstate__() state['_filename'] = state['_inotify'] = None del state['_watch_timer'], state['_autosave_timer'] return state def __setstate__(self, state): self.__dict__.update(state) self._watch_timer = WeakTimer(self._check_file_changed) self._autosave_timer = ... | def copy(self): """ Make a deepcopy of the config. Reset the filename so we don't clobber the original config object's config file, and recreate the timers for the new object. """ copy = Group.copy(self) copy._filename = None copy._watch_timer = WeakTimer(copy._check_file_changed) copy._autosave_timer = WeakOneShotTim... |
fd = urllib2.urlopen(*self._args) | with auth_handler_lock: auth_handler.retried = 0 fd = urllib2.urlopen(*self._args) | def _fetch_thread(self, length): """ The real urllib2 calls in a thread. """ try: fd = urllib2.urlopen(*self._args) except urllib2.HTTPError, e: # FIXME: how to handle this. return e.code self.signals['header'].emit(fd.info()) if length and not len(self.signals['data']): # no callback connected, no need to read return ... |
src = urllib2.urlopen(url) length = int(src.info().get('Content-Length', 0)) | with auth_handler_lock: auth_handler.retried = 0 src = urllib2.urlopen(url) length = int(src.info().get('Content-Length', 0)) | def download(url, filename, tmpname, status): src = urllib2.urlopen(url) length = int(src.info().get('Content-Length', 0)) if not tmpname: tmpname = filename dst = open(tmpname, 'w') status.set(0, length) while True: data = src.read(1024) if len(data) == 0: src.close() dst.close() if length and os.stat(tmpname)[stat.ST... |
print(all_fixers) | def run_2to3(self, files): excludes = build_py.opts_2to3.get('exclude') nofix = build_py.opts_2to3.get('nofix') groups = {'all': files} for file in files[:]: # Strip 'build/lib.*/kaa/module/' from name. relfile = re.sub(r'build\/[^/]*\/kaa\/[^/]+\/', '', file) if excludes: for pattern in excludes: if fnmatch.fnmatch(re... | |
signal.signal(signal.SIGCHLD, self._sigchld_handler) | def __init__(self): self.processes = {} | |
try: | if sys.hexversion >= 0x02060000: | def __init__(self): self.processes = {} |
except AttributeError: try: import ctypes ctypes.CDLL("libc.so.6").siginterrupt(signal.SIGCHLD, 0) except (ImportError, OSError): raise SystemError('kaa.base requires Python 2.5 or later') | signal.signal(signal.SIGCHLD, self._sigchld_handler) elif sys.hexversion >= 0x02050000: import ctypes, ctypes.util libc = ctypes.util.find_library('c') signal.signal(signal.SIGCHLD, self._sigchld_handler) ctypes.CDLL(libc).siginterrupt(signal.SIGCHLD, 0) else: raise SystemError('kaa.base requires Python 2.5 or late... | def __init__(self): self.processes = {} |
``"threaded"``: Python based mainloop in an extra thread; | ``"thread"``: Python based mainloop in an extra thread; | def select_notifier(module, **options): """ Initialize the specified mainloop. :param module: the mainloop implementation to use. ``"generic"``: Python based mainloop, default; ``"gtk"``: pygtk mainloop; ``"threaded"``: Python based mainloop in an extra thread; ``"twisted"``: Twisted mainloop :type module: str :param ... |
copy._real_value = self._real_value if copy._cow_source is None else None | copy._real_value = self._value if copy._cow_source is None else None | def copy(self, copy_on_write=False): copy = super(Var, self).copy(copy_on_write) copy._type = self._type copy._real_value = self._real_value if copy._cow_source is None else None return copy |
self._value = self | self._cow_source = None | def _copy_children(self, source=None): source = source if source is not None else self._cow_source self._dict = dict((key, value.copy()) for (key, value) in source._dict.items()) for child in self._dict.values(): child._parent = self self._value = self |
self._value = self | self._cow_source = None | def _copy_children(self, source=None): source = source if source is not None else self._cow_source self._list = [item.copy() for item in source._list] for child in self._list: child._parent = self self._value = self |
import kaa._utils os.listdir = kaa._utils.listdir | from . import _utils os.listdir = _utils.listdir | def _activate(): """ Invoked when the first kaa object is accessed. Lets us do initial bootstrapping, like replace the buggy system os.listdir. """ if sys.hexversion < 0x02060000 and os.name == 'posix': # Python 2.5 (all point releases) have a bug with listdir on POSIX # systems causing improper out of memory exceptio... |
sql = """select groups.*, picture.* from groups, picture where category = ? and groups.jobject_id = picture.jobject_id order by seq""" | sql = """select groups.*, picture.* from groups, picture where groups.category = ? and groups.jobject_id = picture.jobject_id order by groups.seq""" | def get_album_thumbnails(self,album_id,is_journal=False): if is_journal: #is_journal: #want most recent first, need left join because picture may not exist yet #sql = """select groups.*, data_cache.picture.* from groups left join data_cache.picture \ #where groups.category = ? and groups.jobject_id = data_cache.pictu... |
matrix *= orientation | matrix *= orientation.get_matrix() | def add(self, shape, position=(0, 0, 0), orientation=None): matrix = Matrix4.new_translate(*position) if orientation is not None: matrix *= orientation |
self.assertEqual(XAxis.rotate(XAxis, pi/2), XAxis) self.assertEqual(YAxis.rotate(XAxis, pi/2), NegZAxis) self.assertEqual(ZAxis.rotate(XAxis, pi/2), YAxis) | self.assertEqual(x_axis.rotate(x_axis, pi/2), x_axis) self.assertEqual(y_axis.rotate(x_axis, pi/2), neg_z_axis) self.assertEqual(z_axis.rotate(x_axis, pi/2), y_axis) | def testRotate(self): self.assertEqual(XAxis.rotate(XAxis, pi/2), XAxis) self.assertEqual(YAxis.rotate(XAxis, pi/2), NegZAxis) self.assertEqual(ZAxis.rotate(XAxis, pi/2), YAxis) |
self.assertEqual(XAxis.rotate(YAxis, pi/2), ZAxis) self.assertEqual(YAxis.rotate(YAxis, pi/2), YAxis) self.assertEqual(ZAxis.rotate(YAxis, pi/2), NegXAxis) | self.assertEqual(x_axis.rotate(y_axis, pi/2), z_axis) self.assertEqual(y_axis.rotate(y_axis, pi/2), y_axis) self.assertEqual(z_axis.rotate(y_axis, pi/2), neg_x_axis) | def testRotate(self): self.assertEqual(XAxis.rotate(XAxis, pi/2), XAxis) self.assertEqual(YAxis.rotate(XAxis, pi/2), NegZAxis) self.assertEqual(ZAxis.rotate(XAxis, pi/2), YAxis) |
self.assertEqual(XAxis.rotate(ZAxis, pi/2), NegYAxis) self.assertEqual(YAxis.rotate(ZAxis, pi/2), XAxis) self.assertEqual(ZAxis.rotate(ZAxis, pi/2), ZAxis) | self.assertEqual(x_axis.rotate(z_axis, pi/2), neg_y_axis) self.assertEqual(y_axis.rotate(z_axis, pi/2), x_axis) self.assertEqual(z_axis.rotate(z_axis, pi/2), z_axis) | def testRotate(self): self.assertEqual(XAxis.rotate(XAxis, pi/2), XAxis) self.assertEqual(YAxis.rotate(XAxis, pi/2), NegZAxis) self.assertEqual(ZAxis.rotate(XAxis, pi/2), YAxis) |
friend = y_axis if orig != y_axis else x_axis | assert orig != origin if abs(orig.x) < abs(orig.y): friend = x_axis else: friend = y_axis | def any_orthogonal(orig): ''' return any unit vector at right angles to the given vector ''' # friend = any vector at all, so long as it isn't == orig friend = y_axis if orig != y_axis else x_axis return orig.cross(friend).normalize() |
elif len(content): | elif len(topic): | def post(self, room_key): user = users.get_current_user() sender = Account.all().filter('user =', user).get() room = Room.all().filter('__key__ =', Key(room_key)).get() topic = self.request.get('topic') timestamp = datetime.now() #content = self.request.get('message') payload = {} if not sender: # no account for this u... |
message = Message(sender=sender, room=room, timestamp=timestamp, content=content, | message = Message(sender=sender, room=room, timestamp=timestamp, content=topic, | def post(self, room_key): user = users.get_current_user() sender = Account.all().filter('user =', user).get() room = Room.all().filter('__key__ =', Key(room_key)).get() topic = self.request.get('topic') timestamp = datetime.now() #content = self.request.get('message') payload = {} if not sender: # no account for this u... |
event=Message_event_codes['upload'], content="http://localhost.com:8080/room/" + str(room_key) + "/download/" + blob_info.key(), extra=str(blob_info.key)) | event=Message_event_codes['upload'], content="http://localhost.com:8080/room/" + str(room_key) + "/download/" + str(blob_info.key()), extra=str(blob_info.key)) | def post(self, room_key): upload_files = self.get_uploads('file') blob_info = upload_files[0] timestamp = datetime.now() account = get_account() room = Room.all().filter('__key__ =', Key(room_key)).get() message = Message(sender=account, room=room, timestamp=timestamp, event=Message_event_codes['upload'], content="http... |
self.response.out.write('{success:true}') | self.redirect('/room/' + str(room_key) +'/upload/%s/success' % blob_info.key()) class UploadSuccessHandler(webapp.RequestHandler): def get(self, room_key, file_id): self.response.headers['Content-Type'] = 'text/plain' self.response.out.write('%s/room/download/%s' % (self.request.host_url, file_id)) | def post(self, room_key): upload_files = self.get_uploads('file') blob_info = upload_files[0] timestamp = datetime.now() account = get_account() room = Room.all().filter('__key__ =', Key(room_key)).get() message = Message(sender=account, room=room, timestamp=timestamp, event=Message_event_codes['upload'], content="http... |
size=10 | size=30 | def gravatar(email): size=10 rating='g' default_image='' gravatar_url = "http://www.gravatar.com/avatar/" gravatar_url += hashlib.md5(email).hexdigest() gravatar_url += urllib.urlencode({'s':str(size), 'r':rating, 'd':default_image}) return """<img src="%s" alt="gravatar" />""" % gravatar_url |
gravatar_url = "http://www.gravatar.com/avatar/" gravatar_url += hashlib.md5(email).hexdigest() gravatar_url += urllib.urlencode({'s':str(size), | gravatar_url = "http://www.gravatar.com/avatar.php?" gravatar_url += urllib.urlencode({ 'gravatar_id':hashlib.md5(email).hexdigest(), 's':str(size), | def gravatar(email): size=10 rating='g' default_image='' gravatar_url = "http://www.gravatar.com/avatar/" gravatar_url += hashlib.md5(email).hexdigest() gravatar_url += urllib.urlencode({'s':str(size), 'r':rating, 'd':default_image}) return """<img src="%s" alt="gravatar" />""" % gravatar_url |
messages = reversed(Message.all().order('-timestamp').fetch(40)) | messages = reversed(Message.all().filter('room =', room).order('-timestamp').fetch(40)) | def get(self, room_key): room = Room.all().filter('__key__ =', Key(room_key)).get() if not room: # room doesn't exist self.error(404) self.response.out.write("no such room") else: account = get_account() roomlist = RoomList.all().filter('account =', account).filter('room =', room).get() roomlist.update_presence() since... |
messages = reversed(Message.all().filter('room =', room).order('-timestamp').fetch(70)) | messages = [m for m in reversed(Message.all().filter('room =', room).order('-timestamp').fetch(70))] if messages: next_url = 'room/%s/msg/?since=%s' % (room.key(), messages[-1].key()) else: next_url = 'room/%s/msg/' % (room.key()) | def get(self, room_key): room = Room.all().filter('__key__ =', Key(room_key)).get() if not room: # room doesn't exist self.error(404) self.response.out.write("no such room") else: account = get_account() roomlist = RoomList.all().filter('account =', account).filter('room =', room).get() roomlist.update_presence() since... |
payload = {'response_status' : "OK", 'message' : content, 'timestamp' : timestamp} | payload = {'response_status' : "OK", 'message' : content, 'timestamp' : timestamp.isoformat()} | def post(self, room_key): user = users.get_current_user() sender = Account.all().filter('user =', user).get() room = Room.all().filter('__key__ =', Key(room_key)).get() timestamp = datetime.now() content = self.request.get('message') payload = {} if not sender: # no account for this user payload = {'response_status' : ... |
reply_version = struct.unpack('H', reply.payload[20:22])[0] | def get_single_task_stats(self, thread): thread.task_stats_request.send(self.connection) try: reply = self.connection.recv() except OSError, e: if e.errno == errno.ESRCH: # OSError: Netlink error: No such process (3) return raise if len(reply.payload) < 292: # Short reply return reply_data = reply.payload[20:] | |
assert reply_type == TASKSTATS_CMD_ATTR_PID + 3 assert reply_version >= 4 return Stats(reply_data) | assert reply_type == TASKSTATS_TYPE_AGGR_PID pid_length, pid_type = struct.unpack('HH', reply.payload[8:12]) assert pid_type == TASKSTATS_TYPE_PID taskstats_start = 4 + 4 + pid_length + 4 taskstats_data = reply.payload[taskstats_start:] taskstats_version = struct.unpack('H', taskstats_data[:2])[0] assert taskstats_ve... | def get_single_task_stats(self, thread): thread.task_stats_request.send(self.connection) try: reply = self.connection.recv() except OSError, e: if e.errno == errno.ESRCH: # OSError: Netlink error: No such process (3) return raise if len(reply.payload) < 292: # Short reply return reply_data = reply.payload[20:] |
self.win.insstr(i + 2, 0, lines[i].encode('utf-8')) | self.win.addstr(i + 2, 0, lines[i].encode('utf-8')) | def refresh_display(self, first_time, total_read, total_write, duration): summary = 'Total DISK READ: %s | Total DISK WRITE: %s' % ( format_bandwidth(self.options, total_read, duration), format_bandwidth(self.options, total_write, duration)) if self.options.processes: pid = ' PID' else: pid = ' TID' titles = [pid, ' ... |
def boolean2string(boolean): return boolean and 'Found' or 'Not found' | def boolean2string(boolean): return boolean and 'Found' or 'Not found' | |
print '- Linux >= 2.6.20 with I/O accounting support ' \ '(CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, ' \ 'CONFIG_TASK_IO_ACCOUNTING):', boolean2string(ioaccounting) print '- Python >= 2.5 or Python 2.4 with the ctypes module:', \ boolean2string(has_ctypes) | if not ioaccounting: print '- Linux >= 2.6.20 with I/O accounting support ' \ '(CONFIG_TASKSTATS, CONFIG_TASK_DELAY_ACCT, ' \ 'CONFIG_TASK_IO_ACCOUNTING)' if not has_ctypes: print '- Python >= 2.5 or Python 2.4 with the ctypes module' | def boolean2string(boolean): return boolean and 'Found' or 'Not found' |
def open(self, version=None, transaction_manager=None): | def open(self, version=None, before=None, transaction_manager=None): | def open(self, version=None, transaction_manager=None): if version: raise ValueError("Versions are not supported by this database.") m = ConnectionManager(self, self.database_name) m.open(transaction_manager) return m |
m = ConnectionManager(self, self.database_name) | if before: raise ValueError("I don't know what to do with 'before' argument.") m = PGConnectionManager(self, self.database_name) | def open(self, version=None, transaction_manager=None): if version: raise ValueError("Versions are not supported by this database.") m = ConnectionManager(self, self.database_name) m.open(transaction_manager) return m |
if hasattr(mapnik,'mapnik_version') and mapnik.mapnik_version() >= 700: | if hasattr(mapnik,'mapnik_version') and mapnik.mapnik_version() >= 800: | def render_tile(self, tile_uri, x, y, z): # Calculate pixel positions of bottom-left & top-right p0 = (x * 256, (y + 1) * 256) p1 = ((x + 1) * 256, y * 256) |
pattern = '<ul class="sli.*\r\n(.*\r\n)+? +</ul>' | pattern = '<ul class="sli.*>\r\n(.*\r\n)+? +</ul>' | def getTopSongs(params): items = [] f = urllib.urlopen(params['url']) data = f.read() pattern = '<ul class="sli.*\r\n(.*\r\n)+? +</ul>' matches = re.finditer(pattern, data) i = int(params['group']) * 100 for match in matches: item = xbmcgui.ListItem() pattern = '<li class="l5"><a href="javascript:.*openPlayer\(\'(.+)\'... |
pattern = '<li class="l5"><a href="javascript:.*openPlayer\(\'(.+)\'\);".*>\r\n +(.+)</a>' | pattern = '<li class="l5"><a href="javascript:.*openPlayer\(\'(.+)\'\);".*\r\n( +title=".+">\r\n)? +(.+)</a>' | def getTopSongs(params): items = [] f = urllib.urlopen(params['url']) data = f.read() pattern = '<ul class="sli.*\r\n(.*\r\n)+? +</ul>' matches = re.finditer(pattern, data) i = int(params['group']) * 100 for match in matches: item = xbmcgui.ListItem() pattern = '<li class="l5"><a href="javascript:.*openPlayer\(\'(.+)\'... |
title = m1.group(2).strip() | title = m1.group(3).strip() | def getTopSongs(params): items = [] f = urllib.urlopen(params['url']) data = f.read() pattern = '<ul class="sli.*\r\n(.*\r\n)+? +</ul>' matches = re.finditer(pattern, data) i = int(params['group']) * 100 for match in matches: item = xbmcgui.ListItem() pattern = '<li class="l5"><a href="javascript:.*openPlayer\(\'(.+)\'... |
print '==================================', sys.argv[0] | def parseParams(str): result = {} if not str: result['cmd'] = 'listdir' result['type'] = 'root' return result for param in str[1:].split('&'): key = param.split('=')[0] value = param.split('=')[1] result[key] = value return result | |
metadata.add_image("image/jpeg", "JFIFfoobar") | jpegFakeData = "JFIF" + ("a" * 1024 * 128) metadata.add_image("image/jpeg", jpegFakeData) | def _test_cover_art(self, filename): self._set_up(filename) try: f = picard.formats.open(self.filename) # f.metadata.clear() # f.metadata.add_image("image/jpeg", "JFIFfoobar") metadata = Metadata() metadata.add_image("image/jpeg", "JFIFfoobar") f._save(self.filename, metadata, f.config.setting) |
self.assertEqual(metadata.images[0][1], "JFIFfoobar") | self.assertEqual(metadata.images[0][1], jpegFakeData) | def _test_cover_art(self, filename): self._set_up(filename) try: f = picard.formats.open(self.filename) # f.metadata.clear() # f.metadata.add_image("image/jpeg", "JFIFfoobar") metadata = Metadata() metadata.add_image("image/jpeg", "JFIFfoobar") f._save(self.filename, metadata, f.config.setting) |
Moves the specified prefixes to the end of x. | Moves the specified prefixes to the end of text. | def swapprefix(parser, text, *prefixes): """ Moves the specified prefixes to the end of x. If no prefix is specified 'A' and 'The' are taken as default. """ if not prefixes: prefixes = ('A', 'The') for prefix in prefixes: pattern = re.compile('^' + prefix + '\s') match = pattern.match(text) if match: rest = pattern.spl... |
pattern = re.compile('^' + prefix + '\s') | pattern = re.compile('^' + re.escape(prefix) + '\s') | def swapprefix(parser, text, *prefixes): """ Moves the specified prefixes to the end of x. If no prefix is specified 'A' and 'The' are taken as default. """ if not prefixes: prefixes = ('A', 'The') for prefix in prefixes: pattern = re.compile('^' + prefix + '\s') match = pattern.match(text) if match: rest = pattern.spl... |
'engineer': 'WM/Producer', | 'producer': 'WM/Producer', | def pack_image(mime, data, type=3, description=""): """ Helper function to pack image data for a WM/Picture tag. See unpack_image for a description of the data format. """ tag_data = struct.pack("<bi", type, len(data)) tag_data += mime.encode("utf-16-le") + "\x00\x00" tag_data += description.encode("utf-16-le") + "\x00... |
self.failUnlessEqual(util.replace_win32_incompat("c:\\test\\te\"st2"), "c__test_te_st2") | self.failUnlessEqual(util.replace_win32_incompat("c:\\test\\te\"st/2"), "c_\\test\\te_st/2") self.failUnlessEqual(util.replace_win32_incompat("A\"*:<>?|b"), "A_______b") | def test_correct(self): self.failUnlessEqual(util.replace_win32_incompat("c:\\test\\te\"st2"), "c__test_te_st2") |
name.append(rel.releasecountry) | try: name.append(RELEASE_COUNTRIES[rel.releasecountry]) except KeyError: name.append(rel.releasecountry) | def contextMenuEvent(self, event): item = self.itemAt(event.pos()) if not item: return obj = self.panel.object_from_item(item) |
except (KeyError): name.append(rel.format) | except KeyError: name.append(rel.format) | def contextMenuEvent(self, event): item = self.itemAt(event.pos()) if not item: return obj = self.panel.object_from_item(item) |
if result is None or error is not None: | if result is None or result[0] is None or error is not None: | def _lookup_fingerprint(self, next, filename, result=None, error=None): try: file = self.tagger.files[filename] except (KeyError): # The file has been removed. do nothing return if result is None or error is not None: next(file, result=None) return fingerprint, length = result self.tagger.window.set_statusbar_message(... |
log.debug("window '%s' bottom" % repr(self)) | def bottom(self): """ bring window to bottom""" try: self.panel.bottom() except: pass else: log.debug("window '%s' bottom" % repr(self)) hub.notify(events.focuschanged()) | |
log.debug("window '%s' top" % repr(self)) | def top(self): """ bring window to top""" try: self.panel.top() # The following call fixes the redrawing problem when switching between # the filelist and the playlist window reported by Dag Wieers. curses.panel.update_panels() except: pass else: log.debug("window '%s' top" % repr(self)) hub.notify(events.focuschanged(... | |
log.debug("window '%s' hide" % repr(self)) | def hide(self): """ hide window """ try: self.panel.hide() except: pass else: log.debug("window '%s' hide" % repr(self)) hub.notify(events.focuschanged()) | |
s = sock.getsockopt (SOL_L2CAP, L2CAP_OPTIONS, 7) o,i,f,m = struct.unpack ("HHHB", s) s = struct.pack ("HHHB", mtu, mtu, f, m) sock.setsockopt (SOL_L2CAP, L2CAP_OPTIONS, s) | options = get_l2cap_options (sock) options[0] = options[1] = mtu set_l2cap_options (sock, options) | def set_l2cap_mtu (sock, mtu): """set_l2cap_mtu (sock, mtu) Adjusts the MTU for the specified L2CAP socket. This method needs to be invoked on both sides of the connection for it to work! The default mtu that all L2CAP connections start with is 672 bytes. mtu must be between 48 and 65535, inclusive. """ s = sock.ge... |
"constructor; optionally pass an author name" | def __init__ (self, author = 'twee'): "constructor; optionally pass an author name" self.author = author self.tiddlers = {} | |
def try_getting (self, names, default = ''): "tries retrieving the text of several tiddlers by name; returns default if none exist" | def tryGetting (self, names, default = ''): """Tries retrieving the text of several tiddlers by name; returns default if none exist.""" | def __init__ (self, author = 'twee'): "constructor; optionally pass an author name" self.author = author self.tiddlers = {} |
def to_twee (self): "returns Twee source code for this TiddlyWiki" | def toTwee (self, order = None): """Returns Twee source code for this TiddlyWiki.""" if not order: order = self.tiddlers.keys() | def try_getting (self, names, default = ''): "tries retrieving the text of several tiddlers by name; returns default if none exist" for name in names: if name in self.tiddlers: return self.tiddlers[name].text return default |
for i in self.tiddlers: output += self.tiddlers[i].to_twee() return output def to_html (self): "returns HTML code for this TiddlyWiki" | for i in order: output += self.tiddlers[i].toTwee() return output def toHtml (self, app, target = None, order = None): """Returns HTML code for this TiddlyWiki. If target is passed, adds a header.""" if not order: order = self.tiddlers.keys() | def to_twee (self): "returns Twee source code for this TiddlyWiki" output = '' for i in self.tiddlers: output += self.tiddlers[i].to_twee() return output |
for i in self.tiddlers: output += self.tiddlers[i].to_html(self.author) return output def to_rss (self, num_items = 5): "returns an RSS2 object of recently changed tiddlers" | if (target): header = open(app.getPath() + os.sep + 'targets' + os.sep + target + os.sep + 'header.html') output = header.read() header.close() for i in order: output += self.tiddlers[i].toHtml(self.author) if (target): output += '</div></body></html>' return output def toRtf (self, order = None): """Returns RTF so... | def to_html (self): "returns HTML code for this TiddlyWiki" output = '' for i in self.tiddlers: output += self.tiddlers[i].to_html(self.author) return output |
rss_items.append(self.tiddlers[i].to_rss()) | rss_items.append(self.tiddlers[i].toRss()) | def to_rss (self, num_items = 5): "returns an RSS2 object of recently changed tiddlers" url = self.try_getting(['StoryUrl', 'SiteUrl']) title = self.try_getting(['StoryTitle', 'SiteTitle'], 'Untitled Story') subtitle = self.try_getting(['StorySubtitle', 'SiteSubtitle']) # build a date-sorted list of tiddler titles so... |
def add_twee (self, source): "converts Twee source code to tiddlers in this TiddlyWiki" | def addTwee (self, source): """Adds Twee source code to this TiddlyWiki.""" | def to_rss (self, num_items = 5): "returns an RSS2 object of recently changed tiddlers" url = self.try_getting(['StoryUrl', 'SiteUrl']) title = self.try_getting(['StoryTitle', 'SiteTitle'], 'Untitled Story') subtitle = self.try_getting(['StorySubtitle', 'SiteSubtitle']) # build a date-sorted list of tiddler titles so... |
self.add_tiddler(Tiddler('::' + i)) def add_html (self, source): "converts HTML source code to tiddlers in this TiddlyWiki" | self.addTiddler(Tiddler('::' + i)) def addHtml (self, source): """Adds HTML source code to this TiddlyWiki.""" | def add_twee (self, source): "converts Twee source code to tiddlers in this TiddlyWiki" source = source.replace("\r\n", "\n") tiddlers = source.split('\n::') for i in tiddlers: self.add_tiddler(Tiddler('::' + i)) |
self.add_tiddler(Tiddler('<div' + div, 'html')) def add_tiddler (self, tiddler): "adds a tiddler to this TiddlyWiki" | self.addTiddler(Tiddler('<div' + div, 'html')) def addTiddler (self, tiddler): """Adds a Tiddler object to this TiddlyWiki.""" | def add_html (self, source): "converts HTML source code to tiddlers in this TiddlyWiki" divs_re = re.compile(r'<div id="storeArea">(.*)</div>\s*</html>', re.DOTALL) divs = divs_re.search(source) |
"represents a single tiddler in a TiddlyWiki" | def add_tiddler (self, tiddler): "adds a tiddler to this TiddlyWiki" if tiddler.title in self.tiddlers: if (tiddler == self.tiddlers[tiddler.title]) and \ (tiddler.modified > self.tiddlers[tiddler.title].modified): self.tiddlers[tiddler.title] = tiddler else: self.tiddlers[tiddler.title] = tiddler | |
"constructor; pass source code, and optionally 'twee' or 'html'" | def __init__ (self, source, type = 'twee'): "constructor; pass source code, and optionally 'twee' or 'html'" if type == 'twee': self.init_twee(source) else: self.init_html(source) | |
self.init_twee(source) | self.initTwee(source) | def __init__ (self, source, type = 'twee'): "constructor; pass source code, and optionally 'twee' or 'html'" if type == 'twee': self.init_twee(source) else: self.init_html(source) |
self.init_html(source) | self.initHtml(source) def __repr__ (self): return "<Tiddler '" + self.title + "'>" | def __init__ (self, source, type = 'twee'): "constructor; pass source code, and optionally 'twee' or 'html'" if type == 'twee': self.init_twee(source) else: self.init_html(source) |
"compares a Tiddler to another" | def __cmp__ (self, other): "compares a Tiddler to another" return self.text == other.text | |
def init_twee (self, source): "initializes a Tiddler from Twee source code" | def initTwee (self, source): """Initializes a Tiddler from Twee source code.""" | def __cmp__ (self, other): "compares a Tiddler to another" return self.text == other.text |
def init_html (self, source): "initializes a Tiddler from HTML source code" | def initHtml (self, source): """Initializes a Tiddler from HTML source code.""" | def init_html (self, source): "initializes a Tiddler from HTML source code" # title self.title = 'untitled passage' title_re = re.compile(r'tiddler="(.*?)"') title = title_re.search(source) if title: self.title = title.group(1) # tags self.tags = [] tags_re = re.compile(r'tags="(.*?)"') tags = tags_re.search(source... |
def to_html (self, author = 'twee'): "returns an HTML representation of this tiddler" | def toHtml (self, author = 'twee'): """Returns an HTML representation of this tiddler.""" | def to_html (self, author = 'twee'): "returns an HTML representation of this tiddler" now = time.localtime() output = '<div tiddler="' + self.title + '" tags="' for tag in self.tags: output += tag + ' ' output = output.strip() output += '" modified="' + encode_date(self.modified) + '"' output += ' created="' + encod... |
def to_twee (self): "returns a Twee representation of this tiddler" | def toTwee (self): """Returns a Twee representation of this tiddler.""" | def to_twee (self): "returns a Twee representation of this tiddler" output = ':: ' + self.title if len(self.tags) > 0: output += ' [' for tag in self.tags: output += tag + ' ' output = output.trim() output += "\n" + self.text + "\n\n\n" return output |
output = output.trim() | output = output.strip() output += ']' | def to_twee (self): "returns a Twee representation of this tiddler" output = ':: ' + self.title if len(self.tags) > 0: output += ' [' for tag in self.tags: output += tag + ' ' output = output.trim() output += "\n" + self.text + "\n\n\n" return output |
def to_rss (self, author = 'twee'): "returns an RSS representation of this tiddler" | def toRss (self, author = 'twee'): """Returns an RSS representation of this tiddler.""" | def to_rss (self, author = 'twee'): "returns an RSS representation of this tiddler" return rss.RSSItem( title = self.title, link = '', description = self.text, pubDate = datetime.datetime.now() ) |
def links (self, includeExternal = False): """ Returns a list of all passages linked to by this one. By default, only returns internal links, but you can override it with the includeExternal parameter. """ links = re.findall(r'\[\[(.+?)\]\]', self.text) def filterPrettyLinks (text): if '|' in text: return re.sub(... | def to_rss (self, author = 'twee'): "returns an RSS representation of this tiddler" return rss.RSSItem( title = self.title, link = '', description = self.text, pubDate = datetime.datetime.now() ) | |
output = output.replace('\n', '\\n') | output = re.sub(r'\r?\n', r'\\n', output) | def encode_text (text): output = text output = output.replace('\\', '\s') output = output.replace('\n', '\\n') output = output.replace('<', '<') output = output.replace('>', '>') output = output.replace('"', '"') return output |
actions = actions or self.topo_actions | if not actions: self.runs.appendleft(job_run) actions = self.topo_actions self.remove_old_runs() | def build_run(self, node=None, actions=None, run_num=None): job_run = JobRun(self, run_num=run_num) job_run.node = node or self.node_pool.next() |
self.runs.appendleft(job_run) self.remove_old_runs() | def build_run(self, node=None, actions=None, run_num=None): job_run = JobRun(self, run_num=run_num) job_run.node = node or self.node_pool.next() | |
def _apply(self): real_job = self._ref() node = default_or_from_tag(self.node, Node) | def _match_node(self, real_job, node_conf): node = default_or_from_tag(node_conf, Node) | def _match_actions(self, real_job, actions): for action_conf in actions: action = default_or_from_tag(action_conf, Action) real_action = action.actualized |
def _apply(self): real_job = self._ref() | def _apply(self): real_job = self._ref() node = default_or_from_tag(self.node, Node) | |
real_service.node_pool = self.node.actualized | def _apply(self): real_service = self._ref() real_service.node_pool = self.node.actualized self._match_name(real_service, self.name) self._match_schedule(real_service, self.monitor['schedule']) self._match_actions(real_service, self.monitor['actions']) | |
days = self.wait_days[job.runs[0].run_time.weekday()] | next_day = job.runs[0].run_time + self.wait_days[job.runs[0].run_time.weekday()] | def next_runs(self, job): # Find the next time to run if job.runs: days = self.wait_days[job.runs[0].run_time.weekday()] else: days = self.wait_days[timeutils.current_time().weekday()] |
days = self.wait_days[timeutils.current_time().weekday()] | next_day = timeutils.current_time() + self.wait_days[timeutils.current_time().weekday()] | def next_runs(self, job): # Find the next time to run if job.runs: days = self.wait_days[job.runs[0].run_time.weekday()] else: days = self.wait_days[timeutils.current_time().weekday()] |
run_time = (timeutils.current_time() + datetime.timedelta(days=days)).replace( hour=self.start_time.hour, minute=self.start_time.minute, second=self.start_time.second) | run_time = next_day.replace( hour=self.start_time.hour, minute=self.start_time.minute, second=self.start_time.second) | def next_runs(self, job): # Find the next time to run if job.runs: days = self.wait_days[job.runs[0].run_time.weekday()] else: days = self.wait_days[timeutils.current_time().weekday()] |
self.state_handler.writing_enabled = False | self.state_handler.writing_enabled = True | def run_jobs(self): """This schedules the first time each job runs""" if os.path.isfile(self.state_handler.get_state_file_path()): self.state_handler.load_data() |
def action_state_filter(topo_action): | def action_filter(topo_action): | def action_state_filter(topo_action): return topo_action.name in action_names |
log.info("Received data for action %s: writing to %s", run.action.name, run.stdout_file.name) | log.debug("Received data for action %s: writing to %s", run.action.name, run.stdout_file.name) | def callback(data): if run.stdout_file: log.info("Received data for action %s: writing to %s", run.action.name, run.stdout_file.name) run.stdout_file.write(data) run.stdout_file.flush() |
log.error("Received stderr data for action %s: %s", run.action.name, data) | log.debug("Received stderr data for action %s: %s", run.action.name, data) | def callback(data): log.error("Received stderr data for action %s: %s", run.action.name, data) if run.stderr_file: log.error("Writing error to %s", run.stderr_file.name) run.stderr_file.write(data) run.stderr_file.flush() |
log.error("Writing error to %s", run.stderr_file.name) | log.debug("Writing error to %s", run.stderr_file.name) | def callback(data): log.error("Received stderr data for action %s: %s", run.action.name, data) if run.stderr_file: log.error("Writing error to %s", run.stderr_file.name) run.stderr_file.write(data) run.stderr_file.flush() |
log.info("Channel closed: closing output file %s", run.stdout_file.name) | log.debug("Channel closed: closing output file %s", run.stdout_file.name) | def callback(): if run.stdout_file: log.info("Channel closed: closing output file %s", run.stdout_file.name) run.stdout_file.close() if run.stderr_file: run.stderr_file.close() |
def test_add_action(self): assert_equal(len(self.mcp.actions), 0) assert_equal(len(self.mcp.nodes), 0) assert_equal(len(self.mcp.actions), 0) self.mcp.add_job(self.job) assert_equal(len(self.mcp.actions), 1) assert_equal(self.mcp.actions[self.action.name], self.action) assert_equal(len(self.mcp.nodes), 1) assert_equa... | def test_add_action(self): assert_equal(len(self.mcp.actions), 0) assert_equal(len(self.mcp.nodes), 0) assert_equal(len(self.mcp.actions), 0) | |
self.mcp._schedule_next_run(jo) | self.mcp.schedule_next_run(jo) | def call_now(time, func, next): next.start() next.runs[0].succeed() |
self.job.runs.append(next_run) next_run2 = self.scheduler.next_run(self.job) assert_equal(next_run2.run_time - next_run.run_time, self.interval) | def test_next_run(self): next_run = self.scheduler.next_run(self.job) assert_gte(datetime.datetime.now() + self.interval, next_run.run_time) self.job.runs.append(next_run) next_run2 = self.scheduler.next_run(self.job) assert_equal(next_run2.run_time - next_run.run_time, self.interval) | |
self.prev.waiting.append(self) | if self.prev: self.prev.waiting.append(self) | def restore_state(self, state): self.state = state['state'] self.run_time = state['run_time'] self.start_time = state['start_time'] |
assert not jr.runs[1].run_time | assert_equal(jr.runs[1].run_time, time) | def test_set_run_time(self): jr = self.job.next_runs()[0] time = timeutils.current_time() jr.set_run_time(time) |
run = self.restore_run(data, self.topo_actions) | action_names = [] for action in data['runs']: action_names.append(action['id'].split('.')[-1]) def action_state_filter(topo_action): return topo_action.name in action_names run = self.restore_run(data, action_list) | def restore_main_run(self, data): run = self.restore_run(data, self.topo_actions) self.runs.append(run) if run.is_success and not self.last_success: self.last_success = run return run |
'run_num': 5, | 'run_num': run_num, | def test_restore_main_run(self): state_data = \ {'end_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 234159), 'run_num': 5, 'run_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 125149), 'runs': [{'command': 'free', 'end_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 232693), 'id': 'job.5.free_memory', 'run_time... |
'runs': [{'command': 'free', | 'runs': [{'command': act1.command, | def test_restore_main_run(self): state_data = \ {'end_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 234159), 'run_num': 5, 'run_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 125149), 'runs': [{'command': 'free', 'end_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 232693), 'id': 'job.5.free_memory', 'run_time... |
'id': 'job.5.free_memory', | 'id': act1_id, | def test_restore_main_run(self): state_data = \ {'end_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 234159), 'run_num': 5, 'run_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 125149), 'runs': [{'command': 'free', 'end_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 232693), 'id': 'job.5.free_memory', 'run_time... |
{'command': 'who', | {'command': act3.command, | def test_restore_main_run(self): state_data = \ {'end_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 234159), 'run_num': 5, 'run_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 125149), 'runs': [{'command': 'free', 'end_time': datetime.datetime(2010, 12, 13, 15, 32, 3, 232693), 'id': 'job.5.free_memory', 'run_time... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.