def _load_files(self):
        """Load other files"""

        def copy_dir(path):
            for (dr, _, files) in walk(path):
                for fn in files:

                    if '__pycache__' in fn:
                        continue

                    relpath = dr.replace(self.source_dir, '').strip('/')
                    src = parse_app_url(join(dr, fn))
                    dest = join(relpath, fn)

                    resource = src.get_resource()

                    self._load_file( dest, resource.read())

        for term in self.resources(term = 'Root.Pythonlib'):

            uv = parse_app_url(term.value)
            ur = parse_app_url(self.source_dir)

            # In the case that the input doc is a file, and the ref is to a file,
            # try interpreting the file as relative.
            if ur.proto == 'file' and uv.proto == 'file':

                # Either a file or a directory
                path = join(self.source_dir, uv.path)
                if isdir(path):
                    copy_dir(path)

            else:
                # Load it as a URL
                f = self._get_ref_contents(term)
                try:
                    self._load_file(term.value,f.read() )
                except Exception as e:
                    raise PackageError("Failed to load file for '{}': {} ".format(term.value, e))

        nb_dir = join(self.source_dir, 'notebooks')

        if exists(nb_dir) and isdir(nb_dir):
            copy_dir(nb_dir)
def _load_files ( self ) : def copy_dir ( path ) : for ( dr , _ , files ) in walk ( path ) : for fn in files : if '__pycache__' in fn : continue relpath = dr . replace ( self . source_dir , '' ) . strip ( '/' ) src = parse_app_url ( join ( dr , fn ) ) dest = join ( relpath , fn ) resource = src . get_resource ( ) self . _load_file ( dest , resource . read ( ) ) for term in self . resources ( term = 'Root.Pythonlib' ) : uv = parse_app_url ( term . value ) ur = parse_app_url ( self . source_dir ) if ur . proto == 'file' and uv . proto == 'file' : path = join ( self . source_dir , uv . path ) if isdir ( path ) : copy_dir ( path ) else : f = self . _get_ref_contents ( term ) try : self . _load_file ( term . value , f . read ( ) ) except Exception as e : raise PackageError ( "Failed to load file for '{}': {} " . format ( term . value , e ) ) nb_dir = join ( self . source_dir , 'notebooks' ) if exists ( nb_dir ) and isdir ( nb_dir ) : copy_dir ( nb_dir )
Load other files