File: RecursiveNull.py

package info (click to toggle)
scribus 1.5.8%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 179,080 kB
  • sloc: cpp: 483,300; python: 65,124; xml: 14,334; ansic: 2,484; sh: 192; perl: 95; makefile: 79
file content (28 lines) | stat: -rw-r--r-- 722 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Nothing, but in a friendly way.  Good for filling in for objects you want to
hide.  If $form.f1 is a RecursiveNull object, then
$form.f1.anything["you"].might("use") will resolve to the empty string.

This module was contributed by Ian Bicking.
"""

class RecursiveNull(object):
    def __getattr__(self, attr):
        return self
    def __getitem__(self, item):
        return self
    def __call__(self, *args, **kwargs):
        return self
    def __str__(self):
        return ''
    def __repr__(self):
        return ''
    def __nonzero__(self):
        return 0
    def __eq__(self, x):
        if x:
            return False
        return True
    def __ne__(self, x):
        return x and True or False