Unverified Commit 5baef28e by Peter Weidenbach Committed by GitHub

Merge pull request #2 from fkie-cad/removing_deprecated_function

Removing deprecated function
parents 3d7db864 dae5dd02
[settings]
line_length=120
default_section = THIRDPARTY
multi_line_output=6
default_stages: [commit, push]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.2.3
hooks:
- id: check-added-large-files
args: [--maxkb=10000]
- id: check-json
- id: check-merge-conflict
- id: check-yaml
- id: end-of-file-fixer
types: [python]
- id: fix-encoding-pragma
args: [--remove]
- id: flake8
args: [--ignore="E501,W503", --select=W504]
- id: forbid-new-submodules
- id: no-commit-to-branch
- id: pretty-format-json
args: [--autofix]
- id: trailing-whitespace
types: [python]
- repo: https://github.com/pre-commit/mirrors-pylint
rev: v2.3.1
hooks:
- id: pylint
language: system
args: [--rcfile=.pylintrc]
- repo: https://github.com/jumanjihouse/pre-commit-hooks
rev: 1.11.0
hooks:
- id: shellcheck
- repo: https://github.com/pryorda/dockerfilelint-precommit-hooks
rev: v0.1.0
hooks:
- id: dockerfilelint
- repo: https://github.com/pre-commit/mirrors-jshint
rev: v2.10.2
hooks:
- id: jshint
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.20
hooks:
- id: isort
This diff is collapsed. Click to expand it.
...@@ -13,7 +13,7 @@ install: ...@@ -13,7 +13,7 @@ install:
- "sudo apt-get install -y mongodb-org" - "sudo apt-get install -y mongodb-org"
- "sudo service mongod start" - "sudo service mongod start"
- "python setup.py -q install" - "python setup.py -q install"
- "pip install --upgrade pytest pytest-pep8 pytest-cov codecov" - "pip install --upgrade pytest pytest-flake8 pytest-cov codecov"
# command to run tests # command to run tests
script: "pytest --cov-config .coveragerc --cov=./" script: "pytest --cov-config .coveragerc --cov=./"
after_success: after_success:
......
from .aggregate import (
get_field_average, get_field_execute_operation, get_field_sum, get_list_of_all_values,
get_objects_and_count_of_occurrence
)
from .gridfs import overwrite_file from .gridfs import overwrite_file
from .aggregate import get_objects_and_count_of_occurrence, get_field_average, get_field_sum, get_field_execute_operation, get_list_of_all_values, get_list_of_all_values_and_collect_information_of_additional_field
__all__ = [ __all__ = [
'overwrite_file', 'overwrite_file',
...@@ -8,5 +11,4 @@ __all__ = [ ...@@ -8,5 +11,4 @@ __all__ = [
'get_field_sum', 'get_field_sum',
'get_field_execute_operation', 'get_field_execute_operation',
'get_list_of_all_values', 'get_list_of_all_values',
'get_list_of_all_values_and_collect_information_of_additional_field'
] ]
...@@ -2,7 +2,6 @@ import logging ...@@ -2,7 +2,6 @@ import logging
from typing import List, Optional from typing import List, Optional
from bson.son import SON from bson.son import SON
from pymongo.command_cursor import CommandCursor
def get_list_of_all_values(collection, object_path, unwind=False, match=None): def get_list_of_all_values(collection, object_path, unwind=False, match=None):
...@@ -27,28 +26,6 @@ def get_list_of_all_values(collection, object_path, unwind=False, match=None): ...@@ -27,28 +26,6 @@ def get_list_of_all_values(collection, object_path, unwind=False, match=None):
return result return result
def get_list_of_all_values_and_collect_information_of_additional_field(
collection, object_path, additional_information_object_path, unwind=False, match=None):
'''
Get a list of unique values and a collection of additional information on a specific object path in a collection.
An Optional search string (match) can be added.
:param collection: mongo collection to look at
:type collection: pymongo.collection.Collection
:param object_path: mongo object path
:type object_path: str
:param additional_information_object_path: field of the additional information
:type additional_information_object_path: str
:param unwind: if true: handle list entries as single values
:type unwind: bool
:param match: mongo search string
:type match: dict, optional
:return: {<VALUE>:[<ADDITIONAL_INFORMATION_1>, ...], ...}
'''
logging.warning('deprecation warning: this method will be removed in a future release')
return get_all_value_combinations_of_fields(collection, object_path, additional_information_object_path, unwind, match)
def get_all_value_combinations_of_fields(collection, primary_field, secondary_field, unwind=False, match=None): def get_all_value_combinations_of_fields(collection, primary_field, secondary_field, unwind=False, match=None):
''' '''
Get a dictionary with all unique values of a field as keys and a list of all unique values that a second field takes Get a dictionary with all unique values of a field as keys and a list of all unique values that a second field takes
......
[pytest] [pytest]
addopts = --pep8 -v addopts = --flake8 -v
pep8ignore = flake8-ignore =
*.py E501 *.py E501 W503
flake8-select =
*.py W504
from common_helper_mongo.aggregate import ( from common_helper_mongo.aggregate import (
get_all_value_combinations_of_fields, get_field_average, get_field_sum, get_list_of_all_values, get_all_value_combinations_of_fields, get_field_average, get_field_sum, get_list_of_all_values,
get_list_of_all_values_and_collect_information_of_additional_field, get_objects_and_count_of_occurrence, get_objects_and_count_of_occurrence
) )
from tests.base_class_database_test import MongoDbTest from tests.base_class_database_test import MongoDbTest
...@@ -81,9 +81,3 @@ class TestAggregate(MongoDbTest): ...@@ -81,9 +81,3 @@ class TestAggregate(MongoDbTest):
def test_get_field_execute_operation_empty(self): def test_get_field_execute_operation_empty(self):
result = get_field_sum(self.test_collection, "$test_int") result = get_field_sum(self.test_collection, "$test_int")
self.assertEqual(result, 0) self.assertEqual(result, 0)
def test_get_list_of_all_values_and_collect_information_of_additional_field(self):
self.add_list_test_data()
with self.assertLogs() as logger:
get_list_of_all_values_and_collect_information_of_additional_field(self.test_collection, "$test_list", "$_id", unwind=True)
assert 'deprecation warning' in logger.output.pop()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment