2
[原文]P114
In the reset method, you initialize a data attribute that serves as a counter for
tags. Every time you hit atag, you increment the counter; every time you hit atag, you'll decrement the counter. (You could just use this as a flag and set it to 1 and reset it to 0, but it's just as easy to do it this way, and this handles the odd (but possible) case of nestedtags.) In a minute, you'll see how this counter is put to good use.
[pope译]
在reset 方法中,你初始化
标签的计数器使用的参数。每遇到计数器加一,每遇到计数器减一。(你应该只会使到作为1和0的标准,但是这种方式非常简便,并且可以奇特控制tags?
{ [?] 这样翻译好古怪,回头查查是什么意思。}
[net 译 来源: http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
在 reset 方法中,我们初始化了一个数据属性,它作为 标记的一个计数器。每当我们找到一个 标记,我们增加计数器的值;每当我们找到一个
[popexizhi
you could just use this as a flag and set it to 1 and reset it to 0
[pope译]你应该只会使到作为1和0的标准
[net 译]
我们本可以把它实现为一个标志,即或把它设为 1,或重置为 0
【popexizhi】 a flag and set it to 1 and reset it to 0 ,这不是最好的标志位的解释吗?“标准”嘻嘻,好吧,我当时一定没有再看一遍这句话
but it's just as easy to do it this way,and this handles the odd(but possible) case of nested
tags.
[pope译]但是这种方式非常简便,并且可以奇特控制
tags?
[net 译]但这样做只是为了方便,并且这样做可以处理古怪 (但有可能) 的 标记嵌套的情况。
【popexizhi】 this handles the odd (but possible) case of nested
tags 可以控制古怪但可能发生的 嵌套 标签。嘻嘻,这里的handles
翻译最初被漏掉了,但是现在看来,这个句子没有明白的情况下这个翻译了也没有全部理解的可能。
In a minute,you'll see how this counter is put to good use.
【popexizhi】pooe最初翻译丢了这个部分的内容了。
]
[pope改进译] 在reset 方法中,你为
标签初始化数据属性的计数器。每次你遇
标签,增此计数器;每逢
标签,减
标签。(本可只用标志位设1,0处理,但此计数器易于处理古怪的嵌套标签)。一会儿,你将看到此计数器的好处。
3
[原文]P115
That's it, that's the only special processing you do for
tags. Now
you pass the list of attributes along to
unknown_starttag so it can do the default processing
[pope译]
到这里为止,是你为
做的特殊处理,现在你通过unknown_starttag 处理,完成默认的处理
[net 译: http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
不错,这就是我们对 标记所做的唯一的特殊处理。现在我们将属性列表传给 unknown_starttag,由它来进行缺省的处理。
[popexizhi
that's it
[pope译]到这里为止
[net 译]不错
【popexizhi:】
这个翻译大家多无可厚非,但是pope记住一个问题,that's it,是句广义的连词,承上启下,以后注意一下,中文中这样的用法其实不少,可以灵活处理一下。
the only special processing you do for
tags
[pope译]是你为
做的特殊处理
[net 译]这就是我们对 标记所做的唯一的特殊处理
【popexizhi】 the only pope忘记翻译了,这个是个问题,句子的中的self.verbatim这个计数器的突出效果就弱化了,不好,不准确。[这个后来想了一下,不对的,这个位置应该是说后面的attributes 的:),sorry]对了题外话说一下special 这个词,晨 记诵单词时发现specialist (专家)这个是此特殊的衍生词,在想special 的原词说明对专家 英语语系中的思考认为是特殊技能的list:)
pass the list of attributes along to unknow_starttag
[pope译]通过unknown_starttag 处理
[net 译]将属性列表传给 unknown_starttag
【popexizhi】pope 将pass the list of attributes忘记翻译了,along to 是沿着去,是the list of attribute 做的内容,而pass则是传递动作的内容
]
[pope改进译]止于此,为
标签所作的唯一特殊处理,传其属性列表至unknow_starttage ,做其默认处理。
4
[原文]P115
end_pre is called every time SGMLParser finds a
tag. Since end tags can not contain attributes, the method takes no parameters.
[pope译]
end_pre 每次在遇到
标签时被调用,由于end tags没有attributes,所以此方法没有参数 [net 译来源: http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
每当 SGMLParser 找到一个
标记时,会调用 end_pre。因为结束标记不能包含属性,因此这个方法没有参数。 [popexizhi
没多少可说的,只是感觉自己的翻译比net的简练:)
]
5
[原文]P115
First, you want to do the default processing, just like any other end tag.
[pope译]
首先,要想其他end tag 一样的默认处理。
[net 译来源: http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
首先我们要进行缺省处理,就像其它结束标记做的一样。
[popexizhi
the default processing 这段net 译一直用缺省处理,嘻嘻,看来这里一直是一个人翻译的:)
]
6
[原文]P115
Second, you decrement your counter to signal that this
block has
been closed.
[pope译]
其次,你减少
的计数器,之后结束
[net 译来源: http://woodpecker.org.cn/diveintopython/html_processing/dialect.html ]
其次我们将计数器减少,标记这个
块已经被关闭了
[popexizhi to signal that this block has been closed
这个位置pope翻译省略的多了点儿,这个位置不能省略this
|
没有评论:
发表评论