Coding style.
This commit is contained in:
parent
91879f2041
commit
40b2460038
2 changed files with 23 additions and 27 deletions
|
|
@ -49,6 +49,14 @@ def _parse_proc_mounts():
|
||||||
yield line.split()
|
yield line.split()
|
||||||
|
|
||||||
|
|
||||||
|
def _find_mounts():
|
||||||
|
all_mounts = set(part[1] for part in _parse_proc_mounts())
|
||||||
|
mount_points = {"/", "/usr", "/bin", "/etc", "/lib", "/dev", "/proc",
|
||||||
|
"/home", "/boot", "/opt", "/run", "/sys", "/root", "/var",
|
||||||
|
"/tmp"}
|
||||||
|
return all_mounts.intersection(mount_points)
|
||||||
|
|
||||||
|
|
||||||
class SandboxFs:
|
class SandboxFs:
|
||||||
|
|
||||||
def __init__(self, mount_point):
|
def __init__(self, mount_point):
|
||||||
|
|
@ -59,17 +67,10 @@ class SandboxFs:
|
||||||
return "<SandboxFs:%r mounts:%r>" % (self.mount_point,
|
return "<SandboxFs:%r mounts:%r>" % (self.mount_point,
|
||||||
len(self.overlay_mounts))
|
len(self.overlay_mounts))
|
||||||
|
|
||||||
def _find_mounts(self):
|
|
||||||
all_mounts = set(part[1] for part in _parse_proc_mounts())
|
|
||||||
obvious_mount_points = {"/", "/usr", "/bin", "/etc", "/lib", "/dev",
|
|
||||||
"/proc", "/home", "/boot", "/opt", "/run",
|
|
||||||
"/sys", "/root", "/var", "/tmp"}
|
|
||||||
return all_mounts.intersection(obvious_mount_points)
|
|
||||||
|
|
||||||
def mount(self):
|
def mount(self):
|
||||||
self.overlay_mounts = [OverlayfsMount(mount_point,
|
self.overlay_mounts = [OverlayfsMount(mount_point,
|
||||||
self.mount_point + mount_point)
|
self.mount_point + mount_point)
|
||||||
for mount_point in sorted(self._find_mounts())]
|
for mount_point in sorted(_find_mounts())]
|
||||||
|
|
||||||
def umount(self):
|
def umount(self):
|
||||||
for mount in reversed(self.overlay_mounts):
|
for mount in reversed(self.overlay_mounts):
|
||||||
|
|
|
||||||
31
vigil
31
vigil
|
|
@ -42,7 +42,6 @@ import collections
|
||||||
import contextlib
|
import contextlib
|
||||||
import functools
|
import functools
|
||||||
import gzip
|
import gzip
|
||||||
import importlib
|
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
|
|
@ -216,11 +215,9 @@ class Entry(collections.UserList):
|
||||||
appearance = self.appearance_cache
|
appearance = self.appearance_cache
|
||||||
if appearance is None:
|
if appearance is None:
|
||||||
if self.highlighted is not None:
|
if self.highlighted is not None:
|
||||||
if self.summary.is_status_simple:
|
cursor = (fill3.Text("●") if self.summary.is_status_simple
|
||||||
cursor = fill3.Text("●")
|
else fill3.Style(self.widget[self.highlighted],
|
||||||
else:
|
reverse_style))
|
||||||
cursor = fill3.Style(self.widget[self.highlighted],
|
|
||||||
reverse_style)
|
|
||||||
self.widget[self.highlighted] = cursor
|
self.widget[self.highlighted] = cursor
|
||||||
new_appearance = self.widget.appearance_min()
|
new_appearance = self.widget.appearance_min()
|
||||||
path = tools._path_colored(self.path)
|
path = tools._path_colored(self.path)
|
||||||
|
|
@ -287,9 +284,7 @@ class Summary:
|
||||||
self.__cursor_position = new_position
|
self.__cursor_position = new_position
|
||||||
self.closest_placeholder_generator = None
|
self.closest_placeholder_generator = None
|
||||||
|
|
||||||
def sync_with_filesystem(self, sync_tools=True, sync_paths=True):
|
def sync_with_filesystem(self, sync_paths=True):
|
||||||
if sync_tools:
|
|
||||||
importlib.reload(tools)
|
|
||||||
x, y = self._cursor_position
|
x, y = self._cursor_position
|
||||||
try:
|
try:
|
||||||
old_path = self.get_selection().path
|
old_path = self.get_selection().path
|
||||||
|
|
@ -454,7 +449,7 @@ class Summary:
|
||||||
|
|
||||||
def toggle_status_style(self):
|
def toggle_status_style(self):
|
||||||
self.is_status_simple = not self.is_status_simple
|
self.is_status_simple = not self.is_status_simple
|
||||||
self.sync_with_filesystem(sync_tools=False, sync_paths=False)
|
self.sync_with_filesystem(sync_paths=False)
|
||||||
|
|
||||||
def sort(self, is_directory_sort):
|
def sort(self, is_directory_sort):
|
||||||
def directory_sort(path):
|
def directory_sort(path):
|
||||||
|
|
@ -467,7 +462,7 @@ class Summary:
|
||||||
key_func = directory_sort if is_directory_sort else type_sort
|
key_func = directory_sort if is_directory_sort else type_sort
|
||||||
self._paths.sort(key=key_func)
|
self._paths.sort(key=key_func)
|
||||||
self.is_directory_sort = is_directory_sort
|
self.is_directory_sort = is_directory_sort
|
||||||
self.sync_with_filesystem(sync_tools=False, sync_paths=False)
|
self.sync_with_filesystem(sync_paths=False)
|
||||||
|
|
||||||
|
|
||||||
class Log:
|
class Log:
|
||||||
|
|
@ -745,8 +740,8 @@ class Screen:
|
||||||
" *order *statuses", Log.GREEN_STYLE)
|
" *order *statuses", Log.GREEN_STYLE)
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=2)
|
@functools.lru_cache(maxsize=2)
|
||||||
def _get_status_bar_appearance(self, width, is_directory_sort,
|
def _get_status_bar_appearance(self, width, is_directory_sort, is_paused,
|
||||||
is_paused, progress_bar_size):
|
progress_bar_size):
|
||||||
ordering_text = "directory" if is_directory_sort else "type "
|
ordering_text = "directory" if is_directory_sort else "type "
|
||||||
paused_text = "paused" if is_paused else "------"
|
paused_text = "paused" if is_paused else "------"
|
||||||
indicators = " %s order:%s " % (paused_text, ordering_text)
|
indicators = " %s order:%s " % (paused_text, ordering_text)
|
||||||
|
|
@ -785,8 +780,8 @@ class Screen:
|
||||||
({"C", "page down"}, listing_down), ({"J", "home"}, listing_left),
|
({"C", "page down"}, listing_down), ({"J", "home"}, listing_left),
|
||||||
({"K", "end"}, listing_right), ({"o"}, toggle_sort),
|
({"K", "end"}, listing_right), ({"o"}, toggle_sort),
|
||||||
({"n"}, move_to_next_issue), ({"N"}, move_to_next_issue_of_tool),
|
({"n"}, move_to_next_issue), ({"N"}, move_to_next_issue_of_tool),
|
||||||
({"e"}, edit_file), ({"s"}, toggle_status_style),
|
({"e"}, edit_file), ({"s"}, toggle_status_style), ({"q"}, quit_),
|
||||||
({"q"}, quit_), ({"p"}, toggle_pause)]
|
({"p"}, toggle_pause)]
|
||||||
|
|
||||||
|
|
||||||
def get_cpu_temperature():
|
def get_cpu_temperature():
|
||||||
|
|
@ -893,7 +888,7 @@ def main(root_path, is_being_tested=False):
|
||||||
|
|
||||||
def on_filesystem_change():
|
def on_filesystem_change():
|
||||||
log.log_message("Filesystem changed.")
|
log.log_message("Filesystem changed.")
|
||||||
summary.sync_with_filesystem(sync_tools=False)
|
summary.sync_with_filesystem()
|
||||||
appearance_changed_event.set()
|
appearance_changed_event.set()
|
||||||
add_watch_manager_to_mainloop(root_path, loop, on_filesystem_change)
|
add_watch_manager_to_mainloop(root_path, loop, on_filesystem_change)
|
||||||
log.log_message("Program started.")
|
log.log_message("Program started.")
|
||||||
|
|
@ -949,8 +944,8 @@ def main(root_path, is_being_tested=False):
|
||||||
# Cannot pickle generators, locks, sockets or events.
|
# Cannot pickle generators, locks, sockets or events.
|
||||||
(summary.closest_placeholder_generator, summary._lock,
|
(summary.closest_placeholder_generator, summary._lock,
|
||||||
summary._jobs_added_event, screen._appearance_changed_event,
|
summary._jobs_added_event, screen._appearance_changed_event,
|
||||||
screen._main_loop, screen.runners, log._appearance_changed_event) \
|
screen._main_loop, screen.runners,
|
||||||
= [None] * 7
|
log._appearance_changed_event) = [None] * 7
|
||||||
open_compressed = functools.partial(gzip.open, compresslevel=1)
|
open_compressed = functools.partial(gzip.open, compresslevel=1)
|
||||||
dump_pickle_safe(screen, pickle_path, open=open_compressed)
|
dump_pickle_safe(screen, pickle_path, open=open_compressed)
|
||||||
finally:
|
finally:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue