GithubHelp home page GithubHelp logo

count_lines's Introduction

count_lines

0 Introduction / 简介

A simple Python program counting "useful" lines in .py files. 一个简单的计算.py文件中“有用”行数的小程序

The definition of "useful" line is that the line is NOT a comment, a docstring, or blank. 关于“有用”的定义如下:该行不是注释、文档字符串或空白

1 How to use / 如何使用

You can enter either a file path or a directory path; 你可以输入文件路径或者目录路径

(if you enter a directory path, the program will recursively count all .py files in that directory and all of its sub-directories) (如果你输入的是目录,这个程序将会递归地将这个目录及其子目录的所有.py文件进行行数统计)

Notice: the blank new line at the end of each file would not be counted 注意:文件最后的空白行不会被计入

2 Example / 范例

For following file whose path is /foo/bar.py 对于路径为/foo/bar.py的文件

#this is a comment

def some_function(par1: int) -> None:
    """This is docstring
    still docstring
    docstring ends here"""
    print('hello{}'.format(par1))  # print something

if __name__ == '__main__':
    some_function(5)

The output will be like 输出为

Please enter a file path for counting single file;
or enter a directory path for counting all .py files in that directory;
an input containing only a dot "." would be considered as current work directory;
an empty input would make the program exit;
Your input: /foo/bar.py
--------------------
/foo/bar.py
The number of lines of useful is 4.
The number of lines of comment is 1.
The number of lines of blank is 2.
The number of lines of docstring is 3.

count_lines's People

Contributors

wangjieke avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.