In python what is <type 'revision'>
I use pysvn to extract svn log information from subversion log history (Author, Date, Time, Revision). The code I use below:
client = pysvn.Client()
client.callback_get_login
commit_messages = client.log("url")
log_list = []
for i, commit in enumerate(commit_messages):
rev = commit.revision
auth = commit.author
t = time.ctime(commit.date)
mess = commit.message
log_list.append(rev)
log_list.append(auth)
log_list.append(t)
log_list.append(mess)
log_file = open("extracted_log_history",'wb')
wr = csv.writer(log_file, dialect = 'excel')
for item in log_list:
wr.writerows(item)
I found that this cannot work returning the following TypeError: writerows() argument must be iterable. I believe that this is not so, because it rev = commit.revisionreturns <type 'revision'>, and the rest of the variables (auth, t, mess) are all <type 'str'>. Any ideas on how I can get the revision number as "iterable"?
+4
1 answer
<type 'revision'>means you have an pysvn.Revisioninstance . If you want to write the version number, use the attribute revision.number.
. log_list , , CSV. csv.writerows() :
client = pysvn.Client()
client.callback_get_login
with open("extracted_log_history",'wb') as log_file:
wr = csv.writer(log_file)
for commit in client.log("url"):
rev = commit.revision.number
auth = commit.author
t = time.ctime(commit.date)
mess = commit.message
row = [rev, auth, t, mess]
wr.writerow(row)
+1