예제 #1
0
def test_addBNodeKnowsL():
    Person.knows = rdfalchemy.rdfList(
        FOAF.knowsL, range_type=FOAF.Person)
    p1 = Person(first="PhilipL")
    p2 = Person(last="Cooper", first="Ben")
    p3 = Person(last="Cooper", first="Matt")
    p1.knows = [p2, p3]
    p1 = Person.get_by(first="PhilipL")
    log.info("db len is %s" % len(Person.db))
    assert len(p1.knows) == 2
    del p1
예제 #2
0
class Label(Taggable):
    rdf_type = Namespace(
        'https://brickschema.org/schema/1.0.2/BrickFrame#').Label

    hasTokenSomeToken = rdfList(
        Namespace('https://brickschema.org/schema/1.0.2/BrickFrame#').
        hasTokenSomeToken)
    listOfhasTokenSomeToken = []

    def addhasTokenSome(self, parameter):
        self.listOfhasTokenSomeToken.append(parameter)
        self.hasTokenSomeToken = self.listOfhasTokenSomeToken
예제 #3
0
def test_addBNodeKnowsL():
    Person.knows = rdfalchemy.rdfList(FOAF.knows, range_type=FOAF.Person)
    mapper()
    p1 = Person.get_by(first="Philip")
    p2 = Person(last="Cooper", first="Ben")
    p3 = Person(last="Cooper", first="Matt")
    assert len(Person.db) == 9
    p1.knows = [p2, p3]
    print(len(Person.db))
    assert len(Person.db) == 14
    del p1.knows
    print(len(Person.db))
    assert len(Person.db) == 3
class Duration(TemporalDuration):
    rdf_type = Namespace('http://www.w3.org/2006/time#').Duration

    numericDuration = rdfSingle(
        Namespace('http://www.w3.org/2006/time#').numericDuration)

    unitTypeExactlyThing = rdfList(
        Namespace('http://www.w3.org/2006/time#').unitTypeExactlyThing)
    listOfunitTypeExactlyThing = []

    def addunitTypeExactly(self, parameter):
        self.listOfunitTypeExactlyThing.append(parameter)
        self.unitTypeExactlyThing = self.listOfunitTypeExactlyThing
예제 #5
0
def test_addBNodeKnowsL():
    Person.knows = rdfalchemy.rdfList(FOAF.knows, range_type=FOAF.Person)
    mapper()
    p1 = Person.get_by(first="Philip")
    p2 = Person(last="Cooper", first="Ben")
    p3 = Person(last="Cooper", first="Matt")
    assert len(Person.db) == 9
    p1.knows = [p2, p3]
    print len(Person.db)
    assert len(Person.db) == 14
    del p1.knows
    print len(Person.db)
    assert len(Person.db) == 3
예제 #6
0
class Document(Entity):
    rdf_type = roar.Document, edm.ProvidedCHO
    identifier = rdfSingle(schema.identifier)

    language = rdfSingle(schema.isInLanguage)

    label = rdfMultiple(RDFS.label)

    onScan = rdfMultiple(roar.onScan)

    items = rdfList(AS.items)  # rdf:Collection
    prev = rdfSingle(AS.prev)
    next = rdfSingle(AS.next)
예제 #7
0
class Measurement(rdfSubject):
    rdf_type = Namespace('https://w3id.org/saref#').Measurement

    hasTimestamp = rdfSingle(Namespace('https://w3id.org/saref#').hasTimestamp)
    hasValue = rdfSingle(Namespace('https://w3id.org/saref#').hasValue)

    isMeasuredInExactlyUnitOfMeasure = rdfList(
        Namespace('https://w3id.org/saref#').isMeasuredInExactlyUnitOfMeasure)
    listOfisMeasuredInExactlyUnitOfMeasure = []

    def addisMeasuredInExactly(self, parameter):
        self.listOfisMeasuredInExactlyUnitOfMeasure.append(parameter)
        self.isMeasuredInExactlyUnitOfMeasure = self.listOfisMeasuredInExactlyUnitOfMeasure

    isMeasuredInOnlyUnitOfMeasure = rdfList(
        Namespace('https://w3id.org/saref#').isMeasuredInOnlyUnitOfMeasure)
    listOfisMeasuredInOnlyUnitOfMeasure = []

    def addisMeasuredInOnly(self, parameter):
        self.listOfisMeasuredInOnlyUnitOfMeasure.append(parameter)
        self.isMeasuredInOnlyUnitOfMeasure = self.listOfisMeasuredInOnlyUnitOfMeasure

    relatesToPropertyExactlyProperty = rdfList(
        Namespace('https://w3id.org/saref#').relatesToPropertyExactlyProperty)
    listOfrelatesToPropertyExactlyProperty = []

    def addrelatesToPropertyExactly(self, parameter):
        self.listOfrelatesToPropertyExactlyProperty.append(parameter)
        self.relatesToPropertyExactlyProperty = self.listOfrelatesToPropertyExactlyProperty

    relatesToPropertyOnlyProperty = rdfList(
        Namespace('https://w3id.org/saref#').relatesToPropertyOnlyProperty)
    listOfrelatesToPropertyOnlyProperty = []

    def addrelatesToPropertyOnly(self, parameter):
        self.listOfrelatesToPropertyOnlyProperty.append(parameter)
        self.relatesToPropertyOnlyProperty = self.listOfrelatesToPropertyOnlyProperty
