Skip to content

Commit 7bf1227

Browse files
Merge pull request #2114 from CentreForDigitalHumanities/feature/unify-settings-formats
Feature/unify settings formats
2 parents ebe7e8a + 263430b commit 7bf1227

49 files changed

Lines changed: 122 additions & 376 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

backend/addcorpus/python_corpora/corpus.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,3 @@ def transform_to_date_range(earliest, latest):
547547
'gte': earliest,
548548
'lte': latest
549549
}
550-
551-
552-
def get_deprecated_setting(setting: str):
553-
'''Utility function to get a corpus-specific Django setting'''
554-
if hasattr(settings, setting):
555-
logger.warning('Setting %s is deprecated; use CORPUS_SETTINGS', setting)
556-
return getattr(settings, setting)

backend/addcorpus/python_corpora/tests/test_times_source.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ def times_test_settings(settings):
1111
settings.CORPORA = {
1212
'times': 'corpora.times.times.Times',
1313
}
14-
settings.TIMES_DATA = join(settings.BASE_DIR, 'addcorpus/python_corpora/tests')
15-
settings.TIMES_ES_INDEX = 'test-times'
16-
14+
settings.CORPUS_SETTINGS["times"] = {
15+
"data_directory": join(settings.BASE_DIR, "addcorpus/python_corpora/tests"),
16+
"es_index": "test-times",
17+
}
1718

1819

1920
def test_times_source(times_test_settings):

backend/corpora/dbnl/dbnl.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from tqdm import tqdm
55
from ianalyzer_readers.xml_tag import Tag, CurrentTag, TransformTag
66

7-
from addcorpus.python_corpora.corpus import XMLCorpusDefinition, FieldDefinition, get_deprecated_setting
7+
from addcorpus.python_corpora.corpus import XMLCorpusDefinition, FieldDefinition
88
from ianalyzer_readers.extract import Metadata, XML, Pass, Order, Backup, Combined
99
import corpora.dbnl.utils as utils
1010
from addcorpus.es_mappings import *
@@ -14,18 +14,11 @@
1414
class DBNL(XMLCorpusDefinition):
1515
title = 'DBNL'
1616
description = 'Dutch literature and publications on literary or linguistic studies, from the Middle Ages to the 19th century'
17-
18-
@property
19-
def data_directory(self):
20-
return get_deprecated_setting('DBNL_DATA') or super().data_directory
17+
es_index = 'dbnl' # default setting for development
2118

2219
min_date = datetime(year=1200, month=1, day=1)
2320
max_date = datetime(year=1890, month=12, day=31)
2421

25-
@property
26-
def es_index(self):
27-
return get_deprecated_setting('DBNL_ES_INDEX') or 'dbnl'
28-
2922
image = 'dbnl.png'
3023
description_page = 'dbnl.md'
3124
citation_page = 'citation.md'

backend/corpora/dutchannualreports/dutchannualreports.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,11 @@ class DutchAnnualReports(XMLCorpusDefinition):
2525
description = "Annual reports of Dutch financial and non-financial institutes"
2626
min_date = datetime(year=1957, month=1, day=1)
2727
max_date = datetime(year=2008, month=12, day=31)
28-
data_directory = settings.DUTCHANNUALREPORTS_DATA
29-
es_index = getattr(settings, 'DUTCHANNUALREPORTS_ES_INDEX', 'dutchannualreports')
28+
es_index = 'dutchannualreports'
3029
image = 'dutchannualreports.jpg'
31-
scan_image_type = getattr(settings, 'DUTCHANNUALREPORTS_SCAN_IMAGE_TYPE', 'application/pdf')
30+
scan_image_type = 'application/pdf'
3231
description_page = 'dutchannualreports.md'
33-
allow_image_download = getattr(settings, 'DUTCHANNUALREPORTS_ALLOW_IMAGE_DOWNLOAD', True)
34-
word_model_path = getattr(settings, 'DUTCHANNUALREPORTS_WM', None)
32+
allow_image_download = True
3533

3634
languages = ['nl']
3735
category = 'finance'

