source: titan/mediathek/localhoster/lib/python2.7/lib2to3/fixes/fix_nonzero.py @ 40094

Last change on this file since 40094 was 40094, checked in by obi, 7 years ago

tithek add yoztube-dl support

File size: 598 bytes
Line 
1"""Fixer for __nonzero__ -> __bool__ methods."""
2# Author: Collin Winter
3
4# Local imports
5from .. import fixer_base
6from ..fixer_util import Name, syms
7
8class FixNonzero(fixer_base.BaseFix):
9    BM_compatible = True
10    PATTERN = """
11    classdef< 'class' any+ ':'
12              suite< any*
13                     funcdef< 'def' name='__nonzero__'
14                              parameters< '(' NAME ')' > any+ >
15                     any* > >
16    """
17
18    def transform(self, node, results):
19        name = results["name"]
20        new = Name(u"__bool__", prefix=name.prefix)
21        name.replace(new)
Note: See TracBrowser for help on using the repository browser.