8000 Parse: Should be able to register parsers, detect vcs · Issue #404 · vcs-python/libvcs · GitHub
[go: up one dir, main page]

Skip to content

Parse: Should be able to register parsers, detect vcs #404

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
tony opened this issue Sep 9, 2022 · 0 comments
Closed

Parse: Should be able to register parsers, detect vcs #404

tony opened this issue Sep 9, 2022 · 0 comments

Comments

@tony
Copy link
Member
tony commented Sep 9, 2022

libvcs.parse.parse

parse.py:

# can be string imports
DEFAULTS_PARSERS = {
    "git": "libvcs.parse.git.GitURL"
    # ...
}
PARSERS = DEFAULT_PARSERS.copy()


class Parser:
    def __init__(parser_overrides=None):
        self.parsers = PARSERS
        if isinstance(parser_overrides, dict):
            for k, v in parser_overrides.items():
                if v is None and k in parsers:
                    del self.parsers[k]
                if k is not None and v is not None:
                    self.parsers[k] = v


def register_parser(name: str, parser: Parser):
    PARSERS[name] = parser


def unregister_parser(name):
    del PARSERS[name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant
0