Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 1 addition & 30 deletions augur/application/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import List, Any, Optional
import os
from augur.application.db.models import Config
from augur.application.db.util import execute_session_query
from augur.application.db.util import execute_session_query, convert_type_of_value

def get_development_flag_from_config():

Expand Down Expand Up @@ -109,35 +109,6 @@ def get_development_flag():
}


def convert_type_of_value(config_dict, logger=None):

data_type = config_dict["type"]

if data_type == "str" or data_type is None:
return config_dict

elif data_type == "int":
config_dict["value"] = int(config_dict["value"])

elif data_type == "bool":
value = config_dict["value"]

if value.lower() == "false":
config_dict["value"] = False
else:
config_dict["value"] = True

elif data_type == "float":
config_dict["value"] = float(config_dict["value"])

else:
if logger:
logger.error(f"Need to add support for {data_type} types to config")
else:
print(f"Need to add support for {data_type} types to config")

return config_dict

class AugurConfig():

from augur.application.db.session import DatabaseSession
Expand Down
32 changes: 1 addition & 31 deletions augur/application/db/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,11 @@
from augur.application.db.models import Config, Repo, Commit, WorkerOauth, Issue, PullRequest, PullRequestReview, ContributorsAlias,UnresolvedCommitEmail, Contributor, CollectionStatus, UserGroup, RepoGroup
from augur.tasks.util.collection_state import CollectionState
from augur.application.db import get_session, get_engine
from augur.application.db.util import execute_session_query
from augur.application.db.util import execute_session_query, convert_type_of_value
from augur.application.db.session import remove_duplicates_by_uniques, remove_null_characters_from_list_of_dicts

logger = logging.getLogger("db_lib")

def convert_type_of_value(config_dict, logger=None):


data_type = config_dict["type"]

if data_type == "str" or data_type is None:
return config_dict

if data_type == "int":
config_dict["value"] = int(config_dict["value"])

elif data_type == "bool":
value = config_dict["value"]

if value.lower() == "false":
config_dict["value"] = False
else:
config_dict["value"] = True

elif data_type == "float":
config_dict["value"] = float(config_dict["value"])

else:
if logger:
logger.error(f"Need to add support for {data_type} types to config")
else:
print(f"Need to add support for {data_type} types to config")

return config_dict


def get_section(section_name) -> dict:
"""Get a section of data from the config.
Expand Down
30 changes: 30 additions & 0 deletions augur/application/db/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,33 @@ def convert_orm_list_to_dict_list(result):

return new_list



def convert_type_of_value(config_dict, logger=None):

data_type = config_dict["type"]

if data_type == "str" or data_type is None:
return config_dict

elif data_type == "int":
config_dict["value"] = int(config_dict["value"])

elif data_type == "bool":
value = config_dict["value"]

if value.lower() == "false":
config_dict["value"] = False
else:
config_dict["value"] = True

elif data_type == "float":
config_dict["value"] = float(config_dict["value"])

else:
if logger:
logger.error(f"Need to add support for {data_type} types to config")
else:
print(f"Need to add support for {data_type} types to config")

return config_dict
2 changes: 1 addition & 1 deletion augur/application/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ def get_all_repos_count(**kwargs):

result = controller.get_repo_count(source="all", **kwargs)

return result
return result
Loading