]> kaliko git repositories - python-musicpd.git/blobdiff - musicpd.py
Move everything to setup.cfg
[python-musicpd.git] / musicpd.py
index d96e76a54387fcfb7d6ac8db9be83540252edf83..9603edc5baacc4b8ce04028aa3248073a5fa7267 100644 (file)
@@ -1,5 +1,6 @@
 # python-musicpd: Python MPD client library
 # Copyright (C) 2012-2021  kaliko <kaliko@azylum.org>
+# Copyright (C) 2021       Wonko der Verständige <wonko@hanstool.org>
 # Copyright (C) 2019       Naglis Jonaitis <naglis@mailbox.org>
 # Copyright (C) 2019       Bart Van Loon <bbb@bbbart.be>
 # Copyright (C) 2008-2010  J. Alexander Treuman <jat@spatialrift.net>
@@ -726,6 +727,13 @@ class MPDClient:
             self._sock.close()
         self._reset()
 
+    def __enter__(self):
+        self.connect()
+        return self
+
+    def __exit__(self, exception_type, exception_value, exception_traceback):
+        self.disconnect()
+
     def fileno(self):
         """Return the socket’s file descriptor (a small integer).
         This is useful with :py:obj:`select.select`.