def test_dynamic_attr_access(reps): print("Test Dynamic Attribute Access: ", end="") start = timer() for i in range(reps): f = fg("blue") + "" + rs("fg") b = bg("green") + "" + rs("bg") e = ef("underl") + "" + rs("underl") end = timer() print(end - start)
qui = fg(255, 10, 10) + 'This is red text using 24bit colors.' + fg.rs # Add custom colors: from sty import Style, RgbFg fg.orange = Style(RgbFg(255, 150, 50)) buf = fg.orange + 'Yay, Im orange.' + fg.rs print(foo, bar, baz, qux, qui, buf, sep='\n') # ===== End ===== # ===== Start ===== Example("gettings started: select dynamically") a = ef('italic') + 'Italic text.' + rs.italic b = fg('blue') + 'Blue text.' + rs.fg c = bg(randint(0, 254)) + 'Random colored bg' + rs.bg print(a, b, c, sep='\n') # ===== End ===== # ===== Start ===== Example("gettings started: select 8bit and 24bit directly") # select an 8bit color directly. a = fg(196) + 'This is red text' + rs.fg # select a 24bit rgb color directly. b = bg(50, 255, 50) + 'Text with green bg' + rs.bg print(a, b, sep='\n')
def display_updates(newly_added_tasks): index = 0 formatted_list = [] for task in newly_added_tasks: index += 1 if "@" in task: # if @contextual_tag signifies priority a-la @important, @flagged, etc if "@importan" in task: #catched "important" ans well as "importance" effectValue = 'blink' foregroundColor = 'black' backgroundColor = 'magenta' #24-bit code for orange is 255,150,50 but it's throwing up errors so ¯\_(ツ)_/¯ elif "@cancel" in task: #catches "@cancel" in the present tense, as well as prior tasks that were "@cancelled" effectValue = 'dim' foregroundColor = 'black' backgroundColor = 'white' elif "@drop" in task: # if user chooses to "@drop" the item now, or reflects on something that was "@dropped" in the past effectValue = 'hidden' foregroundColor = 'white' backgroundColor = 'black' elif "@done" in task: # even if it was completed at the time of input, "done" tasks are inherently past-tense i.e. over with and archived effectValue = 'strike' foregroundColor = 'green' backgroundColor = 'black' #if context is a temporal-tag like @due or @defer to signify an ideal start-date or an urgent deadline # if "@due" in task: # deltaValue = calcUrgency(task) # NOTA BENE: Running out of time :( # ...And the irony isn't lost on me that I can't format @due dates properly because this project is due soon >_< # But I'm calling an audible and killing any further development of display_updates() because it's becoming a time-sink # FYI, here is the PSUEDOCODE I wrote for this part prior to coding... # if line contains temporal_tags #(regex?:date/format OR list_of_days OR time:format) # if before currentTime # bg.red + ef.bold # "overdue" styling # elif due_soon = true # due within 24 hrs # fg.yellow + ef.underl # else # i.e. if start OR defer OR due tag value exceeds due_soon conditional check # ef.italic # Needless to say, "urgency calculations()" was dropped along with the formatted_display() function # def calculate_Urgency(task_on_Line): # dueValue = scrape_keywords(strip_line(task_on_Line)) # if scrape_date(dueValue) > time.hour(24) # regex turned out to be the bane of my existence... also I had a late start so I'll take partial responsibility for that😅 # NB: After attempting to write my own parser-functions above, I eventually tried to switch tactics and use dateutil.parse # The results from one solution, or the other, would've yielded me a string of YYYY-MM-DD HH-MM format # Then I planned to use datetime's built-in strptime(inputVariable, "%format-%template-%here) to return actual integers # From there, it would've been trivial to use dateutil.timedelta() to calculate >24 hrs, ≤ 24 hrs, or if it was a negative value # i.e. an overdue task due date that is prior to the value of datetime.today() # Oh, also I planned to compare "day" in the stripped taskline to catch keywords like "Monday, Tuesday, etc" # So scrape_keywords() could've potentially branched off into another function dedicated to non-numeric due-calculations # buuuuut, Haphestus - the god of technology - didn't look down upon me with favor... or something ಠ_ಠ # So I rage quit at this point (╯°□°)╯︵ ┻━┻ formatted_line = ef(effectValue) + fg(foregroundColor) + bg( backgroundColor ) + task + rs.all #swap task+ tags for ▶️ f"{lineNum}: {currentLine}" formatted_list.append(formatted_line) print(formatted_list[index - 1], end="\n")
qui = fg(255, 10, 10) + "This is red text using 24bit colors." + fg.rs # Add custom colors: from sty import RgbFg, Style fg.orange = Style(RgbFg(255, 150, 50)) buf = fg.orange + "Yay, Im orange." + fg.rs print(foo, bar, baz, qux, qui, buf, sep="\n") # ===== End ===== # ===== Start ===== Example("gettings started: select dynamically") a = ef("italic") + "Italic text." + rs.italic b = fg("blue") + "Blue text." + rs.fg c = bg(randint(0, 254)) + "Random colored bg" + rs.bg print(a, b, c, sep="\n") # ===== End ===== # ===== Start ===== Example("gettings started: select 8bit and 24bit directly") # select an 8bit color directly. a = fg(196) + "This is red text" + rs.fg # select a 24bit rgb color directly. b = bg(50, 255, 50) + "Text with green bg" + rs.bg print(a, b, sep="\n")