Skip to content

Conversation

gktrk
Copy link

@gktrk gktrk commented Sep 25, 2020

Most of the work is done by the 2to3 script. Popen required the
passing of 'universal_newlines=True', otherwise it returns a byte
stream in python3. future import is added for backwards
compatibility. Lightly tested with python2.7, python3.{6,7,8}.

Most of the work is done by the 2to3 script. Popen required the
passing of 'universal_newlines=True', otherwise it returns a byte
stream in python3. __future__ import is added for backwards
compatibility. Lightly tested with python2.7, python3.{6,7,8}.

def getkeyssortedbyvalues(dict):
return map(lambda el : el[1], sorted(map(lambda el : (el[1], el[0]), dict.items())))
return [el[1] for el in sorted([(el[1], el[0]) for el in list(dict.items())])]
Copy link

@penguinolog penguinolog Nov 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	return [el[1] for el in sorted(((val, key) for key, val in dict.items()))]

f.write('<tr><th>Name</th><th>Date</th><th>Commits</th><th>Authors</th></tr>')
# sort the tags by date desc
tags_sorted_by_date_desc = map(lambda el : el[1], reversed(sorted(map(lambda el : (el[1]['date'], el[0]), data.tags.items()))))
tags_sorted_by_date_desc = [el[1] for el in reversed(sorted([(el[1]['date'], el[0]) for el in list(data.tags.items())]))]
Copy link

@penguinolog penguinolog Nov 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tags_sorted_by_date_desc = [(el[1] for el in sorted((v['date'], k) for k, v in data.tags.items()), reverse=True)]

fgc.write('%d' % stamp)
for author in self.authors_to_plot:
if author in data.changes_by_date_by_author[stamp].keys():
if author in list(data.changes_by_date_by_author[stamp].keys()):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if author in data.changes_by_date_by_author[stamp]:

keys is checked for in expression

f.write('</tr>')
max_commits_on_tz = max(data.commits_by_timezone.values())
for i in sorted(data.commits_by_timezone.keys(), key = lambda n : int(n)):
for i in sorted(list(data.commits_by_timezone.keys()), key = lambda n : int(n)):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use generator expression: more memory efficient & faster

# dict['author'] = { 'commits': 512 } - ...key(dict, 'commits')
def getkeyssortedbyvaluekey(d, key):
return map(lambda el : el[1], sorted(map(lambda el : (d[el][key], el), d.keys())))
return [el[1] for el in sorted([(d[el][key], el) for el in list(d.keys())])]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

	return [el[1] for el in sorted(((v[key], k) for k, v in d.items()))]

@penguinolog
Copy link

looks like 2to3 still produces code, which "just run"

@shenxianpeng
Copy link

Hi! I’ve revived gitstats with Python 3 support in the repository: https://github.com/shenxianpeng/gitstats. Feel free to check it out if needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants