Skip to content

Commit

Permalink
Add two blank lines where is expected
Browse files Browse the repository at this point in the history
  • Loading branch information
stepshal committed Jun 16, 2016
1 parent 7c760ac commit ab41c77
Show file tree
Hide file tree
Showing 75 changed files with 145 additions and 0 deletions.
1 change: 1 addition & 0 deletions doc/tools/convert_papermode_to_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

FIELDS = ["name", "year", "title", "authors", "url"]


def replace(source, target):
if not os.path.exists(source):
print("Source file `%s' doesn't exist, skipping." % source)
Expand Down
1 change: 1 addition & 0 deletions doc/tools/print_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import curses
from curses import *


@wrapper
def main(win):
def print_all_colors(attr):
Expand Down
1 change: 1 addition & 0 deletions doc/tools/print_keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

sep = '; '


@wrapper
def main(w):
mousemask(ALL_MOUSE_EVENTS)
Expand Down
1 change: 1 addition & 0 deletions examples/plugin_chmod_keybindings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ranger.api
old_hook_init = ranger.api.hook_init


def hook_init(fm):
old_hook_init(fm)

Expand Down
2 changes: 2 additions & 0 deletions examples/plugin_file_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
HIDE_FILES = ("/boot", "/sbin", "/proc", "/sys")

# Define a new one


def custom_accept_file(file, filters):
if not file.fm.settings.show_hidden and file.path in HIDE_FILES:
return False
Expand Down
2 changes: 2 additions & 0 deletions examples/plugin_hello_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
old_hook_ready = ranger.api.hook_ready

# Create a replacement for the hook that...


def hook_ready(fm):
# ...does the desired action...
fm.notify("Hello World")
Expand Down
2 changes: 2 additions & 0 deletions examples/plugin_ipc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import ranger.api

old_hook_init = ranger.api.hook_init


def hook_init(fm):
try:
# Create a FIFO.
Expand Down
1 change: 1 addition & 0 deletions examples/plugin_linemode.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import ranger.api
from ranger.core.linemode import LinemodeBase


@ranger.api.register_linemode
class MyLinemode(LinemodeBase):
name = "rot13"
Expand Down
2 changes: 2 additions & 0 deletions examples/plugin_new_macro.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

# Define a new macro function
import time


def get_macros_with_date(self):
macros = old_get_macros(self)
macros['date'] = time.strftime('%m/%d/%Y')
Expand Down
2 changes: 2 additions & 0 deletions examples/plugin_pmount.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
LIST_MOUNTS_KEY = '<alt>N'

old_hook_init = ranger.api.hook_init


def hook_init(fm):
try:
fm.execute_console("map {key} shell -p lsblk".format(key=LIST_MOUNTS_KEY))
Expand Down
2 changes: 2 additions & 0 deletions ranger/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
# Debugging functions. These will be activated when run with --debug.
# Example usage in the code:
# import ranger; ranger.log("hello world")


def log(*objects, **keywords):
"""Writes objects to a logfile (for the purpose of debugging only.)
Has the same arguments as print() in python3.
Expand Down
3 changes: 3 additions & 0 deletions ranger/api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

# Hooks for use in plugins:


def hook_init(fm):
"""A hook that is called when ranger starts up.
Expand All @@ -18,6 +19,7 @@ def hook_init(fm):
keybindings and such.
"""


def hook_ready(fm):
"""A hook that is called after the ranger UI is initialized.
Expand All @@ -32,6 +34,7 @@ def hook_ready(fm):

from ranger.core.linemode import LinemodeBase


def register_linemode(linemode_class):
"""Add a custom linemode class. See ranger.core.linemode"""
from ranger.container.fsobject import FileSystemObject
Expand Down
2 changes: 2 additions & 0 deletions ranger/api/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

_SETTINGS_RE = re.compile(r'^\s*([^\s]+?)=(.*)$')


class CommandContainer(object):
def __init__(self):
self.commands = {}
Expand Down Expand Up @@ -426,6 +427,7 @@ def execute(self):
(self._object_name, self._function_name,
repr(args), repr(keywords)), bad=True)


class AliasCommand(Command):
_based_function = None
_object_name = ""
Expand Down
1 change: 1 addition & 0 deletions ranger/colorschemes/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ranger.gui.colorscheme import ColorScheme
from ranger.gui.color import *


class Default(ColorScheme):
progress_bar_color = blue

Expand Down
1 change: 1 addition & 0 deletions ranger/colorschemes/jungle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ranger.gui.color import *
from ranger.colorschemes.default import Default


class Scheme(Default):
progress_bar_color = green
def use(self, context):
Expand Down
1 change: 1 addition & 0 deletions ranger/colorschemes/snow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ranger.gui.colorscheme import ColorScheme
from ranger.gui.color import *


class Snow(ColorScheme):
def use(self, context):
fg, bg, attr = default_colors
Expand Down
1 change: 1 addition & 0 deletions ranger/colorschemes/solarized.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from ranger.gui.colorscheme import ColorScheme
from ranger.gui.color import *


class Solarized(ColorScheme):
progress_bar_color = 33

Expand Down
9 changes: 9 additions & 0 deletions ranger/config/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@

from ranger.api.commands import *


class alias(Command):
""":alias <newcommand> <oldcommand>
Expand Down Expand Up @@ -237,6 +238,7 @@ def tab(self, tabnum):
for file in self.fm.thisdir.files or [] \
if file.shell_escaped_basename.startswith(start_of_word))


class open_with(Command):
def execute(self):
app, flags, mode = self._get_app_flags_mode(self.rest(1))
Expand Down Expand Up @@ -789,6 +791,7 @@ def execute(self):
def tab(self, tabnum):
return self._tab_directory_content()


class rename_append(Command):
""":rename_append
Expand All @@ -803,6 +806,7 @@ def execute(self):
else:
self.fm.open_console('rename ' + path)


