예제 #1
0
class PersonnelAgent(Parser):
    schema = tools.GuessAgentType(
        tools.RunPython('combine_first_last_name', ctx))

    name = tools.RunPython('combine_first_last_name', ctx)
    location = tools.RunPython('get_address', ctx['Contact_Address'])

    class Extra:
        role = tools.Try(ctx.Role)
        url = tools.Try(ctx.Data_Center_URL)

    def combine_first_last_name(self, ctx):
        return ctx['First_Name'] + ' ' + ctx['Last_Name']

    def get_address(self, ctx):
        address = ctx['Address']
        if isinstance(address, list):
            address1 = address[0]
            address2 = address[1]
            return format_address(address1=address1,
                                  address2=address2,
                                  city=ctx['City'],
                                  state_or_province=ctx['Province_or_State'],
                                  postal_code=ctx['Postal_Code'],
                                  country=ctx['Country'])

        return format_address(address1=ctx['Address'],
                              address2=address2,
                              city=ctx['City'],
                              state_or_province=ctx['Province_or_State'],
                              postal_code=ctx['Postal_Code'],
                              country=ctx['Country'])
예제 #2
0
class FunderAgent(Parser):
    schema = tools.GuessAgentType(tools.OneOf(ctx.funderName,
                                              ctx.contributorName),
                                  default='organization')

    name = tools.OneOf(ctx.funderName, ctx.contributorName)

    identifiers = tools.Map(
        tools.Delegate(AgentIdentifier),
        tools.Try(tools.IRI(
            tools.OneOf(ctx.funderIdentifier,
                        tools.RunPython(force_text, ctx.nameIdentifier),
                        tools.Static(None))),
                  exceptions=(ValueError, )))

    class Extra:
        name_identifier = tools.Try(ctx.nameIdentifier)
        name_identifier_scheme = tools.Try(
            ctx.nameIdentifier['@nameIdentifierScheme'])
        name_identifier_scheme_uri = tools.Try(
            ctx.nameIdentifier['@schemeURI'])

        funder_identifier = tools.Try(ctx.funderIdentifier)
        funder_identifier_type = tools.Try(ctx.funderIdentifierType)

        contributor_type = tools.Try(ctx.contributorType)
예제 #3
0
파일: v1_push.py 프로젝트: sheriefvt/SHARE
class FundingAgent(Parser):
    schema = tools.GuessAgentType(ctx.sponsorName, default='organization')

    name = ctx.sponsorName

    identifiers = tools.Map(tools.Delegate(AgentIdentifier),
                            tools.IRI(tools.Try(ctx.sponsorIdentifier)))
예제 #4
0
class DataCenterAgent(Parser):
    schema = tools.GuessAgentType(ctx.Data_Center_Name.Long_Name,
                                  default='organization')

    name = ctx.Data_Center_Name.Long_Name
    related_agents = tools.Map(tools.Delegate(IsAffiliatedWith),
                               tools.Try(ctx.Personnel))

    class Extra:
        data_center_short_name = ctx.Data_Center_Name.Short_Name
예제 #5
0
class AffiliatedAgent(Parser):
    schema = tools.GuessAgentType(ctx.awardeeName, default='organization')

    name = ctx.awardeeName
    location = tools.Join(tools.Concat(ctx.awardeeCity,
                                       tools.Try(ctx.awardeeStateCode)),
                          joiner=', ')

    class Extra:
        awardee_city = ctx.awardeeCity
        awardee_state_code = tools.Try(ctx.awardeeStateCode)
예제 #6
0
class Organization(Parser):
    schema = tools.GuessAgentType(ctx)

    name = tools.RunPython('get_name', ctx)
    location = tools.RunPython('get_location', ctx)

    def get_name(self, context):
        return context.split(',')[0]

    def get_location(self, context):
        spl = context.partition(',')
        if len(spl) > 1:
            return spl[-1]
        return None
예제 #7
0
class ContributorAgent(Parser):
    schema = tools.OneOf(
        tools.GuessAgentType(tools.RunPython(get_agent_type, ctx,
                                             person=False),
                             default='organization'),
        tools.GuessAgentType(tools.OneOf(ctx.creatorName,
                                         ctx.contributorName)))

    name = tools.OneOf(ctx.creatorName, ctx.contributorName)
    identifiers = tools.Map(
        tools.Delegate(AgentIdentifier),
        tools.Try(tools.IRI(tools.RunPython(force_text, ctx.nameIdentifier)),
                  exceptions=(ValueError, )))
    related_agents = tools.Map(
        tools.Delegate(IsAffiliatedWith),
        tools.Concat(
            tools.Try(
                tools.Filter(lambda x: bool(x),
                             tools.RunPython(force_text, ctx.affiliation)))))

    class Extra:
        name_identifier = tools.Try(ctx.nameIdentifier)
        name_identifier_scheme = tools.Try(
            ctx.nameIdentifier['@nameIdentifierScheme'])
        name_identifier_scheme_uri = tools.Try(
            ctx.nameIdentifier['@schemeURI'])

        contributor_type = tools.Try(ctx.contributorType)

        # v.4 new givenName and familyName properties
        given_name = tools.OneOf(ctx.creatorName['@givenName'],
                                 ctx.contributorName['@givenName'],
                                 tools.Static(None))
        family_name = tools.OneOf(ctx.creatorName['@familyName'],
                                  ctx.contributorName['@familyName'],
                                  tools.Static(None))
예제 #8
0
파일: v1_push.py 프로젝트: sheriefvt/SHARE
class Agent(Parser):
    schema = tools.GuessAgentType(ctx.name)

    name = ctx.name

    related_agents = tools.Map(tools.Delegate(IsAffiliatedWith),
                               tools.Try(ctx.affiliation))

    identifiers = tools.Map(
        tools.Delegate(AgentIdentifier),
        tools.Map(tools.IRI(), tools.Try(ctx.sameAs), tools.Try(ctx.email)))

    class Extra:
        givenName = tools.Try(ctx.givenName)
        familyName = tools.Try(ctx.familyName)
        additonalName = tools.Try(ctx.additionalName)
        name = tools.Try(ctx.name)
예제 #9
0
파일: oai.py 프로젝트: alexschiller/SHARE
class OAIPublisher(Parser):
    schema = 'Publisher'

    agent = tools.Delegate(
        OAIAgent.using(
            schema=tools.GuessAgentType(ctx, default='organization')), ctx)
예제 #10
0
파일: oai.py 프로젝트: alexschiller/SHARE
class OAIAgent(Parser):
    schema = tools.GuessAgentType(ctx)

    name = ctx
예제 #11
0
class FunderAgent(Parser):
    schema = tools.GuessAgentType(ctx.agency, default='organization')

    name = ctx.agency
예제 #12
0
class Organization(Parser):
    schema = tools.GuessAgentType(ctx, default='Organization')
    name = ctx
예제 #13
0
class PublisherAgent(Parser):
    schema = tools.GuessAgentType(ctx, default='organization')

    name = ctx
예제 #14
0
class AffiliatedAgent(Parser):
    schema = tools.GuessAgentType(ctx, default='organization')

    name = ctx
예제 #15
0
파일: v1_push.py 프로젝트: sheriefvt/SHARE
class OrgAgent(Agent):
    schema = tools.GuessAgentType(ctx.name, default='organization')