Some code cleanup
Adjusted code comment indentation, removed commented out debug code.
This commit is contained in:
parent
4e52c269e3
commit
11086049af
19
printer.py
19
printer.py
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
"""
|
||||
TODO: Pseude Retweets (aka Commments). Tweets in which the only URL is to another Tweet.
|
||||
TODO: Pseudo Retweets (aka Commments). Tweets in which the only URL is to another Tweet.
|
||||
TODO: Figure out if/when to show unshortened URLs in links contained in Tweets.
|
||||
TODO: Figure out bimap mode so stuff that is not latin-1 encodable can still be printed.
|
||||
TODO: Figure out bitmap mode so stuff that is not Latin-1 encodable can still be printed.
|
||||
"""
|
||||
|
||||
__version__ = "0.0.1"
|
||||
|
@ -88,8 +88,6 @@ def format_header(handle, name, dt, is_rt=None):
|
|||
|
||||
header = header.ljust(space)
|
||||
header += dt.strftime(" %Y-%m-%d %H:%M:%S")
|
||||
#if shortened_by>0:
|
||||
# header += f" name shoretened by {shortened_by}"
|
||||
return header
|
||||
|
||||
|
||||
|
@ -99,8 +97,8 @@ class Printer:
|
|||
|
||||
def __enter__(self):
|
||||
self.printer = open(self.port, "wb")
|
||||
self.printer.write(bytes([0x1b, 0x40])) # Initialize printer
|
||||
self.printer.write(bytes([0x1b, 0x74, 0x06])) # Set character code table to CP1252/Latin-1
|
||||
self.printer.write(bytes([0x1b, 0x40])) # Initialize printer
|
||||
self.printer.write(bytes([0x1b, 0x74, 0x06])) # Set character code table to CP1252/Latin-1
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
|
@ -114,11 +112,11 @@ class Printer:
|
|||
return
|
||||
self.printer.write(data)
|
||||
if newline:
|
||||
self.printer.write(bytes([13, 10]))
|
||||
self.printer.write(bytes([13, 10])) # CR, LF
|
||||
if cut:
|
||||
self.printer.write(bytes([0x1d, 0x56, # Feed and Cut
|
||||
0x42, # Feed to cut position with extra length and cut
|
||||
10 # extra*Y Unit exta space
|
||||
self.printer.write(bytes([0x1d, 0x56, # Feed and Cut
|
||||
0x42, # Feed to cut position with extra length and cut
|
||||
10 # extra*Y Unit exta space
|
||||
]))
|
||||
|
||||
def flush(self):
|
||||
|
@ -150,7 +148,6 @@ class StreamListener(tweepy.StreamListener):
|
|||
self.seen_tweets.add(status.id)
|
||||
text = status.extended_tweet["full_text"] if status.truncated else status.text
|
||||
text = html.unescape(text)
|
||||
#print("[{}] New tweet from @{}: {}".format(self.title, status.user.screen_name, text))
|
||||
header = format_header(status.user.screen_name, status.user.name, status.created_at)
|
||||
print(header)
|
||||
print(text)
|
||||
|
|
Loading…
Reference in New Issue