jasy.core package

Submodules

jasy.core.Base62 module

jasy.core.Base62.decode(str)[source]
jasy.core.Base62.decodeStringToArray(str)[source]
jasy.core.Base62.decodeToArrayOfBytes(arr)[source]
jasy.core.Base62.encode(str)[source]
jasy.core.Base62.encodeArrayOfBytes(arr)[source]
jasy.core.Base62.encodeArrayToString(arr)[source]

jasy.core.Cache module

class jasy.core.Cache.Cache(path, filename='jasycache', hashkeys=False)[source]

Bases: builtins.object

A cache class based on shelve feature of Python. Supports transient in-memory storage, too. Uses memory storage for caching requests to DB as well for improved performance. Uses keys for identification of entries like a normal hash table / dictionary.

clear()[source]

Clears the cache file(s)

close()[source]

Closes the internal storage database

open()[source]

Opens a cache file in the given path

read(key, timestamp=None, inMemory=True)[source]

Reads the given value from cache. Optionally support to check wether the value was stored after the given time to be valid (useful for comparing with file modification times).

store(key, value, timestamp=None, transient=False, inMemory=True)[source]

Stores the given value. Default timestamp goes to the current time. Can be modified to the time of an other files modification date etc. Transient enables in-memory cache for the given value

sync()[source]

Syncs the internal storage database

jasy.core.Config module

class jasy.core.Config.Config(data=None)[source]

Bases: builtins.object

Wrapper around YAML/JSON with easy to use import tools for using question files, command line arguments, etc.

ask(question, name, accept=None, required=True, default=None, force=False, parse=True)[source]

Asks the user for value for the given configuration field:

Parameters:
  • question (string) – Question to ask the user
  • name (string) – Name of field to store value in
  • accept (string) – Any of the supported types to validate for (see matchesType)
  • required (boolean) – Whether the field is required
  • default – Default value whenever user has given no value
debug()[source]

Prints data to the console

executeScript(fileName, autoDelete=True, optional=False, encoding='utf-8')[source]

Executes the given script for configuration proposes and deletes the file afterwards (by default). Returns True when the file was found and processed.

export()[source]

Returns a flat data structure of the internal data

get(name, default=None)[source]

Returns the value of the given field or None when field is not set

has(name)[source]

Returns whether there is a value for the given field name.

injectValues(parse=True, **argv)[source]

Injects a list of arguments into the configuration file, typically used for injecting command line arguments

loadValues(fileName, optional=False, encoding='utf-8')[source]

Imports the values of the given config file Returns True when the file was found and processed.

Note: Supports dotted names to store into sub trees Note: This method overrides keys when they are already defined!

readQuestions(fileName, force=False, autoDelete=True, optional=False, encoding='utf-8')[source]

Reads the given configuration file with questions and deletes the file afterwards (by default). Returns True when the file was found and processed.

set(name, value, accept=None, parse=False)[source]

Saves the given value under the given field

write(fileName, indent=2, encoding='utf-8')[source]

Uses config writer to write the configuration file to the application

jasy.core.Config.findConfig(fileName)[source]

Returns the name of a config file based on the given base file name (without extension). Returns either a filename which endswith .yaml, .json or None when no file was found.

jasy.core.Config.isConfigName(fileName, requiredBaseName=None)[source]
jasy.core.Config.loadConfig(fileName, encoding='utf-8')[source]

Loads the given configuration file (filename without extension) and returns the parsed object structure

jasy.core.Config.writeConfig(data, fileName, indent=2, encoding='utf-8')[source]

Writes the given data structure to the given file name. Based on the given extension a different file format is choosen. Currently use either .yaml or .json.

jasy.core.Console module

Centralized logging for complete Jasy environment.

jasy.core.Console.colorize(text, color='red')[source]

Uses to colorize the given text for output on Unix terminals

jasy.core.Console.header(title)[source]

Outputs the given title with prominent formatting

jasy.core.Console.error(text, *argv)[source]

Outputs an error message (visible by default)

jasy.core.Console.warn(text, *argv)[source]

Outputs an warning (visible by default)

jasy.core.Console.info(text, *argv)[source]

Outputs an info message (visible by default, disable via –quiet option)

jasy.core.Console.debug(text, *argv)[source]

Output a debug message (hidden by default, enable via –verbose option)

jasy.core.Console.indent()[source]

Increments global indenting level. Prepends spaces to the next logging messages until outdent() is called.

Should be called whenever leaving a structural logging section.

jasy.core.Console.outdent(all=False)[source]

Decrements global indenting level. Should be called whenever leaving a structural logging section.

jasy.core.Create module

jasy.core.Create.create(name='myproject', origin=None, originVersion=None, skeleton=None, destination=None, session=None, **argv)[source]

Creates a new project from a defined skeleton or an existing project’s root directory (only if there is a jasycreate config file).

Parameters:
  • name (string) – The name of the new created project
  • origin (string) – Path or git url to the base project
  • originVersion (string) – Version of the base project from wich will be created.
  • skeleton (string) – Name of a defined skeleton. None for creating from root
  • destination (string) – Destination path for the new created project
  • session (object) – An optional session to use as origin project
jasy.core.Create.getFirstSubFolder(start)[source]
jasy.core.Create.massFilePatcher(path, data)[source]

jasy.core.Doctor module

jasy.core.Doctor.doCompleteDoctor()[source]

Checks for uninstalled or too old versions of requirements and gives a complete output

jasy.core.Doctor.doInitializationDoctor()[source]

Checks for uninstalled or too old versions only of requirements and gives error output

jasy.core.File module

A module consisting of some often used file system actions in easy to use unix tradition.

jasy.core.File.cp(src, dst)[source]

Copies a file

jasy.core.File.cpdir(src, dst)[source]

Copies a directory

jasy.core.File.exists(name)[source]

Returns whether the given file or folder exists

jasy.core.File.mkdir(name)[source]

Creates directory (works recursively)

jasy.core.File.mv(src, dst)[source]

Moves files or directories

jasy.core.File.read(name, encoding='utf-8')[source]

Read the given file. Returns None when file could not be found/opended

jasy.core.File.rm(name)[source]

Removes the given file

jasy.core.File.rmdir(name)[source]

Removes a directory (works recursively)

jasy.core.File.sha1(fileOrPath, block_size=1048576)[source]

Returns a SHA 1 checksum (as hex digest) of the given file (handle)

jasy.core.File.syncfile(src, dst)[source]

Same as cp() but only do copying when source file is newer than target file

jasy.core.File.write(dst, content, encoding='utf-8')[source]

Writes the content to the destination file name

jasy.core.FileManager module

class jasy.core.FileManager.FileManager(profile=None)[source]

Bases: builtins.object

Summarizes utility methods for operations in filesystem.

copyDir(src, dst)[source]

Copies a directory to a destination directory. Merges the existing directory structure with the folder to copy.

copyFile(src, dst)[source]

Copy src file to dst file. Both should be filenames, not directories.

makeDir(dirname)[source]

Creates missing hierarchy levels for given directory

removeDir(dirname)[source]

Removes the given directory

removeFile(filename)[source]

Removes the given file

updateFile(src, dst)[source]

Same as copyFile() but only do copying when source file is newer than target file

writeFile(dst, content)[source]

Writes the content to the destination file name

jasy.core.FlagSet module

class jasy.core.FlagSet.FlagSet(*args)[source]

Bases: builtins.object

Configures an formatting object which can be used to compress classes afterwards. The optimization set is frozen after initialization which also generates the unique key based on the given formatting options.

disable(flag)[source]
enable(flag)[source]
getKey()[source]

Returns a unique key to identify this formatting set

has(key)[source]

Whether the given formatting is enabled.

jasy.core.Inspect module

jasy.core.Inspect.extractDoc(value, limit=80, indent=2)[source]
jasy.core.Inspect.extractType(value)[source]
jasy.core.Inspect.generateApi(api)[source]

Returns a stringified output for the given API set

jasy.core.Inspect.highlightArgs(value, inClassOrObject=False)[source]

jasy.core.Locale module

class jasy.core.Locale.LocaleParser(locale)[source]

