Standardize imports

Refactor imports to follow pep8 guidelines of standard library, related
third party and local library order for imports.

Change-Id: Ied624c088c110c56f6e471a1441db0f8d6adae3c
This commit is contained in:
Darragh Bailey
2014-10-14 16:50:02 +01:00
parent a7facb708a
commit 98bc0715b4
7 changed files with 33 additions and 30 deletions

View File

@@ -15,9 +15,10 @@
# limitations under the License.
#
from git_upstream.errors import GitUpstreamError
from git import base, GitCommandError
from git_upstream.errors import GitUpstreamError
class NoteAlreadyExistsError(GitUpstreamError):
"""Exception thrown by note related commands"""

View File

@@ -16,7 +16,12 @@
#
import git
from git import Commit, Repo
try:
from git.objects.commit import Commit
from git.repo import Repo
except ImportError:
from git import Commit, Repo
class GitUpstreamCompatRepo(Repo):

View File

@@ -15,13 +15,13 @@
# limitations under the License.
#
import codecs
import subprocess
import os
from git_upstream.lib.utils import GitMixin
from git_upstream.log import LogDedentMixin
from subprocess import call
import os
import codecs
REBASE_EDITOR_SCRIPT = "rebase-editor"
# ensure name of file will match any naming filters used by editors to
@@ -152,7 +152,8 @@ class RebaseEditor(GitMixin, LogDedentMixin):
if self._interactive:
# spawn the editor
user_editor = self.git_sequence_editor or self.git_editor
status = call("%s %s" % (user_editor, todo_file), shell=True)
status = subprocess.call("%s %s" % (user_editor, todo_file),
shell=True)
if status:
return status, None, "Editor returned non-zero exit code"
@@ -171,7 +172,7 @@ class RebaseEditor(GitMixin, LogDedentMixin):
cmd = ['git', 'rebase', '--interactive']
cmd.extend(self.git.transform_kwargs(**kwargs))
cmd.extend(args)
return call(cmd), None, None
return subprocess.call(cmd), None, None
else:
return self.git.rebase(interactive=True, with_exceptions=False,
with_extended_output=True, *args,

View File

@@ -15,17 +15,13 @@
# limitations under the License.
#
from git_upstream.lib.utils import GitMixin
from git_upstream.log import LogDedentMixin
try:
from git.objects.commit import Commit
except ImportError:
from git_upstream.lib.pygitcompat import GitUpstreamCompatCommit as Commit
from abc import ABCMeta, abstractmethod
import re
from git_upstream.lib.utils import GitMixin
from git_upstream.lib.pygitcompat import Commit
from git_upstream.log import LogDedentMixin
class Searcher(GitMixin):
"""

View File

@@ -15,12 +15,12 @@
# limitations under the License.
#
from git_upstream.errors import GitUpstreamError
from git_upstream.lib.pygitcompat import Repo
import os
import sys
from git_upstream.errors import GitUpstreamError
from git_upstream.lib.pygitcompat import Repo
try:
from git.exc import InvalidGitRepositoryError
except ImportError:

View File

@@ -20,27 +20,27 @@
Command-line tool for tracking upstream revisions
"""
import logging
import sys
import argparse
import git
import git_upstream.commands as commands
from git_upstream.errors import GitUpstreamError
import git_upstream.log as log
from git_upstream import commands
from git_upstream import log
from git_upstream import subcommand
from git_upstream import __version__
from git_upstream.errors import GitUpstreamError
import subcommand
import argparse
from argparse import ArgumentParser
try:
import argcomplete
argparse_loaded = True
except ImportError:
argparse_loaded = False
import logging
import sys
def get_parser():
parser = ArgumentParser(
parser = argparse.ArgumentParser(
description=__doc__.strip(),
epilog='See "%(prog)s help COMMAND" for help on a specific command.',
add_help=False)

View File

@@ -28,7 +28,7 @@ Avoid use of stdin for passing such information as many editors have problems
if exec'ed and stdin is a pipe.
"""
from argparse import ArgumentParser
import argparse
import fileinput
import os
import sys
@@ -59,7 +59,7 @@ def rebase_replace_insn(path, istream):
def main():
parser = ArgumentParser(
parser = argparse.ArgumentParser(
description=__doc__.strip(),
)
parser.add_argument('-v', '--verbose', action='store_true', default=False,