From nobody Tue Feb 10 19:47:58 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1528479476858900.9600561344434; Fri, 8 Jun 2018 10:37:56 -0700 (PDT) Received: from localhost ([::1]:37299 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRLKm-0006RW-3Y for importer@patchew.org; Fri, 08 Jun 2018 13:37:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45295) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRLJE-0005d9-Iy for qemu-devel@nongnu.org; Fri, 08 Jun 2018 13:36:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRLJD-0004i8-BC for qemu-devel@nongnu.org; Fri, 08 Jun 2018 13:36:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:51150) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fRLJD-0004hm-3t for qemu-devel@nongnu.org; Fri, 08 Jun 2018 13:36:19 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 632383082A27; Fri, 8 Jun 2018 17:36:18 +0000 (UTC) Received: from localhost (ovpn-116-19.gru2.redhat.com [10.97.116.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 537D2100190D; Fri, 8 Jun 2018 17:36:15 +0000 (UTC) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 8 Jun 2018 14:35:58 -0300 Message-Id: <20180608173558.8122-3-ehabkost@redhat.com> In-Reply-To: <20180608173558.8122-1-ehabkost@redhat.com> References: <20180608173558.8122-1-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Fri, 08 Jun 2018 17:36:18 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 2/2] python: Remove scripts/ordereddict.py X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Cleber Rosa Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Python 2.7 (the minimum Python version we require) provides collections.OrderedDict on the standard library, so we don't need to carry our own implementation. Signed-off-by: Eduardo Habkost --- scripts/ordereddict.py | 128 ----------------------------------------- scripts/qapi/common.py | 5 +- 2 files changed, 1 insertion(+), 132 deletions(-) delete mode 100644 scripts/ordereddict.py diff --git a/scripts/ordereddict.py b/scripts/ordereddict.py deleted file mode 100644 index 68ed340b33..0000000000 --- a/scripts/ordereddict.py +++ /dev/null @@ -1,128 +0,0 @@ -# Copyright (c) 2009 Raymond Hettinger -# -# Permission is hereby granted, free of charge, to any person -# obtaining a copy of this software and associated documentation files -# (the "Software"), to deal in the Software without restriction, -# including without limitation the rights to use, copy, modify, merge, -# publish, distribute, sublicense, and/or sell copies of the Software, -# and to permit persons to whom the Software is furnished to do so, -# subject to the following conditions: -# -# The above copyright notice and this permission notice shall be -# included in all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -# OTHER DEALINGS IN THE SOFTWARE. - -from UserDict import DictMixin - - -class OrderedDict(dict, DictMixin): - - def __init__(self, *args, **kwds): - if len(args) > 1: - raise TypeError('expected at most 1 arguments, got %d' % len(a= rgs)) - try: - self.__end - except AttributeError: - self.clear() - self.update(*args, **kwds) - - def clear(self): - self.__end =3D end =3D [] - end +=3D [None, end, end] # sentinel node for doubly linke= d list - self.__map =3D {} # key --> [key, prev, next] - dict.clear(self) - - def __setitem__(self, key, value): - if key not in self: - end =3D self.__end - curr =3D end[1] - curr[2] =3D end[1] =3D self.__map[key] =3D [key, curr, end] - dict.__setitem__(self, key, value) - - def __delitem__(self, key): - dict.__delitem__(self, key) - key, prev, next =3D self.__map.pop(key) - prev[2] =3D next - next[1] =3D prev - - def __iter__(self): - end =3D self.__end - curr =3D end[2] - while curr is not end: - yield curr[0] - curr =3D curr[2] - - def __reversed__(self): - end =3D self.__end - curr =3D end[1] - while curr is not end: - yield curr[0] - curr =3D curr[1] - - def popitem(self, last=3DTrue): - if not self: - raise KeyError('dictionary is empty') - if last: - key =3D next(reversed(self)) - else: - key =3D next(iter(self)) - value =3D self.pop(key) - return key, value - - def __reduce__(self): - items =3D [[k, self[k]] for k in self] - tmp =3D self.__map, self.__end - del self.__map, self.__end - inst_dict =3D vars(self).copy() - self.__map, self.__end =3D tmp - if inst_dict: - return (self.__class__, (items,), inst_dict) - return self.__class__, (items,) - - def keys(self): - return list(self) - - setdefault =3D DictMixin.setdefault - update =3D DictMixin.update - pop =3D DictMixin.pop - values =3D DictMixin.values - items =3D DictMixin.items - iterkeys =3D DictMixin.iterkeys - itervalues =3D DictMixin.itervalues - iteritems =3D DictMixin.iteritems - - def __repr__(self): - if not self: - return '%s()' % (self.__class__.__name__,) - return '%s(%r)' % (self.__class__.__name__, self.items()) - - def copy(self): - return self.__class__(self) - - @classmethod - def fromkeys(cls, iterable, value=3DNone): - d =3D cls() - for key in iterable: - d[key] =3D value - return d - - def __eq__(self, other): - if isinstance(other, OrderedDict): - if len(self) !=3D len(other): - return False - for p, q in zip(self.items(), other.items()): - if p !=3D q: - return False - return True - return dict.__eq__(self, other) - - def __ne__(self, other): - return not self =3D=3D other diff --git a/scripts/qapi/common.py b/scripts/qapi/common.py index e82990f0f2..2462fc0291 100644 --- a/scripts/qapi/common.py +++ b/scripts/qapi/common.py @@ -16,10 +16,7 @@ import errno import os import re import string -try: - from collections import OrderedDict -except: - from ordereddict import OrderedDict +from collections import OrderedDict =20 builtin_types =3D { 'null': 'QTYPE_QNULL', --=20 2.18.0.rc1.1.g3f1ff2140