Generate a header for a newly created resource.

    Assume `id` attribute convention.
425303
def encode_id_header(resource):
    
    if not hasattr(resource, "id"):
        return {}

    return {
        "X-{}-Id".format(
            camelize(name_for(resource))
        ): str(resource.id),
    }
278167
function (prefix, obj) {
            if (!obj.attr('id')) {
                var generated_id;
                do {
                    generated_id = prefix + '_' + randomNumber();
                } while ($('#' + generated_id).length > 0);
                obj.attr('id', generated_id);
            }
            return obj.attr('id');
        }
179439
def make_header(field_names, permit_not=False):
    """"""
    slug_chars = SLUG_CHARS if not permit_not else SLUG_CHARS + "^"

    header = [
        slug(field_name, permitted_chars=slug_chars) for field_name in field_names
    ]
    result = []
    for index, field_name in enumerate(header):
        if not field_name:
            field_name = "field_{}".format(index)
        elif field_name[0].isdigit():
            field_name = "field_{}".format(field_name)

        if field_name in result:
            field_name = make_unique_name(
                name=field_name, existing_names=result, start=2
            )
        result.append(field_name)

    return result
1000512
def _ensure_request_id_header(self):
        ""
        if REQUEST_ID_HEADER not in self.request.headers:
            self.request.headers.add(REQUEST_ID_HEADER, uuid.uuid1().hex)
208369
def group_id(self, resource_id):
        
        if self._name != 'group':
            self._request_uri = '{}/{}'.format(self._api_uri, resource_id)
321824
def _create_header(self):
        
        # Retrieve the node to which we will append the group header.
        CstmrDrctDbtInitn_node = self._xml.find('CstmrDrctDbtInitn')

        # Create the header nodes.
        GrpHdr_node = ET.Element("GrpHdr")
        MsgId_node = ET.Element("MsgId")
        CreDtTm_node = ET.Element("CreDtTm")
        NbOfTxs_node = ET.Element("NbOfTxs")
        CtrlSum_node = ET.Element("CtrlSum")
        InitgPty_node = ET.Element("InitgPty")
        Nm_node = ET.Element("Nm")
        SupId_node = ET.Element("Id")
        OrgId_node = ET.Element("OrgId")
        Othr_node = ET.Element("Othr")
        Id_node = ET.Element("Id")

        # Add data to some header nodes.
        MsgId_node.text = self.msg_id
        CreDtTm_node.text = datetime.datetime.now().strftime('%Y-%m-%dT%H:%M:%S')
        Nm_node.text = self._config['name']
        Id_node.text = self._config['creditor_id']

        # Append the nodes
        Othr_node.append(Id_node)
        OrgId_node.append(Othr_node)
        SupId_node.append(OrgId_node)
        InitgPty_node.append(Nm_node)
        InitgPty_node.append(SupId_node)
        GrpHdr_node.append(MsgId_node)
        GrpHdr_node.append(CreDtTm_node)
        GrpHdr_node.append(NbOfTxs_node)
        GrpHdr_node.append(CtrlSum_node)
        GrpHdr_node.append(InitgPty_node)

        # Append the header to its parent
        CstmrDrctDbtInitn_node.append(GrpHdr_node)
395517
def __create_document_header(self):
        
        E = self.E
        root = E('basic-transcription')
        head = E('head')

        meta = E('meta-information')
        project = E('project-name')
        tname = E('transcription-name')
        ref_file = E('referenced-file', url="")
        ud = E('ud-meta-information')
        comment = E('comment')
        tconvention = E('transcription-convention')
        meta.append(project)
        meta.append(tname)
        meta.append(ref_file)
        meta.append(ud)
        meta.append(comment)
        meta.append(tconvention)

        speakers = E('speakertable')
        head.append(meta)
        head.append(speakers)
        root.append(head)
        return root
676975
def add_header(self, name, value):
        '''
        '''
        if self.headers is None:
            self.headers = []
        self.headers.append(dict(Name=name, Value=value))
