{"id":16715449,"url":"https://github.com/vil02/string_to_code_proj","last_synced_at":"2025-03-21T20:33:54.515Z","repository":{"id":37024649,"uuid":"438767845","full_name":"vil02/string_to_code_proj","owner":"vil02","description":"Generates a piece of messy code displaying a given string","archived":false,"fork":false,"pushed_at":"2025-03-21T16:45:33.000Z","size":754,"stargazers_count":2,"open_issues_count":9,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T17:37:34.670Z","etag":null,"topics":["code-generation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vil02.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-15T20:45:13.000Z","updated_at":"2025-03-20T17:43:13.000Z","dependencies_parsed_at":"2023-11-25T00:20:36.158Z","dependency_job_id":"1a5d9c0a-6e63-4ca2-b912-3f4952a5fa9f","html_url":"https://github.com/vil02/string_to_code_proj","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vil02%2Fstring_to_code_proj","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vil02%2Fstring_to_code_proj/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vil02%2Fstring_to_code_proj/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vil02%2Fstring_to_code_proj/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vil02","download_url":"https://codeload.github.com/vil02/string_to_code_proj/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244866471,"owners_count":20523520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["code-generation"],"created_at":"2024-10-12T21:09:26.134Z","updated_at":"2025-03-21T20:33:54.200Z","avatar_url":"https://github.com/vil02.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# About `string_to_code`\n\n[![python_test](https://github.com/vil02/string_to_code_proj/actions/workflows/python_test.yml/badge.svg)](https://github.com/vil02/string_to_code_proj/actions/workflows/python_test.yml)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=vil02_string_to_code_proj\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=vil02_string_to_code_proj)\n[![codecov](https://codecov.io/gh/vil02/string_to_code_proj/branch/master/graph/badge.svg?token=EZN5LIK387)](https://codecov.io/gh/vil02/string_to_code_proj)\n[![CodeFactor](https://www.codefactor.io/repository/github/vil02/string_to_code_proj/badge)](https://www.codefactor.io/repository/github/vil02/string_to_code_proj)\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/db4940f574964617abc44d57ee4e7c9b)](https://app.codacy.com/gh/vil02/string_to_code_proj/dashboard?utm_source=gh\u0026utm_medium=referral\u0026utm_content=\u0026utm_campaign=Badge_grade)\n[![Open in Gitpod](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod)](https://gitpod.io/#https://github.com/vil02/string_to_code_proj)\n\nBasic functionality of [`string_to_code`](./string_to_code) is to generate\na piece of _messy_ code printing a given string.\nFor example\n\n```python\ndef f_1():\n    print('H', end='')\n    print('e', end='')\n\n\ndef f_2():\n    print('l', end='')\n    print('l', end='')\n\n\ndef f_5():\n    print(',', end='')\n    print(' ', end='')\n\n\ndef f_4():\n    print('o', end='')\n    f_5()\n    print('W', end='')\n\n\ndef f_6():\n    print('o', end='')\n    print('r', end='')\n    print('l', end='')\n\n\ndef f_3():\n    f_4()\n    f_6()\n\n\ndef f_7():\n    print('d', end='')\n    print('!', end='')\n\n\ndef f_0():\n    f_1()\n    f_2()\n    f_3()\n    f_7()\n\n\nf_0()\n```\n\nis a `python` program generated with\n[`string_to_code.to_python3`](./string_to_code/to_python3.py)\n[displaying](https://www.online-python.com/jgzNiCAvxR) `Hello, World!`.\n\n## Getting started\n\nThis package is available at [PyPI](https://pypi.org/project/string-to-code/).\nIt can be installed using the command\n\n```shell\npip install string-to-code\n```\n\nIn order to generate a code in `your_favourite_language` just call the function\n`string_to_code.to_your_favourite_language.proc`\nwith the string which you want to display.\n[`examples`](./examples) show some basic usage.\n\n## Information for developers\n\nThe project is setup using [poetry](https://python-poetry.org/).\nIn order to create a _develompent enviroment_,\nafter cloning this repository, run the command:\n\n```shell\npoetry install --with dev\n```\n\nHave a look at [**Running tests locally** section](#running-tests-locally).\n\nIf you just want to see the examples in action,\nit is enough to clone this repository and run the command:\n\n```shell\npoetry install\n```\n\nAfterwards you can execute the commands like:\n\n```shell\npoetry run python3 examples/example_to_cpp.py\n```\n\n### Adding a new language\n\nIf you think that [`string_to_code`](./string_to_code) is missing some\nlanguage, feel free to add it - it is simple.\nIf you want to add support of let's say `turbo_snake`,\nthere are few things which you need to do:\n\n- create `to_turbo_snake.py` in [`string_to_code`](./string_to_code).\n  This module should define two function `proc` and `proc_printer_program`.\n  The `proc` function returns a `turbo_snake` program displaying the input string.\n  The `proc_printer_program` returns a `turbo_snake` representation of the given\n  [`core.PrinterProgram`](string_to_code/core.py) object.\n\n  Have a look at the existing modules.\n\n- create `setup_turbo_snake.py` in [`tests`](./tests).\n  This file is used for tests.\n  It should contain a function `get_test_data()` returning a\n  `Language` object having fields like:\n  - `tool_names`: a list of program names (compilers, interpreters, linters etc.)\n    used for executing and analysing the generated code,\n  - `string_to_code` being the function `string_to_code.to_turbo_snake.proc`,\n  - `printer_program_to_code` being the function `string_to_code.to_turbo_snake.proc_printer_program`,\n  - `run_code`: the function, which executes the generated code and returns the _standard output_,\n  - `id`: the _id_ of the language, most likely `turbo_snake`,\n  - `source_code_file_extension`: in case of `turbo_snake` something like `ts`.\n\n- create `setup_for_turbo_snake.sh` or `setup_no_sudo_for_turbo_snake.sh`\n  in [`system_setup_scripts`](./system_setup_scripts).\n  These scripts are used by the workflows to install programs needed to execute\n  corresponding tests - cf. step `Install language dependencies`\n  in [`python_test.yml`](./.github/workflows/python_test.yml) and\n  [`generate_and_upload_coverage_data.yml`](./.github/workflows/generate_and_upload_coverage_data.yml),\n  and [`.gitpod.dockerfile`](.gitpod.dockerfile).\n\n- create and populate the `turbo_snake` directory in [`tests/example_data`](tests/example_data).\n  These files should contain the `turbo_snake` sourcecode of some basic programs.\n  Please have a look at the already existing examples.\n\n### Running tests locally\n\n[`tests`](tests/) use [`pytest`](https://docs.pytest.org/).\nIf you do not want to run the tests for all of the languages\n(because it takes too long\nor you do not want to install all of the required _tools_)\nyou can skip some of them by using the `--skip` option.\nFor example, in order to skip\n[`bash`](./string_to_code/to_bash.py), [`C++`](./string_to_code/to_cpp.py) and\n[`Lisp`](./string_to_code/to_lisp.py) run the command\n\n```shell\npoetry run pytest --skip=bash --skip=cpp --skip=lisp\n```\n\nYou can also specify the languages which you want to test by using\n`--select` option.\nFor example to run tests for [`C++`](./string_to_code/to_cpp.py) and\n[`COBOL`](./string_to_code/to_cobol.py) exclusively execute\n\n```shell\npoetry run pytest --select=cpp --select=cobol\n```\n\nWithout installing any _language dependencies_ from\n[`system_setup_scripts`](system_setup_scripts/) you should be able\nto successfully execute the command\n\n```shell\npoetry run pytest --select=python3\n```\n\n### Existing development environment\n\nThis project is setup to be used with [gitpod](https://www.gitpod.io/).\n\n[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/vil02/string_to_code_proj)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvil02%2Fstring_to_code_proj","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvil02%2Fstring_to_code_proj","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvil02%2Fstring_to_code_proj/lists"}