Usage: create_sedml2 output-filename
180598
def main (args):
  
  if (len(args) != 2):
    print(main.__doc__)
    sys.exit(1);

  # create the document
  doc = libsedml.SedDocument();
  doc.setLevel(1);
  doc.setVersion(3);

  # create a data description
  
  ddesc = doc.createDataDescription()
  ddesc.setId('data1')
  ddesc.setName('Oscli Timecourse data')
  ddesc.setSource('foo.numl')
  
  # create data source 
  dsource = ddesc.createDataSource()
  dsource.setId('dataS1')
  
  # create slice 
  slice = dsource.createSlice()
  slice.setReference('SpeciesIds')
  slice.setValue('S1')
  
  # specify mapping
  timeDesc = libsedml.CompositeDescription()
  timeDesc.setIndexType('double')
  timeDesc.setId('time')
  timeDesc.setName('time')
  
  speciesDesc = timeDesc.createCompositeDescription()
  speciesDesc.setIndexType('string')
  speciesDesc.setId('SpeciesIds')
  speciesDesc.setName('SpeciesIds')
  
  concentrationDesc = speciesDesc.createAtomicDescription()
  concentrationDesc.setValueType("double")
  concentrationDesc.setName("Concentrations")
  
  dimDesc = ddesc.createDimensionDescription()
  dimDesc.append(timeDesc)
  
  # write the document
  libsedml.writeSedML(doc, args[1]);
456785
private File createNewFile(File outputDir, String prefix, String extension) throws IOException {
        String dateTime = new SimpleDateFormat("yyyyMMdd.HHmmss").format(new Date());
        File outputFile;
        do {
            String pid = PID == null ? "" : PID + '.';
            int sequenceNumber = nextSequenceNumber.getAndIncrement();
            outputFile = new File(outputDir, String.format("%s.%s.%s%04d.%s", prefix, dateTime, pid, sequenceNumber, extension));
        } while (outputFile.exists());

        return outputFile;
    }
130601
function dumpSourceToFile(sourcecode, errname, err_id, options, ex) {
    var dumpfile;

    try {
        var dumpPaths = [(options.outfile ? path.dirname(options.outfile) : null), options.inputPath, process.cwd()];
        var dumpName = path.basename(options.inputFilename || options.moduleName || (options.outfile ? path.dirname(options.outfile) : null) || options.defaultModuleName || errname)
        .replace(/\.[a-z]{1,5}$/i, '')          // remove extension .y, .yacc, .jison, ...whatever
        .replace(/[^a-z0-9_]/ig, '_');          // make sure it's legal in the destination filesystem: the least common denominator.
        if (dumpName === '' || dumpName === '_') {
            dumpName = '__bugger__';
        }
        err_id = err_id || 'XXX';

        var ts = new Date();
        var tm = ts.getUTCFullYear() +
            '_' + pad(ts.getUTCMonth() + 1) +
            '_' + pad(ts.getUTCDate()) +
            'T' + pad(ts.getUTCHours()) +
            '' + pad(ts.getUTCMinutes()) +
            '' + pad(ts.getUTCSeconds()) +
            '.' + pad(ts.getUTCMilliseconds(), 3) +
            'Z';

        dumpName += '.fatal_' + err_id + '_dump_' + tm + '.js';

        for (var i = 0, l = dumpPaths.length; i < l; i++) {
            if (!dumpPaths[i]) {
                continue;
            }

            try {
                dumpfile = path.normalize(dumpPaths[i] + '/' + dumpName);
                fs.writeFileSync(dumpfile, sourcecode, 'utf8');
                console.error("****** offending generated " + errname + " source code dumped into file: ", dumpfile);
                break;          // abort loop once a dump action was successful!
            } catch (ex3) {
                //console.error("generated " + errname + " source code fatal DUMPING error ATTEMPT: ", i, " = ", ex3.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex3.stack);
                if (i === l - 1) {
                    throw ex3;
                }
            }
        }
    } catch (ex2) {
        console.error("generated " + errname + " source code fatal DUMPING error: ", ex2.message, " -- while attempting to dump into file: ", dumpfile, "\n", ex2.stack);
    }

    // augment the exception info, when available:
    if (ex) {
        ex.offending_source_code = sourcecode;
        ex.offending_source_title = errname;
        ex.offending_source_dumpfile = dumpfile;
    }    
}
1215873
def _create_update_from_file(mode='create', uuid=None, path=None):
    '''
    
    '''
    ret = {}
    if not os.path.isfile(path) or path is None:
        ret['Error'] = 'File ({0}) does not exists!'.format(path)
        return ret
    # vmadm validate create|update [-f <filename>]
    cmd = 'vmadm validate {mode} {brand} -f {path}'.format(
        mode=mode,
        brand=get(uuid)['brand'] if uuid is not None else '',
        path=path
    )
    res = __salt__['cmd.run_all'](cmd)
    retcode = res['retcode']
    if retcode != 0:
        ret['Error'] = _exit_status(retcode)
        if 'stderr' in res:
            if res['stderr'][0] == '{':
                ret['Error'] = salt.utils.json.loads(res['stderr'])
            else:
                ret['Error'] = res['stderr']
        return ret
    # vmadm create|update [-f <filename>]
    cmd = 'vmadm {mode} {uuid} -f {path}'.format(
        mode=mode,
        uuid=uuid if uuid is not None else '',
        path=path
    )
    res = __salt__['cmd.run_all'](cmd)
    retcode = res['retcode']
    if retcode != 0:
        ret['Error'] = _exit_status(retcode)
        if 'stderr' in res:
            if res['stderr'][0] == '{':
                ret['Error'] = salt.utils.json.loads(res['stderr'])
            else:
                ret['Error'] = res['stderr']
        return ret
    else:
        if res['stderr'].startswith('Successfully created VM'):
            return res['stderr'][24:]
    return True
1133159
def _gen_file_name(self):
        '''
        
        '''
        date = datetime.datetime.now()
        dt = "{}-{}-{}-{}-{}-{}-{}".format(str(date.year),str(date.month),str(date.day),str(date.hour),str(date.minute),str(date.second),str(random.randint(0,10000)))
        return self._output_filename_pattern.format(dt)
930700
def GenerateFile(self, input_filename=None, output_filename=None):
    """"""
    if input_filename is None:
      input_filename = output_filename + ".in"
    if output_filename[-3:] == ".in":
      output_filename = output_filename[:-3]
    logging.debug("Generating file %s from %s", output_filename, input_filename)

    with io.open(input_filename, "r") as fd:
      data = fd.read()

    with io.open(output_filename, "w") as fd:
      fd.write(config.CONFIG.InterpolateValue(data, context=self.context))
1373709
def create_file_name(file, base_dir)
      file_name = file.split("/").delete_if { |f| f.include?(".") }.first
      unless File.exists?(File.join(base_dir, file_name))
        Dir.mkdir(File.join(base_dir, file_name))
      end
      file_name
    end
800475
def _render_filenames(filenames, zip_file, saltenv, template):
    '''
    
    '''
    if not template:
        return (filenames, zip_file)

    # render the path as a template using path_template_engine as the engine
    if template not in salt.utils.templates.TEMPLATE_REGISTRY:
        raise CommandExecutionError(
            'Attempted to render file paths with unavailable engine '
            '{0}'.format(template)
        )

    kwargs = {}
    kwargs['salt'] = __salt__
    kwargs['pillar'] = __pillar__
    kwargs['grains'] = __grains__
    kwargs['opts'] = __opts__
    kwargs['saltenv'] = saltenv

    def _render(contents):
        '''
        Render :param:`contents` into a literal pathname by writing it to a
        temp file, rendering that file, and returning the result.
        '''
        # write out path to temp file
        tmp_path_fn = salt.utils.files.mkstemp()
        with salt.utils.files.fopen(tmp_path_fn, 'w+') as fp_:
            fp_.write(salt.utils.stringutils.to_str(contents))
        data = salt.utils.templates.TEMPLATE_REGISTRY[template](
            tmp_path_fn,
            to_str=True,
            **kwargs
        )
        salt.utils.files.safe_rm(tmp_path_fn)
        if not data['result']:
            # Failed to render the template
            raise CommandExecutionError(
                'Failed to render file path with error: {0}'.format(
                    data['data']
                )
            )
        else:
            return data['data']

    filenames = _render(filenames)
    zip_file = _render(zip_file)
    return (filenames, zip_file)
866750
def get_new_filename(diff_part):
    
    regexps = (
        # e.g. "+++ b/foo/bar"
        r'^\+\+\+ b/(.*)',
        # e.g. "+++ /dev/null"
        r'^\+\+\+ (.*)',
    )
    for regexp in regexps:
        r = re.compile(regexp, re.MULTILINE)
        match = r.search(diff_part)
        if match is not None:
            return match.groups()[0]
    raise MalformedGitDiff("No new filename in diff part found.  "
                           "Examined diff part: {}".format(diff_part))
