Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Preliminary investigation: updating to python 3 #1407

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
7896fe9
feat(BTE):Init cl-binary-transformers-and-extractors
flooie Sep 15, 2020
36f3b8f
refactor(make_png_thumbnail..): Use docker BTE
flooie Sep 15, 2020
f952859
refactor(peopledb/tasks): Remove subprocess import
flooie Sep 15, 2020
40053f2
refactor(scrapers/tasks): Remove subprocess methods
flooie Sep 16, 2020
8db9b46
refactor(scrapers/tests): Update tests for new container
flooie Sep 16, 2020
c8775b9
style(scraper/tests.py): Black style
flooie Sep 16, 2020
ee42731
refactor(get_page_count): Add extension param
flooie Sep 16, 2020
3894abc
docs(get_page_count): Update doc strings
flooie Sep 16, 2020
1983f5d
feat(docker): Add judge pics and seals
flooie Sep 16, 2020
3576775
refactor(docker): Update compose files
flooie Sep 16, 2020
f6cfa5e
refactor(scraper.tasks):Update calls for docker changes
flooie Sep 17, 2020
cbfa9d4
refactor(tests.yml):Update tests.yml
flooie Sep 17, 2020
dec2f1b
fix(docker-compose): Replace build command with image for cl-django
flooie Sep 17, 2020
fd4781f
tests(docker-compose): Push compose with bte-beta django container
flooie Sep 17, 2020
716e6a8
tests(scraper.tests): Update heartbeat test name and logging
flooie Sep 17, 2020
56f0cb7
tests(scraper.tests): Fix content_extraction test for different mimet…
flooie Sep 17, 2020
4cefe43
tests(BinaryTransformerExtractionTest): Fix Heartbeat test
flooie Sep 17, 2020
aca26b5
tests(cl/docker-compose): Test bte_beta containers
flooie Sep 17, 2020
19a3aed
tests(cl/docker-compose): Add volumes to large install containers
flooie Sep 17, 2020
06d9be7
fix(workflows): Update github workflows
flooie Sep 17, 2020
581b51b
refactor(docker-compose): Add env variables
flooie Sep 17, 2020
87eaee6
refactor(scraper.tasks): Add timeouts to BTE calls
flooie Sep 17, 2020
2de8519
refactor(tasks.py): Update BTE calls
flooie Sep 18, 2020
2773d96
feat(docker_helpers): Add helper docker call methods
flooie Sep 18, 2020
effa9ee
tests(scrapers): Update tests for BinaryTransformerExtractionTest
flooie Sep 18, 2020
e594219
style(black): Black last push
flooie Sep 18, 2020
a1dc92e
fix(docker_helpers): Return json object for page count
flooie Sep 18, 2020
ae2a90b
fix(scraper.tests): Use correct method in extraction test
flooie Sep 18, 2020
53faffc
fix(scraper.tasks): Fix convert_audio response
flooie Sep 18, 2020
9446c20
fix(settings): Add Binary Transformers & Extractors
flooie Sep 19, 2020
6dd8f2c
refactor(cl.search): Remove file
flooie Sep 19, 2020
128ac81
refactor(docker_helpers): Make timeout times human readable
flooie Sep 19, 2020
ba4d61e
refactor(get_page_count): Update get_page_count params
flooie Sep 21, 2020
9f71d61
docs(get_page_count): Update docstring
flooie Sep 21, 2020
e9c4125
refactor(generate_thumbnail): Change error handling
flooie Sep 21, 2020
91b7937
refactor(generate_thumbnail): Small tweak
flooie Sep 21, 2020
442675b
refactor(django/dockerfile): Remove unused command
flooie Sep 29, 2020
f167de3
refactor(transformer_extractor_utils): Rename docker_helpers.py
flooie Sep 29, 2020
ffaf8f1
fix(transformer_extractor_utils): Add filename discovery to post corr…
flooie Sep 30, 2020
a71a001
fix(transformer_extractor_utils): Remove extra save in try except pat…
flooie Sep 30, 2020
0e87056
fix(tests.py): Update document extraction test
flooie Sep 30, 2020
50831fe
refactor(transformer_ex..): Update transformer for new BTE build
flooie Sep 30, 2020
32ddcd8
fix(scrapers/tests): Fix test_txt_extraction_with_bad_data
flooie Sep 30, 2020
911948f
Add pyproject for poetry that works with Python 3.8.
drewsilcock Oct 1, 2020
5b5f904
2to3: convert to py3 unicode handling.
drewsilcock Oct 1, 2020
4e407d5
2to3: Use py3 print functions always.
drewsilcock Oct 1, 2020
4bb8e13
Use `range` instead of `xrange`.
drewsilcock Oct 1, 2020
4bab940
Replace execfile with `exec(compile(open("...).read(), "...", "exec")`
drewsilcock Oct 1, 2020
d87fdc5
Use `input()` consistently instead of `raw_input()`.
drewsilcock Oct 1, 2020
463cad5
2to3: Convert iterators to lists where necessary.
drewsilcock Oct 1, 2020
1185caa
Move to py3 imports.
drewsilcock Oct 1, 2020
760cc1e
Ignore venv and egg-info.
drewsilcock Oct 1, 2020
be5bc1e
Library replacements: StringIO, httplib, HTMLParser, urlparse
drewsilcock Oct 1, 2020
dde5826
PEP0237 long has been renamed to int.
drewsilcock Oct 1, 2020
dbeba70
Starting number with '0' is invalid.
drewsilcock Oct 1, 2020
64a1962
refactor(docker-compose): Move seal rookery to cl-binary-transformer
flooie Oct 1, 2020
4e4deec
Convert dunders to py3: __bool__, __str__.
drewsilcock Oct 1, 2020
e0ea84c
Import reduce from functools.
drewsilcock Oct 1, 2020
197450b
feat(convert_audio): Update convert audio BTE call
flooie Oct 1, 2020
6865a0e
Change `smart_unicode` to `force_str`.
drewsilcock Oct 2, 2020
6ff9832
Change `maxBytes` in settings to int, not string.
drewsilcock Oct 2, 2020
c65ba73
Update pyproject to include more project info & include lockfile.
drewsilcock Oct 2, 2020
7cecd27
Enable running `manage.py` as `cl-manage` script.
drewsilcock Oct 2, 2020
971f36e
Add doc explaining port to py3.8.
drewsilcock Oct 2, 2020
78d7734
Format with Black.
drewsilcock Oct 2, 2020
4529517
Rename submodule `ca9-briefs` to `ca9_briefs`.
drewsilcock Oct 2, 2020
f2151d9
refactor(req.txt): Remove unused imports
flooie Oct 2, 2020
edfe701
refactor(scrapers.tasks.py): Update audio conversion to use new methods
flooie Oct 2, 2020
2a20c2d
refactor(scrapers/tests.py): Update tests
flooie Oct 2, 2020
51f26da
refactor(docker-compose): Change port mapping in docker-compose
flooie Oct 2, 2020
930267c
refactor(req.txt): Remove Pillow and PyPdf2
flooie Oct 2, 2020
efc0d2b
Merge branch 'pr/1407' into python38-merger
flooie Oct 2, 2020
d082862
feat(CL):Add python3.8 support
flooie Oct 2, 2020
e3207da
Tweaks to get tests to partially run
flooie Oct 5, 2020
d970773
Tweaks to get tests to partially run
flooie Oct 5, 2020
ae9989f
Merge branch 'python38-merger' of github.com:freelawproject/courtlist…
flooie Oct 5, 2020
515d6c9
Merge branch 'python38-merger' of github.com:freelawproject/courtlist…
flooie Oct 5, 2020
a558eb9
Merge branch 'python38-merger' of github.com:freelawproject/courtlist…
flooie Oct 5, 2020
df07471
fix(sunburnt): Encoding issues py2->py3
flooie Oct 6, 2020
b2e61bb
refactor(court_regexes): Change regex encoding strings
flooie Oct 6, 2020
5d18148
refactor(tests): Update python2->3 string encodings
flooie Oct 6, 2020
94c42a5
refactor(tests): Update python2->3 string encodings
flooie Oct 6, 2020
a135f03
Merge branch 'python38-merger' of github.com:freelawproject/courtlist…
flooie Oct 6, 2020
5afe86d
Merge branch 'python38-merger' of github.com:freelawproject/courtlist…
flooie Oct 6, 2020
ec66de4
Merge branch 'python38-merger' of github.com:freelawproject/courtlist…
flooie Oct 6, 2020
95942b5
refactor(text_filters): Integer division py2-> py3
flooie Oct 6, 2020
c152ad9
refactor(cleanup.tests): Encode docket numbers and answers for compar…
flooie Oct 6, 2020
b293dad
refactor(corpus.tests): Fix test to handle unsorted judges
flooie Oct 6, 2020
813752f
refactor(search_utils): Switch sunburnt for scorched
flooie Oct 7, 2020
76119c4
feat(req.txt): Upgrade req txt file
flooie Oct 7, 2020
804b246
fix(test_tax_court_citation_extractor): Fix encoding
flooie Oct 7, 2020
f57245d
fix(test_pdf_validation_error): Fix test validation error encoding
flooie Oct 7, 2020
32e025f
refactor(cl): Replace magic with magic
flooie Oct 7, 2020
5a2f288
Remove `scripts_archive` from `cl/cleanup` directory.
drewsilcock Oct 5, 2020
76b7d43
Update from pip `mock` package to `unittest.mock` (py3.3+).
drewsilcock Oct 5, 2020
36dd7f9
Change dependency specification from pip to poetry.
drewsilcock Oct 5, 2020
01e79a3
Add black-compatible configs for isort, pylint, flake8 and mypy.
drewsilcock Oct 7, 2020
ff9ccb8
fix(test_more_like_this_opinion_detail_no_filter): Py2->3 encoding up…
flooie Oct 9, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
6 changes: 4 additions & 2 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: black

