255 @rtype int |
255 @rtype int |
256 """ |
256 """ |
257 # convert lineno to be zero based |
257 # convert lineno to be zero based |
258 lineno -= 1 |
258 lineno -= 1 |
259 # 1. search for opening brace '{' |
259 # 1. search for opening brace '{' |
260 while lineno < len(lines) and not "{" in lines[lineno]: |
260 while lineno < len(lines) and "{" not in lines[lineno]: |
261 lineno += 1 |
261 lineno += 1 |
262 depth = lines[lineno].count("{") - lines[lineno].count("}") |
262 depth = lines[lineno].count("{") - lines[lineno].count("}") |
263 # 2. search for ending line, i.e. matching closing brace '}' |
263 # 2. search for ending line, i.e. matching closing brace '}' |
264 while depth > 0 and lineno < len(lines) - 1: |
264 while depth > 0 and lineno < len(lines) - 1: |
265 lineno += 1 |
265 lineno += 1 |