"Fossies" - the Fresh Open Source Software Archive

Member "cheetah3-3.2.6.post2/Cheetah/Tools/RecursiveNull.py" (20 Apr 2021, 849 Bytes) of package /linux/www/cheetah3-3.2.6.post2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "RecursiveNull.py" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 3-3.0.1_vs_3-3.1.0.

    1 """
    2 Nothing, but in a friendly way.  Good for filling in for objects you want to
    3 hide.  If $form.f1 is a RecursiveNull object, then
    4 $form.f1.anything["you"].might("use") will resolve to the empty string.
    5 
    6 This module was contributed by Ian Bicking.
    7 """
    8 import sys
    9 
   10 
   11 class RecursiveNull(object):
   12     def __getattr__(self, attr):
   13         return self
   14 
   15     def __getitem__(self, item):
   16         return self
   17 
   18     def __call__(self, *args, **kwargs):
   19         return self
   20 
   21     def __str__(self):
   22         return ''
   23 
   24     def __repr__(self):
   25         return ''
   26     if sys.version_info[0] >= 3:
   27         def __bool__(self):
   28             return 0
   29     else:
   30         def __nonzero__(self):
   31             return 0
   32 
   33     def __eq__(self, x):
   34         if x:
   35             return False
   36         return True
   37 
   38     def __ne__(self, x):
   39         return x and True or False
   40 
   41 
   42 del sys