Load the pa11y ignore rules from the given file or URL.
541730
def load_pa11y_ignore_rules(file=None, url=None):  # pylint: disable=redefined-builtin
    
    if not file and not url:
        return None

    if file:
        file = Path(file)
        if not file.isfile():
            msg = (
                u"pa11y_ignore_rules_file specified, but file does not exist! {file}"
            ).format(file=file)
            raise ValueError(msg)
        return yaml.safe_load(file.text())

    # must be URL
    resp = requests.get(url)
    if not resp.ok:
        msg = (
            u"pa11y_ignore_rules_url specified, but failed to fetch URL. status={status}"
        ).format(status=resp.status_code)
        err = RuntimeError(msg)
        err.response = resp
        raise err
    return yaml.safe_load(resp.text)
1161067
def _read_http_none(self, size, kind, flag):
        """"""
        if any((int(bit, base=2) for bit in flag)):
            raise ProtocolError(f'HTTP/2: [Type {kind}] invalid format', quiet=True)

        data = dict(
            flags=None,
            payload=self._read_fileng(size - 9) or None,
        )

        return data
1255054
def load_from_file(self, fname):
        '''
        
        '''
        try:
            # Process each line from the extract file, ignoring comments
            with open(fname, 'r') as f:
                for rule in f.readlines():
                    self.add_rule(rule.split(self.COMMENT_DELIM, 1)[0])
        except KeyboardInterrupt as e:
            raise e
        except Exception as e:
            raise Exception("Extractor.load_from_file failed to load file '%s': %s" % (fname, str(e)))
1325229
def load(self, filename=None, ignore_discard=False, ignore_expires=False):
        """"""
        if filename is None:
            if self.filename is not None: filename = self.filename
            else: raise ValueError(MISSING_FILENAME_TEXT)

        f = open(filename)
        try:
            self._really_load(f, filename, ignore_discard, ignore_expires)
        finally:
            f.close()
