working on project class and implegmenting tests
This commit is contained in:
@@ -2,9 +2,10 @@
|
||||
# Parses and calls commands
|
||||
|
||||
import argparse
|
||||
import ctf.utils as util
|
||||
from pathlib import Path
|
||||
from ctf.utils import *
|
||||
|
||||
def setArguments():
|
||||
def set_arguments():
|
||||
parser = argparse.ArgumentParser( #type:ignore
|
||||
prog="ctf",
|
||||
description="A collection of cli tools to improve your ctf workflow",
|
||||
@@ -15,9 +16,32 @@ def setArguments():
|
||||
args = parser.parse_args()
|
||||
return args
|
||||
|
||||
# Class for a competition, defining active catagories, challenges completed, etc
|
||||
# return a list of paths for each catagory in a competition
|
||||
def active_categories(p: Path) -> list:
|
||||
cats = []
|
||||
if not p.exists(): return []
|
||||
for cat in p.iterdir():
|
||||
cats.append(cat)
|
||||
return cats
|
||||
#return a dictionary of competitions in the base directory
|
||||
def active_competitions(dir: str) -> dict:
|
||||
comps = {}
|
||||
p = Path(dir)
|
||||
if not p.exists(): return {}
|
||||
for item in p.iterdir():
|
||||
if item.name == "tools": continue
|
||||
comps[item] = active_categories(item)
|
||||
print(item.name)
|
||||
print(comps[item.name])
|
||||
return comps
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
print(util.config["Competition"]["competition"])
|
||||
active_comps = active_competitions(enviroment["ctf_dir"])
|
||||
print(active_comps)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -21,4 +21,7 @@ def write_config(data: dict, config = f"{user_config_dir()}/ctf"):
|
||||
|
||||
|
||||
config = load_config("/home/venus/code/ctf/config.toml")
|
||||
competition = config["Competition"]
|
||||
enviroment = config["Enviroment"]
|
||||
# base_dir = config["ctf_dir"]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user