diff --git a/datalad_metalad/extractors/annex.py b/datalad_metalad/extractors/annex.py index 382615d0..172f4e07 100644 --- a/datalad_metalad/extractors/annex.py +++ b/datalad_metalad/extractors/annex.py @@ -20,7 +20,6 @@ from .base import MetadataExtractor -from six import text_type import logging lgr = logging.getLogger('datalad.metadata.extractors.metalad_annex') from datalad.log import log_progress @@ -50,7 +49,7 @@ def __call__(self, dataset, refcommit, process_type, status): # limit query to paths that are annexed query_paths = [ # go relative to minimize cmdline footprint of annex call - text_type(Path(s['path']).relative_to(ds.pathobj)) + str(Path(s['path']).relative_to(ds.pathobj)) for s in status # anything that looks like an annexed file if s.get('type', None) == 'file' \ diff --git a/datalad_metalad/extractors/core.py b/datalad_metalad/extractors/core.py index 14696c08..2831e388 100644 --- a/datalad_metalad/extractors/core.py +++ b/datalad_metalad/extractors/core.py @@ -22,10 +22,6 @@ from datalad.utils import ( Path, ) -from six import ( - iteritems, - string_types, -) import logging lgr = logging.getLogger('datalad.metadata.extractors.metalad_core') @@ -319,7 +315,7 @@ def _get_urls_from_whereis(wi, prefixes=('http', 'dl+archive:')): from "whereis" output""" return [ url - for remote, rprops in iteritems(wi.get('remotes', {}) if 'status' in wi else wi) + for remote, rprops in (wi.get('remotes', {}) if 'status' in wi else wi).items() for url in rprops.get('urls', []) if any(url.startswith(pref) for pref in prefixes) ] @@ -433,7 +429,7 @@ def whereis_file_(self, paths): with keys: 'description', 'here', 'urls' (list) that contain the values of the respective 'git annex whereis' response. """ - if isinstance(paths, string_types): + if isinstance(paths, str): raise ValueError('whereis_file(paths): paths must be ' 'iterable, not a string type') diff --git a/datalad_metalad/extractors/custom.py b/datalad_metalad/extractors/custom.py index f77b751d..6d4818f3 100644 --- a/datalad_metalad/extractors/custom.py +++ b/datalad_metalad/extractors/custom.py @@ -20,7 +20,6 @@ from .base import MetadataExtractor import os.path as op -from six import text_type import logging lgr = logging.getLogger('datalad.metadata.extractors.custom') @@ -49,7 +48,7 @@ def get_required_content(self, dataset, process_type, status): if process_type in ('all', 'dataset'): srcfiles, _ = _get_dsmeta_srcfiles(dataset) for f in srcfiles: - f = text_type(dataset.pathobj / f) + f = str(dataset.pathobj / f) if op.lexists(f): yield dict(path=f) @@ -78,7 +77,7 @@ def __call__(self, dataset, refcommit, process_type, status): meta_fpath = _get_fmeta_objpath(ds, mfile_expr, rec) if meta_fpath is not None and op.exists(meta_fpath): try: - meta = jsonload(text_type(meta_fpath)) + meta = jsonload(str(meta_fpath)) if isinstance(meta, dict) and meta \ and '@id' not in meta: # in case we have a single, top-level @@ -136,7 +135,7 @@ def _get_dsmeta_srcfiles(ds): # OK to be always POSIX srcfiles = ['.metadata/dataset.json'] \ if not cfg_srcfiles and op.lexists( - text_type(ds.pathobj / '.metadata' / 'dataset.json')) \ + str(ds.pathobj / '.metadata' / 'dataset.json')) \ else cfg_srcfiles return srcfiles, cfg_srcfiles @@ -154,7 +153,7 @@ def _get_fmeta_objpath(ds, expr, rec): return # build associated metadata file path from POSIX # pieces and convert to platform conventions at the end - return text_type( + return str( ds.pathobj / PurePosixPath(expr.format( freldir=fpath.relative_to( ds.pathobj).parent.as_posix(), @@ -183,7 +182,7 @@ def _yield_dsmeta(ds): # no further operation on half-broken metadata return lgr.debug('Load custom metadata from %s', abssrcfile) - meta = jsonload(text_type(abssrcfile)) + meta = jsonload(str(abssrcfile)) dsmeta.update(meta) if dsmeta: if '@id' not in dsmeta: diff --git a/datalad_metalad/extractors/runprov.py b/datalad_metalad/extractors/runprov.py index a92aab7b..fc71c457 100644 --- a/datalad_metalad/extractors/runprov.py +++ b/datalad_metalad/extractors/runprov.py @@ -61,9 +61,6 @@ get_file_id, get_agent_id, ) -from six import ( - text_type, -) from datalad.support.json_py import ( loads as jsonloads, load as jsonload, @@ -203,7 +200,7 @@ def _finalize_record(r): if not isinstance(rec, dict): # this is a runinfo file name rec = jsonload( - text_type(ds.pathobj / '.datalad' / 'runinfo' / rec), + str(ds.pathobj / '.datalad' / 'runinfo' / rec), # TODO this should not be necessary, instead jsonload() # should be left on auto, and `run` should save compressed # files with an appropriate extension diff --git a/datalad_metalad/extractors/tests/test_annex.py b/datalad_metalad/extractors/tests/test_annex.py index a774b240..dc8dfcb5 100644 --- a/datalad_metalad/extractors/tests/test_annex.py +++ b/datalad_metalad/extractors/tests/test_annex.py @@ -8,8 +8,6 @@ # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## """Test annex metadata extractor""" -from six import text_type - from datalad.distribution.dataset import Dataset from datalad.tests.utils_pytest import ( assert_equal, @@ -29,7 +27,7 @@ def test_annex_contentmeta(path=None): (ds.pathobj / 'ignored').write_text(u'nometa') ds.save(result_renderer="disabled") ds.repo.set_metadata( - text_type(mfile_path.relative_to(ds.pathobj)), + str(mfile_path.relative_to(ds.pathobj)), init={'tag': 'mytag', 'fancy': 'this?'} ) res = ds.meta_extract(extractorname='metalad_annex', path=str(mfile_path)) @@ -38,7 +36,7 @@ def test_annex_contentmeta(path=None): assert_result_count(res, 1) assert_result_count( res, 1, - path=text_type(mfile_path), + path=str(mfile_path), type='file', status='ok', action='meta_extract') diff --git a/datalad_metalad/extractors/tests/test_custom.py b/datalad_metalad/extractors/tests/test_custom.py index 452641ad..a0ca0ece 100644 --- a/datalad_metalad/extractors/tests/test_custom.py +++ b/datalad_metalad/extractors/tests/test_custom.py @@ -9,7 +9,6 @@ """Test custom metadata extractor""" import json -from six import text_type from datalad.distribution.dataset import Dataset from datalad.tests.utils_pytest import ( @@ -177,7 +176,7 @@ def test_custom_contentmeta(path=None): assert_result_count( res, 1, - path=text_type(ds.pathobj / 'sub' / 'one'), + path=str(ds.pathobj / 'sub' / 'one'), type='file', status='ok', action='meta_extract') @@ -212,7 +211,7 @@ def test_custom_content_broken(path=None): assert_result_count(res, 1) assert_result_count( res, 1, - path=text_type(ds.pathobj / 'sub' / 'one'), + path=str(ds.pathobj / 'sub' / 'one'), type='file', # specific message does vary a lot across platforms #message= diff --git a/datalad_metalad/extractors/tests/test_runprov.py b/datalad_metalad/extractors/tests/test_runprov.py index 4b1e3d66..895529b1 100644 --- a/datalad_metalad/extractors/tests/test_runprov.py +++ b/datalad_metalad/extractors/tests/test_runprov.py @@ -8,8 +8,6 @@ # ## ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ## """Test runprov metadata extractor""" -from six import text_type - from datalad.distribution.dataset import Dataset from datalad.tests.utils_pytest import ( assert_in, @@ -48,7 +46,7 @@ def test_custom_dsmeta(path=None): res = ds.meta_extract(extractorname='metalad_runprov', path='dummy0') assert_result_count(res, 1) eq_(res[0]["type"], "file") - eq_(res[0]["path"], text_type(ds.pathobj / 'dummy0')) + eq_(res[0]["path"], str(ds.pathobj / 'dummy0')) for r in res: # we have something from the extractor md = r.get('metadata_record', {}).get('extracted_metadata', None) @@ -80,7 +78,7 @@ def test_custom_dsmeta(path=None): extractorname='metalad_runprov', path='dummy0') assert_result_count(fileres, 1) assert_result_count( - fileres, 1, type='file', path=text_type(ds.pathobj / 'dummy0')) + fileres, 1, type='file', path=str(ds.pathobj / 'dummy0')) # smoke test to see if anything breaks with a record in a sidecar # file @@ -97,7 +95,7 @@ def test_custom_dsmeta(path=None): assert_result_count(res, 1) eq_(res[0]['type'], 'file') assert_result_count( - res, 1, type='file', path=text_type(ds.pathobj / 'dummy_side')) + res, 1, type='file', path=str(ds.pathobj / 'dummy_side')) # check that it survives a partial report (no _core metadata extracted) # for JSON-LD reporting diff --git a/datalad_metalad/tests/__init__.py b/datalad_metalad/tests/__init__.py index d2a5fddd..5b2f0adc 100644 --- a/datalad_metalad/tests/__init__.py +++ b/datalad_metalad/tests/__init__.py @@ -1,4 +1,3 @@ -from six import text_type from datalad.api import ( Dataset, save, @@ -20,7 +19,7 @@ def make_ds_hierarchy_with_metadata(path): ds.repo.set_metadata('file.dat', reset={'tag': ['one', 'two']}) subds = ds.create('sub') # we need one real piece of content for metadata extraction - (subds.pathobj / 'real').write_text(text_type('real')) + (subds.pathobj / 'real').write_text('real') ds.save(recursive=True, result_renderer="disabled") return ds, subds diff --git a/requirements-devel.txt b/requirements-devel.txt index bd215efc..cea54f19 100644 --- a/requirements-devel.txt +++ b/requirements-devel.txt @@ -7,7 +7,6 @@ pre-commit pyyaml pytest pytest-cov -six # required for extractor tests ExifRead diff --git a/requirements.txt b/requirements.txt index b94b33d3..01bcfbb7 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -six datalad>=0.18 sphinx>=1.7.8 sphinx-rtd-theme diff --git a/setup.cfg b/setup.cfg index c4f40c19..e82c41b4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -14,7 +14,6 @@ classifiers = [options] python_requires = >= 3.7 install_requires = - six datalad >= 0.18 datalad-metadata-model >=0.3.10 datalad-deprecated