6 """ |
6 """ |
7 Package implementing various functions/classes needed everywhere within eric6. |
7 Package implementing various functions/classes needed everywhere within eric6. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 try: |
|
12 str = unicode |
|
13 import locale |
|
14 import urllib |
|
15 |
|
16 def quote(url): |
|
17 """ |
|
18 Replacement for the urllib.quote function because of unicode problems. |
|
19 |
|
20 @param url text to quote (string) |
|
21 @return quoted url (string) |
|
22 """ |
|
23 return urllib.quote(url.encode('utf-8')) |
|
24 except NameError: |
|
25 basestring = str |
|
26 from urllib.parse import quote # __IGNORE_WARNING__ |
|
27 |
11 |
28 import os |
12 import os |
29 import sys |
13 import sys |
30 import codecs |
14 import codecs |
31 import re |
15 import re |
621 |
605 |
622 @param text text to be scanned (string) |
606 @param text text to be scanned (string) |
623 @return dictionary of string, boolean, complex, float and int |
607 @return dictionary of string, boolean, complex, float and int |
624 """ |
608 """ |
625 flags = {} |
609 flags = {} |
626 if isinstance(text, basestring): |
610 if isinstance(text, str): |
627 lines = text.rstrip().splitlines() |
611 lines = text.rstrip().splitlines() |
628 else: |
612 else: |
629 lines = text |
613 lines = text |
630 for line in reversed(lines): |
614 for line in reversed(lines): |
631 try: |
615 try: |
1651 elif ext in py2Ext and ext not in py3Ext: |
1632 elif ext in py2Ext and ext not in py3Ext: |
1652 pyVer = 2 |
1633 pyVer = 2 |
1653 elif ext in py3Ext and ext not in py2Ext: |
1634 elif ext in py3Ext and ext not in py2Ext: |
1654 pyVer = 3 |
1635 pyVer = 3 |
1655 elif source: |
1636 elif source: |
1656 if isinstance(source, basestring): |
1637 if isinstance(source, str): |
1657 line0 = source.splitlines()[0] |
1638 line0 = source.splitlines()[0] |
1658 else: |
1639 else: |
1659 line0 = source[0] |
1640 line0 = source[0] |
1660 if line0.startswith("#!"): |
1641 if line0.startswith("#!"): |
1661 if "python3" in line0: |
1642 if "python3" in line0: |