Exemplo n.º 1
0
 def __init__(self, outputPath, templateName):
     super(Serializer, self).__init__()
     self.outputPath = outputPath
     self.templateName = templateName
     fileutil.writeStringToFile("", self.outputPath)
     tmplResource = datamanager.findResourceByLabel(self.templateName)
     tmplContent = unicode(tmplResource.description())
     self.tmpl = Template(tmplContent)
     self.mapper = util.createDictFromResourceDescription("BibtexOntologyMapper")
Exemplo n.º 2
0
 def __init__(self, outputPath, templateName):
     super(Serializer, self).__init__()
     self.outputPath = outputPath
     self.templateName = templateName
     fileutil.writeStringToFile("", self.outputPath)
     tmplResource = datamanager.findResourceByLabel(self.templateName)
     tmplContent = unicode(tmplResource.description())
     self.tmpl = Template(tmplContent)
     self.mapper = util.createDictFromResourceDescription(
         "BibtexOntologyMapper")
Exemplo n.º 3
0
Arquivo: util.py Projeto: KDE/ginkgo
def createDictFromResourceDescription(resourceLabel, separator="=", commentSign="#"):
    mapperResource = datamanager.findResourceByLabel(resourceLabel)
    mapperContent = unicode(mapperResource.description())
    lines = mapperContent.splitlines()
    mapping = dict()
    for line in lines:
        if line.find(commentSign) == 0 or len(line.strip()) == 0:
            continue
        words = line.split(separator)
        mapping[words[0].strip()] = words[1].strip()
    return mapping
Exemplo n.º 4
0
def createDictFromResourceDescription(resourceLabel,
                                      separator="=",
                                      commentSign="#"):
    mapperResource = datamanager.findResourceByLabel(resourceLabel)
    mapperContent = unicode(mapperResource.description())
    lines = mapperContent.splitlines()
    mapping = dict()
    for line in lines:
        if line.find(commentSign) == 0 or len(line.strip()) == 0:
            continue
        words = line.split(separator)
        mapping[words[0].strip()] = words[1].strip()
    return mapping
Exemplo n.º 5
0
def importNotes(root):
    counter = 0
    newResources = []
    oldResources = []

    for filename in os.listdir(root):
        filepath = os.path.join(root, filename)
        if os.path.isfile(filepath):
            counter += 1
            pcontent = read_as_string(filepath)
            pcontent = pcontent.replace("%Types", "")
            pcontent = pcontent.replace("[[FrNet]]", "")
            pcontent = pcontent.replace("[FrNet]", "")
            content = ""
            lineCounter = 0
            for line in pcontent.split("\n"):
                if lineCounter == 0 and line.find("1:") == 0:
                    lineCounter += 1
                    continue
                content = content + line + "\n"
                lineCounter += 1
            content = content.strip()

            res = datamanager.findResourceByLabel(
                filename, match=Nepomuk.Query.ComparisonTerm.Equal)
            if not res:
                #newWord = datamanager.createResource(filename, QUrl("nepomuk:/res/c7f1509b-3eaa-4127-b28f-42f459678bcb"))

                newWord = datamanager.createResource(
                    filename,
                    QUrl("nepomuk:/res/36e59e2e-409a-40a8-9175-c929792383d2"))
                try:
                    newWord.setDescription(unicode(content))
                except Exception, e:
                    print filename
                    print e

                newResources.append(filename)

            else:
                #                    print filename
                #                    print res.genericLabel()
                #oldResources.append(res.genericLabel())
                oldResources.append(filename)