jasy.core package¶
Submodules¶
jasy.core.Base62 module¶
jasy.core.Cache module¶
-
class
jasy.core.Cache.
Cache
(path, filename='jasycache', hashkeys=False)[source]¶ Bases:
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.
-
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).
-
jasy.core.Config module¶
-
class
jasy.core.Config.
Config
(data=None)[source]¶ Bases:
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
-
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.
-
get
(name, default=None)[source]¶ Returns the value of the given field or None when field is not set.
-
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!
-
-
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.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.
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.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.Doctor module¶
jasy.core.File module¶
A module consisting of some often used file system actions in easy to use unix tradition.
-
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.
sha1
(fileOrPath, block_size=1048576)[source]¶ Returns a SHA 1 checksum (as hex digest) of the given file (handle)
jasy.core.FileManager module¶
-
class
jasy.core.FileManager.
FileManager
(profile=None)[source]¶ Bases:
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.
-
jasy.core.FlagSet module¶
jasy.core.Inspect module¶
jasy.core.Locale module¶
-
class
jasy.core.Locale.
LocaleParser
(locale)[source]¶ Bases:
object
Parses CLDR locales into JavaScript files.
-
jasy.core.Locale.
pluralToJavaScript
(expr)[source]¶ Translates the CLDR plural rules from http://cldr.unicode.org/index/cldr-spec/plural-rules into JavaScript expressions
jasy.core.MetaData module¶
-
class
jasy.core.MetaData.
MetaData
(tree)[source]¶ Bases:
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
¶
-
requires
¶
-
jasy.core.Options module¶
jasy.core.Permutation module¶
jasy.core.Profile module¶
-
class
jasy.core.Profile.
Profile
(session)[source]¶ Bases:
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.
-
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
-
getAssetOutputFolder
()[source]¶ Name of the folder inside the destination folder for storing used assets.
-
getCssOutputFolder
()[source]¶ Name of the folder inside the destination folder for storing generated style sheets.
-
getCurrentLocaleProject
(update=False)[source]¶ Returns a locale project for the currently configured locale.
Returns None if locale is not set to a valid value.
-
getCurrentPermutation
()[source]¶ Returns current permutation object (useful during looping through permutations via permutate()).
-
getJsOutputFolder
()[source]¶ Name of the folder inside the destination folder for storing generated script files.
-
getProjects
()[source]¶ Returns all currently registered projects.
Injects locale project when current permutation has configured a locale.
-
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.
-
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.
-
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.
-
setLocales
(locales, default=None)[source]¶ Store locales as a special built-in field with optional default value
-
jasy.core.Project module¶
-
class
jasy.core.Project.
Project
(path, session, config=None, version=None, fromurl=False)[source]¶ Bases:
object
-
getRequires
(checkoutDirectory='external', updateRepositories=True)[source]¶ Return the project requirements as project instances.
-
getStyles
()[source]¶ Returns all project style styles.
Requires all files to have a “sht” extension.
-
kind
= 'none'¶
-
scanned
= False¶
-
jasy.core.Session module¶
-
class
jasy.core.Session.
Session
[source]¶ Bases:
object
Manages all projects.
-
addCommand
(name, func, resultType=None, globalName=False)[source]¶ Registers the given function as a new command.
-
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
-
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.
-
getMain
()[source]¶ Returns the main project which is the first project added to the session and the one with the highest priority.
-
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)
-
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.
-
jasy.core.Text module¶
jasy.core.Types module¶
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) –