From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:gentoolkit-dev commit in: src/ekeyword/
Date: Sat, 25 Jan 2014 22:00:58 +0000 (UTC) [thread overview]
Message-ID: <1390687207.0482abe75ed71c5d0b6bb55f0d98bf9388861c08.vapier@gentoo> (raw)
commit: 0482abe75ed71c5d0b6bb55f0d98bf9388861c08
Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 22:00:07 2014 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 22:00:07 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=0482abe7
ekeyword: fix python3 compat issues
Get the unittests passing w/python-3.3.
---
src/ekeyword/ekeyword.py | 36 ++++++++++++++----------------------
1 file changed, 14 insertions(+), 22 deletions(-)
diff --git a/src/ekeyword/ekeyword.py b/src/ekeyword/ekeyword.py
index d8e0ed1..3fa74c1 100755
--- a/src/ekeyword/ekeyword.py
+++ b/src/ekeyword/ekeyword.py
@@ -41,6 +41,7 @@ from __future__ import print_function
import argparse
import collections
import difflib
+import io
import os
import re
import sys
@@ -77,30 +78,21 @@ def sort_keywords(arches):
arches.remove(g)
keywords.append(g)
- def arch_cmp(a1, a2):
+ def arch_key(keyword):
# Sort independent of leading marker (~ or -).
- a1 = keyword_to_arch(a1)
- a2 = keyword_to_arch(a2)
+ arch = keyword_to_arch(keyword)
# A keyword may have a "-" in it. We split on that and sort
# by the two resulting items. The part after the hyphen is
# the primary key.
- if '-' in a1:
- arch1, plat1 = a1.split('-', 1)
+ if '-' in arch:
+ arch, plat = arch.split('-', 1)
else:
- arch1, plat1 = a1, ''
- if '-' in a2:
- arch2, plat2 = a2.split('-', 1)
- else:
- arch2, plat2 = a2, ''
+ arch, plat = arch, ''
- ret = cmp(plat1, plat2)
- if ret:
- return ret
- else:
- return cmp(arch1, arch2)
+ return (plat, arch)
- keywords += sorted(arches, cmp=arch_cmp)
+ keywords += sorted(arches, key=arch_key)
return keywords
@@ -133,8 +125,8 @@ def diff_keywords(old_keywords, new_keywords, format='color-inline'):
return output
- sold = ' '.join(old_keywords)
- snew = ' '.join(new_keywords)
+ sold = str(' '.join(old_keywords))
+ snew = str(' '.join(new_keywords))
s = difflib.SequenceMatcher(str.isspace, sold, snew, autojunk=False)
return show_diff(s)
@@ -263,12 +255,12 @@ def process_content(ebuild, data, ops, arch_status=None, verbose=0,
def process_ebuild(ebuild, ops, arch_status=None, verbose=0, quiet=0,
dry_run=False, format='color-inline'):
"""Process |ops| for |ebuild|"""
- with open(ebuild, 'rb') as f:
+ with io.open(ebuild, encoding='utf8') as f:
updated, content = process_content(
ebuild, f, ops, arch_status=arch_status,
verbose=verbose, quiet=quiet, format=format)
if updated and not dry_run:
- with open(ebuild, 'wb') as f:
+ with io.open(ebuild, 'w', encoding='utf8') as f:
f.writelines(content)
@@ -396,9 +388,9 @@ def get_parser():
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('-n', '--dry-run', default=False, action='store_true',
help='Show what would be changed, but do not commit')
- parser.add_argument('-v', '--verbose', action='count',
+ parser.add_argument('-v', '--verbose', action='count', default=0,
help='Be verbose while processing things')
- parser.add_argument('-q', '--quiet', action='count',
+ parser.add_argument('-q', '--quiet', action='count', default=0,
help='Be quiet while processing things (only show errors)')
parser.add_argument('--format', default='auto',
choices=('auto', 'color-inline', 'inline', 'short-multi', 'long-multi'),
next reply other threads:[~2014-01-25 22:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-25 22:00 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-03-08 0:16 [gentoo-commits] proj/gentoolkit:gentoolkit-dev commit in: src/ekeyword/ Mike Frysinger
2017-03-08 0:16 Mike Frysinger
2017-02-18 5:24 Mike Frysinger
2017-02-16 7:25 Mike Frysinger
2017-02-16 7:25 Mike Frysinger
2016-01-27 23:35 Mike Frysinger
2016-01-27 23:35 Mike Frysinger
2015-04-04 21:26 Mike Frysinger
2015-04-04 21:26 Mike Frysinger
2015-04-04 21:26 Mike Frysinger
2014-11-18 18:24 Mike Gilbert
2014-11-13 22:51 Mike Frysinger
2014-01-27 23:14 Mike Frysinger
2014-01-25 22:00 Mike Frysinger
2014-01-25 22:00 Mike Frysinger
2014-01-20 16:29 Mike Frysinger
2014-01-20 6:17 Mike Frysinger
2012-04-23 3:02 Christian Ruppert
2012-04-23 3:02 Christian Ruppert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1390687207.0482abe75ed71c5d0b6bb55f0d98bf9388861c08.vapier@gentoo \
--to=vapier@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox