scruffy/file.py
def add(self, *args, **kwargs):
        """
        Add objects to the directory.
        """
        for key in kwargs:
            if isinstance(kwargs[key], str):
                self._children[key] = File(kwargs[key])
            else:
                self._children[key] = kwargs[key]
            self._children[key]._parent = self
            self._children[key]._env = self._env

        added = []
        for arg in args:
            if isinstance(arg, File):
                self._children[arg.name] = arg
                self._children[arg.name]._parent = self
                self._children[arg.name]._env = self._env
            elif isinstance(arg, str):
                f = File(arg)
                added.append(f)
                self._children[arg] = f
                self._children[arg]._parent = self
                self._children[arg]._env = self._env
            else:
                raise TypeError(type(arg))

        # if we were passed a single file/filename, return the File object for convenience
        if len(added) == 1:
            return added[0]
        if len(args) == 1:
            return args[0]
def add(self, *args, **kwargs):
        """
        Add objects to the directory.
        """
        for key in kwargs:
            if isinstance(kwargs[key], str):
                self._children[key] = File(kwargs[key])
            else:
                self._children[key] = kwargs[key]
            self._children[key]._parent = self
            self._children[key]._env = self._env

        added = []
        for arg in args:
            if isinstance(arg, File):
                self._children[arg.name] = arg
                self._children[arg.name]._parent = self
                self._children[arg.name]._env = self._env
            elif isinstance(arg, str):
                f = File(arg)
                added.append(f)
                self._children[arg] = f
                self._children[arg]._parent = self
                self._children[arg]._env = self._env
            else:
                raise TypeError(type(arg))

        # if we were passed a single file/filename, return the File object for convenience
        if len(added) == 1:
            return added[0]
        if len(args) == 1:
            return args[0]
def add ( self , * args , * * kwargs ) : for key in kwargs : if isinstance ( kwargs [ key ] , str ) : self . _children [ key ] = File ( kwargs [ key ] ) else : self . _children [ key ] = kwargs [ key ] self . _children [ key ] . _parent = self self . _children [ key ] . _env = self . _env added = [ ] for arg in args : if isinstance ( arg , File ) : self . _children [ arg . name ] = arg self . _children [ arg . name ] . _parent = self self . _children [ arg . name ] . _env = self . _env elif isinstance ( arg , str ) : f = File ( arg ) added . append ( f ) self . _children [ arg ] = f self . _children [ arg ] . _parent = self self . _children [ arg ] . _env = self . _env else : raise TypeError ( type ( arg ) ) # if we were passed a single file/filename, return the File object for convenience if len ( added ) == 1 : return added [ 0 ] if len ( args ) == 1 : return args [ 0 ]
Add objects to the directory.
Add objects to the directory .