Skip to content

Commit

Permalink
Add some doc stub
Browse files Browse the repository at this point in the history
  • Loading branch information
cnheider committed Apr 12, 2020
1 parent cc374c0 commit 876b40e
Show file tree
Hide file tree
Showing 19 changed files with 609 additions and 104 deletions.
4 changes: 2 additions & 2 deletions .github/images/warg.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
![warg](.github/images/warg.svg)

# Warg
```Old-Norse: Varg```

![warg](.github/images/warg.svg)

![python](.github/images/python.svg)

[![Build Status](https://travis-ci.com/aivclab/warg.svg?branch=master)](https://travis-ci.com/aivclab/warg
Expand Down
104 changes: 104 additions & 0 deletions warg/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@


class UpperAttrMetaclass(type):
"""
Upper case all attributes if not __private
"""

def __new__(cls, clsname, bases, dct: dict):

uppercase_attr = {}
Expand All @@ -37,10 +41,21 @@ def __new__(cls, clsname, bases, dct: dict):


class ConfigObject(object):
"""
Config object
"""

pass


def to_lower_properties(C_dict: Mapping):
"""
:param C_dict:
:type C_dict:
:return:
:rtype:
"""
if not isinstance(C_dict, dict):
C_dict = config_to_mapping(C_dict)

Expand All @@ -58,6 +73,13 @@ def to_lower_properties(C_dict: Mapping):


def lower_dict(map: Mapping) -> Mapping:
"""
:param map:
:type map:
:return:
:rtype:
"""
cop = {}
for (k, v) in map.items():
assert isinstance(k, str)
Expand All @@ -67,6 +89,13 @@ def lower_dict(map: Mapping) -> Mapping:


def upper_dict(map: Mapping) -> Mapping:
"""
:param map:
:type map:
:return:
:rtype:
"""
cop = {}
for (k, v) in map.items():
assert isinstance(k, str)
Expand All @@ -76,6 +105,15 @@ def upper_dict(map: Mapping) -> Mapping:


def get_upper_case_vars_or_protected_of(module: object, lower_keys: bool = True) -> Mapping:
"""
:param module:
:type module:
:param lower_keys:
:type lower_keys:
:return:
:rtype:
"""
v = vars(module)
check_for_duplicates_in_args(**v)
if v:
Expand All @@ -94,6 +132,15 @@ def get_upper_case_vars_or_protected_of(module: object, lower_keys: bool = True)


def config_to_mapping(C: object, only_upper_case: bool = True) -> NOD:
"""
:param C:
:type C:
:param only_upper_case:
:type only_upper_case:
:return:
:rtype:
"""
if only_upper_case:
return NOD(get_upper_case_vars_or_protected_of(C))
else:
Expand All @@ -109,6 +156,21 @@ def add_bool_arg(
default: bool = False,
**kwargs,
):
"""
:param parser:
:type parser:
:param name:
:type name:
:param dest:
:type dest:
:param converse:
:type converse:
:param default:
:type default:
:param kwargs:
:type kwargs:
"""
if not dest:
dest = name

Expand All @@ -127,6 +189,11 @@ def add_bool_arg(


def check_for_duplicates_in_args(**kwargs) -> None:
"""
:param kwargs:
:type kwargs:
"""
for key, value in kwargs.items():

occur = 0
Expand Down Expand Up @@ -154,8 +221,29 @@ def check_for_duplicates_in_args(**kwargs) -> None:


def wrap_args(n_tuple: namedtuple):
"""
:param n_tuple:
:type n_tuple:
:return:
:rtype:
"""

@wrapt.decorator(adapter=n_tuple)
def wrapper(wrapped, instance, args, kwargs):
"""
:param wrapped:
:type wrapped:
:param instance:
:type instance:
:param args:
:type args:
:param kwargs:
:type kwargs:
:return:
:rtype:
"""
if isinstance(args[0], n_tuple):
n = args[0]
else:
Expand Down Expand Up @@ -183,9 +271,25 @@ def str_to_bool(s: str, preds: Tuple[str, ...] = ("true", "1")) -> bool:

@wrap_args(c)
def add(v):
"""
:param v:
:type v:
:return:
:rtype:
"""
return v.a + v.b

def add2(a, b):
"""
:param a:
:type a:
:param b:
:type b:
:return:
:rtype:
"""
return a + b

h = add(2, 2)
Expand Down
19 changes: 19 additions & 0 deletions warg/auto_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,22 @@


def AutoDict():
"""
:return:
:rtype:
"""
return defaultdict(autodict)


def recursive_default_dict_print(d, depth=1):
"""
:param d:
:type d:
:param depth:
:type depth:
"""
for k, v in d.items():
print("-" * depth, k)
if type(v) is defaultdict:
Expand All @@ -24,6 +36,13 @@ def recursive_default_dict_print(d, depth=1):


def sanitise_auto_dict(d):
"""
:param d:
:type d:
:return:
:rtype:
"""
if isinstance(d, defaultdict):
if len(d.keys()) == 0:
return None
Expand Down
4 changes: 4 additions & 0 deletions warg/bases/property_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@


class PropertySettings:
"""
"""

def __init__(self, **kwargs):
for k, v in kwargs.items():
self.__setattr__(k, v)
Expand Down
1 change: 0 additions & 1 deletion warg/decorators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
from .caching import *
from .hashing import *
from .kw_passing import *
from .look_up_table import *
from .timing import *
11 changes: 11 additions & 0 deletions warg/decorators/caching/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

__author__ = "Christian Heider Nielsen"
__doc__ = r"""
Created on 30/03/2020
"""

from .look_up_table import *
from .property_caching import *
Loading

0 comments on commit 876b40e

Please sign in to comment.