public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/test/, pym/gentoolkit/test/equery/, pym/gentoolkit/equery/, ...
@ 2021-01-10  2:48 Matt Turner
  0 siblings, 0 replies; only message in thread
From: Matt Turner @ 2021-01-10  2:48 UTC (permalink / raw
  To: gentoo-commits

commit:     bcb81589c94c416aa460100092f1c2c76c013a93
Author:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  4 18:38:04 2021 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Mon Jan  4 18:43:48 2021 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=bcb81589

equery: Remove 'changes' subcommand

ChangeLogs have been gone from gentoo.git since the beginning, and
Council agreed in 2016 to allow Infra to decide whether to distribute
them through rsync, which they have decided not to do [1].

[1] https://projects.gentoo.org/council/meeting-logs/20160410-summary.txt

Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 pym/gentoolkit/equery/__init__.py       |   1 -
 pym/gentoolkit/equery/changes.py        | 184 --------------------------------
 pym/gentoolkit/helpers.py               | 173 ------------------------------
 pym/gentoolkit/test/equery/test_init.py |   1 -
 pym/gentoolkit/test/test_helpers.py     |  47 --------
 5 files changed, 406 deletions(-)

diff --git a/pym/gentoolkit/equery/__init__.py b/pym/gentoolkit/equery/__init__.py
index 4640086..677f534 100644
--- a/pym/gentoolkit/equery/__init__.py
+++ b/pym/gentoolkit/equery/__init__.py
@@ -42,7 +42,6 @@ __authors__ = (
 
 NAME_MAP = {
 	'b': 'belongs',
-	'c': 'changes',
 	'k': 'check',
 	'd': 'depends',
 	'g': 'depgraph',

diff --git a/pym/gentoolkit/equery/changes.py b/pym/gentoolkit/equery/changes.py
deleted file mode 100644
index f234ecb..0000000
--- a/pym/gentoolkit/equery/changes.py
+++ /dev/null
@@ -1,184 +0,0 @@
-# Copyright(c) 2009, Gentoo Foundation
-#
-# Licensed under the GNU General Public License, v2 or higher
-
-"""Displays the ChangeLog entry for the latest installable version of an atom"""
-
-__docformat__ = 'epytext'
-
-# =======
-# Imports
-# =======
-
-import sys
-import os
-from getopt import gnu_getopt, GetoptError
-
-import gentoolkit.pprinter as pp
-from gentoolkit.atom import Atom
-from gentoolkit.equery import format_options, mod_usage
-from gentoolkit.helpers import ChangeLog
-from gentoolkit.query import Query
-
-# =======
-# Globals
-# =======
-
-QUERY_OPTS = {
-	'only_latest': False,
-	'show_full_log': False,
-	'limit': None,
-	'from': None,
-	'to': None
-}
-
-# =========
-# Functions
-# =========
-
-def print_help(with_description=True):
-	"""Print description, usage and a detailed help message.
-
-	@type with_description: bool
-	@param with_description: if true, print module's __doc__ string
-	"""
-
-	if with_description:
-		print(__doc__.strip())
-		print()
-	print(mod_usage(mod_name="changes"))
-	print()
-	print(pp.emph("examples"))
-	print (" c portage                                # show latest visible "
-	       "version's entry")
-	print(" c portage --full --limit=3               # show 3 latest entries")
-	print(" c '=sys-apps/portage-2.1.6*'             # use atom syntax")
-	print(" c portage --from=2.2_rc60 --to=2.2_rc70  # use version ranges")
-	print()
-	print(pp.command("options"))
-	print(format_options((
-		(" -h, --help", "display this help message"),
-		(" -l, --latest", "display only the latest ChangeLog entry"),
-		(" -f, --full", "display the full ChangeLog"),
-		("     --limit=NUM",
-			"limit the number of entries displayed (with --full)"),
-		("     --from=VER", "set which version to display from"),
-		("     --to=VER", "set which version to display to"),
-	)))
-
-
-def parse_module_options(module_opts):
-	"""Parse module options and update QUERY_OPTS"""
-
-	opts = (x[0] for x in module_opts)
-	posargs = (x[1] for x in module_opts)
-	for opt, posarg in zip(opts, posargs):
-		if opt in ('-h', '--help'):
-			print_help()
-			sys.exit(0)
-		elif opt in ('-f', '--full'):
-			QUERY_OPTS['show_full_log'] = True
-		elif opt in ('-l', '--latest'):
-			QUERY_OPTS['only_latest'] = True
-		elif opt in ('--limit',):
-			set_limit(posarg)
-		elif opt in ('--from',):
-			QUERY_OPTS['from'] = posarg
-		elif opt in ('--to',):
-			QUERY_OPTS['to'] = posarg
-
-
-def print_entries(entries):
-	"""Print entries and strip trailing whitespace from the last entry."""
-
-	len_entries = len(entries)
-	for i, entry in enumerate(entries, start=1):
-		if i < len_entries:
-			pp.uprint(entry)
-		else:
-			pp.uprint(entry.strip())
-
-
-def set_limit(posarg):
-	"""Set a limit in QUERY_OPTS on how many ChangeLog entries to display.
-
-	Die if posarg is not an integer.
-	"""
-
-	if posarg.isdigit():
-		QUERY_OPTS['limit'] = int(posarg)
-	else:
-		err = "Module option --limit requires integer (got '%s')"
-		sys.stderr.write(pp.error(err % posarg))
-		print()
-		print_help(with_description=False)
-		sys.exit(2)
-
-
-def main(input_args):
-	"""Parse input and run the program"""
-
-	short_opts = "hlf"
-	long_opts = ('help', 'full', 'from=', 'latest', 'limit=', 'to=')
-
-	try:
-		module_opts, queries = gnu_getopt(input_args, short_opts, long_opts)
-	except GetoptError as err:
-		sys.stderr.write(pp.error("Module %s" % err))
-		print()
-		print_help(with_description=False)
-		sys.exit(2)
-
-	parse_module_options(module_opts)
-
-	if not queries:
-		print_help()
-		sys.exit(2)
-
-	first_run = True
-	got_match = False
-	for query in (Query(x) for x in queries):
-		if not first_run:
-			print()
-
-		match = query.find_best()
-		if match is None:
-			continue
-
-		got_match = True
-		changelog_path = os.path.join(match.package_path(), 'ChangeLog')
-		changelog = ChangeLog(changelog_path)
-
-		#
-		# Output
-		#
-
-		if (QUERY_OPTS['only_latest'] or (
-			changelog.entries and not changelog.indexed_entries
-		)):
-			pp.uprint(changelog.latest.strip())
-		else:
-			end = QUERY_OPTS['limit'] or len(changelog.indexed_entries)
-			if QUERY_OPTS['to'] or QUERY_OPTS['from']:
-				print_entries(
-					changelog.entries_matching_range(
-						from_ver=QUERY_OPTS['from'],
-						to_ver=QUERY_OPTS['to']
-					)[:end]
-				)
-			elif QUERY_OPTS['show_full_log']:
-				print_entries(changelog.full[:end])
-			else:
-				# Raises GentoolkitInvalidAtom here if invalid
-				if query.is_ranged():
-					atom = Atom(str(query))
-				else:
-					atom = '=' + str(match.cpv)
-				print_entries(changelog.entries_matching_atom(atom)[:end])
-
-		first_run = False
-
-	if not got_match:
-		sys.exit(1)
-
-# vim: set ts=4 sw=4 tw=79:

diff --git a/pym/gentoolkit/helpers.py b/pym/gentoolkit/helpers.py
index e7185c3..236a379 100644
--- a/pym/gentoolkit/helpers.py
+++ b/pym/gentoolkit/helpers.py
@@ -9,7 +9,6 @@
 """
 
 __all__ = (
-	'ChangeLog',
 	'FileOwner',
 	'get_cpvs',
 	'get_installed_cpvs',
@@ -43,178 +42,6 @@ from gentoolkit.versionmatch import VersionMatch
 # Classes
 # =======
 
-class ChangeLog:
-	"""Provides methods for working with a Gentoo ChangeLog file.
-
-	Example usage:
-		>>> from gentoolkit.helpers import ChangeLog
-		>>> portage = ChangeLog('/usr/portage/sys-apps/portage/ChangeLog')
-		>>> print(portage.latest.strip())
-		*portage-2.2.0_alpha142 (26 Oct 2012)
-		<BLANKLINE>
-		  26 Oct 2012; Zac Medico <zmedico@gentoo.org> +portage-2.2.0_alpha142.ebuild:
-		  2.2.0_alpha142 version bump. This includes all of the fixes in 2.1.11.31. Bug
-		  #210077 tracks all bugs fixed since portage-2.1.x.
-		>>> len(portage.full)
-		270
-		>>> len(portage.entries_matching_range(
-		...     from_ver='2.1.11.31',
-		...     to_ver='9999'))
-		140
-	"""
-	def __init__(self, changelog_path, invalid_entry_is_fatal=False):
-		if not (os.path.isfile(changelog_path) and
-			os.access(changelog_path, os.R_OK)):
-			raise errors.GentoolkitFatalError(
-				"%s does not exist or is unreadable" % pp.path(changelog_path)
-			)
-		self.changelog_path = changelog_path
-		self.invalid_entry_is_fatal = invalid_entry_is_fatal
-
-		# Process the ChangeLog:
-		self.entries = self._split_changelog()
-		self.indexed_entries = self._index_changelog()
-		self.full = self.entries
-		self.latest = self.entries[0]
-
-	def __repr__(self):
-		return "<%s %r>" % (self.__class__.__name__, self.changelog_path)
-
-	def entries_matching_atom(self, atom):
-		"""Return entries whose header versions match atom's version.
-
-		@type atom: L{gentoolkit.atom.Atom} or str
-		@param atom: a atom to find matching entries against
-		@rtype: list
-		@return: entries matching atom
-		@raise errors.GentoolkitInvalidAtom: if atom is a string and malformed
-		"""
-		result = []
-
-		if not isinstance(atom, Atom):
-			atom = Atom(atom)
-
-		for entry_set in self.indexed_entries:
-			i, entry = entry_set
-			# VersionMatch doesn't store .cp, so we'll force it to match here:
-			i.cp = atom.cp
-			if atom.intersects(i):
-				result.append(entry)
-
-		return result
-
-	def entries_matching_range(self, from_ver=None, to_ver=None):
-		"""Return entries whose header versions are within a range of versions.
-
-		@type from_ver: str
-		@param from_ver: valid Gentoo version
-		@type to_ver: str
-		@param to_ver: valid Gentoo version
-		@rtype: list
-		@return: entries between from_ver and to_ver
-		@raise errors.GentoolkitFatalError: if neither vers are set
-		@raise errors.GentoolkitInvalidVersion: if either ver is invalid
-		"""
-		result = []
-
-		# Make sure we have at least one version set
-		if not (from_ver or to_ver):
-			raise errors.GentoolkitFatalError(
-				"Need to specifiy 'from_ver' or 'to_ver'"
-			)
-
-		# Create a VersionMatch instance out of from_ver
-		from_restriction = None
-		if from_ver:
-			try:
-				from_ver_rev = CPV("null-%s" % from_ver)
-			except errors.GentoolkitInvalidCPV:
-				raise errors.GentoolkitInvalidVersion(from_ver)
-			from_restriction = VersionMatch(from_ver_rev, op='>=')
-
-		# Create a VersionMatch instance out of to_ver
-		to_restriction = None
-		if to_ver:
-			try:
-				to_ver_rev = CPV("null-%s" % to_ver)
-			except errors.GentoolkitInvalidCPV:
-				raise errors.GentoolkitInvalidVersion(to_ver)
-			to_restriction = VersionMatch(to_ver_rev, op='<=')
-
-		# Add entry to result if version ranges intersect it
-		for entry_set in self.indexed_entries:
-			i, entry = entry_set
-			if from_restriction and not from_restriction.match(i):
-				continue
-			if to_restriction and not to_restriction.match(i):
-				# TODO: is it safe to break here?
-				continue
-			result.append(entry)
-
-		return result
-
-	def _index_changelog(self):
-		"""Use the output of L{self._split_changelog} to create an index list
-		of L{gentoolkit.versionmatch.VersionMatch} objects.
-
-		@rtype: list
-		@return: tuples containing a VersionMatch instance for the release
-			version of each entry header as the first item and the entire entry
-			as the second item
-		@raise ValueError: if self.invalid_entry_is_fatal is True and we hit an
-			invalid entry
-		"""
-
-		result = []
-		for entry in self.entries:
-			# Extract the package name from the entry header, ex:
-			# *xterm-242 (07 Mar 2009) => xterm-242
-			pkg_name = entry.split(' ', 1)[0].lstrip('*')
-			if not pkg_name.strip():
-				continue
-			try:
-				entry_ver = CPV(pkg_name, validate=True)
-			except errors.GentoolkitInvalidCPV:
-				if self.invalid_entry_is_fatal:
-					raise ValueError(entry_ver)
-				continue
-
-			result.append((VersionMatch(entry_ver, op='='), entry))
-
-		return result
-
-	def _split_changelog(self):
-		"""Split the ChangeLog into individual entries.
-
-		@rtype: list
-		@return: individual ChangeLog entries
-		"""
-
-		result = []
-		partial_entries = []
-		with open(_unicode_encode(self.changelog_path,
-			encoding=_encodings['fs'], errors="replace"),
-			encoding=_encodings['content']) as log:
-			for line in log:
-				if line.startswith('#'):
-					continue
-				elif line.startswith('*'):
-					# Append last entry to result...
-					entry = ''.join(partial_entries)
-					if entry and not entry.isspace():
-						result.append(entry)
-					# ... and start a new entry
-					partial_entries = [line]
-				else:
-					partial_entries.append(line)
-			else:
-				# Append the final entry
-				entry = ''.join(partial_entries)
-				result.append(entry)
-
-		return result
-
-
 class FileOwner:
 	"""Creates a function for locating the owner of filename queries.
 

diff --git a/pym/gentoolkit/test/equery/test_init.py b/pym/gentoolkit/test/equery/test_init.py
index 075f653..4cad22e 100644
--- a/pym/gentoolkit/test/equery/test_init.py
+++ b/pym/gentoolkit/test/equery/test_init.py
@@ -15,7 +15,6 @@ class TestEqueryInit(unittest.TestCase):
 		name_map = {
 			'a': 'has',
 			'b': 'belongs',
-			'c': 'changes',
 			'k': 'check',
 			'd': 'depends',
 			'g': 'depgraph',

diff --git a/pym/gentoolkit/test/test_helpers.py b/pym/gentoolkit/test/test_helpers.py
index 734539c..be27835 100644
--- a/pym/gentoolkit/test/test_helpers.py
+++ b/pym/gentoolkit/test/test_helpers.py
@@ -6,52 +6,6 @@ from tempfile import NamedTemporaryFile, mktemp
 from gentoolkit import helpers
 
 
-class TestChangeLog(unittest.TestCase):
-
-	def setUp(self):
-		pass
-
-	def tearDown(self):
-		pass
-
-#  Commented out for being useless
-#          def test_split_changelog(self):
-#                  changelog = """
-#  *portage-2.1.6.2 (20 Dec 2008)
-
-#    20 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.2.ebuild:
-#    2.1.6.2 bump. This fixes bug #251591 (repoman inherit.autotools false
-#    positives) and bug #251616 (performance issue in build log search regex
-#    makes emerge appear to hang). Bug #216231 tracks all bugs fixed since
-#    2.1.4.x.
-
-#    20 Dec 2008; Zac Medico <zmedico@gentoo.org> -portage-2.1.6.ebuild,
-#    -portage-2.1.6.1.ebuild, -portage-2.2_rc17.ebuild:
-#    Remove old versions.
-
-
-#  *portage-2.1.6.1 (12 Dec 2008)
-
-#    12 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.1.ebuild:
-#    2.1.6.1 bump. This fixes bug #250148 (emerge hangs with selinux if ebuild
-#    spawns a daemon), bug #250166 (trigger download when generating manifest
-#    if file size differs from existing entry), and bug #250212 (new repoman
-#    upstream.workaround category for emake -j1 warnings). Bug #216231 tracks
-#    all bugs fixed since 2.1.4.x.
-
-
-#  *portage-2.1.6 (07 Dec 2008)
-
-#    07 Dec 2008; Zac Medico <zmedico@gentoo.org> +portage-2.1.6.ebuild:
-#    2.1.6 final release. This fixes bug #249586. Bug #216231 tracks all bugs
-#    fixed since 2.1.4.x.
-
-#    07 Dec 2008; Zac Medico <zmedico@gentoo.org> -portage-2.1.6_rc1.ebuild,
-#    -portage-2.1.6_rc2.ebuild, -portage-2.1.6_rc3.ebuild,
-#    -portage-2.2_rc16.ebuild:
-#    Remove old versions.
-#                  """
-
 class TestFileOwner(unittest.TestCase):
 
 	def setUp(self):
@@ -113,7 +67,6 @@ class TestFileOwner(unittest.TestCase):
 
 def test_main():
 	suite = unittest.TestLoader()
-	suite.loadTestsFromTestCase(TestChangeLog)
 	suite.loadTestsFromTestCase(TestFileOwner)
 	unittest.TextTestRunner(verbosity=2).run(suite)
 test_main.__test__ = False


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-01-10  2:48 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-10  2:48 [gentoo-commits] proj/gentoolkit:master commit in: pym/gentoolkit/test/, pym/gentoolkit/test/equery/, pym/gentoolkit/equery/, Matt Turner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox