CPPinator
CPPinator is a Python automation script designed for compiling and running multiple C++ files in a specified directory. It simplifies the process of handling multiple C++ programs and provides a clear and organized output for each program's execution along with the execution time for each program.
How it works
-
The script allows you to specify a directory path where your C++ source code files are located.
-
It changes the current working directory to the specified path.
-
CPPinator lists all the C++ source code files with the
.cppextension in the directory. -
For each
.cppfile found, it compiles the code usingg++and runs the resulting executable. -
The script captures and displays the output and any errors produced by each program.
-
Upon successful execution of all C++ files, it provides a summary message.
-
Finally, the compiled executable file (
a.exe) is deleted to keep your directory clean.
Usage
-
Ensure you have Python and a C++ compiler (e.g., g++) installed on your system.
-
Install the
CPPinatorpackage from PyPI using pip:pip install CPPinator
OR
Clone or download the
CPPinator.pyscript to your local machine.git clone https://github.com/Hardvan/CPPinator cd CPPinator pip install .
-
Call the
compile_and_run_cpp_filesfunction from theCPPinatorpackage with the directory path as an argument.from CPPinator import compile_and_run_cpp_files compile_and_run_cpp_files("path/to/your/directory")
View the
run.pyfile for an example of how to use theCPPinatorpackage.
Example Output
Here's an example of the script's output when run with a list of C++ files in the Basic Problems directory.
Changing working directory... Current working directory: F:\CPPinator\Basic Problems
List of .cpp files:
count_digits.cppdivisors.cppgcd.cpppalindrome_number.cppprime.cppreverse_array.cppreverse_number.cpp
Running .cpp files:
-
count_digits.cpp(1.07s)No. of digits in 123456789 is:
9
9
9
Expected: 9 -
divisors.cpp(1.14s)Divisors of 100 are:
1 100 2 50 4 25 5 20 10
Divisors of 100 are:
1 2 4 5 10 20 25 50 100
Expected: 1 2 4 5 10 20 25 50 100 -
gcd.cpp(1.16s)GCD of 12 and 15 is:
3
3
Expected: 3 -
palindrome_number.cpp(1.07s)12321 is palindrome: true
Expected: true -
prime.cpp(1.11s)100 is not prime
100 is not prime
Expected: not prime -
reverse_array.cpp(1.05s)Original array:
1 2 3 4 5
Reversed array using two pointers:
5 4 3 2 1
Reversed array using recursion:
5 4 3 2 1
Reversed array using temporary array:
5 4 3 2 1
Expected: 5 4 3 2 1 -
reverse_number.cpp(1.24s)Reverse of 123456789 is: 987654321
Expected: 987654321
✅ Ran all C++ files successfully. (7.84s)
Metadata
Release files for CPPinator 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| CPPinator-1.0.5.tar.gz | 5.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| CPPinator-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.1 kB
Release files / CPPinator-1.0.5.tar.gz
| Download URL | CPPinator-1.0.5.tar.gz |
|---|---|
| Size | 5.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6de908c83672d96163aa4a495714668b3e2df46382ea85815cf9d42f3ff18c7f
|
|
BLAKE2b-256 checksum How to use checksums |
64f345118629deae461d88649cad258582e15e16281ea15c221d5a344f3d37ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.4
|
Release files / CPPinator-1.0.5-py3-none-any.whl
| Download URL | CPPinator-1.0.5-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01fcc599af3b12dfe4cdaaf9122919e1f20f86699fb328292df1b8ebdda4787b
|
|
BLAKE2b-256 checksum How to use checksums |
3611be4e76cb7b7fae1383c67738e0f4b60f45c5c515760140a2c0aed67477cd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.10.4
|