예제 #1
0
    def testMultiple(self):

        Container.bind('Config').toSingle(Config, loadYamlFilesThatExist(ScriptDir + '/ExampleConfig.yaml', ScriptDir + '/ExampleConfig2.yaml'))

        config = Container.resolve('Config')

        # From 1
        assertIsEqual(config.getString('receipt'), 'Oz-Ware Purchase Invoice')

        # From 2
        assertIsEqual(config.getString('thing1'), 'Foo')

        # Second one should override
        assertIsEqual(config.getString('foo2'), 'ipsum')

        assertIsEqual(config.getString('nest1', 'firstName'), 'Dorothy')

        # Test concatenating lists together
        assertIsEqual(config.getList('list1'), ['lorem', 'ipsum', 'asdf', 'joe', 'frank'])

        # Test concatenating dictionaries together
        assertIsEqual(config.getDictionary('dict1'), {'joe': 5, 'mary': 15, 'kate': 5, 'jim': 10})

        assertIsEqual(config.tryGetDictionary(None, 'asdfasdfasdf'), None)
        assertIsEqual(config.tryGetDictionary({ 5: 1 }, 'asdfasdfasdf'), { 5: 1 })

        assertIsEqual(config.tryGetList(None, 'asdfasdfasdf'), None)
        assertIsEqual(config.tryGetList([1, 2], 'asdfasdfasdf'), [1, 2])

        assertIsEqual(config.tryGetBool(False, 'zxvzasdfasdfasdf'), False)
        assertIsEqual(config.tryGetBool(True, 'zxvzasdfasdfasdf'), True)

        assertIsEqual(config.tryGetString('asdf', 'zxvzasdfasdfasdf'), 'asdf')

        assertIsEqual(config.tryGetInt(5, 'zxvzasdfasdfasdf'), 5)
예제 #2
0
    def testSpecialChars(self):
        Container.bind('Config').toSingle(Config, loadYamlFilesThatExist(ScriptDir + '/ExampleConfig.yaml', ScriptDir + '/ExampleConfig2.yaml'))

        config = Container.resolve('Config')

        assertIsEqual(config.tryGetString(None, 'foo4'), 'asdf')

        assertIsEqual(config.tryGetString(None, 'foo5'), 'zxcv')

        assertIsEqual(config.tryGetString(None, 'foo6'), 'asdf')
        assertIsEqual(config.tryGetString(None, 'foo7'), 'zxcv')
예제 #3
0
    def testSimple(self):
        yamlPath = ScriptDir + '/ExampleConfig.yaml'

        Container.bind('Config').toSingle(Config, loadYamlFilesThatExist(yamlPath))

        config = Container.resolve('Config')

        assertIsEqual(config.getString('date'), '2012-08-06')
        assertIsEqual(config.getString('receipt'), 'Oz-Ware Purchase Invoice')

        assertIsEqual(config.getList('places'), ['New Jersey', 'New York'])
        assertRaisesAny(lambda: config.getString('places'))
        assertRaisesAny(lambda: config.getDictionary('places'))

        assertIsEqual(config.getDictionary('customer'),
          {'first_name': 'Dorothy', 'family_name': 'Gale'})

        # Tests YAML references
        assertIsEqual(config.getString('foo1'), config.getString('receipt'))
예제 #4
0
def installBindings(mainConfigPath = None):

    projenyDir = getProjenyDir()
    projenyConfigPath = os.path.join(projenyDir, ConfigFileName)

    # Put the standard config first so it can be over-ridden by user settings
    configPaths = [projenyConfigPath]

    if mainConfigPath:
        assertThat(os.path.isfile(mainConfigPath), 'Could not find file at "{0}"', mainConfigPath)
        configPaths += [mainConfigPath]

    configPaths += getExtraUserConfigPaths()

    Container.bind('Config').toSingle(Config, loadYamlFilesThatExist(*configPaths))

    initialVars = { 'ProjenyDir': projenyDir, }

    if mainConfigPath:
        initialVars['ConfigDir'] = os.path.dirname(mainConfigPath)

    if not MiscUtil.isRunningAsExe():
        initialVars['PythonPluginDir'] = getPluginDirPath()

    Container.bind('VarManager').toSingle(VarManager, initialVars)
    Container.bind('SystemHelper').toSingle(SystemHelper)
    Container.bind('Logger').toSingle(Logger)
    Container.bind('UnityHelper').toSingle(UnityHelper)
    Container.bind('ScriptRunner').toSingle(ScriptRunner)
    Container.bind('PackageManager').toSingle(PackageManager)
    Container.bind('ProcessRunner').toSingle(ProcessRunner)
    Container.bind('JunctionHelper').toSingle(JunctionHelper)
    Container.bind('VisualStudioSolutionGenerator').toSingle(VisualStudioSolutionGenerator)
    Container.bind('VisualStudioHelper').toSingle(VisualStudioHelper)
    Container.bind('ProjectSchemaLoader').toSingle(ProjectSchemaLoader)
    Container.bind('CommonSettings').toSingle(CommonSettings)
    Container.bind('UnityPackageExtractor').toSingle(UnityPackageExtractor)
    Container.bind('ZipHelper').toSingle(ZipHelper)
    Container.bind('UnityPackageAnalyzer').toSingle(UnityPackageAnalyzer)

    Container.bind('ReleaseSourceManager').toSingle(ReleaseSourceManager)
