Set nseg of sections based on dL param: section.nseg = 1 + 2 * int(section.L / (2*dL))
    :param secs: netpyne dictionary with all sections 
    :param dL: dL from config file
177334
def fix_sec_nseg(secs, dL):
    

    for secName in secs:
        secs[secName]['geom']['nseg'] = 1 + 2 * int(secs[secName]['geom']['L'] / (2*dL))
404999
def _set_from_ini(self, namespace, ini_file):
        
        # Isolate global values
        global_vars = dict((key, val)
            for key, val in namespace.items()
            if isinstance(val, basestring)
        )

        # Copy all sections
        for section in ini_file.sections():
            # Get values set so far
            if section == "GLOBAL":
                raw_vars = global_vars
            else:
                raw_vars = namespace.setdefault(section.lower(), {})

            # Override with values set in this INI file
            raw_vars.update(dict(ini_file.items(section, raw=True)))

            # Interpolate and validate all values
            if section == "FORMATS":
                self._interpolation_escape(raw_vars)
            raw_vars.update(dict(
                (key, validate(key, val))
                for key, val in ini_file.items(section, vars=raw_vars)
            ))

        # Update global values
        namespace.update(global_vars)
491013
def _parseSections(self, data, elfHeader):
        """"""
        offset = elfHeader.header.e_shoff
        shdrs = []
        for i in range(elfHeader.header.e_shnum):
            shdr = self.__classes.SHDR.from_buffer(data, offset)
            section_bytes = None
            ba_section_bytes = None
            if shdr.sh_type != SHT.NOBITS:
                section_bytes = (c_ubyte * shdr.sh_size).from_buffer(data, shdr.sh_offset)
                ba_section_bytes = bytearray(section_bytes)
            shdrs.append(ShdrData(name=None,header=shdr, raw=section_bytes, bytes=ba_section_bytes))
            offset += elfHeader.header.e_shentsize

        if elfHeader.header.e_shstrndx != SHN.UNDEF:
            strtab = shdrs[elfHeader.header.e_shstrndx]
            strtab_offset = strtab.header.sh_offset

            for section in shdrs:
                section.name = get_str(strtab.raw, section.header.sh_name)

        return shdrs
1313155
def get_section_hdrgos_nts(self, sortby=None):
        """"""
        nts_all = []
        section_hdrgos_actual = self.get_sections_2d()
        flds_all = ['Section'] + self.gosubdag.prt_attr['flds']
        ntobj = cx.namedtuple("NtGoSec", " ".join(flds_all))
        flds_go = None
        if sortby is None:
            sortby = lambda nt: -1*nt.dcnt
        for section_name, hdrgos_actual in section_hdrgos_actual:
            nts_sec = []
            for hdrgo_nt in self.gosubdag.get_go2nt(hdrgos_actual).values():
                if flds_go is None:
                    flds_go = hdrgo_nt._fields
                key2val = {key:val for key, val in zip(flds_go, list(hdrgo_nt))}
                key2val['Section'] = section_name
                nts_sec.append(ntobj(**key2val))
            nts_all.extend(sorted(nts_sec, key=sortby))
        return nts_all
103439
def sanitize(self):
        '''
        
        '''
        # The N bit is the nonce-present bit.  When this bit is set to 1,
        # the low-order 24-bits of the first 32-bits of the LISP header
        # contains a Nonce.  See Section 6.3.1 for details.  Both N and V
        # bits MUST NOT be set in the same packet.  If they are, a
        # decapsulating ETR MUST treat the "Nonce/Map-Version" field as
        # having a Nonce value present.
        if self.nonce is not None and (not isinstance(self.nonce, bytes) or
                                       len(self.nonce) != 3):
            raise ValueError('Nonce must be a None or a sequence of 3 bytes')

        if self.nonce is not None \
        and (self.source_map_version is not None or
             self.destination_map_version is not None):
            raise ValueError('Cannot have both a nonce and map versions')

        # The L bit is the Locator Status Bits field enabled bit.  When this
        # bit is set to 1, the Locator Status Bits in the second 32-bits of
        # the LISP header are in use.
        if self.lsb is not None:
            # Determine how many bits we expect
            if self.instance_id is not None:
                lsb_bits = 8
            else:
                lsb_bits = 32

            # Check if LSBs is a sequence of booleans of the right length
            if not isinstance(self.lsb, collections.Sequence) \
            or len(self.lsb) != lsb_bits \
            or any(map(lambda v: type(v) != bool, self.lsb)):
                raise ValueError('Invalid locator status bits')

        # The E bit is the echo-nonce-request bit.  This bit MUST be ignored
        # and has no meaning when the N bit is set to 0.  When the N bit is
        # set to 1 and this bit is set to 1, means an ITR is requesting for
        # the nonce value in the Nonce field to be echoed back in LISP
        # encapsulated packets when the ITR is also an ETR.  See
        # Section 6.3.1 for details.
        if not isinstance(self.echo_nonce_request, bool):
            raise ValueError('Echo-Nonce-Request flag must be a boolean')

        if self.echo_nonce_request and self.nonce is None:
            self.echo_nonce_request = False

        # The V bit is the Map-Version present bit.  When this bit is set to
        # 1, the N bit MUST be 0.  Refer to Section 6.6.3 for more details.
        if self.source_map_version is not None \
        or self.destination_map_version is not None:
            if not isinstance(self.source_map_version, numbers.Integral) \
            or self.source_map_version < 0 \
            or self.source_map_version >= 2 ** 12:
                raise ValueError('Invalid source map version')

            if not isinstance(self.destination_map_version, numbers.Integral) \
            or self.destination_map_version < 0 \
            or self.destination_map_version >= 2 ** 12:
                raise ValueError('Invalid destination map version')

        # The I bit is the Instance ID bit.  See Section 5.5 for more
        # details.  When this bit is set to 1, the Locator Status Bits field
        # is reduced to 8-bits and the high-order 24-bits are used as an
        # Instance ID.  If the L-bit is set to 0, then the low-order 8 bits
        # are transmitted as zero and ignored on receipt.
        if self.instance_id is not None:
            if not isinstance(self.instance_id, numbers.Integral) \
            or self.instance_id < 0 \
            or self.instance_id >= 2 ** 24:
                raise ValueError('Invalid instance id')
