Create command classes from a json array
171476
private function parseCommands(array $json, string $procedureName)
    {
        $factory = new CommandFactory($this->app);
        $errors = [];

        foreach($json as $commandString) {

            /* Get the namespace of the command */
            $plugin = explode(':', $commandString, 2)[0];

            /* Check that the given plugin is installed */
            if(! $this->app->getContainer()->hasPlugin($plugin)) {
                $errors[] = "Plugin '$plugin' is required to run procedure '$procedureName'.";
                continue;
            }
            $parsedCommands[] = $factory->create($plugin, $commandString);
        }

        if(! empty($errors)) {
            throw new PluginNotFoundException(implode(PHP_EOL, $errors));
        }
        return $parsedCommands;
    }
1297715
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")

        data = {}
        data['user'] = User.from_array(array.get('user'))
        data['status'] = u(array.get('status'))
        data['until_date'] = int(array.get('until_date')) if array.get('until_date') is not None else None
        data['can_be_edited'] = bool(array.get('can_be_edited')) if array.get('can_be_edited') is not None else None
        data['can_change_info'] = bool(array.get('can_change_info')) if array.get('can_change_info') is not None else None
        data['can_post_messages'] = bool(array.get('can_post_messages')) if array.get('can_post_messages') is not None else None
        data['can_edit_messages'] = bool(array.get('can_edit_messages')) if array.get('can_edit_messages') is not None else None
        data['can_delete_messages'] = bool(array.get('can_delete_messages')) if array.get('can_delete_messages') is not None else None
        data['can_invite_users'] = bool(array.get('can_invite_users')) if array.get('can_invite_users') is not None else None
        data['can_restrict_members'] = bool(array.get('can_restrict_members')) if array.get('can_restrict_members') is not None else None
        data['can_pin_messages'] = bool(array.get('can_pin_messages')) if array.get('can_pin_messages') is not None else None
        data['can_promote_members'] = bool(array.get('can_promote_members')) if array.get('can_promote_members') is not None else None
        data['can_send_messages'] = bool(array.get('can_send_messages')) if array.get('can_send_messages') is not None else None
        data['can_send_media_messages'] = bool(array.get('can_send_media_messages')) if array.get('can_send_media_messages') is not None else None
        data['can_send_other_messages'] = bool(array.get('can_send_other_messages')) if array.get('can_send_other_messages') is not None else None
        data['can_add_web_page_previews'] = bool(array.get('can_add_web_page_previews')) if array.get('can_add_web_page_previews') is not None else None
        data['_raw'] = array
        return ChatMember(**data)
1001373
def from_json(cls, data):
        
        # Check required and optional keys
        required_keys = ('solar_model', 'month', 'day_of_month')
        for key in required_keys:
            assert key in data, 'Required key "{}" is missing!'.format(key)

        if data['solar_model'] == 'ASHRAEClearSky':
            return OriginalClearSkyCondition.from_json(data)
        if data['solar_model'] == 'ASHRAETau':
            return RevisedClearSkyCondition.from_json(data)

        if 'daylight_savings_indicator' not in data:
            data['daylight_savings_indicator'] = 'No'
        optional_keys = ('beam_shced', 'diff_sched')
        for key in optional_keys:
            if key not in data:
                data[key] = ''

        return cls(data['month'], data['day_of_month'], data['clearness'],
                   data['daylight_savings_indicator'],
                   data['beam_shced'], data['diff_sched'])
167992
def from_json(cls, data):
        """"""
        # Decode JSON string
        assert isinstance(data, str)
        data = json.loads(data)
        assert isinstance(data, dict)
        return cls.from_dict(data)
130725
def from_json(cls, json_text):
        
        data = json.loads(json_text)
        lut = {}
        for k, v in data.items():
            unsan_v = list(v)
            unsan_v[1] = sympify(v[1], locals=vars(unyt_dims))
            lut[k] = tuple(unsan_v)

        return cls(lut=lut, add_default_symbols=False)
1266900
protected function commandClassToArray(string $commandClass): array
    {
        /** @var CommandInterface $commandClass */
        return [
            $commandClass::getName(),
            $commandClass::getDescription(),
            $commandClass::getHelp(),
            $commandClass::getArguments(),
            $commandClass::getOptions(),
            [$commandClass, CommandInterface::COMMAND_METHOD_NAME],
        ];
    }
257453
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")

        data = {}
        data['id'] = int(array.get('id'))
        data['is_bot'] = bool(array.get('is_bot'))
        data['first_name'] = u(array.get('first_name'))
        data['last_name'] = u(array.get('last_name')) if array.get('last_name') is not None else None
        data['username'] = u(array.get('username')) if array.get('username') is not None else None
        data['language_code'] = u(array.get('language_code')) if array.get('language_code') is not None else None
        data['_raw'] = array
        return User(**data)
1035506
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'folders' in _dict:
            args['folders'] = [
                SourceOptionsFolder._from_dict(x)
                for x in (_dict.get('folders'))
            ]
        if 'objects' in _dict:
            args['objects'] = [
                SourceOptionsObject._from_dict(x)
                for x in (_dict.get('objects'))
            ]
        if 'site_collections' in _dict:
            args['site_collections'] = [
                SourceOptionsSiteColl._from_dict(x)
                for x in (_dict.get('site_collections'))
            ]
        if 'urls' in _dict:
            args['urls'] = [
                SourceOptionsWebCrawl._from_dict(x) for x in (_dict.get('urls'))
            ]
        if 'buckets' in _dict:
            args['buckets'] = [
                SourceOptionsBuckets._from_dict(x)
                for x in (_dict.get('buckets'))
            ]
        if 'crawl_all_buckets' in _dict:
            args['crawl_all_buckets'] = _dict.get('crawl_all_buckets')
        return cls(**args)
