<commit_before>from hyperadmin.indexes import Index


class ModelIndex(Index):
    @property
    def model(self):
        return self.resource.model
    
    def get_primary_field(self):
        return self.model._meta.pk
    
    def get_url_params(self, param_map={}):
        """
        returns url parts for use in the url regexp for conducting item lookups
        """
        #TODO support non integer lookups
        param_map.setdefault('pk', 'pk')
        field = self.get_primary_field()
        from django.db import models
        if isinstance(field, (models.IntegerField, models.AutoField)):
            #TODO detect if positive integers only
            return [r'(?P<{pk}>(-){0,1}\d+)'.format(**param_map)]
        return [r'(?P<{pk}>[\w\d\-]+)'.format(**param_map)]
    
    def get_paginator_kwargs(self):
        return {'per_page':self.resource.list_per_page,}
    
    def get_links(self):
        links = super(ModelIndex, self).get_links()
        #links += self.getchangelist_sort_links()
        return links
    <commit_msg>fix formating, regex and python format confusion<commit_after>from hyperadmin.indexes import Index


class ModelIndex(Index):
    @property
    def model(self):
        return self.resource.model
    
    def get_primary_field(self):
        return self.model._meta.pk
    
    def get_url_params(self, param_map={}):
        """
        returns url parts for use in the url regexp for conducting item lookups
        """
        #TODO support non integer lookups
        param_map.setdefault('pk', 'pk')
        field = self.get_primary_field()
        from django.db import models
        if isinstance(field, (models.IntegerField, models.AutoField)):
            #TODO detect if positive integers only
            return [r'(?P<{pk}>(-){{0,1}}\d+)'.format(**param_map)]
        return [r'(?P<{pk}>[\w\d\-]+)'.format(**param_map)]
    
    def get_paginator_kwargs(self):
        return {'per_page':self.resource.list_per_page,}
    
    def get_links(self):
        links = super(ModelIndex, self).get_links()
        #links += self.getchangelist_sort_links()
        return links
    
{'fraction_non_alphanumeric': 0.12295465170640486, 'fraction_numerical': 0.0018700327255726976, 'mean_word_length': 2.6087689713322093, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4317508', 'n_tokens_mistral': 650, 'n_tokens_neox': 635, 'n_words': 148}