1+ #!/usr/bin/env python3
2+
3+ # Copyright 1996-2023 Cyberbotics Ltd.
4+ #
5+ # Licensed under the Apache License, Version 2.0 (the "License");
6+ # you may not use this file except in compliance with the License.
7+ # You may obtain a copy of the License at
8+ #
9+ # https://www.apache.org/licenses/LICENSE-2.0
10+ #
11+ # Unless required by applicable law or agreed to in writing, software
12+ # distributed under the License is distributed on an "AS IS" BASIS,
13+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ # See the License for the specific language governing permissions and
15+ # limitations under the License.
16+
17+ """Display the number of lines of codes in this repository for different programming languages."""
18+
119import glob
220import os
321
22+
423def count_lines (filename ):
524 f = open (filename , 'rb' )
625 lines = 0
@@ -12,6 +31,7 @@ def count_lines(filename):
1231 buf = read_f (buf_size )
1332 return lines
1433
34+
1535def count_files (extensions , name ):
1636 line_counter = 0
1737 file_counter = 0
@@ -24,6 +44,7 @@ def count_files(extensions, name):
2444 line_counter += count_lines (f )
2545 print ((name + ':' ).ljust (12 ) + str (line_counter ).ljust (6 ) + ' lines of codes in ' + str (file_counter ).ljust (4 ) + ' files' )
2646
47+
2748count_files (['cpp' , 'hpp' ], 'C++' )
2849count_files (['c' , 'h' ], 'C' )
2950count_files (['py' ], 'Python' )
0 commit comments