Esempio n. 1
0
    def _parse_meta(self, meta):
        content = meta.replace('\n', '')
        if not content:
            return {}

        docinfo = {}
        dom = minidom.parseString(utf8(content))
        for node in dom.getElementsByTagName('tr'):
            key, value = self._node_to_pairs(node)
            docinfo[key] = value
        return docinfo
Esempio n. 2
0
    def _parse_meta(self, meta):
        content = meta.replace('\n', '')
        if not content:
            return {}

        docinfo = {}
        dom = minidom.parseString(utf8(content))
        for node in dom.getElementsByTagName('tr'):
            key, value = self._node_to_pairs(node)
            docinfo[key] = value
        return docinfo
Esempio n. 3
0
    def write(self, content, destination):
        destination = destination.replace(' ', '-')
        folder = os.path.split(destination)[0]
        # on Mac OSX, `folder` == `FOLDER`
        # then make sure destination is lowercase
        if not os.path.isdir(folder):
            os.makedirs(folder)

        f = open(destination, 'w')
        f.write(utf8(content))
        f.close()
        return
Esempio n. 4
0
    def write(self, content, destination):
        destination = destination.replace(' ', '-')
        folder = os.path.split(destination)[0]
        # on Mac OSX, `folder` == `FOLDER`
        # then make sure destination is lowercase
        if not os.path.isdir(folder):
            os.makedirs(folder)

        f = open(destination, 'w')
        f.write(utf8(content))
        f.close()
        return
Esempio n. 5
0
def __load_themes(force=False):
    import time
    import tempfile
    path = os.path.join(tempfile.gettempdir(), 'liquidluck.json')

    if not os.path.exists(path) or \
       os.stat(path).st_mtime + 600 < time.time() or \
       force:
        content = __fetch_themes()
        if "repositories" not in content:
            return content
        f = open(path, 'w')
        f.write(utf8(content))
        f.close()

    content = to_unicode(open(path).read())
    return __filter_themes(content)
Esempio n. 6
0
def __load_themes(force=False):
    import time
    import tempfile
    path = os.path.join(tempfile.gettempdir(), 'liquidluck.json')

    if not os.path.exists(path) or \
       os.stat(path).st_mtime + 600 < time.time() or \
       force:
        content = __fetch_themes()
        if "repositories" not in content:
            return content
        f = open(path, 'w')
        f.write(utf8(content))
        f.close()

    content = to_unicode(open(path).read())
    return __filter_themes(content)