Build pubnote string from parts (reverse of split_pubnote).
19283
def build_pubnote(title, volume, page_start=None, page_end=None, artid=None):
    """"""
    if title and volume and artid and artid != page_start:
        pubnote_format = u'{title},{volume},{artid}'
    elif title and volume and page_start and page_end:
        pubnote_format = u'{title},{volume},{page_start}-{page_end}'
    elif title and volume and page_start:
        pubnote_format = u'{title},{volume},{page_start}'
    elif title and volume:
        pubnote_format = u'{title},{volume}'
    else:
        return None

    return pubnote_format.format(
        title=title, volume=volume, page_start=page_start, page_end=page_end, artid=artid
    )
1355927
def _split_repo_str(repo):
    '''
    
    '''
    split = sourceslist.SourceEntry(repo)
    return split.type, split.architectures, split.uri, split.dist, split.comps
52284
def notebook_to_md(notebook):
    """"""
    tmp_file = tempfile.NamedTemporaryFile(delete=False)
    tmp_file.write(ipynb_writes(notebook).encode('utf-8'))
    tmp_file.close()

    pandoc(u'--from ipynb --to markdown -s --atx-headers --wrap=preserve --preserve-tabs', tmp_file.name, tmp_file.name)

    with open(tmp_file.name, encoding='utf-8') as opened_file:
        text = opened_file.read()

    os.unlink(tmp_file.name)
    return '\n'.join(text.splitlines())
961143
def from_str(cls: Type[CRCPubkeyType], crc_pubkey: str) -> CRCPubkeyType:
        
        data = CRCPubkey.re_crc_pubkey.match(crc_pubkey)
        if data is None:
            raise Exception("Could not parse CRC public key {0}".format(crc_pubkey))
        pubkey = data.group(1)
        crc = data.group(2)
        return cls(pubkey, crc)
646759
def batch_message_from_parts(cls, messages):
        '''
        '''
        # Comma-separate the messages and wrap the lot in square brackets
        middle = b', '.join(messages)
        if not middle:
            raise ProtocolError.empty_batch()
        return b''.join([b'[', middle, b']'])
980680
def _format_notes(self, record):
        
        notes = []
        for note in record["notes"]:
            if note.get("type"):
                n = {}
                n["type"] = note["type"]
                try:
                    if note["jsonmodel_type"] == "note_singlepart":
                        n["content"] = note["content"][0]
                    else:
                        n["content"] = note["subnotes"][0]["content"]
                except (IndexError, KeyError):
                    n["content"] = ""

                notes.append(n)

        return notes
204460
def split_comments(comments):
    """"""
    flags = []
    other = []
    for c in comments:
        if len(c) > 1 and c[1] == ',':
            flags.append(c)
        else:
            other.append(c)
    return flags, other
308650
def _unmarshal_parts(pkg_reader, package, part_factory):
        
        parts = {}
        for partname, content_type, reltype, blob in pkg_reader.iter_sparts():
            parts[partname] = part_factory(
                partname, content_type, reltype, blob, package
            )
        return parts
90002
def shlex_split(str_to_split: str) -> List[str]:
    
    return shlex.split(str_to_split, comments=False, posix=False)
1260972
def notes_master_part(self):
        
        try:
            return self.part_related_by(RT.NOTES_MASTER)
        except KeyError:
            notes_master_part = NotesMasterPart.create_default(self.package)
            self.relate_to(notes_master_part, RT.NOTES_MASTER)
            return notes_master_part
356511
def as_posix(self):
        """"""
        f = self._flavour
        return str(self).replace(f.sep, '/')
692646
def parse_endnotes(document, xmlcontent):
    

    endnotes = etree.fromstring(xmlcontent)
    document.endnotes = {}

    for note in endnotes.xpath('.//w:endnote', namespaces=NAMESPACES):
        paragraphs = [parse_paragraph(document, para) for para in note.xpath('.//w:p', namespaces=NAMESPACES)]

        document.endnotes[note.attrib[_name('{{{w}}}id')]] = paragraphs
121908
def split_str(string):
    """"""
    split = string.split(' ')
    return ' '.join(split[:len(split) // 2]), ' '.join(split[len(split) // 2:])
390339
def make_pdb(self):
        """"""
        pdb_str = write_pdb(
            [self], ' ' if not self.ampal_parent else self.ampal_parent.id)
        return pdb_str
489188
def from_string(cls, serialized):
        """"""
        warnings.warn(
            "SlashSeparatedCourseKey is deprecated! Please use locator.CourseLocator",
            DeprecationWarning,
            stacklevel=2
        )
        return CourseLocator.from_string(serialized)
1119644
def split_spec(spec, sep):
    """"""
    parts = spec.rsplit(sep, 1)
    spec_start = parts[0].strip()
    spec_end = ''
    if len(parts) == 2:
        spec_end = parts[-1].strip()
    return spec_start, spec_end
1129966
def chunks_str(str, n, separator="\n", fill_blanks_last=True):
    
    return separator.join(chunks(str, n))