file-modification-checker 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: file-modification-checker
3
+ Version: 0.1.0
4
+ Summary: A fast CLI tool to check for modification
5
+ Author: Arel Umut Koyluoglu
@@ -0,0 +1,31 @@
1
+ # Modification Checking Tool
2
+
3
+ ## 0.1.0
4
+
5
+ ### Installing and Importing
6
+ > **Installing**
7
+ Use:
8
+ ```bash
9
+ pip install file_modfication_checker
10
+ ```
11
+ >**Importing**
12
+ Use:
13
+ ```python
14
+ import file_modfication_checker
15
+ ```
16
+ ### Command Usage
17
+ > **How To Use**
18
+ Usage:
19
+ ```bash
20
+ mcheck <folder> [OPTIONS]
21
+ ```
22
+ Arguments:
23
+ <folder> Name of folder to check
24
+
25
+ Options:
26
+ -e, --exclude. File types to ignore
27
+
28
+ > **Result**
29
+ - Red Text: files that were deleted
30
+ - Green Text: files that were added
31
+ - Yellow Text: files that were modified
@@ -0,0 +1,3 @@
1
+ from .modified_checker import find_differences
2
+
3
+ __all__ = ["file_modification_checker"]
@@ -0,0 +1,18 @@
1
+ from .modified_checker import find_differences as find
2
+ from pathlib import Path
3
+ import argparse
4
+ parser = argparse.ArgumentParser(description="tool to check for modifications")
5
+ parser.add_argument("folder", help="Name of folder to scan.")
6
+ parser.add_argument("-e","--exclude", nargs="+", required= False, default=[], help = "file suffixes to exclude (seperate by spaces)")
7
+ args=parser.parse_args()
8
+ folder = Path(args.folder)
9
+ new, deleted, modified = find(folder)
10
+ def return_values():
11
+ for change_type in [new, deleted, modified]:
12
+ for change in change_type.copy():
13
+ print(change, change.name)
14
+ if change.suffix in args.exclude:
15
+ change_type.remove(change)
16
+ print(f"\033[31mDeleted Files: {[file.name for file in deleted]}\033[0m")
17
+ print(f"\033[32mAdded Files: {[file.name for file in new]}\033[0m")
18
+ print(f"\033[33mModified Files: {[file.name for file in modified]}\033[0m")
@@ -0,0 +1,37 @@
1
+ #!/usr/bin/env python3
2
+ from pathlib import Path
3
+ from multiprocessing import Pool, cpu_count
4
+ #lets try with file names instead of file sizes
5
+ def get_file_sizes(folder:Path)->list:
6
+ list_of_file_sizes = []
7
+ for item in folder.iterdir():
8
+ if item.is_file():
9
+ list_of_file_sizes.append(item)
10
+ else:
11
+ list_of_file_sizes.extend(get_file_sizes(item))
12
+ continue
13
+ return list_of_file_sizes
14
+
15
+ def find_differences(folder)->list:
16
+ #get the file sizes before the changes
17
+ before_changes = get_file_sizes(folder)
18
+ before_changes_texts = [file.read_text() for file in before_changes]
19
+ #wait for the user to make changes to the files in the folder
20
+ input("Make changes to the files in the folder and press Enter when done. ")
21
+ #get the file sizes after the changes
22
+ after_changes = get_file_sizes(folder)
23
+ #find the differences between the two lists of file sizes
24
+ deleted_differences = [file for file in before_changes if file not in after_changes]
25
+ new_differences = [file for file in after_changes if file not in before_changes]
26
+ #find the modified files
27
+ modified_differences = []
28
+ #set before and after changes to exclude the new and deleted files
29
+ before_changes = [file for file in before_changes if file not in deleted_differences]
30
+ after_changes = [file for file in after_changes if file not in new_differences]
31
+ #compare the texts of the files
32
+ for index in range(len(before_changes)):
33
+ file = before_changes[index]
34
+ if before_changes_texts[index] != after_changes[index].read_text():
35
+ modified_differences.append(file)
36
+ #return the differences
37
+ return new_differences, deleted_differences, modified_differences
@@ -0,0 +1,5 @@
1
+ Metadata-Version: 2.4
2
+ Name: file-modification-checker
3
+ Version: 0.1.0
4
+ Summary: A fast CLI tool to check for modification
5
+ Author: Arel Umut Koyluoglu
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ file_modification_checker/__init__.py
4
+ file_modification_checker/cli.py
5
+ file_modification_checker/modified_checker.py
6
+ file_modification_checker.egg-info/PKG-INFO
7
+ file_modification_checker.egg-info/SOURCES.txt
8
+ file_modification_checker.egg-info/dependency_links.txt
9
+ file_modification_checker.egg-info/entry_points.txt
10
+ file_modification_checker.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mcheck = file_modification_checker.cli:return_values
@@ -0,0 +1 @@
1
+ file_modification_checker
@@ -0,0 +1,15 @@
1
+ [project]
2
+ name = "file-modification-checker"
3
+ version = "0.1.0"
4
+ description = "A fast CLI tool to check for modification"
5
+ authors = [
6
+ {name = "Arel Umut Koyluoglu"}
7
+ ]
8
+ dependencies = []
9
+
10
+ [project.scripts]
11
+ mcheck = "file_modification_checker.cli:return_values"
12
+
13
+ [build-system]
14
+ requires = ["setuptools"]
15
+ build-backend = "setuptools.build_meta"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+