Skip to content

Commit 9311965

Browse files
committed
add: third step, read_file_json
1 parent 8ac76d2 commit 9311965

File tree

9 files changed

+43
-8
lines changed

9 files changed

+43
-8
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ dist/
66
.coverage
77
coverage.xml
88
*_cache/
9+
file1.json
10+
file2.json

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,8 @@ check: test lint
1818
build:
1919
uv build
2020

21+
file-test:
22+
uv run gendiff /home/zk/python-project-50/file1.json /home/zk/python-project-50/file2.json
23+
2124
.PHONY: install test lint selfcheck check build
2225

gendiff/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from gendiff.cli import parse_args
2+
from gendiff.diff import compare_data_from_files, main, read_file_json
3+
4+
__all__ = [
5+
'parse_args',
6+
'compare_data_from_files',
7+
'read_file_json',
8+
'main',
9+
]

gendiff/cli.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@ def parse_args():
55
parser = argparse.ArgumentParser(
66
prog='gendiff',
77
description='Compares two configuration files and shows a difference.',
8-
epilog='Hi, Lyova Parsyan!)'
8+
epilog='Hi, Lyova!)'
99
)
1010

1111
parser.add_argument('-f', '--format', help='set format of output')
1212
parser.add_argument('first_file')
1313
parser.add_argument('second_file')
1414

1515
return parser.parse_args()
16-

gendiff/diff.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
3+
from gendiff.cli import parse_args
4+
5+
6+
def main() -> None:
7+
args = parse_args()
8+
data1 = read_file_json(args.first_file)
9+
data2 = read_file_json(args.second_file)
10+
# result = compare_data_from_files(data1, data2)
11+
print(data1, data2)
12+
13+
14+
def read_file_json(path: str):
15+
try:
16+
with open(path, mode='r', encoding='utf-8') as file:
17+
return json.load(file)
18+
except Exception as error:
19+
print("Can't read_file_json\n", error)
20+
return None
21+
22+
23+
def compare_data_from_files(data1: dict, data2: dict):
24+
pass

gendiff/scripts/__init.py__

Whitespace-only changes.
File renamed without changes.

gendiff/scripts/gendiff.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
from gendiff.cli import parse_args
2-
3-
4-
def main():
5-
parse_args()
6-
1+
from gendiff.diff import main
72

83
if __name__ == '__main__':
94
main()

te.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import os
2+
3+
print(os.getcwd())

0 commit comments

Comments
 (0)