|
7 | 7 | Email: zeyue.liang@gmail.com |
8 | 8 | Github: https://github.com/zeyue |
9 | 9 | Description: |
10 | | - A program that can compute code line numbers in a directory. |
11 | | - Usage: change the variable "directory" in the main funtion and launch |
12 | | - the program then. |
| 10 | + A program that can count code line numbers in a directory. |
| 11 | + Usage: Launce the program in console with directory as argument, it can add |
| 12 | + several directories in one time: |
| 13 | + $python -3 ComputeCodeLines.py <first directory> [second] [...] |
| 14 | + ATTENTION: use "/" in the place of "\" |
| 15 | +
|
13 | 16 | This program has been tested using some files in C and in Python, |
14 | 17 | maybe support java as well. |
15 | 18 | """ |
16 | 19 |
|
17 | 20 | import os |
| 21 | +import sys |
18 | 22 |
|
19 | 23 | """ |
20 | 24 | Global variables |
@@ -188,15 +192,28 @@ def main(): |
188 | 192 | """main function. |
189 | 193 |
|
190 | 194 | """ |
191 | | - # directory = "d:\PythonProjects\python\zeyue" |
192 | | - directory = "d:/NOTBACKEDUP/python/zeyue" |
193 | | - countInDirectory(directory) |
194 | | - |
195 | | - print() |
196 | | - print("Final result in the directory") |
197 | | - print(directory) |
198 | | - for key in result: |
199 | | - print(str(key) + ": " + str(result[key])) |
| 195 | + global file_suffix, inline_comment_syntax, start_comment_syntax |
| 196 | + global end_comment_syntax, multilineCommentStartFlag, result |
| 197 | + for directory in sys.argv[1:]: |
| 198 | + file_suffix = "not defined" |
| 199 | + inline_comment_syntax = "not defined" |
| 200 | + start_comment_syntax = "not defined" |
| 201 | + end_comment_syntax = "not defined" |
| 202 | + multilineCommentStartFlag = 0 |
| 203 | + result = {"Code files": 0, |
| 204 | + "No blank lines": 0, |
| 205 | + "Code lines": 0, |
| 206 | + "Comment lines": 0, |
| 207 | + "Blank lines": 0} |
| 208 | + |
| 209 | + print("this is the directory: " + directory) |
| 210 | + countInDirectory(directory) |
| 211 | + |
| 212 | + print() |
| 213 | + print("Final result in the directory") |
| 214 | + print(directory) |
| 215 | + for key in result: |
| 216 | + print(str(key) + ": " + str(result[key])) |
200 | 217 |
|
201 | 218 | """ |
202 | 219 | Launch |
|
0 commit comments