[PATCH 4/4] Rename queue.py to queuefactory.py.

Chris Lumens clumens at redhat.com
Fri Feb 20 16:31:43 UTC 2015


In python3, the standard Queue.py has been renamed to queue.py, so anything
in the standard library that imports queue will get confused if pyanaconda
is at the front of PYTHONPATH.  It's best to just stay out of the way.
---
 pyanaconda/progress.py         |  2 +-
 pyanaconda/queue.py            | 78 ------------------------------------------
 pyanaconda/queuefactory.py     | 78 ++++++++++++++++++++++++++++++++++++++++++
 pyanaconda/ui/communication.py |  2 +-
 4 files changed, 80 insertions(+), 80 deletions(-)
 delete mode 100644 pyanaconda/queue.py
 create mode 100644 pyanaconda/queuefactory.py

diff --git a/pyanaconda/progress.py b/pyanaconda/progress.py
index dc7a38c..f1d20ad 100644
--- a/pyanaconda/progress.py
+++ b/pyanaconda/progress.py
@@ -23,7 +23,7 @@ log = logging.getLogger("anaconda")
 
 from contextlib import contextmanager
 
-from pyanaconda.queue import QueueFactory
+from pyanaconda.queuefactory import QueueFactory
 
 # A queue to be used for communicating progress information between a subthread
 # doing all the hard work and the main thread that does the GTK updates.  This
diff --git a/pyanaconda/queue.py b/pyanaconda/queue.py
deleted file mode 100644
index 31f6a54..0000000
--- a/pyanaconda/queue.py
+++ /dev/null
@@ -1,78 +0,0 @@
-#
-# queue.py: factory for creating communications channels
-#
-# Copyright (C) 2013  Red Hat, Inc.  All rights reserved.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-#
-# Author(s): Chris Lumens <clumens at redhat.com>
-
-import Queue
-from pyanaconda.iutil import lowerASCII, upperASCII
-
-class QueueFactory(object):
-    """Constructs a new object wrapping a Queue.Queue, complete with constants
-       and sending functions for each type of message that can be put into the
-       queue.
-
-       Creating a new object using this class is done like so:
-
-           q = QueueFactory("progress")
-
-       And then adding messages to it is done like so:
-
-           q.addMessage("init", 0)
-           q.addMessage("step", 1)
-
-       The first call will create a new constant named PROGRESS_CODE_INIT and a
-       method named send_init that takes zero arguments.  The second call will
-       create a new constant named PROGRESS_CODE_STEP and a method named send_step
-       that takes one argument.
-
-       Reusing names within the same class is not allowed.
-    """
-    def __init__(self, name):
-        self.name = name
-
-        self.__counter = 0
-        self.__names = []
-
-        self.q = Queue.Queue()
-
-    def _makeMethod(self, constant, methodName, argc):
-        def __method(*args):
-            if len(args) != argc:
-                raise TypeError("%s() takes exactly %d arguments (%d given)" %
-                                (methodName, argc, len(args)))
-
-            self.q.put((constant, args))
-
-        __method.__name__ = methodName
-        return __method
-
-    def addMessage(self, name, argc):
-        if name in self.__names:
-            raise AttributeError("%s queue already has a message named %s" % (self.name, name))
-
-        # Add a constant.
-        const_name = upperASCII(self.name) + "_CODE_" + upperASCII(name)
-        setattr(self, const_name, self.__counter)
-        self.__counter += 1
-
-        # Add a convenience method for putting things into the queue.
-        method_name = "send_" + lowerASCII(name)
-        method = self._makeMethod(getattr(self, const_name), method_name, argc)
-        setattr(self, method_name, method)
-
-        self.__names.append(name)
diff --git a/pyanaconda/queuefactory.py b/pyanaconda/queuefactory.py
new file mode 100644
index 0000000..31f6a54
--- /dev/null
+++ b/pyanaconda/queuefactory.py
@@ -0,0 +1,78 @@
+#
+# queue.py: factory for creating communications channels
+#
+# Copyright (C) 2013  Red Hat, Inc.  All rights reserved.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author(s): Chris Lumens <clumens at redhat.com>
+
+import Queue
+from pyanaconda.iutil import lowerASCII, upperASCII
+
+class QueueFactory(object):
+    """Constructs a new object wrapping a Queue.Queue, complete with constants
+       and sending functions for each type of message that can be put into the
+       queue.
+
+       Creating a new object using this class is done like so:
+
+           q = QueueFactory("progress")
+
+       And then adding messages to it is done like so:
+
+           q.addMessage("init", 0)
+           q.addMessage("step", 1)
+
+       The first call will create a new constant named PROGRESS_CODE_INIT and a
+       method named send_init that takes zero arguments.  The second call will
+       create a new constant named PROGRESS_CODE_STEP and a method named send_step
+       that takes one argument.
+
+       Reusing names within the same class is not allowed.
+    """
+    def __init__(self, name):
+        self.name = name
+
+        self.__counter = 0
+        self.__names = []
+
+        self.q = Queue.Queue()
+
+    def _makeMethod(self, constant, methodName, argc):
+        def __method(*args):
+            if len(args) != argc:
+                raise TypeError("%s() takes exactly %d arguments (%d given)" %
+                                (methodName, argc, len(args)))
+
+            self.q.put((constant, args))
+
+        __method.__name__ = methodName
+        return __method
+
+    def addMessage(self, name, argc):
+        if name in self.__names:
+            raise AttributeError("%s queue already has a message named %s" % (self.name, name))
+
+        # Add a constant.
+        const_name = upperASCII(self.name) + "_CODE_" + upperASCII(name)
+        setattr(self, const_name, self.__counter)
+        self.__counter += 1
+
+        # Add a convenience method for putting things into the queue.
+        method_name = "send_" + lowerASCII(name)
+        method = self._makeMethod(getattr(self, const_name), method_name, argc)
+        setattr(self, method_name, method)
+
+        self.__names.append(name)
diff --git a/pyanaconda/ui/communication.py b/pyanaconda/ui/communication.py
index 6b819c5..df2f02c 100644
--- a/pyanaconda/ui/communication.py
+++ b/pyanaconda/ui/communication.py
@@ -18,7 +18,7 @@
 #
 # Author(s): Chris Lumens <clumens at redhat.com>
 
-from pyanaconda.queue import QueueFactory
+from pyanaconda.queuefactory import QueueFactory
 
 # A queue to be used for communicating information from a spoke back to its
 # hub.  This information includes things like marking spokes as ready and
-- 
2.2.2



More information about the anaconda-patches mailing list