[UPD] script: format code
This commit is contained in:
parent
1fdad0ee31
commit
6bb4dafba6
3 changed files with 37 additions and 17 deletions
|
|
@ -30,7 +30,11 @@ def get_config():
|
||||||
)
|
)
|
||||||
parser.add_argument("--csv_1", required=True, help="CSV file first")
|
parser.add_argument("--csv_1", required=True, help="CSV file first")
|
||||||
parser.add_argument("--csv_2", required=True, help="CSV file second")
|
parser.add_argument("--csv_2", required=True, help="CSV file second")
|
||||||
parser.add_argument("--compare_key", required=True, help="Key to search and compare with it.")
|
parser.add_argument(
|
||||||
|
"--compare_key",
|
||||||
|
required=True,
|
||||||
|
help="Key to search and compare with it.",
|
||||||
|
)
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
@ -38,8 +42,8 @@ def get_config():
|
||||||
def main():
|
def main():
|
||||||
config = get_config()
|
config = get_config()
|
||||||
|
|
||||||
with open(config.csv_1, mode='r') as csv_file_1:
|
with open(config.csv_1, mode="r") as csv_file_1:
|
||||||
with open(config.csv_2, mode='r') as csv_file_2:
|
with open(config.csv_2, mode="r") as csv_file_2:
|
||||||
csv_reader_1 = csv.DictReader(csv_file_1)
|
csv_reader_1 = csv.DictReader(csv_file_1)
|
||||||
csv_reader_2 = csv.DictReader(csv_file_2)
|
csv_reader_2 = csv.DictReader(csv_file_2)
|
||||||
lst_csv_1 = [a.get(config.compare_key) for a in csv_reader_1]
|
lst_csv_1 = [a.get(config.compare_key) for a in csv_reader_1]
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,9 @@ import argparse
|
||||||
import logging
|
import logging
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
new_path = os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))
|
new_path = os.path.normpath(
|
||||||
|
os.path.join(os.path.dirname(__file__), "..", "..")
|
||||||
|
)
|
||||||
sys.path.append(new_path)
|
sys.path.append(new_path)
|
||||||
|
|
||||||
from script.git_tool import GitTool
|
from script.git_tool import GitTool
|
||||||
|
|
|
||||||
|
|
@ -37,14 +37,22 @@ def get_config():
|
||||||
parser.add_argument("--backup_2", help="Backup name second")
|
parser.add_argument("--backup_2", help="Backup name second")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
die(bool(args.backup_file_1) and bool(args.backup_1),
|
die(
|
||||||
"Take only --backup_file_1 or --backup_1")
|
bool(args.backup_file_1) and bool(args.backup_1),
|
||||||
die(not bool(args.backup_file_1) and not bool(args.backup_1),
|
"Take only --backup_file_1 or --backup_1",
|
||||||
"Missing --backup_file_1 or --backup_1")
|
)
|
||||||
die(bool(args.backup_file_2) and bool(args.backup_2),
|
die(
|
||||||
"Take only --backup_file_2 or --backup_2")
|
not bool(args.backup_file_1) and not bool(args.backup_1),
|
||||||
die(not bool(args.backup_file_2) and not bool(args.backup_2),
|
"Missing --backup_file_1 or --backup_1",
|
||||||
"Missing --backup_file_2 or --backup_2")
|
)
|
||||||
|
die(
|
||||||
|
bool(args.backup_file_2) and bool(args.backup_2),
|
||||||
|
"Take only --backup_file_2 or --backup_2",
|
||||||
|
)
|
||||||
|
die(
|
||||||
|
not bool(args.backup_file_2) and not bool(args.backup_2),
|
||||||
|
"Missing --backup_file_2 or --backup_2",
|
||||||
|
)
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
|
|
@ -62,10 +70,10 @@ def main():
|
||||||
else:
|
else:
|
||||||
file_path_2 = os.path.join("image_db", f"{config.backup_2}.zip")
|
file_path_2 = os.path.join("image_db", f"{config.backup_2}.zip")
|
||||||
|
|
||||||
with zipfile.ZipFile(file_path_1, 'r') as zip_ref:
|
with zipfile.ZipFile(file_path_1, "r") as zip_ref:
|
||||||
manifest_file_1 = zip_ref.open("manifest.json")
|
manifest_file_1 = zip_ref.open("manifest.json")
|
||||||
|
|
||||||
with zipfile.ZipFile(file_path_2, 'r') as zip_ref:
|
with zipfile.ZipFile(file_path_2, "r") as zip_ref:
|
||||||
manifest_file_2 = zip_ref.open("manifest.json")
|
manifest_file_2 = zip_ref.open("manifest.json")
|
||||||
|
|
||||||
json_manifest_file_1 = json.load(manifest_file_1)
|
json_manifest_file_1 = json.load(manifest_file_1)
|
||||||
|
|
@ -81,10 +89,16 @@ def main():
|
||||||
print(f"{len(same)} same")
|
print(f"{len(same)} same")
|
||||||
if same:
|
if same:
|
||||||
print(same)
|
print(same)
|
||||||
print(f"{Fore.BLUE}{len(difference_1)}{Style.RESET_ALL} difference manifest 1 to manifest 2")
|
print(
|
||||||
|
f"{Fore.BLUE}{len(difference_1)}{Style.RESET_ALL} difference manifest"
|
||||||
|
" 1 to manifest 2"
|
||||||
|
)
|
||||||
if difference_1:
|
if difference_1:
|
||||||
print(difference_1)
|
print(difference_1)
|
||||||
print(f"{Fore.MAGENTA}{len(difference_2)}{Style.RESET_ALL} difference manifest 2 to manifest 1")
|
print(
|
||||||
|
f"{Fore.MAGENTA}{len(difference_2)}{Style.RESET_ALL} difference"
|
||||||
|
" manifest 2 to manifest 1"
|
||||||
|
)
|
||||||
if difference_2:
|
if difference_2:
|
||||||
print(difference_2)
|
print(difference_2)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue