# Path: cma-es/batchcompute_python_sdk/src/batchcompute/utils/functions.py
# def partial(func, *args, **keywords):
#     def newfunc(*fargs, **fkeywords):
#         newkeywords = keywords.copy()
#         newkeywords.update(fkeywords)
#         return func(*(args + fargs), **newkeywords)
#     newfunc.func = func
#     newfunc.args = args
#     newfunc.keywords = keywords
#     return newfunc
# 
# def timestamp_datetime(value):
#     format = '%Y-%m-%d %H:%M:%S'
#     value = time.localtime(value)
#     dt = time.strftime(format, value)
#     return dt
# 
# def import_json():
#     try:
#         import json
#     except ImportError:
#         import simplejson as json
#     return json
# 
# def timediff(delta):
#     if delta:
#         t  = datetime.timedelta(seconds=delta)
#         time_day = t.days
#         s_time = t.seconds
#         ms_time = t.microseconds // 1000000
#         usedtime = int(s_time + ms_time)
#         time_hour = usedtime // 60 // 60
#         time_minute = (usedtime - time_hour * 3600 ) // 60
#         time_second =  usedtime - time_hour * 3600 - time_minute * 60
#         time_micsecond = (t.microseconds - t.microseconds // 1000000) // 1000
# 
#         tags = ['Day', 'Hour', 'Minute', 'Second']
#         time_info = {
#             'Day': time_day,
#             'Hour': time_hour,
#             'Minute': time_minute,
#             'Second': time_second
#         }
# 
#         time_list = []
#         for tag in tags:
#             if time_info[tag] > 1:
#                 new_tag = tag + 's'
#             elif time_info[tag] > 0:
#                 new_tag = tag
#             else:
#                 new_tag = None
#             if new_tag:
#                 time_list.append('%s %s' % (time_info[tag], new_tag))
#         retstr = ' '.join(time_list)
#     else:
#         retstr = '0'
#     return retstr
# 
# Path: cma-es/batchcompute_python_sdk/src/batchcompute/utils/constants.py
# STATE_MAP = [
#     'Init', 'Waiting', 'Running',
#     'Finished', 'Failed', 'Stopped'
# ]
# 
# PY2 = sys.version_info[0] == 2
# 
# PY3 = sys.version_info[0] == 3
# 
# STRING = (str, unicode)


import re
from datetime import timedelta
from .functions import partial, timestamp_datetime, import_json, timediff
from .constants import STATE_MAP, PY2, PY3, STRING
    Mainly add descriptor for each property descripted in description dict.

    e.g.:
        You can get JobId of a job status 'j' through both j.jobId and
        j.getJobId(), and the like.

    '''
    def __new__(cls, nm, parents, attrs):
        super_new = super(CamelCasedClass, cls).__new__

        tmp_dct = dict()
        for name, value in attrs.items():
            if not name.startswith('__') and not name.endswith('__'):
                tmp_dct[name] = value
        attrs.update(tmp_dct)

        # Create property for each key in `description_map` dict.
        # Besides, if `descriptor_type` is data descriptor, a `getxxx` and
        # a `setxxx` method also will be added to `cls`, if `descriptor_type`
        # is non data descriptor, only a `getxxx` method added.
        if 'descriptor_map' in attrs:
            for attr in attrs['descriptor_map']:
                # Definition of getter and setter method for properties.
                def get_attr(attr, self):
                    return self.getproperty(attr)
                def set_attr(attr, self, value):
                    self.setproperty(attr, value)

                property_name = attr
                getter = partial(get_attr, attr)

# Path: cma-es/batchcompute_python_sdk/src/batchcompute/utils/functions.py
# def partial(func, *args, **keywords):
#     def newfunc(*fargs, **fkeywords):
#         newkeywords = keywords.copy()
#         newkeywords.update(fkeywords)
#         return func(*(args + fargs), **newkeywords)
#     newfunc.func = func
#     newfunc.args = args
#     newfunc.keywords = keywords
#     return newfunc
# 
# def timestamp_datetime(value):
#     format = '%Y-%m-%d %H:%M:%S'
#     value = time.localtime(value)
#     dt = time.strftime(format, value)
#     return dt
# 
# def import_json():
#     try:
#         import json
#     except ImportError:
#         import simplejson as json
#     return json
# 
# def timediff(delta):
#     if delta:
#         t  = datetime.timedelta(seconds=delta)
#         time_day = t.days
#         s_time = t.seconds
#         ms_time = t.microseconds // 1000000
#         usedtime = int(s_time + ms_time)
#         time_hour = usedtime // 60 // 60
#         time_minute = (usedtime - time_hour * 3600 ) // 60
#         time_second =  usedtime - time_hour * 3600 - time_minute * 60
#         time_micsecond = (t.microseconds - t.microseconds // 1000000) // 1000
# 
#         tags = ['Day', 'Hour', 'Minute', 'Second']
#         time_info = {
#             'Day': time_day,
#             'Hour': time_hour,
#             'Minute': time_minute,
#             'Second': time_second
#         }
# 
#         time_list = []
#         for tag in tags:
#             if time_info[tag] > 1:
#                 new_tag = tag + 's'
#             elif time_info[tag] > 0:
#                 new_tag = tag
#             else:
#                 new_tag = None
#             if new_tag:
#                 time_list.append('%s %s' % (time_info[tag], new_tag))
#         retstr = ' '.join(time_list)
#     else:
#         retstr = '0'
#     return retstr
# 
# Path: cma-es/batchcompute_python_sdk/src/batchcompute/utils/constants.py
# STATE_MAP = [
#     'Init', 'Waiting', 'Running',
#     'Finished', 'Failed', 'Stopped'
# ]
# 
# PY2 = sys.version_info[0] == 2
# 
# PY3 = sys.version_info[0] == 3
# 
# STRING = (str, unicode)


# Path: cma-es/batchcompute_python_sdk/src/batchcompute/utils/canonicalization.py
import re
from datetime import timedelta
from .functions import partial, timestamp_datetime, import_json, timediff
from .constants import STATE_MAP, PY2, PY3, STRING

    Mainly add descriptor for each property descripted in description dict.

    e.g.:
        You can get JobId of a job status 'j' through both j.jobId and
        j.getJobId(), and the like.

    '''
    def __new__(cls, nm, parents, attrs):
        super_new = super(CamelCasedClass, cls).__new__

        tmp_dct = dict()
        for name, value in attrs.items():
            if not name.startswith('__') and not name.endswith('__'):
                tmp_dct[name] = value
        attrs.update(tmp_dct)

        # Create property for each key in `description_map` dict.
        # Besides, if `descriptor_type` is data descriptor, a `getxxx` and
        # a `setxxx` method also will be added to `cls`, if `descriptor_type`
        # is non data descriptor, only a `getxxx` method added.
        if 'descriptor_map' in attrs:
            for attr in attrs['descriptor_map']:
                # Definition of getter and setter method for properties.
                def get_attr(attr, self):
                    return self.getproperty(attr)
                def set_attr(attr, self, value):
                    self.setproperty(attr, value)

                property_name = attr
                getter = partial(get_attr, attr)

                setter = partial(set_attr, attr)