Read a previously stored blacklist from file fd.
435974
def read_blacklist (self):
        
        with codecs.open(self.filename, 'r', self.output_encoding,
                         self.codec_errors) as fd:
            for line in fd:
                line = line.rstrip()
                if line.startswith('#') or not line:
                    continue
                value, key = line.split(None, 1)
                self.blacklist[key] = int(value)
578112
def _read(self, fd, mask):
        """"""
        try:
            # if EOF was encountered on a tty, avoid reading again because
            # it actually requests more data
            if select.select([fd],[],[],0)[0]:
                snew = os.read(fd, self.nbytes) # returns bytes in PY3K
                if PY3K: snew = snew.decode('ascii','replace')
                self.value.append(snew)
                self.nbytes -= len(snew)
            else:
                snew = ''
            if (self.nbytes <= 0 or len(snew) == 0) and self.widget:
                # stop the mainloop
                self.widget.quit()
        except OSError:
            raise IOError("Error reading from %s" % (fd,))
350453
public function reloadBlacklist()
    {
        $this->cache->flush($this->getCacheKey());

        $this->blackListRegex = null;

        $this->loadBlacklist();
    }
1370909
def read_bplist(data, start, length):
    """"""
    # TODO: pylint doesn't find FMT_BINARY, why?
    # pylint: disable=no-member
    return plistlib.loads(data[start:start+length],
                          fmt=plistlib.FMT_BINARY)
964612
def ListFiles(self, ext_attrs=None):
    """"""
    del ext_attrs  # Unused.

    if not self.IsDirectory():
      raise IOError("%s is not a directory" % self.pathspec.CollapsePath())

    for f in self.fd.as_directory():
      try:
        name = _DecodeUTF8WithWarning(f.info.name.name)
        # Drop these useless entries.
        if name in [".", ".."] or name in self.BLACKLIST_FILES:
          continue

        # First we yield a standard response using the default attributes.
        yield self.MakeStatResponse(f, tsk_attribute=None, append_name=name)

        # Now send back additional named attributes for the ADS.
        for attribute in f:
          if attribute.info.type in [
              pytsk3.TSK_FS_ATTR_TYPE_NTFS_DATA, pytsk3.TSK_FS_ATTR_TYPE_DEFAULT
          ]:
            if attribute.info.name:
              yield self.MakeStatResponse(
                  f, append_name=name, tsk_attribute=attribute)
      except AttributeError:
        pass
62228
def _read_one_byte(self, fd):
        """"""
        c = os.read(fd, 1)
        if not c:
            raise OSError
        return c
377686
def read(self, limit=-1):
        """"""
        remaining = self.len - self.parent_fd.tell() + self.offset

        if limit > remaining or limit == -1:
            limit = remaining

        return self.parent_fd.read(limit)
997136
def check_exptime(filelist):
    
    toclose = False
    removed_files = []
    for f in filelist:
        if isinstance(f, str):
            f = fits.open(f)
            toclose = True

        try:
            exptime = f[0].header['EXPTIME']
        except KeyError:
            removed_files.append(f)
            print("Warning:  There are files without keyword EXPTIME")
            continue
        if exptime <= 0:
            removed_files.append(f)
            print("Warning:  There are files with zero exposure time: keyword EXPTIME = 0.0")

    if removed_files != []:
        print("Warning:  Removing the following files from input list")
        for f in removed_files:
            print('\t',f.filename() or "")
    return removed_files
1097711
def read_records(file):
    """"""
    records = []
    for record_data in read_recordio(file):
        record = Record()
        record.ParseFromString(record_data)
        records.append(record)
    return records
1169315
def readlines(self, filepath):
        """"""
        target = self._read_check(filepath)

        if os.path.isfile(target):
            with open(target) as f:
                lines = f.readlines()

            #If we got this file via SSH, delete it from the temp folder
            if self.is_ssh(filepath):
                os.remove(target)
        else:
            lines = []

        return lines
161313
def is_blacklisted(self, appid, crawlid):
        '''
        
        '''
        key_check = '{appid}||{crawlid}'.format(appid=appid,
                                                crawlid=crawlid)
        redis_key = self.spider.name + ":blacklist"
        return self.redis_conn.sismember(redis_key, key_check)
9817
def write_blacklist (self):
        
        oldmask = os.umask(0077)
        for key, value in self.blacklist.items():
            self.write(u"%d %s%s" % (value, repr(key), os.linesep))
        self.close_fileoutput()
        # restore umask
        os.umask(oldmask)
1061945
def checked_open(filename, log=None, quiet=False):
    
    with open(filename, "rb") as handle:
        raw_data = handle.read()
    data = bencode.bdecode(raw_data)

    try:
        check_meta(data)
        if raw_data != bencode.bencode(data):
            raise ValueError("Bad bencoded data - dict keys out of order?")
    except ValueError as exc:
        if log:
            # Warn about it, unless it's a quiet value query
            if not quiet:
                log.warn("%s: %s" % (filename, exc))
        else:
            raise

    return data
1211367
def from_file(self, fname):
        """"""
        f = open(fname, "rb")
        data = f.read()
        self.update(data)
        f.close()
947747
def blacklisted?(page)
      return false if whitelisted?(page)
      FILENAME_BLACKLIST.include?(page.basename.upcase)
    end
1266188
def _deleted_files():
    '''
    

    '''
    deleted_files = []

    for proc in psutil.process_iter():  # pylint: disable=too-many-nested-blocks
        try:
            pinfo = proc.as_dict(attrs=['pid', 'name'])
            try:
                with salt.utils.files.fopen('/proc/{0}/maps'.format(pinfo['pid'])) as maps:  # pylint: disable=resource-leakage
                    dirpath = '/proc/' + six.text_type(pinfo['pid']) + '/fd/'
                    listdir = os.listdir(dirpath)
                    maplines = maps.readlines()
            except (OSError, IOError):
                yield False

            # /proc/PID/maps
            mapline = re.compile(r'^[\da-f]+-[\da-f]+ [r-][w-][x-][sp-] '
                                 r'[\da-f]+ [\da-f]{2}:[\da-f]{2} (\d+) *(.+)( \(deleted\))?\n$')

            for line in maplines:
                line = salt.utils.stringutils.to_unicode(line)
                matched = mapline.match(line)
                if not matched:
                    continue
                path = matched.group(2)
                if not path:
                    continue
                valid = _valid_deleted_file(path)
                if not valid:
                    continue
                val = (pinfo['name'], pinfo['pid'], path[0:-10])
                if val not in deleted_files:
                    deleted_files.append(val)
                    yield val

            # /proc/PID/fd
            try:
                for link in listdir:
                    path = dirpath + link
                    readlink = os.readlink(path)
                    filenames = []

                    if os.path.isfile(readlink):
                        filenames.append(readlink)
                    elif os.path.isdir(readlink) and readlink != '/':
                        for root, dummy_dirs, files in salt.utils.path.os_walk(readlink, followlinks=True):
                            for name in files:
                                filenames.append(os.path.join(root, name))

                    for filename in filenames:
                        valid = _valid_deleted_file(filename)
                        if not valid:
                            continue
                        val = (pinfo['name'], pinfo['pid'], filename)
                        if val not in deleted_files:
                            deleted_files.append(val)
                            yield val
            except OSError:
                pass

        except psutil.NoSuchProcess:
            pass
1012973
def read_id_list(filepath):
    
    if not filepath:
        return None
    id_list = []
    with open(filepath) as f:
        for line in f:
            line = line.rstrip()
            if not re.match('^[0-9]{8}$', line):
                raise('Each line in whitelist or blacklist is expected '
                      'to contain an eight digit ID, and nothing else.')
            else:
                id_list.append(line)
    return id_list