Esempio n. 1
0
def getPackageInfo(packageName):
    """
    获取包信息

    Args:
        packageName(str): 包名

    Returns:
        包信息
    """
    packageInfo = None
    packagesDir = pathmanager.getEspmPath(pathmanager.PATH_PACKAGES)
    names = os.listdir(packagesDir)
    for name in names:
        if name == packageName:
            espmFlie = os.path.join(pathmanager.getPackagePath(name),
                                    "espm.json")
            if os.path.isfile(espmFlie):
                with open(espmFlie, 'r') as f:
                    packageInfo = json.loads(f.read())

            package = search(packageName)
            if packageInfo == None:
                packageInfo = package
            elif not 'src' in packageInfo or not 'inc' in packageInfo:
                if not 'src' in packageInfo and 'src' in package:
                    packageInfo['src'] = package['src']
                if not 'inc' in packageInfo and 'inc' in package:
                    packageInfo['inc'] = package['inc']
                if not 'version' in packageInfo:
                    packageInfo['version'] = "unknow"

    return packageInfo
Esempio n. 2
0
def uninstall(packageName):
    """
    删除包

    Args:
        packageName(str): 包名

    Returns:
        bool 删除是否成功
    """
    try:
        logging.debug("delete dir: %s" %
                      (pathmanager.getPackagePath(packageName)))
        shutil.rmtree(pathmanager.getPackagePath(packageName))
        return True
    except:
        return False
Esempio n. 3
0
def install(packageName, source=None):
    """
    安装包

    Args:
        packageName(str): 包名
        source(str): 指定源

    Returns:
        bool 安装是否成功
    """
    package = search(packageName, source)
    if package != None:
        if package['type'] == 'git':
            return clonePackageFromGit(package['url'],
                                       pathmanager.getPackagePath(packageName))
        if package['type'] == 'svn':
            return clonePackageFromSvn(package['url'],
                                       pathmanager.getPackagePath(packageName))
Esempio n. 4
0
def getIncs(packageName):
    """
    获取包头文件目录列表

    Args:
        packageName(str): 包名

    Returns:
        list: 头文件目录列表
    """
    packageInfo = getPackageInfo(packageName)
    incs = []
    if packageInfo != None:
        if 'inc' in packageInfo:
            for item in packageInfo['inc']:
                path = os.path.join(pathmanager.getPackagePath(packageName),
                                    item)
                if os.path.isdir(path):
                    incs.append(path)
    return incs
Esempio n. 5
0
def getSrcs(packageName):
    """
    获取包源文件列表

    Args:
        packageName(str): 包名

    Returns:
        list: 源文件列表
    """
    packageInfo = getPackageInfo(packageName)
    srcs = []
    if packageInfo != None:
        if 'src' in packageInfo:
            for item in packageInfo['src']:
                path = os.path.join(pathmanager.getPackagePath(packageName),
                                    item)
                if os.path.isdir(path):
                    for src in os.listdir(path):
                        if src.endswith(".c"):
                            srcs.append(os.path.join(path, src))
                elif os.path.isfile(item) and item.endswith(".c"):
                    srcs.append(item)
    return srcs