• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

iplweb / bpp / 18634744198

19 Oct 2025 07:00PM UTC coverage: 31.618% (-29.9%) from 61.514%
18634744198

push

github

mpasternak
Merge branch 'release/v202510.1270'

657 of 9430 branches covered (6.97%)

Branch coverage included in aggregate %.

229 of 523 new or added lines in 42 files covered. (43.79%)

11303 existing lines in 316 files now uncovered.

14765 of 39346 relevant lines covered (37.53%)

0.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

2.62
src/bpp/export/bibtex.py
1
"""
2
BibTeX export functionality for BPP publication models.
3

4
This module provides utilities to export Wydawnictwo_Ciagle and Wydawnictwo_Zwarte
5
models to BibTeX format.
6
"""
7

8
import re
1✔
9

10

11
def sanitize_bibtex_string(text: str) -> str:
1✔
12
    """
13
    Sanitize a string for use in BibTeX format.
14

15
    Args:
16
        text: Input string to sanitize
17

18
    Returns:
19
        Sanitized string safe for BibTeX
20
    """
UNCOV
21
    if not text:
×
UNCOV
22
        return ""
×
23

24
    # Remove or replace problematic characters
UNCOV
25
    text = str(text)
×
UNCOV
26
    text = text.replace("{", "\\{")
×
UNCOV
27
    text = text.replace("}", "\\}")
×
UNCOV
28
    text = text.replace("&", "\\&")
×
UNCOV
29
    text = text.replace("%", "\\%")
×
UNCOV
30
    text = text.replace("$", "\\$")
×
UNCOV
31
    text = text.replace("#", "\\#")
×
UNCOV
32
    text = text.replace("_", "\\_")
×
UNCOV
33
    text = text.replace("^", "\\^")
×
UNCOV
34
    text = text.replace("~", "\\~")
×
35

UNCOV
36
    return text.strip()
×
37

38

39
def format_authors_bibtex(wydawnictwo) -> str:
1✔
40
    """
41
    Format authors for BibTeX export.
42

43
    Args:
44
        wydawnictwo: Wydawnictwo_Ciagle or Wydawnictwo_Zwarte instance
45

46
    Returns:
47
        Formatted author string for BibTeX
48
    """
UNCOV
49
    authors = []
×
UNCOV
50
    try:
×
UNCOV
51
        for autor_obj in wydawnictwo.autorzy_dla_opisu():
×
UNCOV
52
            if hasattr(autor_obj, "zapisany_jako") and autor_obj.zapisany_jako:
×
UNCOV
53
                authors.append(autor_obj.zapisany_jako)
×
54
            elif hasattr(autor_obj, "autor"):
×
55
                full_name = f"{autor_obj.autor.nazwisko} {autor_obj.autor.imiona}"
×
56
                authors.append(full_name)
×
57
    except Exception:
×
58
        # Fallback to cached authors if available
59
        if (
×
60
            hasattr(wydawnictwo, "opis_bibliograficzny_autorzy_cache")
61
            and wydawnictwo.opis_bibliograficzny_autorzy_cache
62
        ):
63
            # The cached authors are already in "LastName FirstName" format
64
            authors = wydawnictwo.opis_bibliograficzny_autorzy_cache
×
65

UNCOV
66
    return " and ".join(authors)
×
67

68

69
def generate_bibtex_key(wydawnictwo) -> str:
1✔
70
    """
71
    Generate a unique BibTeX citation key.
72

73
    Args:
74
        wydawnictwo: Wydawnictwo_Ciagle or Wydawnictwo_Zwarte instance
75

76
    Returns:
77
        Generated BibTeX key
78
    """
79
    # Use first author's surname if available
UNCOV
80
    key_parts = []
×
81

UNCOV
82
    try:
×
UNCOV
83
        first_author = wydawnictwo.autorzy_dla_opisu().first()
×
UNCOV
84
        if first_author and hasattr(first_author, "autor"):
×
UNCOV
85
            surname = first_author.autor.nazwisko
