summary refs log tree commit diff stats
path: root/doc
Commit message (Expand)AuthorAgeFilesLines
* updated pydochut2010-06-0918-57/+113
* Changed hashbang line to "#!/usr/bin/env python"hut2010-06-092-2/+2
* updated pydochut2010-05-1647-666/+349
* Fixed bug #65 by adding flag "--fail-if-run"hut2010-04-261-1/+5
* updated pydochut2010-04-205-248/+10
* updated pydochut2010-04-1941-2286/+247
* ranger.1: added S key to man pagehut2010-04-161-0/+3
* Fixed suggested cd-after-exit-script for zshhut2010-04-131-1/+1
* added doc/print_keys.pyhut2010-04-081-0/+14
* corrected documentationhut2010-04-061-1/+1
* Improved tabshut2010-04-061-0/+3
* updated keybindings and documentationhut2010-04-061-1/+21
* ranger.1: updatehut2010-04-011-4/+7
* ranger.1: updatedhut2010-04-011-1/+1
* added a man pagehut2010-04-011-0/+187
* rebuilt pydochut2010-03-3118-65/+188
* removed doc/pick.sh, pointless to have it therehut2010-03-311-25/+0
* removed UML stuff, it's uselesshut2010-03-3115-2337/+0
* removed the cd-after-exit hackhut2010-03-291-161/+0
* updated TODO and pydochut2010-03-2120-52/+85
* doc/colorschemes: ugh, its no logical but bitwise OR!hut2010-03-171-1/+1
* incremented verison number v1.0.4hut2010-03-121-2/+2
* standardized formatting of headings in doc/hut2010-03-122-13/+31
* added doc/uml.txthut2010-03-121-0/+5
* updated pydochut2010-03-1217-161/+33
* updated pydochut2010-03-1270-3946/+816
* added two new colorschemes using 88 colorshut2010-03-121-0/+23
* added documentation on how colorschemes workhut2010-03-121-0/+91
* added symlink: doc/help => ranger/helphut2010-02-281-0/+1
* incremented version number and updated pydoc html files v1.0.3hut2010-02-1675-1972/+1415
* doc/cd-after-exit: updatedhut2010-02-141-21/+15
* doc/pick.sh: corrected commit orderhut2010-02-091-1/+1
* doc: what breaks cd-after-exit support in zshhut2010-02-091-0/+2
* pick.sh: added -m to checkout commadshut2010-02-051-3/+3
* pick.sh: added variables for easier customizationhut2010-02-041-7/+8
* added doc/pick.shhut2010-02-041-0/+24
* updated dochut2010-01-211-4/+20
* 1.0.2! v1.0.2hut2010-01-1430-84/+116
* updated pydoc documentationhut2010-01-1361-846/+795
* todo: added more info on bug #31hut2010-01-091-0/+5
* random cleanups and fixeshut2010-01-071-5/+6
* new minor version v1.0.1hut2010-01-022-4/+4
* updated pydoc documentationhut2010-01-0248-788/+3167
* notify: merged into statusbar, allow to view the log in the pagerhut2010-01-013-35/+2
* cleanupshut2009-12-311-1/+5
* rename filelist(container) to browsercolumn/browserviewhut2009-12-313-38/+76
* updated uml projecthut2009-12-305-73/+215
* shorten comment in ranger.pyhut2009-12-261-0/+4
* moved /uml to /doc/umlhut2009-12-2514-0/+2180
* Explained cd-after-exit featurehut2009-12-251-0/+132
= None basename_lower = None _shell_escaped_basename = None _filetype = None dirname = None extension = None exists = False accessible = False marked = False tagged = False loaded = False runnable = False islink = False readlink = None stat = None infostring = None permissions = None type = T_UNKNOWN size = 0 last_used = None stopped = False video = False image = False audio = False media = False document = False container = False mimetype_tuple = () def __init__(self, path): MimeTypeAware.__init__(self) if type(self) == FileSystemObject: raise TypeError("Cannot initialize abstract class FileSystemObject") from os.path import abspath, basename, dirname, realpath path = abspath(path) self.path = path self.basename = basename(path) self.basename_lower = self.basename.lower() self.dirname = dirname(path) self.realpath = realpath(path) try: self.extension = self.basename[self.basename.rindex('.') + 1:].lower() except ValueError: self.extension = None self.set_mimetype() self.use() def __repr__(self): return "<{0} {1}>".format(self.__class__.__name__, self.path) @property def shell_escaped_basename(self): if self._shell_escaped_basename is None: self._shell_escaped_basename = shell_escape(self.basename) return self._shell_escaped_basename @property def filetype(self): if self._filetype is None: import subprocess try: got = subprocess.Popen(["file", '-Lb', '--mime-type',\ self.path], stdout=subprocess.PIPE).communicate()[0] except OSError: self._filetype = '' else: self._filetype = got return self._filetype def get_description(self): return "Loading " + str(self) def __str__(self): """returns a string containing the absolute path""" return str(self.path) def use(self): """mark the filesystem-object as used at the current time""" self.last_used = time.time() def is_older_than(self, seconds): """returns whether this object wasn't use()d in the last n seconds""" if seconds < 0: return True return self.last_used + seconds < time.time() def set_mimetype(self): """assign attributes such as self.video according to the mimetype""" self.mimetype = self.mimetypes.guess_type(self.basename, False)[0] if self.mimetype is None: self.mimetype = '' self.video = self.mimetype.startswith('video') self.image = self.mimetype.startswith('image') self.audio = self.mimetype.startswith('audio') self.media = self.video or self.image or self.audio self.document = self.mimetype.startswith('text') \ or (self.extension in DOCUMENT_EXTENSIONS) \ or (self.basename in DOCUMENT_BASENAMES) self.container = self.extension in CONTAINER_EXTENSIONS keys = ('video', 'audio', 'image', 'media', 'document', 'container') self.mimetype_tuple = tuple(key for key in keys if getattr(self, key)) if self.mimetype == '': self.mimetype = None def mark(self, boolean): directory = self.env.get_directory(self.dirname) directory.mark_item(self) def _mark(self, boolean): """Called by directory.mark_item() and similar functions""" self.marked = bool(boolean) def load(self): """ reads useful information about the filesystem-object from the filesystem and caches it for later use """ import os import stat from ranger.ext.human_readable import human_readable self.loaded = True try: self.stat = os.lstat(self.path) except OSError: self.stat = None self.islink = False self.accessible = False else: self.islink = stat.S_ISLNK(self.stat.st_mode) self.accessible = True if self.accessible and os.access(self.path, os.F_OK): self.exists = True self.accessible = True if os.path.isdir(self.path): self.type = T_DIRECTORY try: self.size = len(os.listdir(self.path)) self.infostring = ' %d' % self.size self.runnable = True except OSError: self.infostring = BAD_INFO self.runnable = False self.accessible = False elif os.path.isfile(self.path): self.type = T_FILE self.size = self.stat.st_size self.infostring = ' ' + human_readable(self.stat.st_size) else: self.type = T_UNKNOWN self.infostring = None else: if self.islink: self.infostring = '->' else: self.infostring = None self.type = T_NONEXISTANT self.exists = False self.runnable = False if self.islink: self.readlink = os.readlink(self.path) def get_permission_string(self): if self.permissions is not None: return self.permissions if self.accessible is False: return '----------' import stat mode = self.stat.st_mode if stat.S_ISDIR(mode): perms = ['d'] elif stat.S_ISLNK(mode): perms = ['l'] else: perms = ['-'] for who in ("USR", "GRP", "OTH"): for what in "RWX": if mode & getattr(stat, "S_I" + what + who): perms.append(what.lower()) else: perms.append('-') self.permissions = ''.join(perms) return self.permissions def load_once(self): """calls load() if it has not been called at least once yet""" if not self.loaded: self.load() return True return False def go(self): """enter the directory if the filemanager is running""" if self.fm: return self.fm.enter_dir(self.path) return False def load_if_outdated(self): """ Calls load() if the currently cached information is outdated or nonexistant. """ if self.load_once(): return True import os try: real_mtime = os.lstat(self.path).st_mtime except OSError: real_mtime = None if self.stat: cached_mtime = self.stat.st_mtime else: cached_mtime = 0 if real_mtime != cached_mtime: self.load() return True return False