mirror of
https://github.com/YunoHost/package_linter.git
synced 2024-09-03 20:06:12 +02:00
commit
2633503658
1 changed files with 11 additions and 8 deletions
|
@ -37,19 +37,21 @@ def print_wrong(str):
|
|||
def check_files_exist(app_path):
|
||||
"""
|
||||
Check files exist
|
||||
'backup' and 'restore' scripts are mandatory
|
||||
"""
|
||||
return_code = 0
|
||||
|
||||
print (c.BOLD + c.HEADER + ">>>> MISSING FILES <<<<" + c.END)
|
||||
print(c.BOLD + c.HEADER + ">>>> MISSING FILES <<<<" + c.END)
|
||||
fnames = ("manifest.json", "scripts/install", "scripts/remove",
|
||||
"scripts/upgrade", "scripts/backup", "scripts/restore", "LICENSE", "README.md")
|
||||
|
||||
for fname in fnames:
|
||||
for nbr, fname in enumerate(fnames):
|
||||
if check_file_exist(app_path + "/" + fname):
|
||||
print_right(fname)
|
||||
else:
|
||||
print_wrong(fname)
|
||||
return_code = 1
|
||||
if nbr != 4 and nbr != 5:
|
||||
return_code = 1
|
||||
|
||||
return return_code
|
||||
|
||||
|
@ -66,7 +68,7 @@ def read_file(file_path):
|
|||
|
||||
|
||||
def check_source_management(app_path):
|
||||
print (c.BOLD + c.HEADER + "\n>>>> SOURCES MANAGEMENT <<<<" + c.END)
|
||||
print(c.BOLD + c.HEADER + "\n>>>> SOURCES MANAGEMENT <<<<" + c.END)
|
||||
DIR = os.path.join(app_path, "sources")
|
||||
# Check if there is more than six files on 'sources' folder
|
||||
if os.path.exists(os.path.join(app_path, "sources")) and \
|
||||
|
@ -79,7 +81,7 @@ def check_source_management(app_path):
|
|||
|
||||
|
||||
def check_manifest(manifest):
|
||||
print (c.BOLD + c.HEADER + "\n>>>> MANIFEST <<<<" + c.END)
|
||||
print(c.BOLD + c.HEADER + "\n>>>> MANIFEST <<<<" + c.END)
|
||||
"""
|
||||
Check if there is no comma syntax issue
|
||||
"""
|
||||
|
@ -176,14 +178,14 @@ def check_script(path, script_name, script_nbr):
|
|||
if check_file_exist(script_path) == 0:
|
||||
return
|
||||
|
||||
print (c.BOLD + c.HEADER + "\n>>>>",
|
||||
print(c.BOLD + c.HEADER + "\n>>>>",
|
||||
script_name.upper(), "SCRIPT <<<<" + c.END)
|
||||
|
||||
script = read_file(script_path)
|
||||
|
||||
return_code = check_non_helpers_usage(script) or return_code
|
||||
if script_nbr < 5:
|
||||
return_code = check_verifications_done_before_modifying_system(script) or return_code
|
||||
check_verifications_done_before_modifying_system(script)
|
||||
return_code = check_set_usage(script_name, script) or return_code
|
||||
check_arg_retrieval(script)
|
||||
|
||||
|
@ -223,6 +225,7 @@ def check_verifications_done_before_modifying_system(script):
|
|||
"Verifications (with 'ynh_die' or 'exit' commands) are done before any system modification.")
|
||||
return 0
|
||||
|
||||
|
||||
def check_non_helpers_usage(script):
|
||||
"""
|
||||
check if deprecated commands are used and propose helpers:
|
||||
|
@ -297,7 +300,7 @@ def check_arg_retrieval(script):
|
|||
if line_nbr > 30:
|
||||
exitFlag = True
|
||||
break
|
||||
if exitFlag == True:
|
||||
if exitFlag is True:
|
||||
break
|
||||
|
||||
if present:
|
||||
|
|
Loading…
Reference in a new issue