{"id":38515274,"url":"https://github.com/stevej2608/oppen-pretty-printer","last_synced_at":"2026-01-17T06:28:16.622Z","repository":{"id":57447809,"uuid":"264855100","full_name":"stevej2608/oppen-pretty-printer","owner":"stevej2608","description":"Python implementation of Derek C. Open's  pretty printer algorithm","archived":false,"fork":false,"pushed_at":"2022-08-11T16:47:28.000Z","size":18657,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-12-26T23:59:25.261Z","etag":null,"topics":["pretty-printer","python"],"latest_commit_sha":null,"homepage":null,"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/stevej2608.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-05-18T07:02:03.000Z","updated_at":"2025-05-28T23:14:28.000Z","dependencies_parsed_at":"2022-09-16T19:50:22.068Z","dependency_job_id":null,"html_url":"https://github.com/stevej2608/oppen-pretty-printer","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/stevej2608/oppen-pretty-printer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevej2608%2Foppen-pretty-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevej2608%2Foppen-pretty-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevej2608%2Foppen-pretty-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevej2608%2Foppen-pretty-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stevej2608","download_url":"https://codeload.github.com/stevej2608/oppen-pretty-printer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stevej2608%2Foppen-pretty-printer/sbom","scorecard":{"id":852210,"data":{"date":"2025-08-11","repo":{"name":"github.com/stevej2608/oppen-pretty-printer","commit":"5f826b24d54a14e39cbccbd290614d9c331f4160"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":1,"reason":"Found 1/10 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T22:50:09.694Z","repository_id":57447809,"created_at":"2025-08-23T22:50:09.694Z","updated_at":"2025-08-23T22:50:09.694Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28502277,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T04:31:57.058Z","status":"ssl_error","status_checked_at":"2026-01-17T04:31:45.816Z","response_time":85,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["pretty-printer","python"],"created_at":"2026-01-17T06:28:16.489Z","updated_at":"2026-01-17T06:28:16.607Z","avatar_url":"https://github.com/stevej2608.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"## oppen-pretty-printer\n\nThis project is a faithful translation, to python, of the\npretty-printing algorithm developed by DEREK C. OPPEN at Stanford  University\nin the late 1970s. The appendix of [PRETTY PRINTING, Derek C. Oppen, 1979] contains\nthe original prettyprint program written in [MESA]\n\nA much quoted, more recent algorithm, [A prettier printer, Philip Wadler 2003] refers to\nOppen, saying, \"The pretty printer presented here uses an algorithm equivalent to Oppen’s, but presented\nin a functional rather than an imperative style\". Many of todays pretty printer implementations\nare based on the Wadler algorithm. So, in a way, the road leads back to Derek C. Oppen, 1979.\n\nTwo python versions are included. `pretty_oppen.py` is, as far as possible, a\nline-by-line translation of the Oppen algorithm from [MESA] to Python. `pretty.py` is\nfunctionally identical to `pretty_oppen.py` but written using a more Pythonic idiom.\n\nPytest tests and example output are included for both versions.\n\n\n### Usage\n\n\tpip install oppen-pretty-printer\n\nExample:\n```\nfrom oppen_pretty_printer import pprint, Tokens as T\n\ntokens = [\n    T.BEGIN(),\n    T.STRING(\"begin\"),T.BREAK(),\n    T.STRING(\"x\"),\n    T.BREAK(), T.STRING(\":=\"), T.BREAK(),\n    T.STRING(\"40\"),\n    T.BREAK(), T.STRING(\"+\"), T.BREAK(),\n    T.STRING(\"2\"),T.BREAK(),\n    T.STRING(\"end\"),\n    T.END(),\n    T.EOF()]\n\npprint(tokens)\n```\n\nResult:\n\n    \"begin x := 40 + 2 end\"\n\nFor more complex examples see the *tests* folder.\n\n### Overview\n\nThe pretty printer processes a sequence of the tokens BEGIN, END, STRING, BREAK, EOF.\nThe tokens BEGIN..END define a block that can contain any number of STRING and BREAK\ntokens together with nested BEGIN..END sub-blocks. The pretty printer attempts\nto keep the content of blocks together on the same line. If this is not possible\nthen the block is automatically folded and indented at a suitable BREAK.\n\nThe STRING token holds a sequence of printable characters that will never be broken. The BRAKE token\nis a replacement for a sequence of non-printing, white-space, characters. A\nBRAKE token is nominally printed as a `single-space` or, if\nfolding takes place, `new-line-with-indent-and-offset`.\n\nThis example from Oppen's paper shows how the pretty printer deals with the same input for\ndifferent line widths.\n\n```\nwidth=75\n\n        begin\n          x := f(x); y := f(y); z := f(z); w := f(w);\n          end;\n\nwidth=24\n\n        begin\n          x := f(x); y := f(y);\n          z := f(z); w := f(w);\n          end;\n\nwidth=75, BreakType.consistent\n\n        begin\n          x := f(x);\n          y := f(y);\n          z := f(z);\n          w := f(w);\n          end;\n```\n\nBLOCK and BREAK tokens can be parameterized, if needed, to modify the default folding\nbehaviour. The parameters are used to control indent, offset and the consistency of folding.\n\nTo create a pretty printer for a new language grammar it is normal to write a tree\nvisitor using the visitor design-pattern. The visitor emits pretty-printer tokens\nas is traverses the program AST. The token sequence is passed to the pretty\nprinter for printing.\n\nSee **[odata-pretty-printer](https://github.com/stevej2608/odata-pretty-printer)** for an\nexample of traversing an AST and emitting `oppen-pretty-printer` tokens. For other\nexamples of usage see the pytest examples in this projects the `./tests` folder.\n\n\n### Development\n\n    pip install -r requirements.txt\n\n    pytest\n\nTo run pytest on `pretty_oppen.py` use:\n\n    pytest --oppen\n\n\npublish:\n\n    invoke publish 0.1.2 --pypi\n\n**Links:** (copies in the docs folder)\n\n* [PRETTY PRINTING, Derek C. Oppen, 1979]\n* [A prettier printer, Philip Wadler 2003]\n* [MESA]\n\n\n\n[PRETTY PRINTING, Derek C. Oppen, 1979]: https://www.cs.tufts.edu/~nr/cs257/archive/derek-oppen/prettyprinting.pdf\n[A prettier printer, Philip Wadler 2003]: http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf\n[MESA]: http://www.bitsavers.org/pdf/xerox/parc/techReports/CSL-79-3_Mesa_Language_Manual_Version_5.0.pdf\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevej2608%2Foppen-pretty-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstevej2608%2Foppen-pretty-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstevej2608%2Foppen-pretty-printer/lists"}