rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
self.config = config | self._config = config | def setConfig(self, config): """Sets the connector configuration. |
return self.schedule | return self._schedule | def getSchedule(self): """Returns the raw XML schedule data.""" return self.schedule |
self.schedule = schedule | self._schedule = schedule | def setSchedule(self, schedule): """Sets the connector schedule. |
return self.data | return self._data | def getData(self): """Returns stored data.""" return self.data |
self.data = data | self._data = data | def setData(self, data): """Sets the data storage object. |
return self.getScheduleParam('load') | return int(self.getScheduleParam('load')) | def getLoad(self): """Returns the current load setting (docs to traverse per min). |
delay = '300000' return delay | return 300000 return int(delay) | def getRetryDelay(self): """Returns the retry delay.""" delay = self.getScheduleParam('RetryDelayMillis') # it seems that the delay isn't provided when a connector is first created, # so we have to provide a default value if not delay: delay = '300000' return delay |
L.append(self.name) | L.append(self._name) | def encode_multipart_formdata(xmldata): BOUNDARY = '<<' CRLF = '\r\n' L = [] L.append('--' + BOUNDARY) L.append('Content-Disposition: form-data; name="datasource"') L.append('Content-Type: text/plain') L.append('') L.append(self.name) |
self.log('Posting Aggregated Feed to : %s' % self.name) | self.log('Posting Aggregated Feed to : %s' % self._name) | def encode_multipart_formdata(xmldata): BOUNDARY = '<<' CRLF = '\r\n' L = [] L.append('--' + BOUNDARY) L.append('Content-Disposition: form-data; name="datasource"') L.append('Content-Type: text/plain') L.append('') L.append(self.name) |
'</gsafeed>') % (self.name, feed_type, data) | '</gsafeed>') % (self._name, feed_type, data) | def encode_multipart_formdata(xmldata): BOUNDARY = '<<' CRLF = '\r\n' L = [] L.append('--' + BOUNDARY) L.append('Content-Disposition: form-data; name="datasource"') L.append('Content-Type: text/plain') L.append('') L.append(self.name) |
u = 'http://%s:19900/xmlfeed' % self.manager.gsa | u = 'http://%s:19900/xmlfeed' % self._manager.gsa | def encode_multipart_formdata(xmldata): BOUNDARY = '<<' CRLF = '\r\n' L = [] L.append('--' + BOUNDARY) L.append('Content-Disposition: form-data; name="datasource"') L.append('Content-Type: text/plain') L.append('') L.append(self.name) |
if self.manager.debug_flag: self.log('POSTING Feed to GSA %s ' % self.manager.gsa) | if self._manager.debug_flag: self.log('POSTING Feed to GSA %s ' % self._manager.gsa) | def encode_multipart_formdata(xmldata): BOUNDARY = '<<' CRLF = '\r\n' L = [] L.append('--' + BOUNDARY) L.append('Content-Disposition: form-data; name="datasource"') L.append('Content-Type: text/plain') L.append('') L.append(self.name) |
self.manager.log(deb_string) | self._manager.log(deb_string) | def log(self, deb_string): self.manager.log(deb_string) |
if con.getName() == cdata.name: | if con.getName() == cdata.getName(): | def _setConnector(self, cdata): found = False for index, con in enumerate(self.connector_list): if con.getName() == cdata.name: found = True self.connector_list[index] = cdata if found == False: self.connector_list.append(cdata) |
parts = [] for content, attrs in records: attrlist = [] for key, value in attrs.iteritems(): attrlist.append('%s="%s"' % (key, value)) attrstr = ' '.join(attrlist) record_str = ('<record %s>' '<content encoding="base64binary">%s</content>' '</record>') % (attrstr, base64.encodestring(content)) parts.append(record_str) | parts = [self.generateFeedRecord(attrs, None, content) for content, attrs in records] | def sendMultiContentFeed(self, records, feed_type='incremental'): """Sends a content feed to the GSA, containing multiple records. |
def sendContentFeed(self, **attrs): | def sendContentFeed(self, content, **attrs): | def sendContentFeed(self, **attrs): """Sends a content feed to the GSA, containing only one record. |
content = attrs['content'] del attrs['content'] | def sendContentFeed(self, **attrs): """Sends a content feed to the GSA, containing only one record. | |
urllib.urlencode({'actionType': 'cache', 'authnLoginUrl': '', 'authnArtifactServiceUrl': '', 'sessionCookieExpiration': '480', | urllib.urlencode({'security_token': security_token, 'actionType': 'cache', 'basicAuthChallengeType': 'auto', | def setAccessControl(self, urlCacheTimeout): # Tested on 5.0.0.G.14 and 6.2.0.G.14 self._login() security_token = self.getSecurityToken('cache') request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType': 'cache', 'authnLoginUrl': '', 'authnArtifactServiceUrl': '', 'sessionCookieExpiration': '480', 'authzSe... |
'security_token': security_token, | def setAccessControl(self, urlCacheTimeout): # Tested on 5.0.0.G.14 and 6.2.0.G.14 self._login() security_token = self.getSecurityToken('cache') request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType': 'cache', 'authnLoginUrl': '', 'authnArtifactServiceUrl': '', 'sessionCookieExpiration': '480', 'authzSe... | |
self.configXMLString = open(fileName).read() | self.openFile(fileName) | def __init__(self, fileName=None): if fileName: self.configXMLString = open(fileName).read() |
self.configXMLString = xmlString | self.configXMLString = xmlString.encode("utf-8") | def setXMLContents(self, xmlString): "Sets the runtime XML contents" self.configXMLString = xmlString #log.warning("Signature maybe invalid. Please verify before uploading or saving") |
return self.configXMLString | return self.configXMLString.encode("utf-8") | def getXMLContents(self): "Returns the contents of the XML file" return self.configXMLString |
doc = xml.dom.minidom.parseString(self.configXMLString) | doc = xml.dom.minidom.parseString(self.getXMLContents()) | def verifySignature(self, password): doc = xml.dom.minidom.parseString(self.configXMLString) # Get <config> node configNode = doc.getElementsByTagName("config").item(0) # get string of Node and children (as utf-8) configNodeXML = configNode.toxml() # Create new HMAC using user password and configXML as sum contents myh... |
self.cookieJar = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) urllib2.install_opener(opener) | cookieJar = cookielib.CookieJar() self._url_opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookieJar)) def _openurl(self, request): """ request: urllib2 request object or URL string """ return self._url_opener.open(request) | def __init__(self, hostName, username, password, port=8000): self.baseURL = 'http://%s:%s/EnterpriseController' % (hostName, port) self.hostName = hostName self.username = username self.password = password self.cookieJar = cookielib.CookieJar() opener = urllib2.build_opener(urllib2.HTTPCookieProcessor()) urllib2.instal... |
request = urllib2.Request(self.baseURL) result = urllib2.urlopen(request) | self._openurl(self.baseURL) | def _login(self): if not self.loggedIn: log.debug("Fetching initial page for new cookie") request = urllib2.Request(self.baseURL) result = urllib2.urlopen(request) request = urllib2.Request(self.baseURL, urllib.urlencode( {'actionType' : 'authenticateUser', 'userName' : self.username, 'password' : self.password})) |
result = urllib2.urlopen(request) | result = self._openurl(request) | def _login(self): if not self.loggedIn: log.debug("Fetching initial page for new cookie") request = urllib2.Request(self.baseURL) result = urllib2.urlopen(request) request = urllib2.Request(self.baseURL, urllib.urlencode( {'actionType' : 'authenticateUser', 'userName' : self.username, 'password' : self.password})) |
request = urllib2.Request(self.baseURL,urllib.urlencode({'actionType' : 'logout'})) res = urllib2.urlopen(request) | request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType' : 'logout'})) self._openurl(request) | def _logout(self): request = urllib2.Request(self.baseURL,urllib.urlencode({'actionType' : 'logout'})) res = urllib2.urlopen(request) self.loggedIn = False |
result = urllib2.urlopen(request) | result = self._openurl(request) | def importConfig(self, gsaConfig, configPassword): fields = [("actionType", "importExport"), ("passwordIn", configPassword), ("import", " Import Configuration ")] |
result = urllib2.urlopen(request) | result = self._openurl(request) | def exportConfig(self, configPassword): self._login() request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType': 'importExport', 'export': ' Export Configuration ', 'password1': configPassword, 'password2': configPassword})) |
result = urllib2.urlopen(request) content = result.read() | result = self._openurl(request) | def setAccessControl(self, urlCacheTimeout): # Tested on 5.0.0.G.14 self._login() request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType': 'cache', 'authnLoginUrl': '', 'authnArtifactServiceUrl': '', 'sessionCookieExpiration': '480', 'authzServiceUrl': '', 'requestBatchTimeout': '5.0', 'singleRequestTime... |
help="Sign password for signing/import/export", metavar="FILE") | help="Sign password for signing/import/export") | def setAccessControl(self, urlCacheTimeout): # Tested on 5.0.0.G.14 self._login() request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType': 'cache', 'authnLoginUrl': '', 'authnArtifactServiceUrl': '', 'sessionCookieExpiration': '480', 'authzServiceUrl': '', 'requestBatchTimeout': '5.0', 'singleRequestTime... |
if debug_flag == True: cherrypy.config.update({'log.screen': True}) else: cherrypy.config.update({'log.screen': False}) | def main(argv): pass | |
self.smbconfig = smbcrawler.Config(['', self.getConfigParam('share')]) | self.share = self.getConfigParam('share') if self.share[-1] != '/': self.share += '/' self.smbconfig = smbcrawler.Config(['', self.share]) | def init(self): self.setInterval(int(self.getConfigParam('delay'))) self.smbconfig = smbcrawler.Config(['', self.getConfigParam('share')]) |
subprocess.call(['smbclient', '//localhost/tmp/', '-N', '-c', | subprocess.call(['smbclient', self.share, '-N', '-c', | def run(self): # fetch all the document URLs with smbcrawler output = smbcrawler.Crawl(self.smbconfig) |
self.good_result_times = [] self.error_result_count = 0 | self.error_search_result_count = 0 self.error_cluster_result_count = 0 self.error_suggest_result_count = 0 self.good_search_result_times = [] self.good_cluster_result_times = [] self.good_suggest_result_times = [] | def __init__(self): self.good_result_times = [] self.error_result_count = 0 self.start = time.time() |
self.good_result_times.sort() total_200 = len(self.good_result_times) total_all = total_200 + self.error_result_count | self.good_search_result_times.sort() self.good_cluster_result_times.sort() self.good_suggest_result_times.sort() total_search_200 = len(self.good_search_result_times) total_cluster_200 = len(self.good_cluster_result_times) total_suggest_200 = len(self.good_suggest_result_times) total_200 = total_search_200 + total_clus... | def Summary(self): """Summarizes the results. |
median = self.good_result_times[int(total_200 / 2.0) - 1] std_dev = self.good_result_times[int(total_200 * 0.9) - 1] max_time = self.good_result_times[-1] return (("Number of responses:\n" | median_search = self.good_search_result_times[int(total_search_200 / 2.0) - 1] std_dev_search = self.good_search_result_times[int(total_search_200 * 0.9) - 1] max_time_search = self.good_search_result_times[-1] median_cluster = self.good_cluster_result_times[int(total_cluster_200 / 2.0) - 1] std_dev_cluster = self.goo... | def Summary(self): """Summarizes the results. |
"\nLatency:\n" " median: %.2f secs\n" " maximum: %.2f secs\n" " 90th percentile: %.2f secs" "\n") % (total_200, self.error_result_count, total_all, av_qps, median, max_time, std_dev)) | "\n") % (total_suggest_200, self.error_suggest_result_count, median_suggest, max_time_suggest, std_dev_suggest, total_cluster_200, self.error_cluster_result_count, median_cluster, max_time_cluster, std_dev_cluster, total_search_200, self.error_search_result_count, median_search, max_time_search, std_dev_search, total_2... | def Summary(self): """Summarizes the results. |
query_parsed_clean = query_parsed[4] if query_parsed_clean[0] == "&": query_parsed_clean = query_parsed_clean[1:-1] try: parameters = dict([param.split('=') for param in query_parsed_clean.split('&')]) except Exception, e: print e print query_parsed print parameters raise if 'q' in parameters: self.FetchContent(self.h... | query_parsed_clean = query_parsed[4] if query_parsed_clean[0] == "&": query_parsed_clean = query_parsed_clean[1:-1] try: parameters = dict([param.split('=') for param in query_parsed_clean.split('&')]) except Exception, e: print e print query_parsed print parameters raise self.FetchContent(self.host, self.port, q.stri... | def run(self): while True: try: q = self.queries.get(block=False) except Queue.Empty: break else: query_parsed = urlparse.urlparse(q.strip()) |
if req.find("/suggest?") != 0 and req.find("/cluster?") !=0: self.res.good_result_times.append(exec_time) | if req.find("/suggest?") == 0: self.res.good_suggest_result_times.append(exec_time) if req.find("/cluster?") == 0: self.res.good_cluster_result_times.append(exec_time) else: self.res.good_search_result_times.append(exec_time) | def FetchContent(self, host, port, q, parameters): start_time = time.ctime(time.time()) test_requests = [] #For each queries we get from the queue, making one suggest query and one clustering req: if q.find("/search?") == 0 and q.find("coutput=json") != 0: test_requests.append(q) else: test_requests.append("/search?q=%... |
self.res.error_result_count += 1 | if req.find("/suggest?") == 0: self.res.error_suggest_result_count += 1 if req.find("/cluster?") == 0: self.res.error_cluster_result_count += 1 else: self.res.error_search_result_count += 1 | def FetchContent(self, host, port, q, parameters): start_time = time.ctime(time.time()) test_requests = [] #For each queries we get from the queue, making one suggest query and one clustering req: if q.find("/search?") == 0 and q.find("coutput=json") != 0: test_requests.append(q) else: test_requests.append("/search?q=%... |
request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType' : 'logout'})) | request = urllib2.Request(self.baseURL + "?" + urllib.urlencode({'actionType' : 'logout'})) | def _logout(self): request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType' : 'logout'})) self._openurl(request) self.loggedIn = False |
request = urllib2.Request(self.baseURL, body, headers) | request = urllib2.Request(self.baseURL + "?" + urllib.urlencode({'actionType': 'importExport', 'export': ' Import Configuration ', 'passwordIn': configPassword}), body, headers) | def importConfig(self, gsaConfig, configPassword): fields = [("actionType", "importExport"), ("passwordIn", configPassword), ("import", " Import Configuration ")] |
request = urllib2.Request(self.baseURL, | request = urllib2.Request(self.baseURL + "?" + | def exportConfig(self, configPassword): self._login() request = urllib2.Request(self.baseURL, urllib.urlencode({'actionType': 'importExport', 'export': ' Export Configuration ', 'password1': configPassword, 'password2': configPassword})) |
query_parsed = urlparse.urlparse(q.strip()) query_parsed_clean = query_parsed[4] | parameters = dict() if q.find("/search?") >= 0: query_parsed = urlparse.urlparse(q.strip()) query_parsed_clean = query_parsed[4] | def run(self): while True: try: q = self.queries.get(block=False) except Queue.Empty: break else: query_parsed = urlparse.urlparse(q.strip()) query_parsed_clean = query_parsed[4] #Cleaning up query input to prevent invalid requests. if query_parsed_clean[0] == "&": query_parsed_clean = query_parsed_clean[1:-1] query_te... |
if query_parsed_clean[0] == "&": query_parsed_clean = query_parsed_clean[1:-1] query_terms = [] for qterm in query_parsed_clean.split("&"): if qterm.find("=") != -1: query_terms.append(qterm) try: parameters = dict([param.split("=") for param in query_terms]) except Exception, e: print e print query_parsed print parame... | if query_parsed_clean[0] == "&": query_parsed_clean = query_parsed_clean[1:-1] query_terms = [] for qterm in query_parsed_clean.split("&"): if qterm.find("=") != -1: query_terms.append(qterm) try: parameters = dict([param.split("=") for param in query_terms]) except Exception, e: print e print query_parsed print parame... | def run(self): while True: try: q = self.queries.get(block=False) except Queue.Empty: break else: query_parsed = urlparse.urlparse(q.strip()) query_parsed_clean = query_parsed[4] #Cleaning up query input to prevent invalid requests. if query_parsed_clean[0] == "&": query_parsed_clean = query_parsed_clean[1:-1] query_te... |
logging.info("Queries loaded") | def RunOnce(self): queries = Queue.Queue() for q in self.queries_list: queries.put(q) | |
PrintTwoCol ('--------------------', '------------------------') | PrintTwoCol ('--------------------', '---------------------') | def GenReport(log_file): """Read each line of the log file and generate reports.""" total_url = 0 states = dict() servers = dict() # The content sizes in KB that we want to report on # The for loop below assumes that this list is in ascending order sizes_kb = [4, 8, 16, 32, 64, 128, 256, 512, 1024, 2*1024, 4*1024, 32*1... |
def to_string(self, string): string = repr(string) if string[0] == "'": string = '"' + string[1:-1].replace('"', r'\"') + '"' return string | def make_func(self, name, args, body): if name: func = '%s = function' % name[1] else: func = 'function' return '%s(%s) %s' % (func, ', '.join(args), body) | |
keywords = set(('as', 'break', 'case', 'catch', 'class', 'continue', 'def', 'default', 'del', 'delete', 'do', 'elif', 'else', 'except', 'finally', 'for', 'function', 'if', 'in', 'instanceof', 'new', 'pass', 'raise', 'return', 'switch', 'this', 'throw', 'try', 'typeof', 'var', 'void', 'while', 'with', 'yield',)) | keywords = set(('and', 'as', 'break', 'case', 'catch', 'class', 'continue', 'def', 'default', 'del', 'delete', 'do', 'elif', 'else', 'except', 'false', 'finally', 'for', 'function', 'if', 'in', 'is', 'instanceof', 'new', 'not', 'null', 'or', 'pass', 'raise', 'return', 'switch', 'this', 'throw', 'true', 'try', 'typeof',... | def parse_source(cls, source): return cls(source).apply('grammar')[0] |
self.check('del x["a"]', 'delete x["a"];') | self.check("del x['a']", "delete x['a'];") | def test_delete(self): self.check('del x[a]', 'delete x[a];') self.check('del x["a"]', 'delete x["a"];') self.check('del x.a', 'delete x.a;') |
"__init__": (function() { | '__init__': (function() { | def nested(): return None |
"add": (function(a, b, c) { | 'add': (function(a, b, c) { | def nested(): return None |
self.assertEqual(search_for_configuration_file(), config_file) | found = search_for_configuration_file() if found.startswith('/private'): found = found[8:] self.assertEqual(found, config_file) | def test_current_working_directory(self): fake_cwd = '/home/alex/mailman/hacking' fake_testdir = self._make_fake(fake_cwd) config_file = os.path.join(fake_testdir, 'mailman.cfg') with fakedirs(fake_testdir): # Write a mostly empty configuration file. with open(os.path.join(fake_testdir, 'mailman.cfg'), 'w') as fp: prin... |
for key, value in validator(request).items(): setattr(self._mlist, key, value) | try: for key, value in validator(request).items(): setattr(self._mlist, key, value) except ValueError as error: return http.bad_request([], str(error)) | def put_configuration(self, request): """Set all of a mailing list's configuration.""" # Use PATCH to change just one or a few of the attributes. validator = Validator(**VALIDATORS) for key, value in validator(request).items(): setattr(self._mlist, key, value) return http.ok([], '') |
gtk.gdk.threads_leave() | def on_sync_message(self, bus, message): print "on_sync_message", bus, message if message.structure is None: return if message.structure.get_name() == 'prepare-xwindow-id': self.videowidget.set_sink(message.src) message.src.set_property('force-aspect-ratio', True) | |
def main(args): | __version__ = "0.1" if __name__ == '__main__': import os import optparse parser = optparse.OptionParser(usage="%prog", version=str(__version__)) (options, args) = parser.parse_args() | def main(args): def usage(): sys.stderr.write("usage: %s URI-OF-MEDIA-FILE\n" % args[0]) sys.exit(1) w = PlayerWindow() if len(args) != 2: usage() if not gst.uri_is_valid(args[1]): sys.stderr.write("Error: Invalid URI: %s\n" % args[1]) sys.exit(1) w.load_file(args[1]) w.show_all() print "gtk.main()" gtk.main() |
if len(args) != 2: | if len(args) < 1: | def usage(): sys.stderr.write("usage: %s URI-OF-MEDIA-FILE\n" % args[0]) sys.exit(1) |
if not gst.uri_is_valid(args[1]): sys.stderr.write("Error: Invalid URI: %s\n" % args[1]) sys.exit(1) w.load_file(args[1]) w.show_all() print "gtk.main()" gtk.main() if __name__ == '__main__': sys.exit(main(sys.argv)) | else: full_file_path = os.path.abspath(args[0]) uri = "file:/%s" % (full_file_path) if not gst.uri_is_valid(full_file_path): sys.stderr.write("Error: Invalid URI: %s\n" % full_file_path) sys.exit(1) print "using", uri w.load_file(full_file_path) w.show_all() gtk.main() | def usage(): sys.stderr.write("usage: %s URI-OF-MEDIA-FILE\n" % args[0]) sys.exit(1) |
uri = "file:/%s" % (full_file_path) if not gst.uri_is_valid(full_file_path): sys.stderr.write("Error: Invalid URI: %s\n" % full_file_path) | uri = "file://%s" % (full_file_path) if not gst.uri_is_valid(uri): sys.stderr.write("Error: Invalid URI: %s\n" % (uri)) | def usage(): sys.stderr.write("usage: %s URI-OF-MEDIA-FILE\n" % args[0]) sys.exit(1) |
w.load_file(full_file_path) | w.load_file(uri) | def usage(): sys.stderr.write("usage: %s URI-OF-MEDIA-FILE\n" % args[0]) sys.exit(1) |
stage = clutter.Stage() scene = Scene(stage) | if have_cluttergtk: app = App() else: stage = clutter.Stage() scene = Scene(stage) | def destroy_app(self, widget, data=None): """ Destroy method causes appliaction to exit when main window closed """ print("Destroying the window.") if reactor.running: print("reactor.stop()") reactor.stop() |
class SimpleDemo(object): | glColor4f(1.0, 1.0, 0.0, 0.8) for x in [4, 3.5, 3, 2.5, 2, 1.5, 1, 0.5, 0, -0.5, -1, -1.5, -2, -2.5, -3, -3.5, -4]: draw_line(float(x), -4.0, float(x), 4.0) draw_line(-4.0, float(x), 4.0, float(x)) class SimpleApp(object): | def draw(self): # DRAW STUFF HERE glColor4f(1.0, 0.8, 0.2, 1.0) draw_square() |
if sys.platform != 'win32': self.window.set_resize_mode(gtk.RESIZE_IMMEDIATE) | def __init__(self): self.is_fullscreen = False self.verbose = True self.window = gtk.Window() self.window.set_title('Testing OpenGL') if sys.platform != 'win32': self.window.set_resize_mode(gtk.RESIZE_IMMEDIATE) self.window.set_reallocate_redraws(True) self.window.connect('delete_event', self.on_delete_event) self.wind... | |
print "toggle %s visibility %s" % (c, hide) | def _showhideWidgets(self, widget, hide=True): """ Show or hide all widgets in the window except the given widget. Used for going fullscreen: in fullscreen, you only want the clutter embed widget and the menu bar etc. """ parent = widget.get_parent() | |
app = SimpleDemo() | app = SimpleApp() | def _showhideWidgets(self, widget, hide=True): """ Show or hide all widgets in the window except the given widget. Used for going fullscreen: in fullscreen, you only want the clutter embed widget and the menu bar etc. """ parent = widget.get_parent() |
text_msg.set_param('charset', 'ASCII') | text_msg.set_param('charset', 'UTF-8') | def assemble_email(self, exc_data): short_html_version, short_extra = self.format_html( exc_data, show_hidden_frames=False, show_extra_data=True) long_html_version, long_extra = self.format_html( exc_data, show_hidden_frames=True, show_extra_data=True) text_version = self.format_text( exc_data, show_hidden_frames=True,... |
return u'%s (%s)' % (item['title'], item['value']) | title = unicode(item['title'], 'utf-8') value = unicode(item['value'], 'utf-8') val = u'%s (%s)' % (title, value) return val | def name_helper(item, value): return u'%s (%s)' % (item['title'], item['value']) |
IStatusMessage(self.request).addStatusMessage(_('statusmessage_no_recipients'), type='error') | IStatusMessage(self.request).addStatusMessage(_(u'statusmessage_no_recipients'), type='error') | def send_notification(self): """""" sp = getToolByName(self.context, 'portal_properties').site_properties use_view_action = self.context.Type() in sp.getProperty('typesUseViewActionInListings', ()) if len(self.request.get('to_list', [])): comment = self.request.get('comment', '') notify(NotificationEvent(self.context... |
def checkbox_helper(item, value): | def checkbox_to_helper(item, value): | def checkbox_helper(item, value): return u"""<input type="checkbox" name="to_list:list" value="%s"/>""" % item['value'] |
columns = (('', checkbox_helper), ('Name', name_helper), ) | columns = ( {'column': 'to', 'column_title': _(u'label_to', default='TO'), 'transform': checkbox_to_helper }, {'column': 'cc', 'column_title': _(u'label_cc', default='CC'), 'transform': checkbox_cc_helper }, {'column': 'name', 'column_title': _(u'label_name', default='Name'), 'transform': name_helper}, ) | def checkbox_helper(item, value): return u"""<input type="checkbox" name="to_list:list" value="%s"/>""" % item['value'] |
x=int(i*dx+self.border_left) y=int(j*dy+border_top) | if pdftemplate is not None: x=(self.x+i*dx+self.border_left)*scale y=800-(self.y+j*dy+border_top)*scale pdf.rectangle(x,y,dx*scale,-dy*scale) pdf.fill() else: x=int(i*dx+self.border_left) y=int(j*dy+border_top) w=int(dx)-1 h=int(dy)-1 if w<1: w=1 if h<1: h=1 if w<=1 and h<=1: g.drawLine(x,y,x,y) else: g.fillRect(x,... | def paintComponent(self,g): core.DataViewComponent.paintComponent(self,g) if self.usemap and self.map is None: self.initialize_map() border_top = self.border_top + self.label_offset g.color=Color(0.8,0.8,0.8) g.drawLine(self.border_left,self.height-self.border_bottom,self.size.width-self.border_right,self.size.heigh... |
w=int(dx)-1 h=int(dy)-1 if w<1: w=1 if h<1: h=1 if w<=1 and h<=1: g.drawLine(x,y,x,y) else: g.fillRect(x,y,w,h) | if pdftemplate is not None: pdf.setLineWidth(1) | def paintComponent(self,g): core.DataViewComponent.paintComponent(self,g) if self.usemap and self.map is None: self.initialize_map() border_top = self.border_top + self.label_offset g.color=Color(0.8,0.8,0.8) g.drawLine(self.border_left,self.height-self.border_bottom,self.size.width-self.border_right,self.size.heigh... |
if isinstance(n,Network) and not n.__class__.__name__=='CCMModelNetwork': | if n.__class__.__name__=='NetworkImpl': | def initialize(self,network): for n in network.nodes: if isinstance(n,Network) and not n.__class__.__name__=='CCMModelNetwork': self.initialize(n) else: self.nodes.append(n) |
self.projections=[] | def __init__(self,network): self.projections=[] self.nodes=[] self.network=network self.initialize(network) if GPUNodeThreadPool.getUseGPU(): for n in self.nodes: if isinstance(n,NEFEnsemble) and n.mode==SimulationMode.DEFAULT: n.setGPU(True) self.thread_pool=GPUNodeThreadPool(self.nodes) elif NodeThreadPool.isMultith... | |
for p in network.projections: self.projections.append(p) | def initialize(self,network): for n in network.nodes: if isinstance(n,Network) and not n.__class__.__name__=='CCMModelNetwork': self.initialize(n) else: self.nodes.append(n) for p in network.projections: self.projections.append(p) | |
return dict(width=self.frame.width,height=self.frame.height,state=self.frame.getExtendedState(),x=self.frame.x,y=self.frame.y) | return dict(width=self.frame.width,height=self.frame.height-self.time_control.config_panel_height,state=self.frame.getExtendedState(),x=self.frame.x,y=self.frame.y) | def view_save(self): return dict(width=self.frame.width,height=self.frame.height,state=self.frame.getExtendedState(),x=self.frame.x,y=self.frame.y) |
return [n.getOrigin('AXON').values.values[0]*0.005 for n in obj.nodes] | return [n.getOrigin('AXON').values.values[0]*0.0005 for n in obj.nodes] | def voltage(self,obj): if obj.mode in [SimulationMode.CONSTANT_RATE,SimulationMode.RATE]: return [n.getOrigin('AXON').values.values[0]*0.005 for n in obj.nodes] else: return [n.generator.voltage for n in obj.nodes] |
return [n.getOrigin('AXON').values.values[0]*0.005 for n in obj.nodes] | return [n.getOrigin('AXON').values.values[0]*0.0005 for n in obj.nodes] | def spikes(self,obj): if obj.mode in [SimulationMode.CONSTANT_RATE,SimulationMode.RATE]: return [n.getOrigin('AXON').values.values[0]*0.005 for n in obj.nodes] else: return obj.getOrigin('AXON').values.values |
(None, None, None), | def views(self,obj): return [ (None, None, None), # Note that the above tuple is to reset popup menu to main popup menu in item.py ('control',components.FunctionControl,dict(func=self.funcOrigin,label=obj.name)), ] | |
(None, None, None), | def views(self,obj): return [ (None, None, None), # Note that the above tuple is to reset popup menu to main popup menu in item.py ('3D view',components.View3D,dict(func=self.physics)), ] | |
self.watcher.add_watch(RoomWatch()) | def __init__(self,network,size=None,ui=None): self.dt=0.001 self.tau_filter=0.03 self.delay=10 self.current_tick=0 self.time_shown=0.5 self.timelog=timelog.TimeLog() self.network=network self.watcher=watcher.Watcher(self.timelog) self.watcher.add_watch(NodeWatch()) self.watcher.add_watch(EnsembleWatch()) self.watcher.... | |
return dict(width=self.frame.width,height=self.frame.height,state=self.frame.getExtendedState()) | return dict(width=self.frame.width,height=self.frame.height,state=self.frame.getExtendedState(),x=self.frame.x,y=self.frame.y) | def view_save(self): return dict(width=self.frame.width,height=self.frame.height,state=self.frame.getExtendedState()) |
mode=JPanel(layout=BorderLayout(),opaque=False) cb=JComboBox(['default','rate','direct']) if self.view.network.mode in [SimulationMode.DEFAULT,SimulationMode.PRECISE]: cb.setSelectedIndex(0) elif self.view.network.mode in [SimulationMode.RATE]: cb.setSelectedIndex(1) elif self.view.network.mode in [SimulationMode.DIREC... | if self.view.network.mode!=SimulationMode.DIRECT: mode=JPanel(layout=BorderLayout(),opaque=False) cb=JComboBox(['default','rate','direct']) if self.view.network.mode in [SimulationMode.DEFAULT,SimulationMode.PRECISE]: cb.setSelectedIndex(0) elif self.view.network.mode in [SimulationMode.RATE]: cb.setSelectedIndex(1) el... | def __init__(self,view): JPanel.__init__(self) self.view=view self.background=Color.white self.config_panel_height=60 #self.config_panel_width = 675 mainPanel=JPanel(background=self.background,layout=BorderLayout()) mainPanel.border=RoundedBorder() configPanel=JPanel(background=self.background,visible=False) |
mode=self.mode_combobox.getSelectedItem() if mode=='default': self.view.network.mode=SimulationMode.DEFAULT elif mode=='rate': self.view.network.mode=SimulationMode.RATE elif mode=='direct': self.view.network.mode=SimulationMode.DIRECT | if self.mode_combobox is not None: mode=self.mode_combobox.getSelectedItem() if mode=='default': requested=SimulationMode.DEFAULT elif mode=='rate': requested=SimulationMode.RATE elif mode=='direct': requested=SimulationMode.DIRECT if requested!=self.view.network.mode: self.view.network.mode=requested | def actionPerformed(self,event): dt=float(self.dt_combobox.getSelectedItem()) if dt!=self.view.dt: self.view.dt=dt self.record_time_spinner.value=(self.view.timelog.tick_limit-1)*self.view.dt self.dt_combobox.repaint() self.view.restart=True self.view.set_target_rate(self.rate_combobox.getSelectedItem()) mode=self.mode... |
start_time=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1)*self.view.dt | start_index=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1) count=min(self.view.timelog.tick_limit,self.view.timelog.tick_count) start_time=start_index*self.view.dt | def extract_data(self): tau=float(self.filter.value) dt=self.view.dt if tau<dt: dt_tau=None else: dt_tau=dt/tau decimals=int(self.decimals.value) format='%%1.%df'%decimals start_time=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1)*self.view.dt data=[] title=['t'] for key,watch in self.view.watche... |
data=[] | data=None | def extract_data(self): tau=float(self.filter.value) dt=self.view.dt if tau<dt: dt_tau=None else: dt_tau=dt/tau decimals=int(self.decimals.value) format='%%1.%df'%decimals start_time=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1)*self.view.dt data=[] title=['t'] for key,watch in self.view.watche... |
d=watch.get(dt_tau=dt_tau) | d=watch.get(dt_tau=dt_tau,start=start_index,count=count) | def extract_data(self): tau=float(self.filter.value) dt=self.view.dt if tau<dt: dt_tau=None else: dt_tau=dt/tau decimals=int(self.decimals.value) format='%%1.%df'%decimals start_time=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1)*self.view.dt data=[] title=['t'] for key,watch in self.view.watche... |
while len(data)<len(d): data.append(['%0.4f'%(start_time+(len(data)+0)*self.view.dt)]) | if data is None: data=[] while len(data)<len(d): data.append(['%0.4f'%(start_time+(len(data)+0)*self.view.dt)]) | def extract_data(self): tau=float(self.filter.value) dt=self.view.dt if tau<dt: dt_tau=None else: dt_tau=dt/tau decimals=int(self.decimals.value) format='%%1.%df'%decimals start_time=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1)*self.view.dt data=[] title=['t'] for key,watch in self.view.watche... |
for j in range(len(d)): | for j in range(len(data)): | def extract_data(self): tau=float(self.filter.value) dt=self.view.dt if tau<dt: dt_tau=None else: dt_tau=dt/tau decimals=int(self.decimals.value) format='%%1.%df'%decimals start_time=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1)*self.view.dt data=[] title=['t'] for key,watch in self.view.watche... |
if dd is None: data[j].append(None) | if dd is None: data[j].append('') | def extract_data(self): tau=float(self.filter.value) dt=self.view.dt if tau<dt: dt_tau=None else: dt_tau=dt/tau decimals=int(self.decimals.value) format='%%1.%df'%decimals start_time=max(0,self.view.timelog.tick_count-self.view.timelog.tick_limit+1)*self.view.dt data=[] title=['t'] for key,watch in self.view.watche... |
def resetNetwork(self,randomize=False): | def resetNetwork(self,randomize=False,saveWeights=True): | def resetNetwork(self,randomize=False): java.lang.System.out.println('resetting') self.model=self._model_class() self.model.run(limit=0) LocalSimulator.resetNetwork(self,randomize) |
LocalSimulator.resetNetwork(self,randomize) | LocalSimulator.resetNetwork(self,randomize,saveWeights) | def resetNetwork(self,randomize=False): java.lang.System.out.println('resetting') self.model=self._model_class() self.model.run(limit=0) LocalSimulator.resetNetwork(self,randomize) |
print "length", len(active_msg) | def scanNew(folders): # delete current items global active_msg print "length", len(active_msg) for i in active_msg: print "del" i.hide() active_msg = [] # find new messages in folders for i, j in folders: print "Scanning folder", i if(not os.path.isdir(j)): print "Folder num", i, "is not a valid maildir folder." contin... | |
print "del" | def scanNew(folders): # delete current items global active_msg print "length", len(active_msg) for i in active_msg: print "del" i.hide() active_msg = [] # find new messages in folders for i, j in folders: print "Scanning folder", i if(not os.path.isdir(j)): print "Folder num", i, "is not a valid maildir folder." contin... | |
print "Scanning folder", i | def scanNew(folders): # delete current items global active_msg print "length", len(active_msg) for i in active_msg: print "del" i.hide() active_msg = [] # find new messages in folders for i, j in folders: print "Scanning folder", i if(not os.path.isdir(j)): print "Folder num", i, "is not a valid maildir folder." contin... | |
print "found msg" | def scanNew(folders): # delete current items global active_msg print "length", len(active_msg) for i in active_msg: print "del" i.hide() active_msg = [] # find new messages in folders for i, j in folders: print "Scanning folder", i if(not os.path.isdir(j)): print "Folder num", i, "is not a valid maildir folder." contin... | |
attrib = searchCtx[0][1:] | attrib, operator, operand = searchCtx[0][1:], searchCtx[1], searchCtx[2] | def findnode(node, pgm) : """ Recursive node finder """ searchCtx = pgm[0] result = [] if searchCtx[0] == ".." : result.append(node.parentNode) elif searchCtx[0][0] == '@' : attrib = searchCtx[0][1:] value = node.getAttribute(attrib) if searchCtx[1] == "=" : if searchCtx[2] != value : return None elif searchCtx[1] =... |
if searchCtx[1] == "=" : if searchCtx[2] != value : | if operator == "=" : if operand != value : | def findnode(node, pgm) : """ Recursive node finder """ searchCtx = pgm[0] result = [] if searchCtx[0] == ".." : result.append(node.parentNode) elif searchCtx[0][0] == '@' : attrib = searchCtx[0][1:] value = node.getAttribute(attrib) if searchCtx[1] == "=" : if searchCtx[2] != value : return None elif searchCtx[1] =... |
elif searchCtx[1] == "!=" : if searchCtx[2] == value : | elif operator == "!=" : if operand == value : | def findnode(node, pgm) : """ Recursive node finder """ searchCtx = pgm[0] result = [] if searchCtx[0] == ".." : result.append(node.parentNode) elif searchCtx[0][0] == '@' : attrib = searchCtx[0][1:] value = node.getAttribute(attrib) if searchCtx[1] == "=" : if searchCtx[2] != value : return None elif searchCtx[1] =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.