summaryrefslogtreecommitdiff
path: root/obsapi/null.py
diff options
context:
space:
mode:
authorScott Bahling <sbahling@suse.de>2016-09-14 12:11:47 +0200
committerScott Bahling <sbahling@suse.de>2017-02-21 06:50:51 +0100
commitee51997334672b2d4a4813c4e4ae2e4a21683fa7 (patch)
tree330a98eac59ddb791848521b457f19b702bd46c2 /obsapi/null.py
parent525ac83bf2bb2c0a23ba78045cbfa6393a4cb2d8 (diff)
downloadobsapi-ee51997334672b2d4a4813c4e4ae2e4a21683fa7.tar.gz
obsapi-ee51997334672b2d4a4813c4e4ae2e4a21683fa7.tar.xz
obsapi-ee51997334672b2d4a4813c4e4ae2e4a21683fa7.zip
Implement locking api; refactor ObsSourceApi get/put/post calls
Diffstat (limited to 'obsapi/null.py')
-rw-r--r--obsapi/null.py42
1 files changed, 42 insertions, 0 deletions
diff --git a/obsapi/null.py b/obsapi/null.py
new file mode 100644
index 0000000..bbfce6e
--- /dev/null
+++ b/obsapi/null.py
@@ -0,0 +1,42 @@
+# -*- coding: utf-8 -*-
+"""
+ Null object
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Simple implementation of the Null Object Pattern.
+ Taken from "Implementing the Null Object Pattern" recipe from
+ the Python CookBook.
+
+ :url: https://www.safaribooksonline.com/library/view/python-cookbook/0596001673/ch05s24.html
+ :credit: Dinu C. Gherman
+
+ :copyright: Copyright (c) 2012-2015 Scott Bahling, SUSE Linux GmbH
+ :license: GPL-2.0, see COPYING for details
+"""
+
+
+class Null:
+ """ Null objects always and reliably "do nothing." """
+
+ def __init__(self, *args, **kwargs):
+ pass
+
+ def __call__(self, *args, **kwargs):
+ return self
+
+ def __repr__(self):
+ return "Null( )"
+
+ def __str__(self):
+ return ""
+
+ def __nonzero__(self):
+ return 0
+
+ def __getattr__(self, name):
+ return self
+
+ def __setattr__(self, name, value):
+ return self
+
+ def __delattr__(self, name):
+ return self