~ubuntu-branches/ubuntu/vivid/kate/vivid-proposed

« back to all changes in this revision

Viewing changes to addons/pate/src/plugins/libkatepate/compat.py

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2014-12-04 16:49:41 UTC
  • mfrom: (1.6.6)
  • Revision ID: package-import@ubuntu.com-20141204164941-l3qbvsly83hhlw2v
Tags: 4:14.11.97-0ubuntu1
* New upstream release
* Update build-deps and use pkg-kde v3 for Qt 5 build
* kate-data now kate5-data for co-installability

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
"""
 
4
Contains common Python2-Python3 compatibility 
 
5
When extending this, please let yourself be inspired by mitsuhiko:
 
6
http://lucumr.pocoo.org/2013/5/21/porting-to-python-3-redux/
 
7
 
 
8
text_type is to be used instead of `unicode` in python 2:
 
9
e.g. my_str += text_type(my_exception)
 
10
 
 
11
string_types is to be used instead of basestring:
 
12
i.e. if isinstance(my_obj, string_types): ...
 
13
"""
 
14
 
 
15
import sys
 
16
PY2 = sys.version_info[0] == 2
 
17
if not PY2:
 
18
    text_type = str
 
19
    string_types = (str,)
 
20
    unichr = chr
 
21
else:
 
22
    text_type = unicode
 
23
    string_types = (str, unicode)
 
24
    unichr = unichr