Preconstrain the data in the flag page.

        :param magic_content:   The content of the magic page as a bytestring.
973461
def preconstrain_flag_page(self, magic_content):
        
        for m, v in zip(magic_content, self.state.cgc.flag_bytes):
            self.preconstrain(m, v)
1037739
def filter_magic(source, magic, strip=True):
    
    filtered, magic_lines=[],[]
    for line in source.splitlines():
        if line.strip().startswith(magic):
            magic_lines.append(line)
        else:
            filtered.append(line)
    if strip:
        magic_lines = [el.replace(magic,'') for el in magic_lines]
    return '\n'.join(filtered), magic_lines
1343630
def set_content(self, data):
        
        content = self._get_content(data, 'content')

        if content == '':
            content = self._get_content(data, 'summary_detail')

        if content == '':
            if data.get('description'):
                content = data.get('description')

        return content
1142502
def add_content(self, data):
        # type: (Optional[Union[Dict[str, Any], ET.Element]]) -> None
        
        if data is None:
            return

        if isinstance(data, ET.Element):
            bytes_data = ET.tostring(data, encoding="utf8")
            self.headers['Content-Length'] = str(len(bytes_data))
            self.data = bytes_data
            return

        # By default, assume JSON
        try:
            self.data = json.dumps(data)
            self.headers['Content-Length'] = str(len(self.data))
        except TypeError:
            self.data = data
1054961
def p_common_scalar_magic_dir(p):
    ''
    value = getattr(p.lexer, 'filename', None)
    if value is not None:
        value = os.path.dirname(value)
    p[0] = ast.MagicConstant(p[1].upper(), value, lineno=p.lineno(1))
260662
def p_common_scalar_magic_file(p):
    ''
    value = getattr(p.lexer, 'filename', None)
    p[0] = ast.MagicConstant(p[1].upper(), value, lineno=p.lineno(1))
316824
def setContent(self, type_, value):
        

        if type_ in [self.CONTENT_TYPE_TXT, self.CONTENT_TYPE_URL,
                     self.CONTENT_TYPE_FILE]:
            if type_ == self.CONTENT_TYPE_FILE:
                self._file = {}
                self._file = {'doc': open(value, 'rb')}
            else:
                self.addParam(type_, value)
1116228
protected function magicInit()
    {
        if (!$this->magicInited) {
            $this->magicFields = array_replace($this->magicFields, $this->magicGetDefaults());
            $this->magicInited = true;
        }
    }
546153
def lock_content(content)
      content = content.to_smash
      content.merge!(:sfn_lock_enabled => true)
      safe = SfnParameters::Safe.build(
        config.fetch(:sfn_parameters, :safe, Smash.new)
      )
      safe.lock(dump_json(content))
    end
451138
private void verifyMagicBytes(TLVInputStream input) throws InvalidPublicationsFileException {
        try {
            byte[] magicBytes = new byte[PUBLICATIONS_FILE_MAGIC_BYTES_LENGTH];
            input.read(magicBytes);
            if (!Arrays.equals(magicBytes, FILE_BEGINNING_MAGIC_BYTES)) {
                throw new InvalidPublicationsFileException("Invalid publications file magic bytes");
            }
        } catch (IOException e) {
            throw new InvalidPublicationsFileException("Checking publications file magic bytes failed", e);
        }
    }
331435
function magic(buf, cb) {
  setTimeout(() => {
    const sampleLength = 24;
    const sample = buf.slice(0, sampleLength).toString('hex'); // lookup data

    const found = Object.keys(_magicDb2.default).find(it => {
      return sample.indexOf(it) != -1;
    });

    if (found) {
      cb(null, _magicDb2.default[found]);
    } else {
      cb(new Error('Magic number not found'));
    }
  }, 0);
}
213510
def store_magic_envelope_doc(self, payload):
        """"""
        try:
            json_payload = json.loads(decode_if_bytes(payload))
        except ValueError:
            # XML payload
            xml = unquote(decode_if_bytes(payload))
            xml = xml.lstrip().encode("utf-8")
            logger.debug("diaspora.protocol.store_magic_envelope_doc: xml payload: %s", xml)
            self.doc = etree.fromstring(xml)
        else:
            logger.debug("diaspora.protocol.store_magic_envelope_doc: json payload: %s", json_payload)
            self.doc = self.get_json_payload_magic_envelope(json_payload)
96826
def put_content(self, content):
        
        if not isinstance(content, str):
            content = content.decode('utf-8')

        self.topic.publish(Message=content, **self.storage_args)
1257931
def _check_content(self, content_str):
        """"""
        if self.do_content_check:
            space_ratio = float(content_str.count(' '))/len(content_str)
            if space_ratio > self.max_space_ratio:
                return "space-ratio: %f > %f" % (space_ratio,
                                                 self.max_space_ratio)
            if len(content_str) > self.input_character_limit:
                return "too long: %d > %d" % (len(content_str),
                                              self.input_character_limit)
        return None
1074930
def _setContent(self):
        '''
        '''
        kw = KW.copy()
        try:
            kw.update(dict(klass=self.getClassName(),
                       element='ElementDeclaration',
                       literal=self.literalTag(),
                       substitutionGroup=self._substitutionGroupTag(),
                       schema=self.schemaTag(), 
                       init=self.simpleConstructor(),
                       ns=self.ns, name=self.name,
                       aname=self.getAttributeName(self.name),  
                       baseslogic=self.getBasesLogic(ID3),
                       #ofwhat=self.getTypecodeList(),
                       #atypecode=self.attribute_typecode,
                       #pyclass=self.getPyClass(),
                       alias=NAD.getAlias(self.sKlassNS),
                       subclass=type_class_name(self.sKlass),
                       ))
        except Exception, ex:
            args = ['Failure processing an element w/local complexType: %s' %(
                          self._item.getItemTrace())]
            args += ex.args
            ex.args = tuple(args)
            raise
        
        if self.local:
            kw['element'] = 'LocalElementDeclaration'
        
        element = [
            '%(ID1)sclass %(klass)s(%(element)s):',
            '%(ID2)s%(literal)s',
            '%(ID2)s%(schema)s',
            '%(ID2)s%(substitutionGroup)s',
            '%(ID2)s%(init)s',
            '%(ID3)skw["pname"] = ("%(ns)s","%(name)s")',
            '%(ID3)skw["aname"] = "%(aname)s"',
            '%(baseslogic)s',
            '%(ID3)s%(alias)s.%(subclass)s.__init__(self, **kw)',
            '%(ID3)sif self.pyclass is not None: self.pyclass.__name__ = "%(klass)s_Holder"',
            ]

        self.writeArray(map(lambda l: l %kw, element))
1175500
def estimate_size_in_bytes(cls, magic, compression_type, key, value):
        
        assert magic in [0, 1], "Not supported magic"
        # In case of compression we may need another overhead for inner msg
        if compression_type:
            return (
                cls.LOG_OVERHEAD + cls.record_overhead(magic) +
                cls.record_size(magic, key, value)
            )
        return cls.LOG_OVERHEAD + cls.record_size(magic, key, value)
1160559
def content(self, content):
        
        allowed_values = ["UNRELEASED", "EARLYACCESS", "SUPPORTED", "EXTENDED_SUPPORT", "EOL"]
        if not set(content).issubset(set(allowed_values)):
            raise ValueError(
                "Invalid values for `content` [{0}], must be a subset of [{1}]"
                .format(", ".join(map(str, set(content)-set(allowed_values))),
                        ", ".join(map(str, allowed_values)))
            )

        self._content = content