Skip to content

Commit

Permalink
added a check for duplicate references which will prevent loading the…
Browse files Browse the repository at this point in the history
… data into the web app
  • Loading branch information
xrotwang committed Aug 15, 2024
1 parent 05e38b8 commit fe3229d
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/pydplace/commands/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,10 @@ def run(args):
print(colored('{} not found'.format(fname), 'red'))
passed = False

for dp in ds.cldf_reader().objects('ValueTable'):
if len(dp.cldf.source) != len(set(dp.cldf.source)):
print(colored('{} duplicate reference'.format(dp.cldf.source), 'red'))
passed = False

print(colored('OK' if passed else 'FAIL', 'green' if passed else 'red', attrs={'bold'}))
return 0
2 changes: 1 addition & 1 deletion tests/dataset_without_societies/cldf/data.csv
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ID,Soc_ID,Var_ID,Value,Code_ID,Comment,Source,sub_case,year,source_coded_data,ad
9,WNAI3,WNAI12,Absent,WNAI12-1,,drucker1940;drucker1950;drucker1965;krause1956;murdock1934a;murdock1934b;murdock1936a;rosmanandrubel1971;swanton1909,,,"wn01.dat (World Cultures CD-ROM 2011, folder 10#2)",
10,WNAI1,WNAI13,Absent,WNAI13-1,,delaguna1960;barnett1968;drucker1950;druckerandheizer1967;garfield1947;jones1914;krause1956;olson1936b;olson1967;rosmanandrubel1971;swanton1908,,,"wn01.dat (World Cultures CD-ROM 2011, folder 10#2)",
11,WNAI2,WNAI13,Absent,WNAI13-1,,delaguna1960;barnett1968;drucker1950;druckerandheizer1967;garfield1947;jones1914;krause1956;olson1936b;olson1967;rosmanandrubel1971;swanton1908,,,"wn01.dat (World Cultures CD-ROM 2011, folder 10#2)",
12,WNAI3,WNAI13,Absent,WNAI13-1,,drucker1940;drucker1950;drucker1965;krause1956;murdock1934a;murdock1934b;murdock1936a;rosmanandrubel1971;swanton1909,,,"wn01.dat (World Cultures CD-ROM 2011, folder 10#2)",
12,WNAI3,WNAI13,Absent,WNAI13-1,,drucker1940;drucker1940;drucker1950;drucker1965;krause1956;murdock1934a;murdock1934b;murdock1936a;rosmanandrubel1971;swanton1909,,,"wn01.dat (World Cultures CD-ROM 2011, folder 10#2)",
1 change: 1 addition & 0 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def test_check(capsys, dataset_with_societies, dataset_without_societies):
out, _ = capsys.readouterr()
assert 'must reference' in out
assert 'Re-run' in out
assert 'duplicate reference' in out


def test_readme(dataset_with_societies, dataset_without_societies):
Expand Down

0 comments on commit fe3229d

Please sign in to comment.