Bases: builtins.object

Parses CLDR locales into JavaScript files

export(path)[source]

jasy.core.MetaData module

class jasy.core.MetaData.MetaData(tree)[source]

Bases: builtins.object

Data structure to hold all meta information.

A instance of this class is typically created by processing all meta data relevant tags of all doc comments in the given node structure.

Hint: Must be a clean data class without links to other systems for optiomal cachability using Pickle

assets
breaks
optionals
parse(node)[source]

The internal inspection routine to add relevant data from comments

requires

jasy.core.Options module

class jasy.core.Options.Options[source]

Bases: builtins.object

More flexible alternative to the standard python option parser module which solves the requirements to have arbirary tasks and custom parameters for each task.

add(name, accept=<class 'bool'>, value=None, short=None, help='')[source]
getTasks()[source]
parse(args)[source]
printOptions(indent=16)[source]

jasy.core.Permutation module

class jasy.core.Permutation.Permutation(combination)[source]

Bases: builtins.object

Object to store a single kind of permutation

filter(available)[source]

Returns a variant of that permutation which only holds values for the available keys.

get(key)[source]

Returns the value of the given key in the permutation

getChecksum()[source]

Returns the computed (SHA1) checksum based on the key of this permutation

getKey()[source]

Returns the computed key from this permutation

has(key)[source]

Whether the permutation holds a value for the given key

jasy.core.Permutation.getPermutation(combination)[source]

Small wrapper to omit double creation of identical permutations in filter() method As these instances don’t have any reference to session etc. they are actually cacheable globally.

jasy.core.Profile module

class jasy.core.Profile.Profile(session)[source]

Bases: builtins.object

Configuration object for the build profile of the current task

addCommand(name, func, resultType=None, globalName=False)[source]

Registers the given function as a new command

executeCommand(command, params=None)[source]

Executes the given command and returns the result

expandFileName(fileName)[source]

Replaces placeholders inside the given filename and returns the result. The placeholders are based on the current state of the session.

These are the currently supported placeholders:

  • {{locale}}: Name of current locale e.g. de_DE
  • {{permutation}}: SHA1 checksum of current permutation
  • {{id}}: SHA1 checksum based on permutation and repository branch/revision
exportData()[source]
getAssetManager()[source]
getAssetOutputFolder()[source]

Name of the folder inside the destination folder for storing used assets

getCompressionLevel()[source]
getCopyAssets()[source]
getCssOutputFolder()[source]

Name of the folder inside the destination folder for storing generated style sheets

getCurrentFormatting()[source]
getCurrentLocale()[source]

Returns the current locale as defined in current permutation

getCurrentLocaleProject(update=False)[source]

Returns a locale project for the currently configured locale. Returns None if locale is not set to a valid value.

getCurrentOptimization()[source]
getCurrentPermutation()[source]

Returns current permutation object (useful during looping through permutations via permutate()).

getCurrentTranslation()[source]
getDestinationPath()[source]

Relative or path of the destination folder

getDestinationUrl()[source]

The same as destination folder but from the URL/server perspective

getFieldSetupScripts()[source]
getFileManager()[source]
getFlag(name, fallback=None)[source]
getFormattingLevel()[source]
getHashAssets()[source]
getId()[source]
getJsOutputFolder()[source]

Name of the folder inside the destination folder for storing generated script files

getMatchingValues(matcher, transformer=None)[source]
getOutputFolder(type, fallback=None)[source]
getOutputFolders()[source]
getParts()[source]
getProjects()[source]

Returns all currently registered projects. Injects locale project when current permutation has configured a locale.

getSession()[source]
getSetupScripts()[source]

Returns a list of (virtual) classes which are relevant for initial setup.

getTemplateOutputFolder()[source]

Name of the folder inside the destination folder for storing compiled templates

getUseSource()[source]
getValue(key, fallback=None)[source]
getWorkingPath()[source]
permutate()[source]

Generator method for permutations for improving output capabilities

permutateField(name, values=None, detect=None, default=None)[source]

Adds the given key/value pair to the session for permutation usage.

