1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.
Comment Parser
Python module used to extract comments from source code files of various types.
Installation
Prerequisites
- libmagic
Linux/Unix
sudo pip3 install comment_parser
OSX and Windows
Additionally, complete the special installation requirements for python-magic.
Usage
To use, simply run:
>>> from comment_parser import comment_parser
>>> # Returns a list of comment_parser.parsers.common.Comments
>>> comment_parser.extract_comments('/path/to/source_file')
extract_comments signature
def extract_comments(filename, mime=None):
"""Extracts and returns the comments from the given source file.
Args:
filename: String name of the file to extract comments from.
mime: Optional MIME type for file (str). Note some MIME types accepted
don't comply with RFC2045. If not given, an attempt to deduce the
MIME type will occur.
Returns:
Python list of parsers.common.Comment in the order that they appear in
the source file.
Raises:
UnsupportedError: If filename is of an unsupported MIME type.
"""
Comments Interface
class Comment(object):
"""Represents comments found in source files."""
def text(self):
"""Returns the comment's text.
Returns:
String
"""
pass
def line_number(self):
"""Returns the line number the comment was found on.
Returns:
Int
"""
pass
def is_multiline(self):
"""Returns whether this comment was a multiline comment.
Returns:
True if comment was a multiline comment, False if not.
"""
pass
def __str__(self):
pass
def __eq__(self, other):
pass
Development
Running locally
Start python3 in the base of repository.
from comment_parser import comment_parser
comment_parser.extract_comments('foo.c', mime='text/x-c')
Running tests
python3 setup.py test
Deploying to PyPi
python3 setup.py sdist
twine upload dist/*
Supported Programming Languages
| Language | Mime String |
|---|---|
| C | text/x-c |
| C++/C# | text/x-c++ |
| Go | text/x-go |
| HTML | text/html |
| Java | text/x-java-source |
| Javascript | application/javascript |
| Shell | text/x-shellscript |
| XML | text/xml |
And more to come!
Check comment_parser.py for corresponding MIME types.
Metadata
Release files for comment-parser 1.0.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
File added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release files before installing.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| comment_parser-1.0.9.tar.gz | 5.9 kB | Without provenance | Details for comment_parser-1.0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| comment_parser-1.0.9-py3.7.egg | Legacy Egg format | - | - | Details for comment_parser-1.0.9-py3.7.egg |
Total release size: 27.1 kB
Release files / comment_parser-1.0.9.tar.gz
| Download URL | comment_parser-1.0.9.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c6c8de788b3aa5a8d7d53992a0b02dd105a562bf4e0cdd2be24affa69ebbaf8d
|
|
BLAKE2b-256 checksum How to use checksums |
c1d1325caee192abed55a09a38ce1870bc7e194183884766470e8de3c4154370
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.23.2 CPython/3.6.7
|
Release files / comment_parser-1.0.9-py3.7.egg
File added late
This file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
We recommend inspecting the release file before installing.
| Download URL | comment_parser-1.0.9-py3.7.egg |
|---|---|
| Size | 21.2 kB |
| Tags | Egg |
|
SHA-256 checksum How to use checksums |
c800f09fad072d8be2dbfa862c11045931adedbf9775738c6c424cff45a70dd6
|
|
BLAKE2b-256 checksum How to use checksums |
7dfe799e484e20887c33d2c46a6da90d8279eb0077d9a4bf44215e5ef5ce8034
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3
|
Security for comment-parser 1.0.9
Upload timing
Release file added late
1 file was uploaded more than 14 days after the first file in this release.
While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.