class chmod(Command):
""":chmod <octal number>
Expand Down Expand Up @@ -920,6 +924,7 @@ def execute(self):
else:
fm.notify("files have not been retagged")


class relink(Command):
""":relink <newpath>
Expand Down Expand Up @@ -1325,6 +1330,7 @@ def execute(self):
action.extend(f.path for f in self.fm.thistab.get_selection())
self.fm.execute_command(action, flags='p')


class flat(Command):
"""
:flat <level>
Expand All @@ -1350,6 +1356,7 @@ def execute(self):
# Version control commands
# --------------------------------


class stage(Command):
"""
:stage
Expand All @@ -1369,6 +1376,7 @@ def execute(self):
else:
self.fm.notify('Unable to stage files: Not in repository')


class unstage(Command):
"""
:unstage
Expand All @@ -1391,6 +1399,7 @@ def execute(self):
# Metadata commands
# --------------------------------


class prompt_metadata(Command):
"""
:prompt_metadata <key1> [<key2> [<key3> ...]]
Expand Down
2 changes: 2 additions & 0 deletions ranger/config/commands_sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

# Any class that is a subclass of "Command" will be integrated into ranger as a
# command. Try typing ":my_edit<ENTER>" in ranger!


class my_edit(Command):
# The so-called doc-string of the class will be visible in the built-in
# help that is accessible by typing "?c" inside ranger.
Expand Down
1 change: 1 addition & 0 deletions ranger/container/bookmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import os
ALLOWED_KEYS = string.ascii_letters + string.digits + "`'"


class Bookmarks(object):
"""Bookmarks is a container which associates keys with bookmarks.
Expand Down
10 changes: 10 additions & 0 deletions ranger/container/directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,36 @@
from ranger.container.settings import LocalSettings
from ranger.ext.vcs import Vcs


def sort_by_basename(path):
"""returns path.relative_path (for sorting)"""
return path.relative_path


def sort_by_basename_icase(path):
"""returns case-insensitive path.relative_path (for sorting)"""
return path.relative_path_lower


def sort_by_directory(path):
"""returns 0 if path is a directory, otherwise 1 (for sorting)"""
return 1 - path.is_directory


def sort_naturally(path):
return path.basename_natural


def sort_naturally_icase(path):
return path.basename_natural_lower


def sort_unicode_wrapper_string(old_sort_func):
def sort_unicode(path):
return locale.strxfrm(old_sort_func(path))
return sort_unicode


def sort_unicode_wrapper_list(old_sort_func):
def sort_unicode(path):
return [locale.strxfrm(str(c)) for c in old_sort_func(path)]
Expand All @@ -63,6 +70,7 @@ def accept_file(file, filters):
return False
return True


def walklevel(some_dir, level):
some_dir = some_dir.rstrip(os.path.sep)
followlinks = True if level > 0 else False
Expand All @@ -74,6 +82,7 @@ def walklevel(some_dir, level):
if level != -1 and num_sep + level <= num_sep_this:
del dirs[:]


def mtimelevel(path, level):
mtime = os.stat(path).st_mtime
for dirpath, dirnames, filenames in walklevel(path, level):
Expand All @@ -82,6 +91,7 @@ def mtimelevel(path, level):
mtime = max(mtime, max([-1] + [os.stat(d).st_mtime for d in dirlist]))
return mtime


class Directory(FileSystemObject, Accumulator, Loadable):
is_directory = True
enterable = False
Expand Down
1 change: 1 addition & 0 deletions ranger/container/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
$
""", re.VERBOSE | re.IGNORECASE)


class File(FileSystemObject):
is_file = True
preview_data = None
Expand Down
2 changes: 2 additions & 0 deletions ranger/container/fsobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@
_extract_number_re = re.compile(r'(\d+|\D)')
_integers = set("0123456789")


def safe_path(path):
return path.translate(_safe_string_table)


class FileSystemObject(FileManagerAware, SettingsAware):
(basename,
relative_path,
Expand Down
2 changes: 2 additions & 0 deletions ranger/container/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

# TODO: rewrite to use deque instead of list


class HistoryEmptyException(Exception):
pass


class History(object):
def __init__(self, maxlen=None, unique=True):
assert maxlen is not None, "maxlen cannot be None"
Expand Down
1 change: 1 addition & 0 deletions ranger/container/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
tuple: tuple([]),
}


class Settings(SignalDispatcher, FileManagerAware):
def __init__(self):
SignalDispatcher.__init__(self)
Expand Down
1 change: 1 addition & 0 deletions ranger/container/tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

ALLOWED_KEYS = string.ascii_letters + string.digits + string.punctuation


class Tags(object):
default_tag = '*'

Expand Down
2 changes: 2 additions & 0 deletions ranger/core/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@

MACRO_FAIL = "<\x01\x01MACRO_HAS_NO_VALUE\x01\01>"


class _MacroTemplate(string.Template):
"""A template for substituting macros in commands"""
delimiter = ranger.MACRO_DELIMITER
idpattern = r"[_a-z0-9]*"


class Actions(FileManagerAware, SettingsAware):
# --------------------------
# -- Basic Commands
Expand Down
1 change: 1 addition & 0 deletions ranger/core/fm.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from ranger import __version__
from ranger.core.loader import Loader


class FM(Actions, SignalDispatcher):
input_blocked = False
input_blocked_until = 0
Expand Down
Loading

0 comments on commit ab41c77

Please sign in to comment.