Commits

Anonymous committed 78a820e

minor: Fix the syntax of some docstrings.

Comments (0)

Files changed (23)

transifex/actionlog/models.py

     return msg
 
 class LogEntry(models.Model):
+    """A Entry in an object's log."""
     user = models.ForeignKey(User, blank=True, null=True, 
-            related_name="tx_user_action")
+                             related_name="tx_user_action")
 
     object_id = models.IntegerField(blank=True, null=True)
     content_type = models.ForeignKey(ContentType, blank=True, null=True,
         super(LogEntry, self).save(*args, **kwargs)
 
 def action_logging(user, object_list, action_type, message=None, context=None):
-    """ 
-    Add ActionLog using a set of parameters
+    """
+    Add ActionLog using a set of parameters.
     
-    user: The user that did the action.
-    object_list: A list of objects that should be created the actionlog for.
-    action_type: Label of a type of action from the NoticeType model.
-    message: A message to be included at the actionlog. If no message is passed
-             it will try do render a message using the notice.html from the
-             notification application.
-    contex: To render the message using the notification files, sometimes it is 
-            necessary to pass some vars by using a context.
+    user:
+      The user that did the action.
+    object_list:
+      A list of objects that should be created the actionlog for.
+    action_type:
+      Label of a type of action from the NoticeType model.
+    message:
+      A message to be included at the actionlog. If no message is passed
+      it will try do render a message using the notice.html from the
+      notification application.
+    contex:
+      To render the message using the notification files, sometimes it is 
+      necessary to pass some vars by using a context.
 
-    Usage:
+    Usage::
+
         al = 'project_component_added'
         context = {'component': object}
         action_logging(request.user, [object], al , context=context):
                     message = message)
             l.save()
     except TypeError:
-        raise TypeError("The 'object_list' parameter must be iterable")
+        raise TypeError("The 'object_list' parameter must be iterable")

transifex/codebases/models.py

 This module contains a model that is expected to be used for the
 codebases used by Transifex. The following definitions are used:
 
-resource: A file within a codebase
-codebase: A collection of files (VCS repo, tarball, etc.) that contains
+resource:
+  A file within a codebase
+codebase:
+  A collection of files (VCS repo, tarball, etc.) that contains
   resources, some or all of which are to be translated
 """
 import operator

transifex/languages/models.py

 
 class LanguageManager(models.Manager):
     def by_code_or_alias(self, code):        
-        """ 
+        """
         Return a language that matches either with the code or something
         inside the code_aliases field.
         """

transifex/languages/tests/test_models.py

     Test Translation Models.
     
     Supplementary tests, in addition to doctests.   
-    """ 
+    """
 
     def test_lang_create(self):
         """

transifex/projects/management/commands/txstatsrefresh.py

     requires_model_validation = False
     
     def handle(self, *comps, **options):
-        """Override default method to make it work without arguments.""" 
+        """Override default method to make it work without arguments."""
         _continue = options.get('continue')
         skip = options.get('skip')
         if _continue and not os.access(os.path.dirname(__file__), os.W_OK):

transifex/projects/views.py

 from txcommon import notifications as txnotification
 
 def _get_project_and_permission(project_slug, permission_pk):
-    """ 
+    """
     Handler to return a project and a permission instance or a 404 error, based 
     on the slugs passed by parameter.
     """
 @one_perm_required_or_403(pr_project_add_perm, 
     (Project, 'slug__exact', 'project_slug'))
 def project_add_permission(request, project_slug):
-    """ 
+    """
     Return a view with a form for adding a permission for an user.
     
     This view is an abstraction of a txpermissions.views method to be able to
 
 @login_required
 def project_add_permission_request(request, project_slug):
-    """ 
+    """
     Return a view with a form for adding a request of permission for an user.
 
     This view is an abstraction of a txpermissions.views method. 
 @one_perm_required_or_403(pr_project_delete_perm, 
     (Project, 'slug__exact', 'project_slug'))
 def project_delete_permission(request, project_slug, permission_pk):
-    """ 
+    """
     View for deleting a permission of an user.
 
     This view is an abstraction of a txpermissions.views method to be able to
 
 @login_required
 def project_delete_permission_request(request, project_slug, permission_pk):
-    """ 
+    """
     View for deleting a request of permission of an user.
 
     This view is an abstraction of a txpermissions.views method. 
 
 @login_required
 def project_toggle_watch(request, project_slug):
-    """ Add/Remove watches on a project for a specific user """
+    """Add/Remove watches on a project for a specific user."""
 
     if request.method != 'POST':
         return json_error(_('Must use POST to activate'))
 @one_perm_required_or_403(pr_component_watch_file, 
     (Project, 'slug__exact', 'project_slug'))
 def component_toggle_watch(request, project_slug, component_slug, filename):
-    """ Add/Remove a watch for a path on a component for a specific user """
+    """Add/Remove a watch for a path on a component for a specific user."""
 
     if request.method != 'POST':
         return json_error(_('Must use POST to activate'))