class LevelControlFunction(ActuatingFunction):
    rdf_type = Namespace('https://w3id.org/saref#').LevelControlFunction

    hasCommandOnlyStepDownCommand = rdfList(
        Namespace('https://w3id.org/saref#').hasCommandOnlyStepDownCommand)
    listOfhasCommandOnlyStepDownCommand = []

    def addhasCommandOnly(self, parameter):
        self.listOfhasCommandOnlyStepDownCommand.append(parameter)
        self.hasCommandOnlyStepDownCommand = self.listOfhasCommandOnlyStepDownCommand

    hasCommandOnlySetAbsoluteLevelCommand = rdfList(
        Namespace(
            'https://w3id.org/saref#').hasCommandOnlySetAbsoluteLevelCommand)
    listOfhasCommandOnlySetAbsoluteLevelCommand = []

    def addhasCommandOnly(self, parameter):
        self.listOfhasCommandOnlySetAbsoluteLevelCommand.append(parameter)
        self.hasCommandOnlySetAbsoluteLevelCommand = self.listOfhasCommandOnlySetAbsoluteLevelCommand

    hasCommandOnlyStepUpCommand = rdfList(
        Namespace('https://w3id.org/saref#').hasCommandOnlyStepUpCommand)
    listOfhasCommandOnlyStepUpCommand = []

    def addhasCommandOnly(self, parameter):
        self.listOfhasCommandOnlyStepUpCommand.append(parameter)
        self.hasCommandOnlyStepUpCommand = self.listOfhasCommandOnlyStepUpCommand

    hasCommandOnlySetRelativeLevelCommand = rdfList(
        Namespace(
            'https://w3id.org/saref#').hasCommandOnlySetRelativeLevelCommand)
    listOfhasCommandOnlySetRelativeLevelCommand = []

    def addhasCommandOnly(self, parameter):
        self.listOfhasCommandOnlySetRelativeLevelCommand.append(parameter)
        self.hasCommandOnlySetRelativeLevelCommand = self.listOfhasCommandOnlySetRelativeLevelCommand
예제 #9
0
class Scan(rdfSubject):
    rdf_type = (saa.Scan, AS.OrderedCollectionPage)

    # partOf a collection

    depiction = rdfSingle(foaf.depiction)

    imageFilename = rdfSingle(saa.imageFilename)
    imageWidth = rdfSingle(saa.imageWidth)
    imageHeight = rdfSingle(saa.imageHeight)

    regions = rdfMultiple(saa.regions)

    items = rdfList(AS.items)  # rdf:Collection
    prev = rdfSingle(AS.prev)
    next = rdfSingle(AS.next)
예제 #10
0
class GeneralDurationDescription(TemporalDuration):
    rdf_type = Namespace(
        'http://www.w3.org/2006/time#').GeneralDurationDescription

    seconds = rdfSingle(Namespace('http://www.w3.org/2006/time#').seconds)
    minutes = rdfSingle(Namespace('http://www.w3.org/2006/time#').minutes)
    hours = rdfSingle(Namespace('http://www.w3.org/2006/time#').hours)
    months = rdfSingle(Namespace('http://www.w3.org/2006/time#').months)
    days = rdfSingle(Namespace('http://www.w3.org/2006/time#').days)
    years = rdfSingle(Namespace('http://www.w3.org/2006/time#').years)
    weeks = rdfSingle(Namespace('http://www.w3.org/2006/time#').weeks)

    hasTRSExactlyThing = rdfList(
        Namespace('http://www.w3.org/2006/time#').hasTRSExactlyThing)
    listOfhasTRSExactlyThing = []

    def addhasTRSExactly(self, parameter):
        self.listOfhasTRSExactlyThing.append(parameter)
        self.hasTRSExactlyThing = self.listOfhasTRSExactlyThing
class MeteringFunction(Function):
    rdf_type = Namespace('https://w3id.org/saref#').MeteringFunction
	
	
    hasCommandOnlyGetCurrentMeterValueCommand = rdfList(Namespace('https://w3id.org/saref#').hasCommandOnlyGetCurrentMeterValueCommand)
    listOfhasCommandOnlyGetCurrentMeterValueCommand = []

    def addhasCommandOnly (self, parameter):
        self.listOfhasCommandOnlyGetCurrentMeterValueCommand.append(parameter)
        self.hasCommandOnlyGetCurrentMeterValueCommand = self.listOfhasCommandOnlyGetCurrentMeterValueCommand
    hasCommandOnlyGetMeterDataCommand = rdfList(Namespace('https://w3id.org/saref#').hasCommandOnlyGetMeterDataCommand)
    listOfhasCommandOnlyGetMeterDataCommand = []

    def addhasCommandOnly (self, parameter):
        self.listOfhasCommandOnlyGetMeterDataCommand.append(parameter)
        self.hasCommandOnlyGetMeterDataCommand = self.listOfhasCommandOnlyGetMeterDataCommand
    hasCommandOnlyGetMeterHistoryCommand = rdfList(Namespace('https://w3id.org/saref#').hasCommandOnlyGetMeterHistoryCommand)
    listOfhasCommandOnlyGetMeterHistoryCommand = []

    def addhasCommandOnly (self, parameter):
        self.listOfhasCommandOnlyGetMeterHistoryCommand.append(parameter)
        self.hasCommandOnlyGetMeterHistoryCommand = self.listOfhasCommandOnlyGetMeterHistoryCommand
			
    hasMeterReadingTypeOnlyProperty = rdfList(Namespace('https://w3id.org/saref#').hasMeterReadingTypeOnlyProperty)
    listOfhasMeterReadingTypeOnlyProperty = []

    def addhasMeterReadingTypeOnly (self, parameter):
        self.listOfhasMeterReadingTypeOnlyProperty.append(parameter)
        self.hasMeterReadingTypeOnlyProperty = self.listOfhasMeterReadingTypeOnlyProperty
    hasMeterReadingTypeOnlyCommodity = rdfList(Namespace('https://w3id.org/saref#').hasMeterReadingTypeOnlyCommodity)
    listOfhasMeterReadingTypeOnlyCommodity = []

    def addhasMeterReadingTypeOnly (self, parameter):
        self.listOfhasMeterReadingTypeOnlyCommodity.append(parameter)
        self.hasMeterReadingTypeOnlyCommodity = self.listOfhasMeterReadingTypeOnlyCommodity
			
    hasMeterReadingOnlyMeasurement = rdfList(Namespace('https://w3id.org/saref#').hasMeterReadingOnlyMeasurement)
    listOfhasMeterReadingOnlyMeasurement = []

    def addhasMeterReadingOnly (self, parameter):
        self.listOfhasMeterReadingOnlyMeasurement.append(parameter)
        self.hasMeterReadingOnlyMeasurement = self.listOfhasMeterReadingOnlyMeasurement
			
예제 #12
0
log = logging.getLogger('rdfalchemy')
if not log.handlers:
    log.addHandler(logging.StreamHandler())
#log.setLevel(10)

Person.db = ConjunctiveGraph()


def test_start():
    assert len(Person.db) == 0
    Person(last="Cooper")
    assert len(Person.db) == 2


Person.m = rdfalchemy.rdfMultiple(FOAF.multi)
Person.l = rdfalchemy.rdfList(FOAF.list)
Person.c = rdfalchemy.rdfContainer(FOAF.seq)


def test_multi():
    p = next(Person.ClassInstances())
    p.m = [1, 2.2, 0, 'a', '', 'c']
    assert len(Person.db) == 8

    p.m = ['a', 'b', 'c']
    assert len(Person.db) == 5


def test_list():
    # set and reset a list
    p = next(Person.ClassInstances())
