13
13
import glob
14
14
import os
15
15
from jinja2 import Template
16
- from subprocess import Popen ,PIPE
16
+ from subprocess import Popen , PIPE
17
17
18
18
readme = Template ("""
19
19
[](https://travis-ci.org/bamos/python-scripts)
74
74
{{similar_projects}}
75
75
""" )
76
76
77
+
77
78
def get_docstr (filename ):
78
79
print (" + get_docstr({})" .format (filename ))
79
80
with open (filename ) as f :
80
81
script = ast .parse (f .read ())
81
82
try :
82
- authors ,date ,desc = map (lambda x : ast .literal_eval (x .value ),
83
- script .body [0 :3 ])
83
+ authors , date , desc = map (lambda x : ast .literal_eval (x .value ),
84
+ script .body [0 :3 ])
84
85
except :
85
- print (" + Error reading (author,date,desc)." )
86
+ print (" + Error reading (author, date, desc)." )
86
87
raise
87
88
return """
88
89
## [{}](https://github.com/bamos/python-scripts/blob/master/{})
@@ -92,31 +93,34 @@ def get_docstr(filename):
92
93
{}
93
94
""" .format (filename , filename , ", " .join (authors ), date , desc )
94
95
96
+
95
97
def get_descriptions ():
96
98
print ("# Getting project descriptions" )
97
99
return ("\n " .join (map (get_docstr ,
98
- ['generate-readme.py' ]+ glob .glob ("python*/*.py" ))))
100
+ ['generate-readme.py' ] + glob .glob ("python*/*.py" ))))
101
+
99
102
100
103
def get_similar_projects ():
101
104
print ("# Getting similar projects" )
102
- projs = ['gpambrozio/PythonScripts' ,
103
- 'ClarkGoble/Scripts' ,
104
- 'gpambrozio/PythonScripts' ,
105
- 'realpython/python-scripts' ,
106
- 'averagesecurityguy/Python-Examples' ,
107
- 'computermacgyver/twitter-python' ]
105
+ projs = ['gpambrozio/PythonScripts' ,
106
+ 'ClarkGoble/Scripts' ,
107
+ 'gpambrozio/PythonScripts' ,
108
+ 'realpython/python-scripts' ,
109
+ 'averagesecurityguy/Python-Examples' ,
110
+ 'computermacgyver/twitter-python' ]
108
111
cmd = ['./python3/github-repo-summary.py' ] + projs
109
112
p = Popen (cmd , stdout = PIPE )
110
- out ,err = p .communicate ()
113
+ out , err = p .communicate ()
111
114
return out .decode ()
112
115
113
- if __name__ == '__main__' :
116
+
117
+ if __name__ == '__main__' :
114
118
# cd into the script directory.
115
119
abspath = os .path .abspath (__file__ )
116
120
dname = os .path .dirname (abspath )
117
121
os .chdir (dname )
118
122
119
- with open ("README.md" ,"w" ) as f :
123
+ with open ("README.md" , "w" ) as f :
120
124
f .write (readme .render (
121
125
descriptions = get_descriptions (),
122
126
similar_projects = get_similar_projects ()
0 commit comments