Builds this scaffold out to the given filepath with the 
        chosen structure.
        
        :param      outpath   | <str>
                    structure | <xml.etree.ElementTree.Element> || None

        :return     <bool> | success
503969
def build(self, outpath, structure=None):
        
        if not os.path.exists(outpath):
            return False

        opts = {'scaffold': self}

        if structure is not None:
            xstruct = structure
        else:
            xstruct = self.structure()

        if zipfile.is_zipfile(self.source()):
            zfile = zipfile.ZipFile(self.source(), 'r')
        else:
            zfile = None
            base = os.path.dirname(self.source())

        # build the structure information
        # noinspection PyShadowingNames
        def build_level(root, xlevel):
            # ignore the entry
            if xlevel.get('enabled', 'True') == 'False':
                return

            # create a folder
            if xlevel.tag == 'folder':
                name = makotext.render(xlevel.get('name'), opts)
                dirname = os.path.join(root, name)
                if not os.path.exists(dirname):
                    os.mkdir(dirname)

                for xchild in xlevel:
                    build_level(dirname, xchild)

            # create a file
            elif xlevel.tag == 'file':
                name = makotext.render(xlevel.get('name'), opts)
                fname = os.path.join(root, name)

                # create from a template
                templ = xlevel.get('templ')
                if templ:
                    if zfile:
                        templ_str = zfile.read('templ/{0}'.format(templ))
                    else:
                        templ_path = os.path.join(base, 'templ', templ)
                        templ_str = open(templ_path, 'r').read()

                    rendered = makotext.render(templ_str, opts)
                    rendered = rendered.replace('\r\n', '\r')

                    f = open(fname, 'w')
                    f.write(rendered)
                    f.close()

                # create a blank file
                else:
                    f = open(fname, 'w')
                    f.close()

        for xlevel in xstruct:
            build_level(outpath, xlevel)

        if zfile:
            zfile.close()
        return True
142410
def load(filename):
        
        # parse a zipped file
        if zipfile.is_zipfile(filename):
            zfile = zipfile.ZipFile(filename, 'r')
            try:
                xml = ElementTree.fromstring(zfile.read('scaffold.xml'))
            except StandardError:
                logger.exception('Failed to load scaffold: {0}'.format(filename))
                zfile.close()
                return None
            zfile.close()

        # parse a standard xml file
        else:
            try:
                xml = ElementTree.parse(filename).getroot()
            except StandardError:
                logger.exception('Failed to load scaffold: {0}'.format(filename))
                return None

        # generate a scaffold
        scaffold = Scaffold()
        scaffold.setSource(filename)
        scaffold.setName(xml.get('name', 'Missing'))
        scaffold.setGroup(xml.get('group', 'Default'))
        scaffold.setLanguage(xml.get('lang', 'Python'))
        scaffold.setIcon(xml.get('icon', ''))

        # define properties
        xprops = xml.find('properties')
        if xprops is not None:
            for xprop in xprops:
                scaffold.addProperty(Property.fromXml(xprop))

        return scaffold
1106901
def makepath(s, as_file=False):
    
    if s is None:
        return None
    result = FilePath(s) if (os.path.isfile(s) or as_file) else DirectPath(s)
    return result.expandall()
911764
def out_to_in(self, out_file):
        
        in_file = os.path.basename(out_file).replace("out", "in", 1)
        dest = os.path.join(self.indir.path, in_file)

        if os.path.exists(dest) and not os.path.islink(dest):
            logger.warning("Will overwrite %s with %s" % (dest, out_file))

        os.rename(out_file, dest)
        return dest
130718
def build(pattern=None, path='.'):
    
    path = abspath(path)
    c = Clay(path)
    c.build(pattern)
774438
def dump_file_by_path(self, path, **kwargs):
        
        file = self.state.fs.get(path)
        if file is None:
            return None
        return file.concretize(**kwargs)
188088
def path_from_structure(cls, ndivsm, structure):
        """"""
        return cls._path(ndivsm,  structure=structure, comment="K-path generated automatically from structure")
773209
def write(self, output_filepath):
        
        with open(output_filepath, 'w') as out_file:
            out_file.write(self.__str__())
889252
def scaffold(args):
    
    p = OptionParser(scaffold.__doc__)
    p.set_aligner(aligner="bwa")
    p.set_home("sspace")
    p.set_cpus()
    opts, args = p.parse_args(args)

    if len(args) < 1:
        sys.exit(not p.print_help())

    contigs = args[0]
    libtxt = write_libraries(args[1:], aligner=opts.aligner)
    # Requires getopts.pl which may be missing
    download("http://web.vims.edu/bridge/bridge2/aw/lib/getopts.pl")

    cmd = "perl " + op.join(opts.sspace_home, "SSPACE_Standard_v3.0.pl")
    cmd += " -l {0} -s {1} -T {2}".format(libtxt, contigs, opts.cpus)
    runsh = "run.sh"
    write_file(runsh, cmd)
