# Path: ranger/ext/spawn.py
# def spawn(*popenargs, **kwargs):
#     """Runs a program, waits for its termination and returns its stdout
# 
#     This function is similar to python 2.7's subprocess.check_output,
#     but is favored due to python 2.6 compatibility.
# 
#     The arguments may be:
# 
#         spawn(string)
#         spawn(command, arg1, arg2...)
#         spawn([command, arg1, arg2])
# 
#     Will be run through a shell if `popenargs` is a string, otherwise the command
#     is executed directly.
# 
#     The keyword argument `decode` determines if the output shall be decoded
#     with the encoding UTF-8.
# 
#     Further keyword arguments are passed to Popen.
#     """
#     if len(popenargs) == 1:
#         return check_output(popenargs[0], **kwargs)
#     return check_output(list(popenargs), **kwargs)
# 
# Path: ranger/ext/vcs/svn.py
# class SVN(Vcs):
#     """VCS implementation for Subversion"""
#     # Generic
#     _status_translations = (
#         ('ADR', 'staged'),
#         ('C', 'conflict'),
#         ('I', 'ignored'),
#         ('M~', 'changed'),
#         ('X', 'none'),
#         ('?', 'untracked'),
#         ('!', 'deleted'),
#     )
# 
#     def _log(self, refspec=None, maxres=None, filelist=None):
#         """Retrieves log message and parses it"""
#         args = ['log', '--xml']
# 
#         if refspec:
#             args += ['--limit', '1', '--revision', refspec]
#         elif maxres:
#             args += ['--limit', str(maxres)]
# 
#         if filelist:
#             args += ['--'] + filelist
# 
#         try:
#             output = self._run(args)
#         except VcsError:
#             return None
#         if not output:
#             return None
# 
#         log = []
#         for entry in etree.fromstring(output).findall('./logentry'):
#             new = {}
#             new['short'] = entry.get('revision')
#             new['revid'] = entry.get('revision')
#             new['author'] = entry.find('./author').text
#             new['date'] = datetime.strptime(
#                 entry.find('./date').text,
#                 '%Y-%m-%dT%H:%M:%S.%fZ',
#             )
#             new['summary'] = entry.find('./msg').text.split('\n')[0]
#             log.append(new)
#         return log
# 
#     def _status_translate(self, code):
#         """Translate status code"""
#         for code_x, status in self._status_translations:
#             if code in code_x:
#                 return status
#         return 'unknown'
# 
#     def _remote_url(self):
#         """Remote url"""
#         try:
#             output = self._run(['info', '--xml'])
#         except VcsError:
#             return None
#         if not output:
#             return None
#         return etree.fromstring(output).find('./entry/url').text or None
# 
#     # Action Interface
# 
#     def action_add(self, filelist=None):
#         args = ['add']
#         if filelist:
#             args += ['--'] + filelist
#         self._run(args, catchout=False)
# 
#     def action_reset(self, filelist=None):
#         args = ['revert', '--']
#         if filelist:
#             args += filelist
#         else:
#             args += self.rootvcs.status_subpaths.keys()  # pylint: disable=no-member
#         self._run(args, catchout=False)
# 
#     # Data Interface
# 
#     def data_status_root(self):
#         statuses = set()
# 
#         # Paths with status
#         lines = self._run(['status']).split('\n')
#         lines = list(filter(None, lines))
#         if not lines:
#             return 'sync'
#         for line in lines:
#             code = line[0]
#             if code == ' ':
#                 continue
#             statuses.add(self._status_translate(code))
# 
#         for status in self.DIRSTATUSES:
#             if status in statuses:
#                 return status
#         return 'sync'
# 
#     def data_status_subpaths(self):
#         statuses = {}
# 
#         # Paths with status
#         lines = self._run(['status']).split('\n')
#         lines = list(filter(None, lines))
#         for line in lines:
#             code, path = line[0], line[8:]
#             if code == ' ':
#                 continue
#             statuses[os.path.normpath(path)] = self._status_translate(code)
# 
#         return statuses
# 
#     def data_status_remote(self):
#         remote = self._remote_url()
#         if remote is None or remote.startswith('file://'):
#             return 'none'
#         return 'unknown'
# 
#     def data_branch(self):
#         return None
# 
#     def data_info(self, rev=None):
#         if rev is None:
#             rev = self.HEAD
# 
#         log = self._log(refspec=rev)
#         if not log:
#             if rev == self.HEAD:
#                 return None
#             else:
#                 raise VcsError('Revision {0:s} does not exist'.format(rev))
#         elif len(log) == 1:
#             return log[0]
#         else:
#             raise VcsError('More than one instance of revision {0:s}'.format(rev))


import os
import subprocess
import threading
import time
    import queue
    import Queue as queue  # pylint: disable=import-error
from io import open
from ranger.ext import spawn
from .bzr import Bzr  # NOQA pylint: disable=wrong-import-position
from .git import Git  # NOQA pylint: disable=wrong-import-position
from .hg import Hg  # NOQA pylint: disable=wrong-import-position
from .svn import SVN  # NOQA pylint: disable=wrong-import-position

    def pause(self):
        """Pause thread"""
        self._advance.clear()

    def unpause(self):
        """Unpause thread"""
        self._advance.set()

    def process(self, dirobj):
        """Process dirobj"""
        self._queue.put(dirobj)
        self._awoken.set()


# Backend imports


class BzrRoot(VcsRoot, Bzr):
    """Bzr root"""


class GitRoot(VcsRoot, Git):
    """Git root"""


class HgRoot(VcsRoot, Hg):
    """Hg root"""



# Path: ranger/ext/spawn.py
# def spawn(*popenargs, **kwargs):
#     """Runs a program, waits for its termination and returns its stdout
# 
#     This function is similar to python 2.7's subprocess.check_output,
#     but is favored due to python 2.6 compatibility.
# 
#     The arguments may be:
# 
#         spawn(string)
#         spawn(command, arg1, arg2...)
#         spawn([command, arg1, arg2])
# 
#     Will be run through a shell if `popenargs` is a string, otherwise the command
#     is executed directly.
# 
#     The keyword argument `decode` determines if the output shall be decoded
#     with the encoding UTF-8.
# 
#     Further keyword arguments are passed to Popen.
#     """
#     if len(popenargs) == 1:
#         return check_output(popenargs[0], **kwargs)
#     return check_output(list(popenargs), **kwargs)
# 
# Path: ranger/ext/vcs/svn.py
# class SVN(Vcs):
#     """VCS implementation for Subversion"""
#     # Generic
#     _status_translations = (
#         ('ADR', 'staged'),
#         ('C', 'conflict'),
#         ('I', 'ignored'),
#         ('M~', 'changed'),
#         ('X', 'none'),
#         ('?', 'untracked'),
#         ('!', 'deleted'),
#     )
# 
#     def _log(self, refspec=None, maxres=None, filelist=None):
#         """Retrieves log message and parses it"""
#         args = ['log', '--xml']
# 
#         if refspec:
#             args += ['--limit', '1', '--revision', refspec]
#         elif maxres:
#             args += ['--limit', str(maxres)]
# 
#         if filelist:
#             args += ['--'] + filelist
# 
#         try:
#             output = self._run(args)
#         except VcsError:
#             return None
#         if not output:
#             return None
# 
#         log = []
#         for entry in etree.fromstring(output).findall('./logentry'):
#             new = {}
#             new['short'] = entry.get('revision')
#             new['revid'] = entry.get('revision')
#             new['author'] = entry.find('./author').text
#             new['date'] = datetime.strptime(
#                 entry.find('./date').text,
#                 '%Y-%m-%dT%H:%M:%S.%fZ',
#             )
#             new['summary'] = entry.find('./msg').text.split('\n')[0]
#             log.append(new)
#         return log
# 
#     def _status_translate(self, code):
#         """Translate status code"""
#         for code_x, status in self._status_translations:
#             if code in code_x:
#                 return status
#         return 'unknown'
# 
#     def _remote_url(self):
#         """Remote url"""
#         try:
#             output = self._run(['info', '--xml'])
#         except VcsError:
#             return None
#         if not output:
#             return None
#         return etree.fromstring(output).find('./entry/url').text or None
# 
#     # Action Interface
# 
#     def action_add(self, filelist=None):
#         args = ['add']
#         if filelist:
#             args += ['--'] + filelist
#         self._run(args, catchout=False)
# 
#     def action_reset(self, filelist=None):
#         args = ['revert', '--']
#         if filelist:
#             args += filelist
#         else:
#             args += self.rootvcs.status_subpaths.keys()  # pylint: disable=no-member
#         self._run(args, catchout=False)
# 
#     # Data Interface
# 
#     def data_status_root(self):
#         statuses = set()
# 
#         # Paths with status
#         lines = self._run(['status']).split('\n')
#         lines = list(filter(None, lines))
#         if not lines:
#             return 'sync'
#         for line in lines:
#             code = line[0]
#             if code == ' ':
#                 continue
#             statuses.add(self._status_translate(code))
# 
#         for status in self.DIRSTATUSES:
#             if status in statuses:
#                 return status
#         return 'sync'
# 
#     def data_status_subpaths(self):
#         statuses = {}
# 
#         # Paths with status
#         lines = self._run(['status']).split('\n')
#         lines = list(filter(None, lines))
#         for line in lines:
#             code, path = line[0], line[8:]
#             if code == ' ':
#                 continue
#             statuses[os.path.normpath(path)] = self._status_translate(code)
# 
#         return statuses
# 
#     def data_status_remote(self):
#         remote = self._remote_url()
#         if remote is None or remote.startswith('file://'):
#             return 'none'
#         return 'unknown'
# 
#     def data_branch(self):
#         return None
# 
#     def data_info(self, rev=None):
#         if rev is None:
#             rev = self.HEAD
# 
#         log = self._log(refspec=rev)
#         if not log:
#             if rev == self.HEAD:
#                 return None
#             else:
#                 raise VcsError('Revision {0:s} does not exist'.format(rev))
#         elif len(log) == 1:
#             return log[0]
#         else:
#             raise VcsError('More than one instance of revision {0:s}'.format(rev))


# Path: ranger/ext/vcs/vcs.py
import os
import subprocess
import threading
import time
    import queue
    import Queue as queue  # pylint: disable=import-error
from io import open
from ranger.ext import spawn
from .bzr import Bzr  # NOQA pylint: disable=wrong-import-position
from .git import Git  # NOQA pylint: disable=wrong-import-position
from .hg import Hg  # NOQA pylint: disable=wrong-import-position
from .svn import SVN  # NOQA pylint: disable=wrong-import-position


    def pause(self):
        """Pause thread"""
        self._advance.clear()

    def unpause(self):
        """Unpause thread"""
        self._advance.set()

    def process(self, dirobj):
        """Process dirobj"""
        self._queue.put(dirobj)
        self._awoken.set()


# Backend imports


class BzrRoot(VcsRoot, Bzr):
    """Bzr root"""


class GitRoot(VcsRoot, Git):
    """Git root"""


class HgRoot(VcsRoot, Hg):
    """Hg root"""



class SVNRoot(VcsRoot, SVN):