Package advene :: Package model :: Package parsers :: Module advene_xml :: Class Parser
[hide private]
[frames] | no frames]

Class Parser

source code

            object --+    
                     |    
base_xml.XmlParserBase --+
                         |
                        Parser
Known Subclasses:

Instance Methods [hide private]
 
parse(self)
Do the actual parsing.
source code
 
__init__(self, file_, package)
x.__init__(...) initializes x; see x.__class__.__doc__ for signature
source code
 
do_or_postpone(self, id, function, function2=None)
If `identified` an imported element, function is invoked with `id` as its argument.
source code
 
optional_sequence(self, tag, *args, **kw) source code
 
manage_package_subelements(self)
This method may be overridden by application model parsers having a syntax simiar to the generic advene format - like the cinelab parser.
source code
 
handle_package(self)
Subclasses should normally not override this method, but rather `manage_package_subelements`.
source code
 
handle_import(self) source code
 
handle_tag(self, element=None) source code
 
handle_media(self) source code
 
handle_resource(self) source code
 
handle_annotation(self) source code
 
handle_relation(self) source code
 
handle_view(self) source code
 
handle_query(self) source code
 
handle_list(self) source code
 
handle_meta(self, obj) source code
 
handle_content(self, creation_method, *args) source code
 
handle_member(self, relation) source code
 
handle_item(self, lst, c) source code
 
handle_element(self, advene_tag) source code
 
handle_association(self) source code

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

    Inherited from base_xml.XmlParserBase
 
_check_end(self, elem) source code
 
_handle(self, args, kw) source code
 
complete_current(self) source code
 
get_attribute(self, key, default=_RAISE) source code
 
optional(self, tag, *args, **kw) source code
 
required(self, tag, *args, **kw) source code
 
sequence(self, tag, *args, **kw)
NB: this methods allows an *empty* sequence.
source code
Class Methods [hide private]
 
claims_for_parse(cls, file_)
Is this parser likely to parse that file-like object?
source code
 
make_parser(cls, file_, package)
Return a parser that will parse `file_` into `package`.
source code
 
parse_into(cls, file_, package)
A shortcut for ``make_parser(file_, package).parse()``.
source code
Class Variables [hide private]
  NAME = 'Generic Advene XML'
  EXTENSION = '.bxp'
  MIMETYPE = 'application/x-advene-bxp'
  SERIALIZER
Generic serializer implementation.
  _NAMESPACE_URI = 'http://advene.liris.cnrs.fr/ns/advene-xml/0.1'
Properties [hide private]

Inherited from object: __class__

    Inherited from base_xml.XmlParserBase
  current
  ns_stack
Method Details [hide private]

claims_for_parse(cls, file_)
Class Method

source code 

Is this parser likely to parse that file-like object?

`file_` is a readable file-like object. It is the responsability of the caller to close it.

Return an int between 00 and 99, indicating the likelyhood of this parser to handle correctly the given URL. 70 is used as a standard value when the parser is pretty sure it can handle the URL.

make_parser(cls, file_, package)
Class Method

source code 

Return a parser that will parse `file_` into `package`.

`file_` is a writable file-like object. It is the responsability of the caller to close it.

The returned object must implement the interface for which :class:`_Parser` is the reference implementation.

parse_into(cls, file_, package)
Class Method

source code 

A shortcut for ``make_parser(file_, package).parse()``.

See also `make_parser`.

parse(self)

source code 

Do the actual parsing.

Overrides: base_xml.XmlParserBase.parse

__init__(self, file_, package)
(Constructor)

source code 

x.__init__(...) initializes x; see x.__class__.__doc__ for signature

Overrides: object.__init__
(inherited documentation)

do_or_postpone(self, id, function, function2=None)

source code 

If `identified` an imported element, function is invoked with `id` as its argument.

If `id` is a plain identifier, it is checked whether `self.package` has such an element. If so, function is invoked with that element as its argument; else, its execution is postponed.

This is useful because some elements in the serialization may refer to other elements that are defined further.

If function2 is provided and the invocation is postponed, then it will be function2 rather than function that will be invoked.


Class Variable Details [hide private]

SERIALIZER

Generic serializer implementation.

Note that the order chosen for XML elements (imports, tags, medias, resources, annotations, relations, views, queries, lists) is designed to limit the number of forward references, which makes the work of the parser more difficult. Forward references are nevetheless still possible in meta-data, tag associated to another tag, list containing another list

Value:
advene.model.serializers.advene_xml