1313import glob
1414import os
1515from jinja2 import Template
16- from subprocess import Popen ,PIPE
16+ from subprocess import Popen , PIPE
1717
1818readme = Template ("""
1919[](https://travis-ci.org/bamos/python-scripts)
7474{{similar_projects}}
7575""" )
7676
77+
7778def get_docstr (filename ):
7879 print (" + get_docstr({})" .format (filename ))
7980 with open (filename ) as f :
8081 script = ast .parse (f .read ())
8182 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 ])
8485 except :
85- print (" + Error reading (author,date,desc)." )
86+ print (" + Error reading (author, date, desc)." )
8687 raise
8788 return """
8889## [{}](https://github.com/bamos/python-scripts/blob/master/{})
@@ -92,31 +93,34 @@ def get_docstr(filename):
9293{}
9394""" .format (filename , filename , ", " .join (authors ), date , desc )
9495
96+
9597def get_descriptions ():
9698 print ("# Getting project descriptions" )
9799 return ("\n " .join (map (get_docstr ,
98- ['generate-readme.py' ]+ glob .glob ("python*/*.py" ))))
100+ ['generate-readme.py' ] + glob .glob ("python*/*.py" ))))
101+
99102
100103def get_similar_projects ():
101104 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' ]
108111 cmd = ['./python3/github-repo-summary.py' ] + projs
109112 p = Popen (cmd , stdout = PIPE )
110- out ,err = p .communicate ()
113+ out , err = p .communicate ()
111114 return out .decode ()
112115
113- if __name__ == '__main__' :
116+
117+ if __name__ == '__main__' :
114118 # cd into the script directory.
115119 abspath = os .path .abspath (__file__ )
116120 dname = os .path .dirname (abspath )
117121 os .chdir (dname )
118122
119- with open ("README.md" ,"w" ) as f :
123+ with open ("README.md" , "w" ) as f :
120124 f .write (readme .render (
121125 descriptions = get_descriptions (),
122126 similar_projects = get_similar_projects ()
0 commit comments