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
2 changes: 1 addition & 1 deletion odml/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def datetime_set(value):
def boolean_get(string):
if string is None:
return None
if isinstance(string, unicode):
if type(string) in (unicode, str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use isinstance() with a tuple as second argument. No need to switch to type()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since type(sthg) is used for nearly every comparable check in odml/dtypes.py i'd rather keep it consistent for now and change all type checks to isinstance checks in one go.

Copy link
Member

@achilleas-k achilleas-k Feb 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough.
Opened issue #226 as a reminder to fix this.

string = string.lower()
truth = ["true", "1", True, "t"] # be kind, spec only accepts True / False
if string in truth:
Expand Down
20 changes: 19 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,25 @@
from setuptools import setup
except ImportError as ex:
from distutils.core import setup
from odml.info import AUTHOR, CONTACT, CLASSIFIERS, HOMEPAGE, VERSION

try:
from odml.info import AUTHOR, CONTACT, CLASSIFIERS, HOMEPAGE, VERSION
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I see it, perhaps it's better to just do the except block and not try to import.

I wonder if it's possible to end up in a situation where the setup imports an exiting installation that has a different version number.

Since the parsing code is there, might as well, right?

except ImportError as ex:
# Read the information from odml.info.py if package dependencies
# are not yet available during a local install.
CLASSIFIERS = ""
with open('odml/info.py') as f:
for line in f:
curr_args = line.split(" = ")
if len(curr_args) == 2:
if curr_args[0] == "AUTHOR":
AUTHOR = curr_args[1].replace('\'', '').replace('\\', '').strip()
elif curr_args[0] == "CONTACT":
CONTACT = curr_args[1].replace('\'', '').strip()
elif curr_args[0] == "HOMEPAGE":
HOMEPAGE = curr_args[1].replace('\'', '').strip()
elif curr_args[0] == "VERSION":
VERSION = curr_args[1].replace('\'', '').strip()

packages = [
'odml',
Expand Down