Skip to content

Commit

Permalink
Replace AttrDict with addict
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonscript committed Mar 27, 2021
1 parent 6f77cf9 commit 0c4f1a5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
16 changes: 9 additions & 7 deletions fylm/fylmlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
from datetime import timedelta
from yaml import Loader, SafeLoader

from attrdict import AttrMap
from addict import Dict
import requests_cache

def construct_yaml_str(self, node):
Expand Down Expand Up @@ -76,9 +76,11 @@ def __init__(self):
# TODO: Perhaps we can improve this fragile hack using __future__?
config_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'config.yaml')

# Load the config file and map it to a 'AttrMap', a dot-notated dictionary.
# Load the config file and map it to a 'Dict', a dot-notated dictionary.
self._defaults = Dict({})
with codecs.open(config_path, encoding='utf-8') as yaml_config_file:
self._defaults = AttrMap(yaml.safe_load(yaml_config_file.read()), sequence_type=list)
self._defaults.update(Dict(yaml.safe_load(
yaml_config_file.read()), sequence_type=list))

# Initialize the CLI argument parser.
parser = argparse.ArgumentParser(description = 'A delightful filing and renaming app for film lovers.')
Expand Down Expand Up @@ -264,12 +266,12 @@ def __init__(self):
args, _ = parser.parse_known_args()

# Re-map any deeply nested arguments
args.tmdb = AttrMap({'min_popularity': args.tmdb__min_popularity})
args.tmdb = Dict({'min_popularity': args.tmdb__min_popularity})

# Re-map arg values onto known options already loaded from config.yaml.
self._defaults = self._defaults + AttrMap(vars(args))
self._defaults.update(Dict(vars(args)))

# Supress console if no_console is true.
# Supress console if no_console is true.
if self._defaults.no_console is True:
sys.stdout = None

Expand Down Expand Up @@ -297,7 +299,7 @@ def __init__(self):
requests_cache.core.remove_expired_responses()

for k, v in self._defaults.items():
setattr(self, k, AttrMap(v) if isinstance(v, dict) else v)
setattr(self, k, Dict(v) if isinstance(v, dict) else v)
del self._defaults

def reload(self):
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
future>=0.16.0
pyyaml>=4.2b4
ansicolors>=1.1.8
git+git://github.com/brandonscript/AttrDict
addict>=2.4.0
requests-cache>=0.4.13
tmdbsimple>=2.1.0
PlexAPI
Expand Down

0 comments on commit 0c4f1a5

Please sign in to comment.