407976
def generate_id(cls, prefix="pelix-"):
        
        if not prefix:
            # Normalize string
            prefix = ""
        else:
            # Truncate long prefixes
            prefix = prefix[:8]

        # Prepare the missing part
        nb_bytes = (23 - len(prefix)) // 2

        random_bytes = os.urandom(nb_bytes)
        if sys.version_info[0] >= 3:
            random_ints = [char for char in random_bytes]
        else:
            random_ints = [ord(char) for char in random_bytes]

        random_id = "".join("{0:02x}".format(value) for value in random_ints)
        return "{0}{1}".format(prefix, random_id)
1204525
private void obtainHeaderIcon(@StyleRes final int themeResourceId) {
        TypedArray typedArray = getContext().getTheme().obtainStyledAttributes(themeResourceId,
                new int[]{R.attr.materialDialogHeaderIcon});
        int resourceId = typedArray.getResourceId(0, 0);

        if (resourceId != 0) {
            setHeaderIcon(resourceId);
        }
    }
1211666
def build_header(self, title):
        """"""
        header = ['---',
                  'title: ' + title,
                  'author(s): ' + self.user,
                  'tags: ',
                  'created_at: ' + str(self.date_created),
                  'updated_at: ' + str(self.date_updated),
                  'tldr: ',
                  'thumbnail: ',
                  '---']

        self.out = header + self.out
808931
def create_definition(self, block_type, slug=None):
        """"""
        prefix = "d"
        if slug:
            prefix += "_" + slug
        def_id = self._next_id(prefix)
        self._definitions[def_id] = block_type
        return def_id
417717
def set_header(self, name, value, append=False):
        '''  '''
        if append:
            self.add_header(name, value)
        else:
            self._headers[_hkey(name)] = [str(value)]
644632
def p_if_header(p):
    
    global ENABLED

    IFDEFS.append((ENABLED, p.lineno(2)))
    ENABLED = ID_TABLE.defined(p[2])
1246644
def build_header(self, plugin, attribute, stat):
        """"""
        line = ''

        if attribute is not None:
            line += '{}.{}{}'.format(plugin, attribute, self.separator)
        else:
            if isinstance(stat, dict):
                for k in stat.keys():
                    line += '{}.{}{}'.format(plugin,
                                             str(k),
                                             self.separator)
            elif isinstance(stat, list):
                for i in stat:
                    if isinstance(i, dict) and 'key' in i:
                        for k in i.keys():
                            line += '{}.{}.{}{}'.format(plugin,
                                                        str(i[i['key']]),
                                                        str(k),
                                                        self.separator)
            else:
                line += '{}{}'.format(plugin, self.separator)

        return line
1252709
def _create_header(info, format, encoding, errors):
        
        parts = [
            stn(info.get("name", ""), 100, encoding, errors),
            itn(info.get("mode", 0) & 0o7777, 8, format),
            itn(info.get("uid", 0), 8, format),
            itn(info.get("gid", 0), 8, format),
            itn(info.get("size", 0), 12, format),
            itn(info.get("mtime", 0), 12, format),
            b"        ", # checksum field
            info.get("type", REGTYPE),
            stn(info.get("linkname", ""), 100, encoding, errors),
            info.get("magic", POSIX_MAGIC),
            stn(info.get("uname", ""), 32, encoding, errors),
            stn(info.get("gname", ""), 32, encoding, errors),
            itn(info.get("devmajor", 0), 8, format),
            itn(info.get("devminor", 0), 8, format),
            stn(info.get("prefix", ""), 155, encoding, errors)
        ]

        buf = struct.pack("%ds" % BLOCKSIZE, b"".join(parts))
        chksum = calc_chksums(buf[-BLOCKSIZE:])[0]
        buf = buf[:-364] + ("%06o\0" % chksum).encode("ascii") + buf[-357:]
        return buf
750350
def create_header(self):
		
		try:
			self.check_valid()
			_header_list = []
			for k,v in self.inputs.items():
				if v is None:
					return  {self.__class__.__name__.replace('_','-'):None}
				elif k == 'value':
					_header_list.insert(0,str(v))
				elif isinstance(v,bool):
					if v is True:
						_header_list.append(k)
				else:
					_header_list.append('%s=%s' % (k,str(v)))
			return {self.__class__.__name__.replace('_','-'):'; '.join(_header_list)}
		except Exception, e:
			raise