예제 #1
0
def createProject():
    """
        Turns a software package into PyCharm project.

        For this some files within ".idea" are created.
    """
    BuildSystemTools.requireTopLevelDir()

    configDir = '.idea'
    logging.info('creating config in %s', configDir)

    projectRoot = ProjectProperties.detectTopLevelDir()

    if projectRoot is None:
        raise RuntimeError('unable to detect top-level-directory of package')

    packageName = ProjectProperties.getPackageName(projectRoot)
    packageVersion = ProjectProperties.getPackageVersion(projectRoot)

    Any.requireIsTextNonEmpty(packageName)
    Any.requireIsTextNonEmpty(packageVersion)

    template = PackageCreator_JetBrains_PyCharm_Config(packageName,
                                                       packageVersion,
                                                       outputDir=configDir)
    template.run()
예제 #2
0
def getPixmap(name):
    """
        Returns a QPixmap for the provided 'name', which used to be
        the short form of a filename (without path and file extension).
    """
    Any.requireIsTextNonEmpty(name)

    global _pixmapCache
    global _pixmapDir

    try:
        # lookup cache
        return _pixmapCache[name]

    except KeyError:

        if _pixmapDir is None:
            scriptDir = os.path.dirname(sys.argv[0])
            topLevelDir = ProjectProperties.detectTopLevelDir(scriptDir)

            _pixmapDir = os.path.join(topLevelDir, 'share/pixmaps')
            Any.requireIsDir(_pixmapDir)

        filePath = os.path.join(_pixmapDir, name + '.png')
        Any.requireIsFile(filePath)
        logging.debug('using pixmap: %s', filePath)

        # load pixmap and put in cache
        pixmap = QPixmap(filePath)
        _pixmapCache[pixmap] = pixmap

        return pixmap
예제 #3
0
def createProject():
    """
        Turns a software package into CLion project.

        For this some files within ".idea" are created.
    """
    BuildSystemTools.requireTopLevelDir()

    configDir = '.idea'
    logging.info('creating config in %s', configDir)

    projectRoot = ProjectProperties.detectTopLevelDir()
    packageName = ProjectProperties.getPackageName(projectRoot)
    packageVersion = ProjectProperties.getPackageVersion(projectRoot)

    Any.requireIsTextNonEmpty(packageName)
    Any.requireIsTextNonEmpty(packageVersion)

    template = PackageCreator_JetBrains_CLion_Config(packageName,
                                                     packageVersion,
                                                     outputDir=configDir)
    template.run()
예제 #4
0
    def __init__(self, projectRoot=None, pkgInfoContent=None):

        from ToolBOSCore.SoftwareQuality.CheckRoutine import sqLevelDefault

        if not projectRoot:
            projectRoot = ProjectProperties.detectTopLevelDir()

        if not projectRoot:
            raise AssertionError('unknown project root location')

        Any.requireIsDir(projectRoot)

        # general meta-info
        self.canonicalPath = None
        self.cmakelistsContent = None
        self.hasCMakeLists = None
        self.installRoot = None
        self.isDeprecated = None
        self.packageCategory = None
        self.packageName = None
        self.packageVersion = None  # e.g. "2.0"
        self.packageVersionRaw = None  # e.g. "2.0-rc3" (corresponds to dir.name)
        self.patchlevel = None  # e.g. 42, may correspond to SVN rev.
        self.topLevelDir = None
        self.versionTokens = None  # e.g. ( "2", "0", "123" )

        # dependencies
        self.buildDependencies = []  # direct build-deps
        self.buildDependsArch = {}
        self.dependencies = []  # direct deps
        self.dependsArch = {}
        self.inheritedProjects = []  # deps. + recommend. (used in BashSrc)
        self.recommendations = []
        self.suggestions = []

        # values extracted from install/user{Install,Src}.php / pkgInfo.py
        self.pkgInfoContent = pkgInfoContent
        self.docTool = None
        self.install = []
        self.installHooks = {}
        self.installMatching = []
        self.installSymlinks = []
        self.installGroup = None
        self.installUmask = None
        self.installMode = 'incremental'
        self.linkAllLibraries = False
        self.usePatchlevels = False
        self.userSrcContent = None
        self.userSrcEnv = ()
        self.userSrcAlias = ()
        self.userSrcBashCode = ()
        self.userSrcCmdCode = ()
        self.sqLevel = sqLevelDefault
        self.sqOptInRules = []
        self.sqOptOutRules = []
        self.sqOptInDirs = []
        self.sqOptOutDirs = []
        self.sqOptInFiles = []
        self.sqOptOutFiles = []
        self.sqCheckExe = None
        self.sqComments = {}
        self.useClang = None

        # revision control system
        self.gitBranch = None
        self.gitBranchForCIA = None
        self.gitFound = None
        self.gitCommitIdLong = None
        self.gitCommitIdShort = None
        self.gitOrigin = None
        self.gitOriginForCIA = None
        self.gitRelPath = None
        self.gitRepositoryRoot = None
        self.svnFound = None
        self.svnRelPath = None
        self.svnRevision = None
        self.svnRepositoryURL = None
        self.svnRepositoryRoot = None
        self.svnRevisionForCIA = None
        self.vcsBranch = None
        self.vcsFound = None
        self.vcsURL = None
        self.vcsRelPath = None
        self.vcsRevision = None
        self.vcsRoot = None

        # current user (likely the maintainer when working on source tree)
        self.userAccount = None
        self.userName = None

        # maintainer (filesystem owner when accessing SIT packages)
        self.maintainerAccount = None
        self.maintainerName = None

        cmakePath = os.path.join(projectRoot, 'CMakeLists.txt')
        self.hasCMakeLists = os.path.exists(cmakePath)

        self.topLevelDir = projectRoot
        self.packageName = ProjectProperties.getPackageName(self.topLevelDir)
        self.packageVersion = ProjectProperties.getPackageVersion(
            self.topLevelDir, False)
        self.packageVersionRaw = ProjectProperties.getPackageVersion(
            self.topLevelDir, True)
        self.versionTokens = ProjectProperties.splitVersion(
            self.packageVersionRaw)

        Any.requireIsTextNonEmpty(self.packageName)
        Any.requireIsTextNonEmpty(self.packageVersion)

        # compute typical directory names (may not be present!)
        hostPlatform = Platforms.getHostPlatform()
        Any.requireIsTextNonEmpty(hostPlatform)

        self.binDir = os.path.join(self.topLevelDir, 'bin')
        self.binDirArch = os.path.join(self.topLevelDir, 'bin', hostPlatform)
        self.examplesDir = os.path.join(self.topLevelDir, 'examples')
        self.examplesDirArch = os.path.join(self.topLevelDir, 'examples',
                                            hostPlatform)
        self.includeDir = os.path.join(self.topLevelDir, 'include')
        self.installDir = os.path.join(self.topLevelDir, 'install')
        self.libDir = os.path.join(self.topLevelDir, 'lib')
        self.libDirArch = os.path.join(self.topLevelDir, 'lib', hostPlatform)
        self.srcDir = os.path.join(self.topLevelDir, 'src')
        self.testDir = os.path.join(self.topLevelDir, 'test')
        self.testDirArch = os.path.join(self.topLevelDir, 'test', hostPlatform)

        if self.hasCMakeLists:
            # source tree, C/C++ package
            self.cmakelistsContent = FastScript.getFileContent(cmakePath)

            if self.cmakelistsContent:
                self.packageCategory = CMakeLists.getCategory(
                    self.cmakelistsContent)
            else:
                logging.debug('skipping empty %s', cmakePath)

        else:
            # source tree w/o CMakeLists.txt, or package installed in SIT
            self.cmakelistsContent = None

            try:
                self.packageCategory = ProjectProperties.getPackageCategoryFromPath(
                    projectRoot)
            except AssertionError:
                raise AssertionError('unable to detect package category')

        if self.packageCategory:
            self.canonicalPath = os.path.join(self.packageCategory,
                                              self.packageName,
                                              self.packageVersion)

        self._retrieveCurrentUser()

        # Any.requireIsTextNonEmpty( self.maintainerAccount ) # might be empty
        # Any.requireIsTextNonEmpty( self.maintainerName )    # might be empty
        Any.requireIsTextNonEmpty(self.packageName)
        Any.requireIsTextNonEmpty(self.packageVersion)
        Any.requireIsTextNonEmpty(self.packageVersionRaw)
        Any.requireIsTextNonEmpty(self.topLevelDir)
        Any.requireIsTextNonEmpty(self.userAccount)
        Any.requireIsTextNonEmpty(self.userName)