[schema2sql] get range from six.moves

Related to #267910.

authorJulien Cristau <julien.cristau@logilab.fr>
changeset9899cf1d9446
branchdefault
phasedraft
hiddenyes
parent revision#342166002939 [schema] implement __eq__ and __lt__ instead of __cmp__ for ERSchema
child revision#c73195f81fcc [test] deal with py3k's string types
files modified by this revision
schema2sql.py
# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1413463763 -7200
# Thu Oct 16 14:49:23 2014 +0200
# Node ID 9899cf1d9446ae8bb242afe4f3523a620743926b
# Parent 3421660029393edd6b836575432704a06fdbb685
[schema2sql] get range from six.moves

Related to #267910.

diff --git a/schema2sql.py b/schema2sql.py
@@ -19,10 +19,12 @@
1 
2  __docformat__ = "restructuredtext en"
3 
4  from hashlib import md5
5 
6 +from six.moves import range
7 +
8  from yams.constraints import SizeConstraint, UniqueConstraint
9 
10  # default are usually not handled at the sql level. If you want them, set
11  # SET_DEFAULT to True
12  SET_DEFAULT = False
@@ -107,11 +109,11 @@
13      w = output.append
14      table = prefix + eschema.type
15      w('CREATE TABLE %s(' % (table))
16      attrs = eschema_attrs(eschema, skip_relations)
17      # XXX handle objectinline physical mode
18 -    for i in xrange(len(attrs)):
19 +    for i in range(len(attrs)):
20          rschema, attrschema = attrs[i]
21          if attrschema is not None:
22              sqltype = aschema2sql(dbhelper, eschema, rschema, attrschema,
23                                    indent=' ')
24          else: # inline relation
@@ -121,11 +123,11 @@
25              w(' %s%s %s' % (prefix, rschema.type, sqltype))
26          else:
27              w(' %s%s %s,' % (prefix, rschema.type, sqltype))
28      w(');')
29      # create indexes
30 -    for i in xrange(len(attrs)):
31 +    for i in range(len(attrs)):
32          rschema, attrschema = attrs[i]
33          if attrschema is None or eschema.rdef(rschema).indexed:
34              w(dbhelper.sql_create_index(table, prefix + rschema.type))
35      for columns, index_name in iter_unique_index_names(eschema):
36          cols  = ['%s%s' % (prefix, col) for col in columns]