-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
106 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
import os | ||
import sys | ||
from typing import Optional | ||
import typer | ||
from database_conn import * | ||
from arango import ArangoClient | ||
from pyramid.paster import get_appsettings, setup_logging | ||
from quranref.__init__ import load_project_settings, do_config | ||
|
||
def usage(argv): | ||
cmd = os.path.basename(argv[0]) | ||
print(('usage: %s <config_uri>\n' | ||
'(example: "%s development.ini")' % (cmd, cmd))) | ||
sys.exit(1) | ||
|
||
def _get_graph(): | ||
from quranref.graph_models import gdb | ||
from quranref.graph_models.quran_graph import QuranGraph | ||
graph = QuranGraph(connection=gdb) | ||
|
||
return gdb, QuranGraph, graph | ||
|
||
def create_graph(): | ||
gdb, _, graph = _get_graph() | ||
gdb.create_graph(graph) | ||
|
||
app = typer.Typer() | ||
quranref_app = typer.Typer() | ||
app.add_typer(quranref_app, name="quranref") | ||
|
||
""" | ||
@app.command() | ||
def add(name:str, key:str): | ||
if name: | ||
try: | ||
doc = ayasCollection.createDocument() | ||
doc["name"] = name | ||
doc._key = key | ||
doc.save() | ||
print("Saved") | ||
#typer.echo(f"Hello {name}") | ||
except: | ||
print("ERROR") | ||
else: | ||
print("Please Insert Correctly") | ||
#typer.echo("Thanks") | ||
""" | ||
|
||
|
||
@app.command() | ||
def getbynumber(number:int): | ||
aql="FOR a IN ayas FILTER a.aya_number == %s RETURN a" %(number) | ||
#print(aql) | ||
queryRes = db.AQLQuery(aql,rawResults=True, batchSize=100) | ||
print("HERE I AM") | ||
for key in queryRes: | ||
print(key) | ||
|
||
@app.command() | ||
def showall(): | ||
aql="FOR a IN ayas RETURN a" | ||
queryRes = db.AQLQuery(aql,rawResults=True, batchSize=100) | ||
for key in queryRes: | ||
print(key) | ||
|
||
@quranref_app.command("populate") | ||
def populate(val:str): | ||
client = ArangoClient() | ||
dbb = client.db('quranref',username='kashif',password='compulife') | ||
if db.has_graph('quran_graph'): | ||
quran_graph = db.graph('quran_graph') | ||
else: | ||
quran_graph = db.create_graph('quran_graph') | ||
|
||
load_project_settings() | ||
|
||
# create_graph() | ||
gdb, QuranGraph, _ = _get_graph() | ||
db_objects = [QuranGraph] | ||
gdb.create_all(db_objects) | ||
gdb, QuranGraph, _ = _get_graph() | ||
db_objects = [QuranGraph] | ||
print(db_objects) | ||
gdb.create_all(db_objects) | ||
print(quran_graph.name) | ||
print(quran_graph.db_name) | ||
print(quran_graph.vertex_collections()) | ||
print(quran_graph.edge_definitions()) | ||
#print(dbb.graphs()); | ||
#gdb, QuranGraph,_= _get_graph() | ||
#db_objects = [QuranGraph] | ||
#print(gdb.graphs['Surah']) | ||
print("quranref.scripts.populate:main") | ||
|
||
|
||
if __name__=="__main__": | ||
app() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters