from csat.acquisition import base


__version__ = '0.1.0'


class GitPythonCollector(base.FactoryBase):

    name = 'Git + Python dependencies analyzer'
    key = 'pygit'
    version = __version__

    def build_parser(self, base):
        parser = super(GitPythonCollector, self).build_parser(base)
        parser.add_argument('repo_path')
        return parser

    def build_collector(self, task_manager, logger, args):
        from .collector import GitPythonCollector
        return GitPythonCollector(task_manager, logger, args.repo_path)


git_python_collector = GitPythonCollector()


if __name__ == '__main__':
    from csat.acquisition.runner import get_runner
    get_runner(git_python_collector).run()

try:
    import git
except ImportError:
    import warnings
    with warnings.catch_warnings():
        warnings.simplefilter('always')
        warnings.warn('No git module found, the pygit collector will not be '
                      'available', ImportWarning)
    git = None

from csat.acquisition import base


__version__ = '0.1.0'


class GitPythonCollector(base.FactoryBase):

    name = 'Git + Python dependencies analyzer'
    key = 'pygit'
    version = __version__

    def build_parser(self, base):
        parser = super(GitPythonCollector, self).build_parser(base)
        parser.add_argument('repo_path')
        return parser

    def build_collector(self, task_manager, logger, args):
        from .collector import GitPythonCollector

        repo = git.Repo(args.repo_path)
        return GitPythonCollector(task_manager, logger, repo)


if git is not None:
    git_python_collector = GitPythonCollector()

    if __name__ == '__main__':
        from csat.acquisition.runner import get_runner
        get_runner(git_python_collector).run()

Disable collector and only produce a warning if the git module is not installed
Disable collector and only produce a warning if the git module is not installed

+ try:
+     import git
+ except ImportError:
+     import warnings
+     with warnings.catch_warnings():
+         warnings.simplefilter('always')
+         warnings.warn('No git module found, the pygit collector will not be '
+                       'available', ImportWarning)
+     git = None
+ 
  from csat.acquisition import base
  
  
  __version__ = '0.1.0'
  
  
  class GitPythonCollector(base.FactoryBase):
  
      name = 'Git + Python dependencies analyzer'
      key = 'pygit'
      version = __version__
  
      def build_parser(self, base):
          parser = super(GitPythonCollector, self).build_parser(base)
          parser.add_argument('repo_path')
          return parser
  
      def build_collector(self, task_manager, logger, args):
          from .collector import GitPythonCollector
+ 
+         repo = git.Repo(args.repo_path)
-         return GitPythonCollector(task_manager, logger, args.repo_path)
+         return GitPythonCollector(task_manager, logger, repo)
  
  
+ if git is not None:
- git_python_collector = GitPythonCollector()
+     git_python_collector = GitPythonCollector()
  
+     if __name__ == '__main__':
+         from csat.acquisition.runner import get_runner
+         get_runner(git_python_collector).run()
  
- if __name__ == '__main__':
-     from csat.acquisition.runner import get_runner
-     get_runner(git_python_collector).run()
- 
Disable collector and only produce a warning if the git module is not installed
## Code Before:
from csat.acquisition import base


__version__ = '0.1.0'


class GitPythonCollector(base.FactoryBase):

    name = 'Git + Python dependencies analyzer'
    key = 'pygit'
    version = __version__

    def build_parser(self, base):
        parser = super(GitPythonCollector, self).build_parser(base)
        parser.add_argument('repo_path')
        return parser

    def build_collector(self, task_manager, logger, args):
        from .collector import GitPythonCollector
        return GitPythonCollector(task_manager, logger, args.repo_path)


git_python_collector = GitPythonCollector()


if __name__ == '__main__':
    from csat.acquisition.runner import get_runner
    get_runner(git_python_collector).run()

## Instruction:
Disable collector and only produce a warning if the git module is not installed
## Code After:
try:
    import git
except ImportError:
    import warnings
    with warnings.catch_warnings():
        warnings.simplefilter('always')
        warnings.warn('No git module found, the pygit collector will not be '
                      'available', ImportWarning)
    git = None

from csat.acquisition import base


__version__ = '0.1.0'


class GitPythonCollector(base.FactoryBase):

    name = 'Git + Python dependencies analyzer'
    key = 'pygit'
    version = __version__

    def build_parser(self, base):
        parser = super(GitPythonCollector, self).build_parser(base)
        parser.add_argument('repo_path')
        return parser

    def build_collector(self, task_manager, logger, args):
        from .collector import GitPythonCollector

        repo = git.Repo(args.repo_path)
        return GitPythonCollector(task_manager, logger, repo)


if git is not None:
    git_python_collector = GitPythonCollector()

    if __name__ == '__main__':
        from csat.acquisition.runner import get_runner
        get_runner(git_python_collector).run()