예제 #5
0
    def loadSchema(self, name, platform):
        schemaPath = self._varMgr.expandPath(
            '[UnityProjectsDir]/{0}/{1}'.format(name, ProjectConfigFileName))
        schemaPathUser = self._varMgr.expandPath(
            '[UnityProjectsDir]/{0}/{1}'.format(name,
                                                ProjectUserConfigFileName))
        schemaPathGlobal = self._varMgr.expandPath(
            '[UnityProjectsDir]/{0}'.format(ProjectConfigFileName))
        schemaPathUserGlobal = self._varMgr.expandPath(
            '[UnityProjectsDir]/{0}'.format(ProjectUserConfigFileName))

        self._log.debug('Loading schema at path "{0}"'.format(schemaPath))
        config = Config(
            loadYamlFilesThatExist(schemaPath, schemaPathUser,
                                   schemaPathGlobal, schemaPathUserGlobal))

        pluginDependencies = config.tryGetList([], 'PluginsFolder')
        scriptsDependencies = config.tryGetList([], 'AssetsFolder')
        customProjects = config.tryGetList([], 'SolutionProjects')
        customFolders = config.tryGetDictionary({}, 'SolutionFolders')
        prebuiltProjects = config.tryGetList([], 'Prebuilt')

        # Remove duplicates
        scriptsDependencies = list(set(scriptsDependencies))
        pluginDependencies = list(set(pluginDependencies))

        for packageName in pluginDependencies:
            assertThat(
                not packageName in scriptsDependencies,
                "Found package '{0}' in both scripts and plugins.  Must be in only one or the other"
                .format(packageName))

        allDependencies = pluginDependencies + scriptsDependencies

        packageMap = {}

        # Resolve all dependencies for each package
        # by default, put any dependencies that are not declared explicitly into the plugins folder
        for packageName in allDependencies:

            configPath = self._varMgr.expandPath(
                '[UnityPackagesDir]/{0}/ProjenyPackage.yaml'.format(
                    packageName))

            if os.path.exists(configPath):
                packageConfig = Config(loadYamlFilesThatExist(configPath))
            else:
                packageConfig = Config([])

            createCustomVsProject = self._checkCustomProjectMatch(
                packageName, customProjects)

            isPluginsDir = packageName in pluginDependencies

            if isPluginsDir:
                assertThat(not packageName in scriptsDependencies)
            else:
                assertThat(packageName in scriptsDependencies)

            if packageConfig.tryGetBool(False, 'ForceAssetsDirectory'):
                isPluginsDir = False

            explicitDependencies = packageConfig.tryGetList([], 'Dependencies')

            forcePluginsDir = packageConfig.tryGetBool(
                False, 'ForcePluginsDirectory')

            assertThat(not packageName in packageMap)
            packageMap[packageName] = PackageInfo(isPluginsDir, packageName,
                                                  packageConfig,
                                                  createCustomVsProject,
                                                  explicitDependencies,
                                                  forcePluginsDir)

            for dependName in explicitDependencies:
                if not dependName in allDependencies:
                    pluginDependencies.append(dependName)
                    # Yes, python is ok with changing allDependencies even while iterating over it
                    allDependencies.append(dependName)

            for dependName in packageConfig.tryGetList([], 'Extras'):
                if not dependName in allDependencies:
                    if isPluginsDir:
                        pluginDependencies.append(dependName)
                    else:
                        scriptsDependencies.append(dependName)
                    # Yes, python is ok with changing allDependencies even while iterating over it
                    allDependencies.append(dependName)

        self._removePlatformSpecificPackages(packageMap, platform)

        self._printDependencyTree(packageMap)

        self._fillOutDependencies(packageMap)

        for customProj in customProjects:
            assertThat(
                customProj.startswith('/') or customProj in allDependencies,
                'Given project "{0}" in schema is not included in either "scripts" or "plugins"'
                .format(customProj))

        self._addPrebuiltProjectsFromPackages(packageMap, prebuiltProjects)

        self._log.info('Found {0} packages in total for given schema'.format(
            len(allDependencies)))

        # In Unity, the plugins folder can not have any dependencies on anything in the scripts folder
        # So if dependencies exist then just automatically move those packages to the scripts folder
        self._ensurePluginPackagesDoNotHaveDependenciesInAssets(packageMap)

        self._ensurePackagesThatAreNotProjectsDoNotHaveProjectDependencies(
            packageMap)

        projectsDir = self._varMgr.expandPath('[UnityProjectsDir]')
        prebuiltProjectPaths = [
            os.path.normpath(os.path.join(projectsDir, x))
            for x in prebuiltProjects
        ]

        for info in packageMap.values():
            if info.forcePluginsDir and not info.isPluginDir:
                assertThat(
                    False, "Package '{0}' must be in plugins directory".format(
                        info.name))

        return ProjectSchema(name, packageMap, customFolders,
                             prebuiltProjectPaths)
