def mark_completed(df: 'dataframe', index: int, name: str) -> None: """Marks challenge index as completed in dataframe. Args: df (dataframe): df index (int): challenge index name (str): challenge name """ msg_completed = f"Logging index {name} as completed" logging.info(msg_completed) df.at[index, CHALLENGE_INFO_CSV_HEADERS[-2]] = 1 return
def mark_not_todo(df: 'datamframe', index: int, name: str) -> None: """marks challenge as not todo in dataframe. Args: df (datamframe): df index (int): challenge index name (str): challenge name """ msg_not_todo = f"Marking NOT todo for: {name}" logging.info(msg_not_todo) print(msg_not_todo) df.at[index, CHALLENGE_INFO_CSV_HEADERS[-1]] = 0 return
def change_dir(domain_dir: str): """Changes the current working directory. Creates directory if it doesn't exist. Also creates a pre-READMEME.md file. Args: domain_dir: directory to change to. """ if not os.path.exists(domain_dir): logging.info(f"DIR - creating {domain_dir}") os.mkdir(domain_dir) logging.info(f"DIR - changing to {domain_dir}") os.chdir(domain_dir) return
def solve_challenge(df: 'dataframe', index: int) -> bool: """Opens challenge url & file for user to complete. Args: df (dataframe): dataframe containing information index (int): Row to read Returns: bool: if challenge was solved. """ logging.info(f"Chall info for: {index}") chall_info = df.iloc[index] logging.info(f"INFO: {chall_info}") ## Open url url = chall_info.loc[CHALLENGE_INFO_CSV_HEADERS[-4]] + FULLSCREEN_URL logging.debug(f"url: {url}") print(f"Webpage: {url}") WebPageInfo(url, scrape= False) ## Solution file solution_url = url = chall_info[CHALLENGE_INFO_CSV_HEADERS[-3]] sol_filename = solution_url[ solution_url.rfind('/') + 1:] logging.info(f"sol filename {sol_filename}") print(f"File: {sol_filename}") os.system(sol_filename) return
def locate_challenge(df: 'dataframe', last_chall_index: int, flag_review: bool) -> Tuple[bool, int]: """Returns boolean indicating if challenge located & index of challenge information Args: df (dataframe): dataframe of challenge inforamtion Returns: Tuple[bool, int]: Challenge located, index of challenge information """ if flag_review: df = df.sample(frac=1).reset_index(drop=True) for index, row in df.iterrows(): logging.debug(f"CHECK - Index {index}") if ( row[CHALLENGE_INFO_CSV_HEADERS[-1]] and ## TODO row[CHALLENGE_INFO_CSV_HEADERS[-2]] == flag_review and ## Completed = flag_review index != last_chall_index ): logging.info(f"FOUND - challenge at {index}") return_index = row[CHALLENGE_INFO_CSV_HEADERS[0]] if flag_review else index return (True, return_index) return (False, None)