<commit_before>from django.contrib.auth.models import User
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.utils.translation import ugettext_lazy as _

from reviewboard.scmtools.managers import RepositoryManager, ToolManager
from reviewboard.site.models import LocalSite


class Tool(models.Model):
    name = models.CharField(max_length=32, unique=True)
    class_name = models.CharField(max_length=128, unique=True)

    objects = ToolManager()

    supports_authentication = property(
        lambda x: x.get_scmtool_class().supports_authentication)
    supports_raw_file_urls = property(
        lambda x: x.get_scmtool_class().supports_raw_file_urls)

    def __unicode__(self):
        return self.name

    def get_scmtool_class(self):
        path = self.class_name
        i = path.rfind('.')
        module, attr = path[:i], path[i+1:]

        try:
            mod = __import__(module, {}, {}, [attr])
        except ImportError, e:
            raise ImproperlyConfigured, \
                'Error importing SCM Tool %s: "%s"' % (module, e)

        try:
            return getattr(mod, attr)
        except AttributeError:
            raise ImproperlyConfigured, \
                'Module "%s" does not define a "%s" SCM Tool' % (module, attr)

    class Meta:
        ordering = ("name",)


class Repository(models.Model):
    name = models.CharField(max_length=64)
    path = models.CharField(
        max_length=255,
        help_text=_("This should be the path to the repository. For most "
                    "version control systems, this will be a URI of some "
                    "form or another. For CVS, this should be a pserver "
                    "path. For Perforce, this should be a port name. For "
                    "git, this should be the path to the .git repository "
                    "on the local disk. For Plastic, this should be a "
                    "repository spec in the form [repo]@[hostname]:[port]."
                    "In case of ClearCase enter absolute path to VOB."))
    mirror_path = models.CharField(max_length=255, blank=True)
    raw_file_url = models.CharField(
        _('Raw file URL mask'),
        max_length=255,
        blank=True,
        help_text=_("A URL mask used to check out a particular revision of a "
                    "file using HTTP. This is needed for repository types "
                    "that can't access remote files natively. "
                    "Use <tt>&lt;revision&gt;</tt> and "
                    "<tt>&lt;filename&gt;</tt> in the URL in place of the "
                    "revision and filename parts of the path."))
    username = models.CharField(max_length=32, blank=True)
    password = models.CharField(max_length=128, blank=True)
    tool = models.ForeignKey(Tool, related_name="repositories")
    bug_tracker = models.CharField(
        _('Bug tracker URL'),
        max_length=256,
        blank=True,
        help_text=_("This should be the full path to a bug in the bug tracker "
                    "for this repository, using '%s' in place of the bug ID."))
    encoding = models.CharField(<commit_msg>Fix documentation for git path.<commit_after>from django.contrib.auth.models import User
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.utils.translation import ugettext_lazy as _

from reviewboard.scmtools.managers import RepositoryManager, ToolManager
from reviewboard.site.models import LocalSite


class Tool(models.Model):
    name = models.CharField(max_length=32, unique=True)
    class_name = models.CharField(max_length=128, unique=True)

    objects = ToolManager()

    supports_authentication = property(
        lambda x: x.get_scmtool_class().supports_authentication)
    supports_raw_file_urls = property(
        lambda x: x.get_scmtool_class().supports_raw_file_urls)

    def __unicode__(self):
        return self.name

    def get_scmtool_class(self):
        path = self.class_name
        i = path.rfind('.')
        module, attr = path[:i], path[i+1:]

        try:
            mod = __import__(module, {}, {}, [attr])
        except ImportError, e:
            raise ImproperlyConfigured, \
                'Error importing SCM Tool %s: "%s"' % (module, e)

        try:
            return getattr(mod, attr)
        except AttributeError:
            raise ImproperlyConfigured, \
                'Module "%s" does not define a "%s" SCM Tool' % (module, attr)

    class Meta:
        ordering = ("name",)


class Repository(models.Model):
    name = models.CharField(max_length=64)
    path = models.CharField(
        max_length=255,
        help_text=_("This should be the path to the repository. For most "
                    "version control systems, this will be a URI of some "
                    "form or another. For CVS, this should be a pserver "
                    "path. For Perforce, this should be a port name. For "
                    "local git, this should be the path to the .git directory "
                    "on the local disk. For remote git, this should be the "
                    "git URL that users clone. For Plastic, this should be a "
                    "repository spec in the form [repo]@[hostname]:[port]."
                    "In case of ClearCase enter absolute path to VOB."))
    mirror_path = models.CharField(max_length=255, blank=True)
    raw_file_url = models.CharField(
        _('Raw file URL mask'),
        max_length=255,
        blank=True,
        help_text=_("A URL mask used to check out a particular revision of a "
                    "file using HTTP. This is needed for repository types "
                    "that can't access remote files natively. "
                    "Use <tt>&lt;revision&gt;</tt> and "
                    "<tt>&lt;filename&gt;</tt> in the URL in place of the "
                    "revision and filename parts of the path."))
    username = models.CharField(max_length=32, blank=True)
    password = models.CharField(max_length=128, blank=True)
    tool = models.ForeignKey(Tool, related_name="repositories")
    bug_tracker = models.CharField(
        _('Bug tracker URL'),
        max_length=256,
        blank=True,
        help_text=_("This should be the full path to a bug in the bug tracker "
                    "for this repository, using '%s' in place of the bug ID."))
    encoding = models.CharField(
{'fraction_non_alphanumeric': 0.09240565305171611, 'fraction_numerical': 0.007765180928715639, 'mean_word_length': 2.3042585941508467, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '2244305', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1776, 'n_words': 576}