CrudePythonTranslator.translate
— Methodtranslate(filename; kwargs...)
Translate filename
, which must be a Python file with .py
extension. The output is written to the same path with .py
replaced by .jl
, if this does not yet exist, otherwise with extension .crude.jl
.
translate(dirname; kwargs...)
Translate all python files in the directory dirname
.
translate(source, custom_translations...; kwargs...)
translate(source, custom_translations::Vector; kwargs...)
Translate file or directory source
with additional custom_translations
. A custom translation is a function which receives a vector of tokens and returns a possibly modified vector of tokens.
keyword arguments:
recursive
: When the source is a directory, translate files also in all subdirectories, recursively. Defaults tofalse
.overwrite
: If the output.jl
file already exists, overwrite it instead of writing to.crude.jl
file. Defaults tofalse
.include_base_translations
: Iffalse
, only do a minimal translation. Defaults to true. This can be used if you want to do a fully customized translation.verbose
: Iftrue
, print the output sequence of tokens. Defaults tofalse
. Mostly useful with a single short file to figure out how to design a custom translation function.