Soft-tasking (b): Individual project -wc.exe (Python implementation)

Github Address


 https://github.com/zhengjinhuai/wc.exe

 

Project requirements


  1.  wc.exe is a common tool that counts the number of characters in a text document, words, and lines. The project asked to write a command line program, to mimic the function of the existing wc.exe, and be expanded while using the GUI to visualize
  2. Specific functional requirements:
    • Program processing mode as user requirements: wc.exe [Parameter] [file_name]
  3. basic skills:
    • wc.exe -c file.c // returns the number of characters in the file file.c
    • The number of wc.exe -w file.c // Returns the file of the word file.c
    • wc.exe -l file.c // returns the number of rows of file file.c
  4. extensions:
    • Under -s Process directories recursively eligible files
    • -a return more complex data (line / space lines / comment lines)
  5. Advanced Features:
    •  -x parameter. This parameter is used alone. If you have the command line parameters, the program will display a graphical interface, the user can select a single file through the interface, the program will display the file number of characters, lines, etc. All statistics.
    • Demand For example: wc.exe -s -a * .c

 

PSP table:


 

PSP2.1 Personal Software Process Stages Estimated time consuming (minutes) The actual time-consuming (minutes)
Planning plan 20 18
· Estimate • Estimate how much time this task requires 20 18
Development Develop 770 850
· Analysis · demand analysis  60 70
· Design Spec Generate design documents 50 50
· Design Review · Design Review  30 40
· Coding Standard · Code Specification 20 20
· Design · Specific design 90 90
· Coding · Specific coding 310 350
· Code Review · Code Review 100 110
· Test · Test (self-test, modify the code, submit modifications) 120 110
Reporting report 140 125
· Test Report · testing report 60 50
· Size Measurement · Computing workload 30 20
· Postmortem & Process Improvement Plan · Hindsight, and propose process improvement plan 50 55
Total  total 940 983

 

Problem-solving ideas


  See the topic asked to write a command line program, immediately thought argparse command parameter analysis module usually frequently used, and therefore decided to use python to complete this project

  1. Parsing the command line parameters used argparse module () function to set parameters, options, -c, -w, -l, -s, -a, -x optional parameter settings, file absolute path for the location parameters add_argument
  2. During the processing of text characters, words, information such as the number of rows using the readline () function, str.strip () method, str.split () method with the use, at the same time, considering the boundary information
  3. Since the recursive process using the wildcard matching document directory relatively cumbersome, at the same time, there are various combinations of wildcards, the use of glob module fitting process to ensure that the test procedure withstand
  4. Empty lines and lines relatively easy to handle, to filter the empty lines and comments, the rest of the code lines.
    • Processing a comment line is divided into four cases: "single comment symbol", "multi-line comment symbol", "multi-line comments in the same symbol row" and "multi-line comments beginning and ending lines" (see Specific Code comment)
    • In consideration comment symbols in different programming languages ​​are not the same, it is possible to select a set CONF configuration file to store annotation symbols of different languages, the processing corresponding to different programming languages
  5. Use graphical interface PyQt5. Now that python graphical interface development more choice PyQt5, therefore choose this, almost the same usage and other languages

 

Design and implementation process


 

 

 

 

Project Test


 

  1.   Terminal test
  2.  Number of characters in a single file test, words, lines, comment lines, blank lines, lines of code
  3. Recursive query test 
    •  
  4. Recursive queries and processing


  5. gui
    •  

       

  6. Code coverage
    • I feel sleepy

 

Project Summary


 

  I think ah ...... 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/jinhuai/p/11545996.html