summary refs log tree commit diff stats
path: root/pylintrc
Path not found
ame/themes/hacker?id=3a1be74e9389d3e161f196e7402bbdff783cb0ee'>blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
[colours]
bkgnd=default
titlebar=green
titlebar.text=black
titlebar.brackets=black
titlebar.unencrypted=black
titlebar.encrypted=black
titlebar.untrusted=black
titlebar.trusted=black
titlebar.online=black
titlebar.offline=black
titlebar.away=black
titlebar.chat=black
titlebar.dnd=black
titlebar.xa=black
statusbar=green
statusbar.text=black
statusbar.time=black
statusbar.brackets=black
statusbar.active=black
statusbar.new=black
main.text=green
main.text.me=green
main.text.them=green
main.splash=bold_green
main.help.header=bold_green
main.time=bold_green
input.text=bold_green
subscribed=bold_green
unsubscribed=green
otr.started.trusted=green
otr.started.untrusted=green
otr.ended=green
otr.trusted=green
otr.untrusted=green
online=bold_green
away=green
chat=bold_green
dnd=green
xa=green
offline=green
incoming=bold_green
mention=bold_green
trigger=bold_green
typing=green
gone=green
error=bold_green
roominfo=green
roommention=bold_green
roommention.term=bold_green
roomtrigger=bold_green
roomtrigger.term=bold_green
me=green
them=bold_green
roster.header=bold_green
roster.chat=bold_green
roster.online=bold_green
roster.away=green
roster.xa=green
roster.dnd=green
roster.offline=green
roster.chat.active=bold_green
roster.online.active=bold_green
roster.away.active=green
roster.xa.active=green
roster.dnd.active=green
roster.offline.active=green
roster.chat.unread=bold_green
roster.online.unread=bold_green
roster.away.unread=green
roster.xa.unread=green
roster.dnd.unread=green
roster.offline.unread=green
roster.room=green
roster.room=bold_green
occupants.header=bold_green
receipt.sent=bold_black
: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */
#!/usr/bin/python
# coding=utf-8
#
# Copyright (C) 2009, 2010  Roman Zimbelmann <romanz@lavabit.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Most import statements in this module are inside the functions.
# This enables more convenient exception handling in ranger.py
# (ImportError will imply that this module can't be found)
# convenient exception handling in ranger.py (ImportError)

import os
import sys

def parse_arguments():
	"""Parse the program arguments"""
	from optparse import OptionParser
	from ranger import __version__, USAGE, DEFAULT_CONFDIR
	from ranger.ext.openstruct import OpenStruct
	parser = OptionParser(usage=USAGE, version='ranger ' + __version__)

	parser.add_option('-d', '--debug', action='store_true',
			help="activate debug mode")
	parser.add_option('-c', '--clean', action='store_true',
			help="don't touch/require any config files. ")
	parser.add_option('--fail-if-run', action='store_true',
			help="experimental: return the exit code 1 if ranger is" \
					"used to run a file (with `ranger filename`)")
	parser.add_option('-r', '--confdir', type='string',
			metavar='dir', default=DEFAULT_CONFDIR,
			help="the configuration directory. (%default)")
	parser.add_option('-m', '--mode', type='int', default=0, metavar='n',
			help="if a filename is supplied, run it with this mode")
	parser.add_option('-f', '--flags', type='string', default='',
			metavar='string',
			help="if a filename is supplied, run it with these flags.")

	options, positional = parser.parse_args()
	arg = OpenStruct(options.__dict__, targets=positional)
	arg.confdir = os.path.expanduser(arg.confdir)

	return arg


def allow_access_to_confdir(confdir, allow):
	if allow:
		try:
			os.makedirs(confdir)
		except OSError as err:
			if err.errno != 17:  # 17 means it already exists
				print("This configuration directory could not be created:")
				print(confdir)
				print("To run ranger without the need for configuration")
				print("files, use the --clean option.")
				raise SystemExit()
		if not confdir in sys.path:
			sys.path[0:0] = [confdir]
	else:
		if sys.path[0] == confdir:
			del sys.path[0]