×
86
            # Clean surname for key
UNCOV
87
            surname = re.sub(r"[^a-zA-Z0-9]", "", surname)
×
UNCOV
88
            key_parts.append(surname)
×
UNCOV
89
    except Exception:
×
UNCOV
90
        pass
×
91

92
    # Add year
UNCOV
93
    if hasattr(wydawnictwo, "rok") and wydawnictwo.rok:
×
UNCOV
94
        key_parts.append(str(wydawnictwo.rok))
×
95

96
    # Add ID as fallback or uniqueness
UNCOV
97
    key_parts.append(f"id{wydawnictwo.pk}")
×
98

UNCOV
99
    return "_".join(key_parts)
×
100

101

102
def wydawnictwo_ciagle_to_bibtex(wydawnictwo_ciagle) -> str:
1✔
103
    """
104
    Convert Wydawnictwo_Ciagle instance to BibTeX format.
105

106
    Args:
107
        wydawnictwo_ciagle: Wydawnictwo_Ciagle model instance
108

109
    Returns:
110
        BibTeX formatted string
111
    """
UNCOV
112
    key = generate_bibtex_key(wydawnictwo_ciagle)
×
UNCOV
113
    authors = format_authors_bibtex(wydawnictwo_ciagle)
×
114

UNCOV
115
    bibtex_entry = f"@article{{{key},\n"
×
116

117
    # Title
UNCOV
118
    if wydawnictwo_ciagle.tytul_oryginalny:
×
UNCOV
119
        title = sanitize_bibtex_string(wydawnictwo_ciagle.tytul_oryginalny)
×
UNCOV
120
        bibtex_entry += f"  title = {{{title}}},\n"
×
121

122
    # Authors
UNCOV
123
    if authors:
×
UNCOV
124
        bibtex_entry += f"  author = {{{sanitize_bibtex_string(authors)}}},\n"
×
125

126
    # Journal
UNCOV
127
    if hasattr(wydawnictwo_ciagle, "zrodlo") and wydawnictwo_ciagle.zrodlo:
×
UNCOV
128
        journal = sanitize_bibtex_string(wydawnictwo_ciagle.zrodlo.nazwa)
×
UNCOV
129
        bibtex_entry += f"  journal = {{{journal}}},\n"
×
130

131
    # Year
UNCOV
132
    if wydawnictwo_ciagle.rok:
×
UNCOV
133
        bibtex_entry += f"  year = {{{wydawnictwo_ciagle.rok}}},\n"
×
134

135
    # Volume (tom)
UNCOV
136
    if hasattr(wydawnictwo_ciagle, "numer_tomu") and wydawnictwo_ciagle.numer_tomu():
×
137
        volume = sanitize_bibtex_string(str(wydawnictwo_ciagle.numer_tomu()))
×
138
        bibtex_entry += f"  volume = {{{volume}}},\n"
×
139

140
    # Number (numer wydania/zeszytu)
UNCOV
141
    if (
×
142
        hasattr(wydawnictwo_ciagle, "numer_wydania")
143
        and wydawnictwo_ciagle.numer_wydania()
144
    ):
145
        number = sanitize_bibtex_string(str(wydawnictwo_ciagle.numer_wydania()))
×
146
        bibtex_entry += f"  number = {{{number}}},\n"
×
147

148
    # Pages
UNCOV
149
    if (
×
150
        hasattr(wydawnictwo_ciagle, "zakres_stron")
151
        and wydawnictwo_ciagle.zakres_stron()
152
    ):
UNCOV
153
        pages = sanitize_bibtex_string(str(wydawnictwo_ciagle.zakres_stron()))
×
UNCOV
154
        bibtex_entry += f"  pages = {{{pages}}},\n"
×
155

156
    # DOI
UNCOV
157
    if hasattr(wydawnictwo_ciagle, "doi") and wydawnictwo_ciagle.doi:
×
UNCOV
158
        doi = sanitize_bibtex_string(wydawnictwo_ciagle.doi)
