Parse params from file's modeline.

    :return dict: Linter params.
422521
def parse_modeline(code):
    
    seek = MODELINE_RE.search(code)
    if seek:
        return dict(v.split('=') for v in seek.group(1).split(':'))

    return dict()
23428
def parseParams(string):
    
    all = params_re.findall(string)
    allParameters = []
    for tup in all:
        paramList = [tup[0]]  # tup looks like (name, valuesString)
        for pair in param_values_re.findall(tup[1]):
            # pair looks like ('', value) or (value, '')
            if pair[0] != '':
                paramList.append(pair[0])
            else:
                paramList.append(pair[1])
        allParameters.append(paramList)
    return allParameters
536830
def parse(self):
        """"""
        for line in self.lines:
            # Parse the line
            field_defs = self.parse_line(line)
            fields = []

            # Convert field parameters into Field objects
            for (kind, options) in field_defs:
                logger.debug("Creating field %s(%r)", kind, options)
                fields.append(self.field_registry.create(kind, **options))

            # Add the list of Field objects to the 'fields per line'.
            self.line_fields.append(fields)

            # Pre-fill the list of widgets
            for field in fields:
                self.widgets[field] = None
1062628
def load_params(fname: str) -> Tuple[Dict[str, mx.nd.NDArray], Dict[str, mx.nd.NDArray]]:
    
    save_dict = mx.nd.load(fname)
    arg_params = {}
    aux_params = {}
    for k, v in save_dict.items():
        tp, name = k.split(':', 1)
        if tp == 'arg':
            """TODO(fhieber):
            temporary weight split for models with combined weight for keys & values
            in transformer source attention layers. This can be removed once with the next major version change."""
            if "att_enc_kv2h_weight" in name:
                logger.info("Splitting '%s' parameters into separate k & v matrices.", name)
                v_split = mx.nd.split(v, axis=0, num_outputs=2)
                arg_params[name.replace('kv2h', "k2h")] = v_split[0]
                arg_params[name.replace('kv2h', "v2h")] = v_split[1]
            else:
                arg_params[name] = v
        if tp == 'aux':
            aux_params[name] = v
    return arg_params, aux_params
1213704
def _parse_file(self, file):
        
        case = Case()
        file.seek(0)

        line = file.readline().split()
        if line[0] != "function":
            logger.error("Invalid data file header.")
            return case
        if line[1] != "mpc":
            self._is_struct = False
            base = ""
        else:
            base = "mpc."
        case.name = line[-1]

        for line in file:
            if line.startswith("%sbaseMVA" % base):
                case_data = line.rstrip(";\n").split()
                case.base_mva = float(case_data[-1])
            elif line.startswith("%sbus" % base):
                self._parse_buses(case, file)
            elif line.startswith("%sgencost" % base):
                self._parse_gencost(case, file)
            elif line.startswith("%sgen" % base):
                self._parse_generators(case, file)
            elif line.startswith("%sbranch" % base):
                self._parse_branches(case, file)

        return case
631078
def _parse_params(self, params=None):
        
        prm = self.default_params.copy()
        if params is not None: 
            prm.update(params)
 
        # Background file is essential!
        if not prm["background"]:
            print("Background file needed!")
            sys.exit()
        
        prm["background"] =  os.path.abspath(prm["background"])
        
        prm["strand"] = ""
        if prm["single"]:
            prm["strand"] = " -strand + "
        
        return prm
1313780
def to_params(self):
        
        dic = self.__dict__
        return [(k, repr(dic[k])) for k in sorted(dic)
                if not k.startswith('_')]
50335
def from_file(cls, fn, *args, **kwargs):
        
        return AmiraHeader(get_parsed_data(fn, *args, **kwargs))
147260
def params(self):
        
        paramlist = [b.params for b in self.bases if b.params.has_value]

        if len(paramlist) == 0:
            return Parameter()
        else:
            return paramlist if len(paramlist) > 1 else paramlist[0]
