Convert [+/-]DDD.DDDDD to [+/-]DDD°MMM'DDD.DDDDD"
352494
def todmsstr(origin):
    

    degrees, minutes, seconds = todms(origin)
    return u'%d°%d\'%f"' % (degrees, minutes, seconds)
356511
def as_posix(self):
        """"""
        f = self._flavour
        return str(self).replace(f.sep, '/')
226188
def _convert(convdef, stri):
    """"""
    if '%' in convdef:
        result = dt.datetime.strptime(stri, convdef)
    elif 'd' in convdef or 's' in convdef:
        regex_match = fmt_spec_regex.match(convdef)
        match_dict = regex_match.groupdict() if regex_match else {}
        align = match_dict.get('align')
        pad = match_dict.get('fill')
        if align:
            # align character is the last one
            align = align[-1]
        if align and align in '<>^' and not pad:
            pad = ' '

        if align == '>':
            stri = stri.lstrip(pad)
        elif align == '<':
            stri = stri.rstrip(pad)
        elif align == '^':
            stri = stri.strip(pad)

        if 'd' in convdef:
            result = int(stri)
        else:
            result = stri
    else:
        result = stri
    return result
1288152
def _nth_str(n):
    """"""
    if n % 10 == 1 and n % 100 != 11:
        return "%dst" % n
    if n % 10 == 2 and n % 100 != 12:
        return "%dnd" % n
    if n % 10 == 3 and n % 100 != 13:
        return "%drd" % n
    return "%dth" % n
392798
function(dec) {
        if(!dec){
            dec = 2;
        }
        return '{x: ' + this.x.toFixed(dec) + ', y: ' + this.y.toFixed(dec)  + ', z: ' + this.z.toFixed(dec)  + '}';
    }
1360870
def todegdec(origin):
    

    # if the input is already a float (or can be converted to float)
    try:
        return float(origin)
    except ValueError:
        pass

    # DMS format
    m = dms_re.search(origin)
    if m:
        degrees = int(m.group('degrees'))
        minutes = float(m.group('minutes'))
        seconds = float(m.group('seconds'))

        return degrees + minutes / 60 + seconds / 3600

    # Degree + Minutes format
    m = mindec_re.search(origin)
    if m:
        degrees = int(m.group('degrees'))
        minutes = float(m.group('minutes'))

        return degrees + minutes / 60
298776
private static String convertToStandardFormat(String valueAfterMD5) {
        String raw = valueAfterMD5.toUpperCase();
        StringBuilder sb = new StringBuilder();
        sb.append(raw.substring(0, 8))
          .append("-")
          .append(raw.substring(8, 12))
          .append("-")
          .append(raw.substring(12, 16))
          .append("-")
          .append(raw.substring(16, 20))
          .append("-")
          .append(raw.substring(20));
        return sb.toString();
    }
851790
def _convert_params(sql, params):
    """"""
    args = [sql]
    if params is not None:
        if hasattr(params, 'keys'):  # test if params is a mapping
            args += [params]
        else:
            args += [list(params)]
    return args
630172
def to_dhm_format(days=0, hours=0, minutes=0, seconds=0, milliseconds=0):
    
    minutes = to_minutes(days=days, hours=hours, minutes=minutes,
                         seconds=seconds, milliseconds=milliseconds)
    delta = timedelta(minutes=int(round(minutes)))
    d = delta.days
    h = delta.seconds // 3600
    m = (delta.seconds // 60) % 60
    m = m and "{}m ".format(str(m)) or ""
    d = d and "{}d ".format(str(d)) or ""
    if m and d:
        h = "{}h ".format(str(h))
    else:
        h = h and "{}h ".format(str(h)) or ""
    return "".join([d, h, m]).strip()
485382
def _der_to_raw(self, der_signature):
        """"""
        r, s = decode_dss_signature(der_signature)
        component_length = self._sig_component_length()
        return int_to_bytes(r, component_length) + int_to_bytes(s, component_length)
1321742
function unifiedDiff (actual, expected, formatAdd, formatRem) {
  return [
    formatAdd('+ expected'),
    formatRem('- actual'),
    ''
  ]
    .concat(
      diff.createPatch('string', actual, expected)
        .split('\n')
        .slice(4)
        .filter(function (line) {
          return line[0] === '+' || line[0] === '-'
        })
        .map(function (line) {
          return line[0] === '+' ? formatAdd(line) : formatRem(line)
        })
    )
    .join('\n')
}
326250
def convert(input, output):
    '''
    
    '''
    dirname = os.path.dirname(output)
    if not os.path.exists(dirname):
        os.makedirs(dirname)
    basename = os.path.basename(output)
    basename = re.sub('.nii(.gz)?', '', basename)
    dcm2niix = commons.which('dcm2niix')
    cmd = [
        'dcm2niix',
        '-s', 'y',
        '-b', 'y',
        '-z', 'y',
        '-f', basename,
        '-o', dirname,
        input
    ]
    logger.debug(cmd)
    sp.check_output(cmd)
119056
def _dump_date(d, delim):
    """"""
    if d is None:
        d = gmtime()
    elif isinstance(d, datetime):
        d = d.utctimetuple()
    elif isinstance(d, (integer_types, float)):
        d = gmtime(d)
    return "%s, %02d%s%s%s%s %02d:%02d:%02d GMT" % (
        ("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")[d.tm_wday],
        d.tm_mday,
        delim,
        (
            "Jan",
            "Feb",
            "Mar",
            "Apr",
            "May",
            "Jun",
            "Jul",
            "Aug",
            "Sep",
            "Oct",
            "Nov",
            "Dec",
        )[d.tm_mon - 1],
        delim,
        str(d.tm_year),
        d.tm_hour,
        d.tm_min,
        d.tm_sec,
    )
58346
def destr(d,*l):
    ''''''
    if type(l[0]) is not str:
        l=l[0];
    return [d[i] for i in l];
1294106
def index_to_coordinate(dims):
    
    _ = divmod  # SO WE KEEP THE IMPORT

    num_dims = len(dims)
    if num_dims == 0:
        return _zero_dim

    prod = [1] * num_dims
    acc = 1
    domain = range(0, num_dims)
    for i in reversed(domain):
        prod[i] = acc
        acc *= dims[i]

    commands = []
    coords = []
    for i in domain:
        if i == num_dims - 1:
            commands.append("\tc" + text_type(i) + " = index")
        else:
            commands.append("\tc" + text_type(i) + ", index = divmod(index, " + text_type(prod[i]) + ")")
        coords.append("c" + text_type(i))
    output = None
    if num_dims == 1:
        code = (
            "def output(index):\n" +
            "\n".join(commands) + "\n" +
            "\treturn " + coords[0] + ","
        )
    else:
        code = (
            "def output(index):\n" +
            "\n".join(commands) + "\n" +
            "\treturn " + ", ".join(coords)
        )

    exec(code)
    return output
1088625
def number_to_dp(number: Optional[float],
                 dp: int,
                 default: Optional[str] = "",
                 en_dash_for_minus: bool = True) -> str:
    
    if number is None:
        return default
    if number == float("inf"):
        return u"∞"
    if number == float("-inf"):
        s = u"-∞"
    else:
        s = u"{:.{precision}f}".format(number, precision=dp)
    if en_dash_for_minus:
        s = s.replace("-", u"–")  # hyphen becomes en dash for minus sign
    return s
333752
private String convertDecimal(double d, String format)
    {
        String ret = "";

        if(format.length() > 0)
        {
            DecimalFormat f = new DecimalFormat(format);
            ret = f.format(d);
        }
        else
        {
            ret = Double.toString(d);
        }

        return ret;
    }