def parse(week, user): root = mm.getroot(week, user) ret = [] # "root" topics (level=0) first for topics in root.findall('.//mo:topics', mm.ns): for topic in topics.findall('./mo:topic', mm.ns): #(topic0id,topic0text) = mm.gettopic(topic) # below "root" topics are subtopics elements = mm.subtopic(topic, 0, []) for e in elements: (topic3id, topic3text, symbolnumber, symbolsmiley, topiclevel, parents) = e # possibly rethink this next structure: # this is due to changing from topiclevel==3 only to include all levels also if topiclevel >= 3: (topic0id, topic0text) = parents[2] (topic1id, topic1text) = parents[1] (topic2id, topic2text) = parents[0] elif topiclevel == 2: (topic0id, topic0text) = parents[1] (topic1id, topic1text) = parents[0] (topic2id, topic2text) = (topic3id, topic3text) (topic3id, topic3text) = (None, None) elif topiclevel == 1: (topic0id, topic0text) = parents[0] (topic1id, topic1text) = (topic3id, topic3text) (topic2id, topic2text) = (None, None) (topic3id, topic3text) = (None, None) ret.append([ topic0id, topic0text, topic1id, topic1text, topic2id, topic2text, topic3id, topic3text ]) return ret
def parse(week, user): root = mm.getroot(week, user) (mapid, name, author, creationDate, modificationDate) = mm.getdocinfo(root) (userID, firstName, lastName, userName) = (None, None, None, None) # TODO: if many what to choose? for user in root.findall('./mo:mapUsers/mo:mapUser', mm.ns): if "userID" in user.attrib: userID = user.attrib["userID"] ret = [] # "root" topics (level=0) first for topics in root.findall('.//mo:topics', mm.ns): for topic in topics.findall('./mo:topic', mm.ns): (topicid, topictext) = mm.gettopic(topic) (symbolnumber, symbolsmiley) = mm.gettopicsymbol(topic) topicLevel = 0 ret.append([ topicid, topictext, symbolnumber, symbolsmiley, topicLevel, mapid, userID ]) # below "root" topics are subtopics elements = mm.subtopic(topic, 0, []) for e in elements: (topicid, topictext, symbolnumber, symbolsmiley, topicLevel, parents) = e ret.append([ topicid, topictext, symbolnumber, symbolsmiley, topicLevel, mapid, userID ]) return ret
def parse(week, user): root = mm.getroot(week, user) ret = [] for user in root.findall('./mo:mapUsers/mo:mapUser', mm.ns): (userID, firstName, lastName, userName) = (None, None, None, None) if "userID" in user.attrib: userID = user.attrib["userID"] if "firstName" in user.attrib: firstName = user.attrib["firstName"] if "lastName" in user.attrib: lastName = user.attrib["lastName"] if "userName" in user.attrib: userName = user.attrib["userName"] ret.append([userID, firstName, lastName, userName]) return ret
def parse(week, user): root = mm.getroot(week, user) (mapid, name, author, creationDate, modificationDate) = mm.getdocinfo(root) (userID, firstName, lastName, userName) = (None, None, None, None) # TODO: if many what to choose? for user in root.findall('./mo:mapUsers/mo:mapUser', mm.ns): if "userID" in user.attrib: userID = user.attrib["userID"] ret = [] for relation in root.findall('./mo:relations/mo:relation', mm.ns): (topicid, fromId, toId, label, userid) = (None, None, None, None, None) if "id" in relation.attrib: topicid = relation.attrib["id"] if "fromId" in relation.attrib: fromId = relation.attrib["fromId"] if "toId" in relation.attrib: toId = relation.attrib["toId"] if "label" in relation.attrib: label = relation.attrib["label"] ret.append([topicid, fromId, toId, label, mapid, userID]) return ret
def parse(week, user): root = mm.getroot(week, user) (id, name, author, creationDate, modificationDate) = mm.getdocinfo(root) return [[id, name, author, creationDate, modificationDate]]