Exemple #1
0
from urllib.parse import urlparse
import yaml
import idlib
import rdflib
import ontquery as oq
import augpathlib as aug
from ttlser import CustomTurtleSerializer
from pyontutils.core import OntGraph, OntTerm, OntResGit, OntResIri
from pyontutils.utils import Async, deferred, log
from pyontutils.config import auth
from pyontutils.identity_bnode import IdentityBNode
from pyontutils.namespaces import (TEMP, ILX, ilx, rdf, rdfs, owl, ilxtr,
                                   npokb, OntCuries)

log = log.getChild('sneechenator')

snchn = rdflib.Namespace('https://uilx.org/sneechenator/u/r/')
sncho = rdflib.Namespace('https://uilx.org/sneechenator/o/u/')
# ontology hash resolver w/ filter by group
sghashes = rdflib.Namespace('https://uilx.org/sneechenator/o/h/')
_tc = (snchn.IndexGraph, snchn.PartialIndexGraph)
CustomTurtleSerializer.addTopClasses(*_tc)
OntGraph.metadata_type_markers.extend(_tc)  # FIXME naming

IXR = oq.plugin.get('InterLex')
rdfl = oq.plugin.get('rdflib')
ixr = IXR()
ixr.port = None  # FIXME hack
# really need a way to override if this changes things during __init__
# luckily it doesn't right now so we can switch the query endpoint
Exemple #2
0
# alt id mapped to more than one SRC id
# garbage in the alt id field

import os
from pathlib import Path
from datetime import date

import rdflib
from docopt import parse_defaults
from sqlalchemy import create_engine, inspect
from pyontutils.core import Ont, Source, build, OntId
from pyontutils.utils import mysql_conn_helper, log
from pyontutils.namespaces import makePrefixes, NIFRID, definition
from pyontutils.namespaces import rdf, rdfs, owl, oboInOwl

log = log.getChild('registry-sync')
logd = log.getChild('data')

defaults = {
    o.name: o.value if o.argcount else None
    for o in parse_defaults(__doc__)
}

_remap_supers = {
    'Resource':
    'NIFSTD:nlx_63400',  # FIXME do not want to use : but broken because of defaulting to add : to all scr ids (can fix just not quite yet)
    'Commercial Organization': OntId('NIFSTD:nlx_152342'),
    'Organization': OntId('NIFSTD:nlx_152328'),
    'University': OntId('NIFSTD:NEMO_0569000'),  # UWOTM8
    'Institution': OntId('NIFSTD:birnlex_2085'),
    'Institute': OntId('NIFSTD:SIO_000688'),
Exemple #3
0
import itertools
from pathlib import Path
from urllib.parse import urlparse
import idlib
import htmlfn as hfn
from terminaltables import AsciiTable
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
from pyontutils.utils import byCol, log as _log
from pyontutils.config import auth
from pyontutils.clifun import python_identifier

# TODO decouple oauth group sheets library

log = _log.getChild('sheets')

CELL_DID_NOT_EXIST = type('CellDidNotExist', (object,), {})()
CELL_REMOVED = type('CellRemoved', (object,), {})()  # FIXME this is ... bad? or is IndexError worse?


def _FakeService():
    """ use if you need a fake service from build """

    class e:
        execute = lambda : {'sheets':[],}
    class v:
        def get(range=None):
            return []
    class g:
        def get(spreadsheetId=None, includeGridData=None, range=None):
Exemple #4
0
                              values: appdata
                                      file
                                      metadata
                                      metadata.readonly
                                      photos.readonly
                                      readonly
                                      scripts
    -d --debug
"""

import sys
from pyontutils.utils import log
from pyontutils.clifun import Dispatcher, Options as BaseOptions
from pyontutils.sheets import _get_oauth_service

log = log.getChild('googapis')


class Options(BaseOptions):
    drive_scopes = (
        'appdata',
        'file',
        'metadata',
        'metadata.readonly',
        'photos.readonly',
        'readonly',
        'scripts',)

    def __new__(cls, args, defaults):
        bads = []
        for scope in args['--drive-scope']: