Re: [Django] #30880: Optimize the _tx_resource_for_name() function in django/scripts/manage_translations.py

2019-10-14 Thread Django
#30880: Optimize the _tx_resource_for_name() function in
django/scripts/manage_translations.py
-+-
 Reporter:  ankit1219|Owner:  nobody
 Type:   |   Status:  closed
  Cleanup/optimization   |
Component:  Core (Other) |  Version:  master
 Severity:  Normal   |   Resolution:  wontfix
 Keywords:  Optimize scripts | Triage Stage:
 |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-
Changes (by felixxm):

 * status:  new => closed
 * version:  2.2 => master
 * resolution:   => wontfix


Comment:

 Decreasing the number of lines doesn't increase readability in most of
 cases. The current form looks good to me.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.aa7c3fee8a289a4cd876fe1777659498%40djangoproject.com.


Re: [Django] #30880: Optimize the _tx_resource_for_name() function in django/scripts/manage_translations.py

2019-10-14 Thread Django
#30880: Optimize the _tx_resource_for_name() function in
django/scripts/manage_translations.py
-+-
 Reporter:  ankit1219|Owner:  nobody
 Type:   |   Status:  new
  Cleanup/optimization   |
Component:  Core (Other) |  Version:  2.2
 Severity:  Normal   |   Resolution:
 Keywords:  Optimize scripts | Triage Stage:
 |  Unreviewed
Has patch:  1|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  1|UI/UX:  0
-+-

Old description:

> The **_tx_resource_for_name()** function in
> **django/scripts/manage_translations.py** uses simple if else statement
> to return the **Transifex resource name**.
>
> ''def _tx_resource_for_name(name):
> """ Return the Transifex resource name """
> if name == 'core':
> return "django.core"
> else:
> return "django.contrib-%s" % name''
>
> You can use Python ternary operator to  reduce code size and increase
> readability of the code.
>

> ''def _tx_resource_for_name(name):
> """ Return the Transifex resource name """
>return "django.core"   if name == 'core' else "django.contrib-%s"
> % name''
>
> It allows us to replace simple if statements with a single line
> expression. Increases code readability by reducing number of lines of
> code.

New description:

 The **_tx_resource_for_name()** function in
 **django/scripts/manage_translations.py** uses simple if else statement to
 return the **Transifex resource name**.

 def _tx_resource_for_name(name):
 if name == 'core':
 return "django.core"
 else:
 return "django.contrib-%s" % name

 You can use Python ternary operator to  reduce code size and increase
 readability of the code.


 def _tx_resource_for_name(name):
return "django.core"   if name == 'core' else "django.contrib-%s" %
 name

 It allows us to replace simple if statements with a single line
 expression. Increases code readability by reducing number of lines of
 code.

--

Comment (by ankit1219):

 I can send a PR to optimize the code.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/071.c662607566af9161fe3b8e7a51c3f523%40djangoproject.com.


[Django] #30880: Optimize the _tx_resource_for_name() function in django/scripts/manage_translations.py

2019-10-14 Thread Django
#30880: Optimize the _tx_resource_for_name() function in
django/scripts/manage_translations.py
-+-
   Reporter:  ankit1219  |  Owner:  nobody
   Type: | Status:  new
  Cleanup/optimization   |
  Component:  Core   |Version:  2.2
  (Other)|
   Severity:  Normal |   Keywords:  Optimize scripts
   Triage Stage: |  Has patch:  1
  Unreviewed |
Needs documentation:  0  |Needs tests:  0
Patch needs improvement:  0  |  Easy pickings:  1
  UI/UX:  0  |
-+-
 The **_tx_resource_for_name()** function in
 **django/scripts/manage_translations.py** uses simple if else statement to
 return the **Transifex resource name**.

 ''def _tx_resource_for_name(name):
 """ Return the Transifex resource name """
 if name == 'core':
 return "django.core"
 else:
 return "django.contrib-%s" % name''

 You can use Python ternary operator to  reduce code size and increase
 readability of the code.


 ''def _tx_resource_for_name(name):
 """ Return the Transifex resource name """
return "django.core"   if name == 'core' else "django.contrib-%s" %
 name''

 It allows us to replace simple if statements with a single line
 expression. Increases code readability by reducing number of lines of
 code.

-- 
Ticket URL: 
Django 
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/056.62e56a14381ab70e6276cfb55dc3e35e%40djangoproject.com.