# Path: checkmate/management/commands/base.py
# class BaseCommand(object):
# 
#     class CommandException(BaseException):
#         pass
# 
#     requires_valid_project = True
# 
#     options = [
#         {
#         'name'        : '--help',
#         'action'      : 'store_true',
#         'dest'        : 'help',
#         'default'     : False,
#         'help'        : 'display this help message.'
#         },
#         {
#         'name'        : '--non-interactive',
#         'action'      : 'store_true',
#         'dest'        : 'non_interactive',
#         'default'     : False,
#         'help'        : 'non-interactive mode.'
#         },
#         {
#         'name'        : '--format',
#         'action'      : 'store',
#         'dest'        : 'format',
#         'default'     : 'python',
#         'help'        : 'the output format for the return value of the command.'
#         },
#         ]
# 
#     description = None
# 
#     def __init__(self, project, settings, backend=None, prog=None, args=None):
#         self.project = project
#         self.settings = settings
#         self.backend = backend
#         self.prog = prog
#         self.parse_args(args if args else [])
# 
#     def _get_parser(self):
#         parser = argparse.ArgumentParser(self.prog,add_help = False,description = self.description)
#         for opt in self.options:
#             c_opt = copy.deepcopy(opt)
#             name = c_opt['name']
#             del c_opt['name']
#             parser.add_argument(name,**c_opt)
#         return parser
# 
#     def parse_args(self,raw_args):
#         parser = self._get_parser()
#         args,self.extra_args = parser.parse_known_args(raw_args)
#         self.raw_args = raw_args
#         self.opts = vars(args)
# 
#     def help_message(self):
#         parser = self._get_parser()
#         return parser.format_help()
# 
# Path: checkmate/lib/models.py
# class Issue(BaseDocument):
# 
#     """
#     An `Issue` object represents an issue or problem with the code.
#     It can be associated with one or multiple file revisions, code objects etc.
# 
#     An issue fingerprint should be a unique identifier for a given issue, hence if
#     two issues have the same fingerprint they should be judged "identical".
#     """
# 
#     class IgnoreReason:
#         not_specified = 0
#         not_relevant = 1
#         false_positive = 2
# 
#     #calculated as hash(analyzer,code,fingerprint)
#     hash = CharField(indexed = True,length = 64)
#     configuration = CharField(indexed = True, length = 64)
#     project = ForeignKeyField('Project',backref = 'issues',nullable = False)
#     analyzer = CharField(indexed = True,length = 100,nullable = False)
#     code = CharField(indexed = True,length = 100,nullable = False)
#     fingerprint = CharField(indexed = True,length = 255,nullable = False)
# 
#     #determines if this issue should be ignored
#     ignore = BooleanField(indexed=True, default=False, nullable=False, server_default=False)
#     #gives a reason for the issue to be ignored (e.g. false_positive, )
#     ignore_reason = IntegerField(indexed=True, nullable=True)
#     #an optional comment for the ignore reason
#     ignore_comment = CharField(indexed=False, length=255, nullable=True)
# 
#     class Meta(Document.Meta):
#         unique_together = [('project','fingerprint','analyzer','code')]
#         dbref_includes = ['code','analyzer']
# 
# class DiskSnapshot(BaseDocument):
# 
#     snapshot = ForeignKeyField('Snapshot',backref = 'disk_snapshot',unique = True)


import logging
from checkmate.management.commands.base import BaseCommand
from checkmate.lib.models import Issue,DiskSnapshot
# -*- coding: utf-8 -*-

from __future__ import unicode_literals


logger = logging.getLogger(__name__)


class Command(BaseCommand):

    """
    Returns a list of issues for the current snapshot or file revision.
    """

    def run(self):
        snapshot_pk = None
        filenames = None
        if self.extra_args:
            if len(self.extra_args) == 1:
                snapshot_pk = self.extra_args[0]
            else:
                snapshot_pk,filenames = self.extra_args[0],self.extra_args[1:]

        if snapshot_pk:
            try:

# Path: checkmate/management/commands/base.py
# class BaseCommand(object):
# 
#     class CommandException(BaseException):
#         pass
# 
#     requires_valid_project = True
# 
#     options = [
#         {
#         'name'        : '--help',
#         'action'      : 'store_true',
#         'dest'        : 'help',
#         'default'     : False,
#         'help'        : 'display this help message.'
#         },
#         {
#         'name'        : '--non-interactive',
#         'action'      : 'store_true',
#         'dest'        : 'non_interactive',
#         'default'     : False,
#         'help'        : 'non-interactive mode.'
#         },
#         {
#         'name'        : '--format',
#         'action'      : 'store',
#         'dest'        : 'format',
#         'default'     : 'python',
#         'help'        : 'the output format for the return value of the command.'
#         },
#         ]
# 
#     description = None
# 
#     def __init__(self, project, settings, backend=None, prog=None, args=None):
#         self.project = project
#         self.settings = settings
#         self.backend = backend
#         self.prog = prog
#         self.parse_args(args if args else [])
# 
#     def _get_parser(self):
#         parser = argparse.ArgumentParser(self.prog,add_help = False,description = self.description)
#         for opt in self.options:
#             c_opt = copy.deepcopy(opt)
#             name = c_opt['name']
#             del c_opt['name']
#             parser.add_argument(name,**c_opt)
#         return parser
# 
#     def parse_args(self,raw_args):
#         parser = self._get_parser()
#         args,self.extra_args = parser.parse_known_args(raw_args)
#         self.raw_args = raw_args
#         self.opts = vars(args)
# 
#     def help_message(self):
#         parser = self._get_parser()
#         return parser.format_help()
# 
# Path: checkmate/lib/models.py
# class Issue(BaseDocument):
# 
#     """
#     An `Issue` object represents an issue or problem with the code.
#     It can be associated with one or multiple file revisions, code objects etc.
# 
#     An issue fingerprint should be a unique identifier for a given issue, hence if
#     two issues have the same fingerprint they should be judged "identical".
#     """
# 
#     class IgnoreReason:
#         not_specified = 0
#         not_relevant = 1
#         false_positive = 2
# 
#     #calculated as hash(analyzer,code,fingerprint)
#     hash = CharField(indexed = True,length = 64)
#     configuration = CharField(indexed = True, length = 64)
#     project = ForeignKeyField('Project',backref = 'issues',nullable = False)
#     analyzer = CharField(indexed = True,length = 100,nullable = False)
#     code = CharField(indexed = True,length = 100,nullable = False)
#     fingerprint = CharField(indexed = True,length = 255,nullable = False)
# 
#     #determines if this issue should be ignored
#     ignore = BooleanField(indexed=True, default=False, nullable=False, server_default=False)
#     #gives a reason for the issue to be ignored (e.g. false_positive, )
#     ignore_reason = IntegerField(indexed=True, nullable=True)
#     #an optional comment for the ignore reason
#     ignore_comment = CharField(indexed=False, length=255, nullable=True)
# 
#     class Meta(Document.Meta):
#         unique_together = [('project','fingerprint','analyzer','code')]
#         dbref_includes = ['code','analyzer']
# 
# class DiskSnapshot(BaseDocument):
# 
#     snapshot = ForeignKeyField('Snapshot',backref = 'disk_snapshot',unique = True)


# Path: checkmate/management/commands/issues.py
import logging
from checkmate.management.commands.base import BaseCommand
from checkmate.lib.models import Issue,DiskSnapshot

# -*- coding: utf-8 -*-

from __future__ import unicode_literals


logger = logging.getLogger(__name__)


class Command(BaseCommand):

    """
    Returns a list of issues for the current snapshot or file revision.
    """

    def run(self):
        snapshot_pk = None
        filenames = None
        if self.extra_args:
            if len(self.extra_args) == 1:
                snapshot_pk = self.extra_args[0]
            else:
                snapshot_pk,filenames = self.extra_args[0],self.extra_args[1:]

        if snapshot_pk:
            try:

                snapshot = self.backend.get(DiskSnapshot,