on:
push:
branches: [master, ]
branches:
- '**'
pull_request:
branches: [master]
branches:
- 'master'

jobs:
black:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ name: "CodeQL"

on:
push:
branches: [master, ]
branches:
- '**'
pull_request:
# The branches below must be a subset of the branches above
branches: [master]
branches:
- 'master'
schedule:
- cron: '0 2 * * 0'

Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/sentry-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ name: sentry-release

on:
push:
branches: [master, ]
branches:
- '**'

jobs:
createSentryRelease:
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ name: docker build and test

on:
push:
branches: [master, ]
branches:
- '**'
pull_request:
branches: [master]
branches:
- 'master'

jobs:
build:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
.venv
*.egg-info

# no compiled files!
*.class
*.pyc
Expand Down
85 changes: 85 additions & 0 deletions UpdatingToPython3-8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Updating to Python 3.8

Preliminary caveat: I haven't tested running the codebase after these changes, this is an introductory investigation. Currently the `reporters-db` dependency is the blocker to actually running the `manage.py`.

## Dependencies

Dependencies that needed updating:

- `pydot` version `1.1.0` is not compatible with Python 3. Update to version `20.9.0`.
- `pandas` version `0.18.1` is not compatible with Python 3(.8 ?). Update to version `1.1.2`. This also requires updating `python-dateutil` from `2.5.0` to `>=2.7.3` - updated to `2.8.1`.
- `pycopg2` version `2.7.7` needs updating. Update to `2.8.6`. Note that this requires `export CONFIGURE_OPTS="CPPFLAGS=-I$(brew --prefix openssl)/include" LDFLAGS="-L$(brew --prefix openssl)/lib"` on macOS.
- `wsgiref` is now built into Python 3, so isn't necessary to include as a dependency.
-` enum34` isn't necessary anymore.
- it's not possible to install `seal-rookery` from PyPI due to missing `sdist` distributions. As workaround, install directly from GitHub.
- `reporters-db` can't be installed because it relies on `python-dateutil==2.5.0`.
- `mock` is no longer needed as this is part of the standard library in `unittest.mock` as of py3.3.

## Code changes

Updating of the actual code:

- Run 2to3 and hand-modify the output to remove false positives and other automatic errors. It picked up a false positive around importing `from celery import Celery` when there was a local file called `celery.py`, and there were a bunch of false positives where 2to3 converts `for x, y in dict.values()` to `for x, y in list(dict.values())` which is unnecessary and inefficient. Other than that the results were pretty good. The main consideration going forwards is that somewhere there's a comparison between a `b"some bytes string"` and a `"some unicode string"` which can't be found at runtime but will never be equal. More details of 2to3 changes below.
- In `10-public.py`, the `maxBytes` setting needs to be changed to an int, not a string.
- `django.utils.encoding.smart_unicode` was renamed to `django.utils.encoding.smart_text` but it's actually just an alias to `django.utils.encoding.force_str`, so may as well just change it to that.
- Any instances of `import mock` or `from mock import ...` need to be trivially changed to `from unittest import mock` and `from unittest.mock import ...`.

### 2to3

This summaries the automatic conversions that 2to3 can apply:

- Remove `u"blah"` from strings to just be `"blah"` - in Python 3 these are equivalent.
- Change `isinstance(x, basestring)` to `isinstance(x, str)` as `basestring = (str, unicode)` doesn't exist in py3.
- Change `unicode(...)` to `str(...)`.
- Remove `from __future__ import unicode_literals`.
- Change `raw_input()` to `input()` and `input()` to `eval(input())` (note: no-where in this repo is the `eval()` bit required, so best to leave it off for obvious security reasons).
- Change `print "blah"` to `print("blah")` and `print "foo",` to `print("foo", end=" ")`.
- Remove `from __future__ import absolute_import`.
- Convert py2 method of importing local files `from local_file import myfunction` to py3 version: `from .local_file import myfunction`. You need to be careful that 2to3 doesn't get false positives where name of local file == local of repository, which happened once here.
- Replace `xrange()` with `range()`.
- Replace `execfile()` with `exec(compile(open("file.py").read(), "file.py", "exec"))`.
- Some functions like `dict.values()`, `dict.items()`, etc. return iterators instead of lists. Sometimes (but not always), you need to convert these to lists yourself to avoid strange bugs. For instance, `for x, y in d.items()` isn't necessary because you're immediately consuming the iterator, but if you do `d = {"a": 1}; x = d.items(); l1 = len(x); l2 = len(x)` then `l1 == 1` and `l2 == 0` because the first `len(x)` consumes the iterator meaning there's nothing left in it. Figuring out which one is immediately consumed and which isn't just needs to be done by hand.
- Change stdlib library names:
- `httplib` => `http.client`
- `HTMLParser` => `html.parser`
- `StringIO => io.StringIO`
- etc.
- Change `long` to `int`, as py2 `long`s are the same as py3 `int`s.
- Starting number with `0`, e.g. `07` is not valid in py3. Either use `0o7` for an octal or `7` for a decimal.
- Change dunder methods: `__nonzero__` to `__bool__` and `__unicode__` to `__str__`.
- `reduce` needs to be imported from `functools`.

There's a bunch of other things too but they don't appear in the courtlistener codebase.

## Poetry

To install dependencies with Poetry, run:

```bash
poetry install

# If you don't want dev dependencies, you have to explicitly say so.
poetry install --no-dev

# If you want the extras, you need to say so.
poetry install -E flp
```

Then you can run the `manage.py` command using either:

```bash
poetry run manage.py
# OR
cl-manage
```

If you invoke `poetry` without being in a virtual environment, poetry will create one for you automatically and use that. If you're already activated, it'll use the venv that you've created. I prefer to create my own because it gives you more control of where the venv is:

```bash
python -m venv .venv
source ./.venv/bin/activate
poetry install

# cl-manage has now been installed into the virtualenv
which cl-manage
```
2 changes: 0 additions & 2 deletions cl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import absolute_import

# This will make sure the app is always imported when
# Django starts so that shared_task will use this app.
from .celery import app as celery_app
4 changes: 2 additions & 2 deletions cl/alerts/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ def clean_rate(self):
# Somebody is trying to hack past the JS/HTML block on the front
# end. Don't let them create the alert until they've donated.
raise ValidationError(
u"You must donate more than $10 per year to create Real Time "
u"alerts."
"You must donate more than $10 per year to create Real Time "
"alerts."
)
else:
return rate
Expand Down
4 changes: 1 addition & 3 deletions cl/alerts/management/commands/handle_old_docket_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,7 @@ class Command(VerboseCommand):
T+187-∞ ─┴─ Item terminated more than 180 days ago and
alert is disabled.
""".decode(
"utf-8"
)
"""

def create_parser(self, *args, **kwargs):
parser = super(Command, self).create_parser(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations

Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0002_alert_user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations
from django.conf import settings
Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0003_auto_20150807_1826.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations
import datetime
Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0004_auto_20150910_1450.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import models, migrations

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import migrations, models

Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0006_add_alert_secret_key.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import migrations, models

Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0007_populate_alert_secret_key.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import migrations
from django.utils.crypto import get_random_string
Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0008_add_docket_alerts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.conf import settings
from django.db import migrations, models
Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0009_add_date_last_hit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import migrations, models

Expand Down
2 changes: 1 addition & 1 deletion cl/alerts/migrations/0010_noop_update_help_text.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-04-25 00:02
from __future__ import unicode_literals


from django.db import migrations, models

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2020-07-22 23:27
from __future__ import unicode_literals


from django.db import migrations, models

Expand Down
8 changes: 4 additions & 4 deletions cl/alerts/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ class Alert(models.Model):
max_length=40,
)

def __unicode__(self):
return u"Alert %s: %s" % (self.pk, self.name)
def __str__(self):
return "Alert %s: %s" % (self.pk, self.name)

class Meta:
ordering = ["rate", "query"]
Expand Down Expand Up @@ -99,8 +99,8 @@ class DocketAlert(models.Model):
class Meta:
unique_together = ("docket", "user")

def __unicode__(self):
return u"DocketAlert %s: %s" % (self.pk, self.docket_id)
def __str__(self):
return "DocketAlert %s: %s" % (self.pk, self.docket_id)

def save(self, *args, **kwargs):
"""Ensure we get a token when we save the first time."""
Expand Down
4 changes: 2 additions & 2 deletions cl/alerts/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def test_create_alert(self):
reverse("show_results"), self.alert_params, follow=True
)
self.assertEqual(r.redirect_chain[0][1], 302)
self.assertIn("successfully", r.content)
self.assertIn("successfully", r.content.decode())
self.client.logout()

def test_fail_gracefully(self):
Expand All @@ -54,7 +54,7 @@ def test_fail_gracefully(self):
)
r = self.client.post("/", bad_alert_params, follow=True)
self.assertEqual(r.status_code, 200)
self.assertIn("error creating your alert", r.content)
self.assertIn("error creating your alert", r.content.decode())
self.client.logout()

def test_new_alert_gets_secret_key(self):
Expand Down
6 changes: 3 additions & 3 deletions cl/api/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# coding=utf-8
from __future__ import print_function

import json
import shutil
from datetime import timedelta, date
Expand Down Expand Up @@ -913,15 +913,15 @@ class BulkDataTest(TestCase):

def setUp(self):
docket = Docket(
case_name=u"foo",
case_name="foo",
court=Court.objects.get(pk="test"),
source=Docket.DEFAULT,
)
docket.save()
# Must be more than a year old for all tests to be runnable.
last_month = now().date() - timedelta(days=400)
self.doc_cluster = OpinionCluster(
case_name=u"foo", docket=docket, date_filed=last_month
case_name="foo", docket=docket, date_filed=last_month
)
self.doc_cluster.save(index=False)
opinion = Opinion(cluster=self.doc_cluster, type="Lead Opinion")
Expand Down
7 changes: 5 additions & 2 deletions cl/api/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging

import scorched
from django.conf import settings
from django.http import JsonResponse
from django.shortcuts import render, get_object_or_404
Expand Down Expand Up @@ -45,8 +46,10 @@ def annotate_courts_with_counts(courts, court_count_tuples):

def make_court_variable():
courts = Court.objects.exclude(jurisdiction=Court.TESTING_COURT)
conn = sunburnt.SolrInterface(settings.SOLR_OPINION_URL, mode="r")
response = conn.raw_query(**build_court_count_query()).execute()
# conn = sunburnt.SolrInterface(settings.SOLR_OPINION_URL, mode="r")
# response = conn.raw_query(**build_court_count_query()).execute()
si = scorched.SolrInterface(settings.SOLR_OPINION_URL, mode="r")
response = si.query(**build_court_count_query()).execute()
court_count_tuples = response.facet_counts.facet_fields["court_exact"]
courts = annotate_courts_with_counts(courts, court_count_tuples)
return courts
Expand Down
22 changes: 11 additions & 11 deletions cl/audio/feeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class JurisdictionPodcast(JurisdictionFeed):
)
subtitle = description
summary = description
iTunes_name = u"Free Law Project"
iTunes_email = u"[email protected]"
iTunes_name = "Free Law Project"
iTunes_email = "[email protected]"
iTunes_image_url = (
u"https://www.courtlistener.com/static/png/producer-2000x2000.png"
"https://www.courtlistener.com/static/png/producer-2000x2000.png"
)
iTunes_explicit = u"no"
item_enclosure_mime_type = u"audio/mpeg"
iTunes_explicit = "no"
item_enclosure_mime_type = "audio/mpeg"

def title(self, obj):
return "Oral Arguments for the %s" % obj.full_name
Expand All @@ -44,15 +44,15 @@ def items(self, obj):

def feed_extra_kwargs(self, obj):
extra_args = {
"iTunes_name": u"Free Law Project",
"iTunes_email": u"[email protected]",
"iTunes_explicit": u"no",
"iTunes_name": "Free Law Project",
"iTunes_email": "[email protected]",
"iTunes_explicit": "no",
}
if hasattr(obj, "pk"):
path = u"/static/png/producer-%s-2000x2000.png" % obj.pk
path = "/static/png/producer-%s-2000x2000.png" % obj.pk
else:
# Not a jurisdiction API -- A search API.
path = u"/static/png/producer-2000x2000.png"
path = "/static/png/producer-2000x2000.png"
extra_args["iTunes_image_url"] = (
"https://www.courtlistener.com%s" % path
)
Expand All @@ -63,7 +63,7 @@ def item_extra_kwargs(self, item):
return {
"author": get_item(item)["court"],
"duration": str(item["duration"]),
"explicit": u"no",
"explicit": "no",
}

def item_enclosure_url(self, item):
Expand Down
2 changes: 1 addition & 1 deletion cl/audio/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals


from django.db import migrations, models
import cl.lib.model_helpers
Expand Down
Loading