Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b98cd39

Browse files
committed
changeit(): Added support for \deprecated{}.
Chunk.__repr__(), main(): Allow Chunk objects to get the buffer, to make the representation contain text instead of a pair of indexes. This makes debugging a little easier.
1 parent 34d6f5b commit b98cd39

2 files changed

Lines changed: 56 additions & 2 deletions

File tree

Doc/partparse.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,14 @@ def __init__(self, chtype, where, data):
197197
self.where = where
198198
self.data = data
199199

200+
__datatypes = [chunk_type[CSNAME], chunk_type[PLAIN], chunk_type[CSLINE]]
201+
200202
def __repr__(self):
201-
return 'chunk' + `self.chtype, self.where, self.data`
203+
if self.chtype in self.__datatypes:
204+
data = s(self.buf, self.data)
205+
else:
206+
data = self.data
207+
return 'chunk' + `self.chtype, self.where, data`
202208

203209
# and the wrapper
204210
chunk = Chunk
@@ -2142,6 +2148,26 @@ def changeit(buf, pp):
21422148
i = i - 1
21432149
length = length + len(data) - 2
21442150

2151+
elif s_buf_data == 'deprecated':
2152+
length, newi = getnextarg(length, buf, pp, i)
2153+
version = pp[i:newi][0]
2154+
print "version =", version
2155+
length, newi2 = getnextarg(length, buf, pp, newi)
2156+
action = pp[newi:newi2]
2157+
print "action =", action
2158+
del pp[i-1:newi2]
2159+
length = length - (newi2 - i) - 1
2160+
stuff = [chunk(PLAIN, ch.where, 'Deprecated since release '),
2161+
version,
2162+
chunk(PLAIN, ch.where, '.')]
2163+
chunks = [chunk(CSNAME, ch.where, 'strong'),
2164+
chunk(GROUP, ch.where, stuff),
2165+
chunk(PLAIN, ch.where, ' ')] + action \
2166+
+ [chunk(DENDLINE, ch.where, '\n')]
2167+
i = i - 1
2168+
pp[i:i] = chunks
2169+
length = length + len(chunks)
2170+
21452171
elif s_buf_data == "quad":
21462172
ch.chtype = PLAIN
21472173
ch.data = " "
@@ -2341,6 +2367,7 @@ def main():
23412367
for file in args:
23422368
if len(args) > 1: print '='*20, file, '='*20
23432369
buf = open(file, 'r').read()
2370+
chunk.buf = buf
23442371
w, pp = parseit(buf)
23452372
startchange()
23462373
changeit(buf, pp)

Doc/tools/partparse.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,8 +197,14 @@ def __init__(self, chtype, where, data):
197197
self.where = where
198198
self.data = data
199199

200+
__datatypes = [chunk_type[CSNAME], chunk_type[PLAIN], chunk_type[CSLINE]]
201+
200202
def __repr__(self):
201-
return 'chunk' + `self.chtype, self.where, self.data`
203+
if self.chtype in self.__datatypes:
204+
data = s(self.buf, self.data)
205+
else:
206+
data = self.data
207+
return 'chunk' + `self.chtype, self.where, data`
202208

203209
# and the wrapper
204210
chunk = Chunk
@@ -2142,6 +2148,26 @@ def changeit(buf, pp):
21422148
i = i - 1
21432149
length = length + len(data) - 2
21442150

2151+
elif s_buf_data == 'deprecated':
2152+
length, newi = getnextarg(length, buf, pp, i)
2153+
version = pp[i:newi][0]
2154+
print "version =", version
2155+
length, newi2 = getnextarg(length, buf, pp, newi)
2156+
action = pp[newi:newi2]
2157+
print "action =", action
2158+
del pp[i-1:newi2]
2159+
length = length - (newi2 - i) - 1
2160+
stuff = [chunk(PLAIN, ch.where, 'Deprecated since release '),
2161+
version,
2162+
chunk(PLAIN, ch.where, '.')]
2163+
chunks = [chunk(CSNAME, ch.where, 'strong'),
2164+
chunk(GROUP, ch.where, stuff),
2165+
chunk(PLAIN, ch.where, ' ')] + action \
2166+
+ [chunk(DENDLINE, ch.where, '\n')]
2167+
i = i - 1
2168+
pp[i:i] = chunks
2169+
length = length + len(chunks)
2170+
21452171
elif s_buf_data == "quad":
21462172
ch.chtype = PLAIN
21472173
ch.data = " "
@@ -2341,6 +2367,7 @@ def main():
23412367
for file in args:
23422368
if len(args) > 1: print '='*20, file, '='*20
23432369
buf = open(file, 'r').read()
2370+
chunk.buf = buf
23442371
w, pp = parseit(buf)
23452372
startchange()
23462373
changeit(buf, pp)

0 commit comments

Comments
 (0)