예제 #13
0
class Device(rdfSubject):
    rdf_type = Namespace('https://w3id.org/saref#').Device
	
    hasDescription = rdfSingle(Namespace('https://w3id.org/saref#').hasDescription)	
    hasManufacturer = rdfSingle(Namespace('https://w3id.org/saref#').hasManufacturer)	
    hasModel = rdfSingle(Namespace('https://w3id.org/saref#').hasModel)	
	
    offersOnlyService = rdfList(Namespace('https://w3id.org/saref#').offersOnlyService)
    listOfoffersOnlyService = []

    def addoffersOnly (self, parameter):
        self.listOfoffersOnlyService.append(parameter)
        self.offersOnlyService = self.listOfoffersOnlyService
			
    consistsOfOnlyDevice = rdfList(Namespace('https://w3id.org/saref#').consistsOfOnlyDevice)
    listOfconsistsOfOnlyDevice = []

    def addconsistsOfOnly (self, parameter):
        self.listOfconsistsOfOnlyDevice.append(parameter)
        self.consistsOfOnlyDevice = self.listOfconsistsOfOnlyDevice
			
    measuresPropertyOnlyProperty = rdfList(Namespace('https://w3id.org/saref#').measuresPropertyOnlyProperty)
    listOfmeasuresPropertyOnlyProperty = []

    def addmeasuresPropertyOnly (self, parameter):
        self.listOfmeasuresPropertyOnlyProperty.append(parameter)
        self.measuresPropertyOnlyProperty = self.listOfmeasuresPropertyOnlyProperty
			
    hasTypicalConsumptionOnlyPower = rdfList(Namespace('https://w3id.org/saref#').hasTypicalConsumptionOnlyPower)
    listOfhasTypicalConsumptionOnlyPower = []

    def addhasTypicalConsumptionOnly (self, parameter):
        self.listOfhasTypicalConsumptionOnlyPower.append(parameter)
        self.hasTypicalConsumptionOnlyPower = self.listOfhasTypicalConsumptionOnlyPower
    hasTypicalConsumptionOnlyEnergy = rdfList(Namespace('https://w3id.org/saref#').hasTypicalConsumptionOnlyEnergy)
    listOfhasTypicalConsumptionOnlyEnergy = []

    def addhasTypicalConsumptionOnly (self, parameter):
        self.listOfhasTypicalConsumptionOnlyEnergy.append(parameter)
        self.hasTypicalConsumptionOnlyEnergy = self.listOfhasTypicalConsumptionOnlyEnergy
			
    accomplishesMinTask = rdfList(Namespace('https://w3id.org/saref#').accomplishesMinTask)
    listOfaccomplishesMinTask = []

    def addaccomplishesMin (self, parameter):
        self.listOfaccomplishesMinTask.append(parameter)
        self.accomplishesMinTask = self.listOfaccomplishesMinTask
			
    controlsPropertyOnlyProperty = rdfList(Namespace('https://w3id.org/saref#').controlsPropertyOnlyProperty)
    listOfcontrolsPropertyOnlyProperty = []

    def addcontrolsPropertyOnly (self, parameter):
        self.listOfcontrolsPropertyOnlyProperty.append(parameter)
        self.controlsPropertyOnlyProperty = self.listOfcontrolsPropertyOnlyProperty
			
    hasStateOnlyState = rdfList(Namespace('https://w3id.org/saref#').hasStateOnlyState)
    listOfhasStateOnlyState = []

    def addhasStateOnly (self, parameter):
        self.listOfhasStateOnlyState.append(parameter)
        self.hasStateOnlyState = self.listOfhasStateOnlyState
			
    makesMeasurementOnlyMeasurement = rdfList(Namespace('https://w3id.org/saref#').makesMeasurementOnlyMeasurement)
    listOfmakesMeasurementOnlyMeasurement = []

    def addmakesMeasurementOnly (self, parameter):
        self.listOfmakesMeasurementOnlyMeasurement.append(parameter)
        self.makesMeasurementOnlyMeasurement = self.listOfmakesMeasurementOnlyMeasurement
			
    isUsedForOnlyCommodity = rdfList(Namespace('https://w3id.org/saref#').isUsedForOnlyCommodity)
    listOfisUsedForOnlyCommodity = []

    def addisUsedForOnly (self, parameter):
        self.listOfisUsedForOnlyCommodity.append(parameter)
        self.isUsedForOnlyCommodity = self.listOfisUsedForOnlyCommodity
			
    hasFunctionMinFunction = rdfList(Namespace('https://w3id.org/saref#').hasFunctionMinFunction)
    listOfhasFunctionMinFunction = []

    def addhasFunctionMin (self, parameter):
        self.listOfhasFunctionMinFunction.append(parameter)
        self.hasFunctionMinFunction = self.listOfhasFunctionMinFunction
			
    hasProfileOnlyProfile = rdfList(Namespace('https://w3id.org/saref#').hasProfileOnlyProfile)
    listOfhasProfileOnlyProfile = []

    def addhasProfileOnly (self, parameter):
        self.listOfhasProfileOnlyProfile.append(parameter)
        self.hasProfileOnlyProfile = self.listOfhasProfileOnlyProfile
			
예제 #14
0
if not log.handlers:
    log.addHandler(logging.StreamHandler())
#log.setLevel(10)


Person.db = ConjunctiveGraph()


def test_start():
    assert len(Person.db) == 0
    Person(last="Cooper")
    assert len(Person.db) == 2


Person.m = rdfalchemy.rdfMultiple(FOAF.multi)
Person.l = rdfalchemy.rdfList(FOAF.list)
Person.c = rdfalchemy.rdfContainer(FOAF.seq)


def test_multi():
    p = Person.ClassInstances().next()
    p.m = [1, 2.2, 0, 'a', '', 'c']
    assert len(Person.db) == 8

    p.m = ['a', 'b', 'c']
    assert len(Person.db) == 5


def test_list():
    # set and reset a list
    p = Person.ClassInstances().next()