def test_remove_folder(): f = FS(__file__).parent c = f.child_folder("__test__") assert not c.exists c.make() assert c.exists c.delete() assert not c.exists
def test_create_folder(): f = FS(__file__).parent assert f.exists f.make() assert True # No Exceptions c = f.child_folder("__test__") assert not c.exists c.make() assert c.exists shutil.rmtree(unicode(c)) assert not c.exists
def test_can_remove_file(): f = FS(__file__).parent c = f.child_folder("__test__") c.make() assert c.exists txt = "abc" abc = File(c.child("abc.txt")) abc.write(txt) assert abc.exists abc.delete() assert not abc.exists abc.delete() assert True # No Exception c.delete()
def create(self, args): """ The create command. Creates a new site from the template at the given sitepath. """ sitepath = self.main(args) markers = ['content', 'layout', 'site.yaml'] exists = any((FS(sitepath.child(item)).exists for item in markers)) if exists and not args.overwrite: raise HydeException( "The given site path [%s] already contains a hyde site." " Use -f to overwrite." % sitepath) layout = Layout.find_layout(args.layout) self.logger.info("Creating site at [%s] with layout [%s]" % (sitepath, layout)) if not layout or not layout.exists: raise HydeException( "The given layout is invalid. Please check if you have the" " `layout` in the right place and the environment variable(%s)" " has been setup properly if you are using custom path for" " layouts" % HYDE_DATA) layout.copy_contents_to(args.sitepath) self.logger.info("Site creation complete")
def test_file_or_folder(): f = FS.file_or_folder(__file__) assert isinstance(f, File) f = FS.file_or_folder(File(__file__).parent) assert isinstance(f, Folder)
def __init__(self, source): super(Processable, self).__init__() self.source = FS.file_or_folder(source) self.is_processable = True self.uses_template = True self._relative_deploy_path = None
def _generate_filename_(self): return FS.file_or_folder( Template(self.source.filename.path).render(self.data))
def combine_path(parent, leaf): return FS.file_or_folder(parent.child(leaf))