def _print_stream_item(self, item, pattern=None): print("") term = Terminal() time_label = "%s at %s" % (term.yellow(item.time.strftime("%a, %d %b %Y")), term.yellow(item.time.strftime("%H:%M"))) print("%s on %s:" % (term.cyan(item.source), time_label)) title = item.title if title is not None: if pattern is not None: title = pattern.sub(term.bold_black_on_bright_yellow("\\g<0>") + term.bold, title) print(" %s" % term.bold(title)) excerpter = TextExcerpter() excerpt, clipped_left, clipped_right = excerpter.get_excerpt(item.text, 220, pattern) # Hashtag or mention excerpt = re.sub("(?<!\w)([#@])(\w+)", term.green("\\g<1>") + term.bright_green("\\g<2>"), excerpt) # URL in one of the forms commonly encountered on the web excerpt = re.sub("(\w+://)?[\w.-]+\.[a-zA-Z]{2,4}(?(1)|/)[\w#?&=%/:.-]*", term.bright_magenta_underline("\\g<0>"), excerpt) if pattern is not None: # TODO: This can break previously applied highlighting (e.g. URLs) excerpt = pattern.sub(term.black_on_bright_yellow("\\g<0>"), excerpt) print(" %s%s%s" % ("... " if clipped_left else "", excerpt, " ..." if clipped_right else "")) print(" %s" % term.bright_blue_underline(item.link))
def show_transactions_from_date(oldest): transactions = [] tfile = open("transactions.csv", "r+") with tfile: reader = csv.reader(tfile, delimiter="\t") for row in reader: if datetime.datetime.strptime(row[0], "%d.%m.%Y") >= oldest: # transactions.append(row) print ", ".join(row) entry = "start" cls() print term.black_on_bright_yellow("Haushaltsbuch") print "" print "Welcome to the accounting app." print "Would you like to add a new transaction ('new'), see all accounts ('show accounts') or categories ('show categories')? For more help, type 'help'." print "" while entry != "quit": accounts = check_balance() account_names = list(accounts.keys()) entry = raw_input("") cls() if entry == "show accounts": show_accounts()