def load_settings(fm, clean):
	import ranger.shared
	import ranger.api.commands
	import ranger.api.keys
	if not clean:
		allow_access_to_confdir(ranger.arg.confdir, True)

		# Load commands
		comcont = ranger.api.commands.CommandContainer()
		ranger.api.commands.alias = comcont.alias
		try:
			import commands
			comcont.load_commands_from_module(commands)
		except ImportError:
			pass
		from ranger.defaults import commands
		comcont.load_commands_from_module(commands)
		commands = comcont

		# Load apps
		try:
			import apps
		except ImportError:
			from ranger.defaults import apps

		# Load keys
		keymanager = ranger.shared.EnvironmentAware.env.keymanager
		ranger.api.keys.keymanager = keymanager
		from ranger.defaults import keys
		try:
			import keys
		except ImportError:
			pass
		# COMPAT WARNING
		if hasattr(keys, 'initialize_commands'):
			print("Warning: the syntax for ~/.ranger/keys.py has changed.")
			print("Your custom keys are not loaded."\
					"  Please update your configuration.")
		allow_access_to_confdir(ranger.arg.confdir, False)
	else:
		comcont = ranger.api.commands.CommandContainer()
		ranger.api.commands.alias = comcont.alias
		from ranger.api import keys
		keymanager = ranger.shared.EnvironmentAware.env.keymanager
		ranger.api.keys.keymanager = keymanager
		from ranger.defaults import commands, keys, apps
		comcont.load_commands_from_module(commands)
		commands = comcont
	fm.commands = commands
	fm.keys = keys
	fm.apps = apps.CustomApplications()


def load_apps(fm, clean):
	import ranger
	if not clean:
		allow_access_to_confdir(ranger.arg.confdir, True)
		try:
			import apps
		except ImportError:
			from ranger.defaults import apps
		allow_access_to_confdir(ranger.arg.confdir, False)
	else:
		from ranger.defaults import apps
	fm.apps = apps.CustomApplications()


def main():
	"""initialize objects and run the filemanager"""
	try:
		import curses
	except ImportError as errormessage:
		print(errormessage)
		print('ranger requires the python curses module. Aborting.')
		sys.exit(1)
	import locale
	import ranger
	from ranger.ext import curses_interrupt_handler
	from ranger.core.runner import Runner
	from ranger.core.fm import FM
	from ranger.core.environment import Environment
	from ranger.gui.defaultui import DefaultUI as UI
	from ranger.fsobject import File
	from ranger.shared import (EnvironmentAware, FileManagerAware,
			SettingsAware)

	try: locale.setlocale(locale.LC_ALL, '')
	except: print("Warning: Unable to set locale.  Expect encoding problems.")

	if not 'SHELL' in os.environ:
		os.environ['SHELL'] = 'bash'

	arg = parse_arguments()
	ranger.arg = arg

	if not ranger.arg.debug:
		curses_interrupt_handler.install_interrupt_handler()

	SettingsAware._setup()

	if arg.targets:
		target = arg.targets[0]
		if target.startswith('file://'):
			target = target[7:]
		if not os.access(target, os.F_OK):
			print("File or directory doesn't exist: %s" % target)
			sys.exit(1)
		elif os.path.isfile(target):
			def print_function(string):
				print(string)
			runner = Runner(logfunc=print_function)
			load_apps(runner, ranger.arg.clean)
			runner(files=[File(target)], mode=arg.mode, flags=arg.flags)
			sys.exit(1 if arg.fail_if_run else 0)
		else:
			path = target
	else:
		path = '.'

	crash_exception = None
	try:
		# Initialize objects
		EnvironmentAware._assign(Environment(path))
		fm = FM()
		load_settings(fm, ranger.arg.clean)
		FileManagerAware._assign(fm)
		fm.ui = UI()

		# Run the file manager
		fm.initialize()
		fm.ui.initialize()
		fm.loop()
	except Exception as e:
		crash_exception = e
		if not (arg.debug or arg.clean):
			import traceback
			dumpname = ranger.relpath_conf('traceback')
			traceback.print_exc(file=open(dumpname, 'w'))
	finally:
		# Finish, clean up
		try:
			fm.ui.destroy()
		except (AttributeError, NameError):
			pass
		if crash_exception:
			print("Fatal: " + str(crash_exception))
			if arg.debug or arg.clean:
				raise crash_exception
			else:
				print("A traceback has been saved to " + dumpname)
				print("Please include it in a bugreport.")


if __name__ == '__main__':
	# The ranger directory can be executed directly, for example by typing
	# python /usr/lib/python2.6/site-packages/ranger
	sys.path.insert(0, os.path.dirname(sys.path[0]))
	main()