rem
stringlengths 0
322k
| add
stringlengths 0
2.05M
| context
stringlengths 8
228k
|
---|---|---|
url = space.lookup( tup[-1] )
|
url = space.lookup( final_name )
|
def lookup_tuple( s, tup ): """ Goes 1 level deep into defaults, match's against 0 depths pattern if nothing found, returns None if there is no 0 depth pattern. Doesn't check defaults on Connections. returns URL or None tup: tuple where first items are connection names, and last item is the name of an item """ space = s.store.get( s.default_ns_url )
|
url=subspace.lookup( tup[-1] )
|
url=subspace.lookup( final_name )
|
def lookup_tuple( s, tup ): """ Goes 1 level deep into defaults, match's against 0 depths pattern if nothing found, returns None if there is no 0 depth pattern. Doesn't check defaults on Connections. returns URL or None tup: tuple where first items are connection names, and last item is the name of an item """ space = s.store.get( s.default_ns_url )
|
return s.store.get( s.default_ns_url ).default_for_name( tup[-1] )
|
return space.default_for_name( final_name )
|
def lookup_tuple( s, tup ): """ Goes 1 level deep into defaults, match's against 0 depths pattern if nothing found, returns None if there is no 0 depth pattern. Doesn't check defaults on Connections. returns URL or None tup: tuple where first items are connection names, and last item is the name of an item """ space = s.store.get( s.default_ns_url )
|
return ({"data": xmlrpclib.Binary(localnames.replace_text(data.encode("utf-8"), url)),
|
return ({"data": xmlrpclib.Binary(localnames.replace_text(data, url).encode("utf-8")),
|
def xmlrpc_filterData(self, data, contentType, params): data = data.decode("utf-8", "replace") url = params["namespace"] return ({"data": xmlrpclib.Binary(localnames.replace_text(data.encode("utf-8"), url)), "contentType": contentType})
|
result = lookup(path[0], url, wo_neighboring)
|
result = lookup([path[0]], url, wo_neighboring)
|
def lookup(path, url, flags): """ Resolve a path to a URL. Returns the resolved URL. path: ["space", "space", ..., "name"] url: "http://url.to.first.namespace.description/" flags: Python 2.3 Set of flags The following flags are understood: "no-case": ignore capitalization "no-punctuation": ignore punctuation "no-space": ignore white space "forgive-spelling": accept plausible mis-spellings "loose": "no-case" + "no-punctuation" + "no-space" + "check-neighboring-spaces" + "check-neighboring-spaces": check spaces linked by NS "reverse": reverse lookup (URL, not name, at end of path) "NS": namespace-lookup; (NS, not LN, at end of path) """ flags = sets.Set(flags) if "loose" in flags: flags = flags | loose_flags flags.discard("loose") assert len(path) > 0 namespace = get_namespace(url) if len(path) == 1: if "NS" in flags: records = namespace["NS-raw"] else: records = namespace["LN-raw"] # If "loose" flags are being used, try resolving without loose # flags, first. If there is an exact match, it has priority. if flags & loose_flags: result = _check_list(path[0], records, flags - loose_flags) if result: return result result = _check_list(path[0], records, flags) if result: return result if "check-neighboring-spaces" in flags: wo_neighboring = flags.copy() wo_neighboring.discard("check-neighboring-spaces") urls = sets.Set() for num, neighborname, url in namespace["NS-raw"]: if url not in urls: result = lookup(path[0], url, wo_neighboring) if result: return result urls.add(url) if ("FINAL" in namespace["X"]) and ("reverse" not in flags): return namespace["X"]["FINAL"][0].replace("$PAGE", path[0]) return None else: pattern_raw = namespace["PATTERN-raw"] ns_raw = namespace["NS-raw"] original_flags = flags flags = flags.copy() flags.discard("reverse") if flags & loose_flags: result = _check_list(path[0], pattern_raw, flags - loose_flags) if result: return result.replace("$PAGE", path[1]) result = _check_list(path[0], ns_raw, flags - loose_flags) if result: return lookup(path[1:], result, original_flags) result = _check_list(path[0], pattern_raw, flags) if result: return result.replace("$PATH", path[1]) result = _check_list(path[0], ns_raw, flags) if result: return lookup(path[1:], result, original_flags) return None
|
return namespace["X"][0].replace("$PAGE", path[0])
|
return namespace["X"]["FINAL"][0].replace("$PAGE", path[0])
|
def lookup(path, url, flags): """ Resolve a path to a URL. Returns the resolved URL. path: ["space", "space", ..., "name"] url: "http://url.to.first.namespace.description/" flags: Python 2.3 Set of flags The following flags are understood: "no-case": ignore capitalization "no-punctuation": ignore punctuation "no-space": ignore white space "forgive-spelling": accept plausible mis-spellings "loose": "no-case" + "no-punctuation" + "no-space" + "check-neighboring-spaces" + "check-neighboring-spaces": check spaces linked by NS "reverse": reverse lookup (URL, not name, at end of path) "NS": namespace-lookup; (NS, not LN, at end of path) """ if "loose" in flags: flags = flags | loose_flags flags.discard("loose") assert len(path) > 0 namespace = get_namespace(url) if len(path) == 1: if "NS" in flags: records = namespace["NS-raw"] else: records = namespace["LN-raw"] # If "loose" flags are being used, try resolving without loose # flags, first. If there is an exact match, it has priority. if flags & loose_flags: result = _check_list(path[0], records, flags - loose_flags) if result: return result result = _check_list(path[0], records, flags) if result: return result if "check-neighboring-spaces" in flags: wo_neighboring = flags.copy() wo_neighboring.discard("check-neighboring-spaces") urls = sets.Set() for num, neighborname, url in namespace["NS-raw"]: if url not in urls: result = lookup(path[0], url, wo_neighboring) if result: return result urls.add(url) if ("FINAL" in namespace["X"]) and ("reverse" not in flags): return namespace["X"][0].replace("$PAGE", path[0]) return None else: pattern_raw = namespace["PATTERN-raw"] ns_raw = namespace["NS-raw"] original_flags = flags flags = flags.copy() flags.discard("reverse") if flags & loose_flags: result = _check_list(path[0], pattern_raw, flags - loose_flags) if result: return result.replace("$PAGE", path[1]) result = _check_list(path[0], ns_raw, flags - loose_flags) if result: return lookup(path[1:], result, original_flags) result = _check_list(path[0], pattern_raw, flags) if result: return result.replace("$PATH", path[1]) result = _check_list(path[0], ns_raw, flags) if result: return lookup(path[1:], result, original_flags) return None
|
self.wfile.write(self.xmlrpc_render(format, args["namespace"]))
|
if len(args["namespace"] == 1): url=args["namespace"][0] else: url=args["namespace"] self.wfile.write(self.xmlrpc_render(format, url))
|
def do_GET(self): if self.path.startswith("/?"): args = cgi.parse_qs( self.path[2:] ) else: args = {}
|
for user in s.userlist: for namespace in user: namespace_list = namespace_list + namespace + "\n"
|
for user in s.userlist.keys(): for namespace in s.userlist[user].keys(): if not namespace.startswith("_"): namespace_list = namespace_list + namespace + '\n'
|
def get_namespaces(s, username, pw): """Return list of namespaces.""" if not s.userlist.has_key(username): return UserDoesntExistError elif s.userlist[username]['_password'] != pw: return IncorrectPasswordError else: namespace_list = "" for user in s.userlist: for namespace in user: namespace_list = namespace_list + namespace + "\n" return namespace_list
|
f.write(entry[0] + " " + entry[1] + " " + entry[2] + "\n")
|
f.write(entry[0] + " \"" + entry[1] + "\" \"" + entry[2] + "\"\n")
|
def save_namespace(s, email, namespace_name): """ Create a LocalNames description and pop it into a file """ f = open(WEB_DIR + email + "-" + namespace_name, 'w') f.write("X VERSION 1.1\n") for entry in s.userlist[email][namespace_name]: f.write(entry[0] + " " + entry[1] + " " + entry[2] + "\n") f.close()
|
f.write(entry[0] + " " + entry[1] + " " + entry[2] + "\n")
|
f.write(entry[0] + " \"" + entry[1] + "\" \"" + entry[2] + "\"\n")
|
def unset(s, email, pw, namespace_name, entry_type, key, value): """ Unsets key, value, entry_type in namespace_name email: email address of user (string) pw: password of user (string) namespace_name: name of namespace to unset the entry in entry_type: type of entry (NS, X, LN, PATTERN) """ if not s.userlist.has_key(email): return UserDoesntExistError elif s.userlist[email]['password'] != pw: return IncorrectPasswordError elif namespace_name == "password": return AccessDeniedError elif s.userlist[email].has_key(namespace_name): try: s.userlist[email][namespace_name].remove( (entry_type, key, value) ) f = open(WEB_DIR + email + "-" + namespace_name, 'w') f.write("X VERSION 1.1\n") for entry in s.userlist[email][namespace_name]: f.write(entry[0] + " " + entry[1] + " " + entry[2] + "\n") f.close() #s.save_namespace(s, email, namespace_name) s._savedb() return True except: return EntryDoesntExistError else: return NamespaceDoesntExistError
|
def notify(s, load)
|
def notify(s, load):
|
def notify(s, load) xmlrpclib.ServerProxy(s.URL).notify(load, s.pw)
|
uli_xmlrpc( XMLRPC_NAMESERVER, "dump-cache %s" % description_key( space_name ) )
|
uli_xmlrpc( XMLRPC_NAMESERVER, "dump-cache %s" % (conf.URL_DOMAIN_NAME+conf.URL_DIRECTORY_BASE+description_key( space_name )) )
|
def tell_dump(s, space_name): uli_xmlrpc( XMLRPC_NAMESERVER, "dump-cache %s" % description_key( space_name ) )
|
try:
|
if not s.spaces.has_key( space_name ): return False if s.spaces[ space_name ].has_key( "password" ):
|
def has_password( s, space_name ): try: return s.spaces[ space_name ][ "password" ] != None except KeyError: return False
|
except KeyError:
|
else:
|
def has_password( s, space_name ): try: return s.spaces[ space_name ][ "password" ] != None except KeyError: return False
|
proxy = xmlrpclib.ServerProxy(args[0])
|
server = xmlrpclib.ServerProxy(args[0])
|
def main(): usage = "usage: %prog [options] url" parser = optparse.OptionParser(usage) parser.add_option("-n", "--namespace", dest="namespace", help="function namespace to use") parser.add_option("-e", "--encoding", dest="encoding", default=default_encoding, help='encoding to report [default: "%s"]' % default_encoding) parser.add_option("-a", "--argument", dest="filter_args", default=[], help="the name of an XmlRpcFilteringPipe " \ "argument, followed by its string value", action="append", type="string", nargs=2) (options, args) = parser.parse_args() if len(args) != 1: parser.error("incorrect number of arguments") data = xmlrpclib.Binary(sys.stdin.read()) filter_args = {} for key, val in options.filter_args: filter_args[key] = val proxy = xmlrpclib.ServerProxy(args[0]) function_name = "filterData" if options.namespace: function_name = "%s.%s" % (options.namespace, function_name) print getattr(proxy,function_name)(data, options.encoding, filter_args)
|
print getattr(proxy,function_name)(data, options.encoding, filter_args)
|
result = getattr(server, function_name)(data, options.encoding, filter_args) if options.show_content_type: print result["contentType"] print result["data"]
|
def main(): usage = "usage: %prog [options] url" parser = optparse.OptionParser(usage) parser.add_option("-n", "--namespace", dest="namespace", help="function namespace to use") parser.add_option("-e", "--encoding", dest="encoding", default=default_encoding, help='encoding to report [default: "%s"]' % default_encoding) parser.add_option("-a", "--argument", dest="filter_args", default=[], help="the name of an XmlRpcFilteringPipe " \ "argument, followed by its string value", action="append", type="string", nargs=2) (options, args) = parser.parse_args() if len(args) != 1: parser.error("incorrect number of arguments") data = xmlrpclib.Binary(sys.stdin.read()) filter_args = {} for key, val in options.filter_args: filter_args[key] = val proxy = xmlrpclib.ServerProxy(args[0]) function_name = "filterData" if options.namespace: function_name = "%s.%s" % (options.namespace, function_name) print getattr(proxy,function_name)(data, options.encoding, filter_args)
|
"suppress-final": don't use "X FINAL"
|
def lookup(path, url, flags): """ Resolve a path to a URL. Returns the resolved URL. path: ["space", "space", ..., "name"] url: "http://url.to.first.namespace.description/" flags: Python 2.3 Set of flags The following flags are understood: "no-case": ignore capitalization "no-punctuation": ignore punctuation "no-space": ignore white space "forgive-spelling": accept plausible mis-spellings "loose": "no-case" + "no-punctuation" + "no-space" + "check-neighboring-spaces" + "check-neighboring-spaces": check spaces linked by NS "reverse": reverse lookup (URL, not name, at end of path) "NS": namespace-lookup; (NS, not LN, at end of path) """ flags = sets.Set(flags) if "loose" in flags: flags = flags | loose_flags flags.discard("loose") assert len(path) > 0 namespace = get_namespace(url) if len(path) == 1: if "NS" in flags: records = namespace["NS-raw"] else: records = namespace["LN-raw"] # If "loose" flags are being used, try resolving without loose # flags, first. If there is an exact match, it has priority. if flags & loose_flags: result = _check_list(path[0], records, flags - loose_flags) if result: return result result = _check_list(path[0], records, flags) if result: return result if "check-neighboring-spaces" in flags: wo_neighboring = flags.copy() wo_neighboring.discard("check-neighboring-spaces") urls = sets.Set() for num, neighborname, url in namespace["NS-raw"]: if url not in urls: result = lookup([path[0]], url, wo_neighboring) if result: return result urls.add(url) if ("FINAL" in namespace["X"]) and ("reverse" not in flags): return namespace["X"]["FINAL"][0].replace("$PAGE", path[0]) return None else: pattern_raw = namespace["PATTERN-raw"] ns_raw = namespace["NS-raw"] original_flags = flags flags = flags.copy() flags.discard("reverse") if flags & loose_flags: result = _check_list(path[0], pattern_raw, flags - loose_flags) if result: return result.replace("$PAGE", path[1]) result = _check_list(path[0], ns_raw, flags - loose_flags) if result: return lookup(path[1:], result, original_flags) result = _check_list(path[0], pattern_raw, flags) if result: return result.replace("$PATH", path[1]) result = _check_list(path[0], ns_raw, flags) if result: return lookup(path[1:], result, original_flags) return None
|
|
if ("FINAL" in namespace["X"]) and ("reverse" not in flags):
|
if (not "suppress-final" in flags) and ("reverse" not in flags) and \ ("FINAL" in namespace["X"]):
|
def lookup(path, url, flags): """ Resolve a path to a URL. Returns the resolved URL. path: ["space", "space", ..., "name"] url: "http://url.to.first.namespace.description/" flags: Python 2.3 Set of flags The following flags are understood: "no-case": ignore capitalization "no-punctuation": ignore punctuation "no-space": ignore white space "forgive-spelling": accept plausible mis-spellings "loose": "no-case" + "no-punctuation" + "no-space" + "check-neighboring-spaces" + "check-neighboring-spaces": check spaces linked by NS "reverse": reverse lookup (URL, not name, at end of path) "NS": namespace-lookup; (NS, not LN, at end of path) """ flags = sets.Set(flags) if "loose" in flags: flags = flags | loose_flags flags.discard("loose") assert len(path) > 0 namespace = get_namespace(url) if len(path) == 1: if "NS" in flags: records = namespace["NS-raw"] else: records = namespace["LN-raw"] # If "loose" flags are being used, try resolving without loose # flags, first. If there is an exact match, it has priority. if flags & loose_flags: result = _check_list(path[0], records, flags - loose_flags) if result: return result result = _check_list(path[0], records, flags) if result: return result if "check-neighboring-spaces" in flags: wo_neighboring = flags.copy() wo_neighboring.discard("check-neighboring-spaces") urls = sets.Set() for num, neighborname, url in namespace["NS-raw"]: if url not in urls: result = lookup([path[0]], url, wo_neighboring) if result: return result urls.add(url) if ("FINAL" in namespace["X"]) and ("reverse" not in flags): return namespace["X"]["FINAL"][0].replace("$PAGE", path[0]) return None else: pattern_raw = namespace["PATTERN-raw"] ns_raw = namespace["NS-raw"] original_flags = flags flags = flags.copy() flags.discard("reverse") if flags & loose_flags: result = _check_list(path[0], pattern_raw, flags - loose_flags) if result: return result.replace("$PAGE", path[1]) result = _check_list(path[0], ns_raw, flags - loose_flags) if result: return lookup(path[1:], result, original_flags) result = _check_list(path[0], pattern_raw, flags) if result: return result.replace("$PATH", path[1]) result = _check_list(path[0], ns_raw, flags) if result: return lookup(path[1:], result, original_flags) return None
|
return result.replace("$PAGE", path[1])
|
return result.replace("$NAME", path[1])
|
def lookup(path, url, flags): """ Resolve a path to a URL. Returns the resolved URL. path: ["space", "space", ..., "name"] url: "http://url.to.first.namespace.description/" flags: Python 2.3 Set of flags The following flags are understood: "no-case": ignore capitalization "no-punctuation": ignore punctuation "no-space": ignore white space "forgive-spelling": accept plausible mis-spellings "loose": "no-case" + "no-punctuation" + "no-space" + "check-neighboring-spaces" + "check-neighboring-spaces": check spaces linked by NS "reverse": reverse lookup (URL, not name, at end of path) "NS": namespace-lookup; (NS, not LN, at end of path) """ flags = sets.Set(flags) if "loose" in flags: flags = flags | loose_flags flags.discard("loose") assert len(path) > 0 namespace = get_namespace(url) if len(path) == 1: if "NS" in flags: records = namespace["NS-raw"] else: records = namespace["LN-raw"] # If "loose" flags are being used, try resolving without loose # flags, first. If there is an exact match, it has priority. if flags & loose_flags: result = _check_list(path[0], records, flags - loose_flags) if result: return result result = _check_list(path[0], records, flags) if result: return result if "check-neighboring-spaces" in flags: wo_neighboring = flags.copy() wo_neighboring.discard("check-neighboring-spaces") urls = sets.Set() for num, neighborname, url in namespace["NS-raw"]: if url not in urls: result = lookup([path[0]], url, wo_neighboring) if result: return result urls.add(url) if ("FINAL" in namespace["X"]) and ("reverse" not in flags): return namespace["X"]["FINAL"][0].replace("$PAGE", path[0]) return None else: pattern_raw = namespace["PATTERN-raw"] ns_raw = namespace["NS-raw"] original_flags = flags flags = flags.copy() flags.discard("reverse") if flags & loose_flags: result = _check_list(path[0], pattern_raw, flags - loose_flags) if result: return result.replace("$PAGE", path[1]) result = _check_list(path[0], ns_raw, flags - loose_flags) if result: return lookup(path[1:], result, original_flags) result = _check_list(path[0], pattern_raw, flags) if result: return result.replace("$PATH", path[1]) result = _check_list(path[0], ns_raw, flags) if result: return lookup(path[1:], result, original_flags) return None
|
return collect_names('<html>' + xhtml_fragment + '</xhtml>')
|
return collect_names('<html>' + xhtml_fragment + '</html>')
|
def collect_names_in_fragment(xhtml_fragment): """Build a list of names to lookup, given an XHTML fragment. This is a convenience function. The fragment must contain no errors. """ return collect_names('<html>' + xhtml_fragment + '</xhtml>')
|
return xmlrpclib.dumps((result,))
|
return xmlrpclib.dumps((ns2,))
|
def xmlrpc_render(self, format, url): if type(url) == type([]): ns = localnames.aggregate(url) else: ns = localnames.get_namespace(url) if format in ["XML-RPC", "XML-RPC-text"]: ns2 = {} for k in ["LN", "X", "NS", "PATTERN"]: ns2[k] = un_unicode_dict(ns[k]) if format == "XML-RPC": return ns2 else: return xmlrpclib.dumps((result,)) elif format == "version1.1": return localnames.clean(ns) elif format == "version1.1-original": return ns["TEXT"]
|
httpd = BaseHTTPServer.HTTPServer(("services.taoriver.net", 9090), LocalNamesHandler)
|
httpd = BaseHTTPServer.HTTPServer(("localhost", 9001), LocalNamesHandler)
|
def xmlrpc_render(self, format, url): if type(url) == type([]): ns = localnames.aggregate(url) else: ns = localnames.get_namespace(url) if format in ["XML-RPC", "XML-RPC-text"]: ns2 = {} for k in ["LN", "X", "NS", "PATTERN"]: ns2[k] = un_unicode_dict(ns[k]) if format == "XML-RPC": return ns2 else: return xmlrpclib.dumps((result,)) elif format == "version1.1": return localnames.clean(ns) elif format == "version1.1-original": return ns["TEXT"]
|
preferred_name = ns["X"].get("PREFERRED-NAME", [None])[0]
|
preferred_name = ns["X"].get("PREFERRED-NAME", ["(none)"])[0]
|
def xmlrpc_cached(self): results = [] for url, ns in localnames.store.items(): preferred_name = ns["X"].get("PREFERRED-NAME", [None])[0] ttl = int(ns["TIME"] + localnames.time_to_live - time.time()) results.append((url, preferred_name, ttl)) return results
|
(SOFTLINK_BASE)?action=redir&url=(URL)&lookup=foo&lookup=bar
|
(SOFTLINK_BASE)?action=redirect&url=(URL)&lookup=foo&lookup=bar
|
def replace_text(text, namespace_url, softlink_base=""): """ Replace links denoted by [[foo]] with A HREFs. text: text to make replacements in namespace_url: URL of namespace to start from softlink_base: URL base to softlink from Examples: [[some name]] [[NS link][NS link][LN name]] [[some name]some other text covering it] [[NS link][LN name]some other text] Softlinks have the form: ((foo)(bar)) ...which becomes a link to: (SOFTLINK_BASE)?action=redir&url=(URL)&lookup=foo&lookup=bar """ def replace_link(match): flags = sets.Set(["loose", "check-neighboring-spaces"]) path = match.group(1)[1:-1].split('][') url = lookup(path, namespace_url, flags) title = match.group(2) if title == None: title = path[-1] return '<a href="%s">%s</a>' % (url, cgi.escape(title)) def replace_softlink(match): flags = sets.Set(["loose", "check-neighboring-spaces"]) path = match.group(1)[1:-1].split(')(') map = {'action': 'redir', 'url': namespace_url, 'lookup': path} url = softlink_base + "?" + urllib.urlencode(map, True) title = match.group(2) if title == None: title = path[-1] return '<a href="%s">%s</a>' % (url, cgi.escape(title)) text = link_re.sub(replace_link, text) text = softlink_re.sub(replace_softlink, text) return text
|
map = {'action': 'redir', 'url': namespace_url, 'lookup': path}
|
map = {'action': 'redirect', 'url': namespace_url, 'lookup': path}
|
def replace_softlink(match): flags = sets.Set(["loose", "check-neighboring-spaces"]) path = match.group(1)[1:-1].split(')(') map = {'action': 'redir', 'url': namespace_url, 'lookup': path} url = softlink_base + "?" + urllib.urlencode(map, True) title = match.group(2) if title == None: title = path[-1] return '<a href="%s">%s</a>' % (url, cgi.escape(title))
|
return s.pattern.replace( "$PAGE", name )
|
return s.pattern.replace( "$NAME", name )
|
def default_for_name(s, name): """ returns a name, made to fit the default page pattern """ if s.pattern == None: return None return s.pattern.replace( "$PAGE", name )
|
pass
|
self.namespace.meta[key] = value
|
def meta(self, key, value): pass
|
self.page_cache.dump(url)
|
self.page_cache.dump_page(url)
|
def dump_cache(self, url): """DOC
|
connection.readline ()
|
msg = connection.readline ()
|
def _connect (self): self._set_state (CONNECTING) waitfor = self._waitfor connection = pexpect.spawn ('nxssh -nx -p %d -i %s nx@%s -2 -S' % \ (self.port, self.sshkey, self.host)) self.connection = connection connection.setlog (self.log)
|
if self._yes_no_dialog (''):
|
msg += connection.before + '?' if self._yes_no_dialog (msg):
|
def _connect (self): self._set_state (CONNECTING) waitfor = self._waitfor connection = pexpect.spawn ('nxssh -nx -p %d -i %s nx@%s -2 -S' % \ (self.port, self.sshkey, self.host)) self.connection = connection connection.setlog (self.log)
|
for line in lines: tokens = string.split(line) if (tokens != []):
|
smoothing_group = 127 for line in lines: tokens = string.split(line) if (tokens != []): if (tokens[0] == 's'): smoothing_group = smoothing_group + 1 if (smoothing_group > 255): smoothing_group = 0
|
def vertex_reference(n, nv): if (n < 0): return n + nv return n - 1
|
faces_lines_out.append('127,127,127,\t%.5f,%.5f,%.5f,\t3,\t%d,%d,%d\n' % (norm[0],norm[1],norm[2],v1,v2,v3))
|
faces_lines_out.append('%d,127,127,\t%.5f,%.5f,%.5f,\t3,\t%d,%d,%d\n' % (smoothing_group,norm[0],norm[1],norm[2],v1,v2,v3))
|
def vertex_reference(n, nv): if (n < 0): return n + nv return n - 1
|
return self.get_value(iter, COLUMN_ENTRY).copy()
|
e = self.get_value(iter, COLUMN_ENTRY) if e is None: return None else: return e.copy()
|
def get_entry(self, iter): "Fetches data for an entry"
|
( ( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL ), ( gtk.STOCK_OK, gtk.RESPONSE_CANCEL ) )
|
( ( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL ), ( gtk.STOCK_OK, gtk.RESPONSE_OK ) ), gtk.RESPONSE_CANCEL
|
def run(self): "Displays the dialog"
|
self.entry.desc = self.entry_desc.get_text()
|
self.entry.description = self.entry_desc.get_text()
|
def run(self): "Displays the dialog"
|
self.hbox.set_size_request(-1, 16)
|
def __init__(self, text = None): Alignment.__init__(self)
|
|
self.iconebox.set_border_width(2)
|
def __init__(self, text = None): Alignment.__init__(self)
|
|
allocation = self.get_allocation()
|
def __cb_expose(self, widget, data): "Draws the widget borders on expose"
|
|
self.ensure_style()
|
def __cb_size_request(self, widget, requisition): "Modifies the widget size request"
|
|
if self.child.get_property("visible") == True: child_width, child_height = self.child.size_request() requisition.width += child_width requisition.height += child_height
|
entrywidth, entryheight = self.entry.size_request() requisition.height += entryheight >= 18 and entryheight or 18
|
def __cb_size_request(self, widget, requisition): "Modifies the widget size request"
|
if self.iconebox in self.hbox.get_children(): self.hbox.remove(self.iconebox)
|
if self.iconalign in self.hbox.get_children(): self.hbox.remove(self.iconalign)
|
def set_icon(self, stock, tooltip = ""): "Sets the icon for the entry"
|
self.hbox.pack_start(self.iconebox, False, False)
|
self.hbox.pack_start(self.iconalign, False, False)
|
def set_icon(self, stock, tooltip = ""): "Sets the icon for the entry"
|
icons[STOCK_ENTRY_FOLDER] = "revelation-fallback-folder-open"
|
icons[STOCK_ENTRY_FOLDER_OPEN] = "revelation-fallback-folder-open"
|
def __init_entryicons(self): "Loads entry icons"
|
self.iconebox.modify_bg(gtk.STATE_NORMAL, self.entry.rc_get_style().base[gtk.STATE_NORMAL])
|
self.iconebox.set_visible_window(False)
|
def __init__(self, text = None): Alignment.__init__(self)
|
if self.entry.flags() & gtk.HAS_FOCUS == True and intfocus == False:
|
if self.entry.flags() & gtk.HAS_FOCUS == gtk.HAS_FOCUS and intfocus == False:
|
def __cb_expose(self, widget, data): "Draws the widget borders on expose"
|
if self.entry.flags() & gtk.HAS_FOCUS == True and intfocus == False: x -= focus_width y -= focus_width width += 2 * focus_width height += 2 * focus_width
|
if self.entry.flags() & gtk.HAS_FOCUS == gtk.HAS_FOCUS and intfocus == False: x -= focuswidth y -= focuswidth width += 2 * focuswidth height += 2 * focuswidth
|
def __cb_expose(self, widget, data): "Draws the widget borders on expose"
|
if self.flags() & gtk.REALIZED == True: child_allocation.x = self.border_width child_allocation.y = self.border_width child_allocation.width = max(allocation.width - self.border_width * 2, 0) child_allocation.height = max(allocation.height - self.border_width * 2, 0) self.window.move_resize(allocation.x + child_allocation.x, allocation.y + child_allocation.y, child_allocation.width, child_allocation.height)
|
def __cb_size_allocate(self, widget, allocation): "Modifies the widget size allocation"
|
|
self.hpaned = revelation.widget.HPaned(self.tree, alignment, self.gconf.get_int("/apps/revelation/view/pane-position"))
|
self.hpaned = revelation.widget.HPaned(scrolledwindow, alignment, self.gconf.get_int("/apps/revelation/view/pane-position"))
|
def __init_mainarea(self): self.tree = Tree(self.data) self.tree.connect("button_press_event", self.__cb_popup_tree) self.tree.selection.connect("changed", self.__cb_entry_display) self.tree.selection.connect("changed", self.__cb_state_entry)
|
field = "" field += "".join([ chr(len(value) >> i * 8) for i in range(4) ]) field += "".join([ chr(type >> i * 8) for i in range(4) ]) field += value
|
field = struct.pack("ii", len(value), type) + value
|
def create_field(value, type = FIELDTYPE_NAME): "Creates a field" field = "" field += "".join([ chr(len(value) >> i * 8) for i in range(4) ]) field += "".join([ chr(type >> i * 8) for i in range(4) ]) field += value if len(value) == 0 or len(value) % 8 != 0: field += "\x00" * (8 - len(value) % 8) return field
|
length = ord(header[0]) << 0 | ord(header[1]) << 8 | ord(header[2]) << 16 | ord(header[3]) << 24
|
length, type = struct.unpack("ii", header[:8])
|
def parse_field_header(header): "Parses field data, returns the length and type" if len(header) < 8: raise base.FormatError # get length length = ord(header[0]) << 0 | ord(header[1]) << 8 | ord(header[2]) << 16 | ord(header[3]) << 24 if length == 0 or length % 8 != 0: length += 8 - length % 8 # get type type = ord(header[4]) << 0 | ord(header[5]) << 8 | ord(header[6]) << 16 | ord(header[7]) << 24 return length, type
|
type = ord(header[4]) << 0 | ord(header[5]) << 8 | ord(header[6]) << 16 | ord(header[7]) << 24
|
def parse_field_header(header): "Parses field data, returns the length and type" if len(header) < 8: raise base.FormatError # get length length = ord(header[0]) << 0 | ord(header[1]) << 8 | ord(header[2]) << 16 | ord(header[3]) << 24 if length == 0 or length % 8 != 0: length += 8 - length % 8 # get type type = ord(header[4]) << 0 | ord(header[5]) << 8 | ord(header[6]) << 16 | ord(header[7]) << 24 return length, type
|
|
self.entrystore.update_entry(iter, data[0]["predata"])
|
self.entrystore.update_entry(iter, action.data[0]["data"][1])
|
def execute(self, action, method = UNDO): "Executes and undo or redo action"
|
self.entrystore.update_entry(iter, data[0]["data"])
|
self.entrystore.update_entry(iter, action.data[0]["data"][0])
|
def execute(self, action, method = UNDO): "Executes and undo or redo action"
|
menu = menubaritem.get_submenu() for item in menu.get_children(): if type(item) in [ gtk.MenuItem, gtk.ImageMenuItem, gtk.CheckMenuItem ]: item.connect("select", self.__cb_menudesc, gtk.TRUE) item.connect("deselect", self.__cb_menudesc, gtk.FALSE)
|
self.__connect_menu_statusbar(menubaritem.get_submenu())
|
def set_menus(self, menubar): "Sets the menus"
|
self.result.set(0, 0.5, 0, 0)
|
def __init__(self, parent, cfg = None, clipboard = None): Utility.__init__( self, parent, _('Password Checker'), ( ( gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE ), ) )
|
|
self.sect_fields = self.add_section("Account data")
|
self.sect_fields = self.add_section("Account Data")
|
def __init__(self, parent, cfg, title, e = None): Utility.__init__( self, parent, title, ( ( gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL ), ( e is None and ui.STOCK_NEW_ENTRY or ui.STOCK_EDIT, gtk.RESPONSE_OK ) ) )
|
gnome.ui.App.add_toolbar(self, toolbar, name, 16 | 1, 0, band, 0, 0)
|
def add_toolbar(self, toolbar, name, band): "Adds a toolbar"
|
|
header += "\x00\x04\x03"
|
header += "\x00\x04\x05"
|
def __generate_header(self): "Generates a header"
|
GConfHandler.gconf_bind(self, key, self.__cb_gconf_get, self.__cb_gconf_set, "changed")
|
GConfHandler.gconf_bind(self, key, self.__cb_gconf_get, self.__cb_gconf_set, "value-changed")
|
def gconf_bind(self, key): GConfHandler.gconf_bind(self, key, self.__cb_gconf_get, self.__cb_gconf_set, "changed")
|
if data.button == 1 and data.type == gtk.gdk._2BUTTON_PRESS and path is not None:
|
if data.button == 1 and data.type == gtk.gdk._2BUTTON_PRESS and path != None:
|
def __cb_buttonpress(self, widget, data): "Callback for handling mouse clicks"
|
if data.button == 3: if path is not None and self.selection.iter_is_selected(self.model.get_iter(path[0])) == False:
|
elif data.button == 3: if path != None and self.selection.iter_is_selected(self.model.get_iter(path[0])) == False:
|
def __cb_buttonpress(self, widget, data): "Callback for handling mouse clicks"
|
return encrypt(data)
|
return encrypt(data, password)
|
def export_data(self, entrystore, password): "Exports data to a data stream"
|
while len(e.description) + 1 < desclen and len(lines) > 0: e.description += lines[0]
|
d = "" while len(d) < desclen and len(lines) > 0: d += lines[0] + "\n"
|
def import_data(self, input, password): "Imports data from a data stream to an entrystore"
|
self.__monitor(file)
|
gobject.idle_add(lambda: self.__monitor(file))
|
def save(self, entrystore, file, password = None): "Saves an entrystore to a file"
|
self.emit("doubleclick", iter)
|
if iter != None: self.emit("doubleclick", iter)
|
def __cb_buttonpress(self, widget, data): "Callback for handling mouse clicks"
|
if enableAction: identity = self._getIdentityFromSelection()
|
identity = self._getIdentityFromSelection() if enableAction and identity:
|
def _enableActions(self): enableAction = (len(self.model) > 0) self.miEdit.set_sensitive(enableAction) self.btnEdit.set_sensitive(enableAction) self.miDel.set_sensitive(enableAction) self.btnDel.set_sensitive(enableAction) if enableAction: identity = self._getIdentityFromSelection() features = transport.FEATURES[identity.transportType] self.miDiscover.set_sensitive('discovery' in features)
|
model, selected = selection.get_selected() return model.get_value(selected, 2)
|
if selection: model, selected = selection.get_selected() return model.get_value(selected, 2)
|
def _getIdentityFromSelection(self): selection = self.lvIdentities.get_selection() model, selected = selection.get_selected() return model.get_value(selected, 2)
|
if DEBUG: print 'Polling events from queue...'
|
def _pollEventQueue(self): if DEBUG: print 'Polling events from queue...' try: event, data = self.events.get_nowait() buf = self.txLog.get_buffer() buf.insert(buf.get_end_iter(), data) buf.insert(buf.get_end_iter(), '\n') except Queue.Empty: pass return True
|
|
unicode(msg), QMessageBox.Ok)
|
unicode(msg, 'UTF-8', 'replace'), QMessageBox.Ok)
|
def customEvent(self, e): t = e.type() if t == 10000: # sender thread ended work self.statusBar().message(self.__tr('Finished sending message')) msg = e.data() if msg is None: msg = self.__tr('Message has been sent.') QMessageBox.information(self, self.__tr('Information'), unicode(msg), QMessageBox.Ok) self.msgItemSelected() elif t == 10001: # sender thread started work self.statusBar().message(self.__tr('Sending message...'))
|
unicode(msg), QMessageBox.Ok)
|
unicode(msg, 'UTF-8', 'replace'), QMessageBox.Ok)
|
def notify(self, message): if message == 'item added': e = self.events.get_nowait() t = e.type() if t == 10000: # sender thread ended work self.statusBar().message(self.__tr('Finished sending message')) msg = e.data() if msg is None: msg = self.__tr('Message has been sent.') QMessageBox.information(self, self.__tr('Information'), unicode(msg), QMessageBox.Ok) self.msgItemSelected() elif t == 10001: # sender thread started work self.statusBar().message(self.__tr('Sending message...'))
|
if selection:
|
if not (None in selection.get_selected()):
|
def _getIdentityFromSelection(self): selection = self.lvIdentities.get_selection() if selection: model, selected = selection.get_selected() return model.get_value(selected, 2)
|
self.controller.discoverWeblogs(identity, self)
|
if identity: self.controller.discoverWeblogs(identity, self)
|
def _discoverWeblogs(self, *args): identity = self._getIdentityFromSelection() self.controller.discoverWeblogs(identity, self)
|
monthStore.append((datetime.date(2005, i + 1, 1).strftime('%B'), ))
|
monthStr = datetime.date(2005, i + 1, 1).strftime('%B') enc = locale.getdefaultlocale()[1] monthStore.append((monthStr.decode(enc), ))
|
def _initGui(self): monthStore = gtk.ListStore(str) # stupid hack for i in range(12): monthStore.append((datetime.date(2005, i + 1, 1).strftime('%B'), )) self.cbxMonth.set_model(monthStore) cell = gtk.CellRendererText() self.cbxMonth.pack_start(cell, True) self.cbxMonth.add_attribute(cell, 'text', 0) self.cbxMonth.set_active(0)
|
identity = model.get_value(self.cbxIdentity.get_active_iter(), 1) features = transport.FEATURES[identity.transportType] self.edWeblogID.set_sensitive('blogID' in features)
|
if len(model) > 0: identity = model.get_value(self.cbxIdentity.get_active_iter(), 1) features = transport.FEATURES[identity.transportType] self.edWeblogID.set_sensitive('blogID' in features)
|
def _activateFeatures(self): model = self.cbxIdentity.get_model() identity = model.get_value(self.cbxIdentity.get_active_iter(), 1) features = transport.FEATURES[identity.transportType] self.edWeblogID.set_sensitive('blogID' in features)
|
gobject.source_remove(self.autosaveTimer)
|
if self.autosaveTimer: gobject.source_remove(self.autosaveTimer)
|
def on_frmEntry_delete_event(self, *args): gobject.source_remove(self.autosaveTimer)
|
gobject.source_remove(self.autosaveTimer)
|
if self.autosaveTimer: gobject.source_remove(self.autosaveTimer)
|
def on_btnCancel_clicked(self, *args): gobject.source_remove(self.autosaveTimer) if self.isNew and self.entry: self.entry.destroySelf() self.window.destroy()
|
body = textile.textile(parent.parent.cfg.useReplacements(message['body']))
|
body = textile.textile(message['body'])
|
def __init__(self, message, parent, name=None, modal=0, fl=0): MsgPreviewDialogImpl.__init__(self, parent, name, modal, fl) qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) try: self.setCaption('%s - %s' % (self.__tr('Message preview'), unicode(message['title']))) if message['content-type'] == 'textile': body = textile.textile(parent.parent.cfg.useReplacements(message['body'])) else: body = parent.parent.cfg.useReplacements(message['body']) msgText = MSGTEMPLATE % (message['title'], body) self.tbPreview.setText(msgText) finally: qApp.restoreOverrideCursor()
|
body = parent.parent.cfg.useReplacements(message['body'])
|
body = message['body']
|
def __init__(self, message, parent, name=None, modal=0, fl=0): MsgPreviewDialogImpl.__init__(self, parent, name, modal, fl) qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) try: self.setCaption('%s - %s' % (self.__tr('Message preview'), unicode(message['title']))) if message['content-type'] == 'textile': body = textile.textile(parent.parent.cfg.useReplacements(message['body'])) else: body = parent.parent.cfg.useReplacements(message['body']) msgText = MSGTEMPLATE % (message['title'], body) self.tbPreview.setText(msgText) finally: qApp.restoreOverrideCursor()
|
self.setCaption('%s - %s' % (self.__tr('Message previev'),
|
self.setCaption('%s - %s' % (self.__tr('Message preview'),
|
def __init__(self, message, parent, name=None, modal=0, fl=0): MsgPreviewDialogImpl.__init__(self, parent, name, modal, fl) qApp.setOverrideCursor(QCursor(Qt.WaitCursor)) try: self.setCaption('%s - %s' % (self.__tr('Message previev'), unicode(message['title']))) if message['content-type'] == 'textile': body = textile.textile(parent.parent.cfg.useReplacements(message['body'])) else: body = parent.parent.cfg.useReplacements(message['body']) msgText = MSGTEMPLATE % (message['title'], body) self.tbPreview.setText(msgText) finally: qApp.restoreOverrideCursor()
|
body['pubDate'] = datetime.datetime.now().isoformat()
|
body['pubDate'] = email.Utils.formatdate(usegmt=True)
|
def postNew(self, blogId, entry, categories): if DEBUG: print 'started sending' s = self.getServerProxy() body = {} body['flNotOnHomePage'] = False body['title'] = entry.title.encode('utf-8') body['description'] = renderBodyAsXML(entry.body.encode('utf-8'), entry.bodyType) body['categories'] = [] for category in categories: body['categories'].append(category.name.encode('utf-8')) body['pubDate'] = datetime.datetime.now().isoformat() body['guid'] = AGENT body['author'] = self.userName.encode('utf-8') if DEBUG: print body try: assignedId = s.metaWeblog.newPost(blogId, self.userName, self.passwd, body, not entry.isDraft) return assignedId except xmlrpclib.Fault, e: raise api.ServiceError(e.faultString)
|
body['pubDate'] = datetime.datetime.now().isoformat()
|
body['pubDate'] = email.Utils.formatdate(usegmt=True)
|
def postModified(self, blogId, entryId, entry, categories): if DEBUG: print 'started sending modified entry' s = self.getServerProxy() body = {} body['flNotOnHomePage'] = False body['title'] = entry.title.encode('utf-8') body['description'] = renderBodyAsXML(entry.body.encode('utf-8'), entry.bodyType) body['categories'] = [] for category in categories: body['categories'].append(category.name.encode('utf-8')) body['pubDate'] = datetime.datetime.now().isoformat() body['guid'] = AGENT body['author'] = self.userName.encode('utf-8') try: s.metaWeblog.editPost(entryId, self.userName, self.passwd, body, not entry.isDraft) except xmlrpclib.Fault, e: raise api.ServiceError(e.faultString)
|
common.inprint("DEBUG_ASSERT(s" + str(i) + ".hasValues());")
|
common.inprint("SH_DEBUG_ASSERT(s" + str(i) + ".hasValues());")
|
def scalarcons(self, args, size, extraTplArg=[]): common.inprint(self.tpl(size)) if len(extraTplArg) > 0: common.inprint("template<" + ", ".join(extraTplArg) + ">") #common.inprint("inline") common.inprint(self.tplcls(size) + "::" + self.name + "(" + ', '.join([' '.join(x) for x in args]) + ")") common.inprint(" : Generic<" + self.sizevar(size) + ", T>" + "(new VariableNode(Binding, " + self.sizevar(size) + ", StorageTypeInfo<T>::value_type, Semantic))") common.inprint("{") common.indent() common.inprint("if (Binding == SH_CONST) {") common.indent() if size > 1: values = "" for i in range(0, size): if i > 0: values += ", " if args[0][0] == "const host_type": values += "s" + str(i) else: common.inprint("DEBUG_ASSERT(s" + str(i) + ".hasValues());") values += "s" + str(i) + ".getValue(0)" common.inprint("host_type data[" + str(size) + "] = {" + values + "};") common.inprint("setValues(data);") else: if args[0][0] == "const host_type": common.inprint("setValue(0, s0);") else: common.inprint("DEBUG_ASSERT(s0.hasValues());") common.inprint("setValue(0, s0.getValue(0));") common.deindent() common.inprint("} else {") common.indent() if args[0][0] != "const host_type": for i in range(0, size): common.inprint("(*this)[" + str(i) + "] = s" + str(i) + ";") else: data = "" for i in range(0, size): if data != "": data += ", " data += "s" + str(i) common.inprint("(*this) = Attrib<" + self.sizevar(size) + ", SH_CONST, T, Semantic>(" + data + ");") common.deindent() common.inprint("}") common.deindent() common.inprint("}") common.inprint("")
|
common.inprint("DEBUG_ASSERT(s0.hasValues());")
|
common.inprint("SH_DEBUG_ASSERT(s0.hasValues());")
|
def scalarcons(self, args, size, extraTplArg=[]): common.inprint(self.tpl(size)) if len(extraTplArg) > 0: common.inprint("template<" + ", ".join(extraTplArg) + ">") #common.inprint("inline") common.inprint(self.tplcls(size) + "::" + self.name + "(" + ', '.join([' '.join(x) for x in args]) + ")") common.inprint(" : Generic<" + self.sizevar(size) + ", T>" + "(new VariableNode(Binding, " + self.sizevar(size) + ", StorageTypeInfo<T>::value_type, Semantic))") common.inprint("{") common.indent() common.inprint("if (Binding == SH_CONST) {") common.indent() if size > 1: values = "" for i in range(0, size): if i > 0: values += ", " if args[0][0] == "const host_type": values += "s" + str(i) else: common.inprint("DEBUG_ASSERT(s" + str(i) + ".hasValues());") values += "s" + str(i) + ".getValue(0)" common.inprint("host_type data[" + str(size) + "] = {" + values + "};") common.inprint("setValues(data);") else: if args[0][0] == "const host_type": common.inprint("setValue(0, s0);") else: common.inprint("DEBUG_ASSERT(s0.hasValues());") common.inprint("setValue(0, s0.getValue(0));") common.deindent() common.inprint("} else {") common.indent() if args[0][0] != "const host_type": for i in range(0, size): common.inprint("(*this)[" + str(i) + "] = s" + str(i) + ";") else: data = "" for i in range(0, size): if data != "": data += ", " data += "s" + str(i) common.inprint("(*this) = Attrib<" + self.sizevar(size) + ", SH_CONST, T, Semantic>(" + data + ");") common.deindent() common.inprint("}") common.deindent() common.inprint("}") common.inprint("")
|
common.inprint("assert(!ShEnvironment::insideShader);") common.inprint("assert(" + other + ".hasValues());")
|
common.inprint("SH_DEBUG_ASSERT(!ShEnvironment::insideShader);") common.inprint("SH_DEBUG_ASSERT(" + other + ".hasValues());")
|
def copycons(self, args, size): other = args[0][1]
|
def assign(self, fun, args, size): common.inprint(self.tpl(size) + "\n" + self.tplcls(size) + "&\n" + self.tplcls(size) + "::" + fun + "(" + ', '.join([' '.join(x) for x in args]) + ")") common.inprint("{") common.indent() other = args[0][1] if fun[-1] == "=" and fun[-2] in ["+", "-", "/", "*"]: common.inprint("*this = *this " + fun[-2] + " " + other + ";") else: common.inprint("if (Binding == SH_CONST || uniform()) {") common.indent() common.inprint("assert(!ShEnvironment::insideShader);") common.inprint("assert(" + other + ".hasValues());") common.inprint("T data[" + self.sizevar(size) + "];") common.inprint(other + ".getValues(data);") common.inprint("setValues(data);") common.deindent() common.inprint("} else {") common.indent() common.inprint("ShStatement asn(*this, SH_OP_ASN, " + other + ");") common.inprint("ShEnvironment::shader->tokenizer.blockList()->addStatement(asn);") common.deindent() common.inprint("}")
|
def assign(self, fun, args, size): common.inprint(self.tpl(size) + "\n" + self.tplcls(size) + "&\n" + self.tplcls(size) + "::" + fun + "(" + ', '.join([' '.join(x) for x in args]) + ")") common.inprint("{") common.indent() other = args[0][1] if fun[-1] == "=" and fun[-2] in ["+", "-", "/", "*"]: common.inprint("*this = *this " + fun[-2] + " " + other + ";") else: common.inprint("if (Binding == SH_CONST || uniform()) {") common.indent() common.inprint("assert(!ShEnvironment::insideShader);") common.inprint("assert(" + other + ".hasValues());") common.inprint("T data[" + self.sizevar(size) + "];") common.inprint(other + ".getValues(data);") common.inprint("setValues(data);") common.deindent() common.inprint("} else {") common.indent() common.inprint("ShStatement asn(*this, SH_OP_ASN, " + other + ");") common.inprint("ShEnvironment::shader->tokenizer.blockList()->addStatement(asn);") common.deindent() common.inprint("}")
|
|
common.inprint("return *this;") common.deindent() common.inprint("}") common.inprint("")
|
def assign(self, fun, args, size): common.inprint(self.tpl(size) + "\n" + self.tplcls(size) + "&\n" + self.tplcls(size) + "::" + fun + "(" + ', '.join([' '.join(x) for x in args]) + ")") common.inprint("{") common.indent() other = args[0][1] if fun[-1] == "=" and fun[-2] in ["+", "-", "/", "*"]: common.inprint("*this = *this " + fun[-2] + " " + other + ";") else: common.inprint("if (Binding == SH_CONST || uniform()) {") common.indent() common.inprint("assert(!ShEnvironment::insideShader);") common.inprint("assert(" + other + ".hasValues());") common.inprint("T data[" + self.sizevar(size) + "];") common.inprint(other + ".getValues(data);") common.inprint("setValues(data);") common.deindent() common.inprint("} else {") common.indent() common.inprint("ShStatement asn(*this, SH_OP_ASN, " + other + ");") common.inprint("ShEnvironment::shader->tokenizer.blockList()->addStatement(asn);") common.deindent() common.inprint("}")
|
|
epsilon = ''
|
epsilon = ', ' + str(EPSILON)
|
def output(self, out, standalone=True): if standalone: self.output_header(out) self.output_textures(out) programs = {} test_nb = 0 for test, testcalls in self.tests: types = test[2] src_arg_types = zip(test[1], types[1:]) for i, call in enumerate(testcalls): testname = make_testname(src_arg_types, types, call.key(), test_nb) if not programs.has_key(testname): programs[testname] = [] progname = self.name + '_' + string.ascii_lowercase[i] + '_' + testname programs[testname].append(progname) out.write(' ShProgram ' + progname + ' = SH_BEGIN_PROGRAM("stream") {\n') for j, (arg, argtype) in enumerate(src_arg_types): out.write(' ' + make_variable(arg, 'SH_INPUT', argtype) + ' ' + string.ascii_lowercase[j] + ';\n') out.write(' ' + make_variable(test[0], 'SH_OUTPUT', types[0]) + ' out;\n') out.write(' ' + str(call) + ';\n') out.write(' } SH_END;\n\n') out.write(' ' + progname + '.name("' + progname + '");\n') out.write(' last_test = "' + progname + '";\n') for p in programs[testname]: out.write(' { // ' + testname + '\n') out.write(init_inputs(' ', src_arg_types)) out.write(init_expected(' ', test[0], types[0])) out.write('\n')
|
epsilon = ''
|
epsilon = ', ' + str(EPSILON)
|
def output(self, out, standalone=True): if standalone: self.output_header(out) self.output_textures(out) test_nb = 0 for test, testcalls in self.tests: types = test[2] src_arg_types = zip(test[1], types[1:]) for i, call in enumerate(testcalls): testname = make_testname(src_arg_types, types, call.key(), test_nb) out.write(' { // ' + testname + '\n') out.write(' last_test = "' + testname + '";\n') out.write(init_inputs(' ', src_arg_types, False)) out.write(init_expected(' ', test[0], types[0], False)) out.write('\n') out.write(' ' + make_variable(test[0], 'SH_TEMP', types[0], False) + ' out;\n') out.write(' ' + str(call) + ';\n') out.write('\n') self.start_catch(out) epsilon = '' if test[3] > 0: epsilon = ', ' + str(test[3]) out.write(' if (test.check("' + testname + '", out, expected' + epsilon + ') != 0) errors++;\n') self.end_catch(out) out.write('\n') out.write(' }\n') test_nb += 1 if standalone: self.output_footer(out)
|
test.add_test(func((1 - 0.1, -1 + 0.1, 0.0), op)) test.add_test(func((-0.5, -0.9, -0.1), op))
|
test.add_test(func((1 - 0.1, 0.0), op)) test.add_test(func((-1 + 0.1,), op, [], 0.09)) test.add_test(func((-0.5, -0.1), op))
|
def insert_into2(test, op): test.add_test(func((0.0,), op)) test.add_test(func((0.3, 0.5, 0.8, 0.9), op)) test.add_test(func((1 - 0.1, -1 + 0.1, 0.0), op)) test.add_test(func((-0.5, -0.9, -0.1), op)) test.add_test(func((0.5, 0.6, 0.9), op))
|
def length(a, types=[]):
|
def length(a):
|
def length(a, types=[]): s = 0 for x in a: s += x*x result = sqrt(s) return shtest.make_test([result], [a], types)
|
result = sqrt(s) return shtest.make_test([result], [a], types)
|
return [sqrt(s)]
|
def length(a, types=[]): s = 0 for x in a: s += x*x result = sqrt(s) return shtest.make_test([result], [a], types)
|
def insert_into(test): test.add_test(length((1.0, 2.0, 3.0))) test.add_test(length((1.0, 2.0, -3.0))) test.add_test(length((1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, 3.0))) test.add_test(length((-1.0, 2.0, 3.0)))
|
def length_1(a): result = 0 for x in a: result += abs(x) return [result]
|
def insert_into(test): test.add_test(length((1.0, 2.0, 3.0))) test.add_test(length((1.0, 2.0, -3.0))) test.add_test(length((1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, 3.0))) test.add_test(length((-1.0, 2.0, 3.0))) test.add_test(length((0.2, 2.7, 3.23))) test.add_test(length((0.2, 2.7, -3.23))) test.add_test(length((0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, 3.23))) test.add_test(length((-0.2, 2.7, 3.23))) test.add_test(length((0.0,))) test.add_test(length((0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((1.0,))) test.add_test(length((-1.0,))) test.add_test(length((1000.0,))) test.add_test(length((-1000.0,))) test.add_test(length((0.5,))) test.add_test(length((-0.5,)))
|
test.add_test(length((0.2, 2.7, 3.23))) test.add_test(length((0.2, 2.7, -3.23))) test.add_test(length((0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, 3.23))) test.add_test(length((-0.2, 2.7, 3.23)))
|
def length_inf(a): result = a[0] for x in a: if abs(x) > result: result = abs(x) return [result]
|
def insert_into(test): test.add_test(length((1.0, 2.0, 3.0))) test.add_test(length((1.0, 2.0, -3.0))) test.add_test(length((1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, 3.0))) test.add_test(length((-1.0, 2.0, 3.0))) test.add_test(length((0.2, 2.7, 3.23))) test.add_test(length((0.2, 2.7, -3.23))) test.add_test(length((0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, 3.23))) test.add_test(length((-0.2, 2.7, 3.23))) test.add_test(length((0.0,))) test.add_test(length((0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((1.0,))) test.add_test(length((-1.0,))) test.add_test(length((1000.0,))) test.add_test(length((-1000.0,))) test.add_test(length((0.5,))) test.add_test(length((-0.5,)))
|
test.add_test(length((0.0,))) test.add_test(length((0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0)))
|
def sub(a, b): result = [] for i in range(len(a)): result.append(a[i] - b[i]) return result
|
def insert_into(test): test.add_test(length((1.0, 2.0, 3.0))) test.add_test(length((1.0, 2.0, -3.0))) test.add_test(length((1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, 3.0))) test.add_test(length((-1.0, 2.0, 3.0))) test.add_test(length((0.2, 2.7, 3.23))) test.add_test(length((0.2, 2.7, -3.23))) test.add_test(length((0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, 3.23))) test.add_test(length((-0.2, 2.7, 3.23))) test.add_test(length((0.0,))) test.add_test(length((0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((1.0,))) test.add_test(length((-1.0,))) test.add_test(length((1000.0,))) test.add_test(length((-1000.0,))) test.add_test(length((0.5,))) test.add_test(length((-0.5,)))
|
test.add_test(length((1.0,))) test.add_test(length((-1.0,))) test.add_test(length((1000.0,))) test.add_test(length((-1000.0,))) test.add_test(length((0.5,))) test.add_test(length((-0.5,)))
|
def length_test(a, func, types=[]): return shtest.make_test(func(a), [a], types) def distance_test(a, b, func, types=[]): return shtest.make_test(func(sub(a, b)), [a, b], types) def insert_into1(test, func): test.add_test(length_test((1.0, 2.0, 3.0), func)) test.add_test(length_test((1.0, 2.0, -3.0), func)) test.add_test(length_test((1.0, -2.0, -3.0), func)) test.add_test(length_test((-1.0, -2.0, -3.0), func)) test.add_test(length_test((-1.0, -2.0, 3.0), func)) test.add_test(length_test((-1.0, 2.0, 3.0), func)) test.add_test(length_test((0.2, 2.7, 3.23), func)) test.add_test(length_test((0.2, 2.7, -3.23), func)) test.add_test(length_test((0.2, -2.7, -3.23), func)) test.add_test(length_test((-0.2, -2.7, -3.23), func)) test.add_test(length_test((-0.2, -2.7, 3.23), func)) test.add_test(length_test((-0.2, 2.7, 3.23), func)) test.add_test(length_test((0.0,), func)) test.add_test(length_test((0.0, 0.0, 0.0), func)) test.add_test(length_test((0.0, 0.0, 0.0, 0.0), func)) test.add_test(length_test((0.0, 0.0, 0.0, 0.0), func)) test.add_test(length_test((1.0,), func)) test.add_test(length_test((-1.0,), func)) test.add_test(length_test((1000.0,), func)) test.add_test(length_test((-1000.0,), func)) test.add_test(length_test((0.5,), func)) test.add_test(length_test((-0.5,), func)) def insert_into2(test, func): test.add_test(distance_test((1.0, 2.0, 3.0), (4, 5, 6), func)) test.add_test(distance_test((1.0, 2.0, -3.0), (-4, 5, 6), func)) test.add_test(distance_test((1.0, -2.0, -3.0), (4, 5, 6), func)) test.add_test(distance_test((-1.0, -2.0, -3.0), (-4, -5, -6), func)) test.add_test(distance_test((-1.0, -2.0, 3.0), (4, 5, 6), func)) test.add_test(distance_test((-1.0, 2.0, 3.0), (4, 5, 6), func)) test.add_test(distance_test((0.2, 2.7, 3.23), (0.1, -34.2, 90.111), func)) test.add_test(distance_test((0.2, 2.7, -3.23), (0.1, 34.2, 90.111), func)) test.add_test(distance_test((0.2, -2.7, -3.23), (0.1, 34.2, -90.111), func)) test.add_test(distance_test((-0.2, -2.7, -3.23), (-0.1, -34.2, 90.111), func)) test.add_test(distance_test((-0.2, -2.7, 3.23), (0.1, -34.2, -90.111), func)) test.add_test(distance_test((-0.2, 2.7, 3.23), (-0.1, -34.2, -90.111), func)) test.add_test(distance_test((0.0,), (0,), func)) test.add_test(distance_test((0.0, 0.0, 0.0), (0, 0, 0), func)) test.add_test(distance_test((0.0, 0.0, 0.0, 0.0), (0, 0, 0, 0), func)) test.add_test(distance_test((1.0,), (1.0,), func)) test.add_test(distance_test((-1.0,), (1.0,), func)) test.add_test(distance_test((1000.0,), (2.0,), func)) test.add_test(distance_test((-1000.0,), (2.4,), func)) test.add_test(distance_test((0.5,), (0.1,), func)) test.add_test(distance_test((-0.5,), (0.7333,), func))
|
def insert_into(test): test.add_test(length((1.0, 2.0, 3.0))) test.add_test(length((1.0, 2.0, -3.0))) test.add_test(length((1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, 3.0))) test.add_test(length((-1.0, 2.0, 3.0))) test.add_test(length((0.2, 2.7, 3.23))) test.add_test(length((0.2, 2.7, -3.23))) test.add_test(length((0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, 3.23))) test.add_test(length((-0.2, 2.7, 3.23))) test.add_test(length((0.0,))) test.add_test(length((0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((1.0,))) test.add_test(length((-1.0,))) test.add_test(length((1000.0,))) test.add_test(length((-1000.0,))) test.add_test(length((0.5,))) test.add_test(length((-0.5,)))
|
insert_into(test)
|
insert_into1(test, length)
|
def insert_into(test): test.add_test(length((1.0, 2.0, 3.0))) test.add_test(length((1.0, 2.0, -3.0))) test.add_test(length((1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, 3.0))) test.add_test(length((-1.0, 2.0, 3.0))) test.add_test(length((0.2, 2.7, 3.23))) test.add_test(length((0.2, 2.7, -3.23))) test.add_test(length((0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, 3.23))) test.add_test(length((-0.2, 2.7, 3.23))) test.add_test(length((0.0,))) test.add_test(length((0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((1.0,))) test.add_test(length((-1.0,))) test.add_test(length((1000.0,))) test.add_test(length((-1000.0,))) test.add_test(length((0.5,))) test.add_test(length((-0.5,)))
|
insert_into(test)
|
insert_into1(test, length) test.output(sys.stdout, False) test = shtest.ImmediateTest('length_1_im', 1) test.add_call(shtest.Call(shtest.Call.call, 'length_1', 1)) insert_into1(test, length_1) test.output(sys.stdout, False) test = shtest.ImmediateTest('length_inf_im', 1) test.add_call(shtest.Call(shtest.Call.call, 'length_inf', 1)) insert_into1(test, length_inf) test.output(sys.stdout, False) test = shtest.ImmediateTest('distance_im', 2) test.add_call(shtest.Call(shtest.Call.call, 'distance', 2)) insert_into2(test, length) test.output(sys.stdout, False) test = shtest.ImmediateTest('distance_1_im', 2) test.add_call(shtest.Call(shtest.Call.call, 'distance_1', 2)) insert_into2(test, length_1) test.output(sys.stdout, False) test = shtest.ImmediateTest('distance_inf_im', 2) test.add_call(shtest.Call(shtest.Call.call, 'distance_inf', 2)) insert_into2(test, length_inf)
|
def insert_into(test): test.add_test(length((1.0, 2.0, 3.0))) test.add_test(length((1.0, 2.0, -3.0))) test.add_test(length((1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, -3.0))) test.add_test(length((-1.0, -2.0, 3.0))) test.add_test(length((-1.0, 2.0, 3.0))) test.add_test(length((0.2, 2.7, 3.23))) test.add_test(length((0.2, 2.7, -3.23))) test.add_test(length((0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, -3.23))) test.add_test(length((-0.2, -2.7, 3.23))) test.add_test(length((-0.2, 2.7, 3.23))) test.add_test(length((0.0,))) test.add_test(length((0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((0.0, 0.0, 0.0, 0.0))) test.add_test(length((1.0,))) test.add_test(length((-1.0,))) test.add_test(length((1000.0,))) test.add_test(length((-1000.0,))) test.add_test(length((0.5,))) test.add_test(length((-0.5,)))
|
common.inprint(" : ShGeneric<" + self.sizevar(size) + ", T>" + "(node)")
|
common.inprint(" : ShGeneric<" + self.sizevar(size) + ", T>" + "(node, swizzle, neg)")
|
def constructors(self, size = 0): common.inprint(self.tpl(size)) common.inprint(self.tplcls(size) + "::" + self.name + "()") common.inprint(" : ShGeneric<" + self.sizevar(size) + ", T>" + "(new ShVariableNode(Binding, " + self.sizevar(size) + "))") common.inprint("{") common.inprint("}") common.inprint("")
|
common.inprint("m_swizzle = swizzle;") common.inprint("m_neg = neg;")
|
def constructors(self, size = 0): common.inprint(self.tpl(size)) common.inprint(self.tplcls(size) + "::" + self.name + "()") common.inprint(" : ShGeneric<" + self.sizevar(size) + ", T>" + "(new ShVariableNode(Binding, " + self.sizevar(size) + "))") common.inprint("{") common.inprint("}") common.inprint("")
|
|
prgname = test[0] + ''.join(combination); f.write(' ShProgram ' + prgname + ' = SH_BEGIN_PROGRAM("gpu:stream") {\n') max = 1 for i, size in enumerate(combination): f.write(' ShAttrib<' + varsize(size) + ', SH_INPUT> ' + string.ascii_uppercase[i]
|
for oi, op in enumerate(ops): prgname = test[0] + ''.join(combination) + str(oi); f.write(' ShProgram ' + prgname + ' = SH_BEGIN_PROGRAM("gpu:stream") {\n') max = 1 for i, size in enumerate(combination): f.write(' ShAttrib<' + varsize(size) + ', SH_INPUT> ' + string.ascii_uppercase[i]
|
def varsize(s): if s == 'v': return '3' if s == 's': return '1' return s
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.