Ejemplo n.º 1
0
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
Ejemplo n.º 2
0
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
Ejemplo n.º 3
0
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()
Ejemplo n.º 4
0
    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")
Ejemplo n.º 5
0
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)
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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
Ejemplo n.º 8
0
 def _generate_filename_(self):
     return FS.file_or_folder(
             Template(self.source.filename.path).render(self.data))
Ejemplo n.º 9
0
 def combine_path(parent, leaf):
     return FS.file_or_folder(parent.child(leaf))