<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def enumarg(enum, arg):
 """Return enum member from its name or value. <PHOTOMETRIC.RGB: 2> <PHOTOMETRIC.RGB: 2> """

    try:
        return enum(arg)
    except Exception:
        try:
            return enum[arg.upper()]
        except Exception:
            raise ValueError('invalid argument %s' % arg)