Logo Search packages:      
Sourcecode: calibre version File versions

def calibre::ebooks::rtf2xml::field_strings::FieldStrings::process_string (   self,
  my_string,
  type 
)

Requires:
    my_string --the string to parse.
    type -- the type of string.
Returns:
    Returns a string for a field instrution attribute.
Logic:
    This handles all "large" fields, which means everything except
    toc entries, index entries, and bookmarks
    Split the string by spaces, and get the first item in the
    resulting list. This item is the field's type. Check for the
    action in the field instructions dictionary for further parsing.
    If no action is found, print out an error message.

Definition at line 182 of file field_strings.py.

00182                                              :
        """
        Requires:
            my_string --the string to parse.
            type -- the type of string.
        Returns:
            Returns a string for a field instrution attribute.
        Logic:
            This handles all "large" fields, which means everything except
            toc entries, index entries, and bookmarks
            Split the string by spaces, and get the first item in the
            resulting list. This item is the field's type. Check for the
            action in the field instructions dictionary for further parsing.
            If no action is found, print out an error message.
        """
        changed_string = ''
        lines = my_string.split('\n')
        for line in lines:
            if line[0:2] == 'tx':
                changed_string += line[17:]
        fields = changed_string.split()
        field_name = fields[0]
        action, name = self.__field_instruction_dict.get(field_name, (None, None))
        match_obj = re.search(self.__merge_format_exp, changed_string)
        if match_obj and name:
            name += '<update>dynamic'
        elif name:
            name += '<update>static'
        else:
            pass
            # no name--not in list above
        if action:
            the_list = action(field_name, name, changed_string)
        else:
            # change -1 to 0--for now, I want users to report bugs
            msg = 'no key for "%s" "%s"\n' % (field_name, changed_string)
            sys.stderr.write(msg)
            if self.__run_level > 3:
                msg = 'no key for "%s" "%s"\n' % (field_name, changed_string)
                raise self.__bug_handler, msg
            the_list = self.__fall_back_func(field_name, line)
            return the_list
        return the_list
    def __default_inst_func(self, field_name, name, line):


Generated by  Doxygen 1.6.0   Back to index