コード例 #1
0
ファイル: reader.py プロジェクト: vasnake/casebook
def collectCaseData(session, case, deep=2):
    '''Collect all information for given case.

    Sequence:
        card.case
        Card.PdfDocumentArchiveCaseCount - just num of docs - skip it
        card.casedocuments
        File.PdfDocumentArchiveCase
        for each judge
            Card.Judge
        for each side
            collectSideData

    URLs:
        GET http://casebook.ru/api/Card/Case
        GET http://casebook.ru/api/Card/CaseDocuments
        GET http://casebook.ru/File/PdfDocumentArchiveCase
        GET http://casebook.ru/api/Card/Judge

    :param casebook.http.HttpSession session: HTTP session wrapper
    :param dict case: case data from casebook.messages.JsonResponce
    :param bool deep: recursion limit
    '''
    if deep <= 0:
        print u"collectCaseData, end of recursion"
        return

    CaseId = case[u"CaseId"]
    print "collectCaseData, CaseId: %s" % CaseId
    if not CaseId:
        print "collectCaseData, CaseId is undefined, nothing to do"
        return

    # check if we already get this case today
    if caseDataIsFresh(CaseId):
        print "collectCaseData, case data downloaded already, nothing to do"
        return

    #~ карточка дела GET http://casebook.ru/api/Card/Case?id=78d283d0-010e-4c50-b1d1-cf2395c00bf9
    jsCardCase = cardCase(session, CaseId)

    #~ инфо о документах GET http://casebook.ru/api/Card/CaseDocuments?id=78d283d0-010e-4c50-b1d1-cf2395c00bf9
    __ = cardCaseDocuments(session, CaseId)

    #~ архив документов GET http://casebook.ru/File/PdfDocumentArchiveCase/78d283d0-010e-4c50-b1d1-cf2395c00bf9/%D0%9040-27010-2012.zip
    #~ Content-Type: application/zip
    filePdfDocumentArchiveCase(session, CaseId)

    caseJudges = getJudgesFromCase(jsCardCase)
    print "collectCaseData, num of case judges: %s" % len(caseJudges)
    for x in caseJudges:
        judge = utils.replaceNone(x)
        judgeID = judge[u'Id']
        print "Judge ID: %s" % judgeID
        #~ карточка судьи GET http://casebook.ru/api/Card/Judge/96743d1a-ca39-4c2f-a5f2-94a2aa0c8b8f
        __ = cardJudge(session, judgeID)

    stor.commit('cases', CaseId)

    caseSides = getSidesFromCase(jsCardCase)
    print "collectCaseData, num of case sides: %s" % len(caseSides)
    for x in caseSides:
        side = utils.replaceNone(x)
        print "collectCaseData, case sides, goto Side: %s" % sideShortName(side)
        # complex method, get data recursively (BusinessCard, BankruptCard)
        try:
            collectSideData(session, side, deep-1)
        except casebook.RequestError:
            print u"collectCaseData, cardCase, error while processing current side"
