Exemplo n.º 1
0
def create__single_entry(isFile, path, name):
    '''
    create filesystem return object for file request
    :param isFile:
    :param path:
    :param name:
    :return:
    '''
    entry = Entry()
    if not isFile:
        entry.id = utils.connect_path(utils.connect_path(Config.SITE_BOOK_LIST,path),name)
        entry.links=[]
        entry.links.append(Link(entry.id, _get_book_entry_rel(name), name, _get_book_entry_type(name)))
    else:
        entry.id = utils.connect_path(utils.connect_path(Config.SITE_BOOK_LIST, path), name)
        #TODO add Another Links
        links=fs.getdownloadurl(os.path.dirname(path), name)
        entry.links=[]
        if links !=None:
            for link in links:
                entry.links.append(Link(link, _get_book_entry_rel(link), name, _get_book_entry_type(link)))
    entry.content = name
    entry.title = name
    entry.updated = utils.getNow()
    return entry
Exemplo n.º 2
0
    def __init__(self, doc , path=None):
        """
        Root Element
        :param doc:  Document()
        :return:
        """
        self.doc = doc
        # xml-stylesheet
        if fs.isfile(path):
            self.doc.appendChild(self.doc.createProcessingInstruction("xml-stylesheet","type=\"text/xsl\" href=\"%s/static/bookdetail.xsl\""%Config.SITE_URL))
        else:
            self.doc.appendChild(self.doc.createProcessingInstruction("xml-stylesheet","type=\"text/xsl\" href=\"%s/static/booklist.xsl\""%Config.SITE_URL))
        # feed
        self.feed = self.doc.createElement("feed")
        setfeedNS(self.feed)
        self.addNode(self.feed, Const.id, Config.SITE_URL)
        self.addNode(self.feed, Const.author, Config.SITE_EMAIL)
        self.addNode(self.feed, Const.title, Config.SITE_TITLE)
        self.addNode(self.feed, Const.updated, utils.getNow())
        self.addNode(self.feed, Const.description, Config.description)
        self.createLink(self.feed, Config.SITE_URL, "Home", "Home",
                        "application/atom+xml; profile=opds-catalog; kind=navigation")

        self.doc.appendChild(self.feed)
        pass
Exemplo n.º 3
0
    def detectData(self, local_path):
        '''
        read data from file mp3
        upload file into firebase
        funtion return song model
        '''
        file = eyed3.load(local_path)
        tag = file.tag

        resp_url = self.uploadFile(local_path, 'songs', tag.title + '.mp3')

        song = model.Song(utils.generateID(), tag.title, tag.artist, tag.album,
                          utils.getNow(), 0, 'No Lyris', resp_url)
        return song
Exemplo n.º 4
0
def root():
    d = Document()
    f = FeedDoc(d)
    entry = Entry()
    entry.id = Config.SITE_BOOK_LIST
    entry.content = "all Books List By Type"
    entry.title = "Book List"

    entry.updated = utils.getNow()
    # TODO add Another Links
    entry.links = [Link(entry.id, Const.book_link_rel_subsection, "Book List", Const.book_type_entry_catalog)]
    f.createEntry(entry)
    resp = make_response(f.toString())
    resp.headers['Content-Type'] = 'application/xml; profile=opds-catalog; kind=navigation'
    # print(f.toString())

    return resp
Exemplo n.º 5
0
from utils import getHtml
from utils import savesql
import utils
import json

fundlist = getHtml(
    'http://fund.eastmoney.com/js/fundcode_search.js').text().replace(
        'var r = ', '').strip()[:-1]
print(fundlist)

for flist in json.loads(fundlist):
    print(flist[0], flist[1], flist[2], flist[3], flist[4])
    sql = "insert into fund (id,abbreviation,name,type,alias,ctdt,status) values ('%s','%s','%s','%s','%s','%s','%s');" % (
        flist[0], flist[1], flist[2], flist[3], flist[4], utils.getNow(), 1)
    savesql(sql)