77import tempfile
88import glob
99import urlparse
10- import pprint
1110from collections import Iterable
1211import errno
1312import shutil
@@ -640,8 +639,8 @@ def mergedirs(listing):
640639 r .extend (ents .itervalues ())
641640 return r
642641
643- def scandeps (base , doc , reffields , urlfields , loadref ):
644- # type: (Text, Any, Set[Text], Set[Text], Callable[[Text, Text], Any]) -> List[Dict[Text, Text]]
642+ def scandeps (base , doc , reffields , urlfields , loadref , urljoin = urlparse . urljoin ):
643+ # type: (Text, Any, Set[Text], Set[Text], Callable[[Text, Text], Any], Callable[[Text, Text], Text] ) -> List[Dict[Text, Text]]
645644 r = [] # type: List[Dict[Text, Text]]
646645 deps = None # type: Dict[Text, Any]
647646 if isinstance (doc , dict ):
@@ -660,7 +659,7 @@ def scandeps(base, doc, reffields, urlfields, loadref):
660659 if u and not u .startswith ("_:" ):
661660 deps = {
662661 "class" : doc ["class" ],
663- "location" : urlparse . urljoin (base , u )
662+ "location" : urljoin (base , u )
664663 }
665664 if doc ["class" ] == "Directory" and "listing" in doc :
666665 deps ["listing" ] = doc ["listing" ]
@@ -670,23 +669,23 @@ def scandeps(base, doc, reffields, urlfields, loadref):
670669 r .append (deps )
671670 else :
672671 if doc ["class" ] == "Directory" and "listing" in doc :
673- r .extend (scandeps (base , doc ["listing" ], reffields , urlfields , loadref ))
672+ r .extend (scandeps (base , doc ["listing" ], reffields , urlfields , loadref , urljoin = urljoin ))
674673 elif doc ["class" ] == "File" and "secondaryFiles" in doc :
675- r .extend (scandeps (base , doc ["secondaryFiles" ], reffields , urlfields , loadref ))
674+ r .extend (scandeps (base , doc ["secondaryFiles" ], reffields , urlfields , loadref , urljoin = urljoin ))
676675
677676 for k , v in doc .iteritems ():
678677 if k in reffields :
679678 for u in aslist (v ):
680679 if isinstance (u , dict ):
681- r .extend (scandeps (base , u , reffields , urlfields , loadref ))
680+ r .extend (scandeps (base , u , reffields , urlfields , loadref , urljoin = urljoin ))
682681 else :
683682 sub = loadref (base , u )
684- subid = urlparse . urljoin (base , u )
683+ subid = urljoin (base , u )
685684 deps = {
686685 "class" : "File" ,
687686 "location" : subid
688687 }
689- sf = scandeps (subid , sub , reffields , urlfields , loadref )
688+ sf = scandeps (subid , sub , reffields , urlfields , loadref , urljoin = urljoin )
690689 if sf :
691690 deps ["secondaryFiles" ] = sf
692691 deps = nestdir (base , deps )
@@ -695,19 +694,20 @@ def scandeps(base, doc, reffields, urlfields, loadref):
695694 for u in aslist (v ):
696695 deps = {
697696 "class" : "File" ,
698- "location" : urlparse . urljoin (base , u )
697+ "location" : urljoin (base , u )
699698 }
700699 deps = nestdir (base , deps )
701700 r .append (deps )
702701 elif k not in ("listing" , "secondaryFiles" ):
703- r .extend (scandeps (base , v , reffields , urlfields , loadref ))
702+ r .extend (scandeps (base , v , reffields , urlfields , loadref , urljoin = urljoin ))
704703 elif isinstance (doc , list ):
705704 for d in doc :
706- r .extend (scandeps (base , d , reffields , urlfields , loadref ))
705+ r .extend (scandeps (base , d , reffields , urlfields , loadref , urljoin = urljoin ))
707706
708707 if r :
709708 normalizeFilesDirs (r )
710709 r = mergedirs (r )
710+
711711 return r
712712
713713def compute_checksums (fs_access , fileobj ):
0 commit comments