rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
return[country[0], country[1]] | return[self.countryName, self.countryCode] | def getCountry(self, string=None): if string == None: return [self.countryName, self.countryCode] else: country = self.parseCountry(string) if country != None and len(country) >= 2: self.countryName = country[0] self.countryCode = country[1] return[country[0], country[1]] else: return [None, None] |
country = self.parseCountry(string) self.countryCode = country[0] self.countryName = country[1] | country = self.getCountry(string) self.countryName = country[0] self.countryCode = country[1] | def parse(self, string): self.abuseMail = self.parseAbuseMail(string) country = self.parseCountry(string) self.countryCode = country[0] self.countryName = country[1] self.networkName = self.parseNetworkName(string) self.networkInfo = self.parseInfos(string) self.ipRange = self.parseIPRange(string) |
def get_header(mailbox, num, section): body_rex_str = r"\s*%s\s+\(BODY\[%s\]\s+" % (num, section) body_rex = re.compile(body_rex_str, re.I) fetch = "(BODY.PEEK[%s])" % section result, data = mailbox.fetch(num, fetch) data = [x for x in data if isinstance(x, tuple) and len(x) >= 2] data = [x[1] for x in data if body... | @threado.stream def thread(inner, call, *args, **keys): thread = inner.thread(call, *args, **keys) while not thread.has_result(): yield inner, thread inner.finish(thread.result()) @threado.stream def collect(inner): collection = list() try: while True: item = yield inner collection.append(item) except threado.Finished... | def get_header(mailbox, num, section): body_rex_str = r"\s*%s\s+\(BODY\[%s\]\s+" % (num, section) body_rex = re.compile(body_rex_str, re.I) fetch = "(BODY.PEEK[%s])" % section result, data = mailbox.fetch(num, fetch) # Filter away parts that don't closely enough resemble tuple # ("<MSGNUM> (BODY[<MSGPATH>.MIME] {<SIZ... |
mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) | mailbox = imaplib.IMAP4_SSL(self.mail_server, self.mail_port) | def feed(inner, self): self.log.info("Connecting to IMAP server %r port %d", self.mail_server, self.mail_port) mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) |
try: yield inner.thread(mailbox.login, self.mail_user, self.mail_password) status, msgs = yield inner.thread(mailbox.select, self.mail_box, readonly=False) | mailbox.login(self.mail_user, self.mail_password) try: status, msgs = mailbox.select(self.mail_box, readonly=False) | def feed(inner, self): self.log.info("Connecting to IMAP server %r port %d", self.mail_server, self.mail_port) mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) |
self.log.info("Logged in to IMAP server %s port %d", self.mail_server, self.mail_port) try: while True: yield inner.sub(self.fetch_content(mailbox, self.filter)) yield inner, timer.sleep(self.poll_interval) finally: yield inner.thread(mailbox.close) | except: mailbox.logout() raise self.log.info("Logged in to IMAP server %s port %d", self.mail_server, self.mail_port) return mailbox def disconnect(self, mailbox): try: mailbox.close() except (imaplib.IMAP4.error, socket.error): pass try: mailbox.logout() except (imaplib.IMAP4.error, socket.error): pass @threado.st... | def feed(inner, self): self.log.info("Connecting to IMAP server %r port %d", self.mail_server, self.mail_port) mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) |
yield inner.thread(mailbox.logout) def _fetch(self, mailbox, num, path): | channel.finish() @threado.stream def noop(inner, self, noop_interval=10.0): while True: yield inner.sub(self.call("noop")) yield inner, timer.sleep(noop_interval) @threado.stream def poll(inner, self): while True: yield inner.sub(self.fetch_mails(self.filter)) yield inner, timer.sleep(self.poll_interval) @thread... | def feed(inner, self): self.log.info("Connecting to IMAP server %r port %d", self.mail_server, self.mail_port) mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) |
list(inner) | def fetch(inner): list(inner) fetch = "(BODY.PEEK[%s])" % path result, data = yield inner.thread(mailbox.fetch, num, fetch) list(inner) for parts in data: if not isinstance(parts, tuple) or len(parts) != 2: continue reader = StringIO(parts[1]) inner.finish(StringIO(parts[1])) | |
result, data = yield inner.thread(mailbox.fetch, num, fetch) list(inner) | result, data = yield inner.sub(self.call("uid", "FETCH", uid, fetch)) | def fetch(inner): list(inner) fetch = "(BODY.PEEK[%s])" % path result, data = yield inner.thread(mailbox.fetch, num, fetch) list(inner) for parts in data: if not isinstance(parts, tuple) or len(parts) != 2: continue reader = StringIO(parts[1]) inner.finish(StringIO(parts[1])) |
def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) result, data = yield inner.thread(mailbox.search, None, filter) | def walk_mail(inner, self, uid, path=(), headers=[]): if not path: header = yield inner.sub(self.get_header(uid, "HEADER")) if header is None: return headers = headers + [header] path = list(path) + [0] while True: path[-1] += 1 path_str = ".".join(map(str, path)) header = yield inner.sub(self.get_header(uid, path_st... | def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) |
for num in data[0].split(): | for uid in data[0].split(): collected = yield inner.sub(self.walk_mail(uid) | collect()) | def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) |
for path, headers in walk_mail(mailbox, num): parts.append((headers, self._fetch(mailbox, num, path))) | for path, headers in collected: parts.append((headers, self.fetcher(uid, path))) | def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) |
headers, _ = parts[0] top_header = headers[0] | top_header, _ = parts[0][0] | def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) |
mailbox.store(num, "+FLAGS", "\\Seen") | yield inner.sub(self.call("uid", "STORE", uid, "+FLAGS", "(\\Seen)")) | def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) |
list(inner) | def handle(inner, self, parts): handle_default = getattr(self, "handle_default", None) | |
wiki_parent=customer.wiki_parent) | parent=customer.wiki_parent) | def wiki(customer): return Session("wikibot", "%(prefix)s", "%(name)s", wiki_url=customer.wiki_url, wiki_user=customer.wiki_user, wiki_password=customer.wiki_password, wiki_type=customer.wiki_type, wiki_parent=customer.wiki_parent) |
([None] by default, so all None objects returned by the | ([None] by default, ie. all None objects returned by the | def values(self, key=_NO_VALUE, parser=None, ignored=[None]): """ Return event values (for a specific key, if given). |
>>> event.values() == set(["ab", "cd"]) True | >>> def ipv4(string): | |
for value in attrs.itervalues(): return value | for values in attrs.itervalues(): for value in values: return value | def value(self, key=_NO_VALUE, default=_NO_VALUE, parser=None, ignored=[None]): attrs = _Parsed(self.attrs, parser, ignored) if parser else self.attrs if key is _NO_VALUE: for value in attrs.itervalues(): return value else: for value in attrs.get(key, ()): return value |
if message.children("body"): self.command_parser(element, to, room_jid, **attrs) | def query_handler(self, success, element): if not success: return | |
inner.thread(mailbox.close) | yield inner.thread(mailbox.close) | def feed(inner, self): self.log.info("Connecting to IMAP server %r port %d", self.mail_server, self.mail_port) mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) |
event.add("abuse_email", ai.getAbuseMail()) | email = ai.getAbuseMail() if email is None: self.log.error("No abuse email found for %r", event) else: event.add("abuse_email", email) | def distribute(inner, self, name): count = 0 while True: yield inner |
yield inner.thread(mailbox.select, self.mail_box, readonly=False) while True: yield inner.sub(self.fetch_content(mailbox, self.filter)) yield inner, timer.sleep(self.poll_interval) | status, msgs = yield inner.thread(mailbox.select, self.mail_box, readonly=False) if status != "OK": for msg in msgs: self.log.critical(msg) return try: while True: yield inner.sub(self.fetch_content(mailbox, self.filter)) yield inner, timer.sleep(self.poll_interval) finally: yield inner.thread(mailbox.close) | def feed(inner, self): self.log.info("Connecting to IMAP server %r port %d", self.mail_server, self.mail_port) mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) |
try: yield inner.thread(mailbox.close) except: pass | def feed(inner, self): self.log.info("Connecting to IMAP server %r port %d", self.mail_server, self.mail_port) mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) | |
yield inner.sub(self.noop() | self.poll() | self.run_mailbox()) | yield inner.sub(self.run_mailbox() | self.noop() | self.poll()) | def feed(inner, self): yield inner.sub(self.noop() | self.poll() | self.run_mailbox()) |
self.xmpp.add_listener(self.query_handler) | def handle_room(inner, self, name): self.log.info("Joining room %r", name) room = yield inner.sub(self.xmpp.muc.join(name, self.bot_name)) self.log.info("Joined room %r", name) | |
def values(self, key=_NO_VALUE, parser=None, ignored=set([None])): | def values(self, key=_NO_VALUE, parser=None, ignored=[None]): | def values(self, key=_NO_VALUE, parser=None, ignored=set([None])): attrs = _Parsed(self.attrs, parser, ignored) if parser else self.attrs if key is not _NO_VALUE: return attrs.get(key, set()) |
parser=None, ignored=set([None])): | parser=None, ignored=[None]): | def value(self, key=_NO_VALUE, default=_NO_VALUE, parser=None, ignored=set([None])): attrs = _Parsed(self.attrs, parser, ignored) if parser else self.attrs if key is _NO_VALUE: for value in attrs.itervalues(): return value else: for value in attrs.get(key, ()): return value |
parser=None, ignored=set([None])): | parser=None, ignored=[None]): | def contains(self, key=_NO_VALUE, value=_NO_VALUE, parser=None, ignored=set([None])): attrs = _Parsed(self.attrs, parser, ignored) if parser else self.attrs if key is not _NO_VALUE: if value is _NO_VALUE: return key in attrs return value in attrs.get(key, ()) |
def keys(self, parser=None, ignored=set([None])): | def keys(self, parser=None, ignored=[None]): | def keys(self, parser=None, ignored=set([None])): attrs = _Parsed(self.attrs, parser, ignored) if parser else self.attrs return attrs.keys() |
else: print element.serialize() | def skip_own(inner, self, room): while True: yield inner | |
if self.disable is not None and conf_obj.name in self.disable: | startup = getattr(conf_obj, "startup", None) if startup is None: | def configs(self): for conf_obj in set(config.load_configs(os.path.abspath(self.config))): if self.disable is not None and conf_obj.name in self.disable: continue if self.enable is not None and conf_obj.name not in self.enable: continue yield conf_obj |
if self.enable is not None and conf_obj.name not in self.enable: | params = startup() names = set([params["bot_name"], params["module"]]) if self.disable is not None and names & set(self.disable): continue if self.enable is not None and not (names & set(self.enable)): | def configs(self): for conf_obj in set(config.load_configs(os.path.abspath(self.config))): if self.disable is not None and conf_obj.name in self.disable: continue if self.enable is not None and conf_obj.name not in self.enable: continue yield conf_obj |
path_str = ".".join(map(str, path)) body_rex_str = r"\s*%s\s+\(BODY\[%s.MIME\]\s+" % (num, path_str) body_rex = re.compile(body_rex_str, re.I) fetch = "(BODY.PEEK[%s.MIME])" % path_str result, data = mailbox.fetch(num, fetch) data = [x for x in data if isinstance(x, tuple) and len(x) >= 2] data = [x[1] for x in da... | path_str = ".".join(map(str, path)) header = get_header(mailbox, num, path_str + ".MIME") if header is None: return | def walk_mail(mailbox, num, path=(), headers=[]): path = list(path) + [0] while True: path[-1] += 1 path_str = ".".join(map(str, path)) body_rex_str = r"\s*%s\s+\(BODY\[%s.MIME\]\s+" % (num, path_str) body_rex = re.compile(body_rex_str, re.I) fetch = "(BODY.PEEK[%s.MIME])" % path_str result, data = mailbox.fetch(num... |
main = headers[-1].get_content_maintype().replace("-", "__") sub = headers[-1].get_content_subtype().replace("-", "__") handler_name = "handle_" + main + "_" + sub handler = getattr(self, handler_name, self.handle_default) if handler is None: continue fetch = "(BODY.PEEK[%s])" % path result, data = yield inner.thread... | parts.append((headers, self._fetch(mailbox, num, path))) if parts: headers, _ = parts[0] top_header = headers[0] subject = top_header["Subject"] or "<no subject>" sender = top_header["From"] or "<unknown sender>" self.log.info("Handling mail %r from %r", subject, sender) yield inner.sub(self.handle(parts)) | def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) |
handle_default = None | @threado.stream def handle(inner, self, parts): handle_default = getattr(self, "handle_default", None) for headers, fetch in parts: content_type = headers[-1].get_content_type() suffix = content_type.replace("-", "__").replace("/", "_") handler = getattr(self, "handle_" + suffix, handle_default) if handler is None: c... | def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) |
from_url = bot.BoolParam() | def fetch_content(inner, self, mailbox, filter): yield inner.thread(mailbox.noop) | |
if self.from_url: for match in re.findall(self.url_rex, fileobj.read()): self.log.info("Fetching URL %r", match) try: info, fileobj = yield inner.sub(utils.fetch_url(match)) except utils.FetchUrlFailed, fail: self.log.error("Fetching URL %r failed: %s", match, fail) return filename = info.get_filename(None) if filenam... | filename = headers[-1].get_filename(None) if filename is not None: self.log.info("Parsing CSV data from an attachment") result = yield inner.sub(self.parse_csv(filename, fileobj)) inner.finish(result) for match in re.findall(self.url_rex, fileobj.read()): self.log.info("Fetching URL %r", match) try: info, fileobj = yi... | def handle_text_plain(inner, self, headers, fileobj): if self.from_url: for match in re.findall(self.url_rex, fileobj.read()): self.log.info("Fetching URL %r", match) try: info, fileobj = yield inner.sub(utils.fetch_url(match)) except utils.FetchUrlFailed, fail: self.log.error("Fetching URL %r failed: %s", match, fail)... |
if self.from_url: return | def handle_application_zip(inner, self, headers, fileobj): if self.from_url: return | |
skip_rest = yield inner.sub(self.parse_csv(filename, csv_data)) if skip_rest: inner.finish(skip_rest) | result = yield inner.sub(self.parse_csv(filename, csv_data)) inner.finish(result) | def handle_application_zip(inner, self, headers, fileobj): if self.from_url: return |
yield set(parsed_values) | yield set(values) | def itervalues(self): for key, values in self.attrs.iteritems(): values = imap(self.parser, values) values = list(self.filter(values)) |
yield parsed_values | yield values | def itervalues(self): for key, values in self.attrs.iteritems(): values = imap(self.parser, values) values = list(self.filter(values)) |
yield inner.thread(mailbox.select, self.mail_box, readonly=False) | def feed(inner, self): self.log.info("Connecting to IMAP server %r port %d", self.mail_server, self.mail_port) mailbox = yield inner.thread(imaplib.IMAP4_SSL, self.mail_server, self.mail_port) | |
os.remove(fname) | def test_image(): w = 400 h = 400 rw, rh = w,h Viewer.widgetGeometry.setSize(w,h) Viewer.frameGL.maximize(True) Viewer.frameGL.setSize(w, h) Viewer.update() fname = 'test_framegl.png' Viewer.frameGL.saveImage(fname,'PNG') Viewer.frameGL.maximize(False) assert os.path.exists(fname), "Viewer.frameGL.saveImage failed" if ... | |
self.__sortedTuples = map(list, self.iteritems()) | self.__sortedTuples = map(tuple, self.iteritems()) | def update_interpolation(self): """ Discard previous interpolation a recompute a new one from the list of cross sections. """ numSections = len(self) if numSections>=2: # -- clear cached sections -- self.__cachedSections.clear() self.__normToReal = dict( (k, self.unnormalised_parameter(k)) for k in self.iterkeys() ) |
columns = zip(*self.itervalues()) | sortedTups = self.as_sorted_tuples() columns = zip(*zip(*sortedTups)[1]) | def create_cross_section(self, parameter): """Adds a interpolated cross section to the set of cross sections that define the NURBS patch. The parameter is expressed in the get_param_range() range. |
ptPairs = ((c[afterId], c[beforeId]) for c in columns) | ptPairs = [(c[afterId], c[beforeId]) for c in columns] | def create_cross_section(self, parameter): """Adds a interpolated cross section to the set of cross sections that define the NURBS patch. The parameter is expressed in the get_param_range() range. |
self.renderText(cxval,self.start[1],0,'%.2f' % cxval) | self.renderText(cxval,self.start[1],0,'%.1f' % cxval) | def drawGrid(self): xr = self.end[0] - self.start[0] xy = self.end[1] - self.start[1] nbdigit = max(int(round(log(xr,10))),int(round(log(xy,10)))) xdelta = pow(10,nbdigit)/10 fxval = round(self.start[0]/xdelta) lxval = round(self.end[0]/xdelta) cxval = fxval*xdelta nbiter = int((lxval-fxval)) glColor4f(0.2,0.2,0.2,0.0)... |
self.renderText(self.start[0],cyval,0,'%.2f' % cyval) | self.renderText(self.start[0],cyval,0,'%.1f' % cyval) | def drawGrid(self): xr = self.end[0] - self.start[0] xy = self.end[1] - self.start[1] nbdigit = max(int(round(log(xr,10))),int(round(log(xy,10)))) xdelta = pow(10,nbdigit)/10 fxval = round(self.start[0]/xdelta) lxval = round(self.end[0]/xdelta) cxval = fxval*xdelta nbiter = int((lxval-fxval)) glColor4f(0.2,0.2,0.2,0.0)... |
degree = 3 | def bezier_kv(self, is_linear=False): """ Compute a nurbs knot vector from Bezier control points. bezier_kv(linear=False) -> knot_vector | |
param = range(nb_arc) self.kv= [ param[ 0 ] ]*degree step = (param[-1]-param[0]) / float(((nb_arc-2)*degree+1)) for i in range((nb_arc-2)*degree+2): self.kv.append( param[0]+i*step ) self.kv.extend( [param[ -1 ]]*degree ) | param = map(float,range(nb_arc+1)) self.kv= [ param[ 0 ] ]*(degree+1) step = (param[-1]-param[0]) / float(nb_arc) for i in range(1,nb_arc): self.kv.extend([param[0]+i*step]*degree) self.kv.extend( [param[ -1 ]]*(degree+1) ) | def bezier_kv(self, is_linear=False): """ Compute a nurbs knot vector from Bezier control points. bezier_kv(linear=False) -> knot_vector |
def curve(self, is_linear= False, stride_factor=10): | def curve(self, is_linear= False, stride_factor=10, distances=None): | def curve(self, is_linear= False, stride_factor=10): """ Return the equivalent PlantGL nurbs curve which interpol the points. :param: stride_factor is the number of points to draw an arc of the curve. """ if not self.nurbs: self.distances() self.derivatives() self.bezier_cp() self.bezier_kv(is_linear) |
self.distances() | if distances is None: self.distances() else: self.dist = distances | def curve(self, is_linear= False, stride_factor=10): """ Return the equivalent PlantGL nurbs curve which interpol the points. :param: stride_factor is the number of points to draw an arc of the curve. """ if not self.nurbs: self.distances() self.derivatives() self.bezier_cp() self.bezier_kv(is_linear) |
raise "Unable to build a spline curve from points of dimension %d"% (self.dim,) | raise Exception("Unable to build a spline curve from points of dimension %d"% (self.dim,)) | def curve(self, is_linear= False, stride_factor=10): """ Return the equivalent PlantGL nurbs curve which interpol the points. :param: stride_factor is the number of points to draw an arc of the curve. """ if not self.nurbs: self.distances() self.derivatives() self.bezier_cp() self.bezier_kv(is_linear) |
return [ sg.SceneFormat("Asc Codec",["asc","pts"],"The Ascii point file format") ] | return [ sg.SceneFormat("Asc Codec",["asc","pts","xyz"],"The Ascii point file format") ] | def formats(self): """ return formats """ return [ sg.SceneFormat("Asc Codec",["asc","pts"],"The Ascii point file format") ] |
pts = [] col = [] | pts = sg.Point3Array([]) col = sg.Color4Array([]) | def read(self,fname): """ read an ascii point file """ import warnings pts = [] col = [] isptsfile = ('.pts' in fname) f = file(fname,"r") if isptsfile: f.readline() for i,line in enumerate(f.readlines()): values = line.split() try: pts.append(mt.Vector3(float(values[0]),float(values[1]),float(values[2]))) if len(value... |
for i,line in enumerate(f.readlines()): | i = 0 for line in f.readlines(): | def read(self,fname): """ read an ascii point file """ import warnings pts = [] col = [] isptsfile = ('.pts' in fname) f = file(fname,"r") if isptsfile: f.readline() for i,line in enumerate(f.readlines()): values = line.split() try: pts.append(mt.Vector3(float(values[0]),float(values[1]),float(values[2]))) if len(value... |
pts = sg.Point3Array(pts) | def read(self,fname): """ read an ascii point file """ import warnings pts = [] col = [] isptsfile = ('.pts' in fname) f = file(fname,"r") if isptsfile: f.readline() for i,line in enumerate(f.readlines()): values = line.split() try: pts.append(mt.Vector3(float(values[0]),float(values[1]),float(values[2]))) if len(value... | |
isptsfile = ('.pts' in fname) | isptsfile = ('.pts' in fname) isxyz = ('.xyz' in fname) | def write(self,fname,scene): """ write an ascii point file """ print("Write "+fname) d = alg.Discretizer() f = file(fname,'w') isptsfile = ('.pts' in fname) for i in scene: if i.apply(d): p = d.discretization if isinstance(p,sg.PointSet) : hasColor = not p.colorList is None and len(p.colorList) > 0 col = i.appearance.... |
if hasColor: col = p.colorList[i] if isptsfile: f.write(str(rgb2intensity(col))) f.write(str(col.red)+' '+str(col.green)+' '+str(col.blue)+'\n') | if not isxyz: if hasColor: col = p.colorList[i] if isptsfile: f.write(str(rgb2intensity(col))) f.write(str(col.red)+' '+str(col.green)+' '+str(col.blue)+'\n') else: f.write('\n') | def write(self,fname,scene): """ write an ascii point file """ print("Write "+fname) d = alg.Discretizer() f = file(fname,'w') isptsfile = ('.pts' in fname) for i in scene: if i.apply(d): p = d.discretization if isinstance(p,sg.PointSet) : hasColor = not p.colorList is None and len(p.colorList) > 0 col = i.appearance.... |
self._value_min=value_range[0] self._value_max=value_range[1] if self._value_min>=self._value_max : | self._value_min = float(value_range[0]) self._value_max = float(value_range[1]) if self._value_min >= self._value_max : | def set_value_range( self, value_range=(0., 1.) ): """sets a value range. :Parameters: - `value_range` : value range in which we pick values :Types: - `value_range` : (float,float) """ self._value_min=value_range[0] self._value_max=value_range[1] if self._value_min>=self._value_max : raise ValueError("max==min %f" %... |
bld_meshverts.extend(pts) | bld_mesh.verts.extend(pts) | def shp_to_blender (shp, bld_mesh = None) : """Create a blender mesh with faces painted with the right color :Parameters: - `shp` (Shape) - the shape to transform - `bld_mesh` (Mesh) - a mesh in which to append the shape. If None, a blank new one will be created :Returns Type: Mesh """ #create bld_mesh if bld_mesh is... |
w = ProfileEditor(editingCentral=True) | w = ProfileEditor(editingCentral=False) | def __on_curve_move_request(self, oldPos, newPos): interpolator = self.__profileExplorer.interpolator() interpolator[oldPos] = newPos |
self.context.append('\\end{figure}\n') | if node.get('ids'): self.out += ['\n'] + self.ids_to_labels(node) | def visit_figure(self, node): self.requirements['float_settings'] = PreambleCmds.float_settings # ! the 'align' attribute should set "outer alignment" ! # For "inner alignment" use LaTeX default alignment (similar to HTML) ## if ('align' not in node.attributes or ## node.attributes['align'] == 'center'): ## ali... |
self.out.append(self.context.pop()) | self.out.append('\\end{figure}\n') | def depart_figure(self, node): self.out.append(self.context.pop()) |
is_inline = self.is_inline(node) align_prepost = { (True, 'bottom'): ('', ''), (True, 'middle'): (r'\raisebox{-0.5\height}{', '}'), (True, 'top'): (r'\raisebox{-\height}{', '}'), (False, 'center'): (r'\noindent\makebox[\textwidth][c]{', '}'), (False, 'left'): (r'\noindent{', r'\hfill}'), (False, 'right'): (r'\n... | display_style = ('block-', 'inline-')[self.is_inline(node)] align_codes = { 'bottom': ('', ''), 'middle': (r'\raisebox{-0.5\height}{', '}'), 'top': (r'\raisebox{-\height}{', '}'), 'center': (r'\noindent\makebox[\textwidth][c]{', '}'), 'left': (r'\noindent{', r'\hfill}'), 'right': (r'\noindent{\hfill', '}'),} | def visit_image(self, node): self.requirements['graphicx'] = self.graphicx_package attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) # alignment defaults: if not 'align' in attrs: # Set default align of image i... |
pre.append(align_prepost[is_inline, attrs['align']][0]) post.append(align_prepost[is_inline, attrs['align']][1]) | align_code = align_codes[attrs['align']] pre.append(align_code[0]) post.append(align_code[1]) | def visit_image(self, node): self.requirements['graphicx'] = self.graphicx_package attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) # alignment defaults: if not 'align' in attrs: # Set default align of image i... |
if not is_inline: | if not self.is_inline(node): | def visit_image(self, node): self.requirements['graphicx'] = self.graphicx_package attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) # alignment defaults: if not 'align' in attrs: # Set default align of image i... |
self.append_hypertargets(node) | def visit_image(self, node): self.requirements['graphicx'] = self.graphicx_package attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) # alignment defaults: if not 'align' in attrs: # Set default align of image i... | |
pass | if node.get('ids'): self.out += self.ids_to_labels(node) + ['\n'] | def depart_image(self, node): pass |
self.body_pre_docinfo.append(PreambleCmds.documenttitle % ( shorttitle, '%\n '.join(title), shortauthor, ' \\and\n'.join(authors), ', '.join(self.date))) | docinfo_list = [shorttitle, '%\n '.join(title), shortauthor, ' \\and\n'.join(authors), ', '.join(self.date)] if self.organization is None: docinfo_str = PreambleCmds.documenttitle % tuple(docinfo_list) else: docinfo_list.append(self.organization) docinfo_str = docinfo_w_institute % tuple(docinfo_list) self.body_pre_do... | def depart_document(self, node): # Complete header with information gained from walkabout # a) conditional requirements (before style sheet) self.requirements = self.requirements.sortedvalues() # b) coditional fallback definitions (after style sheet) self.fallbacks = self.fallbacks.sortedvalues() # c) PDF properties se... |
LaTeXTranslator.visit_docinfo_item(self, node, name) | print('name='+name) print('node.astext='+node.astext()) if name == 'author': self.pdfauthor.append(self.attval(node.astext())) if self.use_latex_docinfo: if name in ('author', 'contact', 'address'): if name == 'author' or not self.author_stack: self.author_stack.append([]) if name == 'address': self.insert_newline =... | def visit_docinfo_item(self, node, name): LaTeXTranslator.visit_docinfo_item(self, node, name) |
f = open(expected_path, 'rb') | f = open(expected_path, 'r') | def test(self): """Process self.configfile.""" os.chdir(DocutilsTestSupport.testroot) # Keyword parameters for publish_file: namespace = {} # Initialize 'settings_overrides' for test settings scripts, # and disable configuration files: namespace['settings_overrides'] = {'_disable_config': 1} # Read the variables set in... |
try: expected = expected.decode(output_encoding) except UnicodeDecodeError: expected = expected.decode('latin1', 'replace') | if sys.version_info < (3,0): try: expected = expected.decode(output_encoding) except UnicodeDecodeError: expected = expected.decode('latin1', 'replace') | def test(self): """Process self.configfile.""" os.chdir(DocutilsTestSupport.testroot) # Keyword parameters for publish_file: namespace = {} # Initialize 'settings_overrides' for test settings scripts, # and disable configuration files: namespace['settings_overrides'] = {'_disable_config': 1} # Read the variables set in... |
0x2018: ur'`', 0x2019: ur"'", | 0x2018: ur'\textquoteleft{}', 0x2019: ur'\textquoteright{}', | def encode(self, text): """Return text with 'problematic' characters escaped. |
0x201E: ur'\quotedblbase', | 0x201E: ur'\quotedblbase{}', 0x2030: ur'\textperthousand{}', 0x2031: ur'\textpertenthousand{}', 0x2039: ur'\guilsinglleft{}', 0x203A: ur'\guilsinglright{}', 0x2423: ur'\textvisiblespace{}', | def encode(self, text): """Return text with 'problematic' characters escaped. |
0x2030: ur'\textperthousand{}', 0x2031: ur'\textpertenthousand{}', | def encode(self, text): """Return text with 'problematic' characters escaped. | |
0x2423: ur'\textvisiblespace{}', | def encode(self, text): """Return text with 'problematic' characters escaped. | |
self.context.append(len(self.body)) | self.push_output_collector([]) | def visit_citation(self, node): # TODO maybe use cite bibitems if self._use_latex_citations: self.context.append(len(self.body)) else: # TODO: do we need these? ## self.requirements['~fnt_floats'] = PreambleCmds.footnote_floats self.out.append(r'\begin{figure}[b]') self.append_hypertargets(node) |
size = self.context.pop() label = self.body[size] text = ''.join(self.body[size+1:]) del self.body[size:] | label = self.out[0] text = ''.join(self.out[1:]) | def depart_citation(self, node): if self._use_latex_citations: size = self.context.pop() label = self.body[size] text = ''.join(self.body[size+1:]) del self.body[size:] self._bibitems.append([label, text]) else: self.out.append('\\end{figure}\n') |
self.body.append('<dd>\n') | self.body.append('</dd>\n') | def depart_citation(self, node): self.body.append('<dd>\n') if isinstance(node.next_node(), nodes.citation): self.body.append('<-- next citation -->') else: self.body.append('</dl>\n') |
Decode file/path string. Return `nodes.reprunicode` object. Convert to Unicode without the UnicodeDecode error of the implicit 'ascii:strict' decoding. | Ensure `path` is Unicode. Return `nodes.reprunicode` object. Decode file/path string in a failsave manner if not already done. | def decode_path(path): """ Decode file/path string. Return `nodes.reprunicode` object. Convert to Unicode without the UnicodeDecode error of the implicit 'ascii:strict' decoding. """ # see also http://article.gmane.org/gmane.text.docutils.user/2905 try: path = path.decode(sys.getfilesystemencoding(), 'strict') except ... |
self.body.append('<dt>%s</dt>\n' % self.language.labels[name]) self.body.append(self.starttag(node, 'dd', '')) | self.body.append('<dt class="%s">%s</dt>\n' % (name, self.language.labels[name])) self.body.append(self.starttag(node, 'dd', '', CLASS=name)) | def visit_docinfo_item(self, node, name, meta=1): if meta: meta_tag = '<meta name="%s" content="%s" />\n' \ % (name, self.attval(node.astext())) self.add_meta(meta_tag) self.body.append('<dt>%s</dt>\n' % self.language.labels[name]) self.body.append(self.starttag(node, 'dd', '')) |
self.body.append(self.starttag(node, 'dt', '%s[' % self.context.pop(), CLASS='label')) | suffix = '%s%s' % (self.context.pop(), self.label_delim(node, '[', '')) self.body.append(self.starttag(node, 'dt', suffix, CLASS='label')) | def visit_label(self, node): # Context added in footnote_backrefs. self.body.append(self.starttag(node, 'dt', '%s[' % self.context.pop(), CLASS='label')) |
self.body.append(']%s</dt>\n%s%s' % (backref, starttag, text)) | self.body.append('%s%s</dt>\n%s%s' % (delim, backref, starttag, text)) | def depart_label(self, node): # Context added in footnote_backrefs. backref = self.context.pop() text = self.context.pop() # <dd> starttag added in visit_footnote() / visit_citation() starttag = self.context.pop() self.body.append(']%s</dt>\n%s%s' % (backref, starttag, text)) |
self.starttag(node, 'table', CLASS='docutils table')) | self.starttag(node, 'table', CLASS=' '.join(classes))) | def visit_table(self, node): self.body.append( self.starttag(node, 'table', CLASS='docutils table')) |
subs['pepnum'] = pepnum | subs['pepnum'] = self.pepnum | def interpolation_dict(self): subs = html4css1.Writer.interpolation_dict(self) settings = self.document.settings pyhome = settings.python_home subs['pyhome'] = pyhome subs['pephome'] = settings.pep_home if pyhome == '..': subs['pepindex'] = '.' else: subs['pepindex'] = pyhome + '/dev/peps' index = self.document.first_c... |
self.out.append('\\multicolumn{%d}{%sl%s}{' % (count, bar1, self.active_table.get_vertical_bar())) | self.out.append('\\multicolumn{%d}{%sp{%s}%s}{' % (count, bar1, self.active_table.get_multicolumn_width( self.active_table.get_entry_number(), count), self.active_table.get_vertical_bar())) | def visit_entry(self, node): self.active_table.visit_entry() # cell separation # BUG: the following fails, with more than one multirow # starting in the second column (or later) see # ../../../test/functional/input/data/latex.txt if self.active_table.get_entry_number() == 1: # if the first row is a multirow, this actua... |
print('name='+name) print('node.astext='+node.astext()) | def visit_docinfo_item(self, node, name): print('name='+name) print('node.astext='+node.astext()) if name == 'author': self.pdfauthor.append(self.attval(node.astext())) if self.use_latex_docinfo: if name in ('author', 'contact', 'address'): # We attach these to the last author. If any of them precedes # the first auth... | |
if self.centerfigs: self.out.append('\\begin{center}\n') | def visit_image(self, node): if self.centerfigs: self.out.append('\\begin{center}\n') attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) pre = [] # in reverse order post = [] include_graph... | |
self.settings.record_dependencies.add(attrs['uri']) pre = [] post = [] include_graphics_options = [] inline = isinstance(node.parent, nodes.TextElement) if 'scale' in attrs: pre.append('\\scalebox{%f}{' % (attrs['scale'] / 100.0,)) post.append('}') if 'width' in attrs: include_graphics_options.append('width=%s' % ( s... | if not 'align' in attrs and self.centerfigs: attrs['align'] = 'center' | def visit_image(self, node): if self.centerfigs: self.out.append('\\begin{center}\n') attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) pre = [] # in reverse order post = [] include_graph... |
include_graphics_options.append('height=0.75\\textheight') if 'align' in attrs: align_prepost = { (1, 'bottom'): ('', ''), (1, 'middle'): ('\\raisebox{-0.5\\height}{', '}'), (1, 'top'): ('\\raisebox{-\\height}{', '}'), (0, 'center'): ('{\\hfill', '\\hfill}'), (0, 'left'): ('{', '\\hfill}'), (0, 'right'): ('{\\hfil... | attrs['height'] = '0.75\\textheight' LaTeXTranslator.visit_image(self, node) | def visit_image(self, node): if self.centerfigs: self.out.append('\\begin{center}\n') attrs = node.attributes # Add image URI to dependency list, assuming that it's # referring to a local file. self.settings.record_dependencies.add(attrs['uri']) pre = [] # in reverse order post = [] include_graph... |
Provides a conversion to unicode without the UnicodeDecode error of the | Convert to Unicode without the UnicodeDecode error of the | def decode_path(path): """ Decode file/path string. Return `nodes.reprunicode` object. Provides a conversion to unicode without the UnicodeDecode error of the implicit 'ascii:strict' decoding. """ # see also http://article.gmane.org/gmane.text.docutils.user/2905 try: path = path.decode(sys.getfilesystemencoding(), 'st... |
path = path.decode('utf-8', 'strict') | def decode_path(path): """ Decode file/path string. Return `nodes.reprunicode` object. Provides a conversion to unicode without the UnicodeDecode error of the implicit 'ascii:strict' decoding. """ # see also http://article.gmane.org/gmane.text.docutils.user/2905 try: path = path.decode(sys.getfilesystemencoding(), 'st... | |
path = path.decode(sys.getfilesystemencoding(), 'strict') | path = path.decode('utf-8', 'strict') | def decode_path(path): """ Decode file/path string. Return `nodes.reprunicode` object. Provides a conversion to unicode without the UnicodeDecode error of the implicit 'ascii:strict' decoding. """ # see also http://article.gmane.org/gmane.text.docutils.user/2905 try: path = path.decode(sys.getfilesystemencoding(), 'st... |
self.paragraph_style_stack.append(self.rststyle('blockindent')) | self.paragraph_style_stack.append( self.rststyle('deflist-def-%d' % self.def_list_level)) | def visit_definition(self, node): self.paragraph_style_stack.append(self.rststyle('blockindent')) self.bumped_list_level_stack.append(ListLevel(1)) |
def visit_definition_list(self, node): pass def depart_definition_list(self, node): pass def visit_definition_list_item(self, node): pass def depart_definition_list_item(self, node): pass def visit_term(self, node): el = self.append_p('textbody') el1 = SubElement(el, 'text:span', attrib={'text:style-name': self.rst... | def depart_definition(self, node): self.paragraph_style_stack.pop() self.bumped_list_level_stack.pop() | |
if self.line_block_level <= 1: el1 = SubElement(self.current_element, 'text:p', attrib={ 'text:style-name': self.rststyle('lineblock1'), }) | def depart_line_block(self, node): if self.line_block_level <= 1: el1 = SubElement(self.current_element, 'text:p', attrib={ 'text:style-name': self.rststyle('lineblock1'), }) self.line_indent_level -= 1 self.line_block_level -= 1 | |
kwargs['py_modules'] += extras | kwargs['py_modules'] = extras | def do_setup(): kwargs = package_data.copy() extras = get_extras() if extras: kwargs['py_modules'] += extras kwargs['classifiers'] = classifiers # Install data files properly. kwargs['cmdclass'] = {'build_data': build_data, 'install_data': smart_install_data} # Auto-convert surce code for Python 3 if sys.version_info >... |
docsource, line = utils.get_source_line(node) if docsource: dirname = os.path.dirname(docsource) if dirname: source = '%s%s%s' % (dirname, os.sep, source, ) | if not source.startswith(os.sep): docsource, line = utils.get_source_line(node) if docsource: dirname = os.path.dirname(docsource) if dirname: source = '%s%s%s' % (dirname, os.sep, source, ) | def visit_image(self, node): # Capture the image file. if 'uri' in node.attributes: source = node.attributes['uri'] source = urllib.url2pathname(source) docsource, line = utils.get_source_line(node) if docsource: dirname = os.path.dirname(docsource) if dirname: source = '%s%s%s' % (dirname, os.sep, source, ) if not sel... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.