sphinx.addnodesdocument)}( rawsourcechildren]docutils.nodessection)}(hhh](h title)}(hGetting startedh]h TextGetting started}(hhparenthhhsourceNlineNuba attributes}(ids]classes]names]dupnames]backrefs]utagnamehhh hhhY/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/docs/sphinx/installation_use.rsthKubh )}(hhh](h)}(h Installationh]h Installation}(hh1hh/hhhNhNubah}(h ]h"]h$]h&]h(]uh*hhh,hhhh+hKubh paragraph)}(hXTranscrypt is currently tested under Windows, Linux and OSX, with Chrome, Internet Explorer and Firefox. To be able to use it, Python 3.9 has to be installed. After that, install *virtualenv* as explained in `Jamie Matthews very clear and brief introduction `_. Be sure to install virtualenv for the right Python version, by using the right *pip*. For each Transcrypt project (or group of projects using the same Transcrypt version) create an environment as described in the referenced introduction. To install Trancrypt into that environment, *activate* the environment as also described there, and then type:h](hTranscrypt is currently tested under Windows, Linux and OSX, with Chrome, Internet Explorer and Firefox. To be able to use it, Python 3.9 has to be installed. After that, install }(hTranscrypt is currently tested under Windows, Linux and OSX, with Chrome, Internet Explorer and Firefox. To be able to use it, Python 3.9 has to be installed. After that, install hh?hhhNhNubh emphasis)}(h *virtualenv*h]h virtualenv}(hhhhJubah}(h ]h"]h$]h&]h(]uh*hHhh?ubh as explained in }(h as explained in hh?hhhNhNubh reference)}(h}`Jamie Matthews very clear and brief introduction `_h]h0Jamie Matthews very clear and brief introduction}(h0Jamie Matthews very clear and brief introductionhh_ubah}(h ]h"]h$]h&]h(]name0Jamie Matthews very clear and brief introductionrefuriGhttps://www.dabapps.com/blog/introduction-to-pip-and-virtualenv-python/uh*h]hh?ubh target)}(hJ h]h}(h ]0jamie-matthews-very-clear-and-brief-introductionah"]h$]0jamie matthews very clear and brief introductionah&]h(]refurihquh*hr referencedKhh?ubhQ. Be sure to install virtualenv for the right Python version, by using the right }(hQ. Be sure to install virtualenv for the right Python version, by using the right hh?hhhNhNubhI)}(h*pip*h]hpip}(hhhhubah}(h ]h"]h$]h&]h(]uh*hHhh?ubh. For each Transcrypt project (or group of projects using the same Transcrypt version) create an environment as described in the referenced introduction. To install Trancrypt into that environment, }(h. For each Transcrypt project (or group of projects using the same Transcrypt version) create an environment as described in the referenced introduction. To install Trancrypt into that environment, hh?hhhNhNubhI)}(h *activate*h]hactivate}(hhhhubah}(h ]h"]h$]h&]h(]uh*hHhh?ubh8 the environment as also described there, and then type:}(h8 the environment as also described there, and then type:hh?hhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhh,hhubh>)}(h*pip install transcrypt*h]hI)}(hhh]hpip install transcrypt}(hhhhubah}(h ]h"]h$]h&]h(]uh*hHhhubah}(h ]h"]h$]h&]h(]uh*h=hh+hK hh,hhubh>)}(h}from the command prompt. This is the recommended way to install Transcrypt. It is flexible and sets the proper access rights.h]h}from the command prompt. This is the recommended way to install Transcrypt. It is flexible and sets the proper access rights.}(hhhhhhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hK hh,hhubh>)}(hVAlternatively, for manual installation under Windows or Linux, follow the steps below:h]hVAlternatively, for manual installation under Windows or Linux, follow the steps below:}(hhhhhhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hK hh,hhubh enumerated_list)}(hhh](h list_item)}(h;Download the Transcrypt zip and unpack it anywhere you likeh]h>)}(hhh]h;Download the Transcrypt zip and unpack it anywhere you like}(hhhhubah}(h ]h"]h$]h&]h(]uh*h=hh+hKhhubah}(h ]h"]h$]h&]h(]uh*hhhhhhh+hNubh)}(h=Add *../Transcrypt-/transcrypt* to your system path h]h>)}(h/transcrypt* to your system pathh](hAdd }(hAdd hjubhI)}(h$*../Transcrypt-/transcrypt*h]h"../Transcrypt-/transcrypt}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh to your system path}(h to your system pathhjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhjubah}(h ]h"]h$]h&]h(]uh*hhhhhhh+hNubeh}(h ]h"]h$]h&]h(]enumtypearabicprefixhsuffix.uh*hhh,hhhh+hKubh>)}(haTo enable minification, additionally the Java Runtime Environment 6 or later has to be installed.h]haTo enable minification, additionally the Java Runtime Environment 6 or later has to be installed.}(hj=hj;hhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hKhh,hhubh note)}(hIf you install Transcrypt manually, Trancrypt is started by typing *run_transcrypt* rather than *transcrypt*. This allows a pip installed Transcrypt and a manually installed Transcrypt to be used side by side selectively.h]h>)}(hjMh](hCIf you install Transcrypt manually, Trancrypt is started by typing }(hCIf you install Transcrypt manually, Trancrypt is started by typing hjOubhI)}(h*run_transcrypt*h]hrun_transcrypt}(hhhjWubah}(h ]h"]h$]h&]h(]uh*hHhjOubh rather than }(h rather than hjOubhI)}(h *transcrypt*h]h transcrypt}(hhhjjubah}(h ]h"]h$]h&]h(]uh*hHhjOubhq. This allows a pip installed Transcrypt and a manually installed Transcrypt to be used side by side selectively.}(hq. This allows a pip installed Transcrypt and a manually installed Transcrypt to be used side by side selectively.hjOubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhjKubah}(h ]h"]h$]h&]h(]uh*jIhh,hhhh+hNubjJ)}(hIf you also use Numscrypt under Linux or OSX, use the MiniConda installer rather than *virtualenv*, as described in the Numscrypt documentation, since it will allow you to obtain the right version of NumPy.h]h>)}(hjh](hVIf you also use Numscrypt under Linux or OSX, use the MiniConda installer rather than }(hVIf you also use Numscrypt under Linux or OSX, use the MiniConda installer rather than hjubhI)}(h *virtualenv*h]h virtualenv}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubhl, as described in the Numscrypt documentation, since it will allow you to obtain the right version of NumPy.}(hl, as described in the Numscrypt documentation, since it will allow you to obtain the right version of NumPy.hjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhjubah}(h ]h"]h$]h&]h(]uh*jIhh,hhhh+hNubh>)}(hYou can test your installation as follows (replacing *transcrypt* by *run_transcrypt* if you installed manually rather than with pip):h](h5You can test your installation as follows (replacing }(h5You can test your installation as follows (replacing hjhhhNhNubhI)}(h *transcrypt*h]h transcrypt}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh by }(h by hjhhhNhNubhI)}(h*run_transcrypt*h]hrun_transcrypt}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh1 if you installed manually rather than with pip):}(h1 if you installed manually rather than with pip):hjhhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhh,hhubh)}(hhh](h)}(h[Go to directory *../Transcrypt-/transcrypt/development/automated_tests/transcrypt*h]h>)}(hjh](hGo to directory }(hGo to directory hjubhI)}(hK*../Transcrypt-/transcrypt/development/automated_tests/transcrypt*h]hI../Transcrypt-/transcrypt/development/automated_tests/transcrypt}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhjubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(hFrom the command prompt run *transcrypt -b -c -da autotest*. This will compile the autotests into a number of .js files and put them into the *__target__* subdirectory. Do NOT go to that directory (there's no need, stay where you went at point 4)h]h>)}(hjh](hFrom the command prompt run }(hFrom the command prompt run hjubhI)}(h*transcrypt -b -c -da autotest*h]htranscrypt -b -c -da autotest}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubhS. This will compile the autotests into a number of .js files and put them into the }(hS. This will compile the autotests into a number of .js files and put them into the hjubhI)}(h *__target__*h]h __target__}(hhhj1ubah}(h ]h"]h$]h&]h(]uh*hHhjubh^ subdirectory. Do NOT go to that directory (there’s no need, stay where you went at point 4)}(h\ subdirectory. Do NOT go to that directory (there's no need, stay where you went at point 4)hjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhjubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(hFrom the command prompt run *transcrypt -r -c autotest*. This will run the autotests with CPython creating file *autotest.html* that refers to the generated *autotest.js* fileh]h>)}(hjRh](hFrom the command prompt run }(hFrom the command prompt run hjTubhI)}(h*transcrypt -r -c autotest*h]htranscrypt -r -c autotest}(hhhj\ubah}(h ]h"]h$]h&]h(]uh*hHhjTubh9. This will run the autotests with CPython creating file }(h9. This will run the autotests with CPython creating file hjTubhI)}(h*autotest.html*h]h autotest.html}(hhhjoubah}(h ]h"]h$]h&]h(]uh*hHhjTubh that refers to the generated }(h that refers to the generated hjTubhI)}(h *autotest.js*h]h autotest.js}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjTubh file}(h filehjTubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhjPubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(hXOStart a http server from the command prompt by typing *python -m http.server*, or, dependent on your installation *python3 -m http.server*. In the address bar of your browser, type *localhost:8000/animals.html*. This will load the autotest, run it and compare the output with what was generated by CPython. It should report no errors h]h>)}(hXNStart a http server from the command prompt by typing *python -m http.server*, or, dependent on your installation *python3 -m http.server*. In the address bar of your browser, type *localhost:8000/animals.html*. This will load the autotest, run it and compare the output with what was generated by CPython. It should report no errorsh](h7Start a http server from the command prompt by typing }(h7Start a http server from the command prompt by typing hjubhI)}(h*python -m http.server*h]hpython -m http.server}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh%, or, dependent on your installation }(h%, or, dependent on your installation hjubhI)}(h*python3 -m http.server*h]hpython3 -m http.server}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh+. In the address bar of your browser, type }(h+. In the address bar of your browser, type hjubhI)}(h*localhost:8000/animals.html*h]hlocalhost:8000/animals.html}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh{. This will load the autotest, run it and compare the output with what was generated by CPython. It should report no errors}(h{. This will load the autotest, run it and compare the output with what was generated by CPython. It should report no errorshjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhjubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubeh}(h ]h"]h$]h&]h(]j6j7j8hj9j:uh*hhh,hhhh+hKubh>)}(h'To experiment with Transcrypt yourself:h]h'To experiment with Transcrypt yourself:}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hKhh,hhubh)}(hhh](h)}(h'Create a directory for your experimentsh]h>)}(hj h]h'Create a directory for your experiments}(hj hjubah}(h ]h"]h$]h&]h(]uh*h=hh+hK!hj ubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(h0Make your own thing there, e.g. *experiment1.py*h]h>)}(hj#h](h Make your own thing there, e.g. }(h Make your own thing there, e.g. hj%ubhI)}(h*experiment1.py*h]hexperiment1.py}(hhhj-ubah}(h ]h"]h$]h&]h(]uh*hHhj%ubeh}(h ]h"]h$]h&]h(]uh*h=hh+hK"hj!ubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(h(Compile with *transcrypt -b experiment1*h]h>)}(hjIh](h Compile with }(h Compile with hjKubhI)}(h*transcrypt -b experiment1*h]htranscrypt -b experiment1}(hhhjSubah}(h ]h"]h$]h&]h(]uh*hHhjKubeh}(h ]h"]h$]h&]h(]uh*h=hh+hK#hjGubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(hMake an HTML page that will load your code in the browser. Use the HTML file generated by the autotest as an example of how to do thath]h>)}(hjoh]hMake an HTML page that will load your code in the browser. Use the HTML file generated by the autotest as an example of how to do that}(hjohjqubah}(h ]h"]h$]h&]h(]uh*h=hh+hK$hjmubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(hALoad and run the HTML + JS in the same way as indicated earlier. h]h>)}(h@Load and run the HTML + JS in the same way as indicated earlier.h]h@Load and run the HTML + JS in the same way as indicated earlier.}(hjhjubah}(h ]h"]h$]h&]h(]uh*h=hh+hK%hjubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubeh}(h ]h"]h$]h&]h(]j6j7j8hj9j:uh*hhh,hhhh+hK!ubh>)}(h$You may also want to try the demo's.h]h&You may also want to try the demo’s.}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hK'hh,hhubh )}(hhh](h)}(h&Installation troubleshooting checklisth]h&Installation troubleshooting checklist}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hK*ubh)}(hhh](h)}(hTranscrypt was installed using *pip*, but *import transcrypt* fails. Transcrypt isn't a library but a compiler. Install and run it as described in this chapter.h]h>)}(hjh](hTranscrypt was installed using }(hTranscrypt was installed using hjubhI)}(h*pip*h]hpip}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh, but }(h, but hjubhI)}(h*import transcrypt*h]himport transcrypt}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubhe fails. Transcrypt isn’t a library but a compiler. Install and run it as described in this chapter.}(hc fails. Transcrypt isn't a library but a compiler. Install and run it as described in this chapter.hjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hK,hjubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(hX*Transcrypt reports an error containing the word 'java'. Transcrypt produces both prettyfied and minified JavaScript output. For the minification it makes use of the Google Closure Compiler, which is included in the distribution and requires Java to run. You can check proper installation of Java by typing the word *java* on the command line. This should give you a list of options: *Usage: java [-options] class []args...]* and so on. If you can't or won't install Java, you can run Transcrypt without minification by using the *-n* command line switch.h]h>)}(hjh](hX?Transcrypt reports an error containing the word ‘java’. Transcrypt produces both prettyfied and minified JavaScript output. For the minification it makes use of the Google Closure Compiler, which is included in the distribution and requires Java to run. You can check proper installation of Java by typing the word }(hX;Transcrypt reports an error containing the word 'java'. Transcrypt produces both prettyfied and minified JavaScript output. For the minification it makes use of the Google Closure Compiler, which is included in the distribution and requires Java to run. You can check proper installation of Java by typing the word hjubhI)}(h*java*h]hjava}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh> on the command line. This should give you a list of options: }(h> on the command line. This should give you a list of options: hjubhI)}(h)*Usage: java [-options] class []args...]*h]h'Usage: java [-options] class []args…]}(hhhj!ubah}(h ]h"]h$]h&]h(]uh*hHhjubhm and so on. If you can’t or won’t install Java, you can run Transcrypt without minification by using the }(hi and so on. If you can't or won't install Java, you can run Transcrypt without minification by using the hjubhI)}(h*-n*h]h-n}(hhhj4ubah}(h ]h"]h$]h&]h(]uh*hHhjubh command line switch.}(h command line switch.hjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hK-hjubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubh)}(hXThe static checker doesn't find all errors it could. The static checks, performed by the PyFlakes package that's part of the distribution, are of a 'light' variety. Style checks and false positives are avoided. The accent is on finding undefined identifiers and unused variables. h]h>)}(hXThe static checker doesn't find all errors it could. The static checks, performed by the PyFlakes package that's part of the distribution, are of a 'light' variety. Style checks and false positives are avoided. The accent is on finding undefined identifiers and unused variables.h]hXThe static checker doesn’t find all errors it could. The static checks, performed by the PyFlakes package that’s part of the distribution, are of a ‘light’ variety. Style checks and false positives are avoided. The accent is on finding undefined identifiers and unused variables.}(hjYhjWubah}(h ]h"]h$]h&]h(]uh*h=hh+hK.hjSubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hNubeh}(h ]h"]h$]h&]h(]j6j7j8hj9j:uh*hhjhhhh+hK,ubeh}(h ]&installation-troubleshooting-checklistah"]h$]&installation troubleshooting checklistah&]h(]uh*h hh,hhhh+hK*ubeh}(h ] installationah"]h$] installationah&]h(]uh*h hh hhhh+hKubh )}(hhh](h)}(hYour first Transcrypt programh]hYour first Transcrypt program}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hK1ubh>)}(hX9Open a command prompt in the *demos/hello* directory and type *transcrypt hello*. Then start a http server from the command prompt by typing *python -m http.server* or *python3 -m http.server*, dependent on your installation and type *localhost:8000/hello* in the address bar to load the result into your browser.h](hOpen a command prompt in the }(hOpen a command prompt in the hjhhhNhNubhI)}(h *demos/hello*h]h demos/hello}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh directory and type }(h directory and type hjhhhNhNubhI)}(h*transcrypt hello*h]htranscrypt hello}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh=. Then start a http server from the command prompt by typing }(h=. Then start a http server from the command prompt by typing hjhhhNhNubhI)}(h*python -m http.server*h]hpython -m http.server}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh or }(h or hjhhhNhNubhI)}(h*python3 -m http.server*h]hpython3 -m http.server}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh*, dependent on your installation and type }(h*, dependent on your installation and type hjhhhNhNubhI)}(h*localhost:8000/hello*h]hlocalhost:8000/hello}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh9 in the address bar to load the result into your browser.}(h9 in the address bar to load the result into your browser.hjhhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hK3hjhhubh>)}(hAfter clicking on both buttons a few times, take a look at *hello.html*. As you can see, eventhandlers are connected to the buttons exactly as you would do with JavaScript.h](h;After clicking on both buttons a few times, take a look at }(h;After clicking on both buttons a few times, take a look at hjhhhNhNubhI)}(h *hello.html*h]h hello.html}(hhhj ubah}(h ]h"]h$]h&]h(]uh*hHhjubhe. As you can see, eventhandlers are connected to the buttons exactly as you would do with JavaScript.}(he. As you can see, eventhandlers are connected to the buttons exactly as you would do with JavaScript.hjhhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hK6hjhhubh>)}(hThen look at *hello.py*. Note that JavaScript functions like document.getElementById can be called from Python exactly as you would call them from JavaScript, but with Python data.h](h Then look at }(h Then look at hj"hhhNhNubhI)}(h *hello.py*h]hhello.py}(hhhj+ubah}(h ]h"]h$]h&]h(]uh*hHhj"ubh. Note that JavaScript functions like document.getElementById can be called from Python exactly as you would call them from JavaScript, but with Python data.}(h. Note that JavaScript functions like document.getElementById can be called from Python exactly as you would call them from JavaScript, but with Python data.hj"hhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hK9hjhhubh>)}(hXThe minified JavaScript files *including the Transcrypt runtime* are only around 50kB. With non-trivial programs this overhead becomes negligible. Transcrypt applications in themselves don't need any external files. Of course you can use extensive JavaScript libraries served by content delivery networks as you normally would. But you can also make very compact stand alone applications. The most efficient thing to do is pack all functionality for a page in a single Transcrypt program. Note that the source can consist of many modules if needed and many callback entrypoints can be provided. But it is *one* stateful application, just like it would be on the desktop.h](hThe minified JavaScript files }(hThe minified JavaScript files hjDhhhNhNubhI)}(h"*including the Transcrypt runtime*h]h including the Transcrypt runtime}(hhhjMubah}(h ]h"]h$]h&]h(]uh*hHhjDubhX are only around 50kB. With non-trivial programs this overhead becomes negligible. Transcrypt applications in themselves don’t need any external files. Of course you can use extensive JavaScript libraries served by content delivery networks as you normally would. But you can also make very compact stand alone applications. The most efficient thing to do is pack all functionality for a page in a single Transcrypt program. Note that the source can consist of many modules if needed and many callback entrypoints can be provided. But it is }(hX are only around 50kB. With non-trivial programs this overhead becomes negligible. Transcrypt applications in themselves don't need any external files. Of course you can use extensive JavaScript libraries served by content delivery networks as you normally would. But you can also make very compact stand alone applications. The most efficient thing to do is pack all functionality for a page in a single Transcrypt program. Note that the source can consist of many modules if needed and many callback entrypoints can be provided. But it is hjDhhhNhNubhI)}(h*one*h]hone}(hhhj`ubah}(h ]h"]h$]h&]h(]uh*hHhjDubh< stateful application, just like it would be on the desktop.}(h< stateful application, just like it would be on the desktop.hjDhhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhj{ubh literal_block)}(hX]

