def handle(self, *args, **options):
        if not options.get('avec-vinaigrette'):
            return super(Command, self).handle(*args, **options)

        verbosity = int(options['verbosity'])
        vinfilepath = 'vinaigrette-deleteme.py'
        sources = ['', '']

        # Because Django makemessages isn't very extensible, we're writing a
        # fake Python file, calling makemessages, then deleting it after.
        vinfile = codecs.open(vinfilepath, 'w', encoding='utf8')
        try:
            vinfile.write('#coding:utf-8\n')
            if verbosity > 0:
                self.stdout.write('Vinaigrette is processing database values...')
            
            for model in sorted(vinaigrette._registry.keys(), key=lambda m: m._meta.object_name):
                strings_seen = set()
                modelname = "%s.%s" % (model._meta.app_label, model._meta.object_name)
                reg = vinaigrette._registry[model]
                fields = reg['fields'] # strings to be translated
                properties = reg['properties']
                # make query_fields a set to avoid duplicates
                # only these fields will be retrieved from the db instead of all model's field
                query_fields = set(fields)

                # if there are properties, we update the needed query fields and
                # update the string that will be translated
                if properties:
                   fields += properties.keys()
                   for prop in properties.itervalues():
                       query_fields.update(prop)

                manager = reg['manager'] if reg['manager'] else model._default_manager
                qs = manager.filter(reg['restrict_to']) if reg['restrict_to'] else manager.all()

                for instance in qs.order_by('pk').only('pk', *query_fields):
                    try:
                        idnum = int(instance.pk)
                    except (ValueError, TypeError):
                        idnum = 0
                    # iterate over fields to translate
                    for field in fields:
                        # In the reference comment in the po file, use the object's primary
                        # key as the line number, but only if it's an integer primary key
                        val = getattr(instance, field)
                        if val and val not in strings_seen:
                            strings_seen.add(val)
                            sources.append('%s/%s:%s' % (modelname, field, idnum))
                            vinfile.write(
                                'gettext(%r)\n'
                                % val.replace('\r', '').replace('%', '%%')
                            )

        finally:
            vinfile.close()

        try:
            super(Command, self).handle(*args, **options)
        finally:
            if not options.get('keep-vinaigrette-temp'):
                os.unlink(vinfilepath)

        r_lineref = re.compile(r'%s:(\d+)' % re.escape(vinfilepath))
        def lineref_replace(match):
            try:
                return sources[int(match.group(1))]
            except (IndexError, ValueError):
                return match.group(0)

        # The PO file has been generated. Now, swap out the line-number
        # references to our fake python file for more descriptive
        # references.
        if options.get('all'):
            po_paths = _get_po_paths()
        else:
            locales = options.get('locale')

            # In django 1.6+ one or more locales can be specified, so we
            # make sure to handle both versions here.

            # Also, there is no simple way to differentiate a string from a
            # sequence of strings that works in both python2 (for str and
            # unicode) and python3 so we query for a string method on locales.
            if hasattr(locales, 'capitalize'):
                locales = [locales]

            po_paths = _get_po_paths(locales)

        if options.get('keep-obsolete'):
            obsolete_warning = ['#. %s\n' %
                ugettext('Obsolete translation kept alive with Viniagrette').encode('utf8'),
                '#: obsolete:0\n']

        for po_path in po_paths:
            po_file = open(po_path)
            new_contents = []
            lastline = ''
            for line in po_file:
                if line.startswith('#: '):
                    new_contents.append(r_lineref.sub(lineref_replace, line))
                else:
                    if (line.startswith('#, python-format')
                      and lastline.startswith('#: ')
                      and lastline in vinfilepath):
                        # A database string got labelled as being python-format;
                        # it shouldn't be. Skip the line.
                        continue
                    if options.get('keep-obsolete'):
                        if line in obsolete_warning:
                            # Don't preserve old obsolete warnings we inserted
                            continue
                        if line.startswith('#~ msgid '):
                            new_contents.extend(obsolete_warning)
                        if line.startswith('#~ '):
                            line = re.sub(r'^#~ ', '', line)

                    new_contents.append(line)
                lastline = line
            po_file.close()

            # Perhaps this should be done a little more atomically w/ renames?
            po_file = open(po_path, 'w')
            for line in new_contents:
                po_file.write(line)
            po_file.close()
dataset/ETHPy150Open ecometrica/django-vinaigrette/vinaigrette/management/commands/makemessages.py/Command.handle/swapped operands of `in`