1362858
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'tones' in _dict:
            args['tones'] = [
                ToneScore._from_dict(x) for x in (_dict.get('tones'))
            ]
        else:
            raise ValueError(
                'Required property \'tones\' not present in ToneCategory JSON')
        if 'category_id' in _dict:
            args['category_id'] = _dict.get('category_id')
        else:
            raise ValueError(
                'Required property \'category_id\' not present in ToneCategory JSON'
            )
        if 'category_name' in _dict:
            args['category_name'] = _dict.get('category_name')
        else:
            raise ValueError(
                'Required property \'category_name\' not present in ToneCategory JSON'
            )
        return cls(**args)
823684
def _fromJSON(cls, jsonobject):
        
        newInstance = cls(None, None)
        attribDict = {}
        attribDict['id'] = jsonobject[0]
        attribDict['specfile'] = jsonobject[1]
        attribDict['attributes'] = jsonobject[2]
        attribDict['params'] = [tuple(param) for param in jsonobject[3]]
        attribDict['scanListParams'] = [tuple(param) for param in jsonobject[4]]
        attribDict['scanList'] = jsonobject[5]
        attribDict['precursorList'] = jsonobject[6]
        attribDict['productList'] = jsonobject[7]
        for key, value in viewitems(attribDict):
            setattr(newInstance, key, value)
        return newInstance
659279
def from_json(cls, data, json_schema_class=None):
        
        schema = cls.json_schema if json_schema_class is None else json_schema_class()
        return schema.load(data)
891793
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'sentence_id' in _dict:
            args['sentence_id'] = _dict.get('sentence_id')
        else:
            raise ValueError(
                'Required property \'sentence_id\' not present in SentenceAnalysis JSON'
            )
        if 'text' in _dict:
            args['text'] = _dict.get('text')
        else:
            raise ValueError(
                'Required property \'text\' not present in SentenceAnalysis JSON'
            )
        if 'tones' in _dict:
            args['tones'] = [
                ToneScore._from_dict(x) for x in (_dict.get('tones'))
            ]
        if 'tone_categories' in _dict:
            args['tone_categories'] = [
                ToneCategory._from_dict(x)
                for x in (_dict.get('tone_categories'))
            ]
        if 'input_from' in _dict:
            args['input_from'] = _dict.get('input_from')
        if 'input_to' in _dict:
            args['input_to'] = _dict.get('input_to')
        return cls(**args)
749228
def from_json(cls, json_dump):
        
        context = cls()
        if json_dump is None:
            return None
        ctxt = json.loads(json_dump)
        for k in ctxt:
            context[k] = ctxt[k]
        return context
747671
def from_json(cls, json_data):
        """"""
        # Example Data:
        # { "grpId": "11817", "grpName": "7603_Digi", "grpDescription": "7603_Digi root group",
        #   "grpPath": "\/7603_Digi\/", "grpParentId": "1"}
        return cls(
            group_id=json_data["grpId"],
            name=json_data["grpName"],
            description=json_data.get("grpDescription", ""),
            path=json_data["grpPath"],
            parent_id=json_data["grpParentId"],
        )
1152627
def from_array(array):
        
        if array is None or not array:
            return None
        # end if
        assert_type_or_raise(array, dict, parameter_name="array")

        data = {}
        data['title'] = u(array.get('title'))
        data['description'] = u(array.get('description'))
        data['photo'] = PhotoSize.from_array_list(array.get('photo'), list_level=1)
        data['text'] = u(array.get('text')) if array.get('text') is not None else None
        data['text_entities'] = MessageEntity.from_array_list(array.get('text_entities'), list_level=1) if array.get('text_entities') is not None else None
        data['animation'] = Animation.from_array(array.get('animation')) if array.get('animation') is not None else None
        data['_raw'] = array
        return Game(**data)
402048
def _from_dict(cls, _dict):
        """"""
        args = {}
        if 'name' in _dict:
            args['name'] = _dict.get('name')
        else:
            raise ValueError(
                'Required property \'name\' not present in ClassifierResult JSON'
            )
        if 'classifier_id' in _dict:
            args['classifier_id'] = _dict.get('classifier_id')
        else:
            raise ValueError(
                'Required property \'classifier_id\' not present in ClassifierResult JSON'
            )
        if 'classes' in _dict:
            args['classes'] = [
                ClassResult._from_dict(x) for x in (_dict.get('classes'))
            ]
        else:
            raise ValueError(
                'Required property \'classes\' not present in ClassifierResult JSON'
            )
        return cls(**args)
17344
def _fromJSON(cls, jsonobject):
        
        newInstance = cls(jsonobject[0], jsonobject[1])
        attribDict = {}
        attribDict['dataProcessingRef'] = jsonobject[2]
        attribDict['precursor'] = jsonobject[3]
        attribDict['product'] = jsonobject[4]
        attribDict['params'] = [tuple(param) for param in jsonobject[5]]
        attribDict['attrib'] = jsonobject[6]
        attribDict['arrayInfo'] = dict()
        for arrayType, jsonEntry in viewitems(jsonobject[7]):
            arrayEntry = {'dataProcessingRef': jsonEntry['dataProcessingRef'],
                          'params': [tuple(_) for _ in jsonEntry['params']]
                          }
            attribDict['arrayInfo'][arrayType] = arrayEntry
        for key, value in viewitems(attribDict):
            setattr(newInstance, key, value)
        return newInstance