Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Python3 #34

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 104 additions & 106 deletions BeautifulSoup.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion activity/activity.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ activity_version = 25
license = GPLv2+;GPLv3+;BSD
icon = slicelogo
bundle_id = org.sugarlabs.InfoSlicer
exec = sugar-activity activity.InfoslicerActivity
exec = sugar-activity3 activity.InfoslicerActivity
show_launcher = yes
summary = Is it possible to have my own encyclopedia? Yes! Find your favorite information on the web and package it with InfoSlicer creating incredible collections.
tags = Tools;Internet
Expand Down
6 changes: 3 additions & 3 deletions book.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def __init__(self, preinstalled, root):
self.revision = 1

if not os.path.exists(self.root):
os.makedirs(self.root, 0775)
os.makedirs(self.root, 0o775)

for i in preinstalled:
filepath = os.path.join(get_bundle_path(), 'examples', i[1])
Expand Down Expand Up @@ -196,7 +196,7 @@ def _save(self, uid, contents):
directory = os.path.join(self.root, str(uid))

if not os.path.exists(directory):
os.makedirs(directory, 0777)
os.makedirs(directory, 0o777)

contents = contents.replace(
'<prolog>', '<prolog>\n<resourceid id="%s" />'
Expand Down Expand Up @@ -232,7 +232,7 @@ def __init__(self, filepath=None):
zip = zipfile.ZipFile(filepath, 'r')
for i in zip.namelist():
path = os.path.join(root, i)
os.makedirs(os.path.dirname(path), 0775)
os.makedirs(os.path.dirname(path), 0o775)
file(path, 'wb').write(zip.read(i))
zip.close()

Expand Down
4 changes: 2 additions & 2 deletions infoslicer/processing/Article.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
from gi.repository import GdkPixbuf

from random import Random
from Article_Data import *
from Section import *
from .Article_Data import *
from .Section import *
import logging

logger = logging.getLogger('infoslicer')
Expand Down
12 changes: 6 additions & 6 deletions infoslicer/processing/Article_Builder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Copyright (C) IBM Corporation 2008

from BeautifulSoup import Tag
from NewtifulSoup import NewtifulStoneSoup as BeautifulStoneSoup
from Article_Data import *
from .BeautifulSoup import Tag
from .NewtifulSoup import NewtifulStoneSoup as BeautifulStoneSoup
from .Article_Data import *
import re
import os
import logging
Expand Down Expand Up @@ -51,7 +51,7 @@ def get_article_from_dita(image_path, dita):
input.shortdesc.extract()
has_shortdesc = True
taglist = input.findAll(re.compile("refbody|section|p|ph|image"))
for i in xrange(len(taglist)):
for i in range(len(taglist)):
tag = taglist[len(taglist) - i - 1]
if tag.name == "ph":
id = tag['id']
Expand All @@ -63,7 +63,7 @@ def get_article_from_dita(image_path, dita):
sentence_data = Sentence_Data(id, source_article_id, source_section_id, source_paragraph_id, source_sentence_id, text)
sentence_data_list.insert(0, sentence_data)
elif tag.name == "p":
if not tag.has_key("id"):
if "id" not in tag:
id = -1
else:
id = tag['id']
Expand All @@ -75,7 +75,7 @@ def get_article_from_dita(image_path, dita):
sentence_data_list = []
current_p_id = id
elif tag.name == "refbody" :
if tag.findParent("reference").has_key("id"):
if "id" in tag.findParent("reference"):
id = "r" + tag.findParent("reference")['id']
else:
id = "r90000"
Expand Down
Loading