eric6/Utilities/__init__.py

branch
without_py2_and_pyqt4
changeset 7192
a22eee00b052
parent 7186
ccd55666e9d2
child 7196
ab0a91b82b37
equal deleted inserted replaced
7191:960850ec284c 7192:a22eee00b052
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:
1528 user = getpass.getuser() 1512 user = getpass.getuser()
1529 1513
1530 if isWindowsPlatform(): 1514 if isWindowsPlatform():
1531 if not user: 1515 if not user:
1532 return win32_GetUserName() 1516 return win32_GetUserName()
1533 else:
1534 if sys.version_info[0] == 2:
1535 user = user.decode(locale.getpreferredencoding())
1536 1517
1537 return user 1518 return user
1538 1519
1539 1520
1540 def getRealName(): 1521 def getRealName():
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:

eric ide

mercurial