{"id":32177764,"url":"https://github.com/consbio/parserutils","last_synced_at":"2026-07-03T21:34:00.579Z","repository":{"id":57450926,"uuid":"67242223","full_name":"consbio/parserutils","owner":"consbio","description":"A collection of performant parsing utilities","archived":false,"fork":false,"pushed_at":"2021-10-12T20:55:06.000Z","size":226,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-03-22T15:36:00.875Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/consbio.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":"2016-09-02T17:31:47.000Z","updated_at":"2022-08-20T20:45:27.000Z","dependencies_parsed_at":"2022-09-26T17:31:21.658Z","dependency_job_id":null,"html_url":"https://github.com/consbio/parserutils","commit_stats":null,"previous_names":[],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/consbio/parserutils","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consbio%2Fparserutils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consbio%2Fparserutils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consbio%2Fparserutils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consbio%2Fparserutils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/consbio","download_url":"https://codeload.github.com/consbio/parserutils/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/consbio%2Fparserutils/sbom","scorecard":{"id":302991,"data":{"date":"2025-08-11","repo":{"name":"github.com/consbio/parserutils","commit":"50e0e4b6afd807a7cf230b2b2fccfe0b287bc2ab"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"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":"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":"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":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","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":"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":"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":"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":"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" 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":"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 'main'"],"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"}}]},"last_synced_at":"2025-08-17T21:14:22.940Z","repository_id":57450926,"created_at":"2025-08-17T21:14:22.940Z","updated_at":"2025-08-17T21:14:22.940Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35102737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-03T02:00:05.635Z","response_time":110,"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":[],"created_at":"2025-10-21T20:26:01.841Z","updated_at":"2026-07-03T21:34:00.574Z","avatar_url":"https://github.com/consbio.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# parserutils\n\n[![Build Status](https://api.travis-ci.com/consbio/parserutils.png?branch=main)](https://app.travis-ci.com/github/consbio/parserutils)\n[![Coverage Status](https://coveralls.io/repos/github/consbio/parserutils/badge.svg?branch=main)](https://coveralls.io/github/consbio/parserutils?branch=main)\n\nThis is a library of utility functions designed to make a developer's life easier.\n\nThe functions in this library are written to be both performant and Pythonic, as well as compatible with Python 3.6 through 3.9.\nThey are both documented and covered thoroughly by unit tests that fully describe and prove their behavior.\n\nIn general, my philosophy is that utility functions should be fast and handle edge cases so the caller doesn't have to take all kinds of precautions or do type checking on results.\nThus, in this library, if None will break a function it is simply returned as is; if there's nothing to do for a value, the result is returned without processing; otherwise, values are either processed successfully or a standard exception is returned.\n\nBut this is just a starting point. I welcome feedback and requests for additional functionality.\n\n\n## Installation\nInstall with `pip install parserutils`.\n\n## Usage\n\nHere's what you can do with `dict` objects and other collections.\n```python\nfrom parserutils import collections\n\ncollections.accumulate_items([('key', 'val1'), ('key', 'val2'), ('key', 'val3')])   # {'key': ['val1', 'val2', 'val3']}\ncollections.accumulate_items(\n    [('key1', 'val1'), ('key2', 'val2'), ('key3', 'val3')], reduce_each=True  # {'key1': 'val1', 'key2': 'val2', 'key3': 'val3'}\n)\n\ncollections.setdefaults({}, 'a.b')                         # {'a': {'b': None}}\ncollections.setdefaults({}, ['a.b', 'a.c'])                # {'a': {'b': None, 'c': None}}\ncollections.setdefaults({}, {'a.b': 'bbb', 'a.c': 'ccc'})  # {'a': {'b': 'bbb', 'c': 'ccc'}}\n\ncollections.filter_empty(x for x in (None, [], ['a'], '', {'b'}, 'c'))      # [['a'], {'b'}, 'c']\ncollections.flatten_items(x for x in ('abc', ['a', 'b', 'c'], ('d', 'e')))  # ['abc', 'a', 'b', 'c', 'd', 'e']\n\ncollections.remove_duplicates('abcdefabc')                                   # 'abcdef'\ncollections.remove_duplicates('abcdefabc', in_reverse=True)                  # 'defabc'\ncollections.remove_duplicates(['a', 'b', 'c', 'a'])                          # ['a', 'b', 'c']\ncollections.remove_duplicates(('a', 'b', 'c', 'a'), in_reverse=True)         # ('b', 'c', 'a')\ncollections.remove_duplicates(x for x in 'abca')                             # ['a', 'b', 'c']\ncollections.remove_duplicates((x for x in 'abca'), in_reverse=True)          # ['b', 'c', 'a']\ncollections.remove_duplicates((set(x) for x in 'abca'), is_unhashable=True)  # [{'a'}, {'b'}, {'c'}]\n\ncollections.rindex('aba', 'a')               # 2\ncollections.rindex(['a', 'b', 'a'], 'a')     # 2\ncollections.rindex(('a', 'b', 'a'), 'a')     # 2\ncollections.rindex('xyz', 'a')               # ValueError\ncollections.rindex([x for x in 'xyz'], 'a')  # ValueError\n\ncollections.rfind('aba', 'a')                # 2\ncollections.rfind(['a', 'b', 'a'], 'a')      # 2\ncollections.rfind(('a', 'b', 'a'), 'a')      # 2\ncollections.rindex('xyz', 'a')               # -1\ncollections.rfind([x for x in 'xyz'], 'a')   # -1\n\ncollections.reduce_value(['abc'])          # 'abc'\ncollections.reduce_value(('abc',))         # 'abc'\ncollections.reduce_value({'abc'})          # 'abc'\ncollections.reduce_value('abc')            # 'abc'\ncollections.reduce_value({'a': 'aaa'})     # {'a': 'aaa'}\ncollections.reduce_value([{'a': 'aaa'}])   # {'a': 'aaa'}\ncollections.reduce_value(['a', 'b', 'c'])  # ['a', 'b', 'c']\n\ncollections.wrap_value(['abc'])           # ['abc']\ncollections.wrap_value(('abc',))          # ('abc',)\ncollections.wrap_value('abc')             # ['abc']\ncollections.wrap_value(x for x in 'abc')  # ['a', 'b', 'c']\ncollections.wrap_value({'a': 'aaa'})      # [{'a': 'aaa'}]\ncollections.wrap_value(['a', 'b', 'c'])   # ['a', 'b', 'c']\n```\n\nHere's a little bit about dates and numbers.\n```python\nfrom parserutils import dates\nfrom parserutils import numbers\n\n# Leverages dateutil in general, but also handles milliseconds and provides defaults\n\ndates.parse_dates(None, default='today')  # Today (default behavior)\ndates.parse_dates(None, default=None)     # Returns None\ndates.parse_dates('nope', default=None)   # Returns None\ndates.parse_dates(0)                      # 1970\ndates.parse_dates('\u003cdate_format\u003e')        # Behaves as described in dateutil library\n\n# Reliably handles all the usual cases\n\nnumbers.is_number(0)                    # Integer: True\nnumbers.is_number(1.1)                  # Float: True\nnumbers.is_number('2.2')                # String: True\nnumbers.is_number(False)                # Boolean: False by default\nnumbers.is_number(False, if_bool=True)  # Boolean: True if you need it to\nnumbers.is_number(float('inf'))         # Infinite: False\nnumbers.is_number(float('nan'))         # NaN: False\n```\n\nHere's something about string and URL parsing helpers.\n```python\nfrom parserutils import strings\nfrom parserutils import urls\n\n# These string conversions are written to be fast and reliable\n\nstrings.camel_to_constant('toConstant')        # TO_CONSTANT\nstrings.camel_to_constant('XMLConstant')       # XML_CONSTANT\nstrings.camel_to_constant('withNumbers1And2')  # WITH_NUMBERS1_AND2\n\nstrings.camel_to_snake('toSnake')              # to_snake\nstrings.camel_to_snake('withXMLAbbreviation')  # with_xml_abbreviation\nstrings.camel_to_snake('withNumbers3And4')     # with_numbers3_and4\n\nstrings.snake_to_camel('from_snake')              # fromSnake\nstrings.snake_to_camel('_leading_and_trailing_')  # leadingAndTrailing\nstrings.snake_to_camel('extra___underscores')     # extraUnderscores\n\nstrings.find_all('ab??ca??bc??', '??')                         # [2, 6, 10]\nstrings.find_all('ab??ca??bc??', '??', reverse=True)           # [10, 6, 2]\nstrings.find_all('ab??ca??bc??', '??', limit=2, reverse=True)  # [10, 6]\nstrings.find_all('ab??ca??bc??', '??', start=4)                # [6, 10]\nstrings.find_all('ab??ca??bc??', '??', end=8)                  # [2, 6]\nstrings.find_all('ab??ca??bc??', '??', start=4, end=8)         # [6]\n\nstrings.splitany('ab:ca:bc', ',')           # Same as 'ab:ca:bc'.split(':')\nstrings.splitany('ab:ca:bc', ',', 1)        # Same as 'ab:ca:bc'.split(':', 1)\nstrings.splitany('ab|ca:bc', '|:')          # ['ab', 'ca', 'bc']\nstrings.splitany('ab|ca:bc', ':|', 1)       # ['ab', 'ca:bc']\nstrings.splitany('0\u003c=3\u003c5', ['\u003c', '\u003c='])     # ['0', '3', '5']\nstrings.splitany('0\u003c=3\u003c5', ['\u003c', '\u003c='], 1)  # ['0', '3\u003c5']\n\nstrings.to_ascii_equivalent('smart quotes, etc.')  # Replaces with ascii quotes, etc.\n\n# URL manipulation leverages urllib, but spares you the extra code\n\nurls.get_base_url('http://www.params.com?a=aaa')                  # 'http://www.params.com'\nurls.get_base_url('http://www.path.com/test')                     # 'http://www.path.com'\nurls.get_base_url('http://www.path.com/test', include_path=True)  # 'http://www.path.com/test'\nurls.get_base_url('http://www.params.com/test?a=aaa', True)       # 'http://www.params.com/test'\n\nurls.update_url_params('http://www.params.com?a=aaa', a='aaa')  # 'http://www.params.com?a=aaa'\nurls.update_url_params('http://www.params.com?a=aaa', a='xxx')  # 'http://www.params.com?a=xxx'\nurls.update_url_params('http://www.params.com', b='bbb')        # 'http://www.params.com?b=bbb'\nurls.update_url_params('http://www.params.com', c=['c', 'cc'])  # 'http://www.params.com?c=c\u0026c=cc'\n\n# Helpers to parse urls to and from parts: parses path as list and params as dict\nurls.url_to_parts('http://www.params.com/test/path?a=aaa')      # SplitResult(..., path=['test', 'path'], query={'a': 'aaa'})\nurls.parts_to_url(\n    {'netloc': 'www.params.com', 'query': {'a': 'aaa'}          # 'http://www.params.com?a=aaa'\n)\nurls.parts_to_url(\n    urls.url_to_parts('http://www.params.com/test/path?a=aaa')  # 'http://www.params.com/test/path?a=aaa'\n)\n```\n\nFinally, XML parsing is also supported, using the cElementTree and defusedxml libraries for performance and security\n```python\nfrom parserutils import elements\n\n# First convert an XML string to an Element object\nxml_string = '\u003croot\u003e\u003cparent\u003e\u003cchild\u003eone\u003c/child\u003e\u003cchild\u003etwo\u003c/child\u003e\u003cuglyChild\u003eyuck\u003c/uglyChild\u003e\u003c/parent\u003e\u003c/root\u003e'\nxml_element = elements.get_element(xml_string)\n\n\n# Update the XML string and print it back out\nelements.set_element_text(xml_element, 'parent/child', 'child text')\nelements.set_element_attributes(xml_element, childHas='child attribute')\nelements.remove_element(xml_element, 'parent/uglyChild')\nelements.element_to_string(xml_element)\n\n\n# Conversion from string to Element, to dict, and then back to string\nconverted = elements.element_to_dict(xml_string, recurse=True)\nreverted = elements.dict_to_element(converted)\nreverted = elements.get_element(converted)\nxml_string == elements.element_to_string(converted)\n\n\n# Conversion to flattened dict object\nroot, obj = elements.element_to_object(converted)\nobj == {'root': {'parent': {'child': ['one', 'two'], 'uglyChild': 'yuck'}}}\n\n\n# Read in an XML file and write it elsewhere\nwith open('/path/to/file.xml', 'wb') as xml:\n    xml_from_file = elements.get_element(xml)\n    elements.write_element(xml_from_file, '/path/to/updated/file.xml')\n\n\n# Write a local file from a remote location (via URL)\nxml_from_web = elements.get_remote_element('http://en.wikipedia.org/wiki/XML')\nelements.write_element(xml_from_web, '/path/to/new/file.xml')\n\n\n# Read content at a local file path to a string\nxml_from_path = elements.get_remote_element('/path/to/file.xml')\nelements.element_to_string(xml_from_path)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconsbio%2Fparserutils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fconsbio%2Fparserutils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fconsbio%2Fparserutils/lists"}