diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2017-10-25 17:16:47 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2017-11-09 18:27:05 +0300 |
commit | 0af273df25f3d930dfa25a2b5dc49b9e4e4261ab (patch) | |
tree | e5d80df5bd10ca120ccb3d79d0636e4b8fe12406 | |
parent | 84829a01884989f65e49e8163dcc7eb3cec9d888 (diff) |
Trim components of obsoletes: and depends: when we sort them
Don't want components to be sorted with any leading whitespace
-rwxr-xr-x | calm/hint.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/calm/hint.py b/calm/hint.py index a5a51d6..dcdbd5f 100755 --- a/calm/hint.py +++ b/calm/hint.py @@ -190,6 +190,13 @@ def item_lexer(c): yield (i, o, None) +def split_trim_sort_join(hint, splitchar, joinchar=None): + if joinchar is None: + joinchar = splitchar + ' ' + + return joinchar.join(sorted([s.strip() for s in hint.split(splitchar)])) + + # parse the file |fn| as a .hint file of kind |kind| def hint_file_parse(fn, kind): hints = OrderedDict() @@ -297,13 +304,13 @@ def hint_file_parse(fn, kind): # sort these hints, as differences in ordering are uninteresting if 'requires' in hints: - hints['requires'] = ' '.join(sorted(hints['requires'].split())) + hints['requires'] = split_trim_sort_join(hints['requires'], None, ' ') if 'depends' in hints: - hints['depends'] = ','.join(sorted(hints['depends'].split(','))) + hints['depends'] = split_trim_sort_join(hints['depends'], ',') if 'obsoletes' in hints: - hints['obsoletes'] = ','.join(sorted(hints['obsoletes'].split(','))) + hints['obsoletes'] = split_trim_sort_join(hints['obsoletes'], ',') except UnicodeDecodeError: errors.append('invalid UTF-8') |