Compare commits
No commits in common. "804438f04506a1ed8cfec99d25a7ea261fa9e631" and "315a249ef6c730105ab408510e09e8e6e0b18c44" have entirely different histories.
804438f045
...
315a249ef6
32
bundle.py
32
bundle.py
|
@ -1,32 +0,0 @@
|
||||||
import zipfile
|
|
||||||
import glob
|
|
||||||
import os
|
|
||||||
|
|
||||||
|
|
||||||
# TODO: should we include .pyc files?
|
|
||||||
# TODO: add urwid source into the repo somewhere
|
|
||||||
|
|
||||||
files = {
|
|
||||||
'__main__.py': 'clients/urwid/main.py',
|
|
||||||
'network.py': 'clients/network_client.py',
|
|
||||||
'urwid': 'env/lib/python3.8/site-packages/urwid/*.py',
|
|
||||||
}
|
|
||||||
|
|
||||||
with open('bbj_demo', 'wb') as f:
|
|
||||||
f.write(b"#!/usr/bin/env python3\n")
|
|
||||||
with zipfile.ZipFile(f, 'w', compression=zipfile.ZIP_DEFLATED) as z:
|
|
||||||
z.comment = b'BBJ'
|
|
||||||
for name, source in files.items():
|
|
||||||
if '*' in source:
|
|
||||||
dirname = name
|
|
||||||
for path in sorted(glob.glob(source)):
|
|
||||||
name = dirname + '/' + os.path.basename(path)
|
|
||||||
z.write(path, name)
|
|
||||||
else:
|
|
||||||
z.write(source, name)
|
|
||||||
try:
|
|
||||||
mask = os.umask(0)
|
|
||||||
os.umask(mask)
|
|
||||||
except OSError:
|
|
||||||
mask = 0
|
|
||||||
os.chmod(z.filename, 0o777&~mask)
|
|
|
@ -793,7 +793,7 @@ class App(object):
|
||||||
"""
|
"""
|
||||||
if self.mode == "thread":
|
if self.mode == "thread":
|
||||||
# mark the current position in this thread before going back to the index
|
# mark the current position in this thread before going back to the index
|
||||||
self.mark()
|
mark()
|
||||||
|
|
||||||
self.body.attr_map = {None: "default"}
|
self.body.attr_map = {None: "default"}
|
||||||
self.mode = "index"
|
self.mode = "index"
|
||||||
|
@ -859,7 +859,7 @@ class App(object):
|
||||||
self.walker += self.make_message_body(message)
|
self.walker += self.make_message_body(message)
|
||||||
self.set_default_header()
|
self.set_default_header()
|
||||||
self.set_default_footer()
|
self.set_default_footer()
|
||||||
self.goto_mark(thread_id)
|
self.goto_post(mark(thread_id))
|
||||||
|
|
||||||
|
|
||||||
def toggle_client_pin(self):
|
def toggle_client_pin(self):
|
||||||
|
@ -983,10 +983,10 @@ class App(object):
|
||||||
self.last_index_pos = self.get_focus_post(True).thread["thread_id"]
|
self.last_index_pos = self.get_focus_post(True).thread["thread_id"]
|
||||||
self.index()
|
self.index()
|
||||||
else:
|
else:
|
||||||
self.mark()
|
mark()
|
||||||
thread = self.thread["thread_id"]
|
thread = self.thread["thread_id"]
|
||||||
self.thread_load(None, thread)
|
self.thread_load(None, thread)
|
||||||
self.goto_mark(thread)
|
self.goto_post(mark(thread))
|
||||||
self.temp_footer_message("Refreshed content!", 1)
|
self.temp_footer_message("Refreshed content!", 1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -1021,31 +1021,10 @@ class App(object):
|
||||||
width=30, height=6)
|
width=30, height=6)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
self.mark()
|
mark()
|
||||||
self.index()
|
self.index()
|
||||||
|
|
||||||
|
|
||||||
def mark(self, thread_id=None):
|
|
||||||
if self.mode != "thread":
|
|
||||||
return
|
|
||||||
|
|
||||||
if thread_id is None:
|
|
||||||
thread_id = self.thread['thread_id']
|
|
||||||
pos = self.get_focus_post()
|
|
||||||
mark(thread_id, pos, default=0)
|
|
||||||
return pos
|
|
||||||
|
|
||||||
|
|
||||||
def goto_mark(self, thread_id=None):
|
|
||||||
if self.mode != "thread":
|
|
||||||
return
|
|
||||||
|
|
||||||
if thread_id is None:
|
|
||||||
thread_id = self.thread['thread_id']
|
|
||||||
pos = mark(thread_id, default=0)
|
|
||||||
self.goto_post(pos)
|
|
||||||
|
|
||||||
|
|
||||||
def get_focus_post(self, return_widget=False):
|
def get_focus_post(self, return_widget=False):
|
||||||
pos = self.box.get_focus_path()[0]
|
pos = self.box.get_focus_path()[0]
|
||||||
if self.mode == "thread":
|
if self.mode == "thread":
|
||||||
|
@ -2522,16 +2501,11 @@ def bbjrc(mode, **params):
|
||||||
return values
|
return values
|
||||||
|
|
||||||
|
|
||||||
def mark(key, value=None, default=None):
|
def mark(directive=True):
|
||||||
"""
|
"""
|
||||||
Sets a value in the markfile and returns the old value (or default).
|
Set and retrieve positional marks for threads.
|
||||||
This uses a seperate file from the preferences
|
This uses a seperate file from the preferences
|
||||||
to keep it free from clutter.
|
to keep it free from clutter.
|
||||||
|
|
||||||
The key must be a string, and the value must be
|
|
||||||
json-encodable. If value isn't provided (or is None)
|
|
||||||
then this doesn't set anything and it is only a
|
|
||||||
read operation.
|
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
with open(markpath, "r") as _in:
|
with open(markpath, "r") as _in:
|
||||||
|
@ -2539,14 +2513,19 @@ def mark(key, value=None, default=None):
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
values = {}
|
values = {}
|
||||||
|
|
||||||
old = values.get(key, default)
|
if directive == True and app.mode == "thread":
|
||||||
|
pos = app.get_focus_post()
|
||||||
if value is not None and value != old:
|
values[app.thread["thread_id"]] = pos
|
||||||
values[key] = value
|
|
||||||
with open(markpath, "w") as _out:
|
with open(markpath, "w") as _out:
|
||||||
json.dump(values, _out)
|
json.dump(values, _out)
|
||||||
|
return pos
|
||||||
|
|
||||||
|
elif isinstance(directive, str):
|
||||||
|
try:
|
||||||
|
return values[directive]
|
||||||
|
except KeyError:
|
||||||
|
return 0
|
||||||
|
|
||||||
return old
|
|
||||||
|
|
||||||
def load_client_pins():
|
def load_client_pins():
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue