[PATCH 15 of 23 yams] [misc] simplify code

Laurent Peuch cortex at worlddomination.be
Fri Feb 14 16:00:05 CET 2020


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1580232810 -3600
#      Tue Jan 28 18:33:30 2020 +0100
# Node ID 46970dfc3a85f9560d44d3686ad0d3cd6b3fd03a
# Parent  325ae96ad162f1dc953bb6787c82be161c5bf010
# Available At https://hg.logilab.org/users/lpeuch/yams
#              hg pull https://hg.logilab.org/users/lpeuch/yams -r 46970dfc3a85
[misc] simplify code

diff --git a/yams/schema2dot.py b/yams/schema2dot.py
--- a/yams/schema2dot.py
+++ b/yams/schema2dot.py
@@ -122,10 +122,8 @@ class FullSchemaVisitor(SchemaVisitor):
     def __init__(self, schema, skiptypes=()):
         super(FullSchemaVisitor, self).__init__(skiptypes)
         self.schema = schema
-        self._eindex = None
-        entities = [eschema for eschema in schema.entities()
-                    if self.should_display_schema(eschema)]
-        self._eindex = dict([(e.type, e) for e in entities])
+        self._eindex = {eschema.type: eschema for eschema in schema.entities()
+                        if self.should_display_schema(eschema)}
 
     def nodes(self):
         for eschema in sorted(self._eindex.values(), key=lambda x: x.type):



More information about the cubicweb-devel mailing list