-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
kattis config
to initialize and update.
Pass nothing and it will make sure that .kattisrc has all available settings. Pass a section, an option and a value to mutate. If section is for file associations and commands, they are added even when option is not present.
- Loading branch information
Showing
6 changed files
with
126 additions
and
55 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"python.pythonPath": "C:\\Users\\simon\\AppData\\Local\\Programs\\Python\\Python38-32\\python.exe" | ||
} |
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,36 @@ | ||
from helpers.config import getConfig, commandConvert | ||
|
||
def configCommand(args, options): | ||
if len(args) == 0: | ||
print("Adding/updating configuration to your .kattisrc...") | ||
if getConfig() == -1: | ||
print("""\ | ||
Something went wrong in locating the configuration file | ||
for kattis. Have you fetched the .kattisrc? Consult the | ||
README.md for more details.""") | ||
else: | ||
print("Successfully added default configuration to your .kattisrc!") | ||
|
||
elif len(args) == 3: | ||
cfg, location = getConfig(shouldReturnLocation=True) | ||
if type(cfg) is int: | ||
print("""\ | ||
Something went wrong in locating the configuration file | ||
for kattis. Have you fetched the .kattisrc? Consult the | ||
README.md for more details.""") | ||
elif cfg.has_section(args[0]): | ||
if not cfg.has_option(args[0], args[1]) and args[0].lower() in ["kat", "kattis", "user"]: | ||
print("Setting", args[1], "was not recognized for section [" + args[0] + "]") | ||
else: | ||
cfg.set(args[0], args[1], args[2]) | ||
with open(location, "w") as configFile: | ||
cfg.write(configFile) | ||
print("The setting", args[1], "from section [" + args[0] + "]", "was set to", args[2]) | ||
else: | ||
print("Section [" + args[0] + "]", "was not found.") | ||
|
||
else: | ||
print("""\ | ||
Invalid number of arguments, expected | ||
'config <section> <option> <value>'. | ||
Remember to put arguments with spaces in quotes.""") |
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