Skip to content

Commit

Permalink
Clenaup unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
Andre Senna committed Oct 8, 2022
1 parent f0579d1 commit 6482f33
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 624 deletions.
16 changes: 7 additions & 9 deletions das/database/couch_mongo_db_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,21 @@
from couchbase.auth import PasswordAuthenticator
from couchbase.bucket import Bucket
from couchbase.cluster import Cluster
from pymongo import MongoClient as MongoDBClient

from das.helpers import get_mongodb
from das.database.db_interface import DBInterface
from das.database.couch_mongo_db import CouchMongoDB
from das.database.couchbase_schema import CollectionNames as CouchbaseCollectionNames
from das.database.mongo_schema import CollectionNames as MongoCollectionNames, FieldNames as MongoFieldNames

@pytest.fixture()
def mongo_db():
mongodb_specs = {
"hostname": "mongo",
"port": 27017,
"username": "dbadmin",
"password": "dassecret",
"database": "das",
}
return get_mongodb(mongodb_specs)
hostname = os.environ.get('DAS_MONGODB_HOSTNAME')
port = os.environ.get('DAS_MONGODB_PORT')
username = os.environ.get('DAS_DATABASE_USERNAME')
password = os.environ.get('DAS_DATABASE_PASSWORD')
mongo_db = MongoDBClient(f'mongodb://{username}:{password}@{hostname}:{port}')['das']
return mongo_db


@pytest.fixture()
Expand Down
56 changes: 56 additions & 0 deletions das/expression.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import json
from typing import Optional, List, Any
from dataclasses import dataclass

@dataclass
class Expression:

#TODO: Implement non-ordered
toplevel: bool = False
ordered: bool = True
terminal_name: Optional[str] = None
typedef_name: Optional[str] = None
typedef_name_hash: Optional[str] = None
symbol_name: Optional[str] = None
named_type: Optional[str] = None
named_type_hash: Optional[str] = None
composite_type: Optional[List[Any]] = None
composite_type_hash: Optional[str] = None
elements: Optional[List[str]] = None
hash_code: Optional[str] = None

def __hash__(self):
return hash(self.hash_code)

def to_dict(self):
assert(self.ordered)
answer = {
"_id": self.hash_code,
"composite_type_hash": self.composite_type_hash
}
if self.typedef_name is not None:
# expression is a typedef
answer["named_type"] = self.typedef_name
answer["named_type_hash"] = self.typedef_name_hash
elif self.terminal_name is not None:
# expression is a terminal
answer["name"] = self.terminal_name
answer["named_type"] = self.named_type
else:
# expression is a regular expression
answer["is_toplevel"] = self.toplevel
answer["composite_type"] = self.composite_type
answer["named_type"] = self.named_type
answer["named_type_hash"] = self.named_type_hash
arity = len(self.elements)
assert arity > 0
if arity > 2:
answer["keys"] = self.elements
else:
answer["key_0"] = self.elements[0]
if arity > 1:
answer["key_1"] = self.elements[1]
return answer

def to_json(self):
return json.dumps(self.to_dict(), sort_keys=False, indent=4)
99 changes: 0 additions & 99 deletions das/helpers.py

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion das/metta_lex_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from das.my_metta_lex import MettaLex
from das.metta_lex import MettaLex

lex_test_data = """
(: Evaluation Type)
Expand Down
2 changes: 1 addition & 1 deletion das/metta_yacc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

from typing import List, Any, Optional
import ply.yacc as yacc
from das.my_metta_lex import MettaLex
from das.metta_lex import MettaLex
from das.exceptions import MettaSyntaxError, UndefinedSymbolError
from das.expression_hasher import ExpressionHasher
from das.expression import Expression
Expand Down
2 changes: 1 addition & 1 deletion das/metta_yacc_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from das.my_metta_lex import MettaLex
from das.metta_lex import MettaLex
from das.metta_lex_test import lex_test_data as test_data
from das.metta_yacc import MettaYacc, Expression
from das.metta_parser_actions import MettaParserActions
Expand Down
82 changes: 0 additions & 82 deletions das/query.py

This file was deleted.

Loading

0 comments on commit 6482f33

Please sign in to comment.