2
[原文]P116
In the ancestor BaseHTMLProcessor, the handle_data method simply appended the text to the output buffer, self.pieces.
[pope译] 在BaseHTMLProcessor的调度器中,handle_data 方法简单的 附加 text 到self.pieces 的output 缓冲.
[net 译 来源:http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
在祖先类 BaseHTMLProcessor 中,handle_data 方法只是将文本追加到输出缓冲区 self.pieces 之后
[popexizhi:
the ancestor
[popexizhi]查了一下class Dialectizer(BaseHTMLProcessor)定义,这个ancestor 是当前描述的Dialectizer的父类,没有问题的,这里应该翻译的
appended the text to the output buffer,self.pieces
[popexizhi] 查了一下父类的handle_data(self, text)的定义内容:
handle_data(self, text):
self.pieces.append(text)
这里使用append就是将这个text加入到了self.pieces之后的,pope翻译中没有体现append()的添加位置。
]
Here the logic is only slightly more complicated. If you're in the middle of a
...block, self.verbatim will be some value greater than 0, and you want to put the text in the output buffer unaltered. Otherwise, you will call a separate method to process the substitutions, then put the result of that into the output buffer. In Python, this is a one−liner, using the and−or trick.
[pope译]这里的逻辑稍微有点复杂(only sightly more complicated).如果你在
..块(block)中,self.verbatim将有些值大于0,并且你打算放一些文本在输出缓存中不被改变(unaltered).否则(otherwise),你需要调用分离method 处理替换,并且放结果到输出缓存中。在Python 中,可以在一行中使用and-or [?]这里的trick如何翻译呢?
[net 译 来源:http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
这里的逻辑稍微有点复杂。如果我们处于 ...
块的中间,self.verbatim 将是大于 0 的某个值,接着我们想要将文本不作改动地传入输出缓冲区。否则,我们将调用另一个单独的方法来进行替换处理,然后将处理结果放入输出缓冲区中。在 Python 中,这是一个一行代码,它使用了and-or 技巧。
[popexizhi:
and-or 的使用先解释是一些,下面是原文给出的例子:
>>> a = "first"
>>> b = "second"
>>> 1 and a or b
'first'
>>> 0 and a or b
'second'
先做与运行再做或运算
self.verbatlm will be some value greater than 0
[pope译]self.verbatim将有些值大于0
[net 译]self.verbatim 将是大于 0 的某个值
[popexizhi]some value pope翻译为某些,value 可是单数啊,注意了啊!细想来是因为看到some 一直认为这个是表示数量的,重查字典,可是有“某个”的翻译的:),这次不归结为自己的粗心了,想来是自己的模糊处,加之大意,模糊是最主要的,大意只是自己的表象而已。不过重新查看的过程正好可以细细打磨,想来也是塞翁失马了。
and you want to put the text in the output buffer unaltered.
[pope译]并且你打算放一些文本在输出缓存中不被改变(unaltered)
[net 译]接着我们想要将文本不作改动地传入输出缓冲区
[popexizhi] 这里的两种翻译,都讲的过去,但是要说的是 the text in the output buffer unaltered 中unaltered 与 in the output buffer 是否有顺序问题,pope的翻译让人感觉是输出缓冲中之后unaltered .但原文应该说的是unaltered text in the output buffer.net 翻译的应该是更好"将文本不作改动地传入输出缓冲区" ,这里说的是这种后置形容词 翻译如何更好的问题,试试文言方式:
“预置文本于输出缓冲区 且不改之”,不是很好,再想想吧!
]
没有评论:
发表评论