Skip to content

Commit 01df207

Browse files
authored
Fixed PEP8 in count_lines.py (cyberbotics#6537)
* Fixed PEP8 in count_lines.py * Update count_lines.py * Update count_lines.py * Update count_lines.py
1 parent 03dc321 commit 01df207

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

scripts/count_lines/count_lines.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,25 @@
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+
119
import glob
220
import os
321

22+
423
def 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+
1535
def 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+
2748
count_files(['cpp', 'hpp'], 'C++')
2849
count_files(['c', 'h'], 'C')
2950
count_files(['py'], 'Python')

0 commit comments

Comments
 (0)