summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2010-02-27 17:48:53 +0100
committerJulian Andres Klode <jak@debian.org>2010-02-27 17:48:53 +0100
commita123b39f6e3dc69c9db46dd00550fc04c1ee9399 (patch)
tree17795a5f57d3b472256ccd6051fe92bfc6ade567
parenta169fd15520d61303639c0dfa2aabec3f6446fb6 (diff)
downloadpython-apt-a123b39f6e3dc69c9db46dd00550fc04c1ee9399.tar.gz
Ship the list of deprecated things in the apt_pkg and apt_inst modules
inside the script itself, so we don't have to parse the source code anymore.
-rw-r--r--debian/changelog3
-rw-r--r--debian/python-apt.docs1
-rwxr-xr-xutils/migrate-0.8.py131
3 files changed, 80 insertions, 55 deletions
diff --git a/debian/changelog b/debian/changelog
index e5945ef4..9a05185d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -8,6 +8,9 @@ python-apt (0.7.93.2) unstable; urgency=low
* utils/migrate-0.8.py:
- Improve C++ parsing and add apt.progress.old to the modules, reduces
false positives.
+ - Ship the list of deprecated things in the apt_pkg and apt_inst modules
+ inside the script itself, so we don't have to parse the source code
+ anymore.
* python:
- Handle deprecated attributes and methods in the tp_gettattro slot, this
allows us to easily warn if a deprecated function is used.
diff --git a/debian/python-apt.docs b/debian/python-apt.docs
index 1bfc7c1c..c4191c81 100644
--- a/debian/python-apt.docs
+++ b/debian/python-apt.docs
@@ -4,3 +4,4 @@ TODO
apt/README.apt
data/templates/README.templates
build/sphinx/html/
+utils/migrate-0.8.py
diff --git a/utils/migrate-0.8.py b/utils/migrate-0.8.py
index 61059b2a..d0d8e9a1 100755
--- a/utils/migrate-0.8.py
+++ b/utils/migrate-0.8.py
@@ -44,7 +44,7 @@ from collections import defaultdict
from textwrap import fill
color=False
-if sys.argv[1] in ('-c', '--color', '--colour'):
+if len(sys.argv) > 1 and sys.argv[1] in ('-c', '--color', '--colour'):
color=True
del sys.argv[1]
@@ -55,6 +55,75 @@ if '-h' in sys.argv or '--help' in sys.argv or not sys.argv[1:]:
if os.path.dirname(__file__).endswith('utils'):
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
+deprecated_cpp_stuff = set([
+ '.Add', '.AllTargets', '.Arch', '.Architecture', '.Archive',
+ '.ArchiveURI', '.Auto', '.Base64Encode', '.Binaries', '.BrokenCount',
+ '.BuildDepends', '.Bytes', '.CheckDep', '.CheckDomainList', '.Clear',
+ '.Close', '.Commit', '.CompType', '.Complete', '.Component', '.Config',
+ '.CurStateConfigFiles', '.CurStateHalfConfigured',
+ '.CurStateHalfInstalled', '.CurStateInstalled', '.CurStateNotInstalled',
+ '.CurStateUnPacked', '.CurrentState', '.CurrentVer', '.Date',
+ '.DeQuoteString', '.DebSize', '.DelCount', '.DepType', '.DependsCount',
+ '.DependsList', '.DependsListStr', '.DescURI', '.Describe', '.DestFile',
+ '.Dist', '.DoInstall', '.Downloadable', '.ErrorText', '.Essential',
+ '.Exists', '.FetchNeeded', '.FileList', '.FileName', '.FileSize',
+ '.Files', '.Find', '.FindB', '.FindDir', '.FindFile', '.FindFlag',
+ '.FindI', '.FindIndex', '.FindRaw', '.FixBroken', '.FixMissing',
+ '.GetAcquire', '.GetArchives', '.GetCache', '.GetCandidateVer',
+ '.GetCdrom', '.GetDepCache', '.GetIndexes', '.GetLock',
+ '.GetPackageManager', '.GetPkgAcqFile', '.GetPkgActionGroup',
+ '.GetPkgProblemResolver', '.GetPkgRecords', '.GetPkgSourceList',
+ '.GetPkgSrcRecords', '.HasPackages', '.Hash', '.Homepage', '.ID',
+ '.Ident', '.Important', '.Index', '.IndexFiles', '.IndexType', '.Init',
+ '.InitConfig', '.InitSystem', '.InstCount', '.InstState',
+ '.InstStateHold', '.InstStateHoldReInstReq', '.InstStateOk',
+ '.InstStateReInstReq', '.InstallProtect', '.InstalledSize',
+ '.IsAutoInstalled', '.IsGarbage', '.IsInstBroken', '.IsNowBroken',
+ '.IsTrusted', '.IsUpgradable', '.Items', '.Jump', '.KeepCount',
+ '.Label', '.LanguageCode', '.LibVersion', '.List', '.Local',
+ '.LongDesc', '.Lookup', '.MD5Hash', '.Maintainer', '.MarkDelete',
+ '.MarkInstall', '.MarkKeep', '.MarkedDelete', '.MarkedDowngrade',
+ '.MarkedInstall', '.MarkedKeep', '.MarkedReinstall', '.MarkedUpgrade',
+ '.MinimizeUpgrade', '.MyTag', '.Name', '.NotAutomatic', '.NotSource',
+ '.Offset', '.Open', '.Origin', '.Package', '.PackageCount',
+ '.PackageFileCount', '.Packages', '.ParentPkg', '.ParentVer',
+ '.ParseCommandLine', '.ParseDepends', '.ParseSection',
+ '.ParseSrcDepends', '.ParseTagFile', '.PartialPresent',
+ '.PkgSystemLock', '.PkgSystemUnLock', '.PriExtra', '.PriImportant',
+ '.PriOptional', '.PriRequired', '.PriStandard', '.Priority',
+ '.PriorityStr', '.Protect', '.ProvidesCount', '.ProvidesList',
+ '.QuoteString', '.ReadConfigDir', '.ReadConfigFile',
+ '.ReadConfigFileISC', '.ReadMainList', '.ReadPinFile', '.Record',
+ '.Remove', '.Resolve', '.ResolveByKeep', '.Restart', '.RevDependsList',
+ '.RewriteSection', '.RewriteSourceOrder', '.Run', '.SHA1Hash',
+ '.SHA256Hash', '.Section', '.SelStateDeInstall', '.SelStateHold',
+ '.SelStateInstall', '.SelStatePurge', '.SelStateUnknown',
+ '.SelectedState', '.Set', '.SetCandidateVer', '.SetReInstall',
+ '.ShortDesc', '.Shutdown', '.Site', '.Size', '.SizeToStr',
+ '.SmartTargetPkg', '.SourcePkg', '.SourceVer', '.Status', '.Step',
+ '.StrToTime', '.StringToBool', '.SubTree', '.TargetPkg', '.TargetVer',
+ '.Time', '.TimeRFC1123', '.TimeToStr', '.TotalNeeded',
+ '.TranslationDescription', '.URI', '.URItoFileName', '.Update',
+ '.Upgrade', '.UpstreamVersion', '.UsrSize', '.ValueList',
+ '.VerFileCount', '.VerStr', '.Version', '.VersionCompare',
+ '.VersionCount', '.VersionList', '.newConfiguration', 'Base64Encode',
+ 'CheckDep', 'CheckDomainList', 'Config', 'CurStateConfigFiles',
+ 'CurStateHalfConfigured', 'CurStateHalfInstalled', 'CurStateInstalled',
+ 'CurStateNotInstalled', 'CurStateUnPacked', 'Date', 'DeQuoteString',
+ 'GetAcquire', 'GetCache', 'GetCdrom', 'GetDepCache', 'GetLock',
+ 'GetPackageManager', 'GetPkgAcqFile', 'GetPkgActionGroup',
+ 'GetPkgProblemResolver', 'GetPkgRecords', 'GetPkgSourceList',
+ 'GetPkgSrcRecords', 'InitConfig', 'InitSystem', 'InstStateHold',
+ 'InstStateHoldReInstReq', 'InstStateOk', 'InstStateReInstReq',
+ 'LibVersion', 'ParseCommandLine', 'ParseDepends', 'ParseSection',
+ 'ParseSrcDepends', 'ParseTagFile', 'PkgSystemLock', 'PkgSystemUnLock',
+ 'PriExtra', 'PriImportant', 'PriOptional', 'PriRequired', 'PriStandard',
+ 'QuoteString', 'ReadConfigDir', 'ReadConfigFile', 'ReadConfigFileISC',
+ 'RewriteSection', 'RewriteSourceOrder', 'SelStateDeInstall',
+ 'SelStateHold', 'SelStateInstall', 'SelStatePurge', 'SelStateUnknown',
+ 'SizeToStr', 'StrToTime', 'StringToBool', 'Time', 'TimeRFC1123',
+ 'TimeToStr', 'URItoFileName', 'UpstreamVersion', 'VersionCompare',
+ 'newConfiguration'])
def do_color(string, words):
"""Colorize (red) the given words in the given string."""
@@ -66,61 +135,13 @@ def do_color(string, words):
r"\2" + "\033[0m\\3", string)
return string
-
-def find_deprecated_cpp():
- """Find all the deprecated functions and attributes."""
- is_open=False
- all_old = set()
- for fname in glob.glob('python/*.cc'):
- lines = list(open(fname, 'r'))
- while lines:
- line = lines.pop(0)
- while lines and not ('static PyMethodDef' in line or
- 'static PyGetSetDef' in line):
- line = lines.pop(0)
- if not lines:
- break
-
- while lines and not ';' in line:
- while lines and not 'COMPAT_0_7' in line and not ';' in line:
- line = lines.pop(0)
- if ';' in line:
- continue
- if lines:
- line = lines.pop(0)
- while lines and not '#endif' in line:
- name = line.split(",")[0].strip().strip('{"')
- if not 'module' in fname:
- name = '.' + name
- else:
- all_old.add('.' + name)
- all_old.add(name)
- line = lines.pop(0)
- # Let's handle constants in the apt_pkg module
- lines = list(open('python/apt_pkgmodule.cc'))
- while lines:
- while lines and not 'COMPAT_0_7' in line:
- line = lines.pop(0)
- if lines:
- lines.pop(0)
- while lines and not '#endif' in line:
- if 'PyModule_Add' in line:
- name = line.split(",")[1].strip().strip('"')
- if name != '_COMPAT_0_7':
- all_old.add('.' + name)
- all_old.add(name)
- line = lines.pop(0)
- return all_old
-
-
def find_deprecated_py():
- """Same as find_deprecated_cpp(), but for apt and aptsources.
-
- We import apt_pkg, set _COMPAT_0_7 to 0, import apt and aptsources and
- create a list of all attributes.
+ """Find all the deprecated functions and attributes.
- No we remove the imported modules, reimport them (with _COMPAT_0_7=1),
- and see which functions have been removed.
+ Import apt_pkg, set _COMPAT_0_7 to 0, import apt and aptsources and
+ create a list of all attributes. Then remove the imported modules,
+ reimport them (with _COMPAT_0_7=1), and see which functions do not
+ exist anymore.
"""
modules = ('apt', 'apt.package', 'apt.cdrom', 'apt.cache', 'apt.debfile',
@@ -204,7 +225,7 @@ if color:
'simply highlight the matched words (like grep).', 79)
print
-all_old = find_deprecated_cpp()
+all_old = deprecated_cpp_stuff
if not '-P' in sys.argv:
all_old |= find_deprecated_py()