def test_party_type_normalization(self):
     pairs = [
         {
             "q": "Defendant                                 (1)",
             "a": "Defendant",
         },
         {"q": "Debtor 2", "a": "Debtor",},
         {"q": "ThirdParty Defendant", "a": "Third Party Defendant",},
         {"q": "ThirdParty Plaintiff", "a": "Third Party Plaintiff",},
         {"q": "3rd Pty Defendant", "a": "Third Party Defendant",},
         {"q": "3rd party defendant", "a": "Third Party Defendant",},
         {"q": "Counter-defendant", "a": "Counter Defendant",},
         {"q": "Counter-Claimaint", "a": "Counter Claimaint",},
         {"q": "US Trustee", "a": "U.S. Trustee",},
         {"q": "United States Trustee", "a": "U.S. Trustee",},
         {"q": "U. S. Trustee", "a": "U.S. Trustee",},
         {"q": "BUS BOY", "a": "Bus Boy",},
         {"q": "JointAdmin Debtor", "a": "Jointly Administered Debtor",},
         {"q": "Intervenor-Plaintiff", "a": "Intervenor Plaintiff",},
         {"q": "Intervenor Dft", "a": "Intervenor Defendant",},
     ]
     for pair in pairs:
         print(
             "Normalizing PACER type of '%s' to '%s'..."
             % (pair["q"], pair["a"]),
             end="",
         )
         result = normalize_party_types(pair["q"])
         self.assertEqual(result, pair["a"])
         print("✓")
Esempio n. 2
0
 def test_party_type_normalization(self):
     pairs = [{
         'q': 'Defendant                                 (1)',
         'a': 'Defendant'
     }, {
         'q': 'Debtor 2',
         'a': 'Debtor',
     }, {
         'q': 'ThirdParty Defendant',
         'a': 'Third Party Defendant',
     }, {
         'q': 'ThirdParty Plaintiff',
         'a': 'Third Party Plaintiff',
     }, {
         'q': '3rd Pty Defendant',
         'a': 'Third Party Defendant',
     }, {
         'q': '3rd party defendant',
         'a': 'Third Party Defendant',
     }, {
         'q': 'Counter-defendant',
         'a': 'Counter Defendant',
     }, {
         'q': 'Counter-Claimaint',
         'a': 'Counter Claimaint',
     }, {
         'q': 'US Trustee',
         'a': 'U.S. Trustee',
     }, {
         'q': 'United States Trustee',
         'a': 'U.S. Trustee',
     }, {
         'q': 'U. S. Trustee',
         'a': 'U.S. Trustee',
     }, {
         'q': 'BUS BOY',
         'a': 'Bus Boy',
     }, {
         'q': 'JointAdmin Debtor',
         'a': 'Jointly Administered Debtor',
     }, {
         'q': 'Intervenor-Plaintiff',
         'a': 'Intervenor Plaintiff',
     }, {
         'q': 'Intervenor Dft',
         'a': 'Intervenor Defendant',
     }]
     for pair in pairs:
         print("Normalizing PACER type of '%s' to '%s'..." %
               (pair['q'], pair['a']),
               end='')
         result = normalize_party_types(pair['q'])
         self.assertEqual(result, pair['a'])
         print('✓')
 def test_party_type_normalization(self):
     pairs = [{
         'q': 'Defendant                                 (1)',
         'a': 'Defendant'
     }, {
         'q': 'Debtor 2',
         'a': 'Debtor',
     }, {
         'q': 'ThirdParty Defendant',
         'a': 'Third Party Defendant',
     }, {
         'q': 'ThirdParty Plaintiff',
         'a': 'Third Party Plaintiff',
     }, {
         'q': '3rd Pty Defendant',
         'a': 'Third Party Defendant',
     }, {
         'q': '3rd party defendant',
         'a': 'Third Party Defendant',
     }, {
         'q': 'Counter-defendant',
         'a': 'Counter Defendant',
     }, {
         'q': 'Counter-Claimaint',
         'a': 'Counter Claimaint',
     }, {
         'q': 'US Trustee',
         'a': 'U.S. Trustee',
     }, {
         'q': 'United States Trustee',
         'a': 'U.S. Trustee',
     }, {
         'q': 'U. S. Trustee',
         'a': 'U.S. Trustee',
     }, {
         'q': 'BUS BOY',
         'a': 'Bus Boy',
     }, {
         'q': 'JointAdmin Debtor',
         'a': 'Jointly Administered Debtor',
     }, {
         'q': 'Intervenor-Plaintiff',
         'a': 'Intervenor Plaintiff',
     }, {
         'q': 'Intervenor Dft',
         'a': 'Intervenor Defendant',
     }]
     for pair in pairs:
         print("Normalizing PACER type of '%s' to '%s'..." %
               (pair['q'], pair['a']), end='')
         result = normalize_party_types(pair['q'])
         self.assertEqual(result, pair['a'])
         print('✓')
Esempio n. 4
0
    def make_parties(self, docket, debug):
        """Pull out the parties and their attorneys and save them to the DB."""
        atty_obj_cache = {}
        for party_node in self.party_list:
            party_name = self.get_str_from_node(party_node, 'name')
            party_type = self.get_str_from_node(party_node, 'type')
            party_type = normalize_party_types(party_type)
            party_extra_info = self.get_str_from_node(party_node, 'extra_info')
            logger.info("Working on party '%s' of type '%s'" %
                        (party_name, party_type))

            try:
                party = Party.objects.get(name=party_name)
            except Party.DoesNotExist:
                party = Party(
                    name=party_name,
                    extra_info=party_extra_info,
                )
                if not debug:
                    try:
                        party.save()
                    except IntegrityError:
                        party = Party.objects.get(name=party_name)

            if party_extra_info and not debug:
                party.extra_info = party_extra_info
                party.save()

            # If the party type doesn't exist, make a new one.
            if not party.party_types.filter(docket=docket,
                                            name=party_type).exists():
                pt = PartyType(
                    docket=docket,
                    party=party,
                    name=party_type,
                )
                if not debug:
                    pt.save()

            self.add_attorneys(docket, party_node, party, atty_obj_cache,
                               debug)