354492
def create_mef(filename=None):
    
    import pyfits, time

    if not filename:
        ### here I know what filename is to start with.
        import tempfile
        filename=tempfile.mktemp(suffix='.fits')
    else:
        import string, re
        ### filenames gotta be a string and no lead/trailing space
        filename=string.strip(str(filename))
        ### require that the filename ends in .fits
        suffix=re.match(r'^.*.fits$',filename)
        if not suffix:
            filename = filename+'.fits'

    ### create an HDU list
    temp = pyfits.HDUList()

    ### create a primary HDU
    prihdu = pyfits.PrimaryHDU()

    ### build the header
    h=prihdu.header
    h.update('EXTEND',pyfits.TRUE,after='NAXIS')
    h.update('NEXTEND',0,after='EXTEND')
    h.add_comment('MEF created at CADC')
    h.add_comment('Created using '+__name__+' '+__Version__)
    h.add_comment('Extensions may not be in CCD order')
    #h.update('cfh12k',__Version__,comment='split2mef software at CADC')
    h.add_comment('Use the EXTNAME keyword')
    h.add_history('Primary HDU created on '+time.asctime())

    ### stick the HDU onto the HDU list and write to file
    temp.append(prihdu)
    temp.writeto(filename)
    temp.close()

    return(filename)
365840
def process_output(meta_file, outfile_name, code_links):
    '''
    '''

    # Markdown title line
    doc_str = '# ' + meta_file['header'] + '\n'
    doc_str += 'Generated by [py2md](https://github.com/gbowerman/py2md) on '
    doc_str += strftime("%Y-%m-%d %H:%M:%S ") + '\n\n'

    # Create a table of contents if more than one module (i.e. more than one
    # source file)
    if len(meta_file['modules']) > 1:
        doc_str += "## Contents\n"
        chapter_num = 1
        for meta_doc in meta_file['modules']:
            chapter_name = meta_doc['summary_comment']
            chapter_link = chapter_name.lstrip().replace('.', '').replace(' ', '-').lower()
            doc_str += str(chapter_num) + \
                '. [' + chapter_name + '](#' + chapter_link + ')\n'
            chapter_num += 1


    # Document each meta-file
    for meta_doc in meta_file['modules']:
        doc_str += '## ' + meta_doc['summary_comment'] + '\n'
        doc_str += '[source file](' + meta_doc['source_file'] + ')' + '\n'
        for function_info in meta_doc['functions']:
            doc_str += '### ' + function_info['name'] + '\n'
            doc_str += function_info['definition'] + '\n\n'
            if 'comments' in function_info:
                doc_str += '```\n' + function_info['comments'] + '\n```\n\n'

    # write the markdown to file
    print('Writing file: ' + outfile_name)
    out_file = open(outfile_name, 'w')
    out_file.write(doc_str)
    out_file.close()
203460
def create_filebase_name(self, group_info, extension='gz', file_name=None):
        
        dirname = self.filebase.formatted_dirname(groups=group_info)
        if not file_name:
            file_name = self.filebase.prefix_template + '.' + extension
        return dirname, file_name
498521
def output_filename(name)
      path = File.expand_path(name, output_dir)
      output File.new(path, 'a+')
    end
173397
def create_shn (archive, compression, cmd, verbosity, interactive, filenames):
    """"""
    if len(filenames) > 1:
        raise util.PatoolError("multiple filenames for shorten not supported")
    cmdlist = [util.shell_quote(cmd)]
    cmdlist.extend(['-', util.shell_quote(archive), '<',
        util.shell_quote(filenames[0])])
    return (cmdlist, {'shell': True})
1244408
def dump(self, fname):
        
        with open(fname, 'wb') as f:
            f.write(self.output)
550847
def posix_redirect_output(filename=None, permanent=True):
    
    sys.stdout.flush()
    sys.stderr.flush()

    stdout_fd = sys.stdout.fileno()
    stderr_fd = sys.stderr.fileno()

    if not permanent:
        stdout_fd_copy = os.dup(stdout_fd)
        stderr_fd_copy = os.dup(stderr_fd)

    if filename is None:
        out_fd, filename = tempfile.mkstemp()
    else:
        out_fd = os.open(filename, os.O_WRONLY | os.O_CREAT | os.O_TRUNC)

    try:
        # Redirect stdout and stderr to file
        os.dup2(out_fd, stdout_fd)
        os.dup2(out_fd, stderr_fd)

        yield filename
    finally:
        sys.stdout.flush()
        sys.stderr.flush()
        os.close(out_fd)

        if not permanent:
            os.dup2(stdout_fd_copy, stdout_fd)
            os.dup2(stderr_fd_copy, stderr_fd)
            os.close(stdout_fd_copy)
            os.close(stderr_fd_copy)
206158
def filenameToModname(self, filename):
        """"""
        for ext in reversed(self._exts):
            if filename.endswith(ext):
                filename = filename[:-len(ext)]
                break
        else:
            self.warn(filename, '%s: unknown file name extension', filename)
        filename = os.path.abspath(filename)
        elements = filename.split(os.path.sep)
        modname = []
        while elements:
            modname.append(elements[-1])
            del elements[-1]
            if not os.path.exists(os.path.sep.join(elements + ['__init__.py'])):
                break
        modname.reverse()
        modname = ".".join(modname)
        return modname