Skip to content

Commit c04fd61

Browse files
Zeyue LIANGZeyue LIANG
authored andcommitted
using console argument as input
1 parent dde19a1 commit c04fd61

1 file changed

Lines changed: 29 additions & 12 deletions

File tree

‎zeyue/0007/ComputeCodeLines.py‎

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,18 @@
77
Email: zeyue.liang@gmail.com
88
Github: https://github.com/zeyue
99
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+
1316
This program has been tested using some files in C and in Python,
1417
maybe support java as well.
1518
"""
1619

1720
import os
21+
import sys
1822

1923
"""
2024
Global variables
@@ -188,15 +192,28 @@ def main():
188192
"""main function.
189193
190194
"""
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]))
200217

201218
"""
202219
Launch

0 commit comments

Comments
 (0)