예제 #6
0
    def loadSchema(self, name, platform):
        schemaPath = self._varMgr.expandPath('[UnityProjectsDir]/{0}/{1}'.format(name, ProjectConfigFileName))
        schemaPathUser = self._varMgr.expandPath('[UnityProjectsDir]/{0}/{1}'.format(name, ProjectUserConfigFileName))
        schemaPathGlobal = self._varMgr.expandPath('[UnityProjectsDir]/{0}'.format(ProjectConfigFileName))
        schemaPathUserGlobal = self._varMgr.expandPath('[UnityProjectsDir]/{0}'.format(ProjectUserConfigFileName))

        self._log.debug('Loading schema at path "{0}"'.format(schemaPath))
        config = Config(loadYamlFilesThatExist(schemaPath, schemaPathUser, schemaPathGlobal, schemaPathUserGlobal))

        pluginDependencies = config.tryGetList([], 'PluginsFolder')
        scriptsDependencies = config.tryGetList([], 'AssetsFolder')
        customProjects = config.tryGetList([], 'SolutionProjects')
        customFolders = config.tryGetDictionary({}, 'SolutionFolders')
        prebuiltProjects = config.tryGetList([], 'Prebuilt')

        # Remove duplicates
        scriptsDependencies = list(set(scriptsDependencies))
        pluginDependencies = list(set(pluginDependencies))

        for packageName in pluginDependencies:
            assertThat(not packageName in scriptsDependencies, "Found package '{0}' in both scripts and plugins.  Must be in only one or the other".format(packageName))

        allDependencies = pluginDependencies + scriptsDependencies

        packageMap = {}

        # Resolve all dependencies for each package
        # by default, put any dependencies that are not declared explicitly into the plugins folder
        for packageName in allDependencies:

            configPath = self._varMgr.expandPath('[UnityPackagesDir]/{0}/ProjenyPackage.yaml'.format(packageName))

            if os.path.exists(configPath):
                packageConfig = Config(loadYamlFilesThatExist(configPath))
            else:
                packageConfig = Config([])

            createCustomVsProject = self._checkCustomProjectMatch(packageName, customProjects)

            isPluginsDir = packageName in pluginDependencies

            if isPluginsDir:
                assertThat(not packageName in scriptsDependencies)
            else:
                assertThat(packageName in scriptsDependencies)

            if packageConfig.tryGetBool(False, 'ForceAssetsDirectory'):
                isPluginsDir = False

            explicitDependencies = packageConfig.tryGetList([], 'Dependencies')

            forcePluginsDir = packageConfig.tryGetBool(False, 'ForcePluginsDirectory')

            assertThat(not packageName in packageMap)
            packageMap[packageName] = PackageInfo(isPluginsDir, packageName, packageConfig, createCustomVsProject, explicitDependencies, forcePluginsDir)

            for dependName in explicitDependencies:
                if not dependName in allDependencies:
                    pluginDependencies.append(dependName)
                    # Yes, python is ok with changing allDependencies even while iterating over it
                    allDependencies.append(dependName)

            for dependName in packageConfig.tryGetList([], 'Extras'):
                if not dependName in allDependencies:
                    if isPluginsDir:
                        pluginDependencies.append(dependName)
                    else:
                        scriptsDependencies.append(dependName)
                    # Yes, python is ok with changing allDependencies even while iterating over it
                    allDependencies.append(dependName)

        self._removePlatformSpecificPackages(packageMap, platform)

        self._printDependencyTree(packageMap)

        self._fillOutDependencies(packageMap)

        for customProj in customProjects:
            assertThat(customProj.startswith('/') or customProj in allDependencies, 'Given project "{0}" in schema is not included in either "scripts" or "plugins"'.format(customProj))

        self._addPrebuiltProjectsFromPackages(packageMap, prebuiltProjects)

        self._log.info('Found {0} packages in total for given schema'.format(len(allDependencies)))

        # In Unity, the plugins folder can not have any dependencies on anything in the scripts folder
        # So if dependencies exist then just automatically move those packages to the scripts folder
        self._ensurePluginPackagesDoNotHaveDependenciesInAssets(packageMap)

        self._ensurePackagesThatAreNotProjectsDoNotHaveProjectDependencies(packageMap)

        projectsDir = self._varMgr.expandPath('[UnityProjectsDir]')
        prebuiltProjectPaths = [os.path.normpath(os.path.join(projectsDir, x)) for x in prebuiltProjects]

        for info in packageMap.values():
            if info.forcePluginsDir and not info.isPluginDir:
                assertThat(False, "Package '{0}' must be in plugins directory".format(info.name))

        return ProjectSchema(name, packageMap, customFolders, prebuiltProjectPaths)