1170371
def from_path(path):
  
  for item in ref:
    build = ref[item]
    valid_ = build['is_valid']
    if valid_(path) is True:
      return build['builder'](path)
  raise errors.InvalidProjectStructure()
243836
def __make_skeleton(self, path):
        """"""
        
        self.path = path
        if os.path.exists(os.path.join(self.path, "output", self.name)):
            shutil.rmtree(os.path.join(self.path, "output", self.name))
        
        self.path_folders = os.path.join(self.path, "output", self.name, "site", "static")
        os.makedirs(self.path_folders)
        
        self.path_folders = os.path.join(self.path, "output", self.name, "site", "static", "css")
        os.makedirs(self.path_folders)
        
        self.path_folders = os.path.join(self.path, "output", self.name, "site", "static", "js")
        os.makedirs(self.path_folders)
        
        for key in self.sections:
            self.path_folders = os.path.join(self.path, "output", self.name, "site", key)
            os.makedirs(self.path_folders)
1088228
def build(self, filenames, cl_args=None, link_args=None,
              x64=False, out_dir=''):
        
        if not cl_args:
            cl_args = []
        if not link_args:
            link_args = []
        msvc, lib = self.vc.get_bin_and_lib(x64)
        lib = self.make_lib(lib)
        if out_dir:
            cl_args.append('/Fo:' + out_dir + '\\')
        include = self.make_inc(self.vc.inc + self.sdk.inc)
        cl_args.extend(include + filenames)
        try:
            msvc.run_cl('/c', *cl_args)
        except CalledProcessError as error:
            logging.error(_('failed to compile: %s'), filenames)
            logging.error(_('cl.exe returned:\n%s'), error.output)
            return False
        link_args.extend(lib + self.make_objs(filenames, out_dir))
        try:
            msvc.run_link(*link_args)
        except CalledProcessError as error:
            logging.error(_('failed to link: %s'), filenames)
            logging.error(_('link.exe returned:\n%s'), error.output)
            return False
        return True
480839
def build_output_directory(self, path):
        '''
        
        '''
        # If we have not already created an output directory for this target
        # file, create one now
        if not has_key(self.extraction_directories, path):
            basedir = os.path.dirname(path)
            basename = os.path.basename(path)

            if basedir != self.directory:
                # During recursive extraction, extracted files will be in subdirectories
                # of the CWD. This allows us to figure out the subdirectory by simply
                # splitting the target file's base directory on our known CWD.
                #
                # However, the very *first* file being scanned is not necessarily in the
                # CWD, so this will raise an IndexError. This is easy to handle though,
                # since the very first file being scanned needs to have its contents
                # extracted to ${CWD}/_basename.extracted, so we just set the subdir
                # variable to a blank string when an IndexError is encountered.
                try:
                    subdir = basedir.split(self.directory)[1][1:]
                except IndexError as e:
                    subdir = ""
            else:
                subdir = ""

            if self.output_directory_override:
                output_directory = os.path.join(self.directory, subdir, self.output_directory_override)
            else:
                outdir = os.path.join(self.directory, subdir, '_' + basename)
                output_directory = unique_file_name(outdir, extension='extracted')

            if not os.path.exists(output_directory):
                os.mkdir(output_directory)

            self.extraction_directories[path] = output_directory
            self.output[path].directory = os.path.realpath(output_directory) + os.path.sep
        # Else, just use the already created directory
        else:
            output_directory = self.extraction_directories[path]

        return output_directory
1371394
def _copy_so(self, outpath):
        
        from os import path
        if not path.isfile(outpath) and path.isfile(self.link):
            from shutil import copy
            copy(self.link, outpath)
520781
def export_to_file(self, filepath, level_prefix = '  '):
        
        xmldom = self.export_to_dom()
        xmlstr = xmldom.toprettyxml(level_prefix, '\n',)


        f = open(filepath, 'w')
        f.write(xmlstr)
        f.close()
563759
def _write_to_filepath(content, output):
    
    outdir = os.path.dirname(output)
    if outdir and not os.path.exists(outdir):
        os.makedirs(outdir)

    with anytemplate.compat.copen(output, 'w') as out:
        out.write(content)
1194935
def build_tree(requester)
      root_node = build_root_node(requester)
      # Search out the implementations directory structure for endpoints
      if defined?(self.implementation_root)
        # For each endpoints directory, recurse down it to load the modules
        endpoints_directories.each do |endpoints_directories|
          Dir["#{endpoints_directories}/**/*.rb"].each { |f| require(f) }
        end
        build_node_children(self.endpoints_module, root_node, requester)
      end
      root_node
    end