Skip to content
This repository has been archived by the owner on Nov 13, 2017. It is now read-only.

Commit

Permalink
Edit program grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
Kumamon Srisuntiroj authored and Kumamon Srisuntiroj committed Jul 31, 2017
1 parent 965e018 commit 9219da8
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 38 deletions.
2 changes: 1 addition & 1 deletion configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
debug_mode_basic = False

# Set up the cache file name to be [Default = "cache"]
cache_file_name = "cache"
cache_file_name = "cache" # and will use .txt as a file surname

# Allow program to create cache file [Default = True]
cache_create = True
Expand Down
41 changes: 23 additions & 18 deletions core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,18 @@
# Importing dependencies libraries
import os # Allows OS system call power
import os.path # Allows OS system call power
from time import sleep

# Import dependencies files
import systems # Import systems.py
import configurations # Imports configurations.py
import configurations as settings # Imports configurations.py


# Served as function caller and receptions
def main():
print("Robco Industries (TM) Termlink Protocol")
print("Welcome to Fallout 4 Hacking Solver")
sleep(2)
count, results, text = 1, [], ""
error_code = 0

Expand All @@ -32,10 +34,10 @@ def main():
elif error_code == 1:
print("Please type something to start a program.")
elif error_code == 2:
print("'%s' is not a valid text length. (expecting: %d) Please try again..." % (
text, len(results[0])))
print("'%s' is not a valid text length. (getting: %-2d| expecting: %-2d)" % (
text, len(text), len(results[0])))
elif error_code == 3:
print("'%s' is already exists in the vocabulary list."%text)
print("'%s' is already exists in the vocabulary list." % text)
else:
print("We are encontering the unexpectancies. Please restart the program...")

Expand Down Expand Up @@ -70,13 +72,14 @@ def main():

while 1:
if len(results) <= 0:
print("We have a problem with something... Recovering data from cache..." if configurations.cache_create else "You have disabled our cache system. We are unable to retrieve this...")
print("We have a problem with something... Recovering data from cache..." if settings.cache_create else "You have disabled our cache system. We are unable to retrieve this...")
break
# and actually pull data from the cache created.

if count > 4:
print("We have failed you. Our algorithms failed you.")
print("You may continue, restart or make new issues in repository.")
print("We have failed you. We use too much attempt.")
print(
"You may continue, restart or make new issues in our repository for further investigation.")

if len(results) == 1:
print("You have solved the riddle!")
Expand All @@ -93,15 +96,17 @@ def main():
if text.startswith("/"):
results = systems.command_center(results, text)

if text == "": # When input is not fine
if text == "": # When input is not fine
print("Are you sure that you have solved it? \nPress ENTER again to confirm.")
if input() == "": break
else: continue
if input() == "":
break
else:
continue

count += 1 # When the input is still in tact
count += 1 # When the input is still in tact

if text not in results:
print("Word '%s' does not exists in your vocabulary list"%text)
print("Word '%s' does not exists in your vocabulary list" % text)
continue

correctness = int(input("and they are what likeness? : "))
Expand All @@ -116,7 +121,7 @@ def main():
def password_filter(results, word, number):
possible_answer = []

if configurations.debug_mode:
if settings.debug_mode:
print("[Debug] ----- Word -----|-- Similarity --") # FOR DEBUG

for check_answer in results:
Expand All @@ -126,12 +131,12 @@ def password_filter(results, word, number):
if check_answer[i] == v:
n += 1

if configurations.debug_mode:
if settings.debug_mode:
print("[Debug] " + check_answer, n) # FOR DEBUG
if n == number:
possible_answer.append(check_answer)

if configurations.debug_mode:
if settings.debug_mode:
print("[Debug] " + possible_answer) # FOR DEBUG

return possible_answer
Expand All @@ -157,11 +162,11 @@ def recommends(results):


# Automatic update
if configurations.auto_update:
if configurations.debug_mode:
if settings.auto_update:
if settings.debug_mode:
print("[Debug] Updating the repository to the newest version...")
os.system("git pull")
if configurations.debug_mode:
if settings.debug_mode:
print("[Debug] Your repository is updated!")


Expand Down
42 changes: 23 additions & 19 deletions systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,19 @@
import os.path # Allows OS system call power

# Import dependencies files
import configurations # Imports configurations.py
import configurations as settings # Imports configurations.py

def result_printer(results, wording): # Designing the way that the possible answer will be print out

# Designing the way that the possible answer will be print out
def result_printer(results, wording):
if not len(results) == 0: # Will print if the program does not recieve a blank print
print(wording + " (%d)"%len(results) )
print(wording + " (%d)" % len(results))
print("-" * len(wording))
for i in results:
print(i, end="\t")
print("\n")


def command_center(results, actions): # Redirect additional features using commands
actions = input("""Welcome to command center. Here's what we can do...
1. /edit\t2. /quit
Expand All @@ -34,6 +37,7 @@ def command_center(results, actions): # Redirect additional features using comm

return results


def list_editor(results, actions): # Make the item in the list editable using this function

one_time = False
Expand Down Expand Up @@ -82,17 +86,17 @@ def screen_clear(): # Cleaning screen for the program. Does not work more than


def file_save(results): # Creating the cache file and save it in the same directory
if configurations.cache_create:
if os.path.exists(configurations.cache_file_name):
if settings.cache_create:
if os.path.exists(settings.cache_file_name):
# Try to create the file
if configurations.debug_mode_basic or configurations.debug_mode:
if settings.debug_mode_basic or settings.debug_mode:
print("[Debug] File %s does exists. Deleting it now..." %
configurations.cache_file_name) # FOR DEBUG
if configurations.cache_delete:
os.remove(configurations.cache_file_name)
settings.cache_file_name) # FOR DEBUG
if settings.cache_delete:
os.remove(settings.cache_file_name)
# Start writing in that file with the data in results

file = open(configurations.cache_file_name, "w")
file = open(settings.cache_file_name, "w")

# Creating file headers
import datetime # Getting user's time for cache timestamps
Expand All @@ -101,23 +105,23 @@ def file_save(results): # Creating the cache file and save it in the same direc
file.write(text)

for i in results:
if (configurations.debug_mode_basic or configurations.debug_mode):
if (settings.debug_mode_basic or settings.debug_mode):
print("[Debug] Writing %s to %s" %
(i, configurations.cache_file_name)) # FOR DEBUG
(i, settings.cache_file_name)) # FOR DEBUG
text = i + "\n"
file.write(text)
file.close()


def exit_and_save(): # Deleting the cache and quitting the program safely
if configurations.cache_delete:
if os.path.exists(configurations.cache_file_name):
def exit_and_save(): # Deleting the cache and quitting the program safely
if settings.cache_delete:
if os.path.exists(settings.cache_file_name):
# Try to delete the file, because it is still exists.
if configurations.debug_mode_basic or configurations.debug_mode:
if settings.debug_mode_basic or settings.debug_mode:
print("[Debug] File %s does exists. Deleting it now..." %
configurations.cache_file_name) # FOR DEBUG
os.remove(configurations.cache_file_name)
settings.cache_file_name) # FOR DEBUG
os.remove(settings.cache_file_name)

if configurations.debug_mode:
if settings.debug_mode:
print("[Debug] Shutting the program down now. Thank you!") # FOR DEBUG
exit()

0 comments on commit 9219da8

Please sign in to comment.