-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from asprazz/develop
Develop
- Loading branch information
Showing
19 changed files
with
750 additions
and
373 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
IS_SETUP_DONE = 0 | ||
PROJECT_PATH = /home/user_name | ||
USE_TEMPLATE = 0 | ||
MAIN_LANG_TEMPLATE_PATH = /home/user_name | ||
BACKUP_LANG_TEMPLATE_PATH = /home/user_name | ||
IS_SETUP_DONE = 1 | ||
PROJECT_PATH = /home/anksh/ankushPatil/developerZone/personalZone/competitive/programmingProblems/problems/competitions | ||
USE_TEMPLATE = 1 | ||
MAIN_LANG_TEMPLATE_PATH = /home/anksh/ankushPatil/developerZone/personalZone/competitive/programmingProblems/problems/competitions/sol.py | ||
BACKUP_LANG_TEMPLATE_PATH = /home/anksh/ankushPatil/developerZone/personalZone/competitive/programmingProblems/problems/competitions/sol.cpp | ||
SEPERATE_FOLDER_STRUCTURE_FOR_DIFFERENT_SITES = 1 | ||
CODECHEF_FOLDER_NAME = Codechef | ||
CODEFORCES_FOLDER_NAME = Codeforces | ||
PRACTICE_FOLDER_NAME = Practice | ||
AFTER_GENERATION_COMMAND = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.2-9-g3da2beb |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
IS_SETUP_DONE = 0 | ||
PROJECT_PATH = /home/user_name | ||
PROJECT_PATH = /home/ | ||
USE_TEMPLATE = 0 | ||
MAIN_LANG_TEMPLATE_PATH = /home/user_name | ||
BACKUP_LANG_TEMPLATE_PATH = /home/user_name | ||
MAIN_LANG_TEMPLATE_PATH = /home/ | ||
BACKUP_LANG_TEMPLATE_PATH = /home/ | ||
SEPERATE_FOLDER_STRUCTURE_FOR_DIFFERENT_SITES = 1 | ||
CODECHEF_FOLDER_NAME = Codechef | ||
CODEFORCES_FOLDER_NAME = Codeforces | ||
PRACTICE_FOLDER_NAME = Practice | ||
AFTER_GENERATION_COMMAND = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
import re | ||
import os | ||
|
||
try: | ||
import printer | ||
import constants | ||
import codechef | ||
import codeforces | ||
import logger | ||
|
||
except Exception: | ||
from startcp import printer, constants, codechef, codeforces, logger | ||
|
||
|
||
|
||
rangebi = printer.Rangebi() | ||
logger = logger.Logger() | ||
|
||
platform_id = None | ||
|
||
|
||
def perform_build(comp_url): | ||
if not validate_url(comp_url): | ||
print( | ||
rangebi.get_in_danger( | ||
"Error orccured while validating url. Please try again!" | ||
) | ||
) | ||
printer.new_lines() | ||
logger.info("Error occured while validating url. Please try again! URL: " + comp_url) | ||
return False | ||
else: | ||
rangebi.set_spinner() | ||
rangebi.start_spinner() | ||
status = perform_operations_on_url(comp_url) | ||
rangebi.stop_spinner() | ||
rangebi.clear_spinner() | ||
return status | ||
|
||
|
||
def validate_url(comp_url): | ||
global platform_id | ||
|
||
# regex matching for codechef url | ||
regex_validator = re.compile(constants.codechef_regex) | ||
if re.match(regex_validator, comp_url): | ||
platform_id = constants.codechef | ||
return True | ||
|
||
# regex matching for codeforces url | ||
regex_validator = re.compile(constants.codeforces_regex) | ||
if re.match(regex_validator, comp_url): | ||
platform_id = constants.codeforces | ||
return True | ||
|
||
return False | ||
|
||
|
||
def perform_operations_on_url(comp_url): | ||
params = parse_url(comp_url) | ||
|
||
if len(params) < 1: | ||
printer.new_lines() | ||
print( | ||
rangebi.get_in_danger( | ||
"Error parsing the URL!" | ||
) | ||
) | ||
return False | ||
else: | ||
return prepare_battlezone(params, comp_url) | ||
|
||
|
||
def parse_url(comp_url): | ||
problem_urls = [] | ||
|
||
if platform_id == constants.codechef: | ||
problem_urls = codechef.get_codechef_problem_urls(comp_url) | ||
elif platform_id == constants.codeforces: | ||
problem_urls = codeforces.get_codeforces_problem_urls(comp_url) | ||
|
||
return problem_urls | ||
|
||
|
||
def prepare_battlezone(problem_urls, comp_url): | ||
if not move_pointer(): | ||
return False | ||
|
||
result = False | ||
|
||
if platform_id == constants.codechef: | ||
result = codechef.prepare_for_codechef_battle(problem_urls, comp_url) | ||
elif platform_id == constants.codeforces: | ||
result = codeforces.prepare_for_codeforces_battle(problem_urls, comp_url) | ||
|
||
return result | ||
|
||
|
||
def move_pointer(): | ||
try: | ||
if (not (os.getenv(constants.is_setup_done) is None)) and (int(os.getenv(constants.is_setup_done)) == 1): | ||
if not (os.getenv(constants.project_path) is None): | ||
os.chdir(os.getenv(constants.project_path)) | ||
logger.info("Changing directory to: " + os.getenv(constants.project_path)) | ||
else: | ||
os.makedirs(constants.startcp_default_folder, exist_ok=True) | ||
os.chdir(constants.startcp_default_folder) | ||
logger.info("Making if not exists and changing directory to: " + constants.startcp_default_folder) | ||
else: | ||
# lets go home by default | ||
os.makedirs(constants.startcp_default_folder, exist_ok=True) | ||
os.chdir(constants.startcp_default_folder) | ||
logger.info("Making if not exists and changing directory to: " + constants.startcp_default_folder) | ||
return True | ||
except Exception: | ||
return False |
Oops, something went wrong.