×
UNCOV
159
        bibtex_entry += f"  doi = {{{doi}}},\n"
×
160

161
    # ISSN
UNCOV
162
    if hasattr(wydawnictwo_ciagle, "issn") and wydawnictwo_ciagle.issn:
×
UNCOV
163
        issn = sanitize_bibtex_string(wydawnictwo_ciagle.issn)
×
UNCOV
164
        bibtex_entry += f"  issn = {{{issn}}},\n"
×
165

166
    # URL
UNCOV
167
    if hasattr(wydawnictwo_ciagle, "www") and wydawnictwo_ciagle.www:
×
UNCOV
168
        url = sanitize_bibtex_string(wydawnictwo_ciagle.www)
×
UNCOV
169
        bibtex_entry += f"  url = {{{url}}},\n"
×
170

171
    # Remove trailing comma and newline, add closing brace
UNCOV
172
    bibtex_entry = bibtex_entry.rstrip(",\n") + "\n}\n"
×
173

UNCOV
174
    return bibtex_entry
×
175

176

177
def wydawnictwo_zwarte_to_bibtex(wydawnictwo_zwarte) -> str:
1✔
178
    """
179
    Convert Wydawnictwo_Zwarte instance to BibTeX format.
180

181
    Args:
182
        wydawnictwo_zwarte: Wydawnictwo_Zwarte model instance
183

184
    Returns:
185
        BibTeX formatted string
186
    """
UNCOV
187
    key = generate_bibtex_key(wydawnictwo_zwarte)
×
UNCOV
188
    authors = format_authors_bibtex(wydawnictwo_zwarte)
×
189

190
    # Determine entry type based on characteristics
UNCOV
191
    entry_type = "book"
×
UNCOV
192
    if (
×
193
        hasattr(wydawnictwo_zwarte, "wydawnictwo_nadrzedne")
194
        and wydawnictwo_zwarte.wydawnictwo_nadrzedne
195
    ):
UNCOV
196
        entry_type = "incollection"  # Chapter in book
×
UNCOV
197
    elif (
×
198
        hasattr(wydawnictwo_zwarte, "charakter_formalny")
199
        and wydawnictwo_zwarte.charakter_formalny
200
    ):
UNCOV
201
        charakter = wydawnictwo_zwarte.charakter_formalny.nazwa.lower()
×
UNCOV
202
        if "rozdział" in charakter or "chapter" in charakter:
×
203
            entry_type = "incollection"
×
UNCOV
204
        elif "konferencja" in charakter or "conference" in charakter:
×
205
            entry_type = "inproceedings"
×
206

UNCOV
207
    bibtex_entry = f"@{entry_type}{{{key},\n"
×
208

209
    # Title
UNCOV
210
    if wydawnictwo_zwarte.tytul_oryginalny:
×
UNCOV
211
        title = sanitize_bibtex_string(wydawnictwo_zwarte.tytul_oryginalny)
×
UNCOV
212
        bibtex_entry += f"  title = {{{title}}},\n"
×
213

214
    # Authors
UNCOV
215
    if authors:
×
UNCOV
216
        bibtex_entry += f"  author = {{{sanitize_bibtex_string(authors)}}},\n"
×
217

218
    # Publisher
UNCOV
219
    if (
×
220
        hasattr(wydawnictwo_zwarte, "get_wydawnictwo")
221
        and wydawnictwo_zwarte.get_wydawnictwo()
222
    ):
UNCOV
223
        publisher = sanitize_bibtex_string(wydawnictwo_zwarte.get_wydawnictwo())
×
UNCOV
224
        bibtex_entry += f"  publisher = {{{publisher}}},\n"
×
225

226
    # Year and address from miejsce_i_rok
UNCOV
227
    if (
×
228
        hasattr(wydawnictwo_zwarte, "miejsce_i_rok")
229
        and wydawnictwo_zwarte.miejsce_i_rok
230
    ):
UNCOV
231
        miejsce_i_rok = wydawnictwo_zwarte.miejsce_i_rok.strip()
×
232
        # Try to extract address and year
UNCOV
233
        parts = miejsce_i_rok.split()
×
UNCOV
234
        if parts:
×
235
            # Last part might be year if it's 4 digits
UNCOV
236
            if len(parts) > 1 and re.match(r"\d{4}", parts[-1]):
×
237
                # year_from_field = parts[-1]
UNCOV
238
                address = " ".join(parts[:-1])
×
UNCOV
239
                if address:
×
UNCOV
240
                    bibtex_entry += (
×
241
                        f"  address = {{{sanitize_bibtex_string(address)}}},\n"
242
                    )
243
            else:
244
                # Whole field as address
245
                bibtex_entry += (
×
246
                    f"  address = {{{sanitize_bibtex_string(miejsce_i_rok)}}},\n"
247
                )
248

249
    # Year
UNCOV
250
    if wydawnictwo_zwarte.rok:
×
UNCOV
251
        bibtex_entry += f"  year = {{{wydawnictwo_zwarte.rok}}},\n"
×
252

253
    # Pages
UNCOV
254
    if hasattr(wydawnictwo_zwarte, "strony") and wydawnictwo_zwarte.strony:
×
UNCOV
255
        pages = sanitize_bibtex_string(wydawnictwo_zwarte.strony)
×
UNCOV
256
        bibtex_entry += f"  pages = {{{pages}}},\n"
×
257

258
    # For chapters, add booktitle (parent publication)
UNCOV
259
    if (
×
260
        entry_type == "incollection"
261
        and hasattr(wydawnictwo_zwarte, "wydawnictwo_nadrzedne")
262
        and wydawnictwo_zwarte.wydawnictwo_nadrzedne
263
    ):
UNCOV
264
        if wydawnictwo_zwarte.wydawnictwo_nadrzedne.tytul_oryginalny:
×
UNCOV
265
            booktitle = sanitize_bibtex_string(
×
266
                wydawnictwo_zwarte.wydawnictwo_nadrzedne.tytul_oryginalny
267
            )
UNCOV
268
            bibtex_entry += f"  booktitle = {{{booktitle}}},\n"
×
269

270
    # DOI
UNCOV
271
    if hasattr(wydawnictwo_zwarte, "doi") and wydawnictwo_zwarte.doi:
×
272
        doi = sanitize_bibtex_string(wydawnictwo_zwarte.doi)
×
273
        bibtex_entry += f"  doi = {{{doi}}},\n"
×
274

275
    # ISBN
UNCOV
276
    if hasattr(wydawnictwo_zwarte, "isbn") and wydawnictwo_zwarte.isbn:
×
UNCOV
277
        isbn = sanitize_bibtex_string(wydawnictwo_zwarte.isbn)
×
UNCOV
278
        bibtex_entry += f"  isbn = {{{isbn}}},\n"
×
279

280
    # URL
UNCOV
281
    if hasattr(wydawnictwo_zwarte, "www") and wydawnictwo_zwarte.www:
×
UNCOV
282
        url = sanitize_bibtex_string(wydawnictwo_zwarte.www)
×
UNCOV
283
        bibtex_entry += f"  url = {{{url}}},\n"
×
284

285
    # Edition
UNCOV
286
    if (
×
287
        hasattr(wydawnictwo_zwarte, "oznaczenie_wydania")
288
        and wydawnictwo_zwarte.oznaczenie_wydania
289
    ):
290
        edition = sanitize_bibtex_string(wydawnictwo_zwarte.oznaczenie_wydania)
×
291
        bibtex_entry += f"  edition = {{{edition}}},\n"
×
292

293
    # Series
UNCOV
294
    if (
×
295
        hasattr(wydawnictwo_zwarte, "seria_wydawnicza")
296
        and wydawnictwo_zwarte.seria_wydawnicza
297
    ):
298
        series = sanitize_bibtex_string(wydawnictwo_zwarte.seria_wydawnicza.nazwa)
×
299
        bibtex_entry += f"  series = {{{series}}},\n"
