summary refs log tree commit diff stats
path: root/doc/pydoc/test.html
blob: 69b6f644867f8df1c9b8415fa9f96d226b417995 (plain) (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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head><title>Python: package test</title>
</head><body bgcolor="#f0f0f8">

<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
<tr bgcolor="#7799ee">
<td valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial">&nbsp;<br><big><big><strong>test</strong></big></big></font></td
><td align=right valign=bottom
><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="file:/home/hut/ranger/test/__init__.py">/home/hut/ranger/test/__init__.py</a></font></td></tr></table>
    <p><tt>#&nbsp;Copyright&nbsp;(C)&nbsp;2009,&nbsp;2010&nbsp;&nbsp;Roman&nbsp;Zimbelmann&nbsp;&lt;romanz@lavabit.com&gt;<br>
#<br>
#&nbsp;This&nbsp;program&nbsp;is&nbsp;free&nbsp;software:&nbsp;you&nbsp;can&nbsp;redistribute&nbsp;it&nbsp;and/or&nbsp;modify<br>
#&nbsp;it&nbsp;under&nbsp;the&nbsp;terms&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;as&nbsp;published&nbsp;by<br>
#&nbsp;the&nbsp;Free&nbsp;Software&nbsp;Foundation,&nbsp;either&nbsp;version&nbsp;3&nbsp;of&nbsp;the&nbsp;License,&nbsp;or<br>
#&nbsp;(at&nbsp;your&nbsp;option)&nbsp;any&nbsp;later&nbsp;version.<br>
#<br>
#&nbsp;This&nbsp;program&nbsp;is&nbsp;distributed&nbsp;in&nbsp;the&nbsp;hope&nbsp;that&nbsp;it&nbsp;will&nbsp;be&nbsp;useful,<br>
#&nbsp;but&nbsp;WITHOUT&nbsp;ANY&nbsp;WARRANTY;&nbsp;without&nbsp;even&nbsp;the&nbsp;implied&nbsp;warranty&nbsp;of<br>
#&nbsp;MERCHANTABILITY&nbsp;or&nbsp;FITNESS&nbsp;FOR&nbsp;A&nbsp;PARTICULAR&nbsp;PURPOSE.&nbsp;&nbsp;See&nbsp;the<br>
#&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License&nbsp;for&nbsp;more&nbsp;details.<br>
#<br>
#&nbsp;You&nbsp;should&nbsp;have&nbsp;received&nbsp;a&nbsp;copy&nbsp;of&nbsp;the&nbsp;GNU&nbsp;General&nbsp;Public&nbsp;License<br>
#&nbsp;along&nbsp;with&nbsp;this&nbsp;program.&nbsp;&nbsp;If&nbsp;not,&nbsp;see&nbsp;&lt;<a href="http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>&gt;.</tt></p>
<p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#aa55cc">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
    
<tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="test.tc_bookmarks.html">tc_bookmarks</a><br>
<a href="test.tc_colorscheme.html">tc_colorscheme</a><br>
<a href="test.tc_commandlist.html">tc_commandlist</a><br>
</td><td width="25%" valign=top><a href="test.tc_directory.html">tc_directory</a><br>
<a href="test.tc_displayable.html">tc_displayable</a><br>
<a href="test.tc_ext.html">tc_ext</a><br>
</td><td width="25%" valign=top><a href="test.tc_history.html">tc_history</a><br>
<a href="test.tc_keyapi.html">tc_keyapi</a><br>
<a href="test.tc_signal.html">tc_signal</a><br>
</td><td width="25%" valign=top><a href="test.tc_ui.html">tc_ui</a><br>
<a href="test.test.html">test</a><br>
</td></tr></table></td></tr></table><p>
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
<tr bgcolor="#55aa55">
<td colspan=3 valign=bottom>&nbsp;<br>
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    
<tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</td>
<td width="100%"><strong>__all__</strong> = ['tc_keyapi', 'tc_history', 'tc_colorscheme', 'tc_bookmarks', 'tc_ext', 'tc_directory', 'tc_commandlist', 'tc_colorscheme', 'tc_keyapi', 'tc_history', 'tc_commandlist', 'tc_signal', 'tc_displayable', 'tc_signal', 'tc_directory', 'tc_ui', 'tc_ui', 'tc_bookmarks', 'tc_ext', 'tc_displayable']</td></tr></table>
</body></html>
39;date'] = datetime.fromtimestamp(line['date']) log.append(line) return log def _git_status_translate(self, code): """Translate git status code""" for X, Y, status in self._status_translations: if code[0] in X and code[1] in Y: return status return 'unknown' # Repo creation #--------------------------- def init(self): """Initializes a repo in current path""" self._git(['init']) self.update() def clone(self, src): """Clones a repo from src""" try: os.rmdir(self.path) except OSError: raise VcsError("Can't clone to {0:s}: Not an empty directory".format(self.path)) self._git(['clone', src, os.path.basename(self.path)], path=os.path.dirname(self.path)) self.update() # Action interface #--------------------------- def commit(self, message): """Commits with a given message""" self._git(['commit', '--message', message]) def add(self, filelist=None): """Adds files to the index, preparing for commit""" if filelist: self._git(['add', '--all'] + filelist) else: self._git(['add', '--all']) def reset(self, filelist=None): """Removes files from the index""" if filelist: self._git(['reset'] + filelist) else: self._git(['reset']) def pull(self, *args): """Pulls from remote""" self._git(['pull'] + list(args)) def push(self, *args): """Pushes to remote""" self._git(['push'] + list(args)) def checkout(self, rev): """Checks out a branch or revision""" self._git(['checkout', self._sanitize_rev(rev)]) def extract_file(self, rev, name, dest): """Extracts a file from a given revision and stores it in dest dir""" if rev == self.INDEX: shutil.copyfile(os.path.join(self.path, name), dest) else: with open(dest, 'wb') as fd: fd.write( self._git([ '--no-pager', 'show', '{0:s}:{1:s}'.format(self._sanitize_rev(rev), name) ], catchout=True, bytes=True) ) # Data Interface #--------------------------- def get_status_root_cheap(self): """Returns the status of root, very cheap""" statuses = set() # Paths with status skip = False for line in self._git(['status', '--porcelain', '-z'], catchout=True, bytes=True).decode('utf-8').split('\x00')[:-1]: if skip: skip = False continue statuses.add(self._git_status_translate(line[:2])) if line.startswith('R'): skip = True for status in self.DIR_STATUS: if status in statuses: return status return 'sync' def get_status_subpaths(self): """Returns a dict (path: status) for paths not in sync. Strips trailing '/' from dirs""" statuses = {} # Ignored directories for line in self._git( ['ls-files', '-z', '--others', '--directory', '--ignored', '--exclude-standard'], catchout=True, bytes=True ).decode('utf-8').split('\x00')[:-1]: if line.endswith('/'): statuses[os.path.normpath(line)] = 'ignored' # Empty directories for line in self._git( ['ls-files', '-z', '--others', '--directory', '--exclude-standard'], catchout=True, bytes=True ).decode('utf-8').split('\x00')[:-1]: if line.endswith('/'): statuses[os.path.normpath(line)] = 'none' # Paths with status skip = False for line in self._git(['status', '--porcelain', '-z', '--ignored'], catchout=True, bytes=True).decode('utf-8').split('\x00')[:-1]: if skip: skip = False continue statuses[os.path.normpath(line[3:])] = self._git_status_translate(line[:2]) if line.startswith('R'): skip = True return statuses def get_status_remote(self): """Checks the status of the repo regarding sync state with remote branch""" try: head = self._head_ref() remote = self._remote_ref(head) except VcsError: head = remote = None if not head or not remote: return 'none' output = self._git(['rev-list', '--left-right', '{0:s}...{1:s}'.format(remote, head)], catchout=True) ahead = re.search("^>", output, flags=re.MULTILINE) behind = re.search("^<", output, flags=re.MULTILINE) if ahead: return 'diverged' if behind else 'ahead' else: return 'behind' if behind else 'sync' def get_branch(self): """Returns the current named branch, if this makes sense for the backend. None otherwise""" try: head = self._head_ref() except VcsError: head = None if head is None: return 'detached' match = re.match('refs/heads/([^/]+)', head) if match: return match.group(1) else: return None def get_log(self, filelist=None, maxres=None): """Get the entire log for the current HEAD""" if not self._has_head(): return [] return self._log(refspec=None, maxres=maxres, filelist=filelist) def get_raw_log(self, filelist=None): """Gets the raw log as a string""" if not self._has_head(): return [] args = ['log'] if filelist: args += ['--'] + filelist return self._git(args, catchout=True) def get_raw_diff(self, refspec=None, filelist=None): """Gets the raw diff as a string""" args = ['diff'] if refspec: args += [refspec] if filelist: args += ['--'] + filelist return self._git(args, catchout=True) def get_remote(self): """Returns the url for the remote repo attached to head""" try: ref = self._head_ref() remote = self._remote_ref(ref) except VcsError: ref = remote = None if not remote: return None match = re.match('refs/remotes/([^/]+)/', remote) if match: return self._git(['config', '--get', 'remote.{0:s}.url'.format(match.group(1))], catchout=True).strip() \ or None return None def get_revision_id(self, rev=None): """Get a canonical key for the revision rev""" if rev is None: rev = self.HEAD elif rev == self.INDEX: return None rev = self._sanitize_rev(rev) return self._sanitize_rev(self._git(['rev-parse', rev], catchout=True)) def get_info(self, rev=None): """Gets info about the given revision rev""" if rev is None: rev = self.HEAD rev = self._sanitize_rev(rev) if rev == self.HEAD and not self._has_head(): return None log = self._log(refspec=rev) if len(log) == 0: raise VcsError("Revision {0:s} does not exist".format(rev)) elif len(log) > 1: raise VcsError("More than one instance of revision {0:s} ?!?".format(rev)) else: return log[0] def get_files(self, rev=None): """Gets a list of files in revision rev""" if rev is None: rev = self.HEAD rev = self._sanitize_rev(rev) if rev is None: return [] if rev == self.INDEX: return self._git(['ls-files', '-z'], catchout=True, bytes=True).decode('utf-8').split('\x00') else: return self._git(['ls-tree', '--name-only', '-r', '-z', rev], catchout=True, bytes=True).decode('utf-8').split('\x00')