@@ -369,63 +369,30 @@ def file_path_to_source_class(file_path, options):
369369 Use a file path to get the :doc:`uproot.source.chunk.Source` class that would read it.
370370
371371 Returns a tuple of (class, file_path) where the class is a subclass of :doc:`uproot.source.chunk.Source`.
372-
373- The "handler" option is the preferred way to specify a custom source class.
374- The "*_handler" options are for backwards compatibility and will override the "handler" option if set.
375372 """
373+
376374 import uproot .source .chunk
377375
378376 file_path = regularize_path (file_path )
379377
380- out = options ["handler" ]
381- if out is not None :
382- if not (isinstance (out , type ) and issubclass (out , uproot .source .chunk .Source )):
383- raise TypeError (
384- f"'handler' is not a class object inheriting from Source: { out !r} "
385- )
386- # check if "object_handler" is set
387- if (
388- options ["object_handler" ] is not None
389- or options ["file_handler" ] is not None
390- or options ["xrootd_handler" ] is not None
391- or options ["s3_handler" ] is not None
392- or options ["http_handler" ] is not None
378+ source_cls = options ["handler" ]
379+ if source_cls is not None :
380+ if not (
381+ isinstance (source_cls , type )
382+ and issubclass (source_cls , uproot .source .chunk .Source )
393383 ):
394- # These options will override the "handler" option for backwards compatibility
395- warnings .warn (
396- """In version 5.2.0, the '*_handler' argument ('http_handler`, 's3_handler', etc.) will be removed from 'uproot.open'. Use 'handler' instead.""" ,
397- stacklevel = 1 ,
384+ raise TypeError (
385+ f"'handler' is not a class object inheriting from Source: { source_cls !r} "
398386 )
399- else :
400- return out , file_path
387+ return source_cls , file_path
401388
402389 if (
403390 not isinstance (file_path , str )
404391 and hasattr (file_path , "read" )
405392 and hasattr (file_path , "seek" )
406393 ):
407- out = options ["object_handler" ]
408- if out is None :
409- out = uproot .source .object .ObjectSource
410- else :
411- warnings .warn (
412- f"""In version 5.2.0, the 'object_handler' argument will be removed from 'uproot.open'. Use
413- uproot.open(..., handler={ out !r} )
414- instead.
415-
416- To raise these warnings as errors (and get stack traces to find out where they're called), run
417- import warnings
418- warnings.filterwarnings("error", module="uproot.*")
419- after the first `import uproot` or use `@pytest.mark.filterwarnings("error:::uproot.*")` in pytest.""" ,
420- DeprecationWarning ,
421- stacklevel = 1 ,
422- )
423- if not (isinstance (out , type ) and issubclass (out , uproot .source .chunk .Source )):
424- raise TypeError (
425- f"'object_handler' is not a class object inheriting from Source: { out !r} "
426- )
427-
428- return out , file_path
394+ source_cls = uproot .source .object .ObjectSource
395+ return source_cls , file_path
429396
430397 windows_absolute_path = None
431398 if win and _windows_absolute_path_pattern .match (file_path ) is not None :
@@ -457,107 +424,27 @@ def file_path_to_source_class(file_path, options):
457424 else :
458425 file_path = windows_absolute_path
459426
460- out = options ["file_handler" ]
461- if out is None :
462- out = uproot .source .file .MemmapSource
463- else :
464- warnings .warn (
465- f"""In version 5.2.0, the 'file_handler' argument will be removed from 'uproot.open'. Use
466- uproot.open(..., handler={ out !r}
467- instead.
468-
469- To raise these warnings as errors (and get stack traces to find out where they're called), run
470- import warnings
471- warnings.filterwarnings("error", module="uproot.*")
472- after the first `import uproot` or use `@pytest.mark.filterwarnings("error:::uproot.*")` in pytest.""" ,
473- DeprecationWarning ,
474- stacklevel = 1 ,
475- )
427+ # uproot.source.file.MemmapSource
428+ source_cls = uproot .source .fsspec .FSSpecSource
476429
477- if not (isinstance (out , type ) and issubclass (out , uproot .source .chunk .Source )):
478- raise TypeError (
479- "'file_handler' is not a class object inheriting from Source: "
480- + repr (out )
481- )
482- return out , os .path .expanduser (file_path )
430+ return source_cls , os .path .expanduser (file_path )
483431
484432 elif scheme == "root" :
485- out = options ["xrootd_handler" ]
486- if out is None :
487- out = uproot .source .xrootd .XRootDSource
488- else :
489- warnings .warn (
490- f"""In version 5.2.0, the 'xrootd_handler' argument will be removed from 'uproot.open'. Use
491- uproot.open(..., handler={ out !r}
492- instead.
493-
494- To raise these warnings as errors (and get stack traces to find out where they're called), run
495- import warnings
496- warnings.filterwarnings("error", module="uproot.*")
497- after the first `import uproot` or use `@pytest.mark.filterwarnings("error:::uproot.*")` in pytest.""" ,
498- DeprecationWarning ,
499- stacklevel = 1 ,
500- )
501- if not (isinstance (out , type ) and issubclass (out , uproot .source .chunk .Source )):
502- raise TypeError (
503- "'xrootd_handler' is not a class object inheriting from Source: "
504- + repr (out )
505- )
506- return out , file_path
433+ # uproot.source.xrootd.XRootDSource
434+ source_cls = uproot .source .fsspec .FSSpecSource
435+ return source_cls , file_path
507436
508437 elif scheme == "s3" :
509- out = options ["s3_handler" ]
510- if out is None :
511- out = uproot .source .s3 .S3Source
512- else :
513- warnings .warn (
514- f"""In version 5.2.0, the 's3_handler' argument will be removed from 'uproot.open'. Use
515- uproot.open(..., handler={ out !r}
516- instead.
517-
518- To raise these warnings as errors (and get stack traces to find out where they're called), run
519- import warnings
520- warnings.filterwarnings("error", module="uproot.*")
521- after the first `import uproot` or use `@pytest.mark.filterwarnings("error:::uproot.*")` in pytest.""" ,
522- DeprecationWarning ,
523- stacklevel = 1 ,
524- )
525- if not (isinstance (out , type ) and issubclass (out , uproot .source .chunk .Source )):
526- raise TypeError (
527- "'s3' is not a class object inheriting from Source: " + repr (out )
528- )
529- return out , file_path
438+ # https://github.com/scikit-hep/uproot5/pull/1012
439+ source_cls = uproot .source .s3 .S3Source
440+ return source_cls , file_path
530441
531442 elif scheme in ("http" , "https" ):
532- out = options ["http_handler" ]
533- if out is None :
534- out = uproot .source .http .HTTPSource
535- else :
536- warnings .warn (
537- f"""In version 5.2.0, the 'http_handler' argument will be removed from 'uproot.open'. Use
538- uproot.open(..., handler={ out !r}
539- instead.
540-
541- To raise these warnings as errors (and get stack traces to find out where they're called), run
542- import warnings
543- warnings.filterwarnings("error", module="uproot.*")
544- after the first `import uproot` or use `@pytest.mark.filterwarnings("error:::uproot.*")` in pytest.""" ,
545- DeprecationWarning ,
546- stacklevel = 1 ,
547- )
548- if not (isinstance (out , type ) and issubclass (out , uproot .source .chunk .Source )):
549- raise TypeError (
550- "'http_handler' is not a class object inheriting from Source: "
551- + repr (out )
552- )
553- return out , file_path
554-
555- else :
556- # try to use fsspec before raising an error
557- if scheme in _schemes :
558- return uproot .source .fsspec .FSSpecSource , file_path
443+ # uproot.source.http.HTTPSource
444+ source_cls = uproot .source .fsspec .FSSpecSource
445+ return source_cls , file_path
559446
560- raise ValueError ( f"URI scheme not recognized: { file_path } " )
447+ return uproot . source . fsspec . FSSpecSource , file_path
561448
562449
563450if isinstance (__builtins__ , dict ):
0 commit comments