Franck Pommereau

fixed encoding problems

Showing with 23 additions and 19 deletions
 # -*- encoding: latin-1 """A plugin to compose nets _à la_ Petri Box Calculus. """A plugin to compose nets _a la_ Petri Box Calculus. @note: this plugin depends on plugins `clusters` and `status` that are automatically loaded ... ...
 #-*- encoding: latin-1 """A plugin to add positions to the nodes. `Place` and `Transition` are added an optional argument for the ... ... @@ -388,8 +387,8 @@ def extend (module) : for node in self.node() : node.pos.shift(dx, dy) def transpose (self) : """Perform a clockwise 90° rotation of node coordinates, ie, change every position `(x, y)` to `(-y, x)` """Perform a clockwise 90 degrees rotation of node coordinates, ie, change every position `(x, y)` to `(-y, x)` """ for node in self.node() : x, y = node.pos() ... ...
 #-*- coding: latin-1 """Add statuses to nodes: a status is a special kind of label that is used to define Petri nets compositions _à la_ Petri Box Calculus. See used to define Petri nets compositions _a la_ Petri Box Calculus. See plugin `ops` to read more about how statuses are used in practice. Several status are defined by default: `entry`, `internal`, `exit`, ... ... @@ -33,6 +32,7 @@ Place('p1', MultiSet([]), tAll, status=Status('entry')) >>> n.add_place(Place('p2', status=exit)) >>> n.place('p2') Place('p2', MultiSet([]), tAll, status=Status('exit')) """ import operator, weakref ... ... @@ -717,6 +717,6 @@ def extend (module) : (self.place(s).status for s in sources)) module.PetriNet.merge_transitions(self, target, sources, **args) self.set_status(target, status) return Place, Transition, PetriNet, Status, \ ("entry", entry), ("exit", exit), ("internal", internal), \ Buffer, buffer, Safebuffer, safebuffer, Tick, tick return (Place, Transition, PetriNet, Status, ("entry", entry), ("exit", exit), ("internal", internal), Buffer, buffer, Safebuffer, safebuffer, Tick, tick) ... ...
 ... ... @@ -51,11 +51,10 @@ at SNAKES source code. However, let's note a few points: it should work in other cases but this may required some work """ import sys, os, os.path import inspect, fnmatch, collections, re, shlex import sys, os, os.path, codecs import inspect, fnmatch, re, shlex import textwrap, doctest import snakes from snakes.lang import unparse from snakes.lang.python.parser import parse, ast try : ... ... @@ -118,7 +117,8 @@ def die (message, code=1) : class DocExtract (object) : """The class that extracts documentation and renders it """ def __init__ (self, inpath, outpath, exclude=[]) : def __init__ (self, inpath, outpath, exclude=[], inputenc="utf-8", outputenc="utf-8") : """ @param inpath: directory where the source code is searched for @type inpath: `str` ... ... @@ -127,11 +127,17 @@ class DocExtract (object) : @param exclude: a list of glob patterns to exclude modules (not file names, but Python modules names) @type exclude: `list` @param inputenc: encoding of input files @type inputenc: `str` @param outputenc: encoding of output files @type outputenc: `str` """ self.path = inpath.rstrip(os.sep) self.outpath = outpath self.out = None self.exclude = exclude self.inputenc = inputenc self.outputenc = outputenc self._last = "\n\n" def md (self, text, inline=True) : """Return the Markdow rendering of `text`, include `

` if ... ... @@ -196,7 +202,7 @@ class DocExtract (object) : info("%s -> %r" % (self.module, outpath)) if not os.path.exists(outdir) : os.makedirs(outdir) self.out = open(outpath, "w") self.out = codecs.open(outpath, "w", encoding=self.outputenc) self.classname = None return True def write (self, text) : ... ... @@ -271,9 +277,9 @@ class DocExtract (object) : if not self.openout(path) : continue try : node = parse(open(path).read()) except : err("error parsing %r" % path) node = parse(codecs.open(path, encoding=self.inputenc).read()) except Exception as e : err("error parsing %r (%s)" % (path, e)) continue if ".plugins." in self.module : self.visit_plugin(node) ... ... @@ -594,7 +600,7 @@ class DocExtract (object) : path = os.path.join(os.path.dirname(self.inpath), name) if not os.path.exists(path) : err("include file %r not found" % name) with open(path) as infile : with codecs.open(path, encoding=self.inputenc) as infile : self.newline() self.writeline(" :::%s" % lang) for i, line in enumerate(infile) : ... ...