Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:more "contacts" fixes
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3ee30d83647a7a9248bf555172df91362f378846
User & Date: brandon 2015-01-25 22:28:31
Context
2015-05-05
21:53
replace some generic Exceptions with slightly less generic BabelErrors check-in: 90294f9468 user: brandon tags: trunk
2015-01-25
22:28
more "contacts" fixes check-in: 3ee30d8364 user: brandon tags: trunk
2015-01-19
23:03
fix erroneously named "contacts" tag check-in: 99709810fc user: brandon tags: trunk
Changes

Changes to treatyofbabel/ifiction.py.

493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
...
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
    pass


def lint_resource(ifiction_dom):
    pass


def add_contacts(ifiction_dom, story_node, url=None, email=None):
    """Add contact information to a story Node.

    Args:
        ifiction_dom: an xml.dom Document
        story_node: a story Node
        url: a URL for the author/story (default: None)
        email: an email address for the author (default: None)
................................................................................
    if email is not None and email != "":
        email_tag = ifiction_dom.createElement("email")
        cont.appendChild(email_tag)
        email_text = ifiction_dom.createTextNode(email)
        email_tag.appendChild(email_text)


def get_contacts(story_node):
    """Return a nested dict object containing story contact data.

    Args:
        story_node: a story Node
    Returns:
        A dict object with node names as keys and node text as values

    """
    contacts = {"url": None, "email": None}
    contact_nodes = story_node.getElementsByTagName("contact")
    if len(contact_nodes) > 0:
        url_nodes = contact_nodes[0].getElementsByTagName("url")
        if len(url_nodes) > 0:
            contacts["url"] = url_nodes[0].firstChild.nodeValue.strip()
        email_nodes = contact_nodes[0].getElementsByTagName("email")
        if len(email_nodes) > 0:
            contacts["email"] = email_nodes[0].firstChild.nodeValue.strip()
    return contacts


def check_contacts(ifiction_dom):
    pass


def lint_contacts(ifiction_dom):
    pass


def add_cover(ifiction_dom, story_node, img_format, height, width,
              description):
    """Add cover art information to a story Node.








|







 







|








|




|


|
|


|



|







493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
...
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
    pass


def lint_resource(ifiction_dom):
    pass


def add_contact(ifiction_dom, story_node, url=None, email=None):
    """Add contact information to a story Node.

    Args:
        ifiction_dom: an xml.dom Document
        story_node: a story Node
        url: a URL for the author/story (default: None)
        email: an email address for the author (default: None)
................................................................................
    if email is not None and email != "":
        email_tag = ifiction_dom.createElement("email")
        cont.appendChild(email_tag)
        email_text = ifiction_dom.createTextNode(email)
        email_tag.appendChild(email_text)


def get_contact(story_node):
    """Return a nested dict object containing story contact data.

    Args:
        story_node: a story Node
    Returns:
        A dict object with node names as keys and node text as values

    """
    contact = {"url": None, "email": None}
    contact_nodes = story_node.getElementsByTagName("contact")
    if len(contact_nodes) > 0:
        url_nodes = contact_nodes[0].getElementsByTagName("url")
        if len(url_nodes) > 0:
            contact["url"] = url_nodes[0].firstChild.nodeValue.strip()
        email_nodes = contact_nodes[0].getElementsByTagName("email")
        if len(email_nodes) > 0:
            contact["email"] = email_nodes[0].firstChild.nodeValue.strip()
    return contact


def check_contact(ifiction_dom):
    pass


def lint_contact(ifiction_dom):
    pass


def add_cover(ifiction_dom, story_node, img_format, height, width,
              description):
    """Add cover art information to a story Node.