Krythz43 / SolveNext-Codeforces

CLI version of codeforces problemsets which not only brings you all the problems present in Codeforces to your terminal effortlessly, but also orders them in the best way you should SolveNext.
11 stars 4 forks source link

Make the app more user friendly #5

Open Krythz43 opened 5 years ago

Krythz43 commented 5 years ago

Currently, every edit needs to be made directly in the code for changing various parameters. This could be a hassle and it would be more better if it was a completely abstracted CLI with parameter changes in the terminal rather than the code.

ghost commented 4 years ago

Hi! I am Aritra Sen....I am interested in knowing which of the parameters you want to change from cli..And why not use a separate setter function for it?

Krythz43 commented 4 years ago

All of the parameters currently under the initialize() are the target here. The parameters once set, do not have to meddled with unless a need to change them again arises. And all of this has to be done without going into the source code. I guess setter function modifies the code a bit like the current one?

ghost commented 4 years ago

Can I refactor the code this way... import requests import csv from operator import itemgetter import urllib.request as url class Codeforce: def init(self,users=["nks43"],tags=["number theory"],round=500,number_of_problems=10,lower_bound = 1600,upper_bound=4000): self._users=users self._tags=tags self._ROUND=round self._number_of_problems=number_of_problems self._lower_bound=lower_bound self._upper_bound=upper_bound

@property
def users(self):
    return self._users
@property
def tags(self):
    return self._tags
@property
def ROUND(self):
    return self._ROUND
@property
def number_of_problems(self):
    return self._number_of_problems
@property
def lower_bound(self):
    return self._lower_bound
@property
def upper_bound(self):
    return self._upper_bound
ghost commented 4 years ago

If you like this type of refactoring I will continue with this style

ghost commented 4 years ago

My plan is to only set the values using the init() method...the name==main will be outside the class...And argparse.Argparser() would be used for command line arguments, which is to be passed to Codeforce class,the defaults being already set The System proxy would be used by urllib.request.getproxies() and proxy_bypass will be ignored...So that it can run on any proxy provided by system

ghost commented 4 years ago

Basically I am trying to give user access with some abstraction so they can't change the arguments once set to run

ghost commented 4 years ago

Guide me if I am wrong :)

Krythz43 commented 4 years ago

I guess you understood it a little different from what we are trying to achieve. All these parameters here are equally important and a user might change all of them at once. What am looking for here is a command-line option which if the arguments are not set, prompts the user for argument input and once set, the user can change the arguments using a CLI flag.

Say you are normally running it as python3 app.py The code checks if the arguments are set. If not, the user is prompted for an input.

The user can change the arguments by something like python3 app.py --change-param

It's just an attempt to make the app more user-friendly unlike the state it is right now. Do tell me what you feel.

ghost commented 4 years ago

Can you please explain me a bit more.... Then I will try to do the same using argparse... As written in one of my messages... So that I can integrate the same in the code...

On Sat, Dec 7, 2019, 5:37 PM N Krithick Santhosh notifications@github.com wrote:

I guess you understood it a little different from what we are trying to achieve. All these parameters here are equally important and a user might change all of them at once. What am looking for here is a command-line option which if the arguments are not set, prompts the user for argument input and once set, the user can change the arguments using a CLI flag.

Say you are normally running it as python3 app.py The code checks if the arguments are set. If not, the user is prompted for an input.

The user can change the arguments by something like python3 app.py --change-param

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/Krythz43/SolveNext-Codeforces/issues/5?email_source=notifications&email_token=ANZLGAQ72DETC7ACTHEULQDQXOGXDA5CNFSM4IEL5RO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGGFP6I#issuecomment-562845689, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZLGAVJSJLKRSMENCFN3UTQXOGXDANCNFSM4IEL5ROQ .

Krythz43 commented 4 years ago

Refactoring using classes is a total no for me. The simple reason being that the main aim is to covert this to a web app and the python code is just the logic implementation.

That being said, let's assume we have a simple text file that stores the required details of a user. While the python3 app.py command is run, we run the initialize() function, which checks the existence of this file. If the file is present, we go ahead with the initialization. Else we prompt the user for the required input.

If the user intends to change the parameters, he goes ahead with the change-params flag. What do you think?

ghost commented 4 years ago

if name==main: import argparse prsr=argparse.ArgumentParser(); prsr.add_argument("-p", "--change_params", help="User input",action="store_true") args=prsr.parse_args() if args.change_params:

Proceed with user input

else
    #Proceed with default
#Your Previous unaltered code,as it is.
ghost commented 4 years ago

Is it okay using argparse, getting change_params,if true then taking user input else the code remains as it was??

zenolus commented 4 years ago

We can use a .env file for doing this. I am currently adding it to the JS version ( PR #10 ). See if anyone can port the same.

Krythz43 commented 4 years ago

@aritrasen5500 Seems fine, send a PR?

ghost commented 4 years ago

Sorry, but I do not know the correct way to create pull requests, but I have changed the app.py code with some basic error handling, and the tags for changing to a json file... Please let me know if this works for you and also let me know the correct way to create pull requests...

Thanks in advance, Aritra Sen.

On Sun, Dec 8, 2019, 8:19 PM N Krithick Santhosh notifications@github.com wrote:

@aritrasen5500 https://github.com/aritrasen5500 Seems fine, send a PR?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Krythz43/SolveNext-Codeforces/issues/5?email_source=notifications&email_token=ANZLGARXTYGB464LI5GKSMLQXUCPDA5CNFSM4IEL5RO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEGHAORQ#issuecomment-562956102, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANZLGAWC6BZP6CIW7LVIVPTQXUCPDANCNFSM4IEL5ROQ .