def createProject(self, session, requirements): path = os.path.join(tempfile.TemporaryDirectory().name, "myproject") os.makedirs(path) def createFolders(): os.makedirs(os.path.join(path, "source")) os.makedirs(os.path.join(os.path.join(path, "source"), "class")) os.makedirs(os.path.join(os.path.join(path, "source"), "asset")) os.makedirs(os.path.join(os.path.join(path, "source"), "translation")) def createSampleClasses(): self.writeFile(os.path.join(path, "source"), "index.html", """<html></html>""") self.writeFile(os.path.join(os.path.join(path, "source"), "class"), "Main.js", ";") def createSampleAssets(): self.writeFile(os.path.join(os.path.join(path, "source"), "asset"), "main.css", """html{}""") def createSampleTranslations(): self.writeFile(os.path.join(os.path.join(path, "source"), "translation"), "de.po", " ") createFolders() self.createjpyaml(path, requirements) createSampleClasses() createSampleAssets() createSampleTranslations() os.chdir(path) return Project.getProjectFromPath(path, session)
def getVirtualProject(self): """ Returns the virtual project for this application. The project offers storage for dynamically created JavaScript classes and other files. Storage is kept intact between different Jasy sessions. """ # Create only once per session if self.__virtualProject: return self.__virtualProject # Place virtual project in application's ".jasy" folder path = os.path.abspath(os.path.join(".jasy", "virtual")) # Set package to empty string to allow for all kind of namespaces in this virtual project jasy.core.File.write(os.path.join(path, "jasyproject.yaml"), 'name: virtual\npackage: ""\n') # Generate project instance from path, store and return project = Project.getProjectFromPath(path, self) self.__virtualProject = project self.__projects.append(project) return project
def createCaseTwo(self): #application path = os.path.join(tempfile.TemporaryDirectory().name, "myproject") os.makedirs(path) def createFolders(): os.makedirs(os.path.join(path, "source")) os.makedirs(os.path.join(os.path.join(path, "source"), "class")) os.makedirs(os.path.join(os.path.join(path, "source"), "asset")) os.makedirs( os.path.join(os.path.join(path, "source"), "translation")) def createSampleClasses(): self.writeFile(os.path.join(path, "source"), "index.html", """<html></html>""") self.writeFile(os.path.join(os.path.join(path, "source"), "class"), "Main.js", ";") def createSampleAssets(): self.writeFile(os.path.join(os.path.join(path, "source"), "asset"), "main.css", """html{}""") def createSampleTranslations(): self.writeFile( os.path.join(os.path.join(path, "source"), "translation"), "de.po", " ") createFolders() self.createjpyaml(path) createSampleClasses() createSampleAssets() createSampleTranslations() return Project.getProjectFromPath(path)
def createCaseTwo(self): # application path = os.path.join(tempfile.TemporaryDirectory().name, "myproject") os.makedirs(path) def createFolders(): os.makedirs(os.path.join(path, "source")) os.makedirs(os.path.join(os.path.join(path, "source"), "class")) os.makedirs(os.path.join(os.path.join(path, "source"), "asset")) os.makedirs(os.path.join(os.path.join(path, "source"), "translation")) def createSampleScripts(): self.writeFile(os.path.join(path, "source"), "index.html", """<html></html>""") self.writeFile(os.path.join(os.path.join(path, "source"), "class"), "Main.js", ";") def createSampleAssets(): self.writeFile(os.path.join(os.path.join(path, "source"), "asset"), "main.css", """html{}""") def createSampleTranslations(): self.writeFile(os.path.join(os.path.join(path, "source"), "translation"), "de.po", " ") createFolders() self.createjpyaml(path) createSampleScripts() createSampleAssets() createSampleTranslations() return Project.getProjectFromPath(path, Session.Session())
def getCurrentLocaleProject(self, update=False): """ Returns a locale project for the currently configured locale. Returns None if locale is not set to a valid value. """ locale = self.getCurrentLocale() if not locale: return None path = os.path.abspath(os.path.join(".jasy", "locale", locale)) if not os.path.exists(path) or update: Locale.LocaleParser(locale).export(path) return Project.getProjectFromPath(path, self.__session)
def getCurrentLocaleProject(self, update=False): """ Returns a locale project for the currently configured locale. Returns None if locale is not set to a valid value. """ locale = self.getCurrentLocale() if not locale: return None path = os.path.abspath(os.path.join(".jasy", "locale", locale)) if not os.path.exists(path) or update: Locale.LocaleParser(locale).export(path) return Project.getProjectFromPath(path, self.__session)
def createProject(self, requirements, onlyFileCreation=False): global globProject globProject = tempfile.TemporaryDirectory() path = os.path.join(globProject.name, "myproject") os.makedirs(path) def createFolders(): os.makedirs(os.path.join(path, "source")) os.makedirs(os.path.join(os.path.join(path, "source"), "class")) os.makedirs(os.path.join(os.path.join(path, "source"), "asset")) os.makedirs( os.path.join(os.path.join(path, "source"), "translation")) def createSampleClasses(): self.writeFile(os.path.join(path, "source"), "index.html", """<html></html>""") self.writeFile(os.path.join(os.path.join(path, "source"), "class"), "Main.js", ";") def createSampleAssets(): self.writeFile(os.path.join(os.path.join(path, "source"), "asset"), "main.css", """html{}""") def createSampleTranslations(): self.writeFile( os.path.join(os.path.join(path, "source"), "translation"), "de.po", " ") createFolders() self.createjpyaml(path, requirements) createSampleClasses() createSampleAssets() createSampleTranslations() os.chdir(path) if onlyFileCreation: return path return Project.getProjectFromPath(path)
def init(self, autoInitialize=True, updateRepositories=True, scriptEnvironment=None): """ Initialize the actual session with projects. :param autoInitialize: Whether the projects should be automatically added when the current folder contains a valid Jasy project. :param updateRepositories: Whether to update repositories of all project dependencies. :param scriptEnvironment: API object as being used for loadLibrary to add Python features offered by projects. :param commandEnvironment: API object as being used for loadCommands to add Python features for any item nodes. """ self.__scriptEnvironment = scriptEnvironment self.__updateRepositories = updateRepositories if autoInitialize and Config.findConfig("jasyproject"): Console.info("Initializing session...") Console.indent() try: self.addProject(Project.getProjectFromPath(".", self)) except UserError as err: Console.outdent(True) Console.error(err) raise UserError("Critical: Could not initialize session!") self.getVirtualProject() Console.debug("Active projects (%s):", len(self.__projects)) Console.indent() for project in self.__projects: if project.version: Console.debug("%s @ %s", Console.colorize(project.getName(), "bold"), Console.colorize(project.version, "magenta")) else: Console.debug(Console.colorize(project.getName(), "bold")) Console.outdent() Console.outdent()
def createCaseThree(self): #src path = os.path.join(tempfile.TemporaryDirectory().name, "myproject") os.makedirs(path) def createFolders(): os.makedirs(os.path.join(path, "src")) def createSampleClasses(): self.writeFile(os.path.join(path, "src"), "index.html", """<html></html>""") self.writeFile(os.path.join(path, "src"), "Main.js", ";") def createSampleAssets(): self.writeFile(os.path.join(path, "src"), "main.css", """html{}""") createFolders() self.createjpyaml(path) createSampleClasses() createSampleAssets() return Project.getProjectFromPath(path)
def createCaseThree(self): # src path = os.path.join(tempfile.TemporaryDirectory().name, "myproject") os.makedirs(path) def createFolders(): os.makedirs(os.path.join(path, "src")) def createSampleScripts(): self.writeFile(os.path.join(path, "src"), "index.html", """<html></html>""") self.writeFile(os.path.join(path, "src"), "Main.js", ";") def createSampleAssets(): self.writeFile(os.path.join(path, "src"), "main.css", """html{}""") createFolders() self.createjpyaml(path) createSampleScripts() createSampleAssets() return Project.getProjectFromPath(path, Session.Session())
def createCaseOne(self): #manual path = os.path.join(tempfile.TemporaryDirectory().name, "myproject") os.makedirs(path) def createFolders(): os.makedirs(os.path.join(path, "man")) def createSampleClasses(): self.writeFile(os.path.join(path, "man"), "index.html", """<html></html>""") self.writeFile(os.path.join(path, "man"), "Main.js", ";") self.writeFile(os.path.join(path, "man"), "Add.js", ";") def createSampleAssets(): self.writeFile(os.path.join(path, "man"), "main.css", """html{}""") createFolders() self.createjpyaml_withContent(path) createSampleClasses() createSampleAssets() return Project.getProjectFromPath(path)
def createCaseOne(self): # manual path = os.path.join(tempfile.TemporaryDirectory().name, "myproject") os.makedirs(path) def createFolders(): os.makedirs(os.path.join(path, "man")) def createSampleScripts(): self.writeFile(os.path.join(path, "man"), "index.html", """<html></html>""") self.writeFile(os.path.join(path, "man"), "Main.js", ";") self.writeFile(os.path.join(path, "man"), "Add.js", ";") def createSampleAssets(): self.writeFile(os.path.join(path, "man"), "main.css", """html{}""") createFolders() self.createjpyaml_withContent(path) createSampleScripts() createSampleAssets() return Project.getProjectFromPath(path, Session.Session())