{"id":26786965,"url":"https://github.com/mvisat/kopyt","last_synced_at":"2025-10-26T04:43:09.672Z","repository":{"id":62574545,"uuid":"386619364","full_name":"mvisat/kopyt","owner":"mvisat","description":"Kotlin parser in pure Python.","archived":false,"fork":false,"pushed_at":"2021-07-21T09:25:58.000Z","size":73,"stargazers_count":11,"open_issues_count":3,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-03-29T12:17:25.347Z","etag":null,"topics":["kotlin","parser","python"],"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/mvisat.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":"2021-07-16T11:51:53.000Z","updated_at":"2025-03-04T10:09:58.000Z","dependencies_parsed_at":"2022-11-03T18:36:04.353Z","dependency_job_id":null,"html_url":"https://github.com/mvisat/kopyt","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvisat%2Fkopyt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvisat%2Fkopyt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvisat%2Fkopyt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mvisat%2Fkopyt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mvisat","download_url":"https://codeload.github.com/mvisat/kopyt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249780513,"owners_count":21324560,"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":["kotlin","parser","python"],"created_at":"2025-03-29T12:17:29.090Z","updated_at":"2025-10-26T04:43:09.577Z","avatar_url":"https://github.com/mvisat.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kopyt\n\nKopyt is a Kotlin programming language parser in pure Python, inspired by [javalang](https://github.com/c2nes/javalang) library.\n\n## Installation\n```sh\npip install -U kopyt\n```\n\n## Features\n- Supports Kotlin 1.5\n- Zero dependency\n\n## Requirements\n- Python 3.7+\n\n## Usage\n```python\nfrom kopyt import Parser, node\n\ncode = \"\"\"\\\npackage main\n\nimport a.b\nimport x.y.z.*\n\nfun main() {\n    println(\"Hello, world!\")\n}\n\"\"\"\n\nparser = Parser(code)\nresult = parser.parse()\n\nassert result.package is not None\nassert result.package.name == \"main\"\n\nassert len(result.imports) == 2\nassert result.imports[0].name == \"a.b\"\nassert result.imports[1].name == \"x.y.z\"\nassert result.imports[1].wildcard\n\nassert len(result.declarations) == 1\nassert isinstance(result.declarations[0], node.FunctionDeclaration)\nassert result.declarations[0].name == \"main\"\nassert result.declarations[0].position.line == 6\n\nprint(result) # this will output a string similar to the original code\n```\n\nAll nodes and its members can be found on [kopyt/node.py](kopyt/node.py).\n\n### Partial Parsing\nIt is possible to parse partial Kotlin code, for example you want to parse a function declaration:\n\n```python\nfrom kopyt import Parser, node\n\ncode = \"fun plusOne(x: Int) = x + 1\"\nparser = Parser(code)\nresult = parser.parse_function_declaration()\n\nassert result.name == \"plusOne\"\nassert len(result.parameters) == 1\nassert result.parameters[0].name == \"x\"\n```\n\nAll parse functions can be found on [kopyt/parser.py](kopyt/parser.py).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvisat%2Fkopyt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmvisat%2Fkopyt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmvisat%2Fkopyt/lists"}