Welcome to Jasy – Web Tooling Framework’s documentation!¶
Contents:
jasy package¶
Subpackages¶
jasy.abstract package¶
Submodules¶
jasy.abstract.Resolver module¶
-
class
jasy.abstract.Resolver.
Resolver
(profile)[source]¶ Bases:
object
Resolves dependencies between items.
This class is not type depended e.g. is used for both scripts and styles.
jasy.abstract.Sorter module¶
Module contents¶
jasy.asset package¶
Subpackages¶
Submodules¶
jasy.asset.ImageInfo module¶
-
class
jasy.asset.ImageInfo.
GifFile
(filename)[source]¶ Bases:
jasy.asset.ImageInfo.ImgFile
Class for parsing GIF files.
-
class
jasy.asset.ImageInfo.
ImgFile
(filename)[source]¶ Bases:
object
Abstract base class for all image types.
-
class
jasy.asset.ImageInfo.
ImgInfo
(filename)[source]¶ Bases:
object
-
classes
= [<class 'jasy.asset.ImageInfo.PngFile'>, <class 'jasy.asset.ImageInfo.GifFile'>, <class 'jasy.asset.ImageInfo.JpegFile'>]¶
-
-
class
jasy.asset.ImageInfo.
JpegFile
(filename)[source]¶ Bases:
jasy.asset.ImageInfo.ImgFile
jasy.asset.Manager module¶
-
class
jasy.asset.Manager.
AssetManager
(profile)[source]¶ Bases:
object
-
copyAssets
()[source]¶ Copies assets from their source folder to the configured destination folder.
Does apply file name transformations during copying when requested.
-
exportToJson
(items=None)[source]¶ Exports asset data for usage at the client side.
Utilizes JavaScript class jasy.Asset to inject data into the client at runtime.
-
getAssetUrl
(fileId)[source]¶ Returns the asset URL for the given item relative to the current working path.
-
getSpriteHeight
(fileId)[source]¶ Returns the height of the sprite sheet which contains the given single image.
-
getSpriteUrl
(fileId)[source]¶ Returns the url of the sprite sheet which contains the given single image.
-
getSpriteWidth
(fileId)[source]¶ Returns the width of the sprite sheet which contains the given single image.
-
jasy.asset.SpritePacker module¶
-
class
jasy.asset.SpritePacker.
SpritePacker
(base, types='png', width=1024, height=1024)[source]¶ Bases:
object
Packs single images into sprite images automatically.
-
addDir
(directory, recursive=False)[source]¶ Adds all images within a directory to the sprite packer.
-
Module contents¶
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) –
Module contents¶
jasy.env package¶
Submodules¶
jasy.env.Context module¶
Global environment which is used by jasyscript.py files.
jasy.env.State module¶
This module is used to pass a single session instance around to different modules.
jasy.env.Task module¶
Tasks are basically functions with some managment code allow them to run in jasyscript.py.
-
jasy.env.Task.
executeTask
(taskname, **kwargs)[source]¶ Executes the given task by name with any optional named arguments.
-
jasy.env.Task.
runTask
(project, task, **kwargs)[source]¶ Executes the given task of the given projects.
This happens inside a new sandboxed session during which the current session is paused/resumed automatically.
-
jasy.env.Task.
printTasks
(indent=16)[source]¶ Prints out a list of all avaible tasks and their descriptions.
-
jasy.env.Task.
setCommand
(cmd)[source]¶ Sets the jasy command which should be used to execute tasks with runTask()
Module contents¶
Glue code used in jasyscript.py to have a convenient API on top of the full Jasy API.
jasy.http package¶
Submodules¶
jasy.http.Request module¶
jasy.http.Server module¶
-
class
jasy.http.Server.
Result
(headers, content, status_code)¶ Bases:
tuple
-
content
¶ Alias for field number 1
-
headers
¶ Alias for field number 0
-
status_code
¶ Alias for field number 2
-
-
class
jasy.http.Server.
Server
(port=8080, host='127.0.0.1', mimeTypes=None)[source]¶ Bases:
object
Starts the built-in HTTP server inside the project’s root directory
-
setRoutes
(routes)[source]¶ Adds the given routes to the server configuration. Routes can be used to add special top level entries to the different features of the integrated webserver either mirroring a remote server or delivering a local directory.
The parameters is a dict where every key is the name of the route and the value is the configuration of that route.
-
Module contents¶
jasy.item package¶
Submodules¶
jasy.item.Abstract module¶
-
class
jasy.item.Abstract.
AbstractItem
(project, id=None, package=None)[source]¶ Bases:
object
-
classmethod
fromPath
(project, relpath, package=None)[source]¶ Initialize MyData from a dict’s items.
-
getId
()[source]¶ Returns a unique identify of the class.
Typically as it is stored inside the project.
-
id
= None¶
-
kind
= 'jasy.Item'¶
-
mtime
= None¶
-
project
= None¶
-
classmethod
jasy.item.Asset module¶
-
class
jasy.item.Asset.
AssetItem
(project, id=None, package=None)[source]¶ Bases:
jasy.item.Abstract.AbstractItem
-
kind
= 'jasy.Asset'¶
-
jasy.item.Doc module¶
jasy.item.Script module¶
-
class
jasy.item.Script.
ScriptItem
(project, id=None, package=None)[source]¶ Bases:
jasy.item.Abstract.AbstractItem
-
generateId
(relpath, package)[source]¶ Generates the fileId of this item as being used by other modules.
-
getBreaks
(permutation=None, items=None)[source]¶ Returns all down-priorized dependencies. This are dependencies which are required to make the module work, but are not required being available before the current item.
-
getDependencies
(permutation=None, items=None, fields=None, warnings=True)[source]¶ Returns a set of dependencies seen through the given list of known classes (ignoring all unknown items in original set) and configured fields with their individual detection classes.
This method also makes use of the meta data and the variable data.
-
getScopeData
(permutation=None)[source]¶ Returns the top level scope object which contains information about the global variable and package usage/influence.
-
kind
= 'jasy.Script'¶
-
jasy.item.Style module¶
-
exception
jasy.item.Style.
StyleError
(inst, msg)[source]¶ Bases:
Exception
Error class used for issues during style processing.
-
class
jasy.item.Style.
StyleItem
(project, id=None, package=None)[source]¶ Bases:
jasy.item.Abstract.AbstractItem
-
filterPermutation
(permutation)[source]¶ Returns a new permutation which only contains information about the fields actually accessed in this stylesheet.
-
generateId
(relpath, package)[source]¶ Generates the fileId of this item as being used by other modules.
-
getBreaks
(permutation=None, items=None, warnings=True)[source]¶ Returns all down-priorized dependencies. These are dependencies which are required to make the item work, but are not required being available before the current item.
-
getDependencies
(permutation=None, items=None, fields=None, warnings=True)[source]¶ Returns a set of dependencies seen through the given list of known items (ignoring all unknown items in original set).
-
getMergedTree
(profile)[source]¶ Returns the merged (includes resolved) and optimized.
(permutation values applied) tree.
-
getModificationTime
(profile)[source]¶ Returns the modification date of the stylesheet.
(or the sum of modification dates when using includes)
-
kind
= 'jasy.Style'¶
-
jasy.item.Template module¶
jasy.item.Translation module¶
-
class
jasy.item.Translation.
TranslationItem
(project, id=None, package=None, table=None)[source]¶ Bases:
jasy.item.Abstract.AbstractItem
-
export
(classes, formatted=True)[source]¶ Exports the translation table as JSON based on the given set of classes.
-
generateId
(relpath, package)[source]¶ Generates the fileId of this item as being used by other modules.
-
kind
= 'jasy.Translation'¶
-
Module contents¶
jasy.parse package¶
Submodules¶
jasy.parse.AbstractNode module¶
-
class
jasy.parse.AbstractNode.
AbstractNode
(tokenizer=None, type=None, args=[])[source]¶ Bases:
list
-
assignOp
¶
-
comments
¶
-
condition
¶
-
elsePart
¶
-
end
¶
-
fileId
¶
Collects all unrelated children.
-
initializer
¶
-
insertAllReplace
(orig, kids)[source]¶ Inserts all kids at the same position as the original node (which is removed afterwards)
-
line
¶
-
name
¶
-
names
¶
-
params
¶
-
parent
¶
-
parenthesized
¶
-
postfix
¶
-
rel
¶
-
scope
¶
-
start
¶
-
statement
¶
-
statements
¶
-
thenPart
¶
-
tokenizer
¶
-
type
¶
-
value
¶
-
values
¶
-
variables
¶
-
jasy.parse.ScopeData module¶
-
class
jasy.parse.ScopeData.
ScopeData
[source]¶ Bases:
object
Used by core/Variables.py to store the resulting statistics data efficiently. Contains information about:
- Declared Variables (declared)
- Modified Variables (modified)
- Shared
- Unused Variables (unused)
-
accessed
¶
-
declared
¶
-
modified
¶
-
name
¶
-
packages
¶
-
params
¶
-
unused
¶
Module contents¶
jasy.script package¶
Subpackages¶
jasy.script.api package¶
-
class
jasy.script.api.Comment.
Comment
(text, context=None, lineNo=0, indent='', fileId=None)[source]¶ Bases:
object
Comment class is attached to parsed nodes and used to store all comment related information.
The class supports a new Markdown and TomDoc inspired dialect to make developers life easier and work less repeative.
-
context
= None¶
-
getHtml
(highlight=True)[source]¶ Returns the comment text converted to HTML.
Parameters: highlight (bool) – Whether to highlight the code
-
params
= None¶
-
returns
= None¶
-
text
= None¶
-
type
= None¶
-
-
class
jasy.script.api.Data.
ApiData
(id, highlight=True)[source]¶ Bases:
object
Container for all relevant API data.
Automatically generated, filled and cached by jasy.item.Script.getApiDocs().
-
assets
¶
-
basename
¶
-
construct
¶
-
content
¶
-
errors
¶
-
events
¶
-
highlight
¶
-
id
¶
-
implementedBy
¶
-
implements
¶
-
includedBy
¶
-
includes
¶
-
isEmpty
¶
-
main
¶
-
members
¶
-
package
¶
-
permutations
¶
-
properties
¶
-
size
¶
-
statics
¶
-
usedBy
¶
-
uses
¶
-
-
class
jasy.script.api.Writer.
ApiWriter
(profile)[source]¶ Bases:
object
Processes JavaScript classes into data for API documentation.
Exports plain data which can be used by a wide varity of tools for further processing or for displaying documentation. A good example of how to use the data generated by write is the ApiBrowser: https://github.com/zynga/apibrowser
-
write
(distFolder, classFilter=None, callback='apiload', showInternals=False, showPrivates=False, printErrors=True, highlightCode=True)[source]¶ Writes API data generated from JavaScript into distFolder.
Parameters: - distFolder (str) – Where to store the API data
- classFilter (tuple or function) – Tuple of classes or method to use for filtering
- callback (function) – Name of callback to use for loading or None if pure JSON should be used
- showInternals (bool) – Include internal methods inside API data
- showPrivates (bool) – Include private methods inside API data
- printErrors (bool) – Whether errors should be printed to the console
- highlightCode (bool) – Whether to enable code highlighting using Pygments
-
jasy.script.clean package¶
This module is used to detect dead code branches and remove them. This is escecially useful after injecting values from the outside which might lead to simple truish equations which can be easily resolved.
This module is directly used by Class after Permutations have been applied (code branches) but can be used more widely, too.
This acts somewhat like the optimizers you find under “optimizer”, but is dependency relevant (Permutations might remove whole blocks of alternative code branches). It makes no sense to optimize this just before compilation. It must be done pretty early during the processing of classes.
The module currently support the following statements:
- if
- hook (?:)
- switch
and can detect good code based on:
- true
- false
- equal: ==
- strict equal: ===
- not equal: !=
- strict not equal: !==
- not: !
- and: &&
- or: ||
It supports the types “string” and “number” during comparisions. It uses a simple equality operator in Python which behaves like strict equal in JavaScript. This also means that number 42 is not equal to string “42” during the dead code analysis.
It can figure out combined expressions as well like:
- 4 == 4 && !false
jasy.script.optimize package¶
-
jasy.script.optimize.BlockReducer.
cleanParens
(node)[source]¶ Automatically tries to remove superfluous parens which are sometimes added for more clearance and readability but which are not required for parsing and just produce overhead.
-
jasy.script.optimize.BlockReducer.
combineAssignments
(condition, thenExpression, elseExpression, compressor)[source]¶ Combines then and else expression to one assignment when they both assign to the same target node and using the same operator.
-
jasy.script.optimize.BlockReducer.
combineExpressions
(condition, thenExpression, elseExpression)[source]¶ Combines then and else expression using a hook statement.
-
jasy.script.optimize.BlockReducer.
combineToCommaExpression
(node)[source]¶ This method tries to combine a block with multiple statements into one semicolon statement with a comma expression containing all expressions from the previous block. This only works when the block exclusively consists of expressions as this do not work with other statements. Still this conversion reduces the size impact of many blocks and leads to the removal of a lot of curly braces in the result code.
Example: {x++;y+=3} => x++,x+=3
-
jasy.script.optimize.BlockReducer.
compactIf
(node, thenPart, condition)[source]¶ Reduces the size of a if statement (without elsePart) using boolean operators instead of the typical keywords e.g. “if(something)make()” is translated to “something&&make()” which is two characters shorter.
This however only works when the thenPart is only based on expressions and does not contain other statements.
-
jasy.script.optimize.BlockReducer.
containsIf
(node)[source]¶ Checks whether the given node contains another if-statement
-
jasy.script.optimize.BlockReducer.
containsIfElse
(node)[source]¶ Checks whether the given node contains another if-else-statement
-
jasy.script.optimize.BlockReducer.
createHook
(condition, thenPart, elsePart)[source]¶ Creates a hook expression with the given then/else parts.
-
jasy.script.optimize.BlockReducer.
createReturn
(value)[source]¶ Creates a return statement with the given value.
-
jasy.script.optimize.BlockReducer.
endsWithReturnOrThrow
(node)[source]¶ Used by the automatic elsePart removal logic to find out whether the given node ends with a return or throw which is bascially the allowance to remove the else keyword as this is not required to keep the logic intact.
-
jasy.script.optimize.BlockReducer.
fixParens
(node)[source]¶ Automatically wraps the given node into parens when it was moved into another block and is not parsed there in the same way as it was the case previously.
The method needs to be called after the node has been moved to the target node.
-
jasy.script.optimize.BlockReducer.
mergeParts
(node, thenPart, elsePart, condition, compressor)[source]¶ Merges if statement with a elsePart using a hook. Supports two different ways of doing this: using a hook expression outside, or using a hook expression inside an assignment.
Example: if(test) first(); else second() => test ? first() : second(); if(foo) x=1; else x=2 => x = foo ? 1 : 2;
jasy.script.output package¶
-
class
jasy.script.output.Formatting.
Formatting
(*args)[source]¶ Bases:
jasy.core.FlagSet.FlagSet
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.
-
exception
jasy.script.output.Optimization.
Error
(msg)[source]¶ Bases:
Exception
Error object which is raised whenever an optimization could not be applied correctly.
-
class
jasy.script.output.Optimization.
Optimization
(*args)[source]¶ Bases:
jasy.core.FlagSet.FlagSet
Configures an optimization 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 optimizations.
jasy.script.parse package¶
-
class
jasy.script.parse.Node.
Node
(tokenizer=None, type=None, args=[])[source]¶ Bases:
jasy.parse.AbstractNode.AbstractNode
-
assignOp
¶
-
block
¶
-
body
¶
-
comments
¶
-
condition
¶
-
defaultIndex
¶
-
discriminant
¶
-
elsePart
¶
-
end
¶
-
exception
¶
-
expression
¶
-
expressionClosure
¶
-
fileId
¶
-
finallyBlock
¶
-
for
¶
-
functionForm
¶
-
guard
¶
-
initializer
¶
-
isEach
¶
-
isLoop
¶
-
iterator
¶
-
label
¶
-
line
¶
-
name
¶
-
names
¶
-
object
¶
-
params
¶
-
parent
¶
-
parenthesized
¶
-
postfix
¶
-
readOnly
¶
-
rel
¶
-
scope
¶
-
setup
¶
-
start
¶
-
statement
¶
-
statements
¶
-
tail
¶
-
thenPart
¶
-
tokenizer
¶
-
tryBlock
¶
-
type
¶
-
update
¶
-
value
¶
-
variables
¶
-
-
jasy.script.parse.ScopeScanner.
scan
(tree)[source]¶ Scans the given tree and attaches variable data instances (core/ScopeData.py) to every scope (aka function).
This data is being stored independently from the real tree so that if you modifiy the tree the data is not automatically updated. This means that every time you modify the tree heavily, it might make sense to re-execute this method to bring it in sync to the current tree structure.
jasy.script.tokenize package¶
JavaScript 1.7 keywords
-
exception
jasy.script.tokenize.Tokenizer.
ParseError
(message, fileId, line)[source]¶ Bases:
Exception
-
class
jasy.script.tokenize.Tokenizer.
Token
[source]¶ Bases:
object
-
assignOp
¶
-
end
¶
-
line
¶
-
start
¶
-
type
¶
-
value
¶
-
jasy.script.util package¶
-
jasy.script.util.
assembleDot
(node, result=None)[source]¶ Joins a dot node (cascaded supported, too) into a single string like “foo.bar.Baz”.
-
jasy.script.util.
detectObjectType
(objectNode)[source]¶ Returns a human readable type information of the given node.
-
jasy.script.util.
detectPlusType
(plusNode)[source]¶ Analyses the given “plus” node and tries to figure out if a “string” or “number” result is produced.
-
jasy.script.util.
findAssignments
(name, node)[source]¶ Returns a list of assignments which might have impact on the value used in the given node.
-
jasy.script.util.
findCall
(node, methodName)[source]¶ Recurses the tree starting with the given node and returns the first node which calls the given method name (supports namespaces, too)
-
jasy.script.util.
findCommentNode
(node)[source]¶ Finds the first doc comment node inside the given node.
-
jasy.script.util.
getKeyValue
(dict, key)[source]¶ Returns the value node of the given key inside the given object initializer.
-
jasy.script.util.
getParamNamesFromFunction
(func)[source]¶ Returns a human readable list of parameter names (sorted by their order in the given function)
-
jasy.script.util.
getParameterFromCall
(call, index=0)[source]¶ Returns a parameter node by index on the call node.
-
jasy.script.util.
getVisibility
(name)[source]¶ Returns the visibility of the given name by convention.
-
jasy.script.util.
query
(node, matcher, deep=True, inner=False)[source]¶ Recurses the tree starting with the given node and returns the first node which is matched by the given matcher method.
- node: any node
- matcher: function which should return a truish value when node matches
- deep: whether inner scopes should be scanned, too
- inner: used internally to differentiate between current and inner nodes
-
jasy.script.util.
queryAll
(node, matcher, deep=True, inner=False, result=None)[source]¶ Recurses the tree starting with the given node and returns a list of nodes matched by the given matcher method.
- node: any node
- matcher: function which should return a truish value when node matches
- deep: whether inner scopes should be scanned, too
- inner: used internally to differentiate between current and inner nodes
- result: can be used to extend an existing list, otherwise a new list is created and returned
Submodules¶
jasy.script.Resolver module¶
-
class
jasy.script.Resolver.
Resolver
(profile)[source]¶ Bases:
jasy.abstract.Resolver.Resolver
-
addVirtual
(name, text)[source]¶ Adds a virtual aka generated class to the resolver with the given name and text.
Please note: The file name is modified to contain a checksum of the content as a postfix. This keeps caches in-tact when using different contents for the same file name aka different sets of assets, translations, etc. The classname itself (which is modified here as said) is not so much of relevance because of the situation that the virtual class object is automatically added to the resolver (and sorter).
-
jasy.script.Sorter module¶
Module contents¶
jasy.style package¶
Subpackages¶
jasy.style.clean package¶
This class is responsible for resolving if-conditions based on permutation data Not all if blocks are being able to be resolved that way though as some use variables etc. which are not available before actual full processing of the content.
jasy.style.output package¶
-
class
jasy.style.output.Formatting.
Formatting
(*args)[source]¶ Bases:
jasy.core.FlagSet.FlagSet
Configures an formatting object which can be used to compress stylesheets afterwards.
The optimization set is frozen after initialization which also generates the unique key based on the given formatting options.
-
exception
jasy.style.output.Optimization.
Error
(msg)[source]¶ Bases:
Exception
Error object which is raised whenever an optimization could not be applied correctly.
-
class
jasy.style.output.Optimization.
Optimization
(*args)[source]¶ Bases:
jasy.core.FlagSet.FlagSet
Configures an optimization object which can be used to compress stylesheets afterwards.
The optimization set is frozen after initialization which also generates the unique key based on the given optimizations.
jasy.style.parse package¶
-
class
jasy.style.parse.Node.
Node
(tokenizer=None, type=None, args=[])[source]¶ Bases:
jasy.parse.AbstractNode.AbstractNode
-
assignOp
¶
-
comments
¶
-
condition
¶
-
dynamic
¶
-
elsePart
¶
-
end
¶
-
fileId
¶
-
initializer
¶
-
line
¶
-
name
¶
-
names
¶
-
noscope
¶
-
params
¶
-
parent
¶
-
parenthesized
¶
-
quote
¶
-
rel
¶
-
rules
¶
-
scope
¶
-
selector
¶
-
start
¶
-
statement
¶
-
statements
¶
-
thenPart
¶
-
token
¶
-
tokenizer
¶
-
type
¶
-
unit
¶
-
value
¶
-
variables
¶
-
vendor
¶
-
-
jasy.style.parse.Parser.
Expression
(tokenizer, staticContext)[source]¶ Top-down expression parser for stylestyles.
-
jasy.style.parse.Parser.
KeyFrames
(tokenizer, staticContext)[source]¶ Supports e.g.:
- @keyframes fade{
- from, 10%{
- background-color: #000000;
}
- 100%{
- background-color: #FFFFFF;
}
}
-
jasy.style.parse.Parser.
Media
(tokenizer, staticContext)[source]¶ Supports e.g.:
- @media print{
- body{
- background-color: #000000;
}
}
- @media handheld, tv{
- body{
- background-color: yellow;
}
}
- @media screen and (max-width: 300px) {
- body{
- background-color: orange;
}
}
-
jasy.style.parse.Parser.
Page
(tokenizer, staticContext)[source]¶ Supports e.g.:
- @page{
- margin: 1cm;
}
- @page :first{
- margin: 5cm 2cm;
}
-
jasy.style.parse.Parser.
ParenExpression
(tokenizer, staticContext)[source]¶ An expression in parens.
Sometimes to force priority of math operations etc.
-
jasy.style.parse.Parser.
Property
(tokenizer, staticContext)[source]¶ Parses all CSS properties e.g.
- background: red
- font: 12px bold Arial;
-
jasy.style.parse.Parser.
Root
(tokenizer, staticContext)[source]¶ Supports e.g.:
- h1{
font-size: 20px;
- @root html.desktop &{
- font-size: 30px;
}
}
- .date{
color: black; background: white;
- @root{
- &__dialog{
- position: absolute;
}
}
}
-
jasy.style.parse.Parser.
Selector
(tokenizer, staticContext)[source]¶ CSS selector parser e.g.
h1 .infobox #header h1::after h2:first-child
-
jasy.style.parse.Parser.
Sheet
(tokenizer, staticContext)[source]¶ Parses the toplevel and rule bodies.
-
jasy.style.parse.Parser.
ValueExpression
(tokenizer, staticContext)[source]¶ Top-down expression parser for rule values in stylestyles.
-
jasy.style.parse.ScopeScanner.
scan
(tree)[source]¶ Scans the given tree and attaches variable data instances (core/ScopeData.py) to every scope (aka function).
This data is being stored independently from the real tree so that if you modifiy the tree the data is not automatically updated. This means that every time you modify the tree heavily, it might make sense to re-execute this method to bring it in sync to the current tree structure.
jasy.style.process package¶
-
jasy.style.process.Operation.
castToBool
(node)[source]¶ Returns the boolean Python representation for the given Node.
-
jasy.style.process.Operation.
compute
(node, first=None, second=None, operator=None, session=None)[source]¶ Recursively processes given operation node.
Consumes optional hints for the first/second child of an operation as well as the operator itself (in cases where it could not be figured out automatically). The session is useful for supporting commands inside of operations.
jasy.style.tokenize package¶
-
class
jasy.style.tokenize.Tokenizer.
Token
[source]¶ Bases:
object
-
assignOp
¶
-
end
¶
-
line
¶
-
quote
¶
-
start
¶
-
type
¶
-
unit
¶
-
value
¶
-
Submodules¶
jasy.style.Engine module¶
-
jasy.style.Engine.
compressTree
(tree, optimizationLevel=0, formattingLevel=0)[source]¶ Returns the compressed result from the given tree.
-
jasy.style.Engine.
getTokenizer
(text, fileId=None)[source]¶ Returns a tokenizer for the given file content.
jasy.style.Resolver module¶
jasy.style.Sorter module¶
jasy.style.Util module¶
-
jasy.style.Util.
assembleDot
(node, result=None)[source]¶ Joins a dot node (cascaded supported, too) into a single string like “foo.bar.Baz”.
Module contents¶
jasy.template package¶
Submodules¶
jasy.template.Compiler module¶
jasy.template.Parser module¶
-
jasy.template.Parser.
tokenize
(text, nostrip=False)[source]¶ Tokenizer for template @text {String}. Returns an array of tokens where tags are returned as an object with the keys tag and name while normal strings are kept as strings.
Optionally you can keep white spaces (line breaks, leading, trailing, etc.) by enabling @nostrip {Boolean?false}.
-
jasy.template.Parser.
parse
(text, nostrip=False)[source]¶ Returns the token tree of the given template @text {String}.
A token holds the following information:
- tag: tag of the token
- name: name of the token
- nodes: children of the node
Optionally you can keep white spaces (line breaks, leading, trailing, etc.) by enabling @nostrip {Boolean?false}.
Module contents¶
jasy.test package¶
Subpackages¶
jasy.test.script package¶
-
class
jasy.test.script.privates.
Tests
(methodName='runTest')[source]¶ Bases:
unittest.case.TestCase
-
test_access_same_named_external
()[source]¶ Is is somehow an unsupported edge case which is not supported correctly yet.
Normally one would expect that the access to __field on RemoteObj would raise an error. At least it breaks this wrong access because this field is renamed based on file name as well.
-
jasy.test.style package¶
Submodules¶
jasy.test.assettype module¶
jasy.test.cache module¶
jasy.test.config module¶
jasy.test.giturl module¶
jasy.test.options module¶
jasy.test.project module¶
jasy.test.requirements module¶
jasy.test.session module¶
jasy.test.text module¶
Module contents¶
jasy.vcs package¶
Submodules¶
jasy.vcs.Git module¶
-
jasy.vcs.Git.
distcleanRepository
()[source]¶ Cleans git repository from untracked files.
Ignores the files listed in ”.gitignore”.
-
jasy.vcs.Git.
getShortRevision
(path=None)[source]¶ Returns the last shortened revision/hash of the git repository.
jasy.vcs.Repository module¶
-
jasy.vcs.Repository.
clean
(path=None)[source]¶ Cleans repository from untracked files.
Parameters: url (string) – Path to the local repository
-
jasy.vcs.Repository.
distclean
(path=None)[source]¶ Cleans repository from untracked and ignored files. This method is pretty agressive in a way that it deletes all non repository managed files e.g. external folder, uncommitted changes, unstaged files, etc.
Parameters: url (string) – Path to the local repository
-
jasy.vcs.Repository.
getRevision
(path=None)[source]¶ Returns the current revision of the repository in the given path.
-
jasy.vcs.Repository.
getTargetFolder
(url, version=None)[source]¶ Returns the target folder name based on the URL and version using SHA1 checksums.
Parameters: - url (string) – URL to the repository
- version – Version to use
-
jasy.vcs.Repository.
getType
(url)[source]¶ Returns repository type of the given URL.
Parameters: url (string) – URL to the repository
-
jasy.vcs.Repository.
isUrl
(url)[source]¶ Figures out whether the given string is a valid Git repository URL.
Parameters: url (string) – URL to the repository
-
jasy.vcs.Repository.
update
(url, version=None, path=None, update=True)[source]¶ Clones the given repository URL (optionally with overriding/update features)
Parameters: - url (string) – URL to the repository
- version – Version to clone
- version – Destination path
- version – Eneable/disable update functionality
jasy.vcs.Svn module¶
Module contents¶
Module contents¶
Jasy - Web Tooling Framework
Jasy is a powerful Python3-based tooling framework. It makes it easy to manage heavy web projects. Its main goal is to offer an API which could be used by developers to write their custom build/deployment scripts.