32 lines
903 B
Python
32 lines
903 B
Python
import db
|
|
from sqlalchemy.orm import Session
|
|
|
|
|
|
def get_branch(bndname: str, scheme: str):
|
|
conn = db.connect_db()
|
|
with Session(conn) as session:
|
|
item = session.query(db.IncomeBranch).filter_by(scheme=scheme).join(db.User).filter_by(bndname=bndname).one_or_none()
|
|
if item:
|
|
return item.branch
|
|
return None
|
|
|
|
|
|
def is_replication_scheme(bndname: str, scheme: str):
|
|
conn = db.connect_db()
|
|
with Session(conn) as session:
|
|
item = session.query(db.User).filter_by(bndname=bndname).one_or_none()
|
|
if not item:
|
|
return False
|
|
profiles = {x.scheme: x.to_dict() for x in item.profiles}
|
|
if len(profiles) == 0 or scheme in profiles:
|
|
return True
|
|
return False
|
|
|
|
|
|
def main():
|
|
# print(get_branch('bnd128', 'ood'))
|
|
print(is_replication_scheme('bnd128', 'documents_src'))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main() |