File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed
Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1+ class Label :
2+ def __init__ (self , name , linenum , fname ):
3+ self .name = name
4+ self .linenum = linenum
5+ self .filename = fname
Original file line number Diff line number Diff line change 11import git
22import os
3+ import re
4+ import glob
5+ from .labels import Label
36
47class Project :
58 def __init__ (self , path ):
@@ -10,8 +13,28 @@ def __init__(self, path):
1013 self .notes = f .read ()
1114 else :
1215 self .notes = ""
16+
17+ self .labels = self .get_all_labels ()
1318 pass
1419
1520 def save_notes (self ):
1621 with open (os .path .join (self .path , ".rte-notes" ), "w" ) as f :
1722 f .write (self .notes )
23+
24+ def get_all_labels (self ):
25+ label_re = re .compile (r'(label) (\S+) ?:' )
26+ labels = []
27+ for filename in self .get_all_files ("rpy" ):
28+ path = os .path .join (self .path , filename )
29+ with open (path , "r" ) as f :
30+ for i , line in enumerate (f ):
31+ match = label_re .match (line )
32+ if match :
33+ labels .append (Label (match .group (2 ), i , path ))
34+ return labels
35+
36+ def get_all_files (self , ext = "rpy" ):
37+ rv = []
38+ for filename in glob .iglob (os .path .join (self .path , f'**/*.{ ext } ' ), recursive = True ):
39+ rv .append (filename )
40+ return rv
Original file line number Diff line number Diff line change 11{
2- "wm_width" : 1597 ,
3- "wm_height" : 752 ,
2+ "wm_width" : 1270 ,
3+ "wm_height" : 575 ,
44 "theme_name" : " monokai" ,
55 "insert_spaces_instead_of_tabs" : true ,
66 "tabs_length" : 4 ,
99 "start_maximized" : false ,
1010 "locale" : " en-US" ,
1111 "path_to_git" : " " ,
12- "side_notebook_width" : 200 ,
13- "scrollbar_width" : 20
12+ "side_notebook_width" : 200
13+ } "scrollbar_width" : 20
1414}
You can’t perform that action at this time.
0 commit comments