# Classes from jasy.core.OutputManager import OutputManager from jasy.core.FileManager import FileManager from jasy.asset.Manager import AssetManager from jasy.asset.SpritePacker import SpritePacker from jasy.js.Resolver import Resolver from jasy.js.api.Writer import ApiWriter from jasy.http.Server import Server # Commands (be careful with these, prefer modules and classes) from jasy.env.Task import task # Create config object import jasy.core.Config as Config config = Config.Config() config.__doc__ = "Auto initialized config object based on project's jasyscript.yaml/json" config.loadValues("jasyscript", optional=True) @task def about(): """Print outs the Jasy about page""" import jasy jasy.info() from jasy.env.Task import getCommand Console.info("Command: %s", getCommand())
def test_config_object_setdata_withdot(self): config = Config.Config({'foo': {'yeah': 42}, 'one': 1}) config.set('foo.yeah', 1337) self.assertEqual(config.get('foo')['yeah'], 1337)
def test_config_object_getdata_withdot(self): config = Config.Config({'foo': {'yeah': 42}, 'one': 1}) self.assertEqual(config.get('foo.yeah'), 42)
def test_config_object_setdata(self): config = Config.Config({'two': 2, 'one': 1, 'ten': 10}) config.set('ten', 15) self.assertEqual(config.get('ten'), 15)
def test_config_object_hasdata(self): config = Config.Config({'two': 2, 'one': 1, 'ten': 10}) self.assertTrue(config.has('two'))
def __init__(self, path, config=None, version=None): """ Constructor call of the project. - First param is the path of the project relative to the current working directory. - Config can be read from jasyproject.json or using constructor parameter @config - Parent is used for structural debug messages (dependency trees) """ if not os.path.isdir(path): raise UserError("Invalid project path: %s" % path) # Only store and work with full path self.__path = os.path.abspath(os.path.expanduser(path)) # Store given params self.version = version # Intialize item registries self.classes = {} self.assets = {} self.docs = {} self.translations = {} # Load project configuration self.__config = Config.Config(config) self.__config.loadValues(os.path.join(self.__path, "jasyproject"), optional=True) # Initialize cache try: File.mkdir(os.path.join(self.__path, ".jasy")) self.__cache = jasy.core.Cache.Cache(self.__path, filename=".jasy/cache") except IOError as err: raise UserError( "Could not initialize project. Cache file in %s could not be initialized! %s" % (self.__path, err)) # Detect version changes if version is None: self.__modified = True else: cachedVersion = self.__cache.read("project[version]") self.__modified = cachedVersion != version self.__cache.store("project[version]", version) # Read name from manifest or use the basename of the project's path self.__name = self.__config.get("name", getProjectNameFromPath(self.__path)) # Read requires self.__requires = self.__config.get("requires", {}) # Defined whenever no package is defined and classes/assets are not stored in the toplevel structure. self.__package = self.__config.get( "package", self.__name if self.__config.has("name") else None) # Read fields (for injecting data into the project and build permutations) self.__fields = self.__config.get("fields", {}) # Read setup for running command pre-scan self.__setup = self.__config.get("setup")