<s> '''<STR_LIT>''' <EOL> from RESTfulResource import RESTfulResource <EOL> from rdflib . graph import Graph <EOL> from Observers import Observers <EOL> class RespGraph ( Graph ) : <EOL> def _xml_ ( self ) : <EOL> return self . serialize ( format = '<STR_LIT>' ) <EOL> class Description ( RESTfulResource ) : <EOL> def __init__ ( self ) : <EOL> RESTfulResource . __init__ ( self ) <EOL> self . graph = Graph ( ) <EOL> self . _parseContentTypes = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . _serializeContentTypes = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> self . fmt = { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> def get ( self , ( s , p , o ) = ( None , None , None ) ) : <EOL> g = RespGraph ( ) <EOL> for triple in self . graph . triples ( ( s , p , o ) ) : <EOL> g . add ( triple ) <EOL> return g <EOL> def set ( self , newValue ) : <EOL> if type ( newValue ) is tuple : <EOL> self . graph . set ( newValue ) <EOL> else : <EOL> self . graph += newValue <EOL> def create ( self , newValue ) : <EOL> if type ( newValue ) is tuple : <EOL> self . graph . add ( newValue ) <EOL> else : <EOL> self . graph = newValue <EOL> def delete ( self , newValue ) : <EOL> if type ( newValue ) is tuple : <EOL> self . graph . remove ( newValue ) <EOL> else : <EOL> self . graph -= newValue <EOL> def parse ( self , source , cType ) : <EOL> g = Graph ( ) <EOL> return g . parse ( source , format = self . fmt [ cType ] ) <EOL> def serialize ( self , graph , cType ) : <EOL> return graph . serialize ( format = self . fmt [ cType ] ) <EOL> def serializeContentTypes ( self ) : <EOL> return self . _serializeContentTypes <EOL> def parseContentTypes ( self ) : <EOL> return self . _parseContentTypes </s>
