{"id":22136062,"url":"https://github.com/mahmoudimus/py2star","last_synced_at":"2025-08-16T19:05:13.481Z","repository":{"id":47234967,"uuid":"309469450","full_name":"mahmoudimus/py2star","owner":"mahmoudimus","description":"Converts python files to starlark (or Larky) compatible scripts.","archived":false,"fork":false,"pushed_at":"2022-04-30T07:21:10.000Z","size":238,"stargazers_count":12,"open_issues_count":9,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-26T01:26:39.052Z","etag":null,"topics":["python","source-to-source","starlark","starlark-files","transpiler"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mahmoudimus.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}},"created_at":"2020-11-02T19:08:32.000Z","updated_at":"2025-05-02T17:08:28.000Z","dependencies_parsed_at":"2022-09-14T06:31:15.107Z","dependency_job_id":null,"html_url":"https://github.com/mahmoudimus/py2star","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/mahmoudimus/py2star","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahmoudimus%2Fpy2star","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahmoudimus%2Fpy2star/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahmoudimus%2Fpy2star/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahmoudimus%2Fpy2star/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mahmoudimus","download_url":"https://codeload.github.com/mahmoudimus/py2star/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mahmoudimus%2Fpy2star/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270756857,"owners_count":24639954,"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","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["python","source-to-source","starlark","starlark-files","transpiler"],"created_at":"2024-12-01T19:18:41.514Z","updated_at":"2025-08-16T19:05:13.425Z","avatar_url":"https://github.com/mahmoudimus.png","language":"Python","funding_links":[],"categories":["Tools"],"sub_categories":[],"readme":"# py2star\nConverts python files to starlark files\n\n## Get started quickly\n\n#### Setup\n```bash\npython -m venv venv\nsource venv/bin/activate\npython setup.py install\n```\n\n#### Run\n```bash\ncd src/py2star\npython cli.py larkify ~/src/pycryptodome/lib/Crypto/SelfTest/PublicKey/test_RSA.py \u003e test_RSA.star\npython cli.py tests test_RSA.star \u003e\u003e test_RSA.star\n```\n\n## Differences with Python\n\nThe list of differences between Starlark and Python are documented at https://bazel.build site:\n- [Differences with Python](https://docs.bazel.build/versions/master/skylark/language.html#differences-with-python)\n- More differences documented as a **W**ork **I**n **P**rogress in [this Github issue](https://github.com/bazelbuild/starlark/pull/158)\n\n\n### Some High-level Differences\n\n- Global variables are immutable.\n- `for` statements are not allowed at the top-level. Use them within functions instead.\n- `if` statements are not allowed at the top-level. However, `if` expressions can be used: `first = data[0] if len(data) \u003e 0 else None`.\n- Deterministic order for iterating through Dictionaries.\n- Recursion is not allowed.\n- Modifying a collection during iteration is an error.\n- Except for equality tests, comparison operators `\u003c`, `\u003c=`, `\u003e=`, `\u003e`, etc. are not defined across value types. In short: `5 \u003c 'foo'` will throw an error and `5 == \"5\"` will return `False`.\n- In tuples, a trailing comma is valid only when the tuple is between parentheses, e.g. `write (1,)` instead of `1,`.\n- Dictionary literals cannot have duplicated keys. For example, this is an error: `{\"a\": 4, \"b\": 7, \"a\": 1}`.\n- **Strings are represented with double-quotes (e.g. when you call repr).**\n- Strings aren't iterable (**WORKAROUND**: use `.elems()` to iterate over it.)\n  \n### The following Python features are attempted to be automatically converted:\n\n- [ ] most `builtin` functions, most methods.\n- [ ] `set` types  (**WORKAROUND**: use [`sets.star`](https://github.com/verygoodsecurity/starlarky/blob/master/larky/src/main/resources/stdlib/sets.star) instead)\n- [ ]`implicit string concatenation (use explicit + operator)`.\n- [x] Chained comparisons (e.g. 1 \u003c x \u003c 5)`.\n- [x] `class` (see `larky.struct` function). \n- [x] `import` (see `load` statement).\n- [x] `while`.\n- [x] `generators` and `generator expressions`.\n- [x] `is` and `is not` (use `==`  and `!=` instead, respectively).\n- [x] `raise` (see `fail` for fatal errors).  \n- [ ] `try`, `except`, `finally`. (see `fail` for fatal errors).\n- [ ] `yield`.\n- [ ] `global`, `nonlocal`.\n\n\n## Automatic Conversion\n\n* `py2star.fixes.fix_declass` -- de-classes and de-indents a class\n\nSo, it goes from:\n\n```python\nclass Foo(object):\n    def bar(self):\n        return \"baz\"\n```\n\nTo:\n\n```python\ndef bar(self):\n    return \"baz\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahmoudimus%2Fpy2star","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmahmoudimus%2Fpy2star","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmahmoudimus%2Fpy2star/lists"}