×
300

301
    # Remove trailing comma and newline, add closing brace
UNCOV
302
    bibtex_entry = bibtex_entry.rstrip(",\n") + "\n}\n"
×
303

UNCOV
304
    return bibtex_entry
×
305

306

307
def patent_to_bibtex(patent) -> str:
1✔
308
    """
309
    Convert Patent instance to BibTeX format.
310

311
    Args:
312
        patent: Patent model instance
313

314
    Returns:
315
        BibTeX formatted string
316
    """
UNCOV
317
    key = generate_bibtex_key(patent)
×
UNCOV
318
    authors = format_authors_bibtex(patent)
×
319

UNCOV
320
    bibtex_entry = f"@misc{{{key},\n"
×
321

322
    # Title
UNCOV
323
    if patent.tytul_oryginalny:
×
UNCOV
324
        title = sanitize_bibtex_string(patent.tytul_oryginalny)
×
UNCOV
325
        bibtex_entry += f"  title = {{{title}}},\n"
×
326

327
    # Authors
UNCOV
328
    if authors:
×
UNCOV
329
        bibtex_entry += f"  author = {{{sanitize_bibtex_string(authors)}}},\n"
×
330

331
    # Year
UNCOV
332
    if patent.rok:
×
UNCOV
333
        bibtex_entry += f"  year = {{{patent.rok}}},\n"
×
334

335
    # Note with patent-specific information
UNCOV
336
    note_parts = []
×
UNCOV
337
    if hasattr(patent, "numer_zgloszenia") and patent.numer_zgloszenia:
×
UNCOV
338
        note_parts.append(f"Numer zgłoszenia: {patent.numer_zgloszenia}")
×
339

UNCOV
340
    if hasattr(patent, "numer_prawa_wylacznego") and patent.numer_prawa_wylacznego:
×
UNCOV
341
        note_parts.append(f"Numer prawa wyłącznego: {patent.numer_prawa_wylacznego}")
×
342

UNCOV
343
    if hasattr(patent, "data_zgloszenia") and patent.data_zgloszenia:
×
UNCOV
344
        note_parts.append(f"Data zgłoszenia: {patent.data_zgloszenia}")
×
345

UNCOV
346
    if hasattr(patent, "data_decyzji") and patent.data_decyzji:
×
UNCOV
347
        note_parts.append(f"Data decyzji: {patent.data_decyzji}")
×
348

UNCOV
349
    if note_parts:
×
UNCOV
350
        note = sanitize_bibtex_string(". ".join(note_parts))
×
UNCOV
351
        bibtex_entry += f"  note = {{{note}}},\n"
×
352

353
    # URL
UNCOV
354
    if hasattr(patent, "www") and patent.www:
×
UNCOV
355
        url = sanitize_bibtex_string(patent.www)
×
UNCOV
356
        bibtex_entry += f"  url = {{{url}}},\n"
×
357

358
    # Remove trailing comma and newline, add closing brace
UNCOV
359
    bibtex_entry = bibtex_entry.rstrip(",\n") + "\n}\n"
×
360

UNCOV
361
    return bibtex_entry
×
362

363

364
def praca_doktorska_to_bibtex(praca_doktorska) -> str:
1✔
365
    """
366
    Convert Praca_Doktorska instance to BibTeX format.
367

368
    Args:
369
        praca_doktorska: Praca_Doktorska model instance
370

371
    Returns:
372
        BibTeX formatted string
373
    """
UNCOV
374
    key = generate_bibtex_key(praca_doktorska)
×
UNCOV
375
    authors = format_authors_bibtex(praca_doktorska)
×
376

UNCOV
377
    bibtex_entry = f"@phdthesis{{{key},\n"
×
378

379
    # Title
UNCOV
380
    if praca_doktorska.tytul_oryginalny:
×
UNCOV
381
        title = sanitize_bibtex_string(praca_doktorska.tytul_oryginalny)
×
UNCOV
382
        bibtex_entry += f"  title = {{{title}}},\n"
