本文整理汇总了Python中ranger.ext.rifle.Rifle.execute方法的典型用法代码示例。如果您正苦于以下问题:Python Rifle.execute方法的具体用法?Python Rifle.execute怎么用?Python Rifle.execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ranger.ext.rifle.Rifle
的用法示例。
在下文中一共展示了Rifle.execute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from ranger.ext.rifle import Rifle [as 别名]
# 或者: from ranger.ext.rifle.Rifle import execute [as 别名]
def main():
"""initialize objects and run the filemanager"""
import locale
import ranger.api
from ranger.container.settings import Settings
from ranger.core.shared import FileManagerAware, SettingsAware
from ranger.core.fm import FM
if not sys.stdin.isatty():
sys.stderr.write("Error: Must run ranger from terminal\n")
raise SystemExit(1)
try:
locale.setlocale(locale.LC_ALL, '')
except:
print("Warning: Unable to set locale. Expect encoding problems.")
# so that programs can know that ranger spawned them:
level = 'RANGER_LEVEL'
if level in os.environ and os.environ[level].isdigit():
os.environ[level] = str(int(os.environ[level]) + 1)
else:
os.environ[level] = '1'
if not 'SHELL' in os.environ:
os.environ['SHELL'] = 'sh'
ranger.arg = arg = parse_arguments()
if arg.copy_config is not None:
fm = FM()
fm.copy_config_files(arg.copy_config)
return 1 if arg.fail_unless_cd else 0 # COMPAT
if arg.list_tagged_files:
fm = FM()
try:
f = open(fm.confpath('tagged'), 'r')
except:
pass
else:
for line in f.readlines():
if len(line) > 2 and line[1] == ':':
if line[0] in arg.list_tagged_files:
sys.stdout.write(line[2:])
elif len(line) > 0 and '*' in arg.list_tagged_files:
sys.stdout.write(line)
return 1 if arg.fail_unless_cd else 0 # COMPAT
SettingsAware._setup(Settings())
if arg.selectfile:
arg.selectfile = os.path.abspath(arg.selectfile)
arg.targets.insert(0, os.path.dirname(arg.selectfile))
targets = arg.targets or ['.']
target = targets[0]
if arg.targets: # COMPAT
if target.startswith('file://'):
target = target[7:]
if not os.access(target, os.F_OK):
print("File or directory doesn't exist: %s" % target)
return 1
elif os.path.isfile(target):
sys.stderr.write("Warning: Using ranger as a file launcher is "
"deprecated.\nPlease use the standalone file launcher "
"'rifle' instead.\n")
def print_function(string):
print(string)
from ranger.ext.rifle import Rifle
fm = FM()
if not arg.clean and os.path.isfile(fm.confpath('rifle.conf')):
rifleconf = fm.confpath('rifle.conf')
else:
rifleconf = fm.relpath('config/rifle.conf')
rifle = Rifle(rifleconf)
rifle.reload_config()
rifle.execute(targets, number=ranger.arg.mode, flags=ranger.arg.flags)
return 1 if arg.fail_unless_cd else 0 # COMPAT
crash_traceback = None
try:
# Initialize objects
fm = FM(paths=targets)
FileManagerAware._setup(fm)
load_settings(fm, arg.clean)
if arg.list_unused_keys:
from ranger.ext.keybinding_parser import (special_keys,
reversed_special_keys)
maps = fm.ui.keymaps['browser']
for key in sorted(special_keys.values(), key=lambda x: str(x)):
if key not in maps:
print("<%s>" % reversed_special_keys[key])
for key in range(33, 127):
if key not in maps:
print(chr(key))
return 1 if arg.fail_unless_cd else 0 # COMPAT
if fm.username == 'root':
fm.settings.preview_files = False
fm.settings.use_preview_script = False
#.........这里部分代码省略.........