chiark / gitweb /
Use shorter and non-redundant 'or' clauses for 'if True else' assignments
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 3 Jul 2014 15:35:28 +0000 (17:35 +0200)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 3 Jul 2014 15:35:28 +0000 (17:35 +0200)
fdroidserver/checkupdates.py
fdroidserver/common.py
fdroidserver/import.py
fdroidserver/lint.py
fdroidserver/metadata.py

index 7d9689abce6c5cd468d33b23e6780bd76eecf600..8325501c98de2d1d6d5f8bd1e07a38a2dacdc882 100644 (file)
@@ -90,7 +90,7 @@ def check_tags(app, pattern):
 
     try:
 
-        appid = app['Update Check Name'] if app['Update Check Name'] else app['id']
+        appid = app['Update Check Name'] or app['id']
         if app['Repo Type'] == 'srclib':
             build_dir = os.path.join('build', 'srclib', app['Repo'])
             repotype = common.getsrclibvcs(app['Repo'])
@@ -174,7 +174,7 @@ def check_repomanifest(app, branch=None):
 
     try:
 
-        appid = app['Update Check Name'] if app['Update Check Name'] else app['id']
+        appid = app['Update Check Name'] or app['id']
         if app['Repo Type'] == 'srclib':
             build_dir = os.path.join('build', 'srclib', app['Repo'])
             repotype = common.getsrclibvcs(app['Repo'])
@@ -312,7 +312,7 @@ def dirs_with_manifest(startdir):
 # subdir relative to the build dir if found, None otherwise.
 def check_changed_subdir(app):
 
-    appid = app['Update Check Name'] if app['Update Check Name'] else app['id']
+    appid = app['Update Check Name'] or app['id']
     if app['Repo Type'] == 'srclib':
         build_dir = os.path.join('build', 'srclib', app['Repo'])
     else:
index 69e6e68bdb9a0dede371fc7e39d16281b9415869..6376b530ddd529ac31fa348ec09afe3d0b5f8abb 100644 (file)
@@ -490,7 +490,7 @@ class vcs_git(vcs):
                 self.refreshed = True
         # origin/HEAD is the HEAD of the remote, e.g. the "default branch" on
         # a github repo. Most of the time this is the same as origin/master.
-        rev = str(rev if rev else 'origin/HEAD')
+        rev = rev or 'origin/HEAD'
         p = SilentPopen(['git', 'checkout', '-f', rev], cwd=self.local)
         if p.returncode != 0:
             raise VCSException("Git checkout of '%s' failed" % rev, p.output)
@@ -608,7 +608,7 @@ class vcs_gitsvn(vcs):
                     raise VCSException("Git svn rebase failed", p.output)
                 self.refreshed = True
 
-        rev = str(rev if rev else 'master')
+        rev = rev or 'master'
         if rev:
             nospaces_rev = rev.replace(' ', '%20')
             # Try finding a svn tag
@@ -723,7 +723,7 @@ class vcs_hg(vcs):
                     raise VCSException("Hg pull failed", p.output)
                 self.refreshed = True
 
-        rev = str(rev if rev else 'default')
+        rev = rev or 'default'
         if not rev:
             return
         p = SilentPopen(['hg', 'update', '-C', rev], cwd=self.local)
index e6c2fa1650cb2f555710ebba7c1be3c39a18d3e8..a241b2baf2829cd54fe18d07c23cc311812e94cc 100644 (file)
@@ -285,8 +285,8 @@ def main():
 
     # Create a build line...
     build = {}
-    build['version'] = version if version else '?'
-    build['vercode'] = vercode if vercode else '?'
+    build['version'] = version or '?'
+    build['vercode'] = vercode or '?'
     build['commit'] = '?'
     build['disable'] = 'Generated by import.py - check/set version fields and commit id'
     if options.subdir:
index 06e2f532f9456126041ef82aeeb362c0581f3304..123a6441edba45f0b8a45e01531aa987b638b425 100644 (file)
@@ -189,7 +189,7 @@ def main():
 
         # Redundant summaries
         summary = app['Summary']
-        name = str(app['Name'] if app['Name'] else app['Auto Name'])
+        name = app['Name'] or app['Auto Name']
         if summary and name:
             summary_l = summary.lower()
             name_l = name.lower()
index e99a6ecab33c6f01892a2f5fa005683e2e05e60e..6ed8410529dbb5468005188983d2a51efa2cf8b0 100644 (file)
@@ -794,7 +794,7 @@ def write_metadata(dest, app):
                 mf.write("%s\n" % comment)
                 written += 1
         if written > 0:
-            logging.debug("...writing comments for " + (key if key else 'EOF'))
+            logging.debug("...writing comments for " + (key or 'EOF'))
 
     def writefield(field, value=None):
         writecomments(field)