Skip to main content

Python lines of code counter

Project description

pycount
=======

* experimental LOC tool (lines of code, a.k.a. SLOC)
* doing this to learn Python
* feel free to raise issues if you find something unusual (the likelihood of someone even looking at this is
very close to zero, so I'm not expecting anything :D)

**TODO**
* add recognition of text files without extension
* add a lightweight option for results charting
* add rules to separate comments based on type of file
* count code lines, comments and blank lines separately
* improve speed, always
* write tests

**INSTALL**
```
pip install pycount
```

**USAGE**

You can run the command at any location in your command line
```
<your code dir>$ pycount
```

Or you can pass it path arguments
```
$ pycount ~/My/Repos/Some/Project # single path
$ pycount ~/Some/Code ~/Some/Other/Code # multiple paths
$ pycount ~/some.file.py # just one file
```

Exclude directories or files (exact match)
```
$ pycount -e test,external
$ pycount -e test,test.c someproject # counts only 'someproject' directory, while excluding 'test' directory and 'test.c' file
```

Alternatively, you can use the Counter class
```
from pycount.core import Counter

COUNTER = Counter() # or Counter('some/path') # or you can pass it a list of paths
COUNTER.discover() # discovers all unique files for a path
COUNTER.count() # counts all lines of code, using the pre-defined file types which should be considered
```

to see just the files, file type count and final results, you can use the class attributes
```
COUNTER.discover()
COUNTER.files # lists all the files

COUNTER.count()
COUNTER.file_types # outputs the breakdown of counted file number, by file type
COUNTER.results # outputs the dictionary with all the values that were collected through counting per file type
```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycount-0.6.18.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycount-0.6.18-py2.py3-none-any.whl (11.3 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pycount-0.6.18.tar.gz.

File metadata

  • Download URL: pycount-0.6.18.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pycount-0.6.18.tar.gz
Algorithm Hash digest
SHA256 0072689ea4d3455e96abf789a9c20a67e8e8c350829ee88f5fd8863b0c3884aa
MD5 bd4edd310a1caa7acb1d8d909d4bbc89
BLAKE2b-256 3980c236a6e899caa56bf776030be02141404bb91a24d14a50fa122abdcb6b7d

See more details on using hashes here.

File details

Details for the file pycount-0.6.18-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pycount-0.6.18-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 a70b0c58e3c98ee0508ecd49677db5987f27dc5e308b3786514b1ea466180459
MD5 54da232a304518ed57023c33a63f11f8
BLAKE2b-256 688562e5a56d8e0e2f3d7646a378cb6a90fb330dd41f50ada0a082866f52c3df

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page