parse a line to determine if it is an import of messages
769703
function parseImportLine (line) {
  if (IS_IMPORT.test(line)) {
    // could be either depending on whether default import was before or after named imports
    const [, default0, named, default1] = IMPORT.exec(line)
    const defaultImport = default0 || default1
    const namedImports = []
    if (named) {
      let next
      while ((next = NAMED_IMPORTS.exec(named)) != null) {
        const [, src, importedAs] = next
        namedImports.push([src, importedAs || src]) // if no alternate name, use default name
      }
    }

    return [defaultImport, namedImports]
  } else {
    return null
  }
}
675921
def check(self, defn, msg=None):
        
        if isinstance(defn.type, dtype.PrimitiveType):
            # Check the nbytes designated in the YAML match the PDT
            nbytes = defn.type.nbytes
            defnbytes = defn.slice().stop - defn.slice().start
            if nbytes != defnbytes:
                self.messages.append(self.msg % defn.name)
                self.messages.append("Definition size of (" + str(defnbytes) +
                                     " bytes) does not match size of data" +
                                     " type " +str(defn.type.name) + " (" +
                                     str(nbytes) + " byte(s))")
                # TODO self.messages.append("TBD location message")
                self.valid = False
1369724
def parse(self, lines):
        ''''''
        if self.type == 'msdos':
            return self.parse_msdos(lines)
        elif self.type == 'unix':
            return self.parse_unix(lines)
        elif self.type == 'nlst':
            return self.parse_nlst(lines)
        else:
            raise UnknownListingError('Unsupported listing type.')
303103
def parse_include(self, start):
        
        # Seek back to start of line
        i = start
        while i:
            if self.text[i] == '\n':
                i += 1
                break
            i -= 1
        line_start = i

        # check that there is no unexpected text before the include
        if not (self.text[line_start:start] == "" or self.text[line_start:start].isspace()):
            self.env.msg.fatal(
                "Unexpected text before include",
                messages.SourceRef(line_start, start-1, filename=self.path)
            )

        # Capture include contents
        inc_regex = re.compile(r'`include\s+("([^\r\n]+)"|<([^\r\n]+)>)')
        m_inc = inc_regex.match(self.text, start)
        if m_inc is None:
            self.env.msg.fatal(
                "Invalid usage of include directive",
                messages.SourceRef(start, start+7, filename=self.path)
            )
        incl_path_raw = m_inc.group(2) or m_inc.group(3)
        end = m_inc.end(0)-1
        path_start = m_inc.start(1)
        #[^\r\n]*?\r?\n
        # Check that only comments follow
        tail_regex = re.compile(r'(?:[ \t]*/\*[^\r\n]*?\*/)*[ \t]*(?://[^\r\n]*?|/\*[^\r\n]*?)?\r?\n')
        if not tail_regex.match(self.text, end+1):
            tail_capture_regex = re.compile(r'[^\r\n]*?\r?\n')
            m = tail_capture_regex.match(self.text, end+1)
            self.env.msg.fatal(
                "Unexpected text after include",
                messages.SourceRef(end+1, m.end(0)-1, filename=self.path)
            )

        # Resolve include path.
        if os.path.isabs(incl_path_raw):
            incl_path = incl_path_raw
        else:
            # Search include paths first.
            for search_path in self.search_paths:
                incl_path = os.path.join(search_path, incl_path_raw)
                if os.path.isfile(incl_path):
                    # found match!
                    break
            else:
                # Otherwise, assume it is relative to the current file
                incl_path = os.path.join(os.path.dirname(self.path), incl_path_raw)
        if not os.path.isfile(incl_path):
            self.env.msg.fatal(
                "Could not find '%s' in include search paths" % incl_path_raw,
                messages.SourceRef(path_start, end, filename=self.path)
            )

        # Check if path has already been referenced before
        incl_ref = self.incl_ref
        while incl_ref:
            if os.path.samefile(incl_path, incl_ref.path):
                self.env.msg.fatal(
                    "Include of '%s' results in a circular reference" % incl_path_raw,
                    messages.SourceRef(path_start, end, filename=self.path)
                )
            incl_ref = incl_ref.parent

        return(end, incl_path)
659171
function parse(line) {
  assert_str(line)

  return Either.either(pipe, noop, Right(line).chain(is_inlined).chain(is_native).chain(is_not_inlined))
}
436754
def parse(cls, line, encoding=pydle.protocol.DEFAULT_ENCODING):
        
        valid = True

        # Decode message.
        try:
            message = line.decode(encoding)
        except UnicodeDecodeError:
            # Try our fallback encoding.
            message = line.decode(pydle.protocol.FALLBACK_ENCODING)

        # Sanity check for message length.
        if len(message) > protocol.MESSAGE_LENGTH_LIMIT:
            valid = False

        # Strip message separator.
        if message.endswith(protocol.LINE_SEPARATOR):
            message = message[:-len(protocol.LINE_SEPARATOR)]
        elif message.endswith(protocol.MINIMAL_LINE_SEPARATOR):
            message = message[:-len(protocol.MINIMAL_LINE_SEPARATOR)]

        # Sanity check for forbidden characters.
        if any(ch in message for ch in protocol.FORBIDDEN_CHARACTERS):
            valid = False

        # Extract message sections.
        # Format: (:source)? command parameter*
        if message.startswith(':'):
            parts = protocol.ARGUMENT_SEPARATOR.split(message[1:], 2)
        else:
            parts = [ None ] + protocol.ARGUMENT_SEPARATOR.split(message, 1)

        if len(parts) == 3:
            source, command, raw_params = parts
        elif len(parts) == 2:
            source, command = parts
            raw_params = ''
        else:
            raise pydle.protocol.ProtocolViolation('Improper IRC message format: not enough elements.', message=message)

        # Sanity check for command.
        if not protocol.COMMAND_PATTERN.match(command):
            valid = False

        # Extract parameters properly.
        # Format: (word|:sentence)*

        # Only parameter is a 'trailing' sentence.
        if raw_params.startswith(protocol.TRAILING_PREFIX):
            params = [ raw_params[len(protocol.TRAILING_PREFIX):] ]
        # We have a sentence in our parameters.
        elif ' ' + protocol.TRAILING_PREFIX in raw_params:
            index = raw_params.find(' ' + protocol.TRAILING_PREFIX)

             # Get all single-word parameters.
            params = protocol.ARGUMENT_SEPARATOR.split(raw_params[:index].rstrip(' '))
            # Extract last parameter as sentence
            params.append(raw_params[index + len(protocol.TRAILING_PREFIX) + 1:])
        # We have some parameters, but no sentences.
        elif raw_params:
            params = protocol.ARGUMENT_SEPARATOR.split(raw_params)
        # No parameters.
        else:
            params = []

        # Commands can be either [a-zA-Z]+ or [0-9]+.
        # In the former case, force it to uppercase.
        # In the latter case (a numeric command), try to represent it as such.
        try:
            command = int(command)
        except ValueError:
            command = command.upper()

        # Return parsed message.
        return RFC1459Message(command, params, source=source, _valid=valid, _raw=message)
662581
def _parse_line(self, line):
        
        # first isolate the timestamp and the event type
        try:
            self._line_parsed = self._line_parsed + 1

            m = RE_LINE_REG.match(line)
            if m is None:
                m = RE_LINE_EXT.match(line)
            if m is None:
                return False
            self.log.debug("Matching line found %s" % line)
            (tstamp, event_type, remainder) = m.groups()
            tstamp = int(tstamp)

            # skip passive checks reports by default for spamminess
            if event_type == 'PASSIVE SERVICE CHECK' and not self.passive_checks:
                return False
            # then retrieve the event format for each specific event type
            fields = EVENT_FIELDS.get(event_type, None)
            if fields is None:
                self.log.warning("Ignoring unknown nagios event for line: %s" % (line[:-1]))
                return False
            elif fields is False:
                # Ignore and skip
                self.log.debug("Ignoring Nagios event for line: %s" % (line[:-1]))
                return False

            # and parse the rest of the line
            parts = [p.strip() for p in remainder.split(';')]
            # Chop parts we don't recognize
            parts = parts[: len(fields._fields)]

            event = self.create_event(tstamp, event_type, self.hostname, fields._make(parts), tags=self.tags)

            self._event(event)
            self.log.debug("Nagios event: %s" % (event))

            return True
        except Exception:
            self.log.exception("Unable to create a nagios event from line: [%s]" % (line))
            return False
75414
def process_message(message):
    
    message["type"] = message.pop("MsgType").lower()
    if message["type"] == 'event':
        message["type"] = str(message.pop("Event")).lower() + '_event'
        message_type = EventMetaClass.TYPES.get(message["type"], UnknownEvent)
    else:
        message_type = MessageMetaClass.TYPES.get(
            message["type"], UnknownMessage
        )
    return message_type(message)
1370729
def enumerate_dynamic_imports(tokens):
    
    imported_modules = []
    import_line = False
    for index, tok in enumerate(tokens):
        token_type = tok[0]
        token_string = tok[1]
        if token_type == tokenize.NEWLINE:
            import_line = False
        elif token_string == "import":
            try:
                if tokens[index-1][0] == tokenize.NEWLINE:
                    import_line = True
            except IndexError:
                import_line = True # Just means this is the first line
        elif import_line:
            if token_type == tokenize.NAME and tokens[index+1][1] != 'as':
                if token_string not in reserved_words:
                    if token_string not in imported_modules:
                        imported_modules.append(token_string)
    return imported_modules
123500
function checkImportCall(node) {
    if (node.callee.type !== 'Import') return
    if (node.arguments.length !== 1) return

    const modulePath = node.arguments[0]
    if (modulePath.type !== 'Literal') return
    if (typeof modulePath.value !== 'string') return

    checkSourceValue(modulePath, node)
  }
643247
def is_import(self):
        """"""
        return not self.cmd and len(self.deps) == 1 and len(self.outs) == 1
720720
function parseMessage(line) { // {{{
  var message = {};
  var match;

  // Parse prefix
  if (match = line.match(/^:([^ ]+) +/)) {
    message.prefix = match[1];
    line = line.replace(/^:[^ ]+ +/, '');
    if (match = message.prefix.match(/^([_a-zA-Z0-9\[\]\\`^{}|-]*)(!([^@]+)@(.*))?$/)) {
      message.nick = match[1];
      message.user = match[3];
      message.host = match[4];
    }
    else
      message.server = message.prefix;
  }

  // Parse command
  match = line.match(/^([^ ]+) +/);
  message.command = match[1];
  message.rawCommand = match[1];
  message.commandType = 'normal';
  line = line.replace(/^[^ ]+ +/, '');

  if (replyFor[message.rawCommand]) {
    message.command     = replyFor[message.rawCommand].name;
    message.commandType = replyFor[message.rawCommand].type;
  }

  message.args = [];
  var middle, trailing;

  // Parse parameters
  if (line.indexOf(':') != -1) {
    var index = line.indexOf(':');
    middle = line.substr(0, index).replace(/ +$/, "");
    trailing = line.substr(index+1);
  } else
    middle = line;

  if (middle.length)
    message.args = middle.split(/ +/);

  if (typeof(trailing) != 'undefined' && trailing.length)
    message.args.push(trailing);

  return message;
}
712482
def parse(self, msg):
        
        #init
        dictValues = HL7Dict(self.tersersep)
        msg_ = msg.strip('\r\n ')

        # extracts separator defined in the message itself
        self.extractSeparators(dictValues, msg_)
        msg_ = msg_.replace('\r', '\n')
        lines = msg_.split('\n')
        lineNumber = 1

        # build the map of segments
        segmentNameCount, lineMap = self.buildSegmentMap(lines)
        dictValues.setSegmentsMap(segmentNameCount, lineMap)

        # Parse each line of the message : 1 line = 1 segment
        for line in lines:
            dictValues.currentLineNumber = lineNumber
            self.extractValues(dictValues, line)
            lineNumber += 1

        return dictValues
48585
def Parse(self):
    """"""
    (start_line, lang) = self.ParseDesc()
    if start_line < 0:
      return
    if 'python' == lang:
      self.ParsePythonFlags(start_line)
    elif 'c' == lang:
      self.ParseCFlags(start_line)
    elif 'java' == lang:
      self.ParseJavaFlags(start_line)
60228
def _extract_msg(args, kwargs, msg_idx, default_msg, non_msg_params):
    '''
    '''
    rem_args = []
    if 'msg' in kwargs:
        msg = kwargs.pop('msg')
    elif len(args) > non_msg_params and msg_idx < len(args):
        msg = args[msg_idx]
        if 0 <= msg_idx:
            rem_args = args[msg_idx + 1:]
        args = args[:msg_idx]
    else:
        msg = default_msg
    return msg, args, rem_args, kwargs
1092608
def message_line
      begin
        if @scanner.getch == '"'
          text = message_text
          unless @scanner.getch == '"'
            err_msg = "The message text '#{text}' must be finished with the double quote character '\"'."
            raise PoSyntaxError, err_msg
          end
          skip_whitespace
          unless end_of_line
            err_msg = "There should be only whitespace until the end of line"
            err_msg += " after the double quote character of a message text."
            raise PoSyntaxError.new(err_msg)
          end
          text
        else
          @scanner.pos = @scanner.pos - 1
          err_msg = "A message text needs to start with the double quote character '\"',"
          err_msg += " but this was found: #{@scanner.peek(10).inspect}"
          raise PoSyntaxError, err_msg
        end
      rescue PoSyntaxError => pe
        raise PoSyntaxError, "Syntax error in message_line\n" + pe.message, pe.backtrace
      end
    end
476582
def extract_from_plain(msg_body):
    """"""
    stripped_text = msg_body

    delimiter = get_delimiter(msg_body)
    msg_body = preprocess(msg_body, delimiter)
    # don't process too long messages
    lines = msg_body.splitlines()[:MAX_LINES_COUNT]
    markers = mark_message_lines(lines)
    lines = process_marked_lines(lines, markers)

    # concatenate lines, change links back, strip and return
    msg_body = delimiter.join(lines)
    msg_body = postprocess(msg_body)
    return msg_body