Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[TIP] print a colori in python
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools)
View previous topic :: View next topic  
Author Message
ultimodruido
Apprentice
Apprentice


Joined: 11 Dec 2003
Posts: 253
Location: Muenchen

PostPosted: Sat Aug 21, 2004 3:21 pm    Post subject: [TIP] print a colori in python Reply with quote

Ciao a tutti! Premetto che questo tip non serve a niente e non risolverà nessun problema.
Tempo fa avevo dato un'occhiata al codice di emerge per vedere come riuscivano gli sviluppatori di gentoo a scrivere testo colorato... (io non ho mai imparato i codici... :oops: ) ho scoperto che nel modulo portage ci sono delle belle funzioni tipo blue("stringa") che fanno tutto da sole!!!
Solo che un utente che non fa parte del gruppo portage non può caricare correttamente il modulo, allora le ho cercate (spero di averle individuate tutte) e le ho riscritte in un nuovo file cosi da poterle usare con tutti gli utenti... nel caso interessasse a qualcuno posto qui il codice:
Code:
def blue(string):
   return "\x1b[34;01m"+string+"\x1b[0m"

def bold(string):
   return "\x1b[01m"+string+"\x1b[0m"

def brown(string):
   return "\x1b[33;06m"+string+"\x1b[0m"

def darkblue(string):
   return "\x1b[34;06m"+string+"\x1b[0m"

def darkgreen(string):
   return "\x1b[32;06m"+string+"\x1b[0m"

def darkred(string):
   return "\x1b[31;06m"+string+"\x1b[0m"

def darkteal(string):
   return "\x1b[36;01m"+string+"\x1b[0m"

def darkyellow(string):
   return "\x1b[33;06m"+string+"\x1b[0m"

def fucsia(string):
   return "\x1b[35;01m"+string+"\x1b[0m"

def green(string):
   return "\x1b[32;01m"+string+"\x1b[0m"

def purple(string):
   return "\x1b[35;06m"+string+"\x1b[0m"

def red(string):
   return "\x1b[31;01m"+string+"\x1b[0m"

def teal(string):
   return "\x1b[36;06m"+string+"\x1b[0m"

def turquoise(string):
   return "\x1b[36;01m"+string+"\x1b[0m"

def white(string):
   return "\x1b[01m"+string+"\x1b[0m"

def yellow(string):
   return "\x1b[33;01m"+string+"\x1b[0m"

Io ho salvato il file in /usr/lib/python2.3/colors.py
In realtà turquoise e darkteal sono uguali, ma lo sono anche in portage... e poi ho rinominato il fucsia per in portage è salvato come fuscia...
ciao a tutti nic
_________________
Account Jabber: ultimodruido@jabber.linux.it
Back to top
View user's profile Send private message
n3m0
l33t
l33t


Joined: 08 Feb 2004
Posts: 798
Location: Richville, Naples, Italy, Europe

PostPosted: Sat Aug 21, 2004 7:21 pm    Post subject: Reply with quote

Ma queste funzioni non sono contenute anche nel modulo output?
_________________
L’energia è la civiltà. Lasciarla in mano ai piromani/petrolieri è criminale. Perché aspettare che finisca il petrolio?
L’età della pietra non è mica finita per mancanza di pietre. - B.G.


Site/Blog: http://www.neminis.org
Back to top
View user's profile Send private message
ultimodruido
Apprentice
Apprentice


Joined: 11 Dec 2003
Posts: 253
Location: Muenchen

PostPosted: Sun Aug 22, 2004 10:19 am    Post subject: Reply with quote

Ma sai che hai proprio ragione? Io li avevo cercati un po', pero non avevo trovato nulla e mi sono arrangiato da solo! Che umiliazione! Vi prego moderatori cancellatemi, mi vergogno troppo!
_________________
Account Jabber: ultimodruido@jabber.linux.it
Back to top
View user's profile Send private message
fedeliallalinea
Administrator
Administrator


Joined: 08 Mar 2003
Posts: 30835
Location: here

PostPosted: Sun Aug 22, 2004 10:21 am    Post subject: Reply with quote

ultimodruido wrote:
Vi prego moderatori cancellatemi, mi vergogno troppo!

Per cosi' poco....
_________________
Questions are guaranteed in life; Answers aren't.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum