forked from s3bw/foolgit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtransform_gits.py
More file actions
54 lines (37 loc) · 1.05 KB
/
transform_gits.py
File metadata and controls
54 lines (37 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""Transforms pickle data into display model."""
import os
import json
import pickle
from collections import defaultdict
def load_pickle(path):
with open(path, 'rb') as r:
b = pickle.load(r)
return list(b)
data = defaultdict(dict)
paths = load_pickle('found_gits.pkl')
for path in paths:
components = path.split('/')
group, repo = components[-3], components[-2]
data[group].update({repo: path})
home = dict(data)['home']
model = [
{
'group': 'home',
'repo': key,
'path': value.replace(os.path.expanduser('~'), '~'),
} for key, value in home.items()
]
from fool import console
from fool.content import Column
from fool.windows import TableWindow
def git_view(screen, model):
items = model
main = TableWindow(w=120, items=items)
columns = [
Column(name='group', size=6, align='left'),
Column(name='repo', size=20, align='left'),
Column(name='path', size=40, align='left'),
]
main.content = columns
return [main]
console.display(git_view, model, close='q')