def _dump_message(self, m, top='<STR_LIT>'):

self._print()<EOL>self._print('<STR_LIT>'.format(m.name))<EOL>self.defines.append('<STR_LIT>'.format(top, m.name))<EOL>self.tabs+=<NUM_LIT:1><EOL>for f in m.field:<EOL><INDENT>self._dump_field(f)<EOL><DEDENT>for e in m.enum_type:<EOL><INDENT>self._dump_enum(e, top='<STR_LIT>'.format(top, m.name))<EOL><DEDENT>for n in m.nested_type:<EOL><INDENT>self._dump_message(n, top='<STR_LIT>'.format(top, m.name))<EOL><DEDENT>self.tabs-=<NUM_LIT:1><EOL>self._print('<STR_LIT:}>')<EOL>

Dump single message type.

        Keyword arguments:
        top -- top namespace


top = '<STR_LIT>'.format(fd.package) if len(fd.package) > <NUM_LIT:0> else '<STR_LIT>'<EOL>for e in fd.enum_type: self._dump_enum(e, top)<EOL>for m in fd.message_type: self. _dump_message(m, top)<EOL>


ser_pb = open(self.input_file, '<STR_LIT:rb>').read()  <EOL>fd = FileDescriptorProto()<EOL>fd.ParseFromString(ser_pb)<EOL>self.name = fd.name<EOL>self._print('<STR_LIT>')<EOL>self._print('<STR_LIT>')<EOL>self._print('<STR_LIT>')<EOL>if len(fd.package) > <NUM_LIT:0>:<EOL><INDENT>self._print('<STR_LIT>'.format(fd.package))<EOL>self.package = fd.package<EOL><DEDENT>else:<EOL><INDENT>self._print('<STR_LIT>')<EOL><DEDENT>self._walk(fd)<EOL>

Disassemble serialized protocol buffers file.


uri = out_dir + os.sep + self.name<EOL>with open(uri, '<STR_LIT:w>') as fh:<EOL><INDENT>fh.write('<STR_LIT:\n>'.join(self.lines))<EOL><DEDENT>

Dump proto file to given directory.

        Keyword arguments:
        out_dir -- dump directory. Default='.'


<EOL>imports = list(set(self.uses).difference(set(self.defines)))<EOL>for imp in imports:<EOL><INDENT>for p in pbds:<EOL><INDENT>if imp in p.defines:<EOL><INDENT>self.imports.append(p.name)<EOL>break<EOL><DEDENT><DEDENT><DEDENT>self.imports = list(set(self.imports))<EOL>for import_file in self.imports:<EOL><INDENT>self.lines.insert(<NUM_LIT:2>, '<STR_LIT>'.format(import_file))<EOL><DEDENT>

Find all missing imports in list of Pbd instances.


return (MSB << <NUM_LIT:8>) | LSB<EOL>

Returns the combined LSB and MSB

        :param LSB: Least Significant Byte
        :param MSB: Most Significant Byte

        :type LSB: byte
        :type MSB: byte

        :rtype: 16-bit unsigned int


if len(byte_array) != <NUM_LIT:4>:<EOL><INDENT>return None<EOL><DEDENT>return struct.unpack('<STR_LIT:f>', struct.pack('<STR_LIT>', *byte_array))[<NUM_LIT:0>]<EOL>

Returns an IEEE 754 float from an array of 4 bytes

        :param byte_array: Expects an array of 4 bytes

        :type byte_array: array

        :rtype: float


return mtof / <NUM_LIT><EOL>

Returns the average amount of time that particles in a bin
        took to cross the path of the laser [units -> microseconds]

        :param mtof: mass time-of-flight

        :type mtof: float

        :rtype: float


if len(vals) < <NUM_LIT:4>:<EOL><INDENT>return None<EOL><DEDENT>return ((vals[<NUM_LIT:3>] << <NUM_LIT>) | (vals[<NUM_LIT:2>] << <NUM_LIT:16>) | (vals[<NUM_LIT:1>] << <NUM_LIT:8>) | vals[<NUM_LIT:0>]) / <NUM_LIT><EOL>

Calculates the temperature in degrees celcius

        :param vals: array of bytes

        :type vals: array

        :rtype: float


if len(vals) < <NUM_LIT:4>:<EOL><INDENT>return None<EOL><DEDENT>return ((vals[<NUM_LIT:3>] << <NUM_LIT>) | (vals[<NUM_LIT:2>] << <NUM_LIT:16>) | (vals[<NUM_LIT:1>] << <NUM_LIT:8>) | vals[<NUM_LIT:0>])<EOL>

Calculates the pressure in pascals

        :param vals: array of bytes

        :type vals: array

        :rtype: float


if len(vals) < <NUM_LIT:4>:<EOL><INDENT>return None<EOL><DEDENT>if self.firmware['<STR_LIT>'] < <NUM_LIT:16>:<EOL><INDENT>return ((vals[<NUM_LIT:3>] << <NUM_LIT>) | (vals[<NUM_LIT:2>] << <NUM_LIT:16>) | (vals[<NUM_LIT:1>] << <NUM_LIT:8>) | vals[<NUM_LIT:0>]) / <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>return self._calculate_float(vals)<EOL><DEDENT>

calculate the sampling period in seconds


if not callable(self.on):<EOL><INDENT>raise UserWarning('<STR_LIT>')<EOL><DEDENT>if not callable(self.histogram):<EOL><INDENT>raise UserWarning('<STR_LIT>')<EOL><DEDENT>self.on()<EOL>while True:<EOL><INDENT>try:<EOL><INDENT>if self.histogram() is None:<EOL><INDENT>raise UserWarning('<STR_LIT>')<EOL><DEDENT><DEDENT>except UserWarning as e:<EOL><INDENT>sleep(kwargs.get('<STR_LIT>', <NUM_LIT:200>) / <NUM_LIT>)<EOL><DEDENT><DEDENT>return self<EOL>

Wait for the OPC to prepare itself for data transmission. On some devides this can take a few seconds
        :rtype: self
        :Example:
        >> alpha = opc.OPCN2(spi, debug=True).wait(check=200)
        >> alpha = opc.OPCN2(spi, debug=True, wait=True, check=200)


if adc_value < <NUM_LIT:0>:<EOL><INDENT>adc_value = <NUM_LIT:0><EOL><DEDENT>if adc_value > <NUM_LIT>:<EOL><INDENT>adc_value = <NUM_LIT><EOL><DEDENT>return OPC_LOOKUP[adc_value]<EOL>

Looks up the bin boundary value in microns based on the lookup table provided by Alphasense.

            :param adc_value: ADC Value (0 - 4095)

            :type adc_value: int

            :rtype: float


return min(enumerate(OPC_LOOKUP), key = lambda x: abs(x[<NUM_LIT:1>] - bb))[<NUM_LIT:0>]<EOL>

Calculate the adc value that corresponds to a specific bin boundary diameter in microns.

            :param bb: Bin Boundary in microns

            :type bb: float

            :rtype: int


infostring = []<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT>):<EOL><INDENT>resp = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>infostring.append(chr(resp))<EOL><DEDENT>sleep(<NUM_LIT:0.1>)<EOL>return '<STR_LIT>'.join(infostring)<EOL>

Reads the information string for the OPC

        :rtype: string

        :Example:

        >>> alpha.read_info_string()
        'OPC-N2 FirmwareVer=OPC-018.2....................BD'


b = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]           <EOL>sleep(<NUM_LIT:0.1>)<EOL>return True if b == <NUM_LIT> else False<EOL>

Checks the connection between the Raspberry Pi and the OPC

        :rtype: Boolean


b1 = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]          <EOL>sleep(<NUM_LIT>)                             <EOL>b2, b3 = self.cnxn.xfer([<NUM_LIT>, <NUM_LIT>])   <EOL>sleep(<NUM_LIT:0.1>)<EOL>return True if b1 == <NUM_LIT> and b2 == <NUM_LIT> else False<EOL>

Turn ON the OPC (fan and laser)

        :rtype: boolean

        :Example:

        >>> alpha.on()
        True


b1 = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]          <EOL>sleep(<NUM_LIT>)                             <EOL>b2 = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]          <EOL>sleep(<NUM_LIT:0.1>)<EOL>return True if b1 == <NUM_LIT> and b2 == <NUM_LIT> else False<EOL>

Turn OFF the OPC (fan and laser)

        :rtype: boolean

        :Example:

        >>> alpha.off()
        True


config  = []<EOL>data    = {}<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT>):<EOL><INDENT>resp = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>config.append(resp)<EOL><DEDENT>for i in range(<NUM_LIT:0>, <NUM_LIT:15>):<EOL><INDENT>data["<STR_LIT>".format(i)] = self._16bit_unsigned(config[<NUM_LIT:2>*i], config[<NUM_LIT:2>*i + <NUM_LIT:1>])<EOL><DEDENT>for i in range(<NUM_LIT:0>, <NUM_LIT:16>):<EOL><INDENT>data["<STR_LIT>".format(i)] = self._calculate_float(config[<NUM_LIT:4>*i + <NUM_LIT:32>:<NUM_LIT:4>*i + <NUM_LIT>])<EOL><DEDENT>for i in range(<NUM_LIT:0>, <NUM_LIT:16>):<EOL><INDENT>data["<STR_LIT>".format(i)] = self._calculate_float(config[<NUM_LIT:4>*i + <NUM_LIT>:<NUM_LIT:4>*i + <NUM_LIT:100>])<EOL><DEDENT>for i in range(<NUM_LIT:0>, <NUM_LIT:16>):<EOL><INDENT>data["<STR_LIT>".format(i)] = self._calculate_float(config[<NUM_LIT:4>*i + <NUM_LIT>: <NUM_LIT:4>*i + <NUM_LIT>])<EOL><DEDENT>data["<STR_LIT>"] = self._calculate_float(config[<NUM_LIT>:<NUM_LIT>])<EOL>data["<STR_LIT>"] = self._calculate_float(config[<NUM_LIT>:<NUM_LIT>])<EOL>data["<STR_LIT>"]    = config[<NUM_LIT>]<EOL>data["<STR_LIT>"]      = config[<NUM_LIT>]<EOL>if self.firmware['<STR_LIT>'] > <NUM_LIT>:<EOL><INDENT>data['<STR_LIT>'] = config[<NUM_LIT>]<EOL><DEDENT>sleep(<NUM_LIT:0.1>)<EOL>return data<EOL>

Read the configuration variables and returns them as a dictionary

        :rtype: dictionary

        :Example:

        >>> alpha.config()
        {
            'BPD 13': 1.6499,
            'BPD 12': 1.6499,
            'BPD 11': 1.6499,
            'BPD 10': 1.6499,
            'BPD 15': 1.6499,
            'BPD 14': 1.6499,
            'BSVW 15': 1.0,
            ...
        }


config  = []<EOL>data    = {}<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT:9>):<EOL><INDENT>resp = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>config.append(resp)<EOL><DEDENT>data["<STR_LIT>"]      = self._16bit_unsigned(config[<NUM_LIT:0>], config[<NUM_LIT:1>])<EOL>data["<STR_LIT>"]     = self._16bit_unsigned(config[<NUM_LIT:2>], config[<NUM_LIT:3>])<EOL>data['<STR_LIT>']             = config[<NUM_LIT:4>]<EOL>data['<STR_LIT>']           = config[<NUM_LIT:5>]<EOL>data['<STR_LIT>']   = self._16bit_unsigned(config[<NUM_LIT:6>], config[<NUM_LIT:7>])<EOL>data['<STR_LIT>']        = config[<NUM_LIT:8>]<EOL>sleep(<NUM_LIT:0.1>)<EOL>return data<EOL>

Read the second set of configuration variables and return as a dictionary.

        **NOTE: This method is supported by firmware v18+.**

        :rtype: dictionary

        :Example:

        >>> a.config2()
        {
            'AMFanOnIdle': 0,
            'AMIdleIntervalCount': 0,
            'AMMaxDataArraysInFile': 61798,
            'AMSamplingInterval': 1,
            'AMOnlySavePMData': 0,
            'AMLaserOnIdle': 0
        }


logger.warning("<STR_LIT>")<EOL>return<EOL>

Write configuration variables to non-volatile memory.

        **NOTE: This method is currently a placeholder and is not implemented.**

        :param config_vars: dictionary containing the configuration variables

        :type config_vars: dictionary


Write configuration variables 2 to non-volatile memory.

        **NOTE: This method is currently a placeholder and is not implemented.**
        **NOTE: This method is supported by firmware v18+.**

        :param config_vars: dictionary containing the configuration variables

        :type config_vars: dictionary


resp = []<EOL>data = {}<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT>):<EOL><INDENT>r = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>resp.append(r)<EOL><DEDENT>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:0>], resp[<NUM_LIT:1>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:2>], resp[<NUM_LIT:3>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:4>], resp[<NUM_LIT:5>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:6>], resp[<NUM_LIT:7>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:8>], resp[<NUM_LIT:9>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:10>], resp[<NUM_LIT:11>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:12>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT:15>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:16>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT:20>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT:30>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']       = self._calculate_mtof(resp[<NUM_LIT:32>])<EOL>data['<STR_LIT>']       = self._calculate_mtof(resp[<NUM_LIT>])<EOL>data['<STR_LIT>']       = self._calculate_mtof(resp[<NUM_LIT>])<EOL>data['<STR_LIT>']       = self._calculate_mtof(resp[<NUM_LIT>])<EOL>if self.firmware['<STR_LIT:version>'] < <NUM_LIT>:<EOL><INDENT>data['<STR_LIT>']     = self._calculate_temp(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>']        = self._calculate_pressure(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>'] = self._calculate_period(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>']        = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']             = self._calculate_float(resp[<NUM_LIT:50>:<NUM_LIT>])<EOL>data['<STR_LIT>']           = self._calculate_float(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>']            = self._calculate_float(resp[<NUM_LIT>:])<EOL><DEDENT>else:<EOL><INDENT>data['<STR_LIT>']             = self._calculate_float(resp[<NUM_LIT>:<NUM_LIT>])<EOL>tmp = self._calculate_pressure(resp[<NUM_LIT>:<NUM_LIT>])<EOL>if tmp > <NUM_LIT>:<EOL><INDENT>data['<STR_LIT>'] = None<EOL>data['<STR_LIT>']    = tmp<EOL><DEDENT>else:<EOL><INDENT>tmp = self._calculate_temp(resp[<NUM_LIT>:<NUM_LIT>])<EOL>if tmp < <NUM_LIT>:<EOL><INDENT>data['<STR_LIT>'] = tmp<EOL>data['<STR_LIT>']    = None<EOL><DEDENT>else:<EOL><INDENT>data['<STR_LIT>'] = None<EOL>data['<STR_LIT>']    = None<EOL><DEDENT><DEDENT>data['<STR_LIT>'] = self._calculate_float(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>']        = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']             = self._calculate_float(resp[<NUM_LIT:50>:<NUM_LIT>])<EOL>data['<STR_LIT>']           = self._calculate_float(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>']            = self._calculate_float(resp[<NUM_LIT>:])<EOL><DEDENT>histogram_sum = data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>']   +data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>']   +data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>']  +data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>'] +data['<STR_LIT>']<EOL>if (histogram_sum & <NUM_LIT>) != data['<STR_LIT>']:<EOL><INDENT>logger.warning("<STR_LIT>")<EOL>return None<EOL><DEDENT>if number_concentration is True:<EOL><INDENT>_conv_ = data['<STR_LIT>'] * data['<STR_LIT>'] <EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']   = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']  = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']  = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']  = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']  = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']  = data['<STR_LIT>'] / _conv_<EOL>data['<STR_LIT>']  = data['<STR_LIT>'] / _conv_<EOL><DEDENT>sleep(<NUM_LIT:0.1>)<EOL>return data<EOL>

Read and reset the histogram. As of v1.3.0, histogram
        values are reported in particle number concentration (#/cc) by default.

        :param number_concentration: If true, histogram bins are reported in number concentration vs. raw values.

        :type number_concentration: boolean

        :rtype: dictionary

        :Example:

        >>> alpha.histogram()
        {
            'Temperature': None,
            'Pressure': None,
            'Bin 0': 0,
            'Bin 1': 0,
            'Bin 2': 0,
            ...
            'Bin 15': 0,
            'SFR': 3.700,
            'Bin1MToF': 0,
            'Bin3MToF': 0,
            'Bin5MToF': 0,
            'Bin7MToF': 0,
            'PM1': 0.0,
            'PM2.5': 0.0,
            'PM10': 0.0,
            'Sampling Period': 2.345,
            'Checksum': 0
        }


command = <NUM_LIT><EOL>byte_list = [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>success = [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>resp = []<EOL>r = self.cnxn.xfer([command])[<NUM_LIT:0>]<EOL>sleep(<NUM_LIT>)<EOL>resp.append(r)<EOL>for each in byte_list:<EOL><INDENT>r = self.cnxn.xfer([each])[<NUM_LIT:0>]<EOL>resp.append(r)<EOL><DEDENT>sleep(<NUM_LIT:0.1>)<EOL>return True if resp == success else False<EOL>

Save the configuration variables in non-volatile memory. This method
        should be used in conjuction with *write_config_variables*.

        :rtype: boolean

        :Example:

        >>> alpha.save_config_variables()
        True


return True if self.cnxn.xfer(<NUM_LIT>)[<NUM_LIT:0>] == <NUM_LIT> else False<EOL>

Enter bootloader mode. Must be issued prior to writing
        configuration variables to non-volatile memory.

        :rtype: boolean

        :Example:

        >>> alpha._enter_bootloader_mode()
        True


<EOL>if power > <NUM_LIT:255>:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>a = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>sleep(<NUM_LIT>)<EOL>b = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>c = self.cnxn.xfer([power])[<NUM_LIT:0>]<EOL>sleep(<NUM_LIT:0.1>)<EOL>return True if a == <NUM_LIT> and b == <NUM_LIT> and c == <NUM_LIT> else False<EOL>

Set only the Fan power.

        :param power: Fan power value as an integer between 0-255.

        :type power: int

        :rtype: boolean

        :Example:

        >>> alpha.set_fan_power(255)
        True


Set the laser power only.

        :param power: Laser power as a value between 0-255.

        :type power: int

        :rtype: boolean

        :Example:

        >>> alpha.set_laser_power(230)
        True


<EOL>a = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>sleep(<NUM_LIT>)<EOL>if state:<EOL><INDENT>b = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL><DEDENT>else:<EOL><INDENT>b = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL><DEDENT>sleep(<NUM_LIT:0.1>)<EOL>return True if a == <NUM_LIT> and b == <NUM_LIT> else False<EOL>

Toggle the power state of the laser.

        :param state: Boolean state of the laser

        :type state: boolean

        :rtype: boolean

        :Example:

        >>> alpha.toggle_laser(True)
        True


Toggle the power state of the fan.

        :param state: Boolean state of the fan

        :type state: boolean

        :rtype: boolean

        :Example:

        >>> alpha.toggle_fan(False)
        True


<EOL>a = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>sleep(<NUM_LIT>)<EOL>res = []<EOL>for i in range(<NUM_LIT:4>):<EOL><INDENT>res.append(self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>])<EOL><DEDENT>sleep(<NUM_LIT:0.1>)<EOL>return {<EOL>'<STR_LIT>':        res[<NUM_LIT:0>],<EOL>'<STR_LIT>':      res[<NUM_LIT:1>],<EOL>'<STR_LIT>':    res[<NUM_LIT:2>],<EOL>'<STR_LIT>':  res[<NUM_LIT:3>]<EOL>}<EOL>

Read the status of the digital pot. Firmware v18+ only.
        The return value is a dictionary containing the following as
        unsigned 8-bit integers: FanON, LaserON, FanDACVal, LaserDACVal.

        :rtype: dict

        :Example:

        >>> alpha.read_pot_status()
        {
            'LaserDACVal': 230,
            'FanDACVal': 255,
            'FanON': 0,
            'LaserON': 0
        }


string = []<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT>):<EOL><INDENT>resp = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>string.append(chr(resp))<EOL><DEDENT>sleep(<NUM_LIT:0.1>)<EOL>return '<STR_LIT>'.join(string)<EOL>

Read the Serial Number string. This method is only available on OPC-N2
        firmware versions 18+.

        :rtype: string

        :Example:

        >>> alpha.sn()
        'OPC-N2 123456789'


return<EOL>

Write the Serial Number string. This method is available for Firmware versions 18+.

        **NOTE: This method is currently a placeholder and is not implemented.**

        :param sn: string containing the serial number to write

        :type sn: string


<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>self.firmware['<STR_LIT>'] = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>self.firmware['<STR_LIT>'] = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>self.firmware['<STR_LIT:version>'] = float('<STR_LIT>'.format(self.firmware['<STR_LIT>'], self.firmware['<STR_LIT>']))<EOL>sleep(<NUM_LIT:0.1>)<EOL>return self.firmware<EOL>

Read the firmware version of the OPC-N2. Firmware v18+ only.

        :rtype: dict

        :Example:

        >>> alpha.read_firmware()
        {
            'major': 18,
            'minor': 2,
            'version': 18.2
        }


resp = []<EOL>data = {}<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT:12>):<EOL><INDENT>r = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>resp.append(r)<EOL><DEDENT>data['<STR_LIT>']     = self._calculate_float(resp[<NUM_LIT:0>:<NUM_LIT:4>])<EOL>data['<STR_LIT>']   = self._calculate_float(resp[<NUM_LIT:4>:<NUM_LIT:8>])<EOL>data['<STR_LIT>']    = self._calculate_float(resp[<NUM_LIT:8>:])<EOL>sleep(<NUM_LIT:0.1>)<EOL>return data<EOL>

Read the PM data and reset the histogram

        **NOTE: This method is supported by firmware v18+.**

        :rtype: dictionary

        :Example:

        >>> alpha.pm()
        {
            'PM1': 0.12,
            'PM2.5': 0.24,
            'PM10': 1.42
        }


b1 = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]          <EOL>sleep(<NUM_LIT>)                             <EOL>return True if b1 == <NUM_LIT> else False<EOL>

Turn ON the OPC (fan and laser)

        :returns: boolean success state


Turn OFF the OPC (fan and laser)

        :returns: boolean success state


config  = []<EOL>data    = {}<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT:8>):<EOL><INDENT>resp = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>config.append(resp)<EOL><DEDENT>data["<STR_LIT>"] = self._calculate_float(config[<NUM_LIT:0>:<NUM_LIT:4>])<EOL>data["<STR_LIT>"] = self._calculate_float(config[<NUM_LIT:4>:])<EOL>return data<EOL>

Read the gain-scaling-coefficient and sample flow rate.

        :returns: dictionary containing GSC and SFR


config  = []<EOL>data    = {}<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT:30>):<EOL><INDENT>resp = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>config.append(resp)<EOL><DEDENT>for i in range(<NUM_LIT:0>, <NUM_LIT>):<EOL><INDENT>data["<STR_LIT>".format(i)] = self._16bit_unsigned(config[<NUM_LIT:2>*i], config[<NUM_LIT:2>*i + <NUM_LIT:1>])<EOL><DEDENT>return data<EOL>

Return the bin boundaries.

        :returns: dictionary with 17 bin boundaries.


return<EOL>

Write the gsc and sfr values

        **NOTE**: This method is currently a placeholder.


config = []<EOL>self.cnxn.xfer([<NUM_LIT>])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT:4>):<EOL><INDENT>resp = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>config.append(resp)<EOL><DEDENT>bpd = self._calculate_float(config)<EOL>return bpd<EOL>

Read the bin particle density

        :returns: float


return<EOL>

Write the bin particle density values to memory. This method is currently a
        placeholder.

        :returns: None


resp = []<EOL>data = {}<EOL>command = <NUM_LIT><EOL>self.cnxn.xfer([command])<EOL>sleep(<NUM_LIT>)<EOL>for i in range(<NUM_LIT>):<EOL><INDENT>r = self.cnxn.xfer([<NUM_LIT>])[<NUM_LIT:0>]<EOL>resp.append(r)<EOL><DEDENT>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:0>], resp[<NUM_LIT:1>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:2>], resp[<NUM_LIT:3>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:4>], resp[<NUM_LIT:5>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:6>], resp[<NUM_LIT:7>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:8>], resp[<NUM_LIT:9>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:10>], resp[<NUM_LIT:11>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:12>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT:15>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT:16>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']           = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT:20>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']          = self._16bit_unsigned(resp[<NUM_LIT:30>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']       = self._calculate_mtof(resp[<NUM_LIT:32>])<EOL>data['<STR_LIT>']       = self._calculate_mtof(resp[<NUM_LIT>])<EOL>data['<STR_LIT>']       = self._calculate_mtof(resp[<NUM_LIT>])<EOL>data['<STR_LIT>']       = self._calculate_mtof(resp[<NUM_LIT>])<EOL>data['<STR_LIT>']     = self._calculate_temp(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>']        = self._calculate_pressure(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>'] = self._calculate_period(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>']        = self._16bit_unsigned(resp[<NUM_LIT>], resp[<NUM_LIT>])<EOL>data['<STR_LIT>']             = self._calculate_float(resp[<NUM_LIT:50>:<NUM_LIT>])<EOL>data['<STR_LIT>']           = self._calculate_float(resp[<NUM_LIT>:<NUM_LIT>])<EOL>data['<STR_LIT>']            = self._calculate_float(resp[<NUM_LIT>:])<EOL>histogram_sum = data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>']   +data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>']   +data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>']  +data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>'] + data['<STR_LIT>'] +data['<STR_LIT>']<EOL>return data<EOL>

Read and reset the histogram. The expected return is a dictionary
        containing the counts per bin, MToF for bins 1, 3, 5, and 7, temperature,
        pressure, the sampling period, the checksum, PM1, PM2.5, and PM10.

        **NOTE:** The sampling period for the OPCN1 seems to be incorrect.

        :returns: dictionary


return value.strftime(format_str)<EOL>

Convert a datetime to a different format.

The default format looks like --> 2016/11/25 12:34

Args:
    value (datetime.datetime): input date and time
    format_str (str): The datetime format string to apply to value

Returns:
    str: value, after the format_str has been applied


return value.strftime('<STR_LIT>')<EOL>

Convert a date to the format we want it displayed on the article template.

Format looks like --> Friday, November 4, 2016

Args:
    value (datetime.datetime): input date

Returns:
    str: value, formatted nicely for displaying the date.


return value.replace('<STR_LIT>', '<STR_LIT:U+0020>')<EOL>

Convert non-breaking spaces to regular spaces.

Args:
    value (str): input value

Returns:
    str: the input string, now with regular spaces


return _titlecase(value)<EOL>

Returns the titlecased version of the supplied text.

    Args:
        value (str): input value

    Returns:
        str: value, titlecase formatted


signals.generator_init.connect(add_all_filters)<EOL>


meta_file = read(*meta_file_parts)<EOL>meta_match = re.search(r"<STR_LIT>".format(meta_key),<EOL>meta_file, re.M)<EOL>if meta_match:<EOL><INDENT>return meta_match.group(<NUM_LIT:1>)<EOL><DEDENT>raise RuntimeError("<STR_LIT>".format(meta_key))<EOL>


assert self.abs_path and self.abs_bundle_path, "<STR_LIT>"<EOL>return self.abs_bundle_path<EOL>

Check if absolute path is not resolved yet


if not self.abs_path:<EOL><INDENT>rel_path = utils.prepare_path(self.rel_bundle_path)<EOL>self.abs_bundle_path = utils.prepare_path([builder.config.input_dir, rel_path])<EOL>self.abs_path = True<EOL><DEDENT>self.input_dir = builder.config.input_dir<EOL>

Called when builder group collect files
Resolves absolute url if relative passed

:type asset: static_bundle.builders.Asset
:type builder: static_bundle.builders.StandardBuilder


for file_path in args:<EOL><INDENT>self.files.append(FilePath(file_path, self))<EOL><DEDENT>

Add single file or list of files to bundle

:type: file_path: str|unicode


def add_directory(self, *args, **kwargs):

exc = kwargs.get('<STR_LIT>', None)<EOL>for path in args:<EOL><INDENT>self.files.append(DirectoryPath(path, self, exclusions=exc))<EOL><DEDENT>

Add directory or directories list to bundle

:param exclusions: List of excluded paths

:type path: str|unicode
:type exclusions: list


for obj in args:<EOL><INDENT>obj.bundle = self<EOL>self.files.append(obj)<EOL><DEDENT>

Add custom path objects

:type: path_object: static_bundle.paths.AbstractPath


if not isinstance(prepare_handlers, static_bundle.BUNDLE_ITERABLE_TYPES):<EOL><INDENT>prepare_handlers = [prepare_handlers]<EOL><DEDENT>if self.prepare_handlers_chain is None:<EOL><INDENT>self.prepare_handlers_chain = []<EOL><DEDENT>for handler in prepare_handlers:<EOL><INDENT>self.prepare_handlers_chain.append(handler)<EOL><DEDENT>

Add prepare handler to bundle

:type: prepare_handler: static_bundle.handlers.AbstractPrepareHandler


result_files = self.collect_files()<EOL>chain = self.prepare_handlers_chain<EOL>if chain is None:<EOL><INDENT>chain = [<EOL>LessCompilerPrepareHandler()<EOL>]<EOL><DEDENT>for prepare_handler in chain:<EOL><INDENT>result_files = prepare_handler.prepare(result_files, self)<EOL><DEDENT>return result_files<EOL>

Called when builder run collect files in builder group

:rtype: list[static_bundle.files.StaticFileResult]


return '<STR_LIT>'<EOL>


for bundle in args:<EOL><INDENT>if not self.multitype and self.has_bundles():<EOL><INDENT>first_bundle = self.get_first_bundle()<EOL>if first_bundle.get_type() != bundle.get_type():<EOL><INDENT>raise Exception(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>% (self.name, first_bundle.get_type(), bundle.get_type())<EOL>)<EOL><DEDENT><DEDENT>self.bundles.append(bundle)<EOL><DEDENT>return self<EOL>

Add some bundle to build group

:type bundle: static_bundle.bundles.AbstractBundle
@rtype: BuildGroup


self.files = []<EOL>for bundle in self.bundles:<EOL><INDENT>bundle.init_build(self, self.builder)<EOL>bundle_files = bundle.prepare()<EOL>self.files.extend(bundle_files)<EOL><DEDENT>return self<EOL>

Return collected files links

:rtype: list[static_bundle.files.StaticFileResult]


if self.minifier is None:<EOL><INDENT>if not self.has_bundles():<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>minifier = self.get_first_bundle().get_default_minifier()<EOL><DEDENT>else:<EOL><INDENT>minifier = self.minifier<EOL><DEDENT>if minifier:<EOL><INDENT>minifier.init_asset(self)<EOL><DEDENT>return minifier<EOL>

Asset minifier
Uses default minifier in bundle if it's not defined

:rtype: static_bundle.minifiers.DefaultMinifier|None


asset = Asset(self, name, **kwargs)<EOL>self.assets[name] = asset<EOL>return asset<EOL>

Create asset

:type name: unicode|str
:rtype: Asset


if name in self.assets:<EOL><INDENT>del self.assets[name]<EOL><DEDENT>

Remove asset by name

:type name: unicode|str


assert self.has_asset(name), "<STR_LIT>"<EOL>return self.assets[name]<EOL>

Get asset by name

:type name: unicode|str


return name in self.assets<EOL>

Check asset exists by name

:type name: unicode|str


result = "<STR_LIT>"<EOL>if self.has_asset(name):<EOL><INDENT>asset = self.get_asset(name)<EOL>if asset.files:<EOL><INDENT>for f in asset.files:<EOL><INDENT>result += f.render_include() + "<STR_LIT:\r\n>"<EOL><DEDENT><DEDENT><DEDENT>return result<EOL>

Render all includes in asset by names

:type name: str|unicode
:rtype: str|unicode


return self.render_asset(name)<EOL>


for asset in self.assets.values():<EOL><INDENT>if asset.has_bundles():<EOL><INDENT>asset.collect_files()<EOL><DEDENT><DEDENT>if env is None:<EOL><INDENT>env = self.config.env<EOL><DEDENT>if env == static_bundle.ENV_PRODUCTION:<EOL><INDENT>self._minify(emulate=True)<EOL><DEDENT>self._add_url_prefix()<EOL>


for asset in self.assets.values():<EOL><INDENT>if asset.has_bundles():<EOL><INDENT>asset.collect_files()<EOL><DEDENT><DEDENT>if not os.path.exists(self.config.output_dir):<EOL><INDENT>os.makedirs(self.config.output_dir)<EOL><DEDENT>if self.config.copy_only_bundles:<EOL><INDENT>for asset in self.assets.values():<EOL><INDENT>if not asset.minify and asset.files:<EOL><INDENT>for f in asset.files:<EOL><INDENT>copy_file(f.abs_path, self._get_output_path(f.abs_path))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>copy_excludes = {}<EOL>for asset in self.assets.values():<EOL><INDENT>if asset.minify and asset.files:<EOL><INDENT>for f in asset.files:<EOL><INDENT>copy_excludes[f.abs_path] = f<EOL><DEDENT><DEDENT><DEDENT>for root, dirs, files in os.walk(self.config.input_dir):<EOL><INDENT>for fpath in files:<EOL><INDENT>current_file_path = os.path.join(root, fpath)<EOL>if current_file_path not in copy_excludes:<EOL><INDENT>copy_file(current_file_path, self._get_output_path(current_file_path))<EOL><DEDENT><DEDENT><DEDENT><DEDENT>self._minify()<EOL>


exclude = exclude or []<EOL>for root, dirs, files in os.walk(self.config.output_dir):<EOL><INDENT>for f in files:<EOL><INDENT>if f not in exclude:<EOL><INDENT>os.unlink(os.path.join(root, f))<EOL><DEDENT><DEDENT>for d in dirs:<EOL><INDENT>if d not in exclude:<EOL><INDENT>shutil.rmtree(os.path.join(root, d))<EOL><DEDENT><DEDENT><DEDENT>

Clear build output dir
:type exclude: list|None


raise NotImplementedError<EOL>

Collect used files
Return list with one element for single file
and list with all files for directory path

:rtype: list


def get_abs_and_rel_paths(self, root_path, file_name, input_dir):

<EOL>relative_dir = root_path.replace(input_dir, '<STR_LIT>')<EOL>return os.path.join(root_path, file_name), relative_dir + '<STR_LIT:/>' + file_name<EOL>

Return absolute and relative path for file

:type root_path: str|unicode
:type file_name: str|unicode
:type input_dir: str|unicode
:rtype: tuple


def __init__(self, file_path, bundle=None):

self.file_path = prepare_path(file_path)<EOL>self.bundle = bundle<EOL>

:type file_path: str|unicode
:type bundle: static_bundle.bundles.AbstractBundle


assert self.bundle, '<STR_LIT>'<EOL>abs_path, rel_path = self.get_abs_and_rel_paths(self.bundle.path, self.file_path, self.bundle.input_dir)<EOL>file_cls = self.bundle.get_file_cls()<EOL>return [file_cls(rel_path, abs_path)]<EOL>


assert self.bundle, '<STR_LIT>'<EOL>result_files = []<EOL>bundle_ext = self.bundle.get_extension()<EOL>ext = "<STR_LIT:.>" + bundle_ext if bundle_ext else None<EOL>if self.directory_path == "<STR_LIT>":<EOL><INDENT>root_path = self.bundle.path<EOL><DEDENT>else:<EOL><INDENT>root_path = os.path.join(self.bundle.path, self.directory_path)<EOL><DEDENT>for root, dirs, files in os.walk(root_path):<EOL><INDENT>for fpath in files:<EOL><INDENT>if (not ext or fpath.endswith(ext)) and (not self.exclusions or all(fpath != n for n in self.exclusions)):<EOL><INDENT>abs_path, rel_path = self.get_abs_and_rel_paths(root, fpath, self.bundle.input_dir)<EOL>file_cls = self.bundle.get_file_cls()<EOL>result_files.append(file_cls(rel_path, abs_path))<EOL><DEDENT><DEDENT><DEDENT>return result_files<EOL>


raise NotImplementedError<EOL>

:type input_files: list[static_bundle.files.StaticFileResult]
:type bundle: list[static_bundle.bundles.AbstractBundle]
:rtype: list


out = []<EOL>for input_file in input_files:<EOL><INDENT>if input_file.extension == "<STR_LIT>" and os.path.isfile(input_file.abs_path):<EOL><INDENT>output_file = self.get_compile_file(input_file, bundle)<EOL>self.compile(input_file, output_file)<EOL>out.append(output_file)<EOL><DEDENT>else:<EOL><INDENT>out.append(input_file)<EOL><DEDENT><DEDENT>return out<EOL>

:type input_files: list[static_bundle.files.StaticFileResult]
:type bundle: static_bundle.bundles.AbstractBundle
:rtype: list


if type(path) == list:<EOL><INDENT>return os.path.join(*path)<EOL><DEDENT>return path<EOL>

Path join helper method
Join paths if list passed

:type path: str|unicode|list
:rtype: str|unicode


with codecs.open(file_path, "<STR_LIT:r>", encoding) as f:<EOL><INDENT>return f.read()<EOL><DEDENT>

Read helper method

:type file_path: str|unicode
:type encoding: str|unicode
:rtype: str|unicode


def write_to_file(file_path, contents, encoding="<STR_LIT:utf-8>"):

with codecs.open(file_path, "<STR_LIT:w>", encoding) as f:<EOL><INDENT>f.write(contents)<EOL><DEDENT>

Write helper method

:type file_path: str|unicode
:type contents: str|unicode
:type encoding: str|unicode


dir_path = os.path.dirname(dest)<EOL>if not os.path.exists(dir_path):<EOL><INDENT>os.makedirs(dir_path)<EOL><DEDENT>shutil.copy2(src, dest)<EOL>

Copy file helper method

:type src: str|unicode
:type dest: str|unicode


file_path, file_ext = os.path.splitext(path)<EOL>return file_ext.lstrip('<STR_LIT:.>')<EOL>

Split file name and extension

:type path: str|unicode
:rtype: one str|unicode


result_parts = []<EOL>while path != "<STR_LIT:/>":<EOL><INDENT>parts = os.path.split(path)<EOL>if parts[<NUM_LIT:1>] == path:<EOL><INDENT>result_parts.insert(<NUM_LIT:0>, parts[<NUM_LIT:1>])<EOL>break<EOL><DEDENT>elif parts[<NUM_LIT:0>] == path:<EOL><INDENT>result_parts.insert(<NUM_LIT:0>, parts[<NUM_LIT:0>])<EOL>break<EOL><DEDENT>else:<EOL><INDENT>path = parts[<NUM_LIT:0>]<EOL>result_parts.insert(<NUM_LIT:0>, parts[<NUM_LIT:1>])<EOL><DEDENT><DEDENT>return result_parts<EOL>

Helper method for absolute and relative paths resolution
Split passed path and return each directory parts

example: "/usr/share/dir"
return: ["usr", "share", "dir"]

@type path: one of (unicode, str)
@rtype: list


self.asset = asset<EOL>

Called before build

:type asset: static_bundle.builders.Asset


return u'<STR_LIT>'<EOL>

Called before minify
Returned text will be prepend on head

:rtype: unicode


text += self._read(f.abs_path) + "<STR_LIT:\r\n>"<EOL>return text<EOL>

Called for each file
Must return file content
Can be wrapped

:type f: static_bundle.files.StaticFileResult
:type text: str|unicode
:rtype: str|unicode


return text<EOL>

@type text: str|unicode
@rtype: str|unicode


if path is None:<EOL><INDENT>path = os.environ['<STR_LIT>']<EOL><DEDENT>paths = path.split(os.pathsep)<EOL>extlist = ['<STR_LIT>']<EOL>if os.name == '<STR_LIT>':<EOL><INDENT>ext = os.path.splitext(executable)<EOL>if not ext:<EOL><INDENT>executable = executable + "<STR_LIT>"<EOL><DEDENT><DEDENT>elif sys.platform == '<STR_LIT:win32>':<EOL><INDENT>pathext = os.environ['<STR_LIT>'].lower().split(os.pathsep)<EOL>ext = os.path.splitext(executable)<EOL>if ext not in pathext:<EOL><INDENT>extlist = pathext<EOL><DEDENT><DEDENT>for ext in extlist:<EOL><INDENT>execname = executable + ext<EOL>if os.path.isfile(execname):<EOL><INDENT>return execname<EOL><DEDENT>else:<EOL><INDENT>for pth in paths:<EOL><INDENT>fil = os.path.join(pth, execname)<EOL>if os.path.isfile(fil):<EOL><INDENT>return fil<EOL><DEDENT><DEDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT>

Try to find 'executable' in the directories listed in 'path' (a
    string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH']).


libs = os.listdir(path1)<EOL>for lib_dir in libs:<EOL><INDENT>if "<STR_LIT>" in lib_dir:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>

Return true if substring is in string for files
    in specified path


<EOL>if sys.platform == "<STR_LIT:win32>":<EOL><INDENT>dirs = sys.path<EOL>for ver in dirs:<EOL><INDENT>if os.path.isdir(ver):<EOL><INDENT>if find_x(ver):<EOL><INDENT>return True<EOL><DEDENT><DEDENT><DEDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>else:<EOL><INDENT>dirs = ['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>for path in dirs:<EOL><INDENT>if os.path.isdir(path):<EOL><INDENT>if find_x(path):<EOL><INDENT>return True<EOL><DEDENT><DEDENT><DEDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>


for executable in ("<STR_LIT>", "<STR_LIT>"):<EOL><INDENT>if find_executable(executable):<EOL><INDENT>return executable<EOL><DEDENT><DEDENT>raise Exception("<STR_LIT>")<EOL>


print("<STR_LIT>")<EOL>find_fann()<EOL>print("<STR_LIT>")<EOL>swig_bin = find_swig()<EOL>swig_cmd = [swig_bin, '<STR_LIT>', '<STR_LIT>', '<STR_LIT>']<EOL>subprocess.Popen(swig_cmd).wait()<EOL>


if level not in range(<NUM_LIT:0>,<NUM_LIT>):<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>b = int(floor(level / <NUM_LIT>)) <EOL>commands = list(darkest(group))<EOL>for i in range(<NUM_LIT:0>, b):<EOL><INDENT>commands.append(COMMANDS['<STR_LIT>'])<EOL><DEDENT>return tuple(commands)<EOL>


if light > <NUM_LIT>: <EOL><INDENT>return <NUM_LIT><EOL><DEDENT>elif light < <NUM_LIT>: <EOL><INDENT>return -<NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>hue = (-hue + <NUM_LIT:1> + <NUM_LIT>/<NUM_LIT>) % <NUM_LIT:1> <EOL>return int(floor(hue * <NUM_LIT>))<EOL><DEDENT>

Takes a hls color and converts to proper hue
        Bulbs use a BGR order instead of RGB


r = min(red, <NUM_LIT:255>)<EOL>g = min(green, <NUM_LIT:255>)<EOL>b = min(blue, <NUM_LIT:255>)<EOL>if r > <NUM_LIT:1> or g > <NUM_LIT:1> or b > <NUM_LIT:1>:<EOL><INDENT>r = r / <NUM_LIT><EOL>g = g / <NUM_LIT><EOL>b = b / <NUM_LIT><EOL><DEDENT>return color_from_hls(*rgb_to_hls(r,g,b))<EOL>

Takes your standard rgb color
        and converts it to a proper hue value


if "<STR_LIT:#>" in value:<EOL><INDENT>value = value[<NUM_LIT:1>:]<EOL><DEDENT>try:<EOL><INDENT>unhexed = bytes.fromhex(value)<EOL><DEDENT>except:<EOL><INDENT>unhexed = binascii.unhexlify(value) <EOL><DEDENT>return color_from_rgb(*struct.unpack('<STR_LIT>',unhexed))<EOL>

Takes an HTML hex code
        and converts it to a proper hue value


sec = max(sec, <NUM_LIT:0>)<EOL>reps = int(floor(sec / <NUM_LIT:0.1>))<EOL>commands = []<EOL>for i in range(<NUM_LIT:0>, reps):<EOL><INDENT>commands.append(Command(<NUM_LIT>, wait=True))<EOL><DEDENT>return tuple(commands)<EOL>

Wait for x seconds
            each wait command is 100ms


if level not in range(<NUM_LIT:0>,<NUM_LIT>):<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>b = int(floor(level / <NUM_LIT>) + <NUM_LIT:2>) <EOL>return (COMMANDS['<STR_LIT>'][group], Command(<NUM_LIT>, b))<EOL>


if level not in range(<NUM_LIT:0>,<NUM_LIT>):<EOL><INDENT>raise Exception("<STR_LIT>")<EOL><DEDENT>b = int(floor(level / <NUM_LIT>)) <EOL>commands = list(coolest(group))<EOL>for i in range(<NUM_LIT:0>, b):<EOL><INDENT>commands.append(COMMANDS['<STR_LIT>'])<EOL><DEDENT>return tuple(commands)<EOL>


@expected('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def pull_stream(self, uri, **kwargs):<DEDENT>

return self.protocol.execute('<STR_LIT>', uri=uri, **kwargs)<EOL>

This will try to pull in a stream from an external source. Once a
stream has been successfully pulled it is assigned a 'local stream
name' which can be used to access the stream from the EMS.

:param uri: The URI of the external stream. Can be RTMP, RTSP or
    unicast/multicast (d) mpegts
:type uri: str

:param keepAlive: If keepAlive is set to 1, the server will attempt to
    reestablish connection with a stream source after a connection has
    been lost. The reconnect will be attempted once every second
    (default: 1 true)
:type keepAlive: int

:param localStreamName: If provided, the stream will be given this
    name. Otherwise, a fallback techniques used to determine the stream
    name (based on the URI)
:type localStreamName: str

:param forceTcp: If 1 and if the stream is RTSP, a TCP connection will
    be forced. Otherwise the transport mechanism will be negotiated
    (UDP or TCP) (default: 1 true)
:type forceTcp: int

:param tcUrl: When specified, this value will be used to set the TC URL
    in the initial RTMP connect invoke
:type tcUrl: str

:param pageUrl: When specified, this value will be used to set the
    originating web page address in the initial RTMP connect invoke
:type pageUrl: str

:param swfUrl: When specified, this value will be used to set the
    originating swf URL in the initial RTMP connect invoke
:type swfUrl: str

:param rangeStart: For RTSP and RTMP connections. A value from which
    the playback should start expressed in seconds. There are 2 special
    values: -2 and -1. For more information, please read about
    start/len parameters here:
    http://livedocs.adobe.com/flashmediaserver/3.0/hpdocs/help.html?content=00000185.html
:type rangeStart: int

:param rangeEnd: The length in seconds for the playback. -1 is a
    special value. For more information, please read about start/len
    parameters here:
    http://livedocs.adobe.com/flashmediaserver/3.0/hpdocs/help.html?content=00000185.html
:type rangeEnd: int

:param ttl: Sets the IP_TTL (time to live) option on the socket
:type ttl: int

:param tos: Sets the IP_TOS (Type of Service) option on the socket
:type tos: int

:param rtcpDetectionInterval: How much time (in seconds) should the
    server wait for RTCP packets before declaring the RTSP stream as a
    RTCP-less stream
:type rtcpDetectionInterval: int

:param emulateUserAgent: When specified, this value will be used as the
    user agent string. It is meaningful only for RTMP
:type emulateUserAgent: str

:param isAudio: If 1 and if the stream is RTP, it indicates that the
    currently pulled stream is an audio source. Otherwise the pulled
    source is assumed as a video source
:type isAudio: int

:param audioCodecBytes: The audio codec setup of this RTP stream if it
    is audio. Represented as hex format without '0x' or 'h'. For
    example: audioCodecBytes=1190
:type audioCodecBytes: str

:param spsBytes: The video SPS bytes of this RTP stream if it is video.
    It should be base 64 encoded.
:type spsBytes: str

:param ppsBytes: The video PPS bytes of this RTP stream if it is video.
    It should be base 64 encoded
:type ppsBytes: str

:param ssmIp: The source IP from source-specific-multicast. Only usable
    when doing UDP based pull
:type ssmIp: str

:param httpProxy: This parameter has two valid values: IP:Port - This
    value combination specifies an RTSP HTTP Proxy from which the RTSP
    stream should be pulled from Self - Specifying "self" as the value
    implies pulling RTSP over HTTP
:type httpProxy: str

:link: http://docs.evostream.com/ems_api_definition/pullstream


@expected('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def push_stream(self, uri, **kwargs):<DEDENT>

Try to push a local stream to an external destination. The pushed
stream can only use the RTMP, RTSP or MPEG-TS unicast/multicast
protocol.

:param uri: The URI of the external stream. Can be RTMP, RTSP or
    unicast/multicast (d) mpegts
:type uri: str

:param keepAlive: If keepAlive is set to 1, the server will attempt to
    reestablish connection with a stream source after a connection has
    been lost. The reconnect will be attempted once every second
    (default: 1 true)
:type keepAlive: int

:param localStreamName: If provided, the stream will be given this
    name. Otherwise, a fallback techniques used to determine the stream
    name (based on the URI)
:type localStreamName: str

:param targetStreamName: The name of the stream at destination. If not
    provided, the target stream name willbe the same as the local
    stream name
:type targetStreamName: str

:param targetStreamType: It can be one of following: **live**,
    **record**, **append**. It is meaningful only for RTMP
:type targetStreamType: str

:param tcUrl: When specified, this value will be used to set the TC
    URL in the initial RTMP connect invoke
:type tcUrl: str

:param pageUrl: When specified, this value will be used to set the
    originating web page address in the initial RTMP connect invoke
:type pageUrl: str

:param swfUrl: When specified, this value will be used to set the
    originating swf URL in the initial RTMP connect invoke
:type swfUrl: str

:param ttl: Sets the IP_TTL (time to live) option on the socket
:type ttl: int

:param tos: Sets the IP_TOS (Type of Service) option on the socket
:type tos: int

:param emulateUserAgent: When specified, this value will be used as the
    user agent string. It is meaningful only for RTMP
:type emulateUserAgent: str

:param rtmpAbsoluteTimestamps: Forces the timestamps to be absolute
    when using RTMP.
:type rtmpAbsoluteTimestamps: int

:param sendChunkSizeRequest: Sets whether the RTMP stream will or will
    not send a "Set Chunk Length" message. This is significant when
    pushing to Akamai's new RTMP HD ingest point where this parameter
    should be set to 0 so that Akamai will not drop the connection.
:type sendChunkSizeRequest: int

:param useSourcePts: When value is true, timestamps on source inbound
    RTMP stream are passed directly to the outbound (pushed) RTMP
    streams. This affects only pushed Outbound Net RTMP with net RTMP
    source. This parameter overrides the value of the config.lua
    option of the same name.
:type useSourcePts: int

:link: http://docs.evostream.com/ems_api_definition/pushstream


@expected('<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def create_hls_stream(self, localStreamNames, targetFolder, **kwargs):<DEDENT>

return self.protocol.execute('<STR_LIT>',<EOL>localStreamNames=localStreamNames,<EOL>targetFolder=targetFolder, **kwargs)<EOL>

Create an HTTP Live Stream (HLS) out of an existing H.264/AAC stream.
HLS is used to stream live feeds to iOS devices such as iPhones and
iPads.

:param localStreamNames: The stream(s) that will be used as the input.
    This is a comma-delimited list of active stream names (local stream
    names).
:type localStreamNames: str

:param targetFolder: The folder where all the .ts/.m3u8 files will be
    stored. This folder must be accessible by the HLS clients. It is
    usually in the web-root of the server.
:type targetFolder: str

:param keepAlive: If true, the EMS will attempt to reconnect to the
    stream source if the connection is severed.
:type keepAlive: int

:param overwriteDestination: If true, it will force overwrite of
    destination files.
:type overwriteDestination: int

:param staleRetentionCount: The number of old files kept besides the
    ones listed in the current version of the playlist. Only
    applicable for rolling playlists.
:type staleRetentionCount: int

:param createMasterPlaylist: If true, a master playlist will be
    created.
:type createMasterPlaylist: int

:param cleanupDestination: If true, all *.ts and *.m3u8 files in the
    target folder will be removed before HLS creation is started.
:type cleanupDestination: int

:param bandwidths: The corresponding bandwidths for each stream listed
    in localStreamNames. Again, this can be a comma-delimited list.
:type bandwidths: int

:param groupName: The name assigned to the HLS stream or group. If the
    localStreamNames parameter contains only one entry and groupName
    is not specified, groupName will have the value of the input
    stream name.
:type groupName: str

:param playlistType: Either appending or rolling.
:type playlistType: str

:param playlistLength: The length (number of elements) of the playlist.
    Used only when playlistType is rolling. Ignored otherwise.
:type playlistLength: int

:param playlistName: The file name of the playlist (*.m3u8).
:type playlistName: str

:param chunkLength: The length (in seconds) of each playlist element
    (*.ts file). Minimum value is 1 (second).
:type chunkLength: int

:param maxChunkLength: Maximum length (in seconds) the EMS will allow
    any single chunk to be. This is primarily in the case of
    chunkOnIDR=true where the EMS will wait for the next key-frame. If
    the maxChunkLength is less than chunkLength, the parameter shall
    be ignored.
:type maxChunkLength: int

:param chunkBaseName: The base name used to generate the *.ts chunks.
:type chunkBaseName: str

:param chunkOnIDR: If true, chunking is performed ONLY on IDR.
    Otherwise, chunking is performed whenever chunk length is
    achieved.
:type chunkOnIDR: int

:param drmType: Type of DRM encryption to use. Options are: none
    (no encryption), evo (AES Encryption), SAMPLE-AES (Sample-AES),
    verimatrix (Verimatrix DRM). For Verimatrix DRM, the "drm" section
    of the config.lua file must be active and properly configured.
:type drmType: str

:param AESKeyCount: Number of keys that will be automatically generated
    and rotated over while encrypting this HLS stream.
:type AESKeyCount: int

:param audioOnly: If true, stream will be audio only.
:type audioOnly: int

:param hlsResume: If true, HLS will resume in appending segments to
    previously created child playlist even in cases of EMS shutdown or
    cut off stream source.
:type hlsResume: int

:param cleanupOnClose: If true, corresponding hls files to a stream
    will be deleted if the said stream is removed or shut down or
    disconnected.
:type cleanupOnClose: int

:param useByteRange: If true, will use the EXT-X-BYTERANGE feature of
    HLS (version 4 and up).
:type useByteRange: int

:param fileLength: When using useByteRange=1, this parameter needs to
    be set too. This will be the size of file before chunking it to
    another file, this replace the chunkLength in case of
    EXT-X-BYTERANGE, since chunkLength will be the byte range chunk.
:type fileLength: int

:param useSystemTime: If true, uses UTC in playlist time stamp
    otherwise will use the local server time.
:type useSystemTime: int

:param offsetTime:
:type offsetTime: int

:param startOffset: A parameter valid only for HLS v.6 onwards. This
    will indicate the start offset time (in seconds) for the playback
    of the playlist.
:type startOffset: int

:link: http://docs.evostream.com/ems_api_definition/createhlsstream


@expected('<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def create_hds_stream(self, localStreamNames, targetFolder, **kwargs):<DEDENT>

Create an HDS (HTTP Dynamic Streaming) stream out of an existing
H.264/AAC stream. HDS is used to stream standard MP4 media over
regular HTTP connections.

:param localStreamNames: The stream(s) that will be used as the input.
    This is a comma-delimited list of active stream names (local stream
    names).
:type localStreamNames: str

:param targetFolder: The folder where all the manifest (*.f4m) and
    fragment (f4v*) files will be stored. This folder must be
    accessible by the HDS clients. It is usually in the web-root of
    the server.
:type targetFolder: str

:param bandwidths: The corresponding bandwidths for each stream listed
    in localStreamNames. Again, this can be a comma-delimited list.
:type bandwidths: int

:param chunkBaseName: The base name used to generate the fragments.
:type chunkBaseName: str

:param chunkLength: The length (in seconds) of fragments to be made.
    Minimum value is 1 (second).
:type chunkLength: int

:param chunkOnIDR: If true, chunking is performed ONLY on IDR.
    Otherwise, chunking is performed whenever chunk length is
    achieved.
:type chunkOnIDR: int

:param groupName: The name assigned to the HDS stream or group. If the
    localStreamNames parameter contains only one entry and groupName
    is not specified, groupName will have the value of the input
    stream name.
:type groupName: str

:param keepAlive: If true, the EMS will attempt to reconnect to the
    stream source if the connection is severed.
:type keepAlive: int

:param manifestName: The manifest file name.
:type manifestName: str

:param overwriteDestination: If true, it will allow overwrite of
    destination files.
:type overwriteDestination: int

:param playlistType: Either appending or rolling.
:type playlistType: str

:param playlistLength: The number of fragments before the server
    starts to overwrite the older fragments. Used only when
    playlistType is "rolling". Ignored otherwise.
:type playlistLength: int

:param staleRetentionCount: The number of old files kept besides the
    ones listed in the current version of the playlist. Only
    applicable for rolling playlists.
:type staleRetentionCount: int

:param createMasterPlaylist: If true, a master playlist will be
    created.
:type createMasterPlaylist: int

:param cleanupDestination: If true, all manifest and fragment files in
    the target folder will be removed before HDS creation is started.
:type cleanupDestination: int

:link: http://docs.evostream.com/ems_api_definition/createhdsstream


@expected('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def create_mss_stream(self, localStreamNames, targetFolder, **kwargs):<DEDENT>

Create a Microsoft Smooth Stream (MSS) out of an existing H.264/AAC
stream. Smooth Streaming was developed by Microsoft to compete with
other adaptive streaming technologies.

:param localStreamNames: The stream(s) that will be used as the input.
    This is a comma-delimited list of active stream names (local
    stream names)
:type localStreamNames: str

:param targetFolder: The folder where all the manifest and fragment
    files will be stored. This folder must be accessible by the MSS
    clients. It is usually in the web-root of the server.
:type targetFolder: str

:param bandwidths: The corresponding bandwidths for each stream listed
    in `localStreamNames`. Again, this can be a comma-delimited list.
:type bandwidths: int or str

:param groupName: The name assigned to the MSS stream or group. If the
    `localStreamNames` parameter contains only one entry and groupName
    is not specified, groupName will have the value of the input
    stream name.
:type groupName: str

:param playlistType: Either `appending` or `rolling`
:type playlistType: str

:param playlistLength: The number of fragments before the server
    starts to overwrite the older fragments. Used only when
    `playlistType` is `rolling`. Ignored otherwise.
:type playlistLength: int

:param manifestName: The manifest file name.
:type manifestName: str

:param chunkLength: The length (in seconds) of fragments to be made.
:type chunkLength: int

:param chunkOnIDR: If 1 (true), chunking is performed ONLY on IDR.
    Otherwise, chunking is performed whenever chunk length is
    achieved.
:type chunkOnIDR: int

:param keepAlive: If 1 (true), the EMS will attempt to reconnect to
    the stream source if the connection is severed.
:type keepAlive: int

:param overwriteDestination: If 1 (true), it will allow overwrite of
    destination files.
:type overwriteDestination: int

:param staleRetentionCount: How many old files are kept besides the
    ones present in the current version of the playlist. Only
    applicable for rolling playlists.
:type staleRetentionCount: int

:param cleanupDestination: If 1 (true), all manifest and fragment
    files in the target folder will be removed before MSS creation is
    started.
:type cleanupDestination: int

:param ismType: Either ismc for serving content to client or isml for
    serving content to smooth server.
:type ismType: int

:param isLive: If true, creates a live MSS stream, otherwise set to 0
    for VOD.
:type isLive: int

:param publishingPoint: This parameter is needed when `ismType=isml`,
    it is the REST URI where the mss contents will be ingested.
:type publishingPoint: str

:param ingestMode: Either `single` for a non looping ingest or `loop`
    for looping an ingest.
:type ingestMode: str

:link: http://docs.evostream.com/ems_api_definition/createmssstream


@expected('<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def create_dash_stream(self, localStreamNames, targetFolder, **kwargs):<DEDENT>

Create Dynamic Adaptive Streaming over HTTP (DASH) out of an existing
H.264/AAC stream. DASH was developed by the Moving Picture Experts
Group (MPEG) to establish a standard for HTTP adaptive-bitrate
streaming that would be accepted by multiple vendors and facilitate
interoperability.

:param localStreamNames: The stream(s) that will be used as the
    input. This is a comma-delimited list of active stream names
    (local stream names).
:type localStreamNames: str

:param targetFolder: The folder where all the manifest and fragment
    files will be stored. This folder must be accessible by the DASH
    clients. It is usually in the web-root of the server.
:type targetFolder: str

:param bandwidths: The corresponding bandwidths for each stream listed
    in `localStreamNames`. Again, this can be a comma-delimited list.
:type bandwidths: int or str

:param groupName: The name assigned to the DASH stream or group. If
    the `localStreamNames` parameter contains only one entry and
    `groupName` is not specified, `groupName` will have the value of
    the input stream name.
:type groupName: str

:param playlistType: Either `appending` or `rolling`.
:type playlistType: str

:param playlistLength: The number of fragments before the server
    starts to overwrite the older fragments. Used only when
    `playlistType` is `rolling`. Ignored otherwise.
:type playlistLength: int

:param manifestName: The manifest file name.
:type manifestName: str

:param chunkLength: The length (in seconds) of fragments to be made.
:type chunkLength: int

:param chunkOnIDR: If true, chunking is performed ONLY on IDR.
    Otherwise, chunking is performed whenever chunk length is
    achieved.
:type chunkOnIDR: int

:param keepAlive: If true, the EMS will attempt to reconnect to the
    stream source if the connection is severed.
:type keepAlive: int

:param overwriteDestination: If true, it will allow overwrite of
    destination files.
:type overwriteDestination: int

:param staleRetentionCount: How many old files are kept besides the
    ones present in the current version of the playlist. Only
    applicable for rolling playlists.
:type staleRetentionCount: int

:param cleanupDestination: If true, all manifest and fragment files in
    the target folder will be removed before DASH creation is started.
:type cleanupDestination: int

:param dynamicProfile: Set this parameter to 1 (default) for a live
    DASH, otherwise set it to 0 for a VOD.
:type dynamicProfile: int

:link: http://docs.evostream.com/ems_api_definition/createdashstream


@expected('<STR_LIT>', '<STR_LIT>', '<STR_LIT:type>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>')<EOL><INDENT>def record(self, localStreamName, pathToFile, **kwargs):<DEDENT>

return self.protocol.execute('<STR_LIT>',<EOL>localStreamName=localStreamName,<EOL>pathToFile=pathToFile, **kwargs)<EOL>

Records any inbound stream. The record command allows users to record
a stream that may not yet exist. When a new stream is brought into
the server, it is checked against a list of streams to be recorded.

Streams can be recorded as FLV files, MPEG-TS files or as MP4 files.

:param localStreamName: The name of the stream to be used as input
    for recording.
:type localStreamName: str

:param pathToFile: Specify path and file name to write to.
:type pathToFile: str

:param type: `ts`, `mp4` or `flv`
:type type: str

:param overwrite: If false, when a file already exists for the stream
    name, a new file will be created with the next appropriate number
    appended. If 1 (true), files with the same name will be
    overwritten.
:type overwrite: int

:param keepAlive: If 1 (true), the server will restart recording every
    time the stream becomes available again.
:type keepAlive: int

:param chunkLength: If non-zero the record command will start a new
    recording file after ChunkLength seconds have elapsed.
:type chunkLength: int

:param waitForIDR: This is used if the recording is being chunked.
    When true, new files will only be created on IDR boundaries.
:type waitForIDR: int

:param winQtCompat: Mandates 32bit header fields to ensure
    compatibility with Windows QuickTime.
:type winQtCompat: int

:param dateFolderStructure: If set to 1 (true), folders will be
    created with names in `YYYYMMDD` format. Recorded files will be
    placed inside these folders based on the date they were created.
:type dateFolderStructure: int

:link: http://docs.evostream.com/ems_api_definition/record


@expected('<STR_LIT:source>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>', '<STR_LIT>',<EOL>'<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def transcode(self, source, destinations, **kwargs):<DEDENT>

return self.protocol.execute('<STR_LIT>', source=source,<EOL>destinations=destinations, **kwargs)<EOL>

Changes the compression characteristics of an audio and/or video
stream. Allows you to change the resolution of a source stream, change
the bitrate of a stream, change a VP8 or MPEG2 stream into H.264 and
much more. Allow users to create overlays on the final stream as well
as crop streams.

:param source: Can be a URI or a local stream name from EMS.
:type source: str

:param destinations: The target URI(s) or stream name(s) of the
    transcoded stream. If only a name is given, it will be pushed
    back to the EMS.
:type destinations: str

:param targetStreamNames: The name of the stream(s) at destination(s).
    If not specified, and a full URI is provided to destinations,
    name will have a time stamped value.
:type targetStreamNames: str

:param groupName: The group name assigned to this process. If not
    specified, groupName will have a random value.
:type groupName: str

:param videoBitrates: Target output video bitrate(s) (in bits/s,
    append `k` to value for kbits/s). Accepts the value `copy` to
    copy the input bitrate. An empty value passed would mean no video.
:type videoBitrates: str

:param videoSizes: Target output video size(s) in wxh (width x height)
    format. IE: 240x480.
:type videoSizes: str

:param videoAdvancedParamsProfiles: Name of video profile template
    that will be used.
:type videoAdvancedParamsProfiles: str

:param audioBitrates: Target output audio bitrate(s) (in bits/s,
    append `k` to value for kbits/s). Accepts the value `copy` to
    copy the input bitrate. An empty value passed would mean no audio.
:type audioBitrates: str

:param audioChannelsCounts: Target output audio channel(s) count(s).
    Valid values are 1 (mono), 2 (stereo), and so on. Actual supported
    channel count is dependent on the number of input audio channels.
:type audioChannelsCounts: str

:param audioFrequencies: Target output audio frequency(ies) (in Hz,
    append `k` to value for kHz).
:type audioFrequencies: str

:param audioAdvancedParamsProfiles: Name of audio profile template
    that will be used.
:type audioAdvancedParamsProfiles: str

:param overlays: Location of the overlay source(s) to be used. These
    are transparent images (normally in PNG format) that have the same
    or smaller size than the video. Image is placed at the top-left
    position of the video.
:type overlays: str

:param croppings: Target video cropping position(s) and size(s) in
    `left : top : width : height` format (e.g. 0:0:200:100. Positions
    are optional (200:100 for a centered cropping of 200 width and 100
    height in pixels). Values are limited to the actual size of the
    video.
:type croppings: str

:param keepAlive: If keepAlive is set to 1, the server will restart
    transcoding if it was previously activated.
:type keepAlive: int

:param commandFlags: Other commands to the transcode process that are
    not supported by the baseline transcode command.
:type commandFlags: str

:link: http://docs.evostream.com/ems_api_definition/transcode


return self.protocol.execute('<STR_LIT>')<EOL>

Get a list of IDs for every active stream.

:link: http://docs.evostream.com/ems_api_definition/liststreamsids


@expected('<STR_LIT:id>', '<STR_LIT>')<EOL><INDENT>def get_stream_info(self, **kwargs):<DEDENT>

return self.protocol.execute('<STR_LIT>', **kwargs)<EOL>

Returns a detailed set of information about a stream.

:param id: The uniqueId of the stream. Usually a value returned by
    listStreamsIDs. This parameter is not mandatory but either this or
    the localStreamName should be present to identify the particular
    stream
:type id: int

:param localStreamName: The name of the stream. This parameter is not
    mandatory but either this or the id should be present to identify
    the particular stream
:type localStreamName: str

:link: http://docs.evostream.com/ems_api_definition/getstreaminfo


Provides a detailed description of all active streams.

:param disableInternalStreams: If this is 1 (true), internal streams
    (origin-edge related) are filtered out from the list
:type disableInternalStreams: int

:link: http://docs.evostream.com/ems_api_definition/liststreams


Returns the number of active streams.

:link: http://docs.evostream.com/ems_api_definition/getstreamscount


@expected('<STR_LIT:id>', '<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def shutdown_stream(self, **kwargs):<DEDENT>

Terminates a specific stream. When permanently=1 is used, this command
is analogous to removeConfig.

:param id: The uniqueId of the stream that needs to be terminated. The
    stream ID's can be obtained using the listStreams command. This
    parameter is not mandatory but either this or localStreamName
    should be present to identify the particular stream
:type id: int

:param localStreamName: The name of the inbound stream which you wish
    to terminate. This will also terminate any outbound streams that
    are dependent upon this input stream. This parameter is not
    mandatory but either this or the id should be present to identify
    the particular stream
:type localStreamName: str

:param permanently: If true, the corresponding push/pull configuration
    will also be terminated. Therefore, the stream will NOT be
    reconnected when the server restarts
:type permanently: int

:link: http://docs.evostream.com/ems_api_definition/shutdownstream


Returns a list with all push/pull configurations.

Whenever the pullStream or pushStream interfaces are called, a record
containing the details of the pull or push is created in the
pullpushconfig.xml file. Then, the next time the EMS is started, the
pullpushconfig.xml file is read, and the EMS attempts to reconnect all
of the previous pulled or pushed streams.

:link: http://docs.evostream.com/ems_api_definition/listconfig


@expected('<STR_LIT:id>', '<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def remove_config(self, **kwargs):<DEDENT>

This command will both stop the stream and remove the corresponding
configuration entry. This command is the same as performing
shutdownStream permanently=1.

:param id: The configId of the configuration that needs to be removed.
    ConfigId's can be obtained from the listConfig interface.
    Removing an inbound stream will also automatically remove all
    associated outbound streams.
:type id: int

:param groupName: The name of the group that needs to be removed
    (applicable to HLS, HDS and external processes). Mandatory only if
    the id parameter is not specified.
:type groupName: str

:param removeHlsHdsFiles: If 1 (true) and the stream is HLS or HDS, the
    folder associated with it will be removed
:type removeHlsHdsFiles: int

:link: http://docs.evostream.com/ems_api_definition/removeconfig


@expected('<STR_LIT:id>', )<EOL><INDENT>def get_config_info(self, id):<DEDENT>

return self.protocol.execute('<STR_LIT>', id=id)<EOL>

Returns the information of the stream by the configId.

:param id: The configId of the configuration to get some information
:type id: int

:link: http://docs.evostream.com/ems_api_definition/getconfiginfo


@expected('<STR_LIT:id>', '<STR_LIT>')<EOL><INDENT>def is_stream_running(self, **kwargs):<DEDENT>

Checks a specific stream if it is running or not.

:param id: The unique id of the stream to check.
:type id: int

:param localStreamName: The name of the stream to check.
:type localStreamName: str

:link: http://docs.evostream.com/ems_api_definition/isstreamrunning


@expected('<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def add_stream_alias(self, localStreamName, aliasName, **kwargs):<DEDENT>

return self.protocol.execute('<STR_LIT>',<EOL>localStreamName=localStreamName,<EOL>aliasName=aliasName, **kwargs)<EOL>

Allows you to create secondary name(s) for internal streams. Once an
alias is created the localstreamname cannot be used to request
playback of that stream. Once an alias is used (requested by a client)
the alias is removed. Aliases are designed to be used to protect/hide
your source streams.

:param localStreamName: The original stream name
:type localStreamName: str

:param aliasName: The alias alternative to the localStreamName
:type aliasName: str

:param expirePeriod: The expiration period for this alias. Negative
    values will be treated as one-shot but no longer than the absolute
    positive value in seconds, 0 means it will not expire, positive
    values mean the alias can be used multiple times but expires after
    this many seconds. The default is -600 (one-shot, 10 mins)
:type expirePeriod: int

:link: http://docs.evostream.com/ems_api_definition/addstreamalias


Returns a complete list of aliases.

:link: http://docs.evostream.com/ems_api_definition/liststreamaliases


@expected('<STR_LIT>', )<EOL><INDENT>def remove_stream_alias(self, aliasName):<DEDENT>

return self.protocol.execute('<STR_LIT>', aliasName=aliasName)<EOL>

Removes an alias of a stream.

:param aliasName: The alias to delete
:type aliasName: str

:link: http://docs.evostream.com/ems_api_definition/removestreamalias


Invalidates all streams aliases.

:link: http://docs.evostream.com/ems_api_definition/flushstreamaliases


@expected('<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def add_group_name_alias(self, groupName, aliasName):<DEDENT>

return self.protocol.execute('<STR_LIT>', groupName=groupName,<EOL>aliasName=aliasName)<EOL>

Creates secondary name(s) for group names. Once an alias is created the
group name cannot be used to request HTTP playback of that stream. Once
an alias is used (requested by a client) the alias is removed. Aliases
are designed to be used to protect/hide your source streams.

:param groupName: The original group name
:type groupName: str

:param aliasName: The alias alternative to the group name
:type aliasName: str

:link: http://docs.evostream.com/ems_api_definition/addgroupnamealias


Invalidates all group name aliases.

:link: http://docs.evostream.com/ems_api_definition/flushgroupnamealiases


return self.protocol.execute('<STR_LIT>',<EOL>aliasName=aliasName)<EOL>

Returns the group name given the alias name.

:param aliasName: The group name alias
:type aliasName: str

:link: http://docs.evostream.com/ems_api_definition/getgroupnamebyalias


Returns a complete list of group name aliases.

:link: http://docs.evostream.com/ems_api_definition/listgroupnamealiases


Removes an alias of a group.

:param aliasName: The alias alternative to be removed from the group
    name.
:type aliasName: str

:link: http://docs.evostream.com/ems_api_definition/removegroupnamealiases


Lists all currently active HTTP streaming sessions.

:link: http://docs.evostream.com/ems_api_definition/listhttpstreamingsessions


@expected('<STR_LIT>', '<STR_LIT>')<EOL><INDENT>def create_ingest_point(self, privateStreamName, publicStreamName):<DEDENT>

return self.protocol.execute('<STR_LIT>',<EOL>privateStreamName=privateStreamName,<EOL>publicStreamName=publicStreamName)<EOL>

Creates an RTMP ingest point, which mandates that streams pushed into
the EMS have a target stream name which matches one Ingest Point
privateStreamName.

:param privateStreamName: The name that RTMP Target Stream Names must
    match.
:type privateStreamName: str

:param publicStreamName: The name that is used to access the stream
    pushed to the privateStreamName. The publicStreamName becomes the
    streams localStreamName.
:type publicStreamName: str

:link: http://docs.evostream.com/ems_api_definition/createingestpoint


return self.protocol.execute('<STR_LIT>',<EOL>privateStreamName=privateStreamName)<EOL>

Removes an RTMP ingest point.

:param privateStreamName: The Ingest Point is identified by the
    privateStreamName, so only that is required to delete it.
:type privateStreamName: str

:link: http://docs.evostream.com/ems_api_definition/removeingestpoint


Lists the currently available Ingest Points.

:link: http://docs.evostream.com/ems_api_definition/listingestpoints


def start_web_rtc(self, ersip, ersport, roomId):

return self.protocol.execute('<STR_LIT>', ersip=ersip, ersport=ersport,<EOL>roomId=roomId)<EOL>

Starts a WebRTC signalling client to an ERS (Evostream Rendezvous
Server).

:param ersip: IP address (xx.yy.zz.xx) of ERS.
:type ersip: str

:param ersport: IP port of ERS.
:type ersport: int

:param roomId: Unique room Identifier within ERS that will be used by
    client browsers to connect to this EMS.
:type roomId: str

:link: http://docs.evostream.com/ems_api_definition/startwebrtc


mod_name, cls_name = class_path.rsplit('<STR_LIT:.>', <NUM_LIT:1>)<EOL>try:<EOL><INDENT>mod = import_module(mod_name)<EOL><DEDENT>except ImportError as ex:<EOL><INDENT>raise EvoStreamException('<STR_LIT>'<EOL>'<STR_LIT>' % (mod_name, ex))<EOL><DEDENT>return getattr(mod, cls_name)<EOL>

imports and returns module class from ``path.to.module.Class``
argument


b, j = -<NUM_LIT:1>, <NUM_LIT:0><EOL>if num_buckets < <NUM_LIT:1>:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>while j < num_buckets:<EOL><INDENT>b = int(j)<EOL>key = ((key * long(<NUM_LIT>)) + <NUM_LIT:1>) & <NUM_LIT><EOL>j = float(b + <NUM_LIT:1>) * (float(<NUM_LIT:1> << <NUM_LIT>) / float((key >> <NUM_LIT>) + <NUM_LIT:1>))<EOL><DEDENT>return int(b)<EOL>

Generate a number in the range [0, num_buckets).

    Args:
        key (int): The key to hash.
        num_buckets (int): Number of buckets to use.

    Returns:
        The bucket number `key` computes to.

    Raises:
        ValueError: If `num_buckets` is not a positive number.


batch, channels, height, width = x.size()<EOL>channels_per_group = channels // groups<EOL>x = x.view(batch, groups, channels_per_group, height, width)<EOL>x = torch.transpose(x, <NUM_LIT:1>, <NUM_LIT:2>).contiguous()<EOL>x = x.view(batch, channels, height, width)<EOL>return x<EOL>

Channel Shuffle operation from ShuffleNet [arxiv: 1707.01083]
    Arguments:
        x (Tensor): tensor to shuffle.
        groups (int): groups to be split


init_block_channels = <NUM_LIT:64><EOL>final_block_channels = <NUM_LIT><EOL>channels_per_layers = [<NUM_LIT:32>, <NUM_LIT:64>, <NUM_LIT>, <NUM_LIT>]<EOL>if version == '<STR_LIT>':<EOL><INDENT>layers = [<NUM_LIT:6>, <NUM_LIT:6>, <NUM_LIT:8>, <NUM_LIT:1>]<EOL><DEDENT>elif version == '<STR_LIT>':<EOL><INDENT>layers = [<NUM_LIT:2>, <NUM_LIT:4>, <NUM_LIT>, <NUM_LIT:1>]<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>".format(version))<EOL><DEDENT>channels = [[ci] * li for (ci, li) in zip(channels_per_layers, layers)]<EOL>if width_scale != <NUM_LIT:1>:<EOL><INDENT>channels = [[int(cij * width_scale) for cij in ci] for ci in channels]<EOL>init_block_channels = int(init_block_channels * width_scale)<EOL>final_block_channels = int(final_block_channels * width_scale)<EOL><DEDENT>net = SqueezeNext(<EOL>channels=channels,<EOL>init_block_channels=init_block_channels,<EOL>final_block_channels=final_block_channels,<EOL>**kwargs)<EOL>if pretrained:<EOL><INDENT>if (model_name is None) or (not model_name):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>import torch<EOL>from .model_store import get_model_file<EOL>net.load_state_dict(torch.load(get_model_file(<EOL>model_name=model_name,<EOL>local_model_store_dir_path=root)))<EOL><DEDENT>return net<EOL>

Create SqueezeNext model with specific parameters.

Parameters:
----------
version : str
    Version of SqueezeNet ('23' or '23v5').
width_scale : float
    Scale factor for width of layers.
model_name : str or None, default None
    Model name for loading pretrained model.
pretrained : bool, default False
    Whether to load the pretrained weights for model.
ctx : Context, default CPU
    The context in which to load the pretrained weights.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_squeezenext(version="<STR_LIT>", width_scale=<NUM_LIT:1.0>, model_name="<STR_LIT>", **kwargs)<EOL>

1.0-SqNxt-23 model from 'SqueezeNext: Hardware-Aware Neural Network Design,' https://arxiv.org/abs/1803.10615.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_squeezenext(version="<STR_LIT>", width_scale=<NUM_LIT>, model_name="<STR_LIT>", **kwargs)<EOL>

0.75-SqNxt-23 model from 'SqueezeNext: Hardware-Aware Neural Network Design,' https://arxiv.org/abs/1803.10615.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


0.5-SqNxt-23 model from 'SqueezeNext: Hardware-Aware Neural Network Design,' https://arxiv.org/abs/1803.10615.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


1.0-SqNxt-23v5 model from 'SqueezeNext: Hardware-Aware Neural Network Design,' https://arxiv.org/abs/1803.10615.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


0.75-SqNxt-23v5 model from 'SqueezeNext: Hardware-Aware Neural Network Design,' https://arxiv.org/abs/1803.10615.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


0.5-SqNxt-23v5 model from 'SqueezeNext: Hardware-Aware Neural Network Design,' https://arxiv.org/abs/1803.10615.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


model = ResNet(SEBasicBlock, [<NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:2>], num_classes=num_classes)<EOL>model.avgpool = nn.AdaptiveAvgPool2d(<NUM_LIT:1>)<EOL>return model<EOL>

Constructs a ResNet-18 model.

    Args:
        pretrained (bool): If True, returns a model pre-trained on ImageNet


model = ResNet(SEBasicBlock, [<NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:6>, <NUM_LIT:3>], num_classes=num_classes)<EOL>model.avgpool = nn.AdaptiveAvgPool2d(<NUM_LIT:1>)<EOL>return model<EOL>

Constructs a ResNet-34 model.

    Args:
        pretrained (bool): If True, returns a model pre-trained on ImageNet


model = ResNet(SEBottleneck, [<NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:6>, <NUM_LIT:3>], num_classes=num_classes)<EOL>model.avgpool = nn.AdaptiveAvgPool2d(<NUM_LIT:1>)<EOL>return model<EOL>

Constructs a ResNet-50 model.

    Args:
        pretrained (bool): If True, returns a model pre-trained on ImageNet


model = ResNet(SEBottleneck, [<NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT>, <NUM_LIT:3>], num_classes=num_classes)<EOL>model.avgpool = nn.AdaptiveAvgPool2d(<NUM_LIT:1>)<EOL>return model<EOL>

Constructs a ResNet-101 model.

    Args:
        pretrained (bool): If True, returns a model pre-trained on ImageNet


model = ResNet(SEBottleneck, [<NUM_LIT:3>, <NUM_LIT:8>, <NUM_LIT>, <NUM_LIT:3>], num_classes=num_classes)<EOL>model.avgpool = nn.AdaptiveAvgPool2d(<NUM_LIT:1>)<EOL>return model<EOL>

Constructs a ResNet-152 model.

    Args:
        pretrained (bool): If True, returns a model pre-trained on ImageNet


return nn.Conv2d(<EOL>in_channels=in_channels,<EOL>out_channels=out_channels,<EOL>kernel_size=<NUM_LIT:1>,<EOL>stride=stride,<EOL>padding=<NUM_LIT:0>,<EOL>bias=False)<EOL>

Convolution 1x1 layer.

Parameters:
----------
in_channels : int
    Number of input channels.
out_channels : int
    Number of output channels.
stride : int or tuple/list of 2 int
    Strides of the convolution.


return PreResConv(<EOL>in_channels=in_channels,<EOL>out_channels=out_channels,<EOL>kernel_size=<NUM_LIT:1>,<EOL>stride=stride,<EOL>padding=<NUM_LIT:0>)<EOL>

1x1 version of the PreResNet specific convolution block.

Parameters:
----------
in_channels : int
    Number of input channels.
out_channels : int
    Number of output channels.
stride : int or tuple/list of 2 int
    Strides of the convolution.


return PreResConv(<EOL>in_channels=in_channels,<EOL>out_channels=out_channels,<EOL>kernel_size=<NUM_LIT:3>,<EOL>stride=stride,<EOL>padding=<NUM_LIT:1>)<EOL>

3x3 version of the PreResNet specific convolution block.

Parameters:
----------
in_channels : int
    Number of input channels.
out_channels : int
    Number of output channels.
stride : int or tuple/list of 2 int
    Strides of the convolution.
bn_use_global_stats : bool
    Whether global moving statistics is used instead of local batch-norm for BatchNorm layers.


if blocks == <NUM_LIT:10>:<EOL><INDENT>layers = [<NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>]<EOL><DEDENT>elif blocks == <NUM_LIT:12>:<EOL><INDENT>layers = [<NUM_LIT:2>, <NUM_LIT:1>, <NUM_LIT:1>, <NUM_LIT:1>]<EOL><DEDENT>elif blocks == <NUM_LIT>:<EOL><INDENT>layers = [<NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:1>, <NUM_LIT:1>]<EOL><DEDENT>elif blocks == <NUM_LIT:16>:<EOL><INDENT>layers = [<NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:1>]<EOL><DEDENT>elif blocks == <NUM_LIT>:<EOL><INDENT>layers = [<NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:2>, <NUM_LIT:2>]<EOL><DEDENT>elif blocks == <NUM_LIT>:<EOL><INDENT>layers = [<NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:6>, <NUM_LIT:3>]<EOL><DEDENT>elif blocks == <NUM_LIT:50>:<EOL><INDENT>layers = [<NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT:6>, <NUM_LIT:3>]<EOL><DEDENT>elif blocks == <NUM_LIT>:<EOL><INDENT>layers = [<NUM_LIT:3>, <NUM_LIT:4>, <NUM_LIT>, <NUM_LIT:3>]<EOL><DEDENT>elif blocks == <NUM_LIT>:<EOL><INDENT>layers = [<NUM_LIT:3>, <NUM_LIT:8>, <NUM_LIT>, <NUM_LIT:3>]<EOL><DEDENT>elif blocks == <NUM_LIT:200>:<EOL><INDENT>layers = [<NUM_LIT:3>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT:3>]<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>".format(blocks))<EOL><DEDENT>init_block_channels = <NUM_LIT:64><EOL>if blocks < <NUM_LIT:50>:<EOL><INDENT>channels_per_layers = [<NUM_LIT:64>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>bottleneck = False<EOL><DEDENT>else:<EOL><INDENT>channels_per_layers = [<NUM_LIT>, <NUM_LIT>, <NUM_LIT>, <NUM_LIT>]<EOL>bottleneck = True<EOL><DEDENT>channels = [[ci] * li for (ci, li) in zip(channels_per_layers, layers)]<EOL>if width_scale != <NUM_LIT:1.0>:<EOL><INDENT>channels = [[int(cij * width_scale) for cij in ci] for ci in channels]<EOL>init_block_channels = int(init_block_channels * width_scale)<EOL><DEDENT>net = PreResNet(<EOL>channels=channels,<EOL>init_block_channels=init_block_channels,<EOL>bottleneck=bottleneck,<EOL>conv1_stride=conv1_stride,<EOL>**kwargs)<EOL>if pretrained:<EOL><INDENT>if (model_name is None) or (not model_name):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>import torch<EOL>from .model_store import get_model_file<EOL>net.load_state_dict(torch.load(get_model_file(<EOL>model_name=model_name,<EOL>local_model_store_dir_path=root)))<EOL><DEDENT>return net<EOL>

Create PreResNet model with specific parameters.

Parameters:
----------
blocks : int
    Number of blocks.
conv1_stride : bool
    Whether to use stride in the first or the second convolution layer in units.
width_scale : float
    Scale factor for width of layers.
model_name : str or None, default None
    Model name for loading pretrained model.
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT:10>, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-10 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.
It's an experimental model.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT:12>, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-12 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.
It's an experimental model.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT>, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-14 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.
It's an experimental model.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT:16>, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-16 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.
It's an experimental model.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT>, width_scale=<NUM_LIT>, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-18 model with 0.25 width scale from 'Identity Mappings in Deep Residual Networks,'
https://arxiv.org/abs/1603.05027. It's an experimental model.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT>, width_scale=<NUM_LIT:0.5>, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-18 model with 0.5 width scale from 'Identity Mappings in Deep Residual Networks,'
https://arxiv.org/abs/1603.05027. It's an experimental model.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


PreResNet-18 model with 0.75 width scale from 'Identity Mappings in Deep Residual Networks,'
https://arxiv.org/abs/1603.05027. It's an experimental model.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


PreResNet-18 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


PreResNet-34 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT:50>, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-50 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT:50>, conv1_stride=False, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-50 model with stride at the second convolution in bottleneck block from 'Identity Mappings in Deep
Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


PreResNet-101 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT>, conv1_stride=False, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-101 model with stride at the second convolution in bottleneck block from 'Identity Mappings in Deep
Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


PreResNet-152 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


PreResNet-152 model with stride at the second convolution in bottleneck block from 'Identity Mappings in Deep
Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT:200>, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-200 model from 'Identity Mappings in Deep Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


return get_preresnet(blocks=<NUM_LIT:200>, conv1_stride=False, model_name="<STR_LIT>", **kwargs)<EOL>

PreResNet-200 model with stride at the second convolution in bottleneck block from 'Identity Mappings in Deep
Residual Networks,' https://arxiv.org/abs/1603.05027.

Parameters:
----------
pretrained : bool, default False
    Whether to load the pretrained weights for model.
root : str, default '~/.torch/models'
    Location for keeping the model parameters.


def convert_batchnorm(params, w_name, scope_name, inputs, layers, weights, names):

print('<STR_LIT>')<EOL>if names == '<STR_LIT>':<EOL><INDENT>tf_name = '<STR_LIT>' + random_string(<NUM_LIT:6>)<EOL><DEDENT>elif names == '<STR_LIT>':<EOL><INDENT>tf_name = w_name<EOL><DEDENT>else:<EOL><INDENT>tf_name = w_name + str(random.random())<EOL><DEDENT>bias_name = '<STR_LIT>'.format(w_name)<EOL>weights_name = '<STR_LIT>'.format(w_name)<EOL>mean_name = '<STR_LIT>'.format(w_name)<EOL>var_name = '<STR_LIT>'.format(w_name)<EOL>if bias_name in weights:<EOL><INDENT>beta = weights[bias_name].numpy()<EOL><DEDENT>if weights_name in weights:<EOL><INDENT>gamma = weights[weights_name].numpy()<EOL><DEDENT>mean = weights[mean_name].numpy()<EOL>variance = weights[var_name].numpy()<EOL>eps = params['<STR_LIT>']<EOL>momentum = params['<STR_LIT>']<EOL>if weights_name not in weights:<EOL><INDENT>bn = keras.layers.BatchNormalization(<EOL>axis=<NUM_LIT:1>, momentum=momentum, epsilon=eps,<EOL>center=False, scale=False,<EOL>weights=[mean, variance],<EOL>name=tf_name<EOL>)<EOL><DEDENT>else:<EOL><INDENT>bn = keras.layers.BatchNormalization(<EOL>axis=<NUM_LIT:1>, momentum=momentum, epsilon=eps,<EOL>weights=[gamma, beta, mean, variance],<EOL>name=tf_name<EOL>)<EOL><DEDENT>layers[scope_name] = bn(layers[inputs[<NUM_LIT:0>]])<EOL>

Convert batch normalization layer.

Args:
    params: dictionary with layer parameters
    w_name: name prefix in state_dict
    scope_name: pytorch scope name
    inputs: pytorch node inputs
    layers: dictionary with keras tensors
    weights: pytorch state_dict
    names: use short names for keras layers


def convert_instancenorm(params, w_name, scope_name, inputs, layers, weights, names):

print('<STR_LIT>')<EOL>if names == '<STR_LIT>':<EOL><INDENT>tf_name = '<STR_LIT>' + random_string(<NUM_LIT:6>)<EOL><DEDENT>elif names == '<STR_LIT>':<EOL><INDENT>tf_name = w_name<EOL><DEDENT>else:<EOL><INDENT>tf_name = w_name + str(random.random())<EOL><DEDENT>assert(len(inputs) == <NUM_LIT:3>)<EOL>bias_name = '<STR_LIT>'.format(w_name)<EOL>weights_name = '<STR_LIT>'.format(w_name)<EOL>if inputs[-<NUM_LIT:2>] + '<STR_LIT>' in layers:<EOL><INDENT>gamma = layers[inputs[-<NUM_LIT:2>] + '<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>gamma = weights[weights_name].numpy()<EOL><DEDENT>if inputs[-<NUM_LIT:1>] + '<STR_LIT>' in layers:<EOL><INDENT>beta = layers[inputs[-<NUM_LIT:1>] + '<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>beta = weights[bias_name].numpy()<EOL><DEDENT>def target_layer(x, epsilon=params['<STR_LIT>'], gamma=gamma, beta=beta):<EOL><INDENT>layer = tf.contrib.layers.instance_norm(<EOL>x,<EOL>param_initializers={'<STR_LIT>': tf.constant_initializer(beta), '<STR_LIT>': tf.constant_initializer(gamma)},<EOL>epsilon=epsilon, data_format='<STR_LIT>',<EOL>trainable=False<EOL>)<EOL>return layer<EOL><DEDENT>lambda_layer = keras.layers.Lambda(target_layer, name=tf_name)<EOL>layers[scope_name] = lambda_layer(layers[inputs[<NUM_LIT:0>]])<EOL>

Convert instance normalization layer.

Args:
    params: dictionary with layer parameters
    w_name: name prefix in state_dict
    scope_name: pytorch scope name
    inputs: pytorch node inputs
    layers: dictionary with keras tensors
    weights: pytorch state_dict
    names: use short names for keras layers


def convert_dropout(params, w_name, scope_name, inputs, layers, weights, names):

print('<STR_LIT>')<EOL>if names == '<STR_LIT>':<EOL><INDENT>tf_name = '<STR_LIT>' + random_string(<NUM_LIT:6>)<EOL><DEDENT>elif names == '<STR_LIT>':<EOL><INDENT>tf_name = w_name<EOL><DEDENT>else:<EOL><INDENT>tf_name = w_name + str(random.random())<EOL><DEDENT>dropout = keras.layers.Dropout(rate=params['<STR_LIT>'], name=tf_name)<EOL>layers[scope_name] = dropout(layers[inputs[<NUM_LIT:0>]])<EOL>

Convert dropout.

Args:
    params: dictionary with layer parameters
    w_name: name prefix in state_dict
    scope_name: pytorch scope name
    inputs: pytorch node inputs
    layers: dictionary with keras tensors
    weights: pytorch state_dict
    names: use short names for keras layers