Accepted format directives: %i %s %m %h
189528
def seconds_to_str_fromatter(_format):
    
    # check directives are correct 
    
    if _format == "%S":
        def _fromatter(seconds):
            return "{:.2f}".format(seconds)
    
    elif _format == "%I":
        def _fromatter(seconds):
            return "{0}".format(int(seconds * 1000))
    
    else:
        _format = _format.replace("%h", "{hrs:02d}")
        _format = _format.replace("%m", "{mins:02d}")
        _format = _format.replace("%s", "{secs:02d}")
        _format = _format.replace("%i", "{millis:03d}")
        
        try:
            i = _format.index("%")
            raise TimeFormatError("Unknow time format directive '{0}'".format(_format[i:i+2]))
        except ValueError:
            pass
        
        def _fromatter(seconds):
            millis = int(seconds * 1000)
            hrs, millis = divmod(millis, 3600000)
            mins, millis = divmod(millis, 60000)
            secs, millis = divmod(millis, 1000)
            return _format.format(hrs=hrs, mins=mins, secs=secs, millis=millis)
    
    return _fromatter
637416
function directives(def) {
  // mock line number for error messages
  var lineno = 1
    , k
    , v
    // inline directive, not from a file
    , file = 'directive override (argv)';

  function addDirective(k, v) {
    // must be strings split into an array
    // they are parsed and validated
    v = ('' + v).split(/\s+/);
    // mimic behaving as a child so source file
    // line numbers are not overwritten
    try {
      this.add(k, v, lineno, true);
    }catch(e) {
      return this.emit('error', new ConfigError(lineno, k + ' ' + v, file, e));
    }
    lineno++;
  }

  addDirective = addDirective.bind(this);

  for(k in def) {
    v = def[k];
    if(!Array.isArray(v)) {
      addDirective(k, v);
    }else{
      v.forEach(function(item) {
        addDirective(k, item);
      })
    }
  }
}
883446
def format_h2(s, format="text", indents=0):
    

    _CHAR = "-"
    if format.startswith("text"):
        return format_underline(s, _CHAR, indents)
    elif format.startswith("markdown"):
        return ["## {}".format(s)]
    elif format.startswith("rest"):
        return format_underline(s, _CHAR, 0)
698
def _init_formats(self):
        
        theme = self._color_scheme
        # normal message format
        fmt = QtGui.QTextCharFormat()
        fmt.setForeground(theme.foreground)
        fmt.setBackground(theme.background)
        self._formats[OutputFormat.NormalMessageFormat] = fmt

        # error message
        fmt = QtGui.QTextCharFormat()
        fmt.setForeground(theme.error)
        fmt.setBackground(theme.background)
        self._formats[OutputFormat.ErrorMessageFormat] = fmt

        # debug message
        fmt = QtGui.QTextCharFormat()
        fmt.setForeground(theme.custom)
        fmt.setBackground(theme.background)
        self._formats[OutputFormat.CustomFormat] = fmt
1067689
def write_implied_format(self, path, jpeg_quality=0, jpeg_progressive=0):
        
        filename = fspath(path)
        with _LeptonicaErrorTrap():
            lept.pixWriteImpliedFormat(
                os.fsencode(filename), self._cdata, jpeg_quality, jpeg_progressive
            )
276178
function readSupportedFormatsFromINI( $iniFile = false )
    {
        if ( !$iniFile )
            $iniFile = 'image.ini';
        $ini = eZINI::instance( $iniFile );
        if ( !$ini )
            return false;
        $allowedOutputFormats = $ini->variable( 'OutputSettings', 'AllowedOutputFormat' );
        foreach ( $allowedOutputFormats as $allowedOutputFormat )
        {
            $this->appendSupportedFormat( $allowedOutputFormat );
        }
    }
635982
def directive_fun(match, directive):
    """"""
    directive_to_alert = dict(note="info", warning="danger")
    return ('<div class="alert alert-{0}"><h4>{1}</h4><p>{2}</p></div>'
            .format(directive_to_alert[directive], directive.capitalize(),
                    match.group(1).strip()))
906471
def _format_info(data):
    '''
    
    '''
    return {'gid': data.pw_gid,
            'groups': list_groups(data.pw_name),
            'home': data.pw_dir,
            'name': data.pw_name,
            'shell': data.pw_shell,
            'uid': data.pw_uid,
            'fullname': data.pw_gecos}
300853
function(p, style) {
		var i, o, s, b, sticy, suid, sgid, str, oct;
		
		if (!style) {
			style = this.options.fileModeStyle.toLowerCase();
		}
		p = $.trim(p);
		if (p.match(/[rwxs-]{9}$/i)) {
			str = p = p.substr(-9);
			if (style == 'string') {
				return str;
			}
			oct = '';
			s = 0;
			for (i=0; i<7; i=i+3) {
				o = p.substr(i, 3);
				b = 0;
				if (o.match(/[r]/i)) {
					b += 4;
				}
				if (o.match(/[w]/i)) {
					b += 2;
				}
				if (o.match(/[xs]/i)) {
					if (o.match(/[xs]/)) {
						b += 1;
					}
					if (o.match(/[s]/i)) {
						if (i == 0) {
							s += 4;
						} else if (i == 3) {
							s += 2;
						}
					}
				}
				oct += b.toString(8);
			}
			if (s) {
				oct = s.toString(8) + oct;
			}
		} else {
			p = parseInt(p, 8);
			oct = p? p.toString(8) : '';
			if (!p || style == 'octal') {
				return oct;
			}
			o = p.toString(8);
			s = 0;
			if (o.length > 3) {
				o = o.substr(-4);
				s = parseInt(o.substr(0, 1), 8);
				o = o.substr(1);
			}
			sticy = ((s & 1) == 1); // not support
			sgid = ((s & 2) == 2);
			suid = ((s & 4) == 4);
			str = '';
			for(i=0; i<3; i++) {
				if ((parseInt(o.substr(i, 1), 8) & 4) == 4) {
					str += 'r';
				} else {
					str += '-';
				}
				if ((parseInt(o.substr(i, 1), 8) & 2) == 2) {
					str += 'w';
				} else {
					str += '-';
				}
				if ((parseInt(o.substr(i, 1), 8) & 1) == 1) {
					str += ((i==0 && suid)||(i==1 && sgid))? 's' : 'x';
				} else {
					str += '-';
				}
			}
		}
		if (style == 'both') {
			return str + ' (' + oct + ')';
		} else if (style == 'string') {
			return str;
		} else {
			return oct;
		}
	}
946215
def _format(self, ans, q):
        
        if 'fmt' in q:
            fmt = q['fmt'][0]
        else:
            fmt = 'json'

        fmt = fmt.lower()

        if fmt in self._formatters:
            return (200, self._formatters[fmt](ans, q), 'application/json')
        else:
            return (415,
                'Invalid fmt request "%s", supported formats are: %s\n'%
                    (fmt, ' '.join(self._formatters.keys()),),
                'text/plain')
402936
def isoformat(self, strict=False):
        '''
        '''
        out = self.year
        # what do we do when no year ...
        for val in [self.month, self.day]:
            if not val:
                break
            out += u'-' + val
        if strict:
            out = out.replace('?', '0')

        if self.hour:
            out += u' '
            out += self.hour
            for val in [self.minute, self.second]:
                if not val:
                    break
                out += u':' + val
            if self.microsecond:
                out += u'.' + self.microsecond
        return out
323854
def add_directive_header(self, sig):
        """"""
        domain = getattr(self, 'domain', 'py')
        directive = getattr(self, 'directivetype', "module")
        name = self.format_name()
        self.add_line(u'.. %s:%s:: %s%s' % (domain, directive, name, sig),
                      '<autodoc>')
        if self.options.noindex:
            self.add_line(u'   :noindex:', '<autodoc>')
        if self.objpath:
            # Be explicit about the module, this is necessary since .. class::
            # etc. don't support a prepended module name
            self.add_line(u'   :module: %s' % self.modname, '<autodoc>')
251660
public static void copyDirective(HashMap<String, String> directives,
            StringBuilder sb, String directive) {
        String directiveValue = directives.get(directive);
        if (directiveValue != null) {
            sb.append(directive).append(" = \"").append(directiveValue).append(
                    "\", ");
        }
    }
839089
def _formatFilepaths(self):
        
        likedir=self['output']['likedir']
        self.likefile  = join(likedir,self['output']['likefile'])
        self.mergefile = join(likedir,self['output']['mergefile'])
        self.roifile   = join(likedir,self['output']['roifile'])

        searchdir=self['output']['searchdir']
        self.labelfile  = join(searchdir,self['output']['labelfile'])
        self.objectfile = join(searchdir,self['output']['objectfile'])
        self.assocfile  = join(searchdir,self['output']['assocfile'])
        self.candfile   = join(searchdir,self['output']['candfile'])

        mcmcdir=self['output']['mcmcdir']
        self.mcmcfile   = join(mcmcdir,self['output']['mcmcfile'])
751949
def clean_readme(fname):
    """"""
    with codecs.open(fname, 'r', 'utf-8') as f:
        return ''.join(
            re.sub(r':\w+:`([^`]+?)( <[^<>]+>)?`', r'``\1``', line)
            for line in f
            if not (line.startswith('.. currentmodule') or line.startswith('.. toctree'))
        )
263572
def _format_markdown_requisite(state, stateid, makelink=True):
    '''
    
    '''
    fmt_id = '{0}: {1}'.format(state, stateid)
    if makelink:
        return ' * [{0}](#{1})\n'.format(fmt_id, _format_markdown_link(fmt_id))
    else:
        return ' * `{0}`\n'.format(fmt_id)
610172
def vformat(self, format_string, args, kwargs):
        """"""
        ret = super().vformat(format_string, args, kwargs)
        if platform.system() == 'Windows':
            ret = ret.replace(':', '\ua789').replace('<', '\ufe64').replace('>', '\ufe65').replace('\"', '\uff02')
            ret = ret.replace('\\', '\uff3c').replace('|', '\uff5c').replace('?', '\ufe16').replace('*', '\uff0a')
        return ret