Skip to content

Commit 77cacf8

Browse files
committed
Merge branch 'master' into Numpy_2_adaptations
2 parents 1edac3a + 9e880d8 commit 77cacf8

File tree

2 files changed

+142
-8
lines changed

2 files changed

+142
-8
lines changed

README.md

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,73 @@ In order to learn more about [``itom``](https://itom-project.github.io/ "``itom`
1414
## What is this project for?
1515

1616
This project contains the core application of:
17+
1718
* [itom](https://github.com/itom-project/itom) core application
1819

1920
Furthermore, you may also need the ``plugins`` and ``designer plugins`` repositories to get all itom functionalities.
21+
2022
* [plugins](https://github.com/itom-project/plugins) hardware/software plugins
2123
* [designer plugins](https://github.com/itom-project/designerPlugins) widget plugins
2224

2325
## How do I get set up?
2426

2527
* In order to get itom either download the ready-to-use setups for Windows 32bit and 64bit. Use the [all-in-one installer](https://sourceforge.net/projects/itom/files/all-in-one-build-setup/ "all-in-one installer") in order to get itom including Python and some important Python packages or use the simple installer if you already have an appropriate version of Python installed on your computer.
28+
2629
* Clone the central repositoy [itomProject](https://github.com/itom-project/itomProject) with the **--recursive** Option.
30+
2731
```bash
2832
git clone --recursive --remote [email protected]:itom-project/itomProject.git
2933
```
34+
3035
This will download the submodule repositories [itom](https://github.com/itom-project/itom) core, plugins [plugins](https://github.com/itom-project/plugins) and [designer plugins](https://github.com/itom-project/designerPlugins). For more information see the corresponding [section](https://itom-project.github.io/latest/docs/02_installation/build_dependencies.html) in the user documentation.
31-
* [``itom``](https://itom-project.github.io/ "``itom``") is written in C++ and requires the Qt framework in version >5.6 (Qt6 is supported for version > 6.2). It is further dependent on OpenCV, the Point Cloud Library (optional) and Python 3.6 or higher including its important package [Numpy](https://numpy.org/doc/stable/index.html "Numpy").
3236

37+
* [``itom``](https://itom-project.github.io/ "``itom``") is written in C++ and requires the Qt framework in version >5.6 (Qt6 is supported for version > 6.2). It is further dependent on OpenCV, the Point Cloud Library (optional) and Python 3.6 or higher including its important package [Numpy](https://numpy.org/doc/stable/index.html "Numpy").
3338

3439
## Contribution
3540

3641
You are welcome to use and test [``itom``](https://itom-project.github.io/ "``itom``"). If you want to you are invited to participate in the development of [``itom``](https://itom-project.github.io/ "``itom``") or some of its plugins. If you found any bug, feel free to post an [issue](https://github.com/itom-project/itom/issues "issue").
3742

3843
### pre-commit hooks
44+
3945
After the first cloning of the repositories, the [pre-commit](https://pre-commit.com/ "pre-commit") hooks should be installed once.
46+
4047
```bash
4148
python -m pre_commit install
4249
```
50+
4351
#### (optional) run against all files
52+
4453
It's usually a good idea to run the hooks against all of the files when adding new hooks (usually ``pre-commit`` will only run on the changed files during git hooks).
54+
4555
```bash
4656
python -m pre_commit run --all-files
4757
```
4858

49-
# Licensing
59+
## Licensing
60+
5061
The core components and the main application of itom are covered by the [GNU Library General Public Licence (GNU LGPL)](https://github.com/itom-project/itom/blob/master/COPYING.txt "GNU Library General Public Licence (GNU LGPL)"). All components belonging to the SDK of [``itom``](https://itom-project.github.io/ "``itom``") (e.g. dataObject, pointCloud, addInInterface,…) are additionally covered by an [``itom``](https://itom-project.github.io/ "``itom``") exception. The main idea of this exception is to allow other libraries (e.g. plugins) to include and link against components of itom SDK independent on the specific license model of the respective "other" library. All files belonging to the itom SDK are included in the folder SDK that is shipped with any setup or included in the build directory (when build from sources).
5162

5263
## itom Exception
64+
5365
The full text license of LGPL and itom [exception](https://github.com/itom-project/itom/blob/master/LGPL_EXCEPTION.txt "exception") is also included as file [COPYING](https://github.com/itom-project/itom/blob/master/COPYING.txt "COPYING") in the source distributions and setups.
5466

5567
All plugins and designer-plugins that can be integrated into itom can have their own licensing. Therefore the user is referred to the specific licensing documents or statements of each external library (plugin).
5668

57-
# Contact
69+
## Contact
5870

5971
[``itom``](https://itom-project.github.io/ "``itom``") is being developed since 2011 by
6072

6173
> [Institut für Technische Optik](http://www.uni-stuttgart.de/ito)
62-
74+
>
6375
> University of Stuttgart
64-
76+
>
6577
> Stuttgart
66-
78+
>
6779
> Germany
6880
6981
in co-operation with
7082
> [twip Optical Solutions GmbH](http://www.twip-os.com)
71-
83+
>
7284
> Stuttgart
73-
85+
>
7486
> Germany

docs/countLinesOfCode.py

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import os
2+
from typing import Dict, List
3+
4+
5+
def count_lines_of_code(directory: str, extensions: Dict[str, str]) -> Dict[str, int]:
6+
"""
7+
Count the lines of code for each file extension in the specified directory.
8+
9+
Args:
10+
directory (str): The directory where the project is located.
11+
extensions (Dict[str, str]): A dictionary mapping file extensions to their programming languages.
12+
13+
Returns:
14+
Dict[str, int]: A dictionary mapping file extensions to the total lines of code counted.
15+
"""
16+
totalLines = {ext: 0 for ext in extensions} # Initialize with 0 for each extension
17+
for ext, language in extensions.items():
18+
total = 0
19+
for dirpath, _, filenames in os.walk(directory):
20+
for filename in filenames:
21+
if filename.endswith(ext):
22+
file_path = os.path.join(dirpath, filename)
23+
try:
24+
with open(file_path, encoding="utf-8") as file:
25+
lines = file.readlines()
26+
lines_count = len(lines)
27+
total += lines_count
28+
except (UnicodeDecodeError, FileNotFoundError):
29+
print(f"Could not read file: {file_path}")
30+
totalLines[ext] = total
31+
return totalLines
32+
33+
34+
def sum_lines_of_code_for_multiple_directories(
35+
directories: List[str], extensions: Dict[str, str]
36+
) -> Dict[str, Dict[str, int]]:
37+
"""
38+
Count the lines of code for each file extension across multiple project directories.
39+
40+
Args:
41+
directories (List[str]): A list of directories representing different projects.
42+
extensions (Dict[str, str]): A dictionary mapping file extensions to their programming languages.
43+
44+
Returns:
45+
Dict[str, Dict[str, int]]: A dictionary with project names as keys and
46+
another dictionary mapping file extensions to their total lines of code in each project.
47+
"""
48+
all_project_lines = {}
49+
total_lines_per_extension = {ext: 0 for ext in extensions}
50+
51+
for directory in directories:
52+
project_name = os.path.basename(directory)
53+
lines_in_project = count_lines_of_code(directory, extensions)
54+
all_project_lines[project_name] = lines_in_project
55+
56+
# Sum up total lines across all projects for each extension
57+
for ext, lines in lines_in_project.items():
58+
total_lines_per_extension[ext] += lines
59+
60+
all_project_lines["total"] = total_lines_per_extension
61+
return all_project_lines
62+
63+
64+
def generate_markdown_table_for_multiple_projects(
65+
project_lines: Dict[str, Dict[str, int]], extensions: Dict[str, str]
66+
) -> str:
67+
"""
68+
Generate a Markdown-formatted table showing lines of code for each file extension across multiple projects.
69+
70+
Args:
71+
project_lines (Dict[str, Dict[str, int]]): A dictionary mapping project names to
72+
another dictionary mapping file extensions to the total lines of code.
73+
extensions (Dict[str, str]): A dictionary mapping file extensions to their programming languages.
74+
75+
Returns:
76+
str: A Markdown-formatted table showing lines of code across multiple projects and their totals.
77+
"""
78+
# Create Markdown table header
79+
header_projects = " | ".join(project_lines.keys())
80+
markdown_table = f"| File Extension | Language | {header_projects} |\n"
81+
82+
# Create separator row
83+
separator = f"|{'-' * 15}|{'-' * 18}|{'-' * (len(header_projects) + 4)}|\n"
84+
markdown_table += separator
85+
86+
# Populate table rows
87+
for ext, language in extensions.items():
88+
row = f"| {ext.ljust(13)} | {language.ljust(16)} "
89+
for project in project_lines:
90+
row += f"| {str(project_lines[project].get(ext, 0)).rjust(6)} "
91+
row += "|\n"
92+
markdown_table += row
93+
94+
return markdown_table
95+
96+
97+
if __name__ == "__main__":
98+
# Define file extensions and their corresponding programming languages
99+
extensions = {
100+
".py": "Python",
101+
".cpp": "C++",
102+
".h": "C++",
103+
".c": "C",
104+
".cmake": "CMake",
105+
".txt": "Text",
106+
".rst": "RestructuredText",
107+
".css": "CSS",
108+
}
109+
110+
# Define the list of project directories
111+
project_directories = [
112+
r"C:\itom\sources\itom", # itom core
113+
r"C:\itom\sources\plugins", # plugins
114+
r"C:\itom\sources\designerPlugins", # designer plugins
115+
]
116+
117+
# Count lines of code for all project directories
118+
total_lines = sum_lines_of_code_for_multiple_directories(project_directories, extensions)
119+
120+
# Generate and print Markdown table for all projects
121+
markdown_output = generate_markdown_table_for_multiple_projects(total_lines, extensions)
122+
print(markdown_output)

0 commit comments

Comments
 (0)