本文整理匯總了Python中ranger.core.loader.Loader.destroy方法的典型用法代碼示例。如果您正苦於以下問題:Python Loader.destroy方法的具體用法?Python Loader.destroy怎麽用?Python Loader.destroy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ranger.core.loader.Loader
的用法示例。
在下文中一共展示了Loader.destroy方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: FM
# 需要導入模塊: from ranger.core.loader import Loader [as 別名]
# 或者: from ranger.core.loader.Loader import destroy [as 別名]
#.........這裏部分代碼省略.........
new_command = command.replace("sxiv ", "sxiv -n %d " % number, 1)
if command[0:4] == 'feh ':
new_command = command.replace(
"feh ",
"feh --start-at %s " % shell_quote(self.thisfile.relative_path),
1,
)
if command[0:4] == 'imv ':
number = images.index(self.thisfile.relative_path) + 1
new_command = command.replace("imv ", "imv -n %d " % number, 1)
if command[0:5] == 'pqiv ':
number = images.index(self.thisfile.relative_path)
new_command = command.replace(
"pqiv ", "pqiv --action \"goto_file_byindex(%d)\" " % number, 1)
if new_command:
command = "set -- %s; %s" % (escaped_filenames, new_command)
return old_preprocessing_hook(command)
self.rifle.hook_command_preprocessing = sxiv_workaround_hook
def mylogfunc(text):
self.notify(text, bad=True)
self.run = Runner(ui=self.ui, logfunc=mylogfunc, fm=self)
self.settings.signal_bind(
'setopt.metadata_deep_search',
lambda signal: setattr(signal.fm.metadata, 'deep_search', signal.value)
)
def destroy(self):
debug = ranger.args.debug
if self.ui:
try:
self.ui.destroy()
except Exception: # pylint: disable=broad-except
if debug:
raise
if self.loader:
try:
self.loader.destroy()
except Exception: # pylint: disable=broad-except
if debug:
raise
@staticmethod
def get_log():
"""Return the current log
The log is returned as a generator over its entries' lines
"""
for entry in logutils.QUEUE:
for line in entry.splitlines():
yield line
def _get_image_displayer(self):
if self.settings.preview_images_method == "w3m":
return W3MImageDisplayer()
elif self.settings.preview_images_method == "iterm2":
return ITerm2ImageDisplayer()
elif self.settings.preview_images_method == "urxvt":
return URXVTImageDisplayer()
elif self.settings.preview_images_method == "urxvt-full":
示例2: FM
# 需要導入模塊: from ranger.core.loader import Loader [as 別名]
# 或者: from ranger.core.loader.Loader import destroy [as 別名]
class FM(Actions, SignalDispatcher):
input_blocked = False
input_blocked_until = 0
mode = "normal" # either 'normal' or 'visual'.
search_method = "ctime"
_previous_selection = None
_visual_reverse = False
_visual_start = None
_visual_start_pos = None
def __init__(self, ui=None, bookmarks=None, tags=None, paths=["."]):
"""Initialize FM."""
Actions.__init__(self)
SignalDispatcher.__init__(self)
if ui is None:
self.ui = UI()
else:
self.ui = ui
self.start_paths = paths
self.directories = dict()
self.log = deque(maxlen=20)
self.bookmarks = bookmarks
self.current_tab = 1
self.tabs = {}
self.tags = tags
self.restorable_tabs = deque([], ranger.MAX_RESTORABLE_TABS)
self.py3 = sys.version_info >= (3,)
self.previews = {}
self.loader = Loader()
self.copy_buffer = set()
self.do_cut = False
try:
self.username = pwd.getpwuid(os.geteuid()).pw_name
except:
self.username = "uid:" + str(os.geteuid())
self.hostname = socket.gethostname()
self.home_path = os.path.expanduser("~")
self.log.append("ranger {0} started! Process ID is {1}.".format(__version__, os.getpid()))
self.log.append("Running on Python " + sys.version.replace("\n", ""))
mimetypes.knownfiles.append(os.path.expanduser("~/.mime.types"))
mimetypes.knownfiles.append(self.relpath("data/mime.types"))
self.mimetypes = mimetypes.MimeTypes()
def initialize(self):
"""If ui/bookmarks are None, they will be initialized here."""
self.tabs = dict((n + 1, Tab(path)) for n, path in enumerate(self.start_paths))
tab_list = self._get_tab_list()
if tab_list:
self.current_tab = tab_list[0]
self.thistab = self.tabs[self.current_tab]
else:
self.current_tab = 1
self.tabs[self.current_tab] = self.thistab = Tab(".")
if not ranger.arg.clean and os.path.isfile(self.confpath("rifle.conf")):
rifleconf = self.confpath("rifle.conf")
else:
rifleconf = self.relpath("config/rifle.conf")
self.rifle = Rifle(rifleconf)
self.rifle.reload_config()
if self.bookmarks is None:
if ranger.arg.clean:
bookmarkfile = None
else:
bookmarkfile = self.confpath("bookmarks")
self.bookmarks = Bookmarks(
bookmarkfile=bookmarkfile, bookmarktype=Directory, autosave=self.settings.autosave_bookmarks
)
self.bookmarks.load()
if not ranger.arg.clean and self.tags is None:
self.tags = Tags(self.confpath("tagged"))
self.ui.setup_curses()
self.ui.initialize()
self.rifle.hook_before_executing = lambda a, b, flags: self.ui.suspend() if "f" not in flags else None
self.rifle.hook_after_executing = lambda a, b, flags: self.ui.initialize() if "f" not in flags else None
self.rifle.hook_logger = self.notify
def mylogfunc(text):
self.notify(text, bad=True)
self.run = Runner(ui=self.ui, logfunc=mylogfunc, fm=self)
def destroy(self):
debug = ranger.arg.debug
if self.ui:
try:
self.ui.destroy()
except:
if debug:
raise
if self.loader:
#.........這裏部分代碼省略.........
示例3: FM
# 需要導入模塊: from ranger.core.loader import Loader [as 別名]
# 或者: from ranger.core.loader.Loader import destroy [as 別名]
#.........這裏部分代碼省略.........
if self.settings.open_all_images and \
len(self.thisdir.marked_items) == 0 and \
re.match(r'^(feh|sxiv) ', command):
images = [f.basename for f in self.thisdir.files if f.image]
escaped_filenames = " ".join(shell_quote(f) \
for f in images if "\x00" not in f)
if images and self.thisfile.basename in images and \
"[email protected]" in command:
new_command = None
if command[0:5] == 'sxiv ':
number = images.index(self.thisfile.basename) + 1
new_command = command.replace("sxiv ",
"sxiv -n %d " % number, 1)
if command[0:4] == 'feh ':
new_command = command.replace("feh ",
"feh --start-at %s " % \
shell_quote(self.thisfile.basename), 1)
if new_command:
command = "set -- %s; %s" % (escaped_filenames,
new_command)
return command
self.rifle.hook_command_preprocessing = sxiv_workaround_hook
def mylogfunc(text):
self.notify(text, bad=True)
self.run = Runner(ui=self.ui, logfunc=mylogfunc, fm=self)
def destroy(self):
debug = ranger.arg.debug
if self.ui:
try:
self.ui.destroy()
except:
if debug:
raise
if self.loader:
try:
self.loader.destroy()
except:
if debug:
raise
def _get_thisfile(self):
return self.thistab.thisfile
def _set_thisfile(self, obj):
self.thistab.thisfile = obj
def _get_thisdir(self):
return self.thistab.thisdir
def _set_thisdir(self, obj):
self.thistab.thisdir = obj
thisfile = property(_get_thisfile, _set_thisfile)
thisdir = property(_get_thisdir, _set_thisdir)
def block_input(self, sec=0):
self.input_blocked = sec != 0
self.input_blocked_until = time() + sec
示例4: FM
# 需要導入模塊: from ranger.core.loader import Loader [as 別名]
# 或者: from ranger.core.loader.Loader import destroy [as 別名]
class FM(Actions, SignalDispatcher):
input_blocked = False
input_blocked_until = 0
def __init__(self, ui=None, bookmarks=None, tags=None):
"""Initialize FM."""
Actions.__init__(self)
SignalDispatcher.__init__(self)
self.ui = ui
self.log = deque(maxlen=20)
self.bookmarks = bookmarks
self.tags = tags
self.tabs = {}
self.py3 = sys.version_info >= (3, )
self.previews = {}
self.current_tab = 1
self.loader = Loader()
self.log.append('Ranger {0} started! Process ID is {1}.' \
.format(__version__, os.getpid()))
self.log.append('Running on Python ' + sys.version.replace('\n',''))
mimetypes.knownfiles.append(os.path.expanduser('~/.mime.types'))
mimetypes.knownfiles.append(self.relpath('data/mime.types'))
self.mimetypes = mimetypes.MimeTypes()
# COMPAT
@property
def executables(self):
"""For compatibility. Calls get_executables()"""
return get_executables()
def initialize(self):
"""If ui/bookmarks are None, they will be initialized here."""
if self.bookmarks is None:
if ranger.arg.clean:
bookmarkfile = None
else:
bookmarkfile = self.confpath('bookmarks')
self.bookmarks = Bookmarks(
bookmarkfile=bookmarkfile,
bookmarktype=Directory,
autosave=self.settings.autosave_bookmarks)
self.bookmarks.load()
else:
self.bookmarks = bookmarks
if not ranger.arg.clean and self.tags is None:
self.tags = Tags(self.confpath('tagged'))
if self.ui is None:
self.ui = DefaultUI()
self.ui.initialize()
def mylogfunc(text):
self.notify(text, bad=True)
self.run = Runner(ui=self.ui, apps=self.apps,
logfunc=mylogfunc)
self.env.signal_bind('cd', self._update_current_tab)
def destroy(self):
debug = ranger.arg.debug
if self.ui:
try:
self.ui.destroy()
except:
if debug:
raise
if self.loader:
try:
self.loader.destroy()
except:
if debug:
raise
def block_input(self, sec=0):
self.input_blocked = sec != 0
self.input_blocked_until = time() + sec
def input_is_blocked(self):
if self.input_blocked and time() > self.input_blocked_until:
self.input_blocked = False
return self.input_blocked
def copy_config_files(self, which):
if ranger.arg.clean:
sys.stderr.write("refusing to copy config files in clean mode\n")
return
import shutil
def copy(_from, to):
if os.path.exists(self.confpath(to)):
sys.stderr.write("already exists: %s\n" % self.confpath(to))
else:
sys.stderr.write("creating: %s\n" % self.confpath(to))
try:
shutil.copy(self.relpath(_from), self.confpath(to))
except Exception as e:
sys.stderr.write(" ERROR: %s\n" % str(e))
if which == 'apps' or which == 'all':
#.........這裏部分代碼省略.........
示例5: FM
# 需要導入模塊: from ranger.core.loader import Loader [as 別名]
# 或者: from ranger.core.loader.Loader import destroy [as 別名]
class FM(Actions, SignalDispatcher):
input_blocked = False
input_blocked_until = 0
def __init__(self, ui=None, bookmarks=None, tags=None):
"""Initialize FM."""
Actions.__init__(self)
SignalDispatcher.__init__(self)
self.ui = ui
self.log = deque(maxlen=20)
self.bookmarks = bookmarks
self.tags = tags
self.tabs = {}
self.py3 = sys.version_info >= (3,)
self.previews = {}
self.current_tab = 1
self.loader = Loader()
self.log.append("ranger {0} started! Process ID is {1}.".format(__version__, os.getpid()))
self.log.append("Running on Python " + sys.version.replace("\n", ""))
mimetypes.knownfiles.append(os.path.expanduser("~/.mime.types"))
mimetypes.knownfiles.append(self.relpath("data/mime.types"))
self.mimetypes = mimetypes.MimeTypes()
def initialize(self):
"""If ui/bookmarks are None, they will be initialized here."""
if self.bookmarks is None:
if ranger.arg.clean:
bookmarkfile = None
else:
bookmarkfile = self.confpath("bookmarks")
self.bookmarks = Bookmarks(
bookmarkfile=bookmarkfile, bookmarktype=Directory, autosave=self.settings.autosave_bookmarks
)
self.bookmarks.load()
if not ranger.arg.clean and self.tags is None:
self.tags = Tags(self.confpath("tagged"))
if self.ui is None:
self.ui = UI()
self.ui.initialize()
def mylogfunc(text):
self.notify(text, bad=True)
self.run = Runner(ui=self.ui, apps=self.apps, logfunc=mylogfunc, fm=self)
self.env.signal_bind("cd", self._update_current_tab)
if self.settings.init_function:
self.settings.init_function(self)
def destroy(self):
debug = ranger.arg.debug
if self.ui:
try:
self.ui.destroy()
except:
if debug:
raise
if self.loader:
try:
self.loader.destroy()
except:
if debug:
raise
def block_input(self, sec=0):
self.input_blocked = sec != 0
self.input_blocked_until = time() + sec
def input_is_blocked(self):
if self.input_blocked and time() > self.input_blocked_until:
self.input_blocked = False
return self.input_blocked
def copy_config_files(self, which):
if ranger.arg.clean:
sys.stderr.write("refusing to copy config files in clean mode\n")
return
import shutil
def copy(_from, to):
if os.path.exists(self.confpath(to)):
sys.stderr.write("already exists: %s\n" % self.confpath(to))
else:
sys.stderr.write("creating: %s\n" % self.confpath(to))
try:
shutil.copy(self.relpath(_from), self.confpath(to))
except Exception as e:
sys.stderr.write(" ERROR: %s\n" % str(e))
if which == "apps" or which == "all":
copy("defaults/apps.py", "apps.py")
if which == "commands" or which == "all":
copy("defaults/commands.py", "commands.py")
if which == "rc" or which == "all":
copy("defaults/rc.conf", "rc.conf")
#.........這裏部分代碼省略.........