transifex/tarball/lib/types/__init__.py

             pass
 
     def rename_repo(self, new_name):
-        """ Rename the directory in the filesystem of the repository. """
+        """Rename the directory in the filesystem of the repository."""
         import shutil
         try:
             destination = "%s/%s" % (os.path.split(self.path)[0], new_name)

transifex/tarball/models.py

 This module contains a model that is expected to be used for the
 codebases used by Transifex. The following definitions are used:
 
-resource: A file within a codebase
-codebase: A collection of files (VCS repo, tarball, etc.) that contains
+resource:
+  A file within a codebase
+codebase:
+  A collection of files (VCS repo, tarball, etc.) that contains
   resources, some or all of which are to be translated
 """
 from datetime import datetime
         
         The initialization will raise an exception if the type
         is not specified in the model.
-        """   
+        """  
         from tarball.lib import get_browser_object
         browser = get_browser_object(self.type)
         self.browser = browser(root=self.root,

transifex/translations/lib/types/pot.py

                " for intltool POT-based projects."
 
 class POTManager(TransManagerMixin):
-    """ A browser class for POT files. """
+    """A browser class for POT files."""
 
     def __init__(self, file_set, path, source_lang, file_filter,
         filepath=None):
         return file_content
 
     def get_po_entries(self, filename):
-        """Return a Django form field for the component"""
+        """Return a Django form field for the component."""
         from django import forms
         if filename in self.file_set:
             file_path = os.path.join(self.path, filename)
         return None
 
     def get_po_files(self):
-        """ Return a list of PO filenames """
+        """Return a list of PO filenames."""
 
         po_files = []
         for filename in self.file_set:
         return po_files
 
     def get_langfiles(self, lang):
-        """ Return a list with the PO filenames for a specificy language """
+        """Return a list with the PO filenames for a specificy language."""
 
         files=[]
         for filepath in self.get_po_files():
         return files
 
     def guess_language(self, filepath):
-        """ Guess a language from a filepath """
+        """Guess a language from a filepath."""
 
         if 'LC_MESSAGES' in filepath:
             fp = filepath.split('LC_MESSAGES')
             return os.path.basename(filepath[:-3:])
 
     def get_langs(self):
-        """ Return all langs tha have a po file for a object """
+        """Return all langs tha have a po file for a object."""
 
         langs = []
         for filepath in self.get_po_files():
 
 
     def po_file_stats(self, pofile):
-        """ Calculate stats for a POT/PO file """
+        """Calculate stats for a POT/PO file."""
         error = False
         pofile = os.path.join(self.msgmerge_path, pofile)
 
                 'error' : error,}
 
     def calculate_file_stats(self, filename, try_to_merge):
-        """ 
+        """
         Return the statistics of a specificy file for an object after
         merging the file with the source translation file (POT), if possible.
         """
             return None
 
     def get_stats(self, object):
-        """ Return a list of statistics of languages for an object."""
+        """Return a list of statistics of languages for an object."""
         return POFile.objects.by_object_total(object)
 
     def delete_stats_for_object(self, object):
-        """ Delete all lang statistics of an object."""
+        """Delete all lang statistics of an object."""
         ctype = ContentType.objects.get_for_model(object)
         POFile.objects.filter(object_id=object.id, content_type=ctype).delete()
 
                     return os.path.join(rel_path, filename)[1:]
 
     def get_source_file_for_pofile(self, filename):
-        """ 
+        """
         Find the related source file (POT) for a pofile when it has multiple
         source files.
 
         This method gets a filename as parameter and tries to discover the 
         related POT file using two methods:
+        
         1. Trying to find a POT file with the same base path that the pofile.
            Example: /foo/bar.pot and /foo/baz.po match on this method.
 
         2. Trying to find a POT file with the same domain that the pofile in any
            directory.
+        
            Example: /foo/bar.pot and /foo/baz/bar.po match on this method.
            The domain in this case is 'bar'.
 
         return (is_msgmerged, outpo)
 
     def guess_po_dir(self):
-        """ Guess the po/ diretory to run intltool """
+        """Guess the po/ diretory to run intltool."""
         for filename in self.file_set:
             if 'POTFILES.in' in filename:
                 if self.file_filter:

transifex/translations/lib/types/publican.py

 
 
     def get_langs_from_makefile(self):
-        """ 
+        """
         Return the languages available in the OTHER_LANGS setting of the 
         Makefile. Case it does not exist return an empty list.
 
 
 
     def guess_language(self, filepath, pot_dir_index=None):
-        """ 
+        """
         Guess a language code from a filepath by finding the 'pot' dir position
 
         The method for looking for the language code consist on finding a 

transifex/translations/models.py

                            object_id=obj.pk).order_by('-trans_perc')
 
     def by_language(self, language):
