Read and analyse the files in your projects.
Project description
Read and summarize the files in your projects. An easy way to achieve the following:
Count the number of lines in your project.
Visualize the hierarchy of the files in your project.
Create a summary of all files.
Using project reader from console
This entails running project_reader module in console python -m project.read. It takes one positional argument and two other optional arguments. The positional argument is the path of the project.
python -m project.read "C:\Users\admin\django projects\blog-site"
Optional one is the folders to ignore in a comma-separated string.
python -m project.read "C:\Users\admin\django projects\blog-site" --ignore ".idea, .vscode"
Optional two is the final output file.
python -m project.read "C:\Users\admin\django projects\blog-site" --output "blog_site_tree.txt"
OR
python -m project.read "C:\Users\admin\django projects\blog-site" --ignore ".idea, .vscode" --output "blog_site_tree.txt"
This will output a file a tree visualizing you project.
Go ahead and run the line below to learn more
python -m project.read -h
Using project reader in python code or from the interpreter
You can choose to use from the interpreter or in your code using the help of project.folder_reader.py and project.folder_visualizer.py
Folder visualizer (project.folder_visualizer.py)
Example 1
question_1.py - 38
question_2(factorial).py - 66
question_21.py - 45
.IDEA
github projects 2.iml - 11
misc.xml - 5
modules.xml - 9
workspace.xml - 17
DICTIONARIES
muremwa.xml - 5
---- END OF DICTIONARIES ----
---- END OF .IDEA ----
DESC
Run the code below
from project.folder_visualizer import assign_classes, draw
klasses = assign_classes('test_FOLDER_GITHUB_PROJECTS_2.txt')
draw(klasses, file_name="results.txt")
This is the output in “results.txt”
Example 2
GITHUB_PROJECTS_2
|
|---- question_1.py (38 lines)
|
|---- question_2(factorial).py (66 lines)
|
|---- question_21.py (45 lines)
|
|---- .IDEA
| |
| |---- github projects 2.iml (11 lines)
| |
| |---- misc.xml (5 lines)
| |
| |---- modules.xml (9 lines)
| |
| |---- workspace.xml (17 lines)
| |
| |---- DICTIONARIES
| | |
| | |---- muremwa.xml (5 lines)
|
|---- DESC
Folder reader (project.folder_reader.py)
Contains the following classes:
KillerFolder - extends the Folder class from project.folder_visualizer.py but adds the following methods (eq) and statement and the path property.
KillerFile - extends the File class from project.folder_visualizer.py but adds the path property
FolderStore - extends the in-built list class. It stores only KillerFolder objects.
RootDoesNotExist - an exception that is raised when one tries to access the root KillerFolder object of a FolderStore object that has none.
Contains the following functions:
kill_project - takes in a path of the folder to read, reads and returns a string representative of the files and folders similar to [example 1](#Example 1) above. You can add a keyword argument called ignore to show what folders to ignore.
print_statement - takes the statement from kill_project and writes it to a file and returns the name of that file. Usually FOLDER_SOMETHING.txt
Using project.folder_reader.py (demonstrated using the folder names TOP)
import os
from project.folder_reader import kill_project, print_statement
# change into the folder you want to read
os.chdir(os.getcwd() + "\\TOP")
# get the statement
statement = kill_project(os.getcwd(), ignore=['.vscode', '.idea'])
# write the statement to a file
file_name = print_statement(statement) # the file_name can be passes into folder_visualizer.assign_classes()
The last line writes to a file called “FOLDER_TOP.txt”
file.txt - 1
VO
s.txt - 1
KO
l1.txt - 1
---- END OF KO ----
---- END OF VO ----
XO
n.txt - 1
BO
temp.txt - 1
---- END OF BO ----
JO
sd.txt - 1
PO
l.txt - 1
---- END OF PO ----
---- END OF JO ----
---- END OF XO ----
Notice how the folder ‘.idea’ was ignored.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file project-reader-0.0.3.tar.gz
.
File metadata
- Download URL: project-reader-0.0.3.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2f63d68e92c820a524a720d6e7593113bbe8283d7e740d669aa28d2e415f12ec |
|
MD5 | c06f43e6c87fb6f9ab4d46d11bf2195c |
|
BLAKE2b-256 | 2b138902bf9f7d675c242a92c67f51a522e20ced833ba86d2b0046d904d8f2e7 |
File details
Details for the file project_reader-0.0.3-py3-none-any.whl
.
File metadata
- Download URL: project_reader-0.0.3-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49ddda1e9ed0fd66d372a044be7bb4087fbfbfa9742781a21c2c528b246efe67 |
|
MD5 | 3c726d19be97f62c65d204269c9f80cd |
|
BLAKE2b-256 | 0fed22b484f2d714ea0a2e300f05b6600d19af203d5c2cfcf1c8b25c816bd5ce |