Skip to main content

PyPI version PyVer Lic coverage Build Status

fcomments

manage comments from your command line

installation

supports Python 3.5+

fcomments is on pypi

$ pip install fcomments

usage

Default behavior is to switch the line. It means that if a matched line is commented, the comment will be removed, and if the line is not commented the comment will be added.

Specifying -c flag ensures that matched lines will be commented out after the command. The flag -u works analogically with respect to uncommenting lines.

Provisioning

from fcomments import Commenter

LINES = [4,5,6]

c = Commenter(path='path/to/file')

c.comment_file(comment=True, lines=LINES)  # ensure that lines 4-6 are commented out

action()  # do sth: run tests, make migrations ..

c.comment_file(uncomment=True, lines=LINES)  # ensure that lines 4-6 are not commented

CLI

# comment all lines in a file:
$ fcomments --comment --all path/to/file
$ fcomments -ca path/to/file
# comment lines 3 to 12:
$ fcomments --comment --lines=3-12 path/to/file
$ fcomments -cl3-12 path/to/file
–help
Usage: __main__.py [options] <path>

Examples:
       __main__.py -h                  --->  see help
       __main__.py -cl1,2 path/to/file  --->  comment out lines 1 and 2
       __main__.py -ul3-6 path/to/file  --->  uncomment lines 3 to 6 (inclusive)
       __main__.py -ac path/to/file     --->  comment out all lines
       __main__.py -au path/to/file     --->  uncomment all lines

       __main__.py --start-pattern='\s+operations\s?=\s?\[' --end-pattern='\s+\]' path/to/file
         --->  comment out everything inside the `operations` list:

         1| class Migration(...):
         2|
         3|     operations = [
         4| #       migrations(
         5| #           ...
         6| #       ),
         7|     ]


  Comment or uncomment lines in a file. Default behavior: do the oposite i.e.
if a line is commented - uncomment it, and vice versa. To make sure that the
matched lines will be [un]commented out - run with -[u]c option. If you don't
specify an --output, the original file (<path>) will be overwritten.

Options:
  -h, --help            show this help message and exit
  -c, --comment         comment lines [default: False]
  -u, --uncomment       uncomment lines [default: False]
  -a, --all             apply to all lines in file; suppresses -l option
                        [default: False]
  -l LINES, --lines=LINES
                        comma separeted string of line numbers [default: None]
  -s IN_PATTERN, --start-pattern=IN_PATTERN
                        pattern to match against the line before commented
                        section [default: None]
  -e OUT_PATTERN, --end-pattern=OUT_PATTERN
                        pattern to match against the first line after
                        commented section [default: None]
  -o OUTPUT, --output=OUTPUT
                        specify a path to output file [default: None]
  --symbol=COMMENT_SYMBOL
                        specify a string to use as comment [default: '#']

Release files for fcomments 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fcomments 0.1.3
File Size Uploaded
fcomments-0.1.3.tar.gz 7.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fcomments 0.1.3
File Interpreter ABI Platform
fcomments-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 24.8 kB

Release files / fcomments-0.1.3.tar.gz

Download URL fcomments-0.1.3.tar.gz
Size 7.0 kB
Tags Source
SHA-256 checksum
How to use checksums
b591b00cb414299c6752933b20b0415aa7a294624a156ed33cd9c4c36c7d2c7d
BLAKE2b-256 checksum
How to use checksums
1923bf4207321d44ff7cc14fb1b712008380cf26254429c6c87b6f01ba3ab941
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / fcomments-0.1.3-py3-none-any.whl

Download URL fcomments-0.1.3-py3-none-any.whl
Size 17.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
32454ea87390808141e3a37dea7030303abc99d78901a5f6f4de53766dd01be9
BLAKE2b-256 checksum
How to use checksums
39e81ba2a017d8d7fc41c8c04100f6c59ad2bc17534f89ba16828bfdc53fd138
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page