Hello demo

...

...
h]hX]

Hello demo

...

...
}(hhhjubah}(h ]h"]h$]h&]h(]sourceO/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/demos/hello/hello.html xml:spacepreserveforcehighlight_args} linenostartKsuh*jhh+hK>hj{ubeh}(h ]id1ah"]literal-block-wrapperah$]h&]h(] literal_blockuh*jyhjhhhhhNubjz)}(hhh](j)}(hrIn hello.py, JavaScript function document.getElementById is called directly from Python, using plain Python valuesh]hrIn hello.py, JavaScript function document.getElementById is called directly from Python, using plain Python values}(hjhjubah}(h ]h"]h$]h&]h(]uh*j~hh+hKBhjubj)}(hXzfrom itertools import chain class SolarSystem: planets = [list (chain (planet, (index + 1,))) for index, planet in enumerate (( ('Mercury', 'hot', 2240), ('Venus', 'sulphurous', 6052), ('Earth', 'fertile', 6378), ('Mars', 'reddish', 3397), ('Jupiter', 'stormy', 71492), ('Saturn', 'ringed', 60268), ('Uranus', 'cold', 25559), ('Neptune', 'very cold', 24766) ))] lines = ( '{} is a {} planet', 'The radius of {} is {} km', '{} is planet nr. {} counting from the sun' ) def __init__ (self): self.lineIndex = 0 def greet (self): self.planet = self.planets [int (Math.random () * len (self.planets))] document.getElementById ('greet') .innerHTML = 'Hello {}'.format (self.planet [0]) self.explain () def explain (self): document.getElementById ('explain').innerHTML = ( self.lines [self.lineIndex] .format (self.planet [0], self.planet [self.lineIndex + 1]) ) self.lineIndex = (self.lineIndex + 1) % 3 solarSystem = SolarSystem () h]hXzfrom itertools import chain class SolarSystem: planets = [list (chain (planet, (index + 1,))) for index, planet in enumerate (( ('Mercury', 'hot', 2240), ('Venus', 'sulphurous', 6052), ('Earth', 'fertile', 6378), ('Mars', 'reddish', 3397), ('Jupiter', 'stormy', 71492), ('Saturn', 'ringed', 60268), ('Uranus', 'cold', 25559), ('Neptune', 'very cold', 24766) ))] lines = ( '{} is a {} planet', 'The radius of {} is {} km', '{} is planet nr. {} counting from the sun' ) def __init__ (self): self.lineIndex = 0 def greet (self): self.planet = self.planets [int (Math.random () * len (self.planets))] document.getElementById ('greet') .innerHTML = 'Hello {}'.format (self.planet [0]) self.explain () def explain (self): document.getElementById ('explain').innerHTML = ( self.lines [self.lineIndex] .format (self.planet [0], self.planet [self.lineIndex + 1]) ) self.lineIndex = (self.lineIndex + 1) % 3 solarSystem = SolarSystem () }(hhhjubah}(h ]h"]h$]h&]h(]sourceM/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/demos/hello/hello.pyjjjlinenosj}jKsuh*jhh+hKBhjubeh}(h ]id2ah"]jah$]h&]h(] literal_blockuh*jyhjhhhhhNubhs)}(h.. _command_line_switches:h]h}(h ]h"]h$]h&]h(]refidcommand-line-switchesuh*hrhKGhjhhhh+ubeh}(h ]your-first-transcrypt-programah"]h$]your first transcrypt programah&]h(]uh*h hh hhhh+hK1ubh )}(hhh](h)}(hAvailable command line switchesh]hAvailable command line switches}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hKJubh>)}(hThe available command line switches will be shown if you run transcrypt -h. They are specified in the source code of Transcrypt as follows:h]hThe available command line switches will be shown if you run transcrypt -h. They are specified in the source code of Transcrypt as follows:}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hKLhjhhubjz)}(hhh](j)}(hPTranscrypt command line switches as specified in module/orgs/transcrypt/utils.pyh]hPTranscrypt command line switches as specified in module/orgs/transcrypt/utils.py}(hjhjubah}(h ]h"]h$]h&]h(]uh*j~hh+hKOhj ubj)}(hX&class CommandArgs: def parse (self): self.argParser = ArgumentParser () self.argParser.add_argument ('source', nargs='?', help = ".py file containing source code of main module") self.argParser.add_argument ('-a', '--anno', help = "annotate target files that were compiled from Python with source file names and source line numbers", action = 'store_true') self.argParser.add_argument ('-am', '--alimod', help = "use aliasing for module paths", action = 'store_true') self.argParser.add_argument ('-b', '--build', help = "rebuild all target files from scratch", action = 'store_true') self.argParser.add_argument ('-c', '--complex', help = "enable complex number support, locally requires operator overloading", action = 'store_true') self.argParser.add_argument ('-d', '--docat', help = "enable __doc__ attributes. Apply sparsely, since it will make docstrings part of the generated code", action = 'store_true') self.argParser.add_argument ('-da', '--dassert', help = "debug: activate assertions", action = 'store_true') self.argParser.add_argument ('-dc', '--dcheck', help = "debug: perform lightweight consistency check", action = 'store_true') self.argParser.add_argument ('-de', '--dextex', help = "debug: show extended exception reports", action = 'store_true') self.argParser.add_argument ('-dl', '--dlog', help = "debug: log compiler messages to disk", action = 'store_true') self.argParser.add_argument ('-dm', '--dmap', help = "debug: dump human readable source map", action = 'store_true') self.argParser.add_argument ('-dn', '--dnostrip', help = "debug: no comment stripping of __core__ and __builtin__ in-line modules", action = 'store_true') self.argParser.add_argument ('-ds', '--dstat', help = "debug: validate static typing using annotations", action = 'store_true') self.argParser.add_argument ('-dt', '--dtree', help = "debug: dump syntax tree", action = 'store_true') self.argParser.add_argument ('-e', '--esv', nargs='?', help = "ecma script version of generated code, default = 6. The symbol __esv__ is added to the global symbol list, e.g. __esv7__.") self.argParser.add_argument ('-ec', '--ecom', help = "enable executable comments, seen as comments by CPython but as executable statements by Transcrypt", action = 'store_true') self.argParser.add_argument ('-f', '--fcall', help = "enable fastcall mechanism by default. You can also use __pragma__ ('fcal') and __pragma__ (\'nofcall\')", action = 'store_true') self.argParser.add_argument ('-g', '--gen', help = "enable generators and iterators. Disadvised, since it will result in a function call for each loop iteration. Preferably use __pragma__ ('gen') and __pragma__ ('nogen')", action = 'store_true') self.argParser.add_argument ('-i', '--iconv', help = "enable automatic conversion to iterable by default. Disadvised, since it will result in a type check for each for-loop. Preferably use __pragma__ ('iconv') and __pragma__ (\'noiconv\') to enable automatic conversion locally", action = 'store_true') self.argParser.add_argument ('-jc', '--jscall', help = "enable native JavaScript calls for Python methods. This is fast, but doesn't support bound method assignment, decorators and non-instance methods. Preferably use __pragma__ ('jscall') and __pragma__ ('nojscall') to enable native JavaScript calls locally", action = 'store_true') self.argParser.add_argument ('-jk', '--jskeys', help = "interpret {key: 'value'} as {'key': 'value'} and forbid {key (): 'value'}, as JavaScript does. Disadvised, since it's less flexible than the Python interpretation. Either follow Python semantics by using {'key': 'value'} explicitly if you want literal keys or use __pragma__ ('jskeys') and __pragma__ ('nojskeys') locally instead to make clear local deviation from Python semantics", action = 'store_true') self.argParser.add_argument ('-jm', '--jsmod', help = "give %% and %%= JavaScript rather than Python behaviour. Disadvised, since it deviates from the mathematical 'modulo' operator. Either follow Python semantics or use __pragma__ ('jsmod') and __pragma__ ('nojsmod') locally instead to make clear local deviation.", action = 'store_true') self.argParser.add_argument ('-k', '--kwargs', help = "enable keyword arguments by default. In general this is disadvised, use __pragma__ ('kwargs') and __pragma__('nokwargs') locally instead to prevent bloated code", action = 'store_true') self.argParser.add_argument ('-kc', '--keycheck', help = "enable checking for existence of dictionary keys. In general this is disadvised, use __pragma__ ('keycheck') and __pragma__('nokeycheck') locally instead to prevent bloated code", action = 'store_true') self.argParser.add_argument ('-l', '--license', help = "show license", action = 'store_true') self.argParser.add_argument ('-m', '--map', help = "generate source map", action = 'store_true') self.argParser.add_argument ('-n', '--nomin', help = "no minification", action = 'store_true') self.argParser.add_argument ('-o', '--opov', help = "enable operator overloading by default. In general this is disadvised, use __pragma__ ('opov') and __pragma__('noopov') locally instead to prevent slow code", action = 'store_true') self.argParser.add_argument ('-od', '--outdir', help = 'override output directory (default = __target__)') self.argParser.add_argument ('-p', '--parent', nargs = '?', help = "object that will hold application, default is window. Use -p .none to generate orphan application, e.g. for use in node.js") self.argParser.add_argument ('-r', '--run', help = "run source file rather than compiling it", action = 'store_true') self.argParser.add_argument ('-s', '--symbols', nargs ='?', help = "names, joined by $, separately passed to main module in __symbols__ variable") self.argParser.add_argument ('-sf', '--sform', help = "enable support for string formatting mini language", action = 'store_true') self.argParser.add_argument ('-t', '--tconv', help = "enable automatic conversion to truth value by default. Disadvised, since it will result in a conversion for each boolean. Preferably use __pragma__ ('tconv') and __pragma__ (\'notconv\') to enable automatic conversion locally", action = 'store_true') self.argParser.add_argument ('-u', '--unit', nargs='?', help = "compile to units rather than to monolithic application. Use -u .auto to autogenerate dynamically loadable native JavaScript modules, one per Python module. Use -u .run to generate the loader and the staticcally loadable runtime unit. Use -u .com to generate a statically loadable component unit.") self.argParser.add_argument ('-v', '--verbose', help = "show all messages", action = 'store_true') self.argParser.add_argument ('-x', '--x', help = "reserved for extended options") self.argParser.add_argument ('-xr', '--xreex', help = "re-export all imported names", action = 'store_true') self.argParser.add_argument ('-xg', '--xglobs', help = "allow use of the 'globals' function", action = 'store_true') self.argParser.add_argument ('-xp', '--xpath', nargs = '?', help = "additional module search paths, joined by $, #'s will be replaced by spaces") self.argParser.add_argument ('-xt', '--xtiny', help = "generate tiny version of runtime, a.o. lacking support for implicit and explicit operator overloading. Use only if generated code can be validated, since it will introduce semantic alterations in edge cases", action = 'store_true') self.argParser.add_argument ('-*', '--star', help = "Like it? Grow it! Go to GitHub and then click [* Star]", action = 'store_true') self.projectOptions = self.argParser.parse_args () .__dict__ self.__dict__.update (self.projectOptions) # Signal invalid switches def logAndExit (message): log (True, message) sys.exit (1) invalidCombi = 'Invalid combination of options' if not (self.license or self.star or self.source): logAndExit (self.argParser.format_usage () .capitalize ()) elif self.map and self.unit: logAndExit ('{}: -m / --map and -u / --unit'.format (invalidCombi)) elif self.parent and self.unit == '.com': logAndExit ('{}: -p / --parent and -u / --unit .com'.format (invalidCombi)) elif self.parent == '.export' and self.esv and int (self.esv) < 6: logAndExit ('{}: -p / --parent .export and -e / --esv < 6'.format (invalidCombi)) elif self.unit == '.auto' and self.esv and int (self.esv) < 6: logAndExit ('{}: -u / --unit .auto and -e / --esv < 6'.format (invalidCombi)) # Set dependent switches # (for future use) # Correcting line counts for source map global extraLines extraLines = [ # Make identifier __pragma__ known to static checker # It was only known in JavaScript from __core__.js, which the checker doesn't see # __ pragma__ ('') in JavaScript requires it to remain a function, as it was in the core # It can't be skipped, since it has to precede __pragma__ ('skip'), to make the checker accept that 'def __pragma__ (): pass', # Make __include__ known to the static checker '__pragma__ (\'skip\')', '__new__ = __include__ = 0', '__pragma__ (\'noskip\')', '' ] if commandArgs.dcheck else [] global nrOfExtraLines nrOfExtraLines = max (len (extraLines) - 1, 0) # Last line only serves to force linefeed extraLines = '\n'.join (extraLines) h]hX&class CommandArgs: def parse (self): self.argParser = ArgumentParser () self.argParser.add_argument ('source', nargs='?', help = ".py file containing source code of main module") self.argParser.add_argument ('-a', '--anno', help = "annotate target files that were compiled from Python with source file names and source line numbers", action = 'store_true') self.argParser.add_argument ('-am', '--alimod', help = "use aliasing for module paths", action = 'store_true') self.argParser.add_argument ('-b', '--build', help = "rebuild all target files from scratch", action = 'store_true') self.argParser.add_argument ('-c', '--complex', help = "enable complex number support, locally requires operator overloading", action = 'store_true') self.argParser.add_argument ('-d', '--docat', help = "enable __doc__ attributes. Apply sparsely, since it will make docstrings part of the generated code", action = 'store_true') self.argParser.add_argument ('-da', '--dassert', help = "debug: activate assertions", action = 'store_true') self.argParser.add_argument ('-dc', '--dcheck', help = "debug: perform lightweight consistency check", action = 'store_true') self.argParser.add_argument ('-de', '--dextex', help = "debug: show extended exception reports", action = 'store_true') self.argParser.add_argument ('-dl', '--dlog', help = "debug: log compiler messages to disk", action = 'store_true') self.argParser.add_argument ('-dm', '--dmap', help = "debug: dump human readable source map", action = 'store_true') self.argParser.add_argument ('-dn', '--dnostrip', help = "debug: no comment stripping of __core__ and __builtin__ in-line modules", action = 'store_true') self.argParser.add_argument ('-ds', '--dstat', help = "debug: validate static typing using annotations", action = 'store_true') self.argParser.add_argument ('-dt', '--dtree', help = "debug: dump syntax tree", action = 'store_true') self.argParser.add_argument ('-e', '--esv', nargs='?', help = "ecma script version of generated code, default = 6. The symbol __esv__ is added to the global symbol list, e.g. __esv7__.") self.argParser.add_argument ('-ec', '--ecom', help = "enable executable comments, seen as comments by CPython but as executable statements by Transcrypt", action = 'store_true') self.argParser.add_argument ('-f', '--fcall', help = "enable fastcall mechanism by default. You can also use __pragma__ ('fcal') and __pragma__ (\'nofcall\')", action = 'store_true') self.argParser.add_argument ('-g', '--gen', help = "enable generators and iterators. Disadvised, since it will result in a function call for each loop iteration. Preferably use __pragma__ ('gen') and __pragma__ ('nogen')", action = 'store_true') self.argParser.add_argument ('-i', '--iconv', help = "enable automatic conversion to iterable by default. Disadvised, since it will result in a type check for each for-loop. Preferably use __pragma__ ('iconv') and __pragma__ (\'noiconv\') to enable automatic conversion locally", action = 'store_true') self.argParser.add_argument ('-jc', '--jscall', help = "enable native JavaScript calls for Python methods. This is fast, but doesn't support bound method assignment, decorators and non-instance methods. Preferably use __pragma__ ('jscall') and __pragma__ ('nojscall') to enable native JavaScript calls locally", action = 'store_true') self.argParser.add_argument ('-jk', '--jskeys', help = "interpret {key: 'value'} as {'key': 'value'} and forbid {key (): 'value'}, as JavaScript does. Disadvised, since it's less flexible than the Python interpretation. Either follow Python semantics by using {'key': 'value'} explicitly if you want literal keys or use __pragma__ ('jskeys') and __pragma__ ('nojskeys') locally instead to make clear local deviation from Python semantics", action = 'store_true') self.argParser.add_argument ('-jm', '--jsmod', help = "give %% and %%= JavaScript rather than Python behaviour. Disadvised, since it deviates from the mathematical 'modulo' operator. Either follow Python semantics or use __pragma__ ('jsmod') and __pragma__ ('nojsmod') locally instead to make clear local deviation.", action = 'store_true') self.argParser.add_argument ('-k', '--kwargs', help = "enable keyword arguments by default. In general this is disadvised, use __pragma__ ('kwargs') and __pragma__('nokwargs') locally instead to prevent bloated code", action = 'store_true') self.argParser.add_argument ('-kc', '--keycheck', help = "enable checking for existence of dictionary keys. In general this is disadvised, use __pragma__ ('keycheck') and __pragma__('nokeycheck') locally instead to prevent bloated code", action = 'store_true') self.argParser.add_argument ('-l', '--license', help = "show license", action = 'store_true') self.argParser.add_argument ('-m', '--map', help = "generate source map", action = 'store_true') self.argParser.add_argument ('-n', '--nomin', help = "no minification", action = 'store_true') self.argParser.add_argument ('-o', '--opov', help = "enable operator overloading by default. In general this is disadvised, use __pragma__ ('opov') and __pragma__('noopov') locally instead to prevent slow code", action = 'store_true') self.argParser.add_argument ('-od', '--outdir', help = 'override output directory (default = __target__)') self.argParser.add_argument ('-p', '--parent', nargs = '?', help = "object that will hold application, default is window. Use -p .none to generate orphan application, e.g. for use in node.js") self.argParser.add_argument ('-r', '--run', help = "run source file rather than compiling it", action = 'store_true') self.argParser.add_argument ('-s', '--symbols', nargs ='?', help = "names, joined by $, separately passed to main module in __symbols__ variable") self.argParser.add_argument ('-sf', '--sform', help = "enable support for string formatting mini language", action = 'store_true') self.argParser.add_argument ('-t', '--tconv', help = "enable automatic conversion to truth value by default. Disadvised, since it will result in a conversion for each boolean. Preferably use __pragma__ ('tconv') and __pragma__ (\'notconv\') to enable automatic conversion locally", action = 'store_true') self.argParser.add_argument ('-u', '--unit', nargs='?', help = "compile to units rather than to monolithic application. Use -u .auto to autogenerate dynamically loadable native JavaScript modules, one per Python module. Use -u .run to generate the loader and the staticcally loadable runtime unit. Use -u .com to generate a statically loadable component unit.") self.argParser.add_argument ('-v', '--verbose', help = "show all messages", action = 'store_true') self.argParser.add_argument ('-x', '--x', help = "reserved for extended options") self.argParser.add_argument ('-xr', '--xreex', help = "re-export all imported names", action = 'store_true') self.argParser.add_argument ('-xg', '--xglobs', help = "allow use of the 'globals' function", action = 'store_true') self.argParser.add_argument ('-xp', '--xpath', nargs = '?', help = "additional module search paths, joined by $, #'s will be replaced by spaces") self.argParser.add_argument ('-xt', '--xtiny', help = "generate tiny version of runtime, a.o. lacking support for implicit and explicit operator overloading. Use only if generated code can be validated, since it will introduce semantic alterations in edge cases", action = 'store_true') self.argParser.add_argument ('-*', '--star', help = "Like it? Grow it! Go to GitHub and then click [* Star]", action = 'store_true') self.projectOptions = self.argParser.parse_args () .__dict__ self.__dict__.update (self.projectOptions) # Signal invalid switches def logAndExit (message): log (True, message) sys.exit (1) invalidCombi = 'Invalid combination of options' if not (self.license or self.star or self.source): logAndExit (self.argParser.format_usage () .capitalize ()) elif self.map and self.unit: logAndExit ('{}: -m / --map and -u / --unit'.format (invalidCombi)) elif self.parent and self.unit == '.com': logAndExit ('{}: -p / --parent and -u / --unit .com'.format (invalidCombi)) elif self.parent == '.export' and self.esv and int (self.esv) < 6: logAndExit ('{}: -p / --parent .export and -e / --esv < 6'.format (invalidCombi)) elif self.unit == '.auto' and self.esv and int (self.esv) < 6: logAndExit ('{}: -u / --unit .auto and -e / --esv < 6'.format (invalidCombi)) # Set dependent switches # (for future use) # Correcting line counts for source map global extraLines extraLines = [ # Make identifier __pragma__ known to static checker # It was only known in JavaScript from __core__.js, which the checker doesn't see # __ pragma__ ('') in JavaScript requires it to remain a function, as it was in the core # It can't be skipped, since it has to precede __pragma__ ('skip'), to make the checker accept that 'def __pragma__ (): pass', # Make __include__ known to the static checker '__pragma__ (\'skip\')', '__new__ = __include__ = 0', '__pragma__ (\'noskip\')', '' ] if commandArgs.dcheck else [] global nrOfExtraLines nrOfExtraLines = max (len (extraLines) - 1, 0) # Last line only serves to force linefeed extraLines = '\n'.join (extraLines) }(hhhjubah}(h ]h"]h$]h&]h(]sourceX/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/modules/org/transcrypt/utils.pyjjjj}jKsuh*jhh+hKOhj ubeh}(h ]id3ah"]jah$]h&]h(] literal_blockuh*jyhjhhhhhNubh>)}(hXqIf static checking is enabled, insert dummy definitions of global JavaScript variables between :ref:`__pragma__ ('skip') and __pragma__ ('noskip') ` to prevent needless complaints of the checker. The static checks are geared towards avoiding false alarms, and mainly check undefined names and unused variables. Style checks are deliberately avoided.h](h_If static checking is enabled, insert dummy definitions of global JavaScript variables between }(h_If static checking is enabled, insert dummy definitions of global JavaScript variables between hj7hhhNhNubh pending_xref)}(hI:ref:`__pragma__ ('skip') and __pragma__ ('noskip') `h]h inline)}(hjDh]h5__pragma__ (‘skip’) and __pragma__ (‘noskip’)}(hhhjHubah}(h ]h"](xrefstdstd-refeh$]h&]h(]uh*jFhjBubah}(h ]h"]h$]h&]h(]refdocinstallation_use refdomainjSreftyperef refexplicitrefwarn reftargetskipping_fragmentsuh*j@hh+hKThj7ubh to prevent needless complaints of the checker. The static checks are geared towards avoiding false alarms, and mainly check undefined names and unused variables. Style checks are deliberately avoided.}(h to prevent needless complaints of the checker. The static checks are geared towards avoiding false alarms, and mainly check undefined names and unused variables. Style checks are deliberately avoided.hj7hhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKThjhhubeh}(h ](available-command-line-switchesjeh"]h$](available command line switchescommand_line_switcheseh&]h(]uh*h hh hhhh+hKJexpect_referenced_by_name}jxjsexpect_referenced_by_id}jjsubh )}(hhh](h)}(hCompiling to JavaScript 6h]hCompiling to JavaScript 6}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hKWubh>)}(hX`Transcrypt generates JavaScript 6, that is by default minimized by the Google Closure compiler. Since multilevel sourcemaps are provided, the minified code can be easily debugged, because it directly links back to the original Python sourcecode. Using the *-n* command line switch turns off minification and results in human readable JavaScript output.h](hXTranscrypt generates JavaScript 6, that is by default minimized by the Google Closure compiler. Since multilevel sourcemaps are provided, the minified code can be easily debugged, because it directly links back to the original Python sourcecode. Using the }(hXTranscrypt generates JavaScript 6, that is by default minimized by the Google Closure compiler. Since multilevel sourcemaps are provided, the minified code can be easily debugged, because it directly links back to the original Python sourcecode. Using the hjhhhNhNubhI)}(h*-n*h]h-n}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh\ command line switch turns off minification and results in human readable JavaScript output.}(h\ command line switch turns off minification and results in human readable JavaScript output.hjhhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKYhjhhubeh}(h ]compiling-to-javascript-6ah"]h$]compiling to javascript 6ah&]h(]uh*h hh hhhh+hKWubh )}(hhh](h)}(hCompiling for node.jsh]hCompiling for node.js}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hK\ubh>)}(hX6Transcrypt will allow you to target *node.js* while writing your server code in Python. This opens up the exploding world of node.js libraries from your favorite programming language. In the *demo/nodejs_demo* subdirectory of the installation, you'll find the following trivial example of a node.js server app:h](h$Transcrypt will allow you to target }(h$Transcrypt will allow you to target hjhhhNhNubhI)}(h *node.js*h]hnode.js}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh while writing your server code in Python. This opens up the exploding world of node.js libraries from your favorite programming language. In the }(h while writing your server code in Python. This opens up the exploding world of node.js libraries from your favorite programming language. In the hjhhhNhNubhI)}(h*demo/nodejs_demo*h]hdemo/nodejs_demo}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubhg subdirectory of the installation, you’ll find the following trivial example of a node.js server app:}(he subdirectory of the installation, you'll find the following trivial example of a node.js server app:hjhhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hK^hjhhubjz)}(hhh](j)}(hlUsing node.js from Transcrypt is trivial, including the use of 'require' to tap into a vast set of librariesh]hpUsing node.js from Transcrypt is trivial, including the use of ‘require’ to tap into a vast set of libraries}(hjhjubah}(h ]h"]h$]h&]h(]uh*j~hh+hKbhjubj)}(hX# Compile with p. command line switch (see docs). import time http = require ('http') class Demo: texts = ( 'Welcome to the world of node.js', 'You can have your cake and eat it', 'Use node\'s ecosystem while programming in Python', 'Using node.js from Transcrypt is easy', 'Take a Python ride into the node.js world' ) def __init__ (self, port): print ('Demo server started on port', port) self.server = http.createServer (self.serve) self.server.listen (port) self.oldIndex = 0 self.newIndex = 0 self.count = 0 def serve (self, request, response): time.__adapt__ (request) response.writeHead (200) print ('Serving page', self.count) self.count += 1 while self.newIndex == self.oldIndex: self.newIndex = int (Math.random () * len (self.texts)) self.oldIndex = self.newIndex response.end ('

{}

{}

'.format ( self.texts [self.newIndex], time.localtime () )) demo = Demo (process.argv [2]) #This is where node puts its command line params h]hX# Compile with p. command line switch (see docs). import time http = require ('http') class Demo: texts = ( 'Welcome to the world of node.js', 'You can have your cake and eat it', 'Use node\'s ecosystem while programming in Python', 'Using node.js from Transcrypt is easy', 'Take a Python ride into the node.js world' ) def __init__ (self, port): print ('Demo server started on port', port) self.server = http.createServer (self.serve) self.server.listen (port) self.oldIndex = 0 self.newIndex = 0 self.count = 0 def serve (self, request, response): time.__adapt__ (request) response.writeHead (200) print ('Serving page', self.count) self.count += 1 while self.newIndex == self.oldIndex: self.newIndex = int (Math.random () * len (self.texts)) self.oldIndex = self.newIndex response.end ('

{}

{}

'.format ( self.texts [self.newIndex], time.localtime () )) demo = Demo (process.argv [2]) #This is where node puts its command line params }(hhhjubah}(h ]h"]h$]h&]h(]sourceY/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/demos/nodejs_demo/nodejs_demo.pyjjjj}jKsuh*jhh+hKbhjubeh}(h ]id4ah"]jah$]h&]h(] literal_blockuh*jyhjhhhhhNubh>)}(h(Follow the steps below to run this demo:h]h(Follow the steps below to run this demo:}(hj,hj*hhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hKfhjhhubh bullet_list)}(hhh](h)}(h)Install node.js from *https://nodejs.org*h]h>)}(hj?h](hInstall node.js from }(hInstall node.js from hjAubhI)}(h*https://nodejs.org*h]hhttps://nodejs.org}(hhhjIubah}(h ]h"]h$]h&]h(]uh*hHhjAubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhhj=ubah}(h ]h"]h$]h&]h(]uh*hhj:hhhh+hNubh)}(hOpen a node.js command prompth]h>)}(hjeh]hOpen a node.js command prompt}(hjehjgubah}(h ]h"]h$]h&]h(]uh*h=hh+hKihjcubah}(h ]h"]h$]h&]h(]uh*hhj:hhhh+hNubh)}(h&Go to the *demo/nodejs_demo* directoryh]h>)}(hj|h](h Go to the }(h Go to the hj~ubhI)}(h*demo/nodejs_demo*h]hdemo/nodejs_demo}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhj~ubh directory}(h directoryhj~ubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKjhjzubah}(h ]h"]h$]h&]h(]uh*hhj:hhhh+hNubh)}(hxCompile the demo with *transcrypt -b -p .none nodejs_demo*, to generate an orphan module rather than a child of *window*h]h>)}(hjh](hCompile the demo with }(hCompile the demo with hjubhI)}(h$*transcrypt -b -p .none nodejs_demo*h]h"transcrypt -b -p .none nodejs_demo}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh6, to generate an orphan module rather than a child of }(h6, to generate an orphan module rather than a child of hjubhI)}(h*window*h]hwindow}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKkhjubah}(h ]h"]h$]h&]h(]uh*hhj:hhhh+hNubh)}(h-Go to *demo/nodejs_demo/__target__* directoryh]h>)}(hjh](hGo to }(hGo to hjubhI)}(h*demo/nodejs_demo/__target__*h]hdemo/nodejs_demo/__target__}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubh directory}(h directoryhjubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKlhjubah}(h ]h"]h$]h&]h(]uh*hhj:hhhh+hNubh)}(hType *node nodejs_demo.js*h]h>)}(hj h](hType }(hType hj ubhI)}(h*node nodejs_demo.js*h]hnode nodejs_demo.js}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhj ubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKmhj ubah}(h ]h"]h$]h&]h(]uh*hhj:hhhh+hNubh)}(h;In your browser, view the result at *http://localhost:8080*h]h>)}(hj1h](h$In your browser, view the result at }(h$In your browser, view the result at hj3ubhI)}(h*http://localhost:8080*h]hhttp://localhost:8080}(hhhj;ubah}(h ]h"]h$]h&]h(]uh*hHhj3ubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKnhj/ubah}(h ]h"]h$]h&]h(]uh*hhj:hhhh+hNubh)}(h\Repeatedly reload the page to see the text change (Google Chrome may actually reload twice) h]h>)}(h[Repeatedly reload the page to see the text change (Google Chrome may actually reload twice)h]h[Repeatedly reload the page to see the text change (Google Chrome may actually reload twice)}(hj[hjYubah}(h ]h"]h$]h&]h(]uh*h=hh+hKohjUubah}(h ]h"]h$]h&]h(]uh*hhj:hhhh+hNubeh}(h ]h"]h$]h&]h(]bullet-uh*j8hh+hKhhjhhubeh}(h ]compiling-for-node-jsah"]h$]compiling for node.jsah&]h(]uh*h hh hhhh+hK\ubh )}(hhh](h)}(h*Using sourcemaps and annotated target codeh]h*Using sourcemaps and annotated target code}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhj}hhhh+hKrubh )}(hhh](h)}(h Sourcemapsh]h Sourcemaps}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hKuubh>)}(hX[Sourcemaps enable debugging from the original Python source code rather then from the generated JavaScript. Transcrypt supports the use of single- and multi-level sourcemaps, using the *-m* switch. This means that you can source-level debug both non-minified and minified JavaScript target code. Sourcemaps are routinely tested for Google Chrome only, both under Windows and Linux, but they also have been observed to work for Firefox. Combined with the high readability of the JavaScript code generated by Transcrypt, this enables efficient debugging for real-world projects consisting of many modules.h](hSourcemaps enable debugging from the original Python source code rather then from the generated JavaScript. Transcrypt supports the use of single- and multi-level sourcemaps, using the }(hSourcemaps enable debugging from the original Python source code rather then from the generated JavaScript. Transcrypt supports the use of single- and multi-level sourcemaps, using the hjhhhNhNubhI)}(h*-m*h]h-m}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubhX switch. This means that you can source-level debug both non-minified and minified JavaScript target code. Sourcemaps are routinely tested for Google Chrome only, both under Windows and Linux, but they also have been observed to work for Firefox. Combined with the high readability of the JavaScript code generated by Transcrypt, this enables efficient debugging for real-world projects consisting of many modules.}(hX switch. This means that you can source-level debug both non-minified and minified JavaScript target code. Sourcemaps are routinely tested for Google Chrome only, both under Windows and Linux, but they also have been observed to work for Firefox. Combined with the high readability of the JavaScript code generated by Transcrypt, this enables efficient debugging for real-world projects consisting of many modules.hjhhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKvhjhhubeh}(h ] sourcemapsah"]h$] sourcemapsah&]h(]uh*h hj}hhhh+hKuubh )}(hhh](h)}(hAnnotated target codeh]hAnnotated target code}(hjhjhhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjhhhh+hKyubh>)}(hXKIn addition to generating sourcemaps, you can use the *-a* switch to annotate non-minified JavaScript files with comments, referring to the original Python file names and line numbers. So even if your browser doesn't support sourcemaps, it's easy to find back the original Python source code location from any JavaScript statement.h](h6In addition to generating sourcemaps, you can use the }(h6In addition to generating sourcemaps, you can use the hjhhhNhNubhI)}(h*-a*h]xh-a}(hhhjubah}(h ]h"]h$]h&]h(]uh*hHhjubhX switch to annotate non-minified JavaScript files with comments, referring to the original Python file names and line numbers. So even if your browser doesn’t support sourcemaps, it’s easy to find back the original Python source code location from any JavaScript statement.}(hX switch to annotate non-minified JavaScript files with comments, referring to the original Python file names and line numbers. So even if your browser doesn't support sourcemaps, it's easy to find back the original Python source code location from any JavaScript statement.hjhhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKzhjhhubjz)}(hhh](j)}(h"Annotated target code for hello.pyh]h"Annotated target code for hello.py}(hj hjubah}(h ]h"]h$]h&]h(]uh*j~hh+hK|hjubj)}(hXU // ============ Source: D:/activ_tosh/geatec/transcrypt/transcrypt/demos/hello/hello.py ============ /* 000001 */ (function () { /* 000001 */ var chain = __init__ (__world__.itertools).chain; /* 000003 */ var SolarSystem = __class__ ('SolarSystem', [object], { /* 000021 */ get __init__ () {return __get__ (this, function (self) { /* 000022 */ self.lineIndex = 0; /* 000022 */ });}, /* 000024 */ get greet () {return __get__ (this, function (self) { /* 000025 */ self.planet = self.planets [int (Math.random () * len (self.planets))]; /* 000026 */ document.getElementById ('greet').innerHTML = 'Hello {}'.format (self.planet [0]); /* 000027 */ self.explain (); /* 000027 */ });}, /* 000029 */ get explain () {return __get__ (this, function (self) { /* 000031 */ document.getElementById ('explain').innerHTML = self.lines [self.lineIndex].format (self.planet [0], self.planet [self.lineIndex + 1]); /* 000033 */ self.lineIndex = (self.lineIndex + 1) % 3; /* 000033 */ });} /* 000033 */ }); /* 000004 */ SolarSystem.planets = function () { /* 000004 */ var __accu0__ = []; /* 000004 */ var __iter0__ = enumerate (tuple ([tuple (['Mercury', 'hot', 2240]), tuple (['Venus', 'sulphurous', 6052]), tuple (['Earth', 'fertile', 6378]), tuple (['Mars', 'reddish', 3397]), tuple (['Jupiter', 'stormy', 71492]), tuple (['Saturn', 'ringed', 60268]), tuple (['Uranus', 'cold', 25559]), tuple (['Neptune', 'very cold', 24766])])); /* 000004 */ for (var __index0__ = 0; __index0__ < __iter0__.length; __index0__++) { /* 000012 */ var __left0__ = __iter0__ [__index0__]; /* 000012 */ var index = __left0__ [0]; /* 000012 */ var planet = __left0__ [1]; /* 000004 */ __accu0__.append (chain (planet, tuple ([index + 1]))); /* 000004 */ } /* 000004 */ return __accu0__; /* 000004 */ } (); /* 000015 */ SolarSystem.lines = tuple (['{} is a {} planet', 'The radius of {} is {} km', '{} is planet nr. {} counting from the sun']); /* 000035 */ var solarSystem = SolarSystem (); /* 000035 */ __pragma__ ('' + /* 000035 */ 'itertools' + /* 000035 */ '') /* 000035 */ __pragma__ ('') /* 000035 */ __all__.SolarSystem = SolarSystem; /* 000035 */ __all__.solarSystem = solarSystem; /* 000035 */ __pragma__ ('') /* 000035 */ }) (); /* 000035 */ return __all__; h]hXU // ============ Source: D:/activ_tosh/geatec/transcrypt/transcrypt/demos/hello/hello.py ============ /* 000001 */ (function () { /* 000001 */ var chain = __init__ (__world__.itertools).chain; /* 000003 */ var SolarSystem = __class__ ('SolarSystem', [object], { /* 000021 */ get __init__ () {return __get__ (this, function (self) { /* 000022 */ self.lineIndex = 0; /* 000022 */ });}, /* 000024 */ get greet () {return __get__ (this, function (self) { /* 000025 */ self.planet = self.planets [int (Math.random () * len (self.planets))]; /* 000026 */ document.getElementById ('greet').innerHTML = 'Hello {}'.format (self.planet [0]); /* 000027 */ self.explain (); /* 000027 */ });}, /* 000029 */ get explain () {return __get__ (this, function (self) { /* 000031 */ document.getElementById ('explain').innerHTML = self.lines [self.lineIndex].format (self.planet [0], self.planet [self.lineIndex + 1]); /* 000033 */ self.lineIndex = (self.lineIndex + 1) % 3; /* 000033 */ });} /* 000033 */ }); /* 000004 */ SolarSystem.planets = function () { /* 000004 */ var __accu0__ = []; /* 000004 */ var __iter0__ = enumerate (tuple ([tuple (['Mercury', 'hot', 2240]), tuple (['Venus', 'sulphurous', 6052]), tuple (['Earth', 'fertile', 6378]), tuple (['Mars', 'reddish', 3397]), tuple (['Jupiter', 'stormy', 71492]), tuple (['Saturn', 'ringed', 60268]), tuple (['Uranus', 'cold', 25559]), tuple (['Neptune', 'very cold', 24766])])); /* 000004 */ for (var __index0__ = 0; __index0__ < __iter0__.length; __index0__++) { /* 000012 */ var __left0__ = __iter0__ [__index0__]; /* 000012 */ var index = __left0__ [0]; /* 000012 */ var planet = __left0__ [1]; /* 000004 */ __accu0__.append (chain (planet, tuple ([index + 1]))); /* 000004 */ } /* 000004 */ return __accu0__; /* 000004 */ } (); /* 000015 */ SolarSystem.lines = tuple (['{} is a {} planet', 'The radius of {} is {} km', '{} is planet nr. {} counting from the sun']); /* 000035 */ var solarSystem = SolarSystem (); /* 000035 */ __pragma__ ('' + /* 000035 */ 'itertools' + /* 000035 */ '') /* 000035 */ __pragma__ ('') /* 000035 */ __all__.SolarSystem = SolarSystem; /* 000035 */ __all__.solarSystem = solarSystem; /* 000035 */ __pragma__ ('') /* 000035 */ }) (); /* 000035 */ return __all__; }(hhhj ubah}(h ]h"]h$]h&]h(]sourceP/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/docs/code/hello_anno.jsjjjj}jKsuh*jhh+hK|hjubeh}(h ]id5ah"]jah$]h&]h(] literal_blockuh*jyhjhhhhhNubh>)}(hSource code annotation only happens for Python sources, not for JavaScript-only modules, that have a trivial correspondence between non-minified target code and source code.h]hSource code annotation only happens for Python sources, not for JavaScript-only modules, that have a trivial correspondence between non-minified target code and source code.}(hj( hj& hhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hKhjhhubeh}(h ]annotated-target-codeah"]h$]annotated target codeah&]h(]uh*h hj}hhhh+hKyubeh}(h ]*using-sourcemaps-and-annotated-target-codeah"]h$]*using sourcemaps and annotated target codeah&]h(]uh*h hh hhhh+hKrubh )}(hhh](h)}(hStatic type validationh]hStatic type validation}(hjI hjG hhhNhNubah}(h ]h"]h$]h&]h(]uh*hhjD hhhh+hKubh>)}(hXStatic type validation is both a powerful method to catch a variety of bugs and a way to add clear, automatically checked documentation to your source code. Transcrypt includes an experimental version of `Jukka Lehtosalo's mypy static type validator `_ This validator uses :raw-html:`type hints` to rigorously cross-check correct use of datatypes all through your application. To activate static type validation use the *-ds* switch. You can combine static type validation with lightweight consistency checking using both the *-ds* and *-dc* switches.h](hStatic type validation is both a powerful method to catch a variety of bugs and a way to add clear, automatically checked documentation to your source code. Transcrypt includes an experimental version of }(hStatic type validation is both a powerful method to catch a variety of bugs and a way to add clear, automatically checked documentation to your source code. Transcrypt includes an experimental version of hjU hhhNhNubh^)}(hG`Jukka Lehtosalo's mypy static type validator `_h]h.Jukka Lehtosalo’s mypy static type validator}(h,Jukka Lehtosalo's mypy static type validatorhj^ ubah}(h ]h"]h$]h&]h(]name,Jukka Lehtosalo's mypy static type validatorhphttp://mypy-lang.org/uh*h]hjU ubhs)}(h h]h}(h ],jukka-lehtosalo-s-mypy-static-type-validatorah"]h$],jukka lehtosalo's mypy static type validatorah&]h(]refurijo uh*hrhKhjU ubh This validator uses }(h This validator uses hjU hhhNhNubh raw)}(h^:raw-html:`type hints`h]hRtype hints}(hhhj ubah}(h ]h"]raw-htmlah$]h&]h(]formathtmljjuh*j hh+hKhjU ubh} to rigorously cross-check correct use of datatypes all through your application. To activate static type validation use the }(h} to rigorously cross-check correct use of datatypes all through your application. To activate static type validation use the hjU hhhNhNubhI)}(h*-ds*h]h-ds}(hhhj ubah}(h ]h"]h$]h&]h(]uh*hHhjU ubhe switch. You can combine static type validation with lightweight consistency checking using both the }(he switch. You can combine static type validation with lightweight consistency checking using both the hjU hhhNhNubhI)}(h*-ds*h]h-ds}(hhhj ubah}(h ]h"]h$]h&]h(]uh*hHhjU ubh and }(h and hjU hhhNhNubhI)}(h*-dc*h]h-dc}(hhhj ubah}(h ]h"]h$]h&]h(]uh*hHhjU ubh switches.}(h switches.hjU hhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhjD hhubh>)}(hBelow is an example of code with type hints and deliberate inconsistencies, and the output of both the static type validator and the lightweight consistency checker. As can be seen, many errors can be caught in this way.h]hBelow is an example of code with type hints and deliberate inconsistencies, and the output of both the static type validator and the lightweight consistency checker. As can be seen, many errors can be caught in this way.}(hj hj hhhNhNubah}(h ]h"]h$]h&]h(]uh*h=hh+hKhjD hhubjz)}(hhh](j)}(h)manual_tests/static_types/static_types.pyh]h)manual_tests/static_types/static_types.py}(hj hj ubah}(h ]h"]h$]h&]h(]uh*j~hh+hKhj ubj)}(hX# from org.transcrypt.stubs.browser import __pragma__ from typing import Iterator #, List, Dict, ClassVar import mod1 import mod2 testVar: int = 3.5 def fib (n: int) -> Iterator [int]: a, b = 0, 1 while a < n: # yield a a, b = b, a + b return 3 def add (a: int, b: int) -> None: return a + b class A: def __init__ (self) -> None: pass def test (self) -> None: return 'test' ''' __pragma__ ('ifdef', '__undefined__') # Needed because Transcrypt imports are compile time if '__undefined__' in __symbols__: # Needed because CPython doesn't understand pragmas # Variable annotations aList: List [int] = [] aString: str # Note: no initial value! class aClass: aClassVar: ClassVar [Dict [str, int]] = {} aList = [1.1, 2.2] aString = 1000 aClass.aClassVar = {'aString', 3.14} __pragma__ ('endif') '''h]hX# from org.transcrypt.stubs.browser import __pragma__ from typing import Iterator #, List, Dict, ClassVar import mod1 import mod2 testVar: int = 3.5 def fib (n: int) -> Iterator [int]: a, b = 0, 1 while a < n: # yield a a, b = b, a + b return 3 def add (a: int, b: int) -> None: return a + b class A: def __init__ (self) -> None: pass def test (self) -> None: return 'test' ''' __pragma__ ('ifdef', '__undefined__') # Needed because Transcrypt imports are compile time if '__undefined__' in __symbols__: # Needed because CPython doesn't understand pragmas # Variable annotations aList: List [int] = [] aString: str # Note: no initial value! class aClass: aClassVar: ClassVar [Dict [str, int]] = {} aList = [1.1, 2.2] aString = 1000 aClass.aClassVar = {'aString', 3.14} __pragma__ ('endif') '''}(hhhj ubah}(h ]h"]h$]h&]h(]sourcen/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.pyjjjjj}jKsuh*jhh+hKhj ubeh}(h ]id6ah"]jah$]h&]h(] literal_blockuh*jyhjD hhhhhNubjz)}(hhh](j)}(h!manual_tests/static_types/mod1.pyh]h!manual_tests/static_types/mod1.py}(hj hj ubah}(h ]h"]h$]h&]h(]uh*j~hh+hKhj ubj)}(hGdef test (i: int) -> int: a = 3 a = 4.5 return str (i) h]hGdef test (i: int) -> int: a = 3 a = 4.5 return str (i) }(hhhj" ubah}(h ]h"]h$]h&]h(]sourcef/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.pyjjjjj}jKsuh*jhh+hKhj ubeh}(h ]id7ah"]jah$]h&]h(] literal_blockuh*jyhjD hhhhhNubjz)}(hhh](j)}(h*manual_tests/static_types/mod2/__init__.pyh]h*manual_tests/static_types/mod2/__init__.py}(hj@ hj> ubah}(h ]h"]h$]h&]h(]uh*j~hh+hKhj; ubj)}(h+def test (i: str) -> str: return 3 h]h+def test (i: str) -> str: return 3 }(hhhjL ubah}(h ]h"]h$]h&]h(]sourceo/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod2/__init__.pyjjjjj}jKsuh*jhh+hKhj; ubeh}(h ]id8ah"]jah$]h&]h(] literal_blockuh*jyhjD hhhhhNubjz)}(hhh](j)}(hKResults of the static type validation and the lightweight consistency checkh]hKResults of the static type validation and the lightweight consistency check}(hjj hjh ubah}(h ]h"]h$]h&]h(]uh*j~hh+hKhje ubj)}(hX Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.9.0 Copyright (C) Geatec Engineering. License: Apache 2.0 Performing static type validation on application: //home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/modules/org/transcrypt/__runtime__.py The following inconsistencies were found: Success: no issues found in 1 source file Performing lightweight consistency check on module: //home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/modules/org/transcrypt/__runtime__.py Line 24: undefined name 'Error' Line 25: undefined name 'Error' Line 169: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 178: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 195: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 204: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 219: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 225: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/org.transcrypt.__runtime__.js Performing static type validation on application: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py The following inconsistencies were found: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod2/__init__.py:2: error: Incompatible return value type (got "int", expected "str") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py:3: error: Incompatible types in assignment (expression has type "float", variable has type "int") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py:4: error: Incompatible return value type (got "str", expected "int") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py:8: error: Incompatible types in assignment (expression has type "float", variable has type "int") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py:16: error: Incompatible return value type (got "int", expected "Iterator[int]") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py:19: error: No return value expected /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py:26: error: No return value expected Found 7 errors in 3 files (checked 1 source file) Performing lightweight consistency check on module: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py Line 5: 'mod1' imported but unused Line 6: 'mod2' imported but unused Performing static type validation on application: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod2/__init__.py The following inconsistencies were found: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod2/__init__.py:2: error: Incompatible return value type (got "int", expected "str") Found 1 error in 1 file (checked 1 source file) Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/mod2.js Performing static type validation on application: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py The following inconsistencies were found: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py:3: error: Incompatible types in assignment (expression has type "float", variable has type "int") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py:4: error: Incompatible return value type (got "str", expected "int") Found 2 errors in 1 file (checked 1 source file) Performing lightweight consistency check on module: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py Line 3: local variable 'a' is assigned to but never used Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/mod1.js Performing static type validation on application: //home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/modules/typing/__init__.py The following inconsistencies were found: Success: no issues found in 1 source file Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/typing.js Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/static_types.js Ready h]hX Transcrypt (TM) Python to JavaScript Small Sane Subset Transpiler Version 3.9.0 Copyright (C) Geatec Engineering. License: Apache 2.0 Performing static type validation on application: //home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/modules/org/transcrypt/__runtime__.py The following inconsistencies were found: Success: no issues found in 1 source file Performing lightweight consistency check on module: //home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/modules/org/transcrypt/__runtime__.py Line 24: undefined name 'Error' Line 25: undefined name 'Error' Line 169: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 178: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 195: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 204: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 219: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Line 225: use ==/!= to compare constant literals (str, bytes, int, float, tuple) Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/org.transcrypt.__runtime__.js Performing static type validation on application: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py The following inconsistencies were found: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod2/__init__.py:2: error: Incompatible return value type (got "int", expected "str") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py:3: error: Incompatible types in assignment (expression has type "float", variable has type "int") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py:4: error: Incompatible return value type (got "str", expected "int") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py:8: error: Incompatible types in assignment (expression has type "float", variable has type "int") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py:16: error: Incompatible return value type (got "int", expected "Iterator[int]") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py:19: error: No return value expected /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py:26: error: No return value expected Found 7 errors in 3 files (checked 1 source file) Performing lightweight consistency check on module: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/static_types.py Line 5: 'mod1' imported but unused Line 6: 'mod2' imported but unused Performing static type validation on application: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod2/__init__.py The following inconsistencies were found: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod2/__init__.py:2: error: Incompatible return value type (got "int", expected "str") Found 1 error in 1 file (checked 1 source file) Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/mod2.js Performing static type validation on application: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py The following inconsistencies were found: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py:3: error: Incompatible types in assignment (expression has type "float", variable has type "int") /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py:4: error: Incompatible return value type (got "str", expected "int") Found 2 errors in 1 file (checked 1 source file) Performing lightweight consistency check on module: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/mod1.py Line 3: local variable 'a' is assigned to but never used Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/mod1.js Performing static type validation on application: //home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/modules/typing/__init__.py The following inconsistencies were found: Success: no issues found in 1 source file Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/typing.js Saving target code in: /home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/static_types.js Ready }(hhhjv ubah}(h ]h"]h$]h&]h(]sourcez/home/jac/active/geatec/transcrypt/Transcrypt/transcrypt/development/manual_tests/static_types/__target__/static_types.outjjjj}jKsuh*jhh+hKhje ubeh}(h ]id9ah"]jah$]h&]h(] literal_blockuh*jyhjD hhhhhNubeh}(h ]static-type-validationah"]h$]static type validationah&]h(]uh*h hh hhhh+hKubh )}(hhh](h)}(h Getting help and giving feedbackh]h Getting help and giving feedback}(hj hj hhhNhNubah}(h ]h"]h$]h&]h(]uh*hhj hhhh+hKubh>)}(hXIf you have coding questions with regard to Transcrypt applications, the best place to ask for help is `StackOverflow (tag: Transcrypt) `_. For bugs and feature requests use the `Transcrypt issue list on GitHub `_. For any matters with regard to Transcrypt you'd like to ask or discuss you can also send a email to info@transcrypt.org.h](hgIf you have coding questions with regard to Transcrypt applications, the best place to ask for help is }(hgIf you have coding questions with regard to Transcrypt applications, the best place to ask for help is hj hhhNhNubh^)}(hZ`StackOverflow (tag: Transcrypt) `_h]hStackOverflow (tag: Transcrypt)}(hStackOverflow (tag: Transcrypt)hj ubah}(h ]h"]h$]h&]h(]nameStackOverflow (tag: Transcrypt)hp5http://stackoverflow.com/questions/tagged/transcrypt/uh*h]hj ubhs)}(h8 h]h}(h ]stackoverflow-tag-transcryptah"]h$]stackoverflow (tag: transcrypt)ah&]h(]refurij uh*hrhKhj ubh(. For bugs and feature requests use the }(h(. For bugs and feature requests use the hj hhhNhNubh^)}(hP`Transcrypt issue list on GitHub `_h]hTranscrypt issue list on GitHub}(hTranscrypt issue list on GitHubhj ubah}(h ]h"]h$]h&]h(]nameTranscrypt issue list on GitHubhp+https://github.com/QQuick/Transcrypt/issuesuh*h]hj ubhs)}(h. h]h}(h ]transcrypt-issue-list-on-githubah"]h$]transcrypt issue list on githubah&]h(]refurij uh*hrhKhj ubhh. For any matters with regard to Transcrypt you’d like to ask or discuss you can also send a email to }(hf. For any matters with regard to Transcrypt you'd like to ask or discuss you can also send a email to hj hhhNhNubh^)}(hinfo@transcrypt.orgh]hinfo@transcrypt.org}(hhhj ubah}(h ]h"]h$]h&]h(]refurimailto:info@transcrypt.orguh*h]hj ubh.}(hj:hj hhhNhNubeh}(h ]h"]h$]h&]h(]uh*h=hh+hKhj hhubeh}(h ] getting-help-and-giving-feedbackah"]h$] getting help and giving feedbackah&]h(]uh*h hh hhhh+hKubeh}(h ]getting-startedah"]h$]getting startedah&]h(]uh*h hhhhhh+hKubah}(h ]h"]h$]h&]h(]sourceh+uh*hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjF error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh+ _destinationN _config_files]pep_referencesN pep_base_url https://www.python.org/dev/peps/pep_file_url_templatepep-%04drfc_referencesN rfc_base_urlhttps://tools.ietf.org/html/ tab_widthKtrim_footnote_reference_spacefile_insertion_enabled raw_enabledKsyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xformembed_stylesheetcloak_email_addressesenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}j]jasnameids}(j j j~j{h}hzjvjsjjjxjjwjtjjjzjwjA j> jjj9 j6 j j jy jv j j j j j j u nametypes}(j Nj~Nh}jvNjNjxjwNjNjzNjA NjNj9 Nj Njy j Nj j uh }(j h j{h,hzhtjsjjjjjjtjjjjwjj> j}jjj6 jj jD jv jp j j j j j j jj{jjj1j j$jj jj j j5 j j_ j; j je u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}jT K sRparse_messages]transform_messages]h system_message)}(hhh]h>)}(hhh]h;Hyperlink target "command-line-switches" is not referenced.}(hhhj ubah}(h ]h"]h$]h&]h(]uh*h=hj ubah}(h ]h"]h$]h&]h(]levelKtypeINFOsourceh+lineKGuh*j uba transformerN decorationNhhub.