Kod
def phpbb2_posts():
'''Create table phpbb2_posts'''
mybb_posts = open_dump('posts')
phpbb2_posts = list()
enable_bbcode = 1
enable_html = 0
enable_smilies = 1
enable_sig = 1
post_edit_time = 'NULL'
post_edit_count = 0
#We need to get the ID of the newest topic
newest_topic = 1
for row in xrange(len(mybb_posts)):
post_id = int(mybb_posts[row][0]) #pid
topic_id = int(mybb_posts[row][1]) #tid
forum_id = int(mybb_posts[row][3]) #fid
poster_id = int(mybb_posts[row][6]) #uid
post_time = int(mybb_posts[row][8]) #dateline
poster_ip = mybb_posts[row][10].rstrip("'").lstrip("'") #ipaddress
#poster_ip must be hex
string_end = len(poster_ip)
start = 0
string_hex = ''
for number_block in xrange(4):
end = poster_ip.find('.', start, string_end)
#Last number block of the ip address (XXX.XXX.XXX.XXX)
if number_block == 3:
end = string_end
number = int(poster_ip[start:end]) //tutaj wypada 305 linja
start = end + 1
hexnumber = "%x" %number
if len(hexnumber) == 1:
hexnumber = '0' + hexnumber
string_hex += str(hexnumber)
poster_ip = "'" + string_hex + "'"
post_username = mybb_posts[row][7] #username
phpbb2_posts.append((post_id, topic_id, forum_id, poster_id,
post_time, poster_ip, post_username,
enable_bbcode, enable_html,enable_smilies,
enable_sig, post_edit_time, post_edit_count))
if topic_id > newest_topic:
newest_topic = topic_id
columns_names = ('post_id', 'topic_id', 'forum_id', 'poster_id',
'post_time','poster_ip', 'post_username', 'enable_bbcode',
'enable_html', 'enable_smilies', 'enable_sig', 'post_edit_time',
'post_edit_count')
#We need the the ID of the last post of each topic
topic_last_post_id_list = list()
#Now this is a bad solution, I guess
#We create a list with newest_topic elements
for i in xrange(newest_topic + 1):
topic_last_post_id_list += ["''"]
for row in xrange(len(phpbb2_posts)):
#phpbb2_posts[row][1] is the thread number
#phpbb2_posts[row][0] is the post number
topic_last_post_id_list[phpbb2_posts[row][1]] = phpbb2_posts[row][0]
return phpbb2_posts, columns_names, topic_last_post_id_list
'''Create table phpbb2_posts'''
mybb_posts = open_dump('posts')
phpbb2_posts = list()
enable_bbcode = 1
enable_html = 0
enable_smilies = 1
enable_sig = 1
post_edit_time = 'NULL'
post_edit_count = 0
#We need to get the ID of the newest topic
newest_topic = 1
for row in xrange(len(mybb_posts)):
post_id = int(mybb_posts[row][0]) #pid
topic_id = int(mybb_posts[row][1]) #tid
forum_id = int(mybb_posts[row][3]) #fid
poster_id = int(mybb_posts[row][6]) #uid
post_time = int(mybb_posts[row][8]) #dateline
poster_ip = mybb_posts[row][10].rstrip("'").lstrip("'") #ipaddress
#poster_ip must be hex
string_end = len(poster_ip)
start = 0
string_hex = ''
for number_block in xrange(4):
end = poster_ip.find('.', start, string_end)
#Last number block of the ip address (XXX.XXX.XXX.XXX)
if number_block == 3:
end = string_end
number = int(poster_ip[start:end]) //tutaj wypada 305 linja
start = end + 1
hexnumber = "%x" %number
if len(hexnumber) == 1:
hexnumber = '0' + hexnumber
string_hex += str(hexnumber)
poster_ip = "'" + string_hex + "'"
post_username = mybb_posts[row][7] #username
phpbb2_posts.append((post_id, topic_id, forum_id, poster_id,
post_time, poster_ip, post_username,
enable_bbcode, enable_html,enable_smilies,
enable_sig, post_edit_time, post_edit_count))
if topic_id > newest_topic:
newest_topic = topic_id
columns_names = ('post_id', 'topic_id', 'forum_id', 'poster_id',
'post_time','poster_ip', 'post_username', 'enable_bbcode',
'enable_html', 'enable_smilies', 'enable_sig', 'post_edit_time',
'post_edit_count')
#We need the the ID of the last post of each topic
topic_last_post_id_list = list()
#Now this is a bad solution, I guess
#We create a list with newest_topic elements
for i in xrange(newest_topic + 1):
topic_last_post_id_list += ["''"]
for row in xrange(len(phpbb2_posts)):
#phpbb2_posts[row][1] is the thread number
#phpbb2_posts[row][0] is the post number
topic_last_post_id_list[phpbb2_posts[row][1]] = phpbb2_posts[row][0]
return phpbb2_posts, columns_names, topic_last_post_id_list
Błąd(zaznaczylem wam w kodzie u góry która to 305linja):
Cytat
Traceback (most recent call last):
File "C:\skrypt.py", line 897, in <module>
phpbb2_posts()
File "C:\skrypt.py", line 305, in phpbb2_posts
number = int(poster_ip[start:end])
ValueError: invalid literal for int() with base 10: ''
File "C:\skrypt.py", line 897, in <module>
phpbb2_posts()
File "C:\skrypt.py", line 305, in phpbb2_posts
number = int(poster_ip[start:end])
ValueError: invalid literal for int() with base 10: ''
Z uwagi że nigdy nie zagłebiałem się w ten język może mi ktoś powiedzieć co tutaj jest nie tak ?