1318234
async def section_name(self, sec_name=None):
        
        if self.writing:
            fvalue = sec_name.encode('ascii')
            await x.dump_uint(self.iobj, len(fvalue), 1)
            await self.iobj.awrite(bytearray(fvalue))

        else:
            ivalue = await x.load_uint(self.iobj, 1)
            fvalue = bytearray(ivalue)
            await self.iobj.areadinto(fvalue)
            return bytes(fvalue).decode('ascii')
69335
void set_sectioned_gain()
    {
        double gain = 0.0f;
        if (sectioned_gain_ == 0 && sectioned_clusters_.size() > 1)
        {
            for (Cluster<K> cluster : sectioned_clusters_)
            {
                gain += cluster.composite_vector().norm();
            }
            gain -= composite_.norm();
        }
        sectioned_gain_ = gain;
    }
1303741
def set_option(section='main', cfg_file=cfg_file, **kwargs):
    
    parser = get_parser(cfg_file=cfg_file)
    if section not in parser.sections():
        parser.add_section(section)

    for k, v in kwargs.items():
        parser.set(section=section, option=k, value=v)

    with open(cfg_file, 'w') as f:
        parser.write(f)
    return "Done"
836640
def summarize_sec2hdrnts(self, sec2d_hdrnts):
        """"""
        sec2d_hdrgos = [(s, set(nt.GO for nt in nts)) for s, nts in sec2d_hdrnts]
        return self.summarize_sec2hdrgos(sec2d_hdrgos)
704258
def set(config, section, opt, value):
        
        if section not in config.keys():
            config[section] = {}

        config[section][opt] = value
786182
def setSectionLength(self, length):
        
        self._sectionLength = length
        for editor in self.editors():
            editor.setMaxLength(length)
1000722
def sec_as_hex(self, is_compressed=None):
        
        sec = self.sec(is_compressed=is_compressed)
        return self._network.sec_text_for_blob(sec)
484421
def read_sections(sections_file, exclude_ungrouped=False, prt=sys.stdout):
    """"""
    if sections_file is None:
        return None
    assert isinstance(sections_file, str), "BAD SECTIONS FILENAME({S})".format(
        S=sections_file)
    if os.path.exists(sections_file):
        return ReadGoids().read_sections(sections_file, False, exclude_ungrouped)
    # Is 'sections_file' a module string?
    if '/' not in sections_file and r'\\' not in sections_file and \
            pkgutil.find_loader(sections_file) is not None:
        mod = importlib.import_module(sections_file)
        var = getattr(mod, 'SECTIONS', None)
        if var is not None:
            dat = SummarySec2dHdrGos().summarize_sec2hdrgos(var)
            print(Grouper.fmtsum.format(
                GO_DESC='hdr', SECs=len(dat['S']), GOs=len(dat['G']),
                UNGRP="N/A", undesc="unused", ACTION="IMPORTED: ", FILE=sections_file))
            return var
        raise RuntimeError("NO 'SECTIONS' VARIABLE FOUND IN MODULE({M})".format(M=sections_file))
    if prt:
        prt.write("CANNOT READ: {SEC}\n".format(SEC=sections_file))
635725
def prt_section_key(self, prt=sys.stdout):
        """"""
        for section_name, letter in self.sec2chr.items():
            prt.write("{ABC} {SEC_NAME}\n".format(ABC=letter, SEC_NAME=section_name))
318735
def sections(self):
        
        secs = OrderedDict()
        secs['Overview'] = self.sec_overview
        secs['Communication Channels'] = self.sec_com_channels
        secs['Detailed Activity by Project'] = self.sec_projects

        return secs
996133
def __set_folder_list(self, section):
        
        for l in range(1, self.__folder_list_max_size + 1):
            value = {}
            key = 'folder_' + str(l) + '_'

            # Path is mandatory
            value['indice'] = str(l)
            value['path'] = self.config.get_value(section, key + 'path')
            if value['path'] is None:
                continue
            else:
                value['path'] = nativestr(value['path'])

            # Optional conf keys
            for i in ['careful', 'warning', 'critical']:
                # Read threshold
                value[i] = self.config.get_value(section, key + i)
                if value[i] is not None:
                    logger.debug("{} threshold for folder {} is {}".format(i, value["path"], value[i]))
                # Read action
                action = self.config.get_value(section, key + i + '_action')
                if action is not None:
                    value[i + '_action'] = action
                    logger.debug("{} action for folder {} is {}".format(i, value["path"], value[i + '_action']))

            # Add the item to the list
            self.__folder_list.append(value)
1349112
def _get_section_start_index(self, section):
        '''
        '''

        sec_start_re = r'%s\s*\{' % section

        found = re.search(sec_start_re, self.template_str)
        if found:
            return found.end() - 1

        raise NonextantSectionException(
            'Section %s not found in template' % section
            )