Decodes a Windows NT FTP LIST line like these two:

    `11-02-18  02:12PM       <DIR>          images`
    `11-02-18  03:33PM                 9276 logo.gif`
161569
def decode_windowsnt(line, match):
    
    is_dir = match.group("size") == "<DIR>"

    raw_info = {
        "basic": {
            "name": match.group("name"),
            "is_dir": is_dir,
        },
        "details": {
            "type": int(ResourceType.directory if is_dir else ResourceType.file),
        },
        "ftp": {"ls": line},
    }

    if not is_dir:
        raw_info["details"]["size"] = int(match.group("size"))

    modified = _parse_time(match.group("modified"), formats=["%d-%m-%y %I:%M%p"])
    if modified is not None:
        raw_info["details"]["modified"] = modified

    return raw_info
1260820
def recv_raw(self, x=MTU):
        """"""  # noqa: E501
        pkt, sa_ll = self.ins.recvfrom(x)
        if self.outs and sa_ll[2] == socket.PACKET_OUTGOING:
            return None, None, None
        ts = get_last_packet_timestamp(self.ins)
        return self.LL, pkt, ts
67451
def _process_list(self, list_line):
        # -rw-r--r-- 1 ftp ftp 68	 May 09 19:37 testftp.txt
        
        res = list_line.split(' ', 8)
        if res[0].startswith('-'):
            self.state['file_list'].append(res[-1])
        if res[0].startswith('d'):
            self.state['dir_list'].append(res[-1])
971343
function decode(pem) {
  if (Buffer.isBuffer(pem)) {
    pem = pem.toString('ascii')
  }

  const lines = pem.trim().split('\n')

  if (lines.length < 3) {
    throw new Error('Invalid PEM data.')
  }

  const match = header.exec(lines[0])

  if (match === null) {
    throw new Error('Invalid label.')
  }

  const label = match[1]
  let i = 1

  for (; i < lines.length; ++i) {
    if (lines[i].startsWith(after)) {
      break
    }
  }

  const footer = new RegExp(`^${after} ${label}${endline}\r?\n?$`)

  if (footer.exec(lines[i]) === null) {
    throw new Error('Invalid end of file.')
  }

  const body = lines.slice(1, i).join('\n').replace(/\r?\n/g, '')
  return Buffer.from(body, 'base64')
}
685107
def _tzstr(self, sep=":"):
        """"""
        off = self.utcoffset()
        if off is not None:
            if off.days < 0:
                sign = "-"
                off = -off
            else:
                sign = "+"
            hh, mm = divmod(off, timedelta(hours=1))
            assert not mm % timedelta(minutes=1), "whole minute"
            mm //= timedelta(minutes=1)
            assert 0 <= hh < 24
            off = "%s%02d%s%02d" % (sign, hh, sep, mm)
        return off
54400
function cmd_LIST($fd, $cmd)
    {
        $user = $this->getUser($fd);
        $ftpsock = $this->getUserSock($user);
        if (!$ftpsock)
        {
            $this->send($fd, "501 Connection Error");
            return;
        }
        $this->send($fd, "150 Opening ASCII mode data connection for file list");
        $path = $this->getAbsDir($user);
        if (isset($cmd[1]) and preg_match("/\-(.*)a/", $cmd[1]))
        {
            $showHidden = true;
        }
        else
        {
            $showHidden = false;
        }
        $filelist = $this->getFileList($path, $showHidden);
        fwrite($ftpsock, $filelist);
        $this->closeUserSock($user);
        $this->send($fd, "226 Transfer complete.");
    }
571838
def parsePositionFile(filename):
    
    l=[]
    with open( filename, "rb" ) as theFile:
        reader = csv.DictReader( theFile )
        for line in reader:
            # Convert the time string to something
            # a bit more human readable
            mytime=dateparser.parse(line['time'])
            line['strtime']=mytime.strftime("%d %b %Y, %H:%M UTC")
            l.append(line)
    return l
961547
function getRealUptime (next) {
  fs.readFile('/proc/uptime', 'utf8', function (err, uptime) {
    if (err || uptime === undefined) {
      console.warn("[pidusage] We couldn't find uptime from /proc/uptime, using os.uptime() value")
      return next(null, os.uptime())
    }

    return next(null, parseFloat(uptime.split(' ')[0]))
  })
}
6746
def decode_schedule(string):
  
  splits = string.split()
  steps = [int(x[1:]) for x in splits[1:] if x[0] == '@']
  pmfs = np.reshape(
      [float(x) for x in splits[1:] if x[0] != '@'], [len(steps), -1])
  return splits[0], tuplize(steps), tuplize(pmfs)
738464
def decode_rfc2231(s):
    """"""
    parts = s.split(TICK, 2)
    if len(parts) <= 2:
        return None, None, s
    return parts
653833
def to_ts(s):
        

        # Strip TZ portion if present
        m = Nginx.DATE_FMT.match(s)
        if m:
            s = m.group(1)
            delta = timedelta(seconds=int(m.group(3)) * (-1 if m.group(2) == '-' else 1)) # Offset from GMT
        else:
            delta = timedelta(seconds=0)
        dt = datetime.strptime(s, "%d/%b/%Y:%H:%M:%S")
        dt += delta
        return dt.strftime('%Y-%m-%dT%H:%M:%SZ')
787677
def decode (cls, bytes, cmddict=None):
    
    delay_s  = struct.unpack('>H', bytes[0:2])[0]
    delay_ms = struct.unpack('B' , bytes[2:3])[0]
    return cls(delay_s + (delay_ms / 255.0))
1303623
def tail(f, window=20):
    
    if window == 0:
        return []
    BUFSIZ = 1024
    f.seek(0, 2)
    bytes = f.tell()
    size = window + 1
    block = -1
    data = []
    while size > 0 and bytes > 0:
        if bytes - BUFSIZ > 0:
            # Seek back one whole BUFSIZ
            f.seek(block * BUFSIZ, 2)
            # read BUFFER
            data.insert(0, f.read(BUFSIZ).decode('utf-8', errors='ignore'))
        else:
            # file too small, start from begining
            f.seek(0,0)
            # only read what was not read
            data.insert(0, f.read(bytes).decode('utf-8', errors='ignore'))

        linesFound = data[0].count('\n')
        size -= linesFound
        bytes -= BUFSIZ
        block -= 1
    return ''.join(data).splitlines()[-window:]
198591
def read_info(
    filename
):
    

    cmd = [
        'ffprobe',
        filename,
        '-v', 'error',
        '-print_format', 'json',
        '-show_format', '-show_streams',
    ]

    out = sp.check_output(cmd)
    info = json.loads(out.decode('utf-8'))
    return info
854979
def infer_delimiter(filepath):
    
    ext = os.path.splitext(filepath)[1][1:].lower()
    return {"txt": "\t", "tsv": "\t", "csv": ","}.get(ext)
1319487
def decode(self, data, as_list=False):
        
        return self._concat(self.decode_streaming(data))
695586
def _listFilesPosix(self) -> ['File']:
        

        find = "find %s -type f" % self._path
        output = check_output(args=find.split()).strip().decode().split(
            '\n')
        return output