コード例 #2
0
def collectSideData(session, side, deep=2):
    '''Collect all information for given side

    Sequence:
        card.accountingstat
        card.excerpt
        search.sidesdetailsex
        calendar.period
        card.bankruptcard
            case info for each case mentioned
        card.businesscard
            side info for each side mentioned
        search.cases2
            case info for each: todo?
        search.casesgj
            case info for each: todo?

    URLs:
        GET http://casebook.ru/api/Card/Excerpt
        GET http://casebook.ru/api/Search/SidesDetailsEx
        POST http://casebook.ru/api/Card/AccountingStat
        POST http://casebook.ru/api/Calendar/Period
        POST http://casebook.ru/api/Card/BankruptCard
        POST http://casebook.ru/api/Card/BusinessCard
        POST http://casebook.ru/api/Search/Cases
        POST http://casebook.ru/api/Search/CasesGj

    :param casebook.http.HttpSession session: HTTP session wrapper
    :param dict side: side data from casebook.messages.JsonResponce
    :param bool deep: recursion limit
    '''
    if deep <= 0:
        print u"collectSideData, end of recursion"
        return

    ShortName = sideShortName(side)
    sid = utils.getSidePseudoID(side)
    print "collectSideData, side short name: %s" % ShortName

    # check if we already get this side today
    if sideDataIsFresh(sid):
        print "collectSideData, side data downloaded already, nothing to do"
        return

    #~ отчетность POST http://casebook.ru/api/Card/AccountingStat
    #~ payload {"Organization":{"Address": ...
    __ = cardAccountingStat(session, side)

    #~ выписка из ЕГРЮЛ
    #~ GET http://casebook.ru/api/Card/Excerpt?Address= ...
    cardExcerpt(session, side)

    # доп.сведения
    # GET http://casebook.ru/api/Search/SidesDetailsEx?index=1&inn=1106014140&okpo=3314561
    __ = searchSidesDetailsEx(session, side)

    # расписание событий POST http://casebook.ru/api/Calendar/Period
    # payload {...,"Sides":[{"Name":"ДИРЕКЦИЯ
    __ = calendarPeriod(session, side)

    # что-то про банкротство, внутри тянет case info for each case mentioned
    # POST http://casebook.ru/api/Card/BankruptCard
    # payload {"Address":"169300, РЕСПУБЛИКА КОМИ...","Inn":"1106014140","Name":"ДИРЕКЦИЯ ...","Ogrn":"1021100895760","Okpo":"3314561","IsUnique":false,"OrganizationId":""}
    jsCardBankruptCard = cardBankruptCard(session, side)

    #~ карточка участника POST http://casebook.ru/api/Card/BusinessCard
    jsCardBusinessCard = cardBusinessCard(session, side)

    # поиск дел с участием стороны
    # POST http://casebook.ru/api/Search/Cases
    # payload {"StatusEx":[],"SideTypes":[],"ConsiderType":-1,"CourtType":-1,"CaseNumber":null,"CaseCategoryId":"","MonitoredStatus":-1,"Courts":[],"Instances":[],"Judges":[],"Delegate":"","StateOrganizations":[],"DateFrom":null,"DateTo":null,"SessionFrom":null,"SessionTo":null,"FinalDocFrom":null,"FinalDocTo":null,"MinSum":0,"MaxSum":-1,"Sides":[{"Name":"ДИРЕКЦИЯ ...","ShortName":"ТПП ...","Inn":"1106014140","Ogrn":"1021100895760","Okpo":"3314561","Address":"169300, РЕСП...","IsUnique":false,"IsOriginal":true,"IsBranch":true},{"Name":"ДИР...","ShortName":"ТПП ...","Inn":"1106014140","Ogrn":"1021100895760","Okpo":"3314561","IsUnique":false,"OrganizationId":0,"Address":"169300, РЕСП...","IsBranch":true}],"CoSides":[],"Accuracy":0,"Page":1,"Count":30,"OrderBy":"incoming_date_ts desc","JudgesNames":[]}
    __ = searchCases4Side(session, side)

    # поиск дел общей юрисдикции
    # POST http://casebook.ru/api/Search/CasesGj
    # payload {"CoSides":[],"Count":30,"DateFrom":null,"DateTo":null,"OrderBy":"incoming_date_ts desc","Page":1,"Sides":[{"Name":"ДИРЕКЦИЯ...","ShortName":"ТПП ...","Inn":"1106014140","Ogrn":"1021100895760","Okpo":"3314561","Address":"169300, РЕСП...","IsUnique":false,"IsOriginal":true,"IsBranch":true},{"Name":"ДИРЕКЦИЯ ...","ShortName":"ТПП ...","Inn":"1106014140","Ogrn":"1021100895760","Okpo":"3314561","IsUnique":false,"OrganizationId":0,"Address":"169300, РЕСП...","IsBranch":true}],"CaseTypeId":"","Courts":[]}
    __ = searchCasesGj4Side(session, side)

    stor.commit('sides', sid)

    bankruptCases = getCasesFromBancruptCard(jsCardBankruptCard)
    print "collectSideData, num of cases in bankruptCard: %s" % len(
        bankruptCases)
    for x in bankruptCases:
        case = utils.replaceNone(x)
        case[u"CaseId"] = case.get(u'Id', u'')
        print u"collectSideData, cardBankruptCard, goto case: %s" % case.get(
            u'Number', u'')
        # complex method, recursion
        collectCaseData(session, case, deep - 1)
