Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_basic(self):
ns = Namespace.make("banana")
assert Namespace.make(ns) == ns
assert Namespace(b"banana") == ns
assert "banana" in repr(ns), repr(ns)
assert ns == Namespace("banana"), Namespace("banana")
def test_sign_null(self):
null = Namespace(None)
assert null.sign("split") == "split", null.sign("split")
assert null.signature("split") is None
def test_basic(self):
ns = Namespace.make("banana")
assert Namespace.make(ns) == ns
assert Namespace(b"banana") == ns
assert "banana" in repr(ns), repr(ns)
assert ns == Namespace("banana"), Namespace("banana")
def test_basic(self):
ns = Namespace.make("banana")
assert Namespace.make(ns) == ns
assert Namespace(b"banana") == ns
assert "banana" in repr(ns), repr(ns)
assert ns == Namespace("banana"), Namespace("banana")
def __init__(self, subject, canonical, judgement):
self.subject, _ = Namespace.parse(get_entity_id(subject))
self.canonical, _ = Namespace.parse(get_entity_id(canonical))
self.judgement = judgement or self.UNSURE
def __init__(self, subject, canonical, judgement):
self.subject, _ = Namespace.parse(get_entity_id(subject))
self.canonical, _ = Namespace.parse(get_entity_id(canonical))
self.judgement = judgement or self.UNSURE
def make_id(cls, subject, candidate):
subject, _ = Namespace.parse(get_entity_id(subject))
candidate, _ = Namespace.parse(get_entity_id(candidate))
return '.'.join((subject, candidate))
def by_id(cls, entity_id, collection_id=None):
entity_id, _ = Namespace.parse(entity_id)
q = cls.all()
q = q.filter(cls.id == entity_id)
return q.first()
def stream_mapping(infile, outfile, mapping_yaml, sign=True):
sources = []
config = load_mapping_file(mapping_yaml)
for dataset, meta in config.items():
for data in keys_values(meta, "queries", "query"):
query = model.make_mapping(data, key_prefix=dataset)
source = StreamSource(query, data)
sources.append((dataset, source))
try:
for record in StreamSource.read_csv(infile):
for (dataset, source) in sources:
ns = Namespace(dataset)
if source.check_filters(record):
entities = source.query.map(record)
for entity in entities.values():
if sign:
entity = ns.apply(entity)
write_object(outfile, entity)
except BrokenPipeError:
raise click.Abort()
from followthemoney import model
from followthemoney.compare import compare
from followthemoney.util import get_entity_id
from followthemoney.namespace import Namespace
from followthemoney_integrate import settings
from followthemoney_integrate.util import index_text, text_parts
log = logging.getLogger(__name__)
now = datetime.utcnow
engine = create_engine(settings.DATABASE_URI)
metadata = MetaData(bind=engine)
Session = sessionmaker(bind=engine)
Base = declarative_base(bind=engine, metadata=metadata)
Thing = model.get('Thing')
NS = Namespace(None)
DEFAULT_PRIORITY = 1.0
class Entity(Base):
id = Column(String(255), primary_key=True)
schema = Column(String(255))
origin = Column(String(255))
properties = Column(String)
context = Column(String)
search = Column(String)
priority = Column(Float, default=DEFAULT_PRIORITY)
created_at = Column(DateTime, default=now)
updated_at = Column(DateTime, default=now, onupdate=now)
@declared_attr