Supported Libraries and Frameworks
A toolbox to multiple external libraries. Epyk will interface with the most popular JavaScript and Css libraries from the vast number of components.
This will be fully transparent Epyk Components will include to the page their external resources.
127 Libraries
Framework
Import Manager
The import Manager is one of the entry point directly accessible from Epyk.
- class epyk.core.js.Imports.ImportManager(page=None)
The main class in charge of defining the order of the imports in the header.
There is no check on the presence of the modules on the server. The only purpose of this module is to produce the string with the module names and the correct paths to your final HTML report.
- add(alias: str)
Add package to the page external required modules.
- Parameters:
alias – The external module alias
- addPackage(alias: str, config: dict)
Add a new package or update an existing one with new parameters.
Only few parameters are available here in order to limit the changes.
Usage:
i.addPackage('test', { 'req': [{'alias': 'd3'}], 'modules': [ {'script': 'dc.min.css', 'version': '3.0.9', 'path': 'dc/%(version)s/', 'cdnjs': 'https://cdnjs.cloudflare.com/ajax/libs'}, {'script': 'dc.min.js', 'version': '3.0.9', 'path': 'dc/%(version)s/', 'cdnjs': 'https://cdnjs.cloudflare.com/ajax/libs'}, ]}, )
- Parameters:
alias – The package alias
config – The Python dictionary with the package details
- Returns:
The import Manager.
- cleanImports(imports: List[str], import_hierarchy: Optional[dict] = None, use_require_js: bool = False)
Remove the underlying imports to avoid duplicated entries.
Usage:
>>> ImportManager().cleanImports(['c3'], JS_IMPORTS)
[‘jquery’, ‘d3’, ‘c3’]
- Parameters:
imports – An array with the list of aliases for the external packages
import_hierarchy – Optional. The package definition (Javascript | CSS) from the above import list
use_require_js – Optional. Define if this is using requirejs to load imports. Default False
- Returns:
Return the list with the full list of aliases (including dependencies)
- cssGetAll()
To retrieve the full list of available modules on the server.
This will return the dependencies as they should be included in the HTML page. The order and the path resolution is already performed.
If split is True the generated css file will be not included.
Usage:
print(page.imports.cssGetAll())
- cssResolve(css_aliases: List[str], local_css: Optional[dict] = None, excluded: Optional[List[str]] = None)
Return the list of CSS modules to add to the header.
Usage:
>>> ImportManager().cssResolve(['c3'])
‘<link rel=”stylesheet” href=”/static/c3/0.6.12/c3.min.css” type=”text/css”>’
- Parameters:
css_aliases – An array with the list of aliases for the external packages
local_css – Optional. The external file overrides with the full path
excluded – Optional. Packages excluded from the result object (mandatory for some frameworks already onboarding modules).
- Returns:
The string to be added to the header.
- cssURLs(css_str: str)
Retrieve the list of CSS dependencies URL from a header.
- Parameters:
css_str – The CSS String in the page
- Returns:
A Python list with all the CSS external URL to be imported.
- extend(aliases: List[str])
Add multiple aliases to the external requirements.
- Parameters:
aliases – The list of package aliases to be added
- getFiles(css_alias: List[str], js_alias: List[str])
Retrieve the package definition from the list of module aliases
Usage:
>>> ImportManager().getFiles(['c3'], ['c3'])
f[‘css’][0][‘file’][‘script’]
- Parameters:
css_alias – An array with the list of aliases for the CSS external packages
js_alias – An array with the list of aliases for the Js external packages
- Returns:
A dictionary with the CSS and JS files definition.
- getFullPackage(alias: str, version: Optional[str] = None, static_path: Optional[str] = None, reload: bool = False)
Download a full package (CSS and JS) locally for a server or full offline mode.
Usage:
Imports.ImportManager(report=Report()).getFullPackage('font-awesome')
- Parameters:
alias – The package reference in the above list
version – Optional. The package version to retrieve
static_path – Optional. The path in which the files should be copied to
reload – Optional. Flag to force the package reloading if the folder already exists. Default False
- Returns:
The Python Import manager.
- getModules(modules: dict, alias: Union[str, dict], folder: Optional[str] = None, module_details: Optional[dict] = None)
Return the list of modules for a given entry.
This will be used recursively to resolve all the dependencies.
Usage:
modules = collections.OrderedDict() ImportManager().getModules(modules, 'c3')
- Parameters:
modules – The ordered definition of modules
alias – The module reference in the above JS and CSS dictionaries
folder – Optional. The folder name
module_details – The module definition. Default check in the Javascript modules
- Returns:
The list of modules
- getReq(mod: str, modules: List[dict], import_hierarchy: Optional[dict] = None, use_require_js: bool = False)
Set the list pf required modules for a given alias to the modules list.
Usage:
deps = [] page.imports.getReq("c3", deps) print(deps)
- Parameters:
mod – The alias of the external package
modules – The list of packages aliases in the inverse dependency order
import_hierarchy – Optional. The package definition (Javascript | CSS) from the above import list
use_require_js – Optional. Define if this is using requirejs to load imports. Default False
- google_products(products: List[str], api_key: Optional[str] = None, site_key: str = '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI')
Enable the google predefined products.
Those are by default disabled as they are sharing data with Google.
TODO: Add the use of the API Key.
Usage:
page.imports.google_products(['charts']) page.imports.google_products(['maps']) page.imports.google_products(['tables']) https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha.-what-should-i-do
- Parameters:
products – The various Google products to enable in the report
api_key – Optional. The Google developer API key
site_key – Optional. The Google site key: https://developers.google.com/recaptcha/docs/v3
- jsGetAll()
To retrieve the full list of available modules on the server.
This will return the dependencies as they should be included in the HTML page. The order and the path resolution is already performed.
If split is True the generated JS file will be not included.
Usage:
print(page.imports.jsGetAll())
- jsResolve(js_aliases: List[str], local_js: Optional[dict] = None, excluded: Optional[List[str]] = None)
Return the list of Javascript modules to add to the header.
Usage:
>>> ImportManager().jsResolve(['c3'])
‘<script language=”javascript” type=”text/javascript” src=”/static/jquery/3.4.1/jquery.min.js”></script>
<script language=”javascript” type=”text/javascript” src=”/static/d3/5.9.7/d3.min.js”></script> <script language=”javascript” type=”text/javascript” src=”/static/c3/0.6.12/c3.min.js”></script>’
- param js_aliases:
An array with the list of aliases for the external packages
- param local_js:
Optional. The external file overrides with the full path
- param excluded:
Optional. Packages excluded from the result object (mandatory for some frameworks already onboarding modules)
- return:
The string to be added to the header
- jsURLs(expr: str)
Retrieve the list of Javascript dependencies URL from a header.
- Parameters:
expr – The Javascript String in the page
- Returns:
A Python list with all the Javascript external URL to be imported.
- locals(aliases: List[str], end_points: Optional[str] = None)
Short circuit the import mechanism and retrieve the selected ones from a local static path.
This could help on the debugging and the improvement of the packages before submitting them for review.
- Parameters:
aliases – The list of aliases
end_points – Optional. The end point on the server (The module static_path as default)
- packages_from_json(dependency_file: str, ext_packages: Dict[str, dict])
reduce the list of packages to the ones defined in the packages.json. This will also add the requirements for those packages.
Usage:
page = ek.Page() page.imports.packages_from_json(r"./assets/package.json") # Loading external packages ext_pkgs = { "@eonasdan/tempus-dominus": { 'version': "6.7.7", 'req': [{'alias': '@popperjs/core'}, {'alias': 'bootstrap'}], 'modules': [ {'script': 'tempus-dominus.min.css', 'node_path': 'dist/css/', 'path': 'tempus-dominus/%(version)s/'}, {'script': 'tempus-dominus.min.js', 'node_path': 'dist/js/', 'path': 'tempus-dominus/%(version)s/'}, ]}} page.imports.packages_from_json(r"./assets/package.json", ext_pkgs)
- Parameters:
dependency_file – Path for the file packages.json
ext_packages – A dictionary with all the external packages to add added to the internal imports
- property pkgs: ImportPackages
Shortcut properties to the various package definitions.
This can be used in the script in order to change the path of the version of any external modules used.
- property requirements: set
Retrieve all the mandatory requirements required to display the final HTML page.
Usage:
print(page.imports().requirements)
- setVersion(alias: str, version: str, js: Optional[dict] = None, css: Optional[dict] = None)
Allow the use of different version of a package.
This will change the Import important to the Python env.
Usage:
page.imports.setVersion(page.imports.pkgs.popper_js.alias, "1.00.0")
- Parameters:
alias – The package reference in the above list
version – The new version to be used globally
js – Optional. The JavaScript packages to be added
css – Optional. The CSS packages to be added
- show(all: bool = False)
Show all the underlying packages used in a report or available in the framework.
- Parameters:
all – Optional. A flag to specify if only the one requested in the report should be displayed
- to_requireJs(data: dict, excluded_packages: Optional[list] = None)
- Parameters:
data – The Report modules to resolve
excluded_packages – Optional. The packages to exclude
- website(alias: str)
Get the official website for a JavaScript library.
- Parameters:
alias – The JavaScript module alias (usually the one used by npm)