Kirill Simonov avatar Kirill Simonov committed 456144d

duplicates -> seen or used

Comments (0)

Files changed (7)

src/htsql/core/adapter.py

         Returns all names assigned to protocol implementations.
         """
         names = []
-        duplicates = set()
+        seen = set()
         for component in interface.__implementations__():
             for name in component.__names__:
-                if name not in duplicates:
+                if name not in seen:
                     names.append(name)
-                    duplicates.add(name)
+                    seen.add(name)
         names.sort()
         return names
 

src/htsql/core/classify.py

         for signature in sorted(rejections_by_signature):
             name, arity = signature
             alternatives = []
-            duplicates = set()
+            seen = set()
             for arc in rejections_by_signature[signature]:
-                if arc in duplicates:
+                if arc in seen:
                     continue
                 alternatives.append(arc)
-                duplicates.add(arc)
+                seen.add(arc)
             arc = AmbiguousArc(arity, alternatives)
             label = Label(name, arc, False)
             labels.append(label)
 
     def trace(self, node):
         arcs = []
-        duplicates = set()
+        seen = set()
         for arc in Trace.__invoke__(node):
-            if arc in duplicates:
+            if arc in seen:
                 continue
             arcs.append(arc)
-            duplicates.add(arc)
+            seen.add(arc)
         return arcs
 
     def call(self, arc):
         bids = []
-        duplicates = set()
+        seen = set()
         for name, weight in Call.__invoke__(arc):
             name = normalize(name)
-            if (name, weight) in duplicates:
+            if (name, weight) in seen:
                 continue
             bids.append((name, weight))
-            duplicates.add((name, weight))
+            seen.add((name, weight))
         return bids
 
     def order(self, labels):
     assert isinstance(arc, Arc)
     cache = context.app.htsql.cache
     labels = classify(arc.origin)
-    duplicates = set()
+    seen = set()
     labels_by_arc = {}
     labels_by_arc[arc] = []
     arcs = [arc]
     for label in labels:
-        assert label.name not in duplicates, label
-        duplicates.add(label.name)
+        assert label.name not in seen, label
+        seen.add(label.name)
         arc = label.arc
         if arc not in labels_by_arc:
             labels_by_arc[arc] = []

src/htsql/core/domain.py

             name = cls.__name__
 
         # Names already taken.
-        duplicates = set()
+        seen = set()
         # Process all field names.
         for idx, field in enumerate(fields):
             if field is None:
                 if keyword.iskeyword(field):
                     field = field+'_'
                 # Skip names already taken.
-                if field in duplicates:
+                if field in seen:
                     field = None
                 # Store the normalized name.
                 fields[idx] = field
-                duplicates.add(field)
+                seen.add(field)
 
         # Prepare the class namespace and generate the class.
         bases = (cls,)

src/htsql/core/fmt/json.py

         super(RecordToJSON, self).__init__(domain)
         self.fields_to_json = [to_json(field.domain) for field in domain.fields]
         self.field_keys = []
-        duplicates = set()
+        used = set()
         for idx, field in enumerate(self.domain.fields):
-            if field.tag and field.tag not in duplicates:
+            if field.tag and field.tag not in used:
                 key = field.tag
-                duplicates.add(key)
+                used.add(key)
             else:
                 key = unicode(idx)
             self.field_keys.append(key)

src/htsql/core/fmt/xml.py

     def __init__(self, domain, tag):
         super(RecordToXML, self).__init__(domain, tag)
         self.fields_to_xml = []
-        duplicates = set()
+        used = set()
         for idx, field in enumerate(self.domain.fields):
-            if (field.tag and field.tag not in duplicates and
+            if (field.tag and field.tag not in used and
                     not re.match(r"""^[Xx][Mm][Ll]|^_\d*$""", field.tag)):
                 tag = field.tag
-                duplicates.add(tag)
+                used.add(tag)
             else:
                 tag = u"_%s" % (idx+1)
             field_to_xml = to_xml(field.domain, tag)

src/htsql/core/introspect.py

 
         for schema in catalog.schemas:
             for table in schema.tables:
-                duplicates = {}
+                seen = {}
                 for unique_key in list(table.unique_keys):
                     key = tuple(unique_key.origin_columns)
-                    if key in duplicates:
-                        other_key = duplicates[key]
+                    if key in seen:
+                        other_key = seen[key]
                         if (unique_key.is_primary or
                             (not unique_key.is_partial and
                                 other_key.is_partial)):
                             other_key.remove()
-                            duplicates[key] = unique_key
+                            seen[key] = unique_key
                         else:
                             unique_key.remove()
                     else:
-                        duplicates[key] = unique_key
-                duplicates = {}
+                        seen[key] = unique_key
+                seen = {}
                 for foreign_key in list(table.foreign_keys):
                     key = (tuple(foreign_key.origin_columns),
                            foreign_key.target,
                            tuple(foreign_key.target_columns))
-                    if key in duplicates:
-                        other_key = duplicates[key]
+                    if key in seen:
+                        other_key = seen[key]
                         if (not foreign_key.is_partial and
                                 other_key.is_partial):
                             other_key.remove()
-                            duplicates[key] = foreign_key
+                            seen[key] = foreign_key
                         else:
                             foreign_key.remove()
                     else:
-                        duplicates[key] = foreign_key
+                        seen[key] = foreign_key
 
         return catalog
 

src/htsql/tweak/meta/slave/connect.py

         cursor = self.connection.cursor()
 
         home_arcs = []
-        duplicates = set()
+        seen = set()
         for label in classify(HomeNode()):
             arc = label.arc
             if not isinstance(arc, TableArc):
                 continue
-            if arc in duplicates:
+            if arc in seen:
                 continue
             home_arcs.append(arc)
-            duplicates.add(arc)
+            seen.add(arc)
 
         for arc in home_arcs:
             labels = relabel(arc)
         for home_arc in home_arcs:
             origin = home_arc.target
             table_arcs = []
-            duplicates = set()
+            seen = set()
             for label in classify(origin):
                 arc = label.arc
                 if not isinstance(arc, (ColumnArc, ChainArc)):
                     continue
-                if arc in duplicates:
+                if arc in seen:
                     continue
                 if (isinstance(arc, ChainArc) and
                         not relabel(TableArc(arc.target.table))):
                     continue
                 table_arcs.append(arc)
-                duplicates.add(arc)
+                seen.add(arc)
 
             table_name = relabel(TableArc(origin.table))[0].name
             last_sort = 0
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.