[Yum] code cleanup: one function in one source

Vladimir Bormotov bor at vb.dn.ua
Sun Jul 14 10:12:47 UTC 2002


		Hi!

=========================================
$ grep -A 14 "def formatRequire" *py 
clientStuff.py:def formatRequire (name, version, flags):
clientStuff.py-    string = name
clientStuff.py-        
clientStuff.py-    if flags:
clientStuff.py-        if flags & (rpm.RPMSENSE_LESS | rpm.RPMSENSE_GREATER | rpm.RPMSENSE_EQUAL):
clientStuff.py-            string = string + ' '
clientStuff.py-        if flags & rpm.RPMSENSE_LESS:
clientStuff.py-            string = string + '<'
clientStuff.py-        if flags & rpm.RPMSENSE_GREATER:
clientStuff.py-            string = string + '>'
clientStuff.py-        if flags & rpm.RPMSENSE_EQUAL:
clientStuff.py-            string = string + '='
clientStuff.py-            string = string + ' %s' % version
clientStuff.py-    return string
clientStuff.py-
--
depchecktree.py:def formatRequire (name, version, flags):
depchecktree.py-    string = name
depchecktree.py-        
depchecktree.py-    if flags:
depchecktree.py-        if flags & (rpm.RPMSENSE_LESS | rpm.RPMSENSE_GREATER | rpm.RPMSENSE_EQUAL):
depchecktree.py-            string = string + " "
depchecktree.py-        if flags & rpm.RPMSENSE_LESS:
depchecktree.py-            string = string + "<"
depchecktree.py-        if flags & rpm.RPMSENSE_GREATER:
depchecktree.py-            string = string + ">"
depchecktree.py-        if flags & rpm.RPMSENSE_EQUAL:
depchecktree.py-            string = string + "="
depchecktree.py-            string = string + " %s" % version
depchecktree.py-    return string
depchecktree.py-
--
serverStuff.py:def formatRequire (name, version, flags):
serverStuff.py-    import rpm
serverStuff.py-    string = name
serverStuff.py-        
serverStuff.py-    if flags:
serverStuff.py-      if flags & (rpm.RPMSENSE_LESS | rpm.RPMSENSE_GREATER | rpm.RPMSENSE_EQUAL):
serverStuff.py-         string = string + " "
serverStuff.py-      if flags & rpm.RPMSENSE_LESS:
serverStuff.py-         string = string + "<"
serverStuff.py-      if flags & rpm.RPMSENSE_GREATER:
serverStuff.py-         string = string + ">"
serverStuff.py-      if flags & rpm.RPMSENSE_EQUAL:
serverStuff.py-         string = string + "="
serverStuff.py-         string = string + " %s" % version
serverStuff.py-    return string
=========================================

 and, please, no import inside functions (look at 'import rpm' in this grep 
 output  and many-many-many  import string/os/sys/etc  in other sources)...
 
 PythonStyleGuide (http://www.python.org/peps/pep-0008.html): 
 
   Imports
    - Imports are always put at the top of the file, just after any
      module comments and docstrings, and before module globals and
      constants.
 
-- 
		Bor.



More information about the Yum mailing list