×
383

384
    # Author
UNCOV
385
    if authors:
×
UNCOV
386
        bibtex_entry += f"  author = {{{sanitize_bibtex_string(authors)}}},\n"
×
387

388
    # School (University)
UNCOV
389
    if hasattr(praca_doktorska, "jednostka") and praca_doktorska.jednostka:
×
UNCOV
390
        if (
×
391
            hasattr(praca_doktorska.jednostka, "wydzial")
392
            and praca_doktorska.jednostka.wydzial
393
        ):
UNCOV
394
            school = sanitize_bibtex_string(praca_doktorska.jednostka.wydzial.nazwa)
×
UNCOV
395
            bibtex_entry += f"  school = {{{school}}},\n"
×
396

397
    # Year
UNCOV
398
    if praca_doktorska.rok:
×
UNCOV
399
        bibtex_entry += f"  year = {{{praca_doktorska.rok}}},\n"
×
400

401
    # Type
UNCOV
402
    bibtex_entry += "  type = {Rozprawa doktorska},\n"
×
403

404
    # Publisher/address from miejsce_i_rok
UNCOV
405
    if hasattr(praca_doktorska, "miejsce_i_rok") and praca_doktorska.miejsce_i_rok:
×
UNCOV
406
        miejsce_i_rok = praca_doktorska.miejsce_i_rok.strip()
×
407
        # Try to extract address and year
UNCOV
408
        parts = miejsce_i_rok.split()
×
UNCOV
409
        if parts:
×
410
            # Last part might be year if it's 4 digits
UNCOV
411
            if len(parts) > 1 and re.match(r"\d{4}", parts[-1]):
×
UNCOV
412
                address = " ".join(parts[:-1])
×
UNCOV
413
                if address:
×
UNCOV
414
                    bibtex_entry += (
×
415
                        f"  address = {{{sanitize_bibtex_string(address)}}},\n"
416
                    )
417
            else:
418
                # Whole field as address
419
                bibtex_entry += (
×
420
                    f"  address = {{{sanitize_bibtex_string(miejsce_i_rok)}}},\n"
421
                )
422

423
    # URL
UNCOV
424
    if hasattr(praca_doktorska, "www") and praca_doktorska.www:
×
UNCOV
425
        url = sanitize_bibtex_string(praca_doktorska.www)
×
UNCOV
426
        bibtex_entry += f"  url = {{{url}}},\n"
×
427

428
    # Remove trailing comma and newline, add closing brace
UNCOV
429
    bibtex_entry = bibtex_entry.rstrip(",\n") + "\n}\n"
×
430

UNCOV
431
    return bibtex_entry
×
432

433

434
def praca_habilitacyjna_to_bibtex(praca_habilitacyjna) -> str:
1✔
435
    """
436
    Convert Praca_Habilitacyjna instance to BibTeX format.
437

438
    Args:
439
        praca_habilitacyjna: Praca_Habilitacyjna model instance
440

441
    Returns:
442
        BibTeX formatted string
443
    """
UNCOV
444
    key = generate_bibtex_key(praca_habilitacyjna)
×
UNCOV
445
    authors = format_authors_bibtex(praca_habilitacyjna)
×
446

UNCOV
447
    bibtex_entry = f"@misc{{{key},\n"
×
448

449
    # Title
UNCOV
450
    if praca_habilitacyjna.tytul_oryginalny:
×
UNCOV
451
        title = sanitize_bibtex_string(praca_habilitacyjna.tytul_oryginalny)
×
UNCOV
452
        bibtex_entry += f"  title = {{{title}}},\n"
×
453

454
    # Author
UNCOV
455
    if authors:
×
UNCOV
456
        bibtex_entry += f"  author = {{{sanitize_bibtex_string(authors)}}},\n"
×
457

458
    # Year
UNCOV
459
    if praca_habilitacyjna.rok:
×
UNCOV
460
        bibtex_entry += f"  year = {{{praca_habilitacyjna.rok}}},\n"
×
461

