コード例 #1
0
ファイル: docserver.py プロジェクト: EQ4/pycompmusic
def create_document(collection, document, title=None):
    path = "/document/by-id/%s" % document
    data = {"collection": collection}
    if title:
        data["title"] = title
    url = conn._make_url(path)
    req = conn._dunya_post(url, data=data)
    return req.json()
コード例 #2
0
ファイル: docserver.py プロジェクト: oriolromani/pycompmusic
def create_document(collection, document, title=None):
    path = "/document/by-id/%s" % document
    data = {"collection": collection}
    if title:
        data["title"] = title
    url = conn._make_url(path)
    req = conn._dunya_post(url, data=data)
    return req.json()
コード例 #3
0
ファイル: docserver.py プロジェクト: EQ4/pycompmusic
def add_sourcetype(document, filetype, file):
    """ If file is a string and refers to a file on disk, the contents
        of the file is read and send, otherwise it is sent as-is """
    path = "/document/by-id/%s/add/%s" % (document, filetype)
    if isinstance(file, basestring) and os.path.exists(file):
        f = open(file, "rb")
    else:
        f = file
    files = {"file": f}
    url = conn._make_url(path)
    req = conn._dunya_post(url, files=files)
    return req.json()
コード例 #4
0
ファイル: docserver.py プロジェクト: oriolromani/pycompmusic
def add_sourcetype(document, filetype, file):
    """ If file is a string and refers to a file on disk, the contents
        of the file is read and send, otherwise it is sent as-is """
    path = "/document/by-id/%s/add/%s" % (document, filetype)
    if isinstance(file, basestring) and os.path.exists(file):
        f = open(file, "rb")
    else:
        f = file
    files = {"file": f}
    url = conn._make_url(path)
    req = conn._dunya_post(url, files=files)
    return req.json()