ThirdParty/asttokens/asttokens/util.py

changeset 6936
6b301c8a3c5b
parent 6929
0db8a4378ad7
equal deleted inserted replaced
6935:71627b93aebc 6936:6b301c8a3c5b
10 # distributed under the License is distributed on an "AS IS" BASIS, 10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and 12 # See the License for the specific language governing permissions and
13 # limitations under the License. 13 # limitations under the License.
14 14
15 import sys
16 # define some compatibility methods like it is done in six.
17 if sys.version_info[0] == 2:
18 # Python 2
19 def iteritems(d):
20 return d.iteritems()
21 else:
22 # Python 3
23 def iteritems(d):
24 return iter(d.items())
25
15 import ast 26 import ast
16 import collections 27 import collections
17 import token 28 import token
18 from six import iteritems
19 29
20 30
21 def token_repr(tok_type, string): 31 def token_repr(tok_type, string):
22 """Returns a human-friendly representation of a token with the given type and string.""" 32 """Returns a human-friendly representation of a token with the given type and string."""
23 # repr() prefixes unicode with 'u' on Python2 but not Python3; strip it out for consistency. 33 # repr() prefixes unicode with 'u' on Python2 but not Python3; strip it out for consistency.

eric ide

mercurial