276990
def parse(self):
        
        index_server = None
        for num, line in enumerate(self.iter_lines()):
            line = line.rstrip()
            if not line:
                continue
            if line.startswith('#'):
                # comments are lines that start with # only
                continue
            if line.startswith('-i') or \
                line.startswith('--index-url') or \
                line.startswith('--extra-index-url'):
                # this file is using a private index server, try to parse it
                index_server = self.parse_index_server(line)
                continue
            elif self.obj.path and (line.startswith('-r') or line.startswith('--requirement')):
                self.obj.resolved_files.append(self.resolve_file(self.obj.path, line))
            elif line.startswith('-f') or line.startswith('--find-links') or \
                line.startswith('--no-index') or line.startswith('--allow-external') or \
                line.startswith('--allow-unverified') or line.startswith('-Z') or \
                line.startswith('--always-unzip'):
                continue
            elif self.is_marked_line(line):
                continue
            else:
                try:

                    parseable_line = line

                    # multiline requirements are not parseable
                    if "\\" in line:
                        parseable_line = line.replace("\\", "")
                        for next_line in self.iter_lines(num + 1):
                            parseable_line += next_line.strip().replace("\\", "")
                            line += "\n" + next_line
                            if "\\" in next_line:
                                continue
                            break
                        # ignore multiline requirements if they are marked
                        if self.is_marked_line(parseable_line):
                            continue

                    hashes = []
                    if "--hash" in parseable_line:
                        parseable_line, hashes = Parser.parse_hashes(parseable_line)

                    req = RequirementsTXTLineParser.parse(parseable_line)
                    if req:
                        req.hashes = hashes
                        req.index_server = index_server
                        # replace the requirements line with the 'real' line
                        req.line = line
                        self.obj.dependencies.append(req)
                except ValueError:
                    continue
492644
def parse_msdos(self, lines):
        ''''''
        for line in lines:
            fields = line.split(None, 4)

            date_str = fields[0]
            time_str = fields[1]

            datetime_str = '{} {}'.format(date_str, time_str)

            file_datetime = self.parse_datetime(datetime_str)[0]

            if fields[2] == '<DIR>':
                file_size = None
                file_type = 'dir'
            else:
                file_size = parse_int(fields[2])
                file_type = 'file'

            filename = fields[3]

            yield FileEntry(filename, file_type, file_size, file_datetime)
875380
def _line_to_dict(self, file, field_names):
        
        for line in file:
            delimiter = settings.IPGEOBASE_FILE_FIELDS_DELIMITER
            yield self._extract_data_from_line(line, field_names, delimiter)
773881
def parse_params(params, key_word)
      body = params.has_key?(:path) ? load_file(params[:path], key_word) : params
      body = { key_word => body } unless body.has_key?(key_word.to_sym)
      body
    end
1109913
def _parse_params(self, params=None):
        
        prm = self.default_params.copy()
        if params is not None: 
            prm.update(params)
 
        if prm["background_model"]:
            # Absolute path, just to be sure
            prm["background_model"] = os.path.abspath(prm["background_model"])
        else:
            if prm.get("organism", None):
                prm["background_model"] = os.path.join(
                        self.config.get_bg_dir(), 
                        "{}.{}.bg".format(
                            prm["organism"], 
                            "MotifSampler"))
            else:            
                raise Exception("No background specified for {}".format(self.name))
        
        prm["strand"] = 1
        if prm["single"]:
            prm["strand"] = 0
        
        tmp = NamedTemporaryFile(dir=self.tmpdir)
        prm["pwmfile"] = tmp.name

        tmp2  = NamedTemporaryFile(dir=self.tmpdir)
        prm["outfile"] = tmp2.name
 
        return prm
1114774
def p_paramlist(self, p):
        ''
        p[0] = Paramlist(params=p[3], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
513539
def _get_params_value(params):
    
    # sort params for consistency
    ord_params = sorted(params)

    def fn(obj):
        l = []
        for p in ord_params:
            try:
                l.append((p, obj.parameters[p]))
            except:
                raise ValueError('{} is not a valid parameter'.format(p))
        return tuple(l)
    return fn
1117515
def load_parameters(self, path):
        
        nn.load_parameters(path)
        for v in self.get_modules():
            if not isinstance(v, tuple):
                continue
            prefix, module = v
            for k, v in module.__dict__.items():
                if not isinstance(v, nn.Variable):
                    continue
                pname = k
                name = "{}/{}".format(prefix, pname)
                # Substitute
                param0 = v
                param1 = nn.parameter.pop_parameter(name)
                if param0 is None:
                    raise ValueError(
                        "Model does not have {} parameter.".format(name))
                param0.d = param1.d.copy()
                nn.logger.info("`{}` loaded.)".format(name))