It supports an optional test. A test is required as soon as there is more than one value available. The detection method and values are typically already defined by the project declaring the key/value pair.

registerPart(name, className='', styleName='', templateName='')[source]
resetCurrentPermutation()[source]

Resets the current permutation object.

setAssetOutputFolder(folder)[source]
setCompressionLevel(level)[source]
setCopyAssets(enable)[source]
setCssOutputFolder(folder)[source]
setDefaultLocale(locale)[source]

Sets the default locale

setDestinationPath(path)[source]
setDestinationUrl(url)[source]
setField(name, value)[source]

Statically configure the value of the given field.

This field is just injected into Permutation data and used for permutations, but as it only holds a single value all alternatives paths are removed/ignored.

setFlag(name, value)[source]
setFormattingLevel(level)[source]
setHashAssets(enable)[source]
setJsOutputFolder(folder)[source]
setLocales(locales, default=None)[source]

Store locales as a special built-in field with optional default value

setOutputFolder(type, value)[source]
setStaticPermutation(**argv)[source]

Sets current permutation to a static permutation which contains all values hardly wired to static values using setField() or given via additional named parameters.

setTemplateOutputFolder(folder)[source]
setUseSource(enable)[source]
setValue(key, value)[source]
setWorkingPath(path)[source]

jasy.core.Project module

class jasy.core.Project.Project(path, session, config=None, version=None, fromurl=False)[source]

Bases: builtins.object

addFile(relPath, fullPath, itemType, package, override=False)[source]
addItem(type, item)[source]

Add item to item list of given type

clean()[source]

Clears the cache of the project

close()[source]

Closes the project which deletes the internal caches

getAssets()[source]

Returns all project asssets (images, stylesheets, static data, etc.).

getCache()[source]

Returns the cache instance

getConfigValue(key, default=None)[source]
getDocs()[source]

Returns all package docs

getFields()[source]

Return the project defined fields which may be configured by the build script

getItem(type, name)[source]

Return item of given type and name

getItems(type)[source]

Returns all items of given type.

getName()[source]
getPackage()[source]
getPath()[source]
getRequires(checkoutDirectory='external', updateRepositories=True)[source]

Return the project requirements as project instances

getRevision()[source]

Returns the current revision of the project

getScriptByName(className)[source]

Finds a class by its name.

getScripts()[source]

Returns all project classes. Requires all files to have a “js” extension.

getSession()[source]
getStyles()[source]

Returns all project style styles. Requires all files to have a “sht” extension.

getTranslations()[source]

Returns all translation objects

hasRequires()[source]
isReady()[source]
kind = 'none'
pause()[source]

Pauses the project so that other processes could modify/access it

resume()[source]

Resumes the paused project

scan()[source]
scanned = False
toRelativeUrl(path, prefix='', subpath='source')[source]
jasy.core.Project.getProjectFromPath(path, session, config=None, version=None)[source]
jasy.core.Project.getProjectDependencies(project, checkoutDirectory='external', updateRepositories=True)[source]

Returns a sorted list of projects depending on the given project (including the given one)

jasy.core.Session module

class jasy.core.Session.Session[source]

Bases: builtins.object

Manages all projects.

addCommand(name, func, resultType=None, globalName=False)[source]

Registers the given function as a new command

addItemType(itemType, name, cls)[source]
addProject(project)[source]

Adds the given project to the list of known projects. Projects should be added in order of their priority. This adds the field configuration of each project to the session fields. Fields must not conflict between different projects (same name).

Parameters:project (object) – Instance of Project to append to the list
clean()[source]

Clears all caches of all registered projects

close()[source]

Closes the session and stores cache to the harddrive.

executeCommand(name, params)[source]
getAvailableTranslations()[source]

Returns a set of all available translations

This is the sum of all projects so even if only one project supports “fr_FR” then it will be included here.

getCommands()[source]

Returns a dictionary of all commands

getCurrentTask()[source]
getFields()[source]
getItemType(itemType)[source]
getItemTypes()[source]
getMain()[source]

Returns the main project which is the first project added to the session and the one with the highest priority.

getProjectByName(name)[source]

