Skip to content

Commit

Permalink
Fixed PEP8 in count_lines.py (#6537)
Browse files Browse the repository at this point in the history
* Fixed PEP8 in count_lines.py

* Update count_lines.py

* Update count_lines.py

* Update count_lines.py
  • Loading branch information
omichel authored Apr 11, 2024
1 parent 03dc321 commit 01df207
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions scripts/count_lines/count_lines.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,25 @@
#!/usr/bin/env python3

# Copyright 1996-2023 Cyberbotics Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Display the number of lines of codes in this repository for different programming languages."""

import glob
import os


def count_lines(filename):
f = open(filename, 'rb')
lines = 0
Expand All @@ -12,6 +31,7 @@ def count_lines(filename):
buf = read_f(buf_size)
return lines


def count_files(extensions, name):
line_counter = 0
file_counter = 0
Expand All @@ -24,6 +44,7 @@ def count_files(extensions, name):
line_counter += count_lines(f)
print((name + ':').ljust(12) + str(line_counter).ljust(6) + ' lines of codes in ' + str(file_counter).ljust(4) + ' files')


count_files(['cpp', 'hpp'], 'C++')
count_files(['c', 'h'], 'C')
count_files(['py'], 'Python')
Expand Down

0 comments on commit 01df207

Please sign in to comment.