[gobject-introspection/wip/meson: 9/23] giscanner: Remove custom collections implementation



commit 69d85405ad4bb42aa7691e5cf8fd653138109423
Author: Nirbheek Chauhan <nirbheek centricular com>
Date:   Fri Nov 24 02:24:17 2017 +0530

    giscanner: Remove custom collections implementation
    
    We already require python 2.7, and it has OrderedDict and Counter.
    
    Besides cleaning up unmaintained code, this change found and fixed
    a Python 3 bug where we were iterating over a dict while changing it.

 Makefile-giscanner.am                |    6 -
 giscanner/annotationparser.py        |    3 +-
 giscanner/ast.py                     |    2 +-
 giscanner/collections/__init__.py    |   27 ---
 giscanner/collections/counter.py     |  305 ----------------------------------
 giscanner/collections/ordereddict.py |  132 ---------------
 giscanner/gdumpparser.py             |    6 +-
 giscanner/girparser.py               |    2 +-
 giscanner/meson.build                |    5 -
 9 files changed, 6 insertions(+), 482 deletions(-)
---
diff --git a/Makefile-giscanner.am b/Makefile-giscanner.am
index b0e1373..c2bcdf2 100644
--- a/Makefile-giscanner.am
+++ b/Makefile-giscanner.am
@@ -53,12 +53,6 @@ pkgpyexec_PYTHON =                   \
        giscanner/utils.py              \
        giscanner/xmlwriter.py
 
-collectionsdir = $(pkgpyexecdir)/collections
-collections_PYTHON =           \
-       giscanner/collections/__init__.py       \
-       giscanner/collections/counter.py        \
-       giscanner/collections/ordereddict.py
-
 templatedir = $(pkglibdir)
 nobase_dist_template_DATA =            \
        giscanner/doctemplates/base.tmpl        \
diff --git a/giscanner/annotationparser.py b/giscanner/annotationparser.py
index 31a6292..1092310 100644
--- a/giscanner/annotationparser.py
+++ b/giscanner/annotationparser.py
@@ -116,10 +116,9 @@ import os
 import re
 import operator
 
-from collections import namedtuple
 from operator import ne, gt, lt
+from collections import namedtuple, Counter, OrderedDict
 
-from .collections import Counter, OrderedDict
 from .message import Position, warn, error
 
 
diff --git a/giscanner/ast.py b/giscanner/ast.py
index 7a2b5b1..2dff8bd 100644
--- a/giscanner/ast.py
+++ b/giscanner/ast.py
@@ -27,10 +27,10 @@ from __future__ import unicode_literals
 import copy
 import operator
 from itertools import chain
+from collections import OrderedDict
 
 from . import message
 
-from .collections import OrderedDict
 from .message import Position
 from .utils import to_underscores
 
diff --git a/giscanner/gdumpparser.py b/giscanner/gdumpparser.py
index 1134f33..bd4d233 100644
--- a/giscanner/gdumpparser.py
+++ b/giscanner/gdumpparser.py
@@ -89,12 +89,12 @@ class GDumpParser(object):
         """
 
         # First pass: parsing
-        for node in self._namespace.values():
+        for node in list(self._namespace.values()):
             if isinstance(node, ast.Function):
                 self._initparse_function(node)
 
         if self._namespace.name == 'GObject' or self._namespace.name == 'GLib':
-            for node in self._namespace.values():
+            for node in list(self._namespace.values()):
                 if isinstance(node, ast.Record):
                     self._initparse_gobject_record(node)
 
@@ -123,7 +123,7 @@ class GDumpParser(object):
         # Pair up boxed types and class records
         for name, boxed in self._boxed_types.items():
             self._pair_boxed_type(boxed)
-        for node in self._namespace.values():
+        for node in list(self._namespace.values()):
             if isinstance(node, (ast.Class, ast.Interface)):
                 self._find_class_record(node)
 
diff --git a/giscanner/girparser.py b/giscanner/girparser.py
index 909e08d..6841b6c 100644
--- a/giscanner/girparser.py
+++ b/giscanner/girparser.py
@@ -25,11 +25,11 @@ from __future__ import unicode_literals
 
 import os
 
+from collections import OrderedDict
 from xml.etree.cElementTree import parse
 
 from . import ast
 from .girwriter import COMPATIBLE_GIR_VERSION
-from .collections import OrderedDict
 
 CORE_NS = "http://www.gtk.org/introspection/core/1.0";
 C_NS = "http://www.gtk.org/introspection/c/1.0";
diff --git a/giscanner/meson.build b/giscanner/meson.build
index e9a9c3c..acf1486 100644
--- a/giscanner/meson.build
+++ b/giscanner/meson.build
@@ -29,11 +29,6 @@ install_data([
   'xmlwriter.py',
 ], install_dir: giscannerdir)
 
-install_data([
-  'collections/__init__.py',
-  'collections/counter.py',
-  'collections/ordereddict.py',
-], install_dir: join_paths(giscannerdir, 'collections'))
 
 install_subdir('doctemplates', install_dir: giscannerdir)
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]