Using custom parser as python module
See original GitHub issueI have created custom parser crontab_h.py
and placed it in the $HOME/.local/share/jc/jcparsers
folder.
I can successfully use this parser when executing crontab -l | jc --crontab_h
, but when I try to use it as python module, I get error that module is not found: ModuleNotFoundError: No module named 'jc.parsers.crontab_h'
.
test.py
#!/usr/bin/env python3
import subprocess
import jc.parsers.crontab_h
command_output = subprocess.check_output(['crontab', '-l'], text=True)
result = jc.parsers.crontab_h.parse(command_output)
print(result)
output:
> python3 test.py
Traceback (most recent call last):
File "//test.py", line 4, in <module>
import jc.parsers.crontab_h
ModuleNotFoundError: No module named 'jc.parsers.crontab_h'
Does this mean that custom parsers cant be used as python modules?
Even if I override default parser crontab.py
(by renaming the custom crontab_h.py
to crontab.py
), the default parser is still imported as python module in stead of the custom one when using import jc.parsers.crontab
.
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
How to Build a Custom Parser - Packet Coders
The first thing is to create a template that can be used for multiple parsers, and for that, my preference would be to...
Read more >Parsing in Python: all the tools and libraries you can use
We present and compare all possible alternatives you can use to parse languages in Python. From libraries to parser generators, we present all...
Read more >argparse — Parser for command-line options, arguments and ...
The argparse module makes it easy to write user-friendly command-line interfaces. The program defines what arguments it requires, and argparse will figure out ......
Read more >How to create custom argparse types in Python? - Medium
Import the argparse module; Create the parser; Added arguments (positional, optional); Parse the arguments and validate. Let's start off by ...
Read more >Add own realtime custom parser to Python to generate and ...
Parse a .py file, read the AST, modify it, then write back the modified source code · Python's tokenize module · Python's ast...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The new API to call builtin and plugin parsers is now available with v1.18.1
Here is a not-so-elegant solution for now. I’ll look into creating true interface for this: