Skip to content

Commit

Permalink
Merge pull request #12 from asprazz/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
ankush-0x90 authored Jan 2, 2022
2 parents 61f51c0 + e195a0a commit cc082cf
Show file tree
Hide file tree
Showing 19 changed files with 750 additions and 373 deletions.
15 changes: 10 additions & 5 deletions .env
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 =
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
- name: Analysing the code with pylint
run: |
export PYTHONAPP=startcp
pylint --exit-zero $(find . -name "*.py" | xargs)
pylint --errors-only $(find . -name "*.py" | xargs)
29 changes: 17 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@

## Upcomming Release

- version 1.0.2
- done
- use case screenshot added
- fixed #8
- codeforces support new feature for folder segregation
- fixed problem.html with pointer to the problem
Todos:
- [ ] competition scanner from CLI
- [ ] small judge on the cli
- [ ] scheduling tracking and notifying (email, sms, chrome notification using extension, etc)

- pending
- codechef regex fixes
- fix #6 linting issues
- UI fixes and new things on UI
- competition scanner from CLI
## Released

- version 1.0.3
- [x] codechef regex fixes
- [x] fix #6 linting issues
- [x] code duplicacy fixed
- [x] UI fixes and new things on UI like logo, loaders, etc
- [x] logging of every file transaction to ensure trust and reliablity
- [x] customisation in generation of configuration file with more options

## Released
- version 1.0.2
- [x] use case screenshot added
- [x] fixed #8
- [x] codeforces support new feature for folder segregation
- [x] fixed problem.html with pointer to the problem

- version 1.0.1
- features:
Expand Down
108 changes: 51 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
>
> Don't Forget To Update StartCp-Cli Frequently, Thank You For Using
> Don't Forget To Update StartCp-Cli Frequently, Thank You For Using
> Use `pip install -U startcp-cli` or `pip install startcp-cli==x.y.z` x.y.z is the latest version
>
> Use `pip install -U startcp-cli` or `pip install startcp-cli==x.y.z` x.y.z is the latest version
---

<p align="center">
<img width="600" src="https://github.com/asprazz/startcp-cli/blob/master/screenshots/logos/start_cp_2x.png">
<p align="center" style="margin-top: 50px; margin-bottom: 50px">
<img width="100%" src="https://github.com/asprazz/startcp-cli/blob/develop/screenshots/logos/logo.png">
</p>

---

<P>
<P align="justify">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;A CLI application for generating battlespace in seconds for online coding competitions with features like custom template configuration, backup language support, auto input output files generation, etc. But, currently available for Codechef and Codeforces (version 1.0.2).
</p>

Expand All @@ -24,84 +18,84 @@

</p>

#### Usage

- `startcp-cli` is a command line application.
- `pip install startcp-cli` or `pip install startcp-cli==x.y.z` to install the package.
- After installing use `startcp` command to start on the terminal.
![Use Case](https://github.com/asprazz/startcp-cli/blob/develop/screenshots/1.png "Use Case")
- First step is to generate a configuration file by simply entering `g` or `generate` inside the sub startcp terminal. Follow the instructions to generate the config file.
- After configuring the config file, you can use `cp <competition_url>` to generate the battlespace for the competition.
- You can use `h` or `help` on the sub startcp termininal to print the help message whenever needed.

#### Dependencies

- `startcp-cli` runs on Python3.x
- [`pip3`](https://pip.pypa.io/en/stable/installing/)
- [`requests`](https://requests.readthedocs.io/en/master/user/install/)
- [`argparse`](https://pypi.org/project/argparse/)
and our beloved
and our beloved
- [`colorama`](https://pypi.org/project/colorama/)
- Thanks to all :pray:
- [`bs4`](https://pypi.org/project/beautifulsoup4/)
- [`halo`](https://pypi.org/project/halo/)

- Thanks to all :pray:

#### Installation (Not for development)
- <strong>Note: Please update globally installed package frequently. :innocent: </strong>

- <strong>Note: Please update globally installed package frequently. :innocent: </strong>
- Installing from `pypi`
- `pip install startcp-cli` (use pip for Python3)
- Already installed ?
- Update using `pip install -U startcp-cli`
- see [How To Update Pip Package](https://stackoverflow.com/questions/4536103/how-can-i-upgrade-specific-packages-using-pip-and-a-requirements-file)
- `pip install startcp-cli` (use pip for Python3)
- Already installed ?
- Update using `pip install -U startcp-cli`
- see [How To Update Pip Package](https://stackoverflow.com/questions/4536103/how-can-i-upgrade-specific-packages-using-pip-and-a-requirements-file)
- Installing Manually :
- `git clone https://github.com/asprazz/startcp-cli.git`
- `cd startcp-cli`
- Option 1:
- (if windows) `pip install .`
- (if linux/mac) `sudo pip install . -H`
- Option 2:
- (optional for linux users) if requires `chmod +x install.sh`
- then run `scripts/./install.sh`


#### Usage
![Use Case](https://github.com/asprazz/startcp-cli/blob/develop/screenshots/1.png "Use Case")
- After installing using pip or building from source, by using `startcp` on terminal you can trigger the execution for startcp-cli from anywhere.
- Please enter URL of the competition to parse and generate the battlespace.
- Battle space will auto generated in ${USER_HOME}/startcp/ (default path which is configurable see Configuration)
- Battlespace incldes,
- a problem.html file with problem direct link
- in.txt containing all input cases
- sol.py | sol.cpp either blank coding file or prepared from custom template

- `git clone https://github.com/asprazz/startcp-cli.git`
- `cd startcp-cli`
- Option 1:
- (if windows) `pip install .`
- (if linux/mac) `sudo pip install . -H`
- Option 2:
- (optional for linux users) if requires `chmod +x install.sh`
- then run `scripts/./install.sh`

#### Configuration

- `startcp -g` or `startcp --generate` will generate configuration file in ${USER_HOME}/startcp/
- By setting, `IS_SETUP_DONE = 1` in configuration file custom configuration can be used over default ones



#### Contributing Guidelines

- Thank you for Showing interest in contributing to this project
- Please see https://github.com/asprazz/startcp-cli/blob/master/CONTRIBUTORS.md

##### Development

- Please, follow the contributing guidelines
- Fork the repository and clone it to your local environment
- Activate environment if any (
[`venv`](https://docs.python.org/3/library/venv.html)
or [`conda`](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)
for more details
[`venv`](https://docs.python.org/3/library/venv.html)
or [`conda`](https://docs.conda.io/projects/conda/en/latest/user-guide/install/index.html)
for more details
)
- Running `startcp`
- Running locally
- `cd startcp-cli`
- `python startcp/__main__.py`
- `cd startcp-cli`
- `python startcp/__main__.py`
- Installing globally from your local repository
- `cd startcp-cli`
- Option 1:
- (if windows) `pip install .`
- (if linux/mac) `sudo pip install . -H`
- Option 2:
- (optional for linux users) if requires `chmod +x install.sh`
- then run `scripts/./install.sh`
- option 3:
- `python setup.py install`
- `cd startcp-cli`
- Option 1:
- (if windows) `pip install .`
- (if linux/mac) `sudo pip install . -H`
- Option 2:
- (optional for linux users) if requires `chmod +x install.sh`
- then run `scripts/./install.sh`
- option 3:
- `python setup.py install`
- Fix :wrench: something broken or Build :hammer: something interesting
- Don't forget to create child branch from `develop` and that branch only



#### Error reports

- First of all thank you.
- https://github.com/asprazz/startcp-cli/issues

1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1.0.2-9-g3da2beb
Binary file modified screenshots/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/logos/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
assert os.path.isfile("startcp/version.py")
with open("startcp/VERSION", "w", encoding="utf-8") as fh:
fh.write(f"{startcp_version}\n")
with open("VERSION", "w", encoding="utf-8") as fh:
fh.write(f"{startcp_version}\n")

with open("README.md", "r", encoding="utf-8") as fh:
long_description = fh.read()
Expand Down Expand Up @@ -42,6 +44,7 @@
'colorama',
'python-dotenv',
'Rangebi',
'beautifulsoup4==4.10.0'
'beautifulsoup4==4.10.0',
'halo==0.0.31'
],
)
11 changes: 8 additions & 3 deletions startcp/.env
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 =
5 changes: 3 additions & 2 deletions startcp/__main__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#! /usr/bin/env python3

import argparse

try:
import functions, printer
import functions
import printer
except Exception:
from startcp import functions, printer



def main():

parser = argparse.ArgumentParser(
Expand Down
116 changes: 116 additions & 0 deletions startcp/builder.py
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
Loading

0 comments on commit cc082cf

Please sign in to comment.