コード例 #3
0
ファイル: reader.py プロジェクト: vasnake/casebook
def collectSideData(session, side, deep=2):
    '''Collect all information for given side

    Sequence:
        card.accountingstat
        card.excerpt
        search.sidesdetailsex
        calendar.period
        card.bankruptcard
            case info for each case mentioned
        card.businesscard
            side info for each side mentioned
        search.cases2
            case info for each: todo?
        search.casesgj
            case info for each: todo?

    URLs:
        GET http://casebook.ru/api/Card/Excerpt
        GET http://casebook.ru/api/Search/SidesDetailsEx
        POST http://casebook.ru/api/Card/AccountingStat
        POST http://casebook.ru/api/Calendar/Period
        POST http://casebook.ru/api/Card/BankruptCard
        POST http://casebook.ru/api/Card/BusinessCard
        POST http://casebook.ru/api/Search/Cases
        POST http://casebook.ru/api/Search/CasesGj

    :param casebook.http.HttpSession session: HTTP session wrapper
    :param dict side: side data from casebook.messages.JsonResponce
    :param bool deep: recursion limit
    '''
    if deep <= 0:
        print u"collectSideData, end of recursion"
        return

    ShortName = sideShortName(side)
    sid = utils.getSidePseudoID(side)
    print "collectSideData, side short name: %s" % ShortName

    # check if we already get this side today
    if sideDataIsFresh(sid):
        print "collectSideData, side data downloaded already, nothing to do"
        return

    #~ отчетность POST http://casebook.ru/api/Card/AccountingStat
    #~ payload {"Organization":{"Address": ...
    __ = cardAccountingStat(session, side)

    #~ выписка из ЕГРЮЛ
    #~ GET http://casebook.ru/api/Card/Excerpt?Address= ...
    cardExcerpt(session, side)

    # доп.сведения
    # GET http://casebook.ru/api/Search/SidesDetailsEx?index=1&inn=1106014140&okpo=3314561
    __ = searchSidesDetailsEx(session, side)

    # расписание событий POST http://casebook.ru/api/Calendar/Period
    # payload {...,"Sides":[{"Name":"ДИРЕКЦИЯ
    __ = calendarPeriod(session, side)

    # что-то про банкротство, внутри тянет case info for each case mentioned
    # POST http://casebook.ru/api/Card/BankruptCard
    # payload {"Address":"169300, РЕСПУБЛИКА КОМИ...","Inn":"1106014140","Name":"ДИРЕКЦИЯ ...","Ogrn":"1021100895760","Okpo":"3314561","IsUnique":false,"OrganizationId":""}
    jsCardBankruptCard = cardBankruptCard(session, side)

    #~ карточка участника POST http://casebook.ru/api/Card/BusinessCard
    jsCardBusinessCard = cardBusinessCard(session, side)

    # поиск дел с участием стороны
    # POST http://casebook.ru/api/Search/Cases
    # payload {"StatusEx":[],"SideTypes":[],"ConsiderType":-1,"CourtType":-1,"CaseNumber":null,"CaseCategoryId":"","MonitoredStatus":-1,"Courts":[],"Instances":[],"Judges":[],"Delegate":"","StateOrganizations":[],"DateFrom":null,"DateTo":null,"SessionFrom":null,"SessionTo":null,"FinalDocFrom":null,"FinalDocTo":null,"MinSum":0,"MaxSum":-1,"Sides":[{"Name":"ДИРЕКЦИЯ ...","ShortName":"ТПП ...","Inn":"1106014140","Ogrn":"1021100895760","Okpo":"3314561","Address":"169300, РЕСП...","IsUnique":false,"IsOriginal":true,"IsBranch":true},{"Name":"ДИР...","ShortName":"ТПП ...","Inn":"1106014140","Ogrn":"1021100895760","Okpo":"3314561","IsUnique":false,"OrganizationId":0,"Address":"169300, РЕСП...","IsBranch":true}],"CoSides":[],"Accuracy":0,"Page":1,"Count":30,"OrderBy":"incoming_date_ts desc","JudgesNames":[]}
    __ = searchCases4Side(session, side)

    # поиск дел общей юрисдикции
    # POST http://casebook.ru/api/Search/CasesGj
    # payload {"CoSides":[],"Count":30,"DateFrom":null,"DateTo":null,"OrderBy":"incoming_date_ts desc","Page":1,"Sides":[{"Name":"ДИРЕКЦИЯ...","ShortName":"ТПП ...","Inn":"1106014140","Ogrn":"1021100895760","Okpo":"3314561","Address":"169300, РЕСП...","IsUnique":false,"IsOriginal":true,"IsBranch":true},{"Name":"ДИРЕКЦИЯ ...","ShortName":"ТПП ...","Inn":"1106014140","Ogrn":"1021100895760","Okpo":"3314561","IsUnique":false,"OrganizationId":0,"Address":"169300, РЕСП...","IsBranch":true}],"CaseTypeId":"","Courts":[]}
    __ = searchCasesGj4Side(session, side)

    stor.commit('sides', sid)

    bankruptCases = getCasesFromBancruptCard(jsCardBankruptCard)
    print "collectSideData, num of cases in bankruptCard: %s" % len(bankruptCases)
    for x in bankruptCases:
        case = utils.replaceNone(x)
        case[u"CaseId"] = case.get(u'Id', u'')
        print u"collectSideData, cardBankruptCard, goto case: %s" % case.get(u'Number', u'')
        # complex method, recursion
        collectCaseData(session, case, deep-1)

    businessSides = getSidesFromBusinessCard(jsCardBusinessCard)
    print "collectSideData, num of sides in businessCard: %s" % len(businessSides)
    for x in businessSides:
        bside = utils.replaceNone(x)
        print u"collectSideData, cardBusinessCard, goto side: %s" % sideShortName(bside)
        # complex method, get data recursively
        try:
            collectSideData(session, bside, deep-1)
        except casebook.RequestError:
            print u"collectSideData, cardBusinessCard, error while processing current side"
コード例 #4
0
    bankruptCases = getCasesFromBancruptCard(jsCardBankruptCard)
    print "collectSideData, num of cases in bankruptCard: %s" % len(
        bankruptCases)
    for x in bankruptCases:
        case = utils.replaceNone(x)
        case[u"CaseId"] = case.get(u'Id', u'')
        print u"collectSideData, cardBankruptCard, goto case: %s" % case.get(
            u'Number', u'')
        # complex method, recursion
        collectCaseData(session, case, deep - 1)

    businessSides = getSidesFromBusinessCard(jsCardBusinessCard)
    print "collectSideData, num of sides in businessCard: %s" % len(
        businessSides)
    for x in businessSides:
        bside = utils.replaceNone(x)
        print u"collectSideData, cardBusinessCard, goto side: %s" % sideShortName(
            bside)
        # complex method, get data recursively
        try:
            collectSideData(session, bside, deep - 1)
        except casebook.RequestError:
            print u"collectSideData, cardBusinessCard, error while processing current side"


def collectCaseData(session, case, deep=2):
    '''Collect all information for given case.

    Sequence:
        card.case
        Card.PdfDocumentArchiveCaseCount - just num of docs - skip it