backend/corpora/dutchnewspapers/dutchnewspapers_all.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ class DutchNewsPapersAll(DutchNewspapersPublic):
1414

1515
title = "Dutch Newspapers (full)"
1616
description = "Full collection of Dutch newspapers digitised by the Koninklijke Bibliotheek."
17-
data_directory = settings.DUTCHNEWSPAPERS_ALL_DATA
18-
es_index = getattr(settings, 'DUTCHNEWSPAPERS_ALL_ES_INDEX', 'dutchnewspapers-all')
17+
es_index = 'dutchnewspapers-all'
1918
max_date = datetime(year=1995, month=12, day=31)
20-
word_model_path = getattr(settings, "DUTCHNEWSPAPERS_WM", None)
2119

2220
def update_body(self, doc=None):
2321
if not doc:

backend/corpora/dutchnewspapers/dutchnewspapers_public.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ class DutchNewspapersPublic(XMLCorpusDefinition):
3232
description = "Collection of Dutch newspapers in the public domain, digitised by the Koninklijke Bibliotheek."
3333
min_date = datetime(year=1600, month=1, day=1)
3434
max_date = datetime(year=1876, month=12, day=31)
35-
data_directory = getattr(settings, 'DUTCHNEWSPAPERS_DATA', None)
36-
es_index = getattr(settings, 'DUTCHNEWSPAPERS_ES_INDEX', 'dutchnewspapers-public')
35+
es_index = 'dutchnewspapers-public'
3736
image = 'dutchnewspapers.jpg'
3837
languages = ['nl']
3938
category = 'periodical'
4039
description_page = 'description_public.md'
4140
citation_page = 'citation_public.md'
42-
word_model_path = getattr(settings, "DUTCHNEWSPAPERS_WM", None)
4341

4442
@property
4543
def es_settings(self):

backend/corpora/ecco/ecco.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ class Ecco(XMLCorpusDefinition):
3131
min_date = datetime(year=1700, month=1, day=1)
3232
max_date = datetime(year=1800, month=12, day=31)
3333

34-
data_directory = settings.ECCO_DATA
35-
es_index = getattr(settings, 'ECCO_ES_INDEX', 'ecco')
34+
es_index = 'ecco'
3635
image = 'ecco.jpg'
37-
scan_image_type = getattr(settings, 'ECCO_SCAN_IMAGE_TYPE', 'application/pdf')
36+
scan_image_type = 'application/pdf'
3837
es_settings = None
3938
languages = ['en', 'fr', 'la', 'grc', 'de', 'it', 'cy', 'ga', 'gd']
4039
category = 'book'

backend/corpora/economist/economist.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ class Economist(GaleCorpus):
5454
description = "Archive of The Economist, a weekly news magazine."
5555
min_date = datetime(1843, 8, 1)
5656
max_date = datetime(2021, 1, 1)
57-
data_directory = settings.ECONOMIST_DATA
58-
es_index = getattr(settings, 'ECONOMIST_ES_INDEX', 'economist')
57+
es_index = 'economist'
5958
image = 'A_stack_of_Economist_papers.jpg'
6059
description_page = 'Economist.md'
6160
languages = ['en']

backend/corpora/gallica/caricature.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Caricature(Gallica):
1212
max_date = datetime(year=1843, month=12, day=31)
1313
corpus_id = "cb344523348"
1414
category = "periodical"
15-
es_index = getattr(settings, 'CARICATURE_INDEX', 'caricature')
15+
es_index = 'caricature'
1616
description_page = 'caricature.md'
1717
image = "caricature.jpg"
1818

backend/corpora/gallica/figaro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Figaro(Gallica):
1212
max_date = datetime(year=1954, month=12, day=31)
1313
corpus_id = "cb34355551z"
1414
category = "periodical"
15-
es_index = getattr(settings, 'FIGARO_INDEX', 'figaro')
15+
es_index = 'figaro'
1616
image = "figaro.jpg"
1717
description_page = 'figaro.md'
1818

0 commit comments

Comments
 (0)