Skip to content
This repository has been archived by the owner on Jan 11, 2022. It is now read-only.

Commit

Permalink
Additional use six library and import some future stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
Domme, Sergej committed Sep 10, 2015
1 parent 10e078a commit 608c180
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
1 change: 1 addition & 0 deletions build.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
@init
def set_properties(project):
project.depends_on("PyYAML")
project.depends_on("six")

project.set_property('distutils_console_scripts', ['yamlreader=yamlreader:__main'])

Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[bdist_rpm]
requires = python >= 2.6 PyYAML python-setuptools
requires = python >= 2.6 PyYAML python-setuptools python-six
release = ${rpm_release}

3 changes: 2 additions & 1 deletion src/main/python/yamlreader/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import print_function, absolute_import, unicode_literals, division

from .yamlreader import data_merge, yaml_load, YamlReaderError

__all__ = ['data_merge', 'yaml_load', 'YamlReaderError']
9 changes: 6 additions & 3 deletions src/main/python/yamlreader/yamlreader.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from __future__ import print_function, absolute_import, unicode_literals, division

__all__ = ["YamlReaderError", "yaml_load"]
__version__ = "3.0.1"

from yaml import MarkedYAMLError, safe_load, safe_dump
import glob
import os
import logging
import six


class NoDefault(object):
Expand All @@ -29,7 +32,7 @@ def data_merge(a, b):
# ## debug output
# sys.stderr.write("DEBUG: %s to %s\n" %(b,a))
try:
if a is None or isinstance(a, (str, unicode, int, long, float)):
if a is None or isinstance(a, (six.string_types, float, six.integer_types)):
# border case for first run or if a is a primitive
a = b
elif isinstance(a, list):
Expand Down Expand Up @@ -137,8 +140,8 @@ def __main():
if not args:
parser.error("Need at least one argument")
try:
print safe_dump(yaml_load(args, defaultdata={}),
indent=4, default_flow_style=False, canonical=False)
print(safe_dump(yaml_load(args, defaultdata={}),
indent=4, default_flow_style=False, canonical=False))
except Exception as e:
parser.error(e)

Expand Down
2 changes: 2 additions & 0 deletions src/unittest/python/yamlreader_tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import print_function, absolute_import, unicode_literals, division

import unittest
import logging
from yamlreader import data_merge, yaml_load, YamlReaderError
Expand Down

0 comments on commit 608c180

Please sign in to comment.