Giter VIP home page Giter VIP logo

ascii-art-splash-screen's People

Contributors

dancrichards avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ascii-art-splash-screen's Issues

Ascii art code correction suggestion

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 python3
import random
import os
import requests

default_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 random
import os
import requests

default_art = """
  _________
 /   _____/ __________________ ___.__.
 \\_____  \\ /  _ \\_  __ \\_  __ <   |  |
 /        (  <_> )  | \\/|  | \\/\\___  |
/_______  /\\____/|__|   |__|   / ____|
        \\/                     \\/
            _______
            \\      \\   ____
            /   |   \\ /  _ \\
           /    |    (  <_> )
           \\____|__  /\\____/
                   \\/
                       .__
                       |__| _____ _____     ____   ____   ______
                       |  |/     \\\\__  \\   / ___\\_/ __ \\ /  ___/
                       |  |  Y Y  \\/ __ \\_/ /_/  >  ___/ \\___ \\ 
                       |__|__|_|  (____  /\\___  / \\___  >____  >
                                \\/     \\//_____/      \\/     \\/ 
                             __             .___
                           _/  |_  ____   __| _/____  ___.__.   
                           \\   __\\/  _ \\ / __ |\\__  \\<   |  |
                            |  | (  <_> ) /_/ | / __ \\\\___  |   
                            |__|  \\____/\\____ |(____  / ____|   
                                             \\/     \\/\\/
"""

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 files
        os.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_art

display(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)

Enhancement List

  • Add Random messages which can change for the different ascii art
  • Add more ascii art
  • Add ability to customise art that is presented (Not sure how, but I haven't really sat down and thought about it)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.