475677
function filter(p, rules, root, isDirectory, included) {
  p = path.relative(root, p);
  for (var i in rules) {
    var rule = rules[i];
    if (isDirectory) {
      if (rule.match(p) || rule.match("/" + p) ||
          rule.match(p + "/") || rule.match("/" + p + "/")
         ) {
        return rule.negate;
      }
    } else {
      if (rule.match(p) || rule.match("/" + p)) {
        return rule.negate;
      }
    }
  }
  return included;
}
643250
def run_rules(url, rules)
      str = url.to_s
      return str if rules.nil?
      rules.each do |rule|
        case rule
        when 'noproto'
          str = str.gsub(%r{^https?://}, '')
        when 'nossl', 'http'
          str = str.gsub(%r{^https://}, 'http://')
        when 'ssl', 'https'
          str = str.gsub(%r{^http://}, 'https://')
        when 'base32'
          str = Base32.encode(str).to_s
        when 'base64'
          str = Base64.encode64(str).delete("\n")
        when 'md4'
          str = OpenSSL::Digest::MD4.hexdigest(str)
        when 'md5'
          md5 = Digest::MD5.new
          md5.update str
          str = md5.hexdigest
        when 'sha1'
          str = Digest::SHA1.hexdigest(str)
        when 'reverse'
          str = str.reverse
        when 'upcase'
          str = str.upcase
        when 'downcase'
          str = str.downcase
        when 'rot13'
          str = str.tr('A-Za-z', 'N-ZA-Mn-za-m')
        when 'urlencode'
          str = CGI.escape(str).gsub(/\+/, '%20')
        when 'urldecode'
          str = CGI.unescape(str)
        when 'append-hash'
          str = "#{str}##{rand(36**6).to_s(36)}"
        when 'append-method-get'
          separator = str.include?('?') ? '&' : '?'
          str = "#{str}#{separator}method=get&_method=get"
        else
          logger.warn("Unknown rule: #{rule}")
        end
      end
      str
    end
1203419
private static List<String> loadRenameFile(URL url) throws IOException {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(url.openStream(), UTF_8))) {
            return reader.lines()
                    .filter(line -> !line.isEmpty() && !line.startsWith("#"))
                    .collect(toList());
        }
    }
457162
private boolean loadMatchRules(String rulesUrl) {
	//load match rules from file
	try {
            //check for file URL 
            if (rulesUrl != null && rulesUrl.toLowerCase().startsWith("file:")) {
                return loadMatchRulesFromFile(rulesUrl);
            }
            
            //request match rules from remote URL 
    	    mCallbacks.printOutput("Loading match rules from: " + rulesUrl);
	    URL url = new URL(rulesUrl);
            IHttpService service = new HttpService(url);
            HttpRequest request = new HttpRequest(url);
            byte[] responseBytes = mCallbacks.makeHttpRequest(
                    service.getHost(), 
                    service.getPort(), 
                    HttpService.PROTOCOL_HTTPS.equalsIgnoreCase(service.getProtocol()), 
                    request.getBytes());
            
            //parse the response
            if (responseBytes == null) return false; //no response received from server 
            HttpResponse response = HttpResponse.parseMessage(responseBytes);
            
	    //read match rules from the response
            Reader is = new StringReader(response.getBody());
	    BufferedReader reader = new BufferedReader(is);
	    
            processMatchRules(reader);
                        
            return true;

	} catch (IOException e) {
	    scan.printStackTrace(e);
	} catch (Exception e) {
	    scan.printStackTrace(e);
        }
        
        return false;
    }
112420
def should_ignore(self, filename):
        """"""
        _, ext = os.path.splitext(filename)
        return ext in self.ignored_file_extensions
954193
def _load(self,
              url,
              headers=CaseInsensitiveDict(),
              params=None,
              path=None,
              ):
        
        r = self._session.get(url, headers=headers, params=params)
        try:
            j = json_loads(r)
        except ValueError as e:
            logging.error("%s:\n%s" % (e, r.text))
            raise e
        if path:
            j = j[path]
        self._parse_raw(j)
419175
def loadFromURL(self, url):
        """"""
        if isfile(url) is True:
            file = open(url, 'r')
        else:
            file = urlopen(url)

        try:     
            result = self.loadDocument(file)
        except Exception, ex:
            file.close()
            raise ParseError(('Failed to load document %s' %url,) + ex.args)
        else:
            file.close()
        return result
958710
def load_apis(self, path, ignore=[], include_crash_api=False):
        """"""

        if not path:
            raise Exception("Missing path to api swagger files")

        if type(ignore) is not list:
            raise Exception("'ignore' should be a list of api names")

        # Always ignore pym-config.yaml
        ignore.append('pym-config')

        # Find all swagger apis under 'path'
        apis = {}

        log.debug("Searching path %s" % path)
        for root, dirs, files in os.walk(path):
            for f in files:
                if f.endswith('.yaml'):
                    api_name = f.replace('.yaml', '')

                    if api_name in ignore:
                        log.info("Ignoring api %s" % api_name)
                        continue

                    apis[api_name] = os.path.join(path, f)
                    log.debug("Found api %s in %s" % (api_name, f))

        # And add pymacaron's default ping and crash apis
        for name in ['ping', 'crash']:
            yaml_path = pkg_resources.resource_filename(__name__, 'pymacaron/%s.yaml' % name)
            if not os.path.isfile(yaml_path):
                yaml_path = os.path.join(os.path.dirname(sys.modules[__name__].__file__), '%s.yaml' % name)
            apis[name] = yaml_path

        if not include_crash_api:
            del apis['crash']

        # Save found apis
        self.path_apis = path
        self.apis = apis

        return self
949678
function loadIgnoreFile(filepath) {
  var ignoredDeps = [];

  /**
     * Check if string is not empty
     * @param {string} line string to examine
     * @returns {boolean} True is its not empty
     * @private
     */
  function nonEmpty(line) {
    return line.trim() !== '' && line[0] !== '#';
  }

  if (filepath) {
    try {
      ignoredDeps = fs.readFileSync(filepath, 'utf8')
        .split(/\r?\n/)
        .filter(nonEmpty);
    } catch (e) {
      e.message = 'Cannot read ignore file: ' + filepath + '\nError: ' + e.message;
      throw e;
    }
  }

  return ignoredDeps;
}
826723
def handle_url(url, session, res):
    """"""
    print("Parsing", url, file=sys.stderr)
    try:
        data = getPageContent(url, session)
    except IOError as msg:
        print("ERROR:", msg, file=sys.stderr)
        return
    for match in url_matcher.finditer(data):
        url = match.group(1)
        name = unescape(match.group(2))
        name = asciify(name.replace('&', 'And').replace('@', 'At'))
        name = capfirst(name)
        if name in exclude_comics:
            continue
        if contains_case_insensitive(res, name):
            # we cannot handle two comics that only differ in case
            print("INFO: skipping possible duplicate", repr(name), file=sys.stderr)
            continue
        res[name] = url
201955
def load(cls, filename, encoding):
        """"""
        if encoding is None:
            encoding = cls.encoding

        with io.open(filename, 'r', encoding=encoding) as fd:
            source = fd.read()

        if cls.normalize_newlines:
            source = source.replace('\r\n', '\n').replace('\r', '\n')
        return cls.loads(source)
372798
def _load_rules(self):
        """"""
        for ruleset in self.active_rulesets:
            section_name = 'sweep_rules_' + ruleset.lower()
            try:
                ruledefs = getattr(self.config, section_name)
            except AttributeError:
                raise error.UserError("There is no [{}] section in your configuration"
                                      .format(section_name.upper()))
            for ruledef, filtercond in ruledefs.items():
                if ruledef.endswith('.filter'):
                    rulename = ruledef.rsplit('.', 1)[0]
                    rule = SweepRule(ruleset, rulename,
                                     int(ruledefs.get(rulename + '.prio', '999')),
                                     ruledefs.get(rulename + '.order', self.default_order),
                                     parse_cond(filtercond))
                    self.rules.append(rule)

        self.rules.sort(key=lambda x: (x.prio, x.name))

        return self.rules
868885
def load(self, patterns, dirs, ignore=None):
        
        for path in self.find_files(patterns=patterns, dirs=dirs, ignore=ignore):
            data = self.read_file(path=path)
            if data:
                self.paths[path] = data