462
    # Note indicating this is a habilitation thesis
UNCOV
463
    bibtex_entry += "  note = {Rozprawa habilitacyjna},\n"
×
464

465
    # School (University)
UNCOV
466
    if hasattr(praca_habilitacyjna, "jednostka") and praca_habilitacyjna.jednostka:
×
UNCOV
467
        if (
×
468
            hasattr(praca_habilitacyjna.jednostka, "wydzial")
469
            and praca_habilitacyjna.jednostka.wydzial
470
        ):
UNCOV
471
            school = sanitize_bibtex_string(praca_habilitacyjna.jednostka.wydzial.nazwa)
×
UNCOV
472
            bibtex_entry += f"  school = {{{school}}},\n"
×
473

474
    # Publisher/address from miejsce_i_rok
UNCOV
475
    if (
×
476
        hasattr(praca_habilitacyjna, "miejsce_i_rok")
477
        and praca_habilitacyjna.miejsce_i_rok
478
    ):
UNCOV
479
        miejsce_i_rok = praca_habilitacyjna.miejsce_i_rok.strip()
×
480
        # Try to extract address and year
UNCOV
481
        parts = miejsce_i_rok.split()
×
UNCOV
482
        if parts:
×
483
            # Last part might be year if it's 4 digits
UNCOV
484
            if len(parts) > 1 and re.match(r"\d{4}", parts[-1]):
×
UNCOV
485
                address = " ".join(parts[:-1])
×
UNCOV
486
                if address:
×
UNCOV
487
                    bibtex_entry += (
×
488
                        f"  address = {{{sanitize_bibtex_string(address)}}},\n"
489
                    )
490
            else:
491
                # Whole field as address
492
                bibtex_entry += (
×
493
                    f"  address = {{{sanitize_bibtex_string(miejsce_i_rok)}}},\n"
494
                )
495

496
    # URL
UNCOV
497
    if hasattr(praca_habilitacyjna, "www") and praca_habilitacyjna.www:
×
UNCOV
498
        url = sanitize_bibtex_string(praca_habilitacyjna.www)
×
UNCOV
499
        bibtex_entry += f"  url = {{{url}}},\n"
×
500

501
    # Remove trailing comma and newline, add closing brace
UNCOV
502
    bibtex_entry = bibtex_entry.rstrip(",\n") + "\n}\n"
×
503

UNCOV
504
    return bibtex_entry
×
505

506

507
def export_to_bibtex(publications) -> str:
1✔
508
    """
509
    Export multiple publications to BibTeX format.
510

511
    Args:
512
        publications: Queryset or list of Wydawnictwo_Ciagle/Wydawnictwo_Zwarte/Patent/
513
                     Praca_Doktorska/Praca_Habilitacyjna instances
514

515
    Returns:
516
        Complete BibTeX file content as string
517
    """
UNCOV
518
    bibtex_entries = []
×
519

UNCOV
520
    for pub in publications:
×
UNCOV
521
        if hasattr(pub, "_meta"):
×
UNCOV
522
            model_name = pub._meta.model_name
×
UNCOV
523
            if model_name == "wydawnictwo_ciagle":
×
UNCOV
524
                bibtex_entries.append(wydawnictwo_ciagle_to_bibtex(pub))
×
UNCOV
525
            elif model_name == "wydawnictwo_zwarte":
×
UNCOV
526
                bibtex_entries.append(wydawnictwo_zwarte_to_bibtex(pub))
×
UNCOV
527
            elif model_name == "patent":
×
UNCOV
528
                bibtex_entries.append(patent_to_bibtex(pub))
×
UNCOV
529
            elif model_name == "praca_doktorska":
×
UNCOV
530
                bibtex_entries.append(praca_doktorska_to_bibtex(pub))
×
UNCOV
531
            elif model_name == "praca_habilitacyjna":
×
UNCOV
532
                bibtex_entries.append(praca_habilitacyjna_to_bibtex(pub))
×
533

UNCOV
534
    return "\n".join(bibtex_entries)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc