[Yum-devel] [PATCH] clean up all the import yum.blah and from yum.blah import blah
Mike Bonnet
mikeb at redhat.com
Wed Sep 30 15:49:33 UTC 2009
On 09/30/2009 09:45 AM, Tim Lauridsen wrote:
> On 09/28/2009 11:26 PM, Seth Vidal wrote:
>> from items inside the module it is not necessary.
>> ---
>> yum/__init__.py | 12 ++++++------
>> yum/comps.py | 2 +-
>> yum/history.py | 9 ++++-----
>> yum/plugins.py | 2 +-
>> yum/rpmsack.py | 2 +-
>> yum/rpmtrans.py | 2 +-
>> yum/sqlitesack.py | 4 ++--
>> yum/update_md.py | 8 ++++----
>> yum/yumRepo.py | 6 +++---
>> 9 files changed, 23 insertions(+), 24 deletions(-)
>>
>> diff --git a/yum/__init__.py b/yum/__init__.py
>> index 35da1fb..e645e22 100644
>> --- a/yum/__init__.py
>> +++ b/yum/__init__.py
>> @@ -32,9 +32,9 @@ import logging.config
>> import operator
>> import gzip
>>
>> -import yum.i18n
>> -_ = yum.i18n._
>> -P_ = yum.i18n.P_
>> +import i18n
>> +_ = i18n._
>> +P_ = i18n.P_
>>
>> import config
>> from config import ParsingError, ConfigParser
>> @@ -57,15 +57,15 @@ import plugins
>> import logginglevels
>> import yumRepo
>> import callbacks
>> -import yum.history
>> +import history
>>
>> import warnings
>> warnings.simplefilter("ignore", Errors.YumFutureDeprecationWarning)
>>
>> from packages import parsePackages, YumAvailablePackage,
>> YumLocalPackage, YumInstalledPackage, comparePoEVR
>> from constants import *
>> -from yum.rpmtrans import RPMTransaction,SimpleCliCallBack
>> -from yum.i18n import to_unicode
>> +from rpmtrans import RPMTransaction,SimpleCliCallBack
>> +from i18n import to_unicode
>>
>> import string
>>
>> diff --git a/yum/comps.py b/yum/comps.py
>> index 2048c77..d310b1b 100755
>> --- a/yum/comps.py
>> +++ b/yum/comps.py
>> @@ -26,7 +26,7 @@ from Errors import CompsException
>> # switch all compsexceptions to grouperrors after api break
>> import fnmatch
>> import re
>> -from yum.i18n import to_unicode
>> +from i18n import to_unicode
>> from misc import get_my_lang_code
>>
>> lang_attr = '{http://www.w3.org/XML/1998/namespace}lang'
>> diff --git a/yum/history.py b/yum/history.py
>> index 644c2fc..18d2a41 100644
>> --- a/yum/history.py
>> +++ b/yum/history.py
>> @@ -23,11 +23,10 @@ import glob
>> from weakref import proxy as weakref
>>
>> from sqlutils import sqlite, executeSQL
>> -import yum.misc
>> -import yum.constants
>> -from yum.constants import *
>> -from yum.packages import YumInstalledPackage, YumAvailablePackage,
>> PackageObject
>> -from yum.i18n import to_unicode
>> +import misc
>> +from constants import *
>> +from packages import YumInstalledPackage, YumAvailablePackage,
>> PackageObject
>> +from i18n import to_unicode
>>
>> _history_dir = '/var/lib/yum/history'
>>
>> diff --git a/yum/plugins.py b/yum/plugins.py
>> index 02f0d57..c0e510f 100644
>> --- a/yum/plugins.py
>> +++ b/yum/plugins.py
>> @@ -34,7 +34,7 @@ from weakref import proxy as weakref
>>
>> from yum import _
>>
>> -from yum.i18n import utf8_width
>> +from i18n import utf8_width
>>
>> # TODO: expose rpm package sack objects to plugins (once finished)
>> # TODO: allow plugins to use the existing config stuff to define
>> options for
>> diff --git a/yum/rpmsack.py b/yum/rpmsack.py
>> index fd05f9b..74dd69d 100644
>> --- a/yum/rpmsack.py
>> +++ b/yum/rpmsack.py
>> @@ -31,7 +31,7 @@ from packageSack import PackageSackBase,
>> PackageSackVersion
>> import fnmatch
>> import re
>>
>> -from yum.i18n import to_unicode
>> +from i18n import to_unicode
>> import constants
>>
>> class RPMInstalledPackage(YumInstalledPackage):
>> diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
>> index b1b896f..ed52df0 100644
>> --- a/yum/rpmtrans.py
>> +++ b/yum/rpmtrans.py
>> @@ -23,7 +23,7 @@ import time
>> import logging
>> import types
>> import sys
>> -from yum.constants import *
>> +from constants import *
>> from yum import _
>> import misc
>>
>> diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
>> index ce2988f..89744ff 100644
>> --- a/yum/sqlitesack.py
>> +++ b/yum/sqlitesack.py
>> @@ -33,8 +33,8 @@ import rpmUtils.miscutils
>> import sqlutils
>> import constants
>> import operator
>> -from yum.misc import seq_max_split
>> -from yum.i18n import to_utf8, to_unicode
>> +from misc import seq_max_split
>> +from i18n import to_utf8, to_unicode
>> import sys
>> import re
>>
>> diff --git a/yum/update_md.py b/yum/update_md.py
>> index b3a120e..34179ea 100644
>> --- a/yum/update_md.py
>> +++ b/yum/update_md.py
>> @@ -24,10 +24,10 @@ Update metadata (updateinfo.xml) parsing.
>> import sys
>> import gzip
>>
>> -from yum.i18n import utf8_text_wrap, to_utf8
>> -from yum.yumRepo import YumRepository
>> -from yum.packages import FakeRepository
>> -from yum.misc import to_xml
>> +from i18n import utf8_text_wrap, to_utf8
>> +from yumRepo import YumRepository
>> +from packages import FakeRepository
>> +from misc import to_xml
>> import Errors
>>
>> import rpmUtils.miscutils
>> diff --git a/yum/yumRepo.py b/yum/yumRepo.py
>> index ea8518a..2bc7476 100644
>> --- a/yum/yumRepo.py
>> +++ b/yum/yumRepo.py
>> @@ -32,9 +32,9 @@ from repos import Repository
>> import parser
>> import sqlitecachec
>> import sqlitesack
>> -from yum import config
>> -from yum import misc
>> -from yum import comps
>> +import config
>> +import misc
>> +import comps
>> from constants import *
>> import metalink
>>
>
> Why ?
>
> from yum.i18n import ....
>
> is more readable than
>
> from i18n import .....
>
> and it is easier to see what is a yum submodule.
+1 to Tim's point. For an occasional yum hacker like myself it's very
useful to quickly see what is a yum submodule vs. what I need to poke
around in /usr/lib{,64}/python*/(site-packages/)? to find.
More information about the Yum-devel
mailing list