-        """ Return a list of objects statistics for a language."""
+        """Return a list of objects statistics for a language."""
         return self.filter(language=language)
 
     def by_release(self, release):
         return self.filter(content_type=ctype, object_id__in=comp_query)
 
     def by_language_and_release(self, language, release):
-        """ 
+        """
         Return a list of stats object for a language and release.
         """
         return self.by_release(release).filter(language=language)
 
     def by_lang_code_and_object(self, language_code, obj):
-        """ 
+        """
         Return a list of stats for a language and object.
         """
         return self.by_object(obj).filter(language_code=language_code)

transifex/translations/tests/test_models.py

     Test Translation Models.
     
     Supplementary tests, in addition to doctests.   
-    """ 
+    """
 
 #    def setUp(self):
 #        self.pofile = POFile(object=self.language, language=self.language)

transifex/translations/tests/test_pot.py

     """Test POT support.
     
     Supplementary tests, in addition to doctests.   
-    """ 
+    """
 
     #TODO: Run the init stuff only when needed.
     def setUp(self):

transifex/txcommon/decorators.py

     enabled for an object or a general permission from the django permission 
     system, redirecting to the log-in page if necessary.
     
-    Use example:
-    # Permissions required for setting stats
-    pr_set_stats = (
-        ('granular', 'project_permission.maintain'),
-        ('general',  'projects.refresh_stats'),
-       #(<perm_type>, <perm_name>),
-    )
+    Example::
+
+      # Permissions required for setting stats
+      pr_set_stats = (
+          ('granular', 'project_permission.maintain'),
+          ('general',  'projects.refresh_stats'),
+         #(<perm_type>, <perm_name>),
+      )
     
-    @one_perm_required_or_403(pr_set_stats, 
-        (Project, 'slug__contains', 'project_slug'))
-    def component_set_stats(request, project_slug, component_slug):
-        bla bla bla
+      @one_perm_required_or_403(pr_set_stats, 
+          (Project, 'slug__contains', 'project_slug'))
+      def component_set_stats(request, project_slug, component_slug):
+          bla bla bla
         
     In the example above the decorator checks for the `maintain` permission
     for a Project object, taking the project_slug from the view 

transifex/txcommon/log/receivers.py

 
 """
 Logging receivers for signals by models, etc.
-""" 
+"""
 
 def model_named(sender, message='', **kwargs):
     """

transifex/txpermissions/templatetags/txpermissions.py

 
 @register.simple_tag
 def txurl_for_obj(view_name, obj):
-    """ 
+    """
     Return the reverse url for a given obj and view_name based on the 
     object slug
     """
 
 @register.simple_tag
 def txadd_url_for_obj(obj):
-    """ Return the reverse url for adding permissions to an object. """
+    """Return the reverse url for adding permissions to an object"""
     return txurl_for_obj(u'%s_add_permission' % obj._meta.module_name, obj)
 
 
 @register.simple_tag
 def txrequest_url_for_obj(obj):
-    """ Return the reverse url for adding permission request to an object. """
+    """Return the reverse url for adding permission request to an object"""
     return txurl_for_obj(u'%s_add_permission_request' % obj._meta.module_name, 
                          obj)
 

transifex/vcs/lib/types/__init__.py

             pass
 
     def rename_repo(self, new_name):
-        """ Rename the directory in the filesystem of the repository. """
+        """Rename the directory in the filesystem of the repository."""
         import shutil
         try:
             destination = "%s/%s" % (os.path.split(self.path)[0], new_name)

transifex/vcs/models.py

         
         The initialization will raise an exception if the VCS type
         is not specified in the model.
-        """   
+        """  
         from vcs.lib import get_browser_object
         browser = get_browser_object(self.type)
         self.browser = browser(root=self.root,

transifex/vcs/tests/test_bzr.py

     """Test Bzr VCS support.
     
     Supplementary tests, in addition to doctests.   
-    """ 
+    """
 
     #TODO: Run the init stuff only when needed.
     def setUp(self):

transifex/vcs/tests/test_cvs.py

     """Test CVS VCS support.
     
     Supplementary tests, in addition to doctests.   
-    """ 
+    """
 
     #TODO: Run the init stuff only when needed.
     def setUp(self):

transifex/vcs/tests/test_git.py

     """Test Git VCS support.
     
     Supplementary tests, in addition to doctests.   
-    """ 
+    """
 
     #TODO: Run the init stuff only when needed.
     def setUp(self):

transifex/vcs/tests/test_hg.py

     """Test Hg VCS support.
     
     Supplementary tests, in addition to doctests.   
-    """ 
+    """
 
     #TODO: Run the init stuff only when needed.
     def setUp(self):

transifex/vcs/tests/test_svn.py

     """Test Subversion VCS support.
     
     Supplementary tests, in addition to doctests.   
-    """ 
+    """
 
     #TODO: Run the init stuff only when needed.
     def setUp(self):