Returns a project by its name

getProjects()[source]

Returns all currently registered projects.

getRelativePath(project)[source]

Returns the relative path of any project to the main project

getScriptByName(className)[source]

Queries all currently registered projects for the given class and returns the class item. Returns None when no matching class item was found.

Parameters:className (str) – Any valid classname from any of the projects.
getStyleByName(styleName)[source]

Queries all currently registered projects for the given style and returns the style item. Returns None when no matching style item was found.

Parameters:styleName (str) – Any valid styleName from any of the projects.
getTranslationBundle(language=None)[source]

Returns a translation object for the given language containing all relevant translation files for the current project set.

getVirtualFilePathFromId(fileId, extension=None)[source]

Returns a valid virtual path for the given file item ID. Supports adding an optional extension for files where the extension is not part of the idea (effectively this are most of them, but not assets)

getVirtualItem(baseName, itemClass, text, extension)[source]
getVirtualProject()[source]

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.

init(autoInitialize=True, updateRepositories=True, scriptEnvironment=None)[source]

Initialize the actual session with projects

Parameters:
  • autoInitialize – Whether the projects should be automatically added when the current folder contains a valid Jasy project.
  • updateRepositories – Whether to update repositories of all project dependencies.
  • scriptEnvironment – API object as being used for loadLibrary to add Python features offered by projects.
  • commandEnvironment – API object as being used for loadCommands to add Python features for any item nodes.
loadCommands(objectName, fileName, encoding='utf-8')[source]

Loads new commands into the session wide command registry.

loadLibrary(objectName, fileName, encoding='utf-8', doc=None)[source]

Creates a new object inside the user API (jasyscript.py) with the given name containing all @share’d functions and fields loaded from the given file.

pause()[source]

Pauses the session. This release cache files etc. and makes it possible to call other jasy processes on the same projects.

resume()[source]

Resumes the session after it has been paused.

scan()[source]

Scans all registered projects

setCurrentTask(name=None)[source]

jasy.core.Text module

jasy.core.Text.highlightCodeBlocks(html, tabsize=2, defaultlang='javascript')[source]

Patches ‘code’ elements in HTML to apply HTML based syntax highlighting. Automatically chooses the matching language detected via a CSS class of the ‘code’ element.

jasy.core.Text.markdownToHtml(markdownStr)[source]

Converts Markdown to HTML. Supports GitHub’s fenced code blocks, auto linking and typographic features by SmartyPants.

jasy.core.Types module

class jasy.core.Types.CaseInsensitiveDict[source]

Bases: builtins.dict

A case-insensitive dict subclass. Each key is changed on entry to str(key).title().

classmethod fromkeys(seq, value=None)[source]
get(key, default=None)[source]
pop(key, default)[source]
setdefault(key, x=None)[source]
update(E)[source]

jasy.core.Util module

jasy.core.Util.camelize(str)[source]

Returns a camelized version of the incoming string: foo-bar-baz => fooBarBaz

Parameters:str – Input string
jasy.core.Util.executeCommand(args, failMessage=None, path=None, wrapOutput=True)[source]

Executes the given process and outputs failMessage when errors happen.

Parameters:
  • args (str or list) –
  • failMessage (str) – Message for exception when command fails
  • path (str) – Directory path where the command should be executed
  • wrapOutput (bool) – Whether shell output should be wrapped and returned (and passed through to Console.debug())
Raises Exception:
 

Raises an exception whenever the shell command fails in execution

jasy.core.Util.generateChecksum(key, method='base62')[source]

Generates a unique SHA1 based hash/checksum encoded as Base62 or Hex depending on the given parameters.

Parameters:
  • key (str) –
  • method (str) –
jasy.core.Util.getKey(data, key, default=None)[source]

Returns the key from the data if available or the given default

Parameters:
  • data (dict) – Data structure to inspect
  • key (str) – Key to lookup in dictionary
  • default (any) – Default value to return when key is not set
jasy.core.Util.hyphenate(str)[source]

Returns a hyphenated version of the incoming string: fooBarBaz => foo-bar-baz

Parameters:str – Input string

Module contents