Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make python2 and python3 compatible #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
setup(
name="yccp",
version=".".join(map(str, __version__)),
install_requires=["PyYAML>=3.12"],
install_requires=["PyYAML>=3.12", "future"],
packages=["yccp", "yccp.cli", "yccp.sweeps"],
entry_points={
"console_scripts" : [
Expand Down
6 changes: 3 additions & 3 deletions yccp/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def __new__(mcs, name, bases, dct):
base.__name__))
del to_update[to_delete]

for k,v in to_update.iteritems():
for k,v in to_update.items():
if k in all_nonrec_updates:
updated_defaults.setdefault(k, {}).update(v)
else:
updated_defaults[k] = v
for k,v in dct.get(mcs.attr_defaults, {}).iteritems():
for k,v in dct.get(mcs.attr_defaults, {}).items():
if k in all_nonrec_updates:
updated_defaults.setdefault(k, {}).update(v)
else:
Expand Down Expand Up @@ -173,7 +173,7 @@ def _get_updated_parameters(cls, parameters):
cls, cls.__metaclass__.attr_nonrec_update, set())

# update the default parameters with whatever was proved
for k, v in copy.deepcopy(parameters).iteritems():
for k, v in copy.deepcopy(parameters).items():
if k in prms:
if isinstance(v, dict)\
and k not in not_recursively_updated_attributes:
Expand Down
7 changes: 4 additions & 3 deletions yccp/prelude.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"load",
]

from builtins import str

import numpy as np
import yaml
Expand Down Expand Up @@ -109,7 +110,7 @@ def disable(self):
def eval(self, value):
if isinstance(value, (RawExpression, RawPreludeEntry)):
value = value.expression
if not isinstance(value, basestring):
if not isinstance(value, str):
return value
eval_globals = {"np": np}
eval_locals = {
Expand Down Expand Up @@ -146,7 +147,7 @@ def __call__(self, loader, node):
yaml.add_representer(RawExpression,
lambda dumper, re: re.dump(dumper),
Dumper=YccpDumper)
yaml.add_representer(unicode, lambda dumper, value:
yaml.add_representer(str, lambda dumper, value:
dumper.represent_scalar(u'tag:yaml.org,2002:str', value),
Dumper=YccpDumper)

Expand Down Expand Up @@ -231,7 +232,7 @@ def load_data_with_prelude(obj, name_prelude=default_prelude_attr, **kwargs):
"of dictionaries".format(name_prelude_found))

for dct in prelude:
for k, v in dct.iteritems():
for k, v in dct.items():
evaluate_expression.prelude_add(
k, evaluate_expression.eval(v))

Expand Down
2 changes: 1 addition & 1 deletion yccp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def update_dict_recursively(d, u):
"""
Dictionary d with the contents from u in recursive manner.
"""
for k, v in copy.deepcopy(u).iteritems():
for k, v in copy.deepcopy(u).items():
if isinstance(v, c.Mapping):
if k in d and not isinstance(d.get(k), c.Mapping):
raise ValueError(
Expand Down