How to use the pymarc.record.Record function in pymarc

To help you get started, we’ve selected a few pymarc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github edsu / pymarc / test / test_record.py View on Github external
def test_title(self):
        record = Record()
        self.assertEqual(record.title(), None)
        record.add_field(Field("245", [0, 1], subfields=["a", "Foo :", "b", "bar"]))
        self.assertEqual(record.title(), "Foo : bar")

        record = Record()
        record.add_field(Field("245", [0, 1], subfields=["a", "Farghin"]))
        self.assertEqual(record.title(), "Farghin")
github edsu / pymarc / test / test_record.py View on Github external
def test_as_marc_consistency(self):
        record = Record()
        leadertype = type(record.leader)
        record.as_marc()
        self.assertEqual(leadertype, type(record.leader))
github edsu / pymarc / test / test_record.py View on Github external
def test_publisher(self):
        record = Record()
        self.assertEqual(record.publisher(), None)
        record.add_field(
            Field(
                "260",
                [" ", " "],
                subfields=[
                    "a",
                    "Paris :",
                    "b",
                    "Gauthier-Villars ;",
                    "a",
                    "Chicago :",
                    "b",
                    "University of Chicago Press,",
                    "c",
                    "1955.",
github edsu / pymarc / test / test_record.py View on Github external
def test_added_entries(self):
        record = Record()
        ae1 = "=730  0\\$aTosefta.$lEnglish.$f1977."
        ae2 = "=700  10$aLe Peu, Pepe."
        aelist = [ae1, ae2]
        self.assertEqual(record.addedentries(), [])
        record.add_field(
            Field(
                "730",
                [0, " "],
                subfields=["a", "Tosefta.", "l", "English.", "f", "1977."],
            )
        )
        record.add_field(Field("700", [1, 0], subfields=["a", "Le Peu, Pepe."]))
        record.add_field(Field("245", [0, 0], subfields=["a", "Le Peu's Tosefa."]))
        self.assertEqual(len(record.addedentries()), 2)
        self.assertEqual(record.addedentries()[0].__str__(), ae1)
        self.assertEqual(record.addedentries()[1].__str__(), ae2)
github unt-libraries / catalog-api / django / sierra / blacklight / sierra2marc_alpha_solrmarc_02.py View on Github external
def compile_original_marc(self, r):
        marc_record = pymarc.record.Record(force_utf8=True)
        marc_record.add_ordered_field(*self.compile_control_fields(r))
        marc_record.add_ordered_field(*self.compile_varfields(r))
        return marc_record
github gwu-libraries / launchpad / lp / ui / catalogs / z3950.py View on Github external
holdmeta['note'] = rec[1].publicNote.rstrip('\x00')
                if hasattr(rec[1], 'circulationData'):
                    holdmeta['status'] = rec[1].circulationData[0].availableNow
                if holdmeta['status'] is True or\
                        holdmeta['status'] == ' AVAILABLE':
                    holdmeta['status'] = 'Not Charged'
                    holdmeta['item_status'] = 1
                marc = pymarc.record.Record(zoom_record.data.
                                            bibliographicRecord.encoding[1])
                if marc['856']:
                    holdmeta['url'] = marc['856']['u']
                    holdmeta['msg'] = marc['856']['z']
                holdings.append(holdmeta)
            return holdings
        if hasattr(zoom_record, 'data'):
            marc = pymarc.record.Record(zoom_record.data)
            if marc['856']:
                holdmeta['url'] = marc['856']['u']
                holdmeta['msg'] = marc['856']['z']
                holdmeta['callnum'] = ''
                holdmeta['status'] = ''
                holdmeta['note'] = ''
                holdmeta['item_status'] = 0
                holdmeta['location'] = ''
                holdings.append(holdmeta)
                return holdings
            else:
                return [{'item_status': 0, 'location': '', 'callnum': '',
                         'status': '', 'url': '', 'note': '', 'msg': ''}]
        return [{'item_status': 0, 'location': '', 'callnum': '', 'status': '',
                'url': '', 'note': '', 'msg': ''}]