def __init__(self, parent = None, 
              completionMode = QCompleter.PopupCompletion, 
              showHidden = False):
     """
     Constructor
     
     @param parent parent widget of the completer (QWidget)
     @keyparam completionMode completion mode of the 
         completer (QCompleter.CompletionMode)
     @keyparam showHidden flag indicating to show hidden entries as well (boolean)
     """
     QCompleter.__init__(self, parent)
     self.__model = QFileSystemModel(self)
     if showHidden:
         self.__model.setFilter(\
             QDir.Filters(QDir.Drives | QDir.AllDirs | QDir.Hidden))
     else:
         self.__model.setFilter(\
             QDir.Filters(QDir.Drives | QDir.AllDirs))
     self.setModel(self.__model)
     self.setCompletionMode(completionMode)
     if isWindowsPlatform():
         self.setCaseSensitivity(Qt.CaseInsensitive)
     if parent:
         parent.setCompleter(self)
Ejemplo n.º 2
0
def getPythonLibPath():
    """
    Function to determine the path to Python's library.
    
    @return path to the Python library (string)
    """
    pyFullVers = sys.version.split()[0]

    vl = re.findall("[0-9.]*", pyFullVers)[0].split(".")
    major = vl[0]
    minor = vl[1]

    pyVers = major + "." + minor
    pyVersNr = int(major) * 10 + int(minor)

    if isWindowsPlatform():
        libDir = sys.prefix + "\\Lib"
    else:
        try:
            syslib = sys.lib
        except AttributeError:
            syslib = "lib"
        libDir = sys.prefix + "/" + syslib + "/python" + pyVers
        
    return libDir
Ejemplo n.º 3
0
def checkBlacklistedVersions():
    """
    Module functions to check for blacklisted versions of the prerequisites.
    
    @return flag indicating good versions were found (boolean)
    """
    from install import BlackLists, PlatformsBlackLists
    
    # determine the platform dependent black list
    if isWindowsPlatform():
        PlatformBlackLists = PlatformsBlackLists["windows"]
    elif isLinuxPlatform():
        PlatformBlackLists = PlatformsBlackLists["linux"]
    else:
        PlatformBlackLists = PlatformsBlackLists["mac"]
    
    # check version of sip
    try:
        import sipconfig
        sipVersion = sipconfig.Configuration().sip_version_str
        # always assume, that snapshots are good
        if "snapshot" not in sipVersion:
            # check for blacklisted versions
            for vers in BlackLists["sip"] + PlatformBlackLists["sip"]:
                if vers == sipVersion:
                    print 'Sorry, sip version %s is not compatible with eric4.' % vers
                    print 'Please install another version.'
                    return False
    except ImportError:
        pass
    
    # check version of PyQt
    from PyQt4.QtCore import PYQT_VERSION_STR
    pyqtVersion = PYQT_VERSION_STR
    # always assume, that snapshots are good
    if "snapshot" not in pyqtVersion:
        # check for blacklisted versions
        for vers in BlackLists["PyQt4"] + PlatformBlackLists["PyQt4"]:
            if vers == pyqtVersion:
                print 'Sorry, PyQt4 version %s is not compatible with eric4.' % vers
                print 'Please install another version.'
                return False
    
    # check version of QScintilla
    from PyQt4.Qsci import QSCINTILLA_VERSION_STR
    scintillaVersion = QSCINTILLA_VERSION_STR
    # always assume, that snapshots are new enough
    if "snapshot" not in scintillaVersion:
        # check for blacklisted versions
        for vers in BlackLists["QScintilla2"] + PlatformBlackLists["QScintilla2"]:
            if vers == scintillaVersion:
                print 'Sorry, QScintilla2 version %s is not compatible with eric4.' % vers
                print 'Please install another version.'
                return False
    
    return True
Ejemplo n.º 4
0
def getUserName():
    """
    Function to get the user name.
    
    @return user name (string)
    """
    if isWindowsPlatform():
        return win32_GetUserName()
    else:
        return posix_GetUserName()
Ejemplo n.º 5
0
def hasEnvironmentEntry(key):
    """
    Module function to check, if the environment contains an entry.
    
    @param key key of the requested environment entry (string)
    @return flag indicating the presence of the requested entry (boolean)
    """
    filter = QRegExp("^%s[ \t]*=" % key)
    if isWindowsPlatform():
        filter.setCaseSensitivity(Qt.CaseInsensitive)
    
    entries = QProcess.systemEnvironment().filter(filter)
    return entries.count() > 0
Ejemplo n.º 6
0
def generatePySideToolPath(toolname):
    """
    Module function to generate the executable path for a PySide tool.
    
    @param toolname base name of the tool (string or QString)
    @return the PySide tool path with extension (string)
    """
    if isWindowsPlatform():
        if toolname == "pyside-uic":
            return os.path.join(sys.prefix, "Scripts", toolname + '.exe')
        else:
            return os.path.join(sys.prefix, "Lib", "site-packages", "PySide",
                                 toolname + ".exe")
    else:
        return toolname
Ejemplo n.º 7
0
def getConfigDir():
    """
    Module function to get the name of the directory storing the config data.
    
    @return directory name of the config dir (string)
    """
    if configDir is not None and os.path.exists(configDir):
        hp = configDir
    else:
        if isWindowsPlatform():
            cdn = "_eric4"
        else:
            cdn = ".eric4"
            
        hp = QDir.homePath()
        dn = QDir(hp)
        dn.mkdir(cdn)
        hp.append("/").append(cdn)
    return unicode(toNativeSeparators(hp))
Ejemplo n.º 8
0
def getEnvironmentEntry(key, default = None):
    """
    Module function to get an environment entry.
    
    @param key key of the requested environment entry (string)
    @param default value to be returned, if the environment doesn't contain
        the requested entry (string)
    @return the requested entry or the default value, if the entry wasn't 
        found (string or None)
    """
    filter = QRegExp("^%s[ \t]*=" % key)
    if isWindowsPlatform():
        filter.setCaseSensitivity(Qt.CaseInsensitive)
    
    entries = QProcess.systemEnvironment().filter(filter)
    if entries.count() == 0:
        return default
    
    # if there are multiple entries, just consider the first one
    ename, val = unicode(entries[0]).split("=", 1)
    return val.strip()