You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Dear @DanCRichards,
Having recently found your program about ascii generation, I found that it was a great Idea.
I thus took a look into you code (to try and understand how it worked) and was surprised about it's build quality.
I thus re-wrote the code and it supports local and remote image fetching, the next three bullets describes the reaction of to code depending on it's situation:
If the computer has an active internet connection the file will be retrieved from your repository
If the computer does not have an active internet connection, the file will be retrieved from a defined folder
If the two options above fail, an error message will be displayed (Sorry no images today)
In order to run the file, it requires execution rigths and/or python3
I hope you like this new version of the script.
Yours sincerely
Henry Letellier
#!/bin/env python3importrandomimportosimportrequestsdefault_art=""" #!/bin/env python3#### EPITECH PROJECT, 2022## ASCII-Art-Splash-Screen## File description:## ascii_revisited.py### Code written by (c) Henry Letellier (please leave this in the file)import randomimport osimport requestsdefault_art = """_________/_____/_____________________.__.
\\_____ \\ /_ \\_ __ \\_ __<||/ ( <_> ) | \\/|| \\/\\___|/_______/\\____/|__||__|/____|
\\/ \\/_______
\\ \\ ____/| \\ / _ \\/| ( <_> )
\\____|__/\\____/
\\/
.__|__|________________________||/ \\\\__ \\ /___\\_/__ \\ /___/||YY \\/__ \\_//_/>___/ \\___ \\
|__|__|_| (____/\\___/ \\___>____>
\\/ \\//_____/ \\/ \\/__ .____/|_______|_/_______.__.
\\ __\\/_ \\ /__|\\__ \\<|||| ( <_> ) /_/|/__ \\\\___||__| \\____/\\____|(____/____|
\\/ \\/\\/
"""
def get_file_content(filename:str, location:str) -> str:
f = open(f"{location}/{filename}", "r", encoding="utf-8")
content = f.read()
f.close()
return content
def display(the_file_content:str) -> None:
print(the_file_content)
def get_file_online(url_start:str, url_end:str, int_max:int) -> str:
content = requests.get(f"{url_start}{str(random.randint(1,int_max))}{url_end}")
if content.status_code == 200:
raw_file_content = content.content
decoded_content = raw_file_content.decode()
if "</html>" not in decoded_content:
return decoded_content
else:
return ""
else:
return ""
usr_location = os.getcwd()
file_url_start = 'https://raw.githubusercontent.com/DanCRichards/ASCII-Art-Splash-Screen/master/art/'
file_url_end = ".txt"
max_nb_files = 9
file_content = get_file_online(file_url_start, file_url_end, max_nb_files)
if file_content == "":
try:
program_location = f"{os.environ['HOME']}/manually_installed_software/ascii_in_terminal/ASCII-Art-Splash-Screen/"
# Change the path of program_location in order to set tge repository containing the folder with the ascii art folder
art_location = "art"
# Change the content of the variable art_location in order to change the name of the folder containing the art filesos.chdir(program_location)
art_files=os.listdir(art_location)
art_file=random.randint(1, len(art_files)-1)
file_name=art_files[art_file]
file_content=get_file_content(file_name, art_location)
os.chdir(usr_location)
except:
file_content=default_artdisplay(file_content)
PS: I would appreciate it if you leave my credit in the source code
PPS: why not add a file containing the number of available ascii images (avoid's having to hard code it in case you decide to add more images one day, you just have to change the number in the file, no need to roll out a new code for everyone)
The text was updated successfully, but these errors were encountered:
Dear @DanCRichards,
Having recently found your program about ascii generation, I found that it was a great Idea.
I thus took a look into you code (to try and understand how it worked) and was surprised about it's build quality.
I thus re-wrote the code and it supports local and remote image fetching, the next three bullets describes the reaction of to code depending on it's situation:
Sorry no images today
)In order to run the file, it requires execution rigths and/or python3
I hope you like this new version of the script.
Yours sincerely
Henry Letellier
PS: I would appreciate it if you leave my credit in the source code
PPS: why not add a file containing the number of available ascii images (avoid's having to hard code it in case you decide to add more images one day, you just have to change the number in the file, no need to roll out a new code for everyone)
The text was updated successfully, but these errors were encountered: