about summary refs log tree commit diff stats
path: root/000organization.cc
Commit message (Expand)AuthorAgeFilesLines
* 4252Kartik Agaram2018-06-061-2/+2
* 4061Kartik K. Agaram2017-10-131-4/+4
* 4010Kartik K. Agaram2017-10-041-16/+16
* 3966Kartik K. Agaram2017-07-091-1/+1
* 3965 - get rid of the teardown() functionKartik K. Agaram2017-07-091-6/+2
* 3557Kartik K. Agaram2016-10-221-4/+4
* 3414Kartik K. Agaram2016-09-241-1/+1
* 3297 - run unit tests before scenariosKartik K. Agaram2016-09-051-0/+3
* 3273Kartik K. Agaram2016-08-281-7/+9
* 3272Kartik K. Agaram2016-08-281-0/+3
* 3270Kartik K. Agaram2016-08-281-0/+5
* 3027Kartik K. Agaram2016-06-021-1/+1
* 2935Kartik K. Agaram2016-05-071-2/+2
* 2609 - run $browse-trace on old runsKartik K. Agaram2015-11-291-0/+1
* 1342Kartik K. Agaram2015-05-111-8/+8
* 1330Kartik K. Agaram2015-05-101-0/+5
* 1294Kartik K. Agaram2015-05-061-5/+5
* 1276 - make C++ version the defaultKartik K. Agaram2015-05-051-0/+121
iltin */ .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 */
# 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/>.

import types
from inspect import isclass, ismodule
import ranger
from ranger.ext.openstruct import OpenStruct
from ranger.gui.colorscheme import ColorScheme

ALLOWED_SETTINGS = {
	'show_hidden': bool,
	'show_cursor': bool,
	'autosave_bookmarks': bool,
	'collapse_preview': bool,
	'sort': str,
	'reverse': bool,
	'directories_first': bool,
	'update_title': bool,
	'max_filesize_for_preview': (int, type(None)),
	'max_history_size': (int, type(None)),
	'scroll_offset': int,
	'preview_files': bool,
	'flushinput': bool,
	'colorscheme': (ColorScheme, types.ModuleType),
	'hidden_filter': lambda x: isinstance(x, str) or hasattr(x, 'match'),
}

# -- globalize the settings --
class SettingsAware(object):
	settings = OpenStruct()

	@staticmethod
	def _setup():
		settings = OpenStruct()

		from ranger.defaults import options
		for setting in ALLOWED_SETTINGS:
			try:
				settings[setting] = getattr(options, setting)
			except AttributeError:
				raise Exception("The option `{0}' was not defined" \
						" in the defaults!".format(setting))

		import sys
		if not ranger.arg.clean:
			# overwrite single default options with custom options
			try:
				import options as my_options
			except ImportError:
				pass
			else:
				for setting in ALLOWED_SETTINGS:
					try:
						settings[setting] = getattr(my_options, setting)
					except AttributeError:
						pass

		assert check_option_types(settings)

		# If a module is specified as the colorscheme, replace it with one
		# valid colorscheme inside that module.

		all_content = settings.colorscheme.__dict__.items()

		if isclass(settings.colorscheme) and \
				issubclass(settings.colorscheme, ColorScheme):
			settings.colorscheme = settings.colorscheme()

		elif ismodule(settings.colorscheme):
			def is_scheme(x):
				return isclass(x) and issubclass(x, ColorScheme)

			if hasattr(settings.colorscheme, 'Scheme') \
					and is_scheme(settings.colorscheme.Scheme):
				settings.colorscheme = settings.colorscheme.Scheme()
			else:
				for name, var in settings.colorscheme.__dict__.items():
					if var != ColorScheme and is_scheme(var):
						settings.colorscheme = var()
						break
				else:
					raise Exception("The module contains no " \
							"valid colorscheme!")
		else:
			raise Exception("Cannot locate colorscheme!")

		try:
			import apps
		except ImportError:
			from ranger.defaults import apps
		settings.apps = apps
		try:
			import keys
		except ImportError:
			from ranger.defaults import keys
		settings.keys = keys

		SettingsAware.settings = settings

def check_option_types(opt):
	import inspect
	for name, typ in ALLOWED_SETTINGS.items():
		optvalue = getattr(opt, name)
		if inspect.isfunction(typ):
			assert typ(optvalue), \
				"The option `" + name + "' has an incorrect type!"
		else:
			assert isinstance(optvalue, typ), \
				"The option `" + name + "' has an incorrect type!"\
				" Got " + str(type(optvalue)) + ", expected " + str(typ) + "!"
	return True