diff options
Diffstat (limited to 'git/cmd.py')
-rw-r--r-- | git/cmd.py | 27 |
1 files changed, 13 insertions, 14 deletions
@@ -17,6 +17,7 @@ from subprocess import ( import subprocess import sys import threading +from collections import OrderedDict from textwrap import dedent from git.compat import ( @@ -31,7 +32,6 @@ from git.compat import ( is_win, ) from git.exc import CommandError -from git.odict import OrderedDict from git.util import is_cygwin_git, cygpath, expand_path from .exc import ( @@ -44,10 +44,10 @@ from .util import ( ) -execute_kwargs = set(('istream', 'with_extended_output', - 'with_exceptions', 'as_process', 'stdout_as_string', - 'output_stream', 'with_stdout', 'kill_after_timeout', - 'universal_newlines', 'shell', 'env')) +execute_kwargs = {'istream', 'with_extended_output', 'with_exceptions', + 'as_process', 'stdout_as_string', 'output_stream', + 'with_stdout', 'kill_after_timeout', 'universal_newlines', + 'shell', 'env'} log = logging.getLogger(__name__) log.addHandler(logging.NullHandler()) @@ -125,7 +125,7 @@ def dashify(string): def slots_to_dict(self, exclude=()): - return dict((s, getattr(self, s)) for s in self.__slots__ if s not in exclude) + return {s: getattr(self, s) for s in self.__slots__ if s not in exclude} def dict_to_slots_and__excluded_are_none(self, d, excluded=()): @@ -143,8 +143,7 @@ CREATE_NO_WINDOW = 0x08000000 ## CREATE_NEW_PROCESS_GROUP is needed to allow killing it afterwards, # see https://docs.python.org/3/library/subprocess.html#subprocess.Popen.send_signal PROC_CREATIONFLAGS = (CREATE_NO_WINDOW | subprocess.CREATE_NEW_PROCESS_GROUP - if is_win and sys.version_info >= (2, 7) - else 0) + if is_win else 0) class Git(LazyMixin): @@ -486,10 +485,10 @@ class Git(LazyMixin): def readlines(self, size=-1): if self._nbr == self._size: - return list() + return [] # leave all additional logic to our readline method, we just check the size - out = list() + out = [] nbr = 0 while True: line = self.readline() @@ -895,7 +894,7 @@ class Git(LazyMixin): def transform_kwargs(self, split_single_char_options=True, **kwargs): """Transforms Python style kwargs into git command line options.""" - args = list() + args = [] kwargs = OrderedDict(sorted(kwargs.items(), key=lambda x: x[0])) for k, v in kwargs.items(): if isinstance(v, (list, tuple)): @@ -914,7 +913,7 @@ class Git(LazyMixin): return [arg_list.encode(defenc)] return [str(arg_list)] - outlist = list() + outlist = [] for arg in arg_list: if isinstance(arg_list, (list, tuple)): outlist.extend(cls.__unpack_args(arg)) @@ -973,8 +972,8 @@ class Git(LazyMixin): :return: Same as ``execute``""" # Handle optional arguments prior to calling transform_kwargs # otherwise these'll end up in args, which is bad. - exec_kwargs = dict((k, v) for k, v in kwargs.items() if k in execute_kwargs) - opts_kwargs = dict((k, v) for k, v in kwargs.items() if k not in execute_kwargs) + exec_kwargs = {k: v for k, v in kwargs.items() if k in execute_kwargs} + opts_kwargs = {k: v for k, v in kwargs.items() if k not in execute_kwargs} insert_after_this_arg = opts_kwargs.pop('insert_kwargs_after', None) |