Not logged in

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

Overview
Comment:Fix bug in which a handler initially chosen for the file extension is kept even if it does not claim the file.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:de5fe86a8e884f5a4892acbc98d287c4a1a8800e
User & Date: brandon 2018-10-06 20:35:23
Context
2018-10-09
19:37
Move error checking to pyifbabel tool check-in: 7cc6c3a772 user: brandon tags: trunk
2018-10-06
20:35
Fix bug in which a handler initially chosen for the file extension is kept even if it does not claim the file. check-in: de5fe86a8e user: brandon tags: trunk
2018-01-16
21:37
fix use of lists in nested node objects check-in: 2f68ce1cc2 user: brandon tags: trunk
Changes

Changes to treatyofbabel/__init__.py.

78
79
80
81
82
83
84



85
86
87
88
89
90
91
...
119
120
121
122
123
124
125
126

127


128
129
130
131
132
133
134
135
    basename = os.path.basename(story_file)
    extension = os.path.splitext(basename)[1]
    handler = EXTENSION_MAP.get(extension)
    if handler is None or not handler.claim_story_file(story_buffer):
        for h in HANDLERS:
            if h.claim_story_file(story_buffer):
                handler = h



    if handler is None:
        raise BabelError("Unknown story format")
    return handler


def _get_story_data(story_file):
    """Extract the data from a story file.
................................................................................
        The name of the formt of the story, which could be blorbed

    """
    story_data = _get_story_data(story_file)
    if blorb.claim_story_file(story_data):
        story_format = blorb.get_story_format(story_data)
        return "blorbed {0}".format(story_format)
    else:

        handler = deduce_handler(story_file, story_data)


        return handler.get_format_name()


def get_ifids(story_file):
    """Get the IFID from a story file or from an ifiction file.

    Args:
        story_file: the file path of a story file or an iFiction file







>
>
>







 







<
>

>
>
|







78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
...
122
123
124
125
126
127
128

129
130
131
132
133
134
135
136
137
138
139
140
    basename = os.path.basename(story_file)
    extension = os.path.splitext(basename)[1]
    handler = EXTENSION_MAP.get(extension)
    if handler is None or not handler.claim_story_file(story_buffer):
        for h in HANDLERS:
            if h.claim_story_file(story_buffer):
                handler = h
                break
            else:
                handler = None
    if handler is None:
        raise BabelError("Unknown story format")
    return handler


def _get_story_data(story_file):
    """Extract the data from a story file.
................................................................................
        The name of the formt of the story, which could be blorbed

    """
    story_data = _get_story_data(story_file)
    if blorb.claim_story_file(story_data):
        story_format = blorb.get_story_format(story_data)
        return "blorbed {0}".format(story_format)

    try:
        handler = deduce_handler(story_file, story_data)
    except BabelError:
        return "unknown"
    return handler.get_format_name()


def get_ifids(story_file):
    """Get the IFID from a story file or from an ifiction file.

    Args:
        story_file: the file path of a story file or an iFiction file