id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1 value | code stringlengths 51 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
8,900 | luckydonald/pytgbot | pytgbot/api_types/sendable/inline.py | InlineQueryResultCachedVoice.to_array | def to_array(self):
"""
Serializes this InlineQueryResultCachedVoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedVoice, self).to_array()
# 'type' and 'id' given by superclass
array['voice_file_id'] = u(self.voice_file_id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultCachedVoice, self).to_array()
# 'type' and 'id' given by superclass
array['voice_file_id'] = u(self.voice_file_id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultCachedVoice",
",",
"self",
")",
".",
"to_array",
"(",
")",
"# 'type' and 'id' given by superclass",
"array",
"[",
"'voice_file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"voice... | Serializes this InlineQueryResultCachedVoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultCachedVoice",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/inline.py#L3664-L3683 |
8,901 | luckydonald/pytgbot | pytgbot/api_types/sendable/inline.py | InlineQueryResultCachedAudio.from_array | def from_array(array):
"""
Deserialize a new InlineQueryResultCachedAudio from a given dictionary.
:return: new InlineQueryResultCachedAudio instance.
:rtype: InlineQueryResultCachedAudio
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup
data = {}
# 'type' is given by class type
data['id'] = u(array.get('id'))
data['audio_file_id'] = u(array.get('audio_file_id'))
data['caption'] = u(array.get('caption')) if array.get('caption') is not None else None
data['parse_mode'] = u(array.get('parse_mode')) if array.get('parse_mode') is not None else None
data['reply_markup'] = InlineKeyboardMarkup.from_array(array.get('reply_markup')) if array.get('reply_markup') is not None else None
data['input_message_content'] = InputMessageContent.from_array(array.get('input_message_content')) if array.get('input_message_content') is not None else None
instance = InlineQueryResultCachedAudio(**data)
instance._raw = array
return instance | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.sendable.reply_markup import InlineKeyboardMarkup
data = {}
# 'type' is given by class type
data['id'] = u(array.get('id'))
data['audio_file_id'] = u(array.get('audio_file_id'))
data['caption'] = u(array.get('caption')) if array.get('caption') is not None else None
data['parse_mode'] = u(array.get('parse_mode')) if array.get('parse_mode') is not None else None
data['reply_markup'] = InlineKeyboardMarkup.from_array(array.get('reply_markup')) if array.get('reply_markup') is not None else None
data['input_message_content'] = InputMessageContent.from_array(array.get('input_message_content')) if array.get('input_message_content') is not None else None
instance = InlineQueryResultCachedAudio(**data)
instance._raw = array
return instance | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
"pytgbot",
".",
"api... | Deserialize a new InlineQueryResultCachedAudio from a given dictionary.
:return: new InlineQueryResultCachedAudio instance.
:rtype: InlineQueryResultCachedAudio | [
"Deserialize",
"a",
"new",
"InlineQueryResultCachedAudio",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/inline.py#L3850-L3875 |
8,902 | luckydonald/pytgbot | pytgbot/api_types/sendable/inline.py | InputTextMessageContent.to_array | def to_array(self):
"""
Serializes this InputTextMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputTextMessageContent, self).to_array()
array['message_text'] = u(self.message_text) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.disable_web_page_preview is not None:
array['disable_web_page_preview'] = bool(self.disable_web_page_preview) # type bool
return array | python | def to_array(self):
array = super(InputTextMessageContent, self).to_array()
array['message_text'] = u(self.message_text) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.disable_web_page_preview is not None:
array['disable_web_page_preview'] = bool(self.disable_web_page_preview) # type bool
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InputTextMessageContent",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'message_text'",
"]",
"=",
"u",
"(",
"self",
".",
"message_text",
")",
"# py2: type unicode, py3: typ... | Serializes this InputTextMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InputTextMessageContent",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/inline.py#L3958-L3971 |
8,903 | luckydonald/pytgbot | pytgbot/api_types/sendable/inline.py | InputLocationMessageContent.to_array | def to_array(self):
"""
Serializes this InputLocationMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputLocationMessageContent, self).to_array()
array['latitude'] = float(self.latitude) # type float
array['longitude'] = float(self.longitude) # type float
if self.live_period is not None:
array['live_period'] = int(self.live_period) # type int
return array | python | def to_array(self):
array = super(InputLocationMessageContent, self).to_array()
array['latitude'] = float(self.latitude) # type float
array['longitude'] = float(self.longitude) # type float
if self.live_period is not None:
array['live_period'] = int(self.live_period) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InputLocationMessageContent",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'latitude'",
"]",
"=",
"float",
"(",
"self",
".",
"latitude",
")",
"# type float",
"array",
"... | Serializes this InputLocationMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InputLocationMessageContent",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/inline.py#L4077-L4089 |
8,904 | luckydonald/pytgbot | pytgbot/api_types/sendable/inline.py | InputLocationMessageContent.from_array | def from_array(array):
"""
Deserialize a new InputLocationMessageContent from a given dictionary.
:return: new InputLocationMessageContent instance.
:rtype: InputLocationMessageContent
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['latitude'] = float(array.get('latitude'))
data['longitude'] = float(array.get('longitude'))
data['live_period'] = int(array.get('live_period')) if array.get('live_period') is not None else None
instance = InputLocationMessageContent(**data)
instance._raw = array
return instance | python | 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['latitude'] = float(array.get('latitude'))
data['longitude'] = float(array.get('longitude'))
data['live_period'] = int(array.get('live_period')) if array.get('live_period') is not None else None
instance = InputLocationMessageContent(**data)
instance._raw = array
return instance | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new InputLocationMessageContent from a given dictionary.
:return: new InputLocationMessageContent instance.
:rtype: InputLocationMessageContent | [
"Deserialize",
"a",
"new",
"InputLocationMessageContent",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/inline.py#L4093-L4112 |
8,905 | luckydonald/pytgbot | pytgbot/api_types/sendable/inline.py | InputVenueMessageContent.to_array | def to_array(self):
"""
Serializes this InputVenueMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputVenueMessageContent, self).to_array()
array['latitude'] = float(self.latitude) # type float
array['longitude'] = float(self.longitude) # type float
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['address'] = u(self.address) # py2: type unicode, py3: type str
if self.foursquare_id is not None:
array['foursquare_id'] = u(self.foursquare_id) # py2: type unicode, py3: type str
if self.foursquare_type is not None:
array['foursquare_type'] = u(self.foursquare_type) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(InputVenueMessageContent, self).to_array()
array['latitude'] = float(self.latitude) # type float
array['longitude'] = float(self.longitude) # type float
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['address'] = u(self.address) # py2: type unicode, py3: type str
if self.foursquare_id is not None:
array['foursquare_id'] = u(self.foursquare_id) # py2: type unicode, py3: type str
if self.foursquare_type is not None:
array['foursquare_type'] = u(self.foursquare_type) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InputVenueMessageContent",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'latitude'",
"]",
"=",
"float",
"(",
"self",
".",
"latitude",
")",
"# type float",
"array",
"[",... | Serializes this InputVenueMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InputVenueMessageContent",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/inline.py#L4224-L4240 |
8,906 | luckydonald/pytgbot | pytgbot/api_types/sendable/inline.py | InputVenueMessageContent.from_array | def from_array(array):
"""
Deserialize a new InputVenueMessageContent from a given dictionary.
:return: new InputVenueMessageContent instance.
:rtype: InputVenueMessageContent
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['latitude'] = float(array.get('latitude'))
data['longitude'] = float(array.get('longitude'))
data['title'] = u(array.get('title'))
data['address'] = u(array.get('address'))
data['foursquare_id'] = u(array.get('foursquare_id')) if array.get('foursquare_id') is not None else None
data['foursquare_type'] = u(array.get('foursquare_type')) if array.get('foursquare_type') is not None else None
instance = InputVenueMessageContent(**data)
instance._raw = array
return instance | python | 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['latitude'] = float(array.get('latitude'))
data['longitude'] = float(array.get('longitude'))
data['title'] = u(array.get('title'))
data['address'] = u(array.get('address'))
data['foursquare_id'] = u(array.get('foursquare_id')) if array.get('foursquare_id') is not None else None
data['foursquare_type'] = u(array.get('foursquare_type')) if array.get('foursquare_type') is not None else None
instance = InputVenueMessageContent(**data)
instance._raw = array
return instance | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new InputVenueMessageContent from a given dictionary.
:return: new InputVenueMessageContent instance.
:rtype: InputVenueMessageContent | [
"Deserialize",
"a",
"new",
"InputVenueMessageContent",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/inline.py#L4244-L4266 |
8,907 | luckydonald/pytgbot | pytgbot/api_types/sendable/inline.py | InputContactMessageContent.to_array | def to_array(self):
"""
Serializes this InputContactMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputContactMessageContent, self).to_array()
array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str
array['first_name'] = u(self.first_name) # py2: type unicode, py3: type str
if self.last_name is not None:
array['last_name'] = u(self.last_name) # py2: type unicode, py3: type str
if self.vcard is not None:
array['vcard'] = u(self.vcard) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(InputContactMessageContent, self).to_array()
array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str
array['first_name'] = u(self.first_name) # py2: type unicode, py3: type str
if self.last_name is not None:
array['last_name'] = u(self.last_name) # py2: type unicode, py3: type str
if self.vcard is not None:
array['vcard'] = u(self.vcard) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InputContactMessageContent",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'phone_number'",
"]",
"=",
"u",
"(",
"self",
".",
"phone_number",
")",
"# py2: type unicode, py3: ... | Serializes this InputContactMessageContent to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InputContactMessageContent",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/inline.py#L4360-L4374 |
8,908 | luckydonald/pytgbot | code_generation/code_generator_template.py | can_strip_prefix | def can_strip_prefix(text:str, prefix:str) -> (bool, str):
"""
If the given text starts with the given prefix, True and the text without that prefix is returned.
Else False and the original text is returned.
Note: the text always is stripped, before returning.
:param text:
:param prefix:
:return: (bool, str) :class:`bool` whether he text started with given prefix, :class:`str` the text without prefix
"""
if text.startswith(prefix):
return True, text[len(prefix):].strip()
return False, text.strip() | python | def can_strip_prefix(text:str, prefix:str) -> (bool, str):
if text.startswith(prefix):
return True, text[len(prefix):].strip()
return False, text.strip() | [
"def",
"can_strip_prefix",
"(",
"text",
":",
"str",
",",
"prefix",
":",
"str",
")",
"->",
"(",
"bool",
",",
"str",
")",
":",
"if",
"text",
".",
"startswith",
"(",
"prefix",
")",
":",
"return",
"True",
",",
"text",
"[",
"len",
"(",
"prefix",
")",
... | If the given text starts with the given prefix, True and the text without that prefix is returned.
Else False and the original text is returned.
Note: the text always is stripped, before returning.
:param text:
:param prefix:
:return: (bool, str) :class:`bool` whether he text started with given prefix, :class:`str` the text without prefix | [
"If",
"the",
"given",
"text",
"starts",
"with",
"the",
"given",
"prefix",
"True",
"and",
"the",
"text",
"without",
"that",
"prefix",
"is",
"returned",
".",
"Else",
"False",
"and",
"the",
"original",
"text",
"is",
"returned",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_template.py#L694-L707 |
8,909 | luckydonald/pytgbot | code_generation/code_generator_template.py | Function.class_name | def class_name(self) -> str:
"""
Makes the fist letter big, keep the rest of the camelCaseApiName.
"""
if not self.api_name: # empty string
return self.api_name
# end if
return self.api_name[0].upper() + self.api_name[1:] | python | def class_name(self) -> str:
if not self.api_name: # empty string
return self.api_name
# end if
return self.api_name[0].upper() + self.api_name[1:] | [
"def",
"class_name",
"(",
"self",
")",
"->",
"str",
":",
"if",
"not",
"self",
".",
"api_name",
":",
"# empty string",
"return",
"self",
".",
"api_name",
"# end if",
"return",
"self",
".",
"api_name",
"[",
"0",
"]",
".",
"upper",
"(",
")",
"+",
"self",
... | Makes the fist letter big, keep the rest of the camelCaseApiName. | [
"Makes",
"the",
"fist",
"letter",
"big",
"keep",
"the",
"rest",
"of",
"the",
"camelCaseApiName",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_template.py#L224-L231 |
8,910 | luckydonald/pytgbot | code_generation/code_generator_template.py | Function.class_name_teleflask_message | def class_name_teleflask_message(self) -> str:
"""
If it starts with `Send` remove that.
"""
# strip leading "Send"
name = self.class_name # "sendPhoto" -> "SendPhoto"
name = name[4:] if name.startswith('Send') else name # "SendPhoto" -> "Photo"
name = name + "Message" # "Photo" -> "PhotoMessage"
# e.g. "MessageMessage" will be replaced as "TextMessage"
# b/c "sendMessage" -> "SendMessage" -> "Message" -> "MessageMessage" ==> "TextMessage"
if name in MESSAGE_CLASS_OVERRIDES:
return MESSAGE_CLASS_OVERRIDES[name]
# end if
return name | python | def class_name_teleflask_message(self) -> str:
# strip leading "Send"
name = self.class_name # "sendPhoto" -> "SendPhoto"
name = name[4:] if name.startswith('Send') else name # "SendPhoto" -> "Photo"
name = name + "Message" # "Photo" -> "PhotoMessage"
# e.g. "MessageMessage" will be replaced as "TextMessage"
# b/c "sendMessage" -> "SendMessage" -> "Message" -> "MessageMessage" ==> "TextMessage"
if name in MESSAGE_CLASS_OVERRIDES:
return MESSAGE_CLASS_OVERRIDES[name]
# end if
return name | [
"def",
"class_name_teleflask_message",
"(",
"self",
")",
"->",
"str",
":",
"# strip leading \"Send\"",
"name",
"=",
"self",
".",
"class_name",
"# \"sendPhoto\" -> \"SendPhoto\"",
"name",
"=",
"name",
"[",
"4",
":",
"]",
"if",
"name",
".",
"startswith",
"(",
"'Se... | If it starts with `Send` remove that. | [
"If",
"it",
"starts",
"with",
"Send",
"remove",
"that",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_template.py#L235-L249 |
8,911 | luckydonald/pytgbot | code_generation/code_generator_template.py | Import.full | def full(self):
""" self.path + "." + self.name """
if self.path:
if self.name:
return self.path + "." + self.name
else:
return self.path
# end if
else:
if self.name:
return self.name
else:
return "" | python | def full(self):
if self.path:
if self.name:
return self.path + "." + self.name
else:
return self.path
# end if
else:
if self.name:
return self.name
else:
return "" | [
"def",
"full",
"(",
"self",
")",
":",
"if",
"self",
".",
"path",
":",
"if",
"self",
".",
"name",
":",
"return",
"self",
".",
"path",
"+",
"\".\"",
"+",
"self",
".",
"name",
"else",
":",
"return",
"self",
".",
"path",
"# end if",
"else",
":",
"if"... | self.path + "." + self.name | [
"self",
".",
"path",
"+",
".",
"+",
"self",
".",
"name"
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/code_generator_template.py#L479-L491 |
8,912 | luckydonald/pytgbot | pytgbot/extra/bot_response.py | ResponseBot.do | def do(self, command, files=None, use_long_polling=False, request_timeout=None, **query):
"""
Return the request params we would send to the api.
"""
url, params = self._prepare_request(command, query)
return {
"url": url, "params": params, "files": files, "stream": use_long_polling,
"verify": True, # No self signed certificates. Telegram should be trustworthy anyway...
"timeout": request_timeout
} | python | def do(self, command, files=None, use_long_polling=False, request_timeout=None, **query):
url, params = self._prepare_request(command, query)
return {
"url": url, "params": params, "files": files, "stream": use_long_polling,
"verify": True, # No self signed certificates. Telegram should be trustworthy anyway...
"timeout": request_timeout
} | [
"def",
"do",
"(",
"self",
",",
"command",
",",
"files",
"=",
"None",
",",
"use_long_polling",
"=",
"False",
",",
"request_timeout",
"=",
"None",
",",
"*",
"*",
"query",
")",
":",
"url",
",",
"params",
"=",
"self",
".",
"_prepare_request",
"(",
"command... | Return the request params we would send to the api. | [
"Return",
"the",
"request",
"params",
"we",
"would",
"send",
"to",
"the",
"api",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/extra/bot_response.py#L20-L29 |
8,913 | luckydonald/pytgbot | pytgbot/api_types/receivable/updates.py | Update.to_array | def to_array(self):
"""
Serializes this Update to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Update, self).to_array()
array['update_id'] = int(self.update_id) # type int
if self.message is not None:
array['message'] = self.message.to_array() # type Message
if self.edited_message is not None:
array['edited_message'] = self.edited_message.to_array() # type Message
if self.channel_post is not None:
array['channel_post'] = self.channel_post.to_array() # type Message
if self.edited_channel_post is not None:
array['edited_channel_post'] = self.edited_channel_post.to_array() # type Message
if self.inline_query is not None:
array['inline_query'] = self.inline_query.to_array() # type InlineQuery
if self.chosen_inline_result is not None:
array['chosen_inline_result'] = self.chosen_inline_result.to_array() # type ChosenInlineResult
if self.callback_query is not None:
array['callback_query'] = self.callback_query.to_array() # type CallbackQuery
if self.shipping_query is not None:
array['shipping_query'] = self.shipping_query.to_array() # type ShippingQuery
if self.pre_checkout_query is not None:
array['pre_checkout_query'] = self.pre_checkout_query.to_array() # type PreCheckoutQuery
return array | python | def to_array(self):
array = super(Update, self).to_array()
array['update_id'] = int(self.update_id) # type int
if self.message is not None:
array['message'] = self.message.to_array() # type Message
if self.edited_message is not None:
array['edited_message'] = self.edited_message.to_array() # type Message
if self.channel_post is not None:
array['channel_post'] = self.channel_post.to_array() # type Message
if self.edited_channel_post is not None:
array['edited_channel_post'] = self.edited_channel_post.to_array() # type Message
if self.inline_query is not None:
array['inline_query'] = self.inline_query.to_array() # type InlineQuery
if self.chosen_inline_result is not None:
array['chosen_inline_result'] = self.chosen_inline_result.to_array() # type ChosenInlineResult
if self.callback_query is not None:
array['callback_query'] = self.callback_query.to_array() # type CallbackQuery
if self.shipping_query is not None:
array['shipping_query'] = self.shipping_query.to_array() # type ShippingQuery
if self.pre_checkout_query is not None:
array['pre_checkout_query'] = self.pre_checkout_query.to_array() # type PreCheckoutQuery
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Update",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'update_id'",
"]",
"=",
"int",
"(",
"self",
".",
"update_id",
")",
"# type int",
"if",
"self",
".",
"message",... | Serializes this Update to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Update",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/updates.py#L149-L176 |
8,914 | luckydonald/pytgbot | pytgbot/api_types/receivable/updates.py | WebhookInfo.to_array | def to_array(self):
"""
Serializes this WebhookInfo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(WebhookInfo, self).to_array()
array['url'] = u(self.url) # py2: type unicode, py3: type str
array['has_custom_certificate'] = bool(self.has_custom_certificate) # type bool
array['pending_update_count'] = int(self.pending_update_count) # type int
if self.last_error_date is not None:
array['last_error_date'] = int(self.last_error_date) # type int
if self.last_error_message is not None:
array['last_error_message'] = u(self.last_error_message) # py2: type unicode, py3: type str
if self.max_connections is not None:
array['max_connections'] = int(self.max_connections) # type int
if self.allowed_updates is not None:
array['allowed_updates'] = self._as_array(self.allowed_updates) # type list of str
return array | python | def to_array(self):
array = super(WebhookInfo, self).to_array()
array['url'] = u(self.url) # py2: type unicode, py3: type str
array['has_custom_certificate'] = bool(self.has_custom_certificate) # type bool
array['pending_update_count'] = int(self.pending_update_count) # type int
if self.last_error_date is not None:
array['last_error_date'] = int(self.last_error_date) # type int
if self.last_error_message is not None:
array['last_error_message'] = u(self.last_error_message) # py2: type unicode, py3: type str
if self.max_connections is not None:
array['max_connections'] = int(self.max_connections) # type int
if self.allowed_updates is not None:
array['allowed_updates'] = self._as_array(self.allowed_updates) # type list of str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"WebhookInfo",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'url'",
"]",
"=",
"u",
"(",
"self",
".",
"url",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
"'... | Serializes this WebhookInfo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"WebhookInfo",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/updates.py#L334-L353 |
8,915 | luckydonald/pytgbot | pytgbot/api_types/receivable/updates.py | WebhookInfo.from_array | def from_array(array):
"""
Deserialize a new WebhookInfo from a given dictionary.
:return: new WebhookInfo instance.
:rtype: WebhookInfo
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['url'] = u(array.get('url'))
data['has_custom_certificate'] = bool(array.get('has_custom_certificate'))
data['pending_update_count'] = int(array.get('pending_update_count'))
data['last_error_date'] = int(array.get('last_error_date')) if array.get('last_error_date') is not None else None
data['last_error_message'] = u(array.get('last_error_message')) if array.get('last_error_message') is not None else None
data['max_connections'] = int(array.get('max_connections')) if array.get('max_connections') is not None else None
data['allowed_updates'] = WebhookInfo._builtin_from_array_list(required_type=unicode_type, value=array.get('allowed_updates'), list_level=1) if array.get('allowed_updates') is not None else None
data['_raw'] = array
return WebhookInfo(**data) | python | 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['url'] = u(array.get('url'))
data['has_custom_certificate'] = bool(array.get('has_custom_certificate'))
data['pending_update_count'] = int(array.get('pending_update_count'))
data['last_error_date'] = int(array.get('last_error_date')) if array.get('last_error_date') is not None else None
data['last_error_message'] = u(array.get('last_error_message')) if array.get('last_error_message') is not None else None
data['max_connections'] = int(array.get('max_connections')) if array.get('max_connections') is not None else None
data['allowed_updates'] = WebhookInfo._builtin_from_array_list(required_type=unicode_type, value=array.get('allowed_updates'), list_level=1) if array.get('allowed_updates') is not None else None
data['_raw'] = array
return WebhookInfo(**data) | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new WebhookInfo from a given dictionary.
:return: new WebhookInfo instance.
:rtype: WebhookInfo | [
"Deserialize",
"a",
"new",
"WebhookInfo",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/updates.py#L357-L378 |
8,916 | luckydonald/pytgbot | pytgbot/api_types/receivable/updates.py | CallbackQuery.to_array | def to_array(self):
"""
Serializes this CallbackQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(CallbackQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['chat_instance'] = u(self.chat_instance) # py2: type unicode, py3: type str
if self.message is not None:
array['message'] = self.message.to_array() # type Message
if self.inline_message_id is not None:
array['inline_message_id'] = u(self.inline_message_id) # py2: type unicode, py3: type str
if self.data is not None:
array['data'] = u(self.data) # py2: type unicode, py3: type str
if self.game_short_name is not None:
array['game_short_name'] = u(self.game_short_name) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(CallbackQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['chat_instance'] = u(self.chat_instance) # py2: type unicode, py3: type str
if self.message is not None:
array['message'] = self.message.to_array() # type Message
if self.inline_message_id is not None:
array['inline_message_id'] = u(self.inline_message_id) # py2: type unicode, py3: type str
if self.data is not None:
array['data'] = u(self.data) # py2: type unicode, py3: type str
if self.game_short_name is not None:
array['game_short_name'] = u(self.game_short_name) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"CallbackQuery",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'id'",
"]",
"=",
"u",
"(",
"self",
".",
"id",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
"'... | Serializes this CallbackQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"CallbackQuery",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/updates.py#L1140-L1159 |
8,917 | luckydonald/pytgbot | pytgbot/api_types/receivable/updates.py | CallbackQuery.from_array | def from_array(array):
"""
Deserialize a new CallbackQuery from a given dictionary.
:return: new CallbackQuery instance.
:rtype: CallbackQuery
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from ..receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['chat_instance'] = u(array.get('chat_instance'))
data['message'] = Message.from_array(array.get('message')) if array.get('message') is not None else None
data['inline_message_id'] = u(array.get('inline_message_id')) if array.get('inline_message_id') is not None else None
data['data'] = u(array.get('data')) if array.get('data') is not None else None
data['game_short_name'] = u(array.get('game_short_name')) if array.get('game_short_name') is not None else None
data['_raw'] = array
return CallbackQuery(**data) | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from ..receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['chat_instance'] = u(array.get('chat_instance'))
data['message'] = Message.from_array(array.get('message')) if array.get('message') is not None else None
data['inline_message_id'] = u(array.get('inline_message_id')) if array.get('inline_message_id') is not None else None
data['data'] = u(array.get('data')) if array.get('data') is not None else None
data['game_short_name'] = u(array.get('game_short_name')) if array.get('game_short_name') is not None else None
data['_raw'] = array
return CallbackQuery(**data) | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
".",
".",
"receivabl... | Deserialize a new CallbackQuery from a given dictionary.
:return: new CallbackQuery instance.
:rtype: CallbackQuery | [
"Deserialize",
"a",
"new",
"CallbackQuery",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/updates.py#L1163-L1186 |
8,918 | luckydonald/pytgbot | pytgbot/api_types/receivable/updates.py | ResponseParameters.to_array | def to_array(self):
"""
Serializes this ResponseParameters to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ResponseParameters, self).to_array()
if self.migrate_to_chat_id is not None:
array['migrate_to_chat_id'] = int(self.migrate_to_chat_id) # type int
if self.retry_after is not None:
array['retry_after'] = int(self.retry_after) # type int
return array | python | def to_array(self):
array = super(ResponseParameters, self).to_array()
if self.migrate_to_chat_id is not None:
array['migrate_to_chat_id'] = int(self.migrate_to_chat_id) # type int
if self.retry_after is not None:
array['retry_after'] = int(self.retry_after) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"ResponseParameters",
",",
"self",
")",
".",
"to_array",
"(",
")",
"if",
"self",
".",
"migrate_to_chat_id",
"is",
"not",
"None",
":",
"array",
"[",
"'migrate_to_chat_id'",
"]",
"=",
"i... | Serializes this ResponseParameters to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"ResponseParameters",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/updates.py#L1279-L1291 |
8,919 | luckydonald/pytgbot | pytgbot/api_types/receivable/updates.py | ResponseParameters.from_array | def from_array(array):
"""
Deserialize a new ResponseParameters from a given dictionary.
:return: new ResponseParameters instance.
:rtype: ResponseParameters
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['migrate_to_chat_id'] = int(array.get('migrate_to_chat_id')) if array.get('migrate_to_chat_id') is not None else None
data['retry_after'] = int(array.get('retry_after')) if array.get('retry_after') is not None else None
data['_raw'] = array
return ResponseParameters(**data) | python | 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['migrate_to_chat_id'] = int(array.get('migrate_to_chat_id')) if array.get('migrate_to_chat_id') is not None else None
data['retry_after'] = int(array.get('retry_after')) if array.get('retry_after') is not None else None
data['_raw'] = array
return ResponseParameters(**data) | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new ResponseParameters from a given dictionary.
:return: new ResponseParameters instance.
:rtype: ResponseParameters | [
"Deserialize",
"a",
"new",
"ResponseParameters",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/updates.py#L1295-L1311 |
8,920 | delph-in/pydelphin | delphin/mrs/xmrs.py | Xmrs.from_xmrs | def from_xmrs(cls, xmrs, **kwargs):
"""
Facilitate conversion among subclasses.
Args:
xmrs (:class:`Xmrs`): instance to convert from; possibly
an instance of a subclass, such as :class:`Mrs` or
:class:`Dmrs`
**kwargs: additional keyword arguments that may be used
by a subclass's redefinition of :meth:`from_xmrs`.
"""
x = cls()
x.__dict__.update(xmrs.__dict__)
return x | python | def from_xmrs(cls, xmrs, **kwargs):
x = cls()
x.__dict__.update(xmrs.__dict__)
return x | [
"def",
"from_xmrs",
"(",
"cls",
",",
"xmrs",
",",
"*",
"*",
"kwargs",
")",
":",
"x",
"=",
"cls",
"(",
")",
"x",
".",
"__dict__",
".",
"update",
"(",
"xmrs",
".",
"__dict__",
")",
"return",
"x"
] | Facilitate conversion among subclasses.
Args:
xmrs (:class:`Xmrs`): instance to convert from; possibly
an instance of a subclass, such as :class:`Mrs` or
:class:`Dmrs`
**kwargs: additional keyword arguments that may be used
by a subclass's redefinition of :meth:`from_xmrs`. | [
"Facilitate",
"conversion",
"among",
"subclasses",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/xmrs.py#L105-L118 |
8,921 | delph-in/pydelphin | delphin/mrs/xmrs.py | Xmrs.is_connected | def is_connected(self):
"""
Return `True` if the Xmrs represents a connected graph.
Subgraphs can be connected through things like arguments,
QEQs, and label equalities.
"""
nids = set(self._nodeids) # the nids left to find
if len(nids) == 0:
raise XmrsError('Cannot compute connectedness of an empty Xmrs.')
# build a basic dict graph of relations
edges = []
# label connections
for lbl in self.labels():
lblset = self.labelset(lbl)
edges.extend((x, y) for x in lblset for y in lblset if x != y)
# argument connections
_vars = self._vars
for nid in nids:
for rarg, tgt in self.args(nid).items():
if tgt not in _vars:
continue
if IVARG_ROLE in _vars[tgt]['refs']:
tgtnids = list(_vars[tgt]['refs'][IVARG_ROLE])
elif tgt in self._hcons:
tgtnids = list(self.labelset(self.hcon(tgt)[2]))
elif 'LBL' in _vars[tgt]['refs']:
tgtnids = list(_vars[tgt]['refs']['LBL'])
else:
tgtnids = []
# connections are bidirectional
edges.extend((nid, t) for t in tgtnids if nid != t)
edges.extend((t, nid) for t in tgtnids if nid != t)
g = {nid: set() for nid in nids}
for x, y in edges:
g[x].add(y)
connected_nids = _bfs(g)
if connected_nids == nids:
return True
elif connected_nids.difference(nids):
raise XmrsError(
'Possibly bogus nodeids: {}'
.format(', '.join(connected_nids.difference(nids)))
)
return False | python | def is_connected(self):
nids = set(self._nodeids) # the nids left to find
if len(nids) == 0:
raise XmrsError('Cannot compute connectedness of an empty Xmrs.')
# build a basic dict graph of relations
edges = []
# label connections
for lbl in self.labels():
lblset = self.labelset(lbl)
edges.extend((x, y) for x in lblset for y in lblset if x != y)
# argument connections
_vars = self._vars
for nid in nids:
for rarg, tgt in self.args(nid).items():
if tgt not in _vars:
continue
if IVARG_ROLE in _vars[tgt]['refs']:
tgtnids = list(_vars[tgt]['refs'][IVARG_ROLE])
elif tgt in self._hcons:
tgtnids = list(self.labelset(self.hcon(tgt)[2]))
elif 'LBL' in _vars[tgt]['refs']:
tgtnids = list(_vars[tgt]['refs']['LBL'])
else:
tgtnids = []
# connections are bidirectional
edges.extend((nid, t) for t in tgtnids if nid != t)
edges.extend((t, nid) for t in tgtnids if nid != t)
g = {nid: set() for nid in nids}
for x, y in edges:
g[x].add(y)
connected_nids = _bfs(g)
if connected_nids == nids:
return True
elif connected_nids.difference(nids):
raise XmrsError(
'Possibly bogus nodeids: {}'
.format(', '.join(connected_nids.difference(nids)))
)
return False | [
"def",
"is_connected",
"(",
"self",
")",
":",
"nids",
"=",
"set",
"(",
"self",
".",
"_nodeids",
")",
"# the nids left to find",
"if",
"len",
"(",
"nids",
")",
"==",
"0",
":",
"raise",
"XmrsError",
"(",
"'Cannot compute connectedness of an empty Xmrs.'",
")",
"... | Return `True` if the Xmrs represents a connected graph.
Subgraphs can be connected through things like arguments,
QEQs, and label equalities. | [
"Return",
"True",
"if",
"the",
"Xmrs",
"represents",
"a",
"connected",
"graph",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/xmrs.py#L606-L650 |
8,922 | delph-in/pydelphin | delphin/mrs/xmrs.py | Xmrs.validate | def validate(self):
"""
Check that the Xmrs is well-formed.
The Xmrs is analyzed and a list of problems is compiled. If
any problems exist, an :exc:`XmrsError` is raised with the list
joined as the error message. A well-formed Xmrs has the
following properties:
* All predications have an intrinsic variable
* Every intrinsic variable belongs one predication and maybe
one quantifier
* Every predication has no more than one quantifier
* All predications have a label
* The graph of predications form a net (i.e. are connected).
Connectivity can be established with variable arguments,
QEQs, or label-equality.
* The lo-handle for each QEQ must exist as the label of a
predication
"""
errors = []
ivs, bvs = {}, {}
_vars = self._vars
_hcons = self._hcons
labels = defaultdict(set)
# ep_args = {}
for ep in self.eps():
nid, lbl, args, is_q = (
ep.nodeid, ep.label, ep.args, ep.is_quantifier()
)
if lbl is None:
errors.append('EP ({}) is missing a label.'.format(nid))
labels[lbl].add(nid)
iv = args.get(IVARG_ROLE)
if iv is None:
errors.append('EP {nid} is missing an intrinsic variable.'
.format(nid))
if is_q:
if iv in bvs:
errors.append('{} is the bound variable for more than '
'one quantifier.'.format(iv))
bvs[iv] = nid
else:
if iv in ivs:
errors.append('{} is the intrinsic variable for more '
'than one EP.'.format(iv))
ivs[iv] = nid
# ep_args[nid] = args
for hc in _hcons.values():
if hc[2] not in labels:
errors.append('Lo variable of HCONS ({} {} {}) is not the '
'label of any EP.'.format(*hc))
if not self.is_connected():
errors.append('Xmrs structure is not connected.')
if errors:
raise XmrsError('\n'.join(errors)) | python | def validate(self):
errors = []
ivs, bvs = {}, {}
_vars = self._vars
_hcons = self._hcons
labels = defaultdict(set)
# ep_args = {}
for ep in self.eps():
nid, lbl, args, is_q = (
ep.nodeid, ep.label, ep.args, ep.is_quantifier()
)
if lbl is None:
errors.append('EP ({}) is missing a label.'.format(nid))
labels[lbl].add(nid)
iv = args.get(IVARG_ROLE)
if iv is None:
errors.append('EP {nid} is missing an intrinsic variable.'
.format(nid))
if is_q:
if iv in bvs:
errors.append('{} is the bound variable for more than '
'one quantifier.'.format(iv))
bvs[iv] = nid
else:
if iv in ivs:
errors.append('{} is the intrinsic variable for more '
'than one EP.'.format(iv))
ivs[iv] = nid
# ep_args[nid] = args
for hc in _hcons.values():
if hc[2] not in labels:
errors.append('Lo variable of HCONS ({} {} {}) is not the '
'label of any EP.'.format(*hc))
if not self.is_connected():
errors.append('Xmrs structure is not connected.')
if errors:
raise XmrsError('\n'.join(errors)) | [
"def",
"validate",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"ivs",
",",
"bvs",
"=",
"{",
"}",
",",
"{",
"}",
"_vars",
"=",
"self",
".",
"_vars",
"_hcons",
"=",
"self",
".",
"_hcons",
"labels",
"=",
"defaultdict",
"(",
"set",
")",
"# ep_arg... | Check that the Xmrs is well-formed.
The Xmrs is analyzed and a list of problems is compiled. If
any problems exist, an :exc:`XmrsError` is raised with the list
joined as the error message. A well-formed Xmrs has the
following properties:
* All predications have an intrinsic variable
* Every intrinsic variable belongs one predication and maybe
one quantifier
* Every predication has no more than one quantifier
* All predications have a label
* The graph of predications form a net (i.e. are connected).
Connectivity can be established with variable arguments,
QEQs, or label-equality.
* The lo-handle for each QEQ must exist as the label of a
predication | [
"Check",
"that",
"the",
"Xmrs",
"is",
"well",
"-",
"formed",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/xmrs.py#L664-L719 |
8,923 | delph-in/pydelphin | delphin/mrs/xmrs.py | Mrs.to_dict | def to_dict(self, short_pred=True, properties=True):
"""
Encode the Mrs as a dictionary suitable for JSON serialization.
"""
def _lnk(obj): return {'from': obj.cfrom, 'to': obj.cto}
def _ep(ep, short_pred=True):
p = ep.pred.short_form() if short_pred else ep.pred.string
d = dict(label=ep.label, predicate=p, arguments=ep.args)
if ep.lnk is not None: d['lnk'] = _lnk(ep)
return d
def _hcons(hc): return {'relation':hc[1], 'high':hc[0], 'low':hc[2]}
def _icons(ic): return {'relation':ic[1], 'left':ic[0], 'right':ic[2]}
def _var(v):
d = {'type': var_sort(v)}
if properties and self.properties(v):
d['properties'] = self.properties(v)
return d
d = dict(
relations=[_ep(ep, short_pred=short_pred) for ep in self.eps()],
constraints=([_hcons(hc) for hc in self.hcons()] +
[_icons(ic) for ic in self.icons()]),
variables={v: _var(v) for v in self.variables()}
)
if self.top is not None: d['top'] = self.top
if self.index is not None: d['index'] = self.index
# if self.xarg is not None: d['xarg'] = self.xarg
# if self.lnk is not None: d['lnk'] = self.lnk
# if self.surface is not None: d['surface'] = self.surface
# if self.identifier is not None: d['identifier'] = self.identifier
return d | python | def to_dict(self, short_pred=True, properties=True):
def _lnk(obj): return {'from': obj.cfrom, 'to': obj.cto}
def _ep(ep, short_pred=True):
p = ep.pred.short_form() if short_pred else ep.pred.string
d = dict(label=ep.label, predicate=p, arguments=ep.args)
if ep.lnk is not None: d['lnk'] = _lnk(ep)
return d
def _hcons(hc): return {'relation':hc[1], 'high':hc[0], 'low':hc[2]}
def _icons(ic): return {'relation':ic[1], 'left':ic[0], 'right':ic[2]}
def _var(v):
d = {'type': var_sort(v)}
if properties and self.properties(v):
d['properties'] = self.properties(v)
return d
d = dict(
relations=[_ep(ep, short_pred=short_pred) for ep in self.eps()],
constraints=([_hcons(hc) for hc in self.hcons()] +
[_icons(ic) for ic in self.icons()]),
variables={v: _var(v) for v in self.variables()}
)
if self.top is not None: d['top'] = self.top
if self.index is not None: d['index'] = self.index
# if self.xarg is not None: d['xarg'] = self.xarg
# if self.lnk is not None: d['lnk'] = self.lnk
# if self.surface is not None: d['surface'] = self.surface
# if self.identifier is not None: d['identifier'] = self.identifier
return d | [
"def",
"to_dict",
"(",
"self",
",",
"short_pred",
"=",
"True",
",",
"properties",
"=",
"True",
")",
":",
"def",
"_lnk",
"(",
"obj",
")",
":",
"return",
"{",
"'from'",
":",
"obj",
".",
"cfrom",
",",
"'to'",
":",
"obj",
".",
"cto",
"}",
"def",
"_ep... | Encode the Mrs as a dictionary suitable for JSON serialization. | [
"Encode",
"the",
"Mrs",
"as",
"a",
"dictionary",
"suitable",
"for",
"JSON",
"serialization",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/xmrs.py#L783-L813 |
8,924 | delph-in/pydelphin | delphin/mrs/xmrs.py | Dmrs.to_dict | def to_dict(self, short_pred=True, properties=True):
"""
Encode the Dmrs as a dictionary suitable for JSON serialization.
"""
qs = set(self.nodeids(quantifier=True))
def _lnk(obj): return {'from': obj.cfrom, 'to': obj.cto}
def _node(node, short_pred=True):
p = node.pred.short_form() if short_pred else node.pred.string
d = dict(nodeid=node.nodeid, predicate=p)
if node.lnk is not None: d['lnk'] = _lnk(node)
if properties and node.sortinfo:
if node.nodeid not in qs:
d['sortinfo'] = node.sortinfo
if node.surface is not None: d['surface'] = node.surface
if node.base is not None: d['base'] = node.base
if node.carg is not None: d['carg'] = node.carg
return d
def _link(link): return {
'from': link.start, 'to': link.end,
'rargname': link.rargname, 'post': link.post
}
d = dict(
nodes=[_node(n) for n in nodes(self)],
links=[_link(l) for l in links(self)]
)
# if self.top is not None: ... currently handled by links
if self.index is not None:
idx = self.nodeid(self.index)
if idx is not None:
d['index'] = idx
if self.xarg is not None:
xarg = self.nodeid(self.index)
if xarg is not None:
d['index'] = xarg
if self.lnk is not None: d['lnk'] = _lnk(self)
if self.surface is not None: d['surface'] = self.surface
if self.identifier is not None: d['identifier'] = self.identifier
return d | python | def to_dict(self, short_pred=True, properties=True):
qs = set(self.nodeids(quantifier=True))
def _lnk(obj): return {'from': obj.cfrom, 'to': obj.cto}
def _node(node, short_pred=True):
p = node.pred.short_form() if short_pred else node.pred.string
d = dict(nodeid=node.nodeid, predicate=p)
if node.lnk is not None: d['lnk'] = _lnk(node)
if properties and node.sortinfo:
if node.nodeid not in qs:
d['sortinfo'] = node.sortinfo
if node.surface is not None: d['surface'] = node.surface
if node.base is not None: d['base'] = node.base
if node.carg is not None: d['carg'] = node.carg
return d
def _link(link): return {
'from': link.start, 'to': link.end,
'rargname': link.rargname, 'post': link.post
}
d = dict(
nodes=[_node(n) for n in nodes(self)],
links=[_link(l) for l in links(self)]
)
# if self.top is not None: ... currently handled by links
if self.index is not None:
idx = self.nodeid(self.index)
if idx is not None:
d['index'] = idx
if self.xarg is not None:
xarg = self.nodeid(self.index)
if xarg is not None:
d['index'] = xarg
if self.lnk is not None: d['lnk'] = _lnk(self)
if self.surface is not None: d['surface'] = self.surface
if self.identifier is not None: d['identifier'] = self.identifier
return d | [
"def",
"to_dict",
"(",
"self",
",",
"short_pred",
"=",
"True",
",",
"properties",
"=",
"True",
")",
":",
"qs",
"=",
"set",
"(",
"self",
".",
"nodeids",
"(",
"quantifier",
"=",
"True",
")",
")",
"def",
"_lnk",
"(",
"obj",
")",
":",
"return",
"{",
... | Encode the Dmrs as a dictionary suitable for JSON serialization. | [
"Encode",
"the",
"Dmrs",
"as",
"a",
"dictionary",
"suitable",
"for",
"JSON",
"serialization",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/xmrs.py#L1011-L1049 |
8,925 | delph-in/pydelphin | delphin/mrs/xmrs.py | Dmrs.to_triples | def to_triples(self, short_pred=True, properties=True):
"""
Encode the Dmrs as triples suitable for PENMAN serialization.
"""
ts = []
qs = set(self.nodeids(quantifier=True))
for n in nodes(self):
pred = n.pred.short_form() if short_pred else n.pred.string
ts.append((n.nodeid, 'predicate', pred))
if n.lnk is not None:
ts.append((n.nodeid, 'lnk', '"{}"'.format(str(n.lnk))))
if n.carg is not None:
ts.append((n.nodeid, 'carg', '"{}"'.format(n.carg)))
if properties and n.nodeid not in qs:
for key, value in n.sortinfo.items():
ts.append((n.nodeid, key.lower(), value))
for l in links(self):
if safe_int(l.start) == LTOP_NODEID:
ts.append((l.start, 'top', l.end))
else:
relation = '{}-{}'.format(l.rargname.upper(), l.post)
ts.append((l.start, relation, l.end))
return ts | python | def to_triples(self, short_pred=True, properties=True):
ts = []
qs = set(self.nodeids(quantifier=True))
for n in nodes(self):
pred = n.pred.short_form() if short_pred else n.pred.string
ts.append((n.nodeid, 'predicate', pred))
if n.lnk is not None:
ts.append((n.nodeid, 'lnk', '"{}"'.format(str(n.lnk))))
if n.carg is not None:
ts.append((n.nodeid, 'carg', '"{}"'.format(n.carg)))
if properties and n.nodeid not in qs:
for key, value in n.sortinfo.items():
ts.append((n.nodeid, key.lower(), value))
for l in links(self):
if safe_int(l.start) == LTOP_NODEID:
ts.append((l.start, 'top', l.end))
else:
relation = '{}-{}'.format(l.rargname.upper(), l.post)
ts.append((l.start, relation, l.end))
return ts | [
"def",
"to_triples",
"(",
"self",
",",
"short_pred",
"=",
"True",
",",
"properties",
"=",
"True",
")",
":",
"ts",
"=",
"[",
"]",
"qs",
"=",
"set",
"(",
"self",
".",
"nodeids",
"(",
"quantifier",
"=",
"True",
")",
")",
"for",
"n",
"in",
"nodes",
"... | Encode the Dmrs as triples suitable for PENMAN serialization. | [
"Encode",
"the",
"Dmrs",
"as",
"triples",
"suitable",
"for",
"PENMAN",
"serialization",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/xmrs.py#L1079-L1102 |
8,926 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | Invoice.to_array | def to_array(self):
"""
Serializes this Invoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Invoice, self).to_array()
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['description'] = u(self.description) # py2: type unicode, py3: type str
array['start_parameter'] = u(self.start_parameter) # py2: type unicode, py3: type str
array['currency'] = u(self.currency) # py2: type unicode, py3: type str
array['total_amount'] = int(self.total_amount) # type int
return array | python | def to_array(self):
array = super(Invoice, self).to_array()
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['description'] = u(self.description) # py2: type unicode, py3: type str
array['start_parameter'] = u(self.start_parameter) # py2: type unicode, py3: type str
array['currency'] = u(self.currency) # py2: type unicode, py3: type str
array['total_amount'] = int(self.total_amount) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Invoice",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'title'",
"]",
"=",
"u",
"(",
"self",
".",
"title",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
"'... | Serializes this Invoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Invoice",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L88-L101 |
8,927 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | ShippingAddress.to_array | def to_array(self):
"""
Serializes this ShippingAddress to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ShippingAddress, self).to_array()
array['country_code'] = u(self.country_code) # py2: type unicode, py3: type str
array['state'] = u(self.state) # py2: type unicode, py3: type str
array['city'] = u(self.city) # py2: type unicode, py3: type str
array['street_line1'] = u(self.street_line1) # py2: type unicode, py3: type str
array['street_line2'] = u(self.street_line2) # py2: type unicode, py3: type str
array['post_code'] = u(self.post_code) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(ShippingAddress, self).to_array()
array['country_code'] = u(self.country_code) # py2: type unicode, py3: type str
array['state'] = u(self.state) # py2: type unicode, py3: type str
array['city'] = u(self.city) # py2: type unicode, py3: type str
array['street_line1'] = u(self.street_line1) # py2: type unicode, py3: type str
array['street_line2'] = u(self.street_line2) # py2: type unicode, py3: type str
array['post_code'] = u(self.post_code) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"ShippingAddress",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'country_code'",
"]",
"=",
"u",
"(",
"self",
".",
"country_code",
")",
"# py2: type unicode, py3: type str",
... | Serializes this ShippingAddress to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"ShippingAddress",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L243-L257 |
8,928 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | OrderInfo.to_array | def to_array(self):
"""
Serializes this OrderInfo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(OrderInfo, self).to_array()
if self.name is not None:
array['name'] = u(self.name) # py2: type unicode, py3: type str
if self.phone_number is not None:
array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str
if self.email is not None:
array['email'] = u(self.email) # py2: type unicode, py3: type str
if self.shipping_address is not None:
array['shipping_address'] = self.shipping_address.to_array() # type ShippingAddress
return array | python | def to_array(self):
array = super(OrderInfo, self).to_array()
if self.name is not None:
array['name'] = u(self.name) # py2: type unicode, py3: type str
if self.phone_number is not None:
array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str
if self.email is not None:
array['email'] = u(self.email) # py2: type unicode, py3: type str
if self.shipping_address is not None:
array['shipping_address'] = self.shipping_address.to_array() # type ShippingAddress
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"OrderInfo",
",",
"self",
")",
".",
"to_array",
"(",
")",
"if",
"self",
".",
"name",
"is",
"not",
"None",
":",
"array",
"[",
"'name'",
"]",
"=",
"u",
"(",
"self",
".",
"name",
... | Serializes this OrderInfo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"OrderInfo",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L377-L393 |
8,929 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | SuccessfulPayment.to_array | def to_array(self):
"""
Serializes this SuccessfulPayment to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(SuccessfulPayment, self).to_array()
array['currency'] = u(self.currency) # py2: type unicode, py3: type str
array['total_amount'] = int(self.total_amount) # type int
array['invoice_payload'] = u(self.invoice_payload) # py2: type unicode, py3: type str
array['telegram_payment_charge_id'] = u(self.telegram_payment_charge_id) # py2: type unicode, py3: type str
array['provider_payment_charge_id'] = u(self.provider_payment_charge_id) # py2: type unicode, py3: type str
if self.shipping_option_id is not None:
array['shipping_option_id'] = u(self.shipping_option_id) # py2: type unicode, py3: type str
if self.order_info is not None:
array['order_info'] = self.order_info.to_array() # type OrderInfo
return array | python | def to_array(self):
array = super(SuccessfulPayment, self).to_array()
array['currency'] = u(self.currency) # py2: type unicode, py3: type str
array['total_amount'] = int(self.total_amount) # type int
array['invoice_payload'] = u(self.invoice_payload) # py2: type unicode, py3: type str
array['telegram_payment_charge_id'] = u(self.telegram_payment_charge_id) # py2: type unicode, py3: type str
array['provider_payment_charge_id'] = u(self.provider_payment_charge_id) # py2: type unicode, py3: type str
if self.shipping_option_id is not None:
array['shipping_option_id'] = u(self.shipping_option_id) # py2: type unicode, py3: type str
if self.order_info is not None:
array['order_info'] = self.order_info.to_array() # type OrderInfo
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"SuccessfulPayment",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'currency'",
"]",
"=",
"u",
"(",
"self",
".",
"currency",
")",
"# py2: type unicode, py3: type str",
"arr... | Serializes this SuccessfulPayment to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"SuccessfulPayment",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L544-L561 |
8,930 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | SuccessfulPayment.from_array | def from_array(array):
"""
Deserialize a new SuccessfulPayment from a given dictionary.
:return: new SuccessfulPayment instance.
:rtype: SuccessfulPayment
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['currency'] = u(array.get('currency'))
data['total_amount'] = int(array.get('total_amount'))
data['invoice_payload'] = u(array.get('invoice_payload'))
data['telegram_payment_charge_id'] = u(array.get('telegram_payment_charge_id'))
data['provider_payment_charge_id'] = u(array.get('provider_payment_charge_id'))
data['shipping_option_id'] = u(array.get('shipping_option_id')) if array.get('shipping_option_id') is not None else None
data['order_info'] = OrderInfo.from_array(array.get('order_info')) if array.get('order_info') is not None else None
data['_raw'] = array
return SuccessfulPayment(**data) | python | 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['currency'] = u(array.get('currency'))
data['total_amount'] = int(array.get('total_amount'))
data['invoice_payload'] = u(array.get('invoice_payload'))
data['telegram_payment_charge_id'] = u(array.get('telegram_payment_charge_id'))
data['provider_payment_charge_id'] = u(array.get('provider_payment_charge_id'))
data['shipping_option_id'] = u(array.get('shipping_option_id')) if array.get('shipping_option_id') is not None else None
data['order_info'] = OrderInfo.from_array(array.get('order_info')) if array.get('order_info') is not None else None
data['_raw'] = array
return SuccessfulPayment(**data) | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new SuccessfulPayment from a given dictionary.
:return: new SuccessfulPayment instance.
:rtype: SuccessfulPayment | [
"Deserialize",
"a",
"new",
"SuccessfulPayment",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L565-L586 |
8,931 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | ShippingQuery.to_array | def to_array(self):
"""
Serializes this ShippingQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ShippingQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['invoice_payload'] = u(self.invoice_payload) # py2: type unicode, py3: type str
array['shipping_address'] = self.shipping_address.to_array() # type ShippingAddress
return array | python | def to_array(self):
array = super(ShippingQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['invoice_payload'] = u(self.invoice_payload) # py2: type unicode, py3: type str
array['shipping_address'] = self.shipping_address.to_array() # type ShippingAddress
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"ShippingQuery",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'id'",
"]",
"=",
"u",
"(",
"self",
".",
"id",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
"'... | Serializes this ShippingQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"ShippingQuery",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L689-L701 |
8,932 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | ShippingQuery.from_array | def from_array(array):
"""
Deserialize a new ShippingQuery from a given dictionary.
:return: new ShippingQuery instance.
:rtype: ShippingQuery
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['invoice_payload'] = u(array.get('invoice_payload'))
data['shipping_address'] = ShippingAddress.from_array(array.get('shipping_address'))
data['_raw'] = array
return ShippingQuery(**data) | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['invoice_payload'] = u(array.get('invoice_payload'))
data['shipping_address'] = ShippingAddress.from_array(array.get('shipping_address'))
data['_raw'] = array
return ShippingQuery(**data) | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
"pytgbot",
".",
"api... | Deserialize a new ShippingQuery from a given dictionary.
:return: new ShippingQuery instance.
:rtype: ShippingQuery | [
"Deserialize",
"a",
"new",
"ShippingQuery",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L705-L724 |
8,933 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | PreCheckoutQuery.to_array | def to_array(self):
"""
Serializes this PreCheckoutQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PreCheckoutQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['currency'] = u(self.currency) # py2: type unicode, py3: type str
array['total_amount'] = int(self.total_amount) # type int
array['invoice_payload'] = u(self.invoice_payload) # py2: type unicode, py3: type str
if self.shipping_option_id is not None:
array['shipping_option_id'] = u(self.shipping_option_id) # py2: type unicode, py3: type str
if self.order_info is not None:
array['order_info'] = self.order_info.to_array() # type OrderInfo
return array | python | def to_array(self):
array = super(PreCheckoutQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['currency'] = u(self.currency) # py2: type unicode, py3: type str
array['total_amount'] = int(self.total_amount) # type int
array['invoice_payload'] = u(self.invoice_payload) # py2: type unicode, py3: type str
if self.shipping_option_id is not None:
array['shipping_option_id'] = u(self.shipping_option_id) # py2: type unicode, py3: type str
if self.order_info is not None:
array['order_info'] = self.order_info.to_array() # type OrderInfo
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"PreCheckoutQuery",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'id'",
"]",
"=",
"u",
"(",
"self",
".",
"id",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
... | Serializes this PreCheckoutQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"PreCheckoutQuery",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L854-L871 |
8,934 | luckydonald/pytgbot | pytgbot/api_types/receivable/payments.py | PreCheckoutQuery.from_array | def from_array(array):
"""
Deserialize a new PreCheckoutQuery from a given dictionary.
:return: new PreCheckoutQuery instance.
:rtype: PreCheckoutQuery
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['currency'] = u(array.get('currency'))
data['total_amount'] = int(array.get('total_amount'))
data['invoice_payload'] = u(array.get('invoice_payload'))
data['shipping_option_id'] = u(array.get('shipping_option_id')) if array.get('shipping_option_id') is not None else None
data['order_info'] = OrderInfo.from_array(array.get('order_info')) if array.get('order_info') is not None else None
data['_raw'] = array
return PreCheckoutQuery(**data) | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['currency'] = u(array.get('currency'))
data['total_amount'] = int(array.get('total_amount'))
data['invoice_payload'] = u(array.get('invoice_payload'))
data['shipping_option_id'] = u(array.get('shipping_option_id')) if array.get('shipping_option_id') is not None else None
data['order_info'] = OrderInfo.from_array(array.get('order_info')) if array.get('order_info') is not None else None
data['_raw'] = array
return PreCheckoutQuery(**data) | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
"pytgbot",
".",
"api... | Deserialize a new PreCheckoutQuery from a given dictionary.
:return: new PreCheckoutQuery instance.
:rtype: PreCheckoutQuery | [
"Deserialize",
"a",
"new",
"PreCheckoutQuery",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/payments.py#L875-L897 |
8,935 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/input_media.py | InputMediaPhoto.to_array | def to_array(self):
"""
Serializes this InputMediaPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InputMediaPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['media'] = u(self.media) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(InputMediaPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['media'] = u(self.media) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InputMediaPhoto",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"array",
"["... | Serializes this InputMediaPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InputMediaPhoto",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/input_media.py#L72-L90 |
8,936 | delph-in/pydelphin | delphin/mrs/prolog.py | dump | def dump(destination, ms, single=False, pretty_print=False, **kwargs):
"""
Serialize Xmrs objects to the Prolog representation and write to a file.
Args:
destination: filename or file object where data will be written
ms: an iterator of Xmrs objects to serialize (unless the
*single* option is `True`)
single: if `True`, treat *ms* as a single Xmrs object
instead of as an iterator
pretty_print: if `True`, add newlines and indentation
"""
text = dumps(ms,
single=single,
pretty_print=pretty_print,
**kwargs)
if hasattr(destination, 'write'):
print(text, file=destination)
else:
with open(destination, 'w') as fh:
print(text, file=fh) | python | def dump(destination, ms, single=False, pretty_print=False, **kwargs):
text = dumps(ms,
single=single,
pretty_print=pretty_print,
**kwargs)
if hasattr(destination, 'write'):
print(text, file=destination)
else:
with open(destination, 'w') as fh:
print(text, file=fh) | [
"def",
"dump",
"(",
"destination",
",",
"ms",
",",
"single",
"=",
"False",
",",
"pretty_print",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"text",
"=",
"dumps",
"(",
"ms",
",",
"single",
"=",
"single",
",",
"pretty_print",
"=",
"pretty_print",
... | Serialize Xmrs objects to the Prolog representation and write to a file.
Args:
destination: filename or file object where data will be written
ms: an iterator of Xmrs objects to serialize (unless the
*single* option is `True`)
single: if `True`, treat *ms* as a single Xmrs object
instead of as an iterator
pretty_print: if `True`, add newlines and indentation | [
"Serialize",
"Xmrs",
"objects",
"to",
"the",
"Prolog",
"representation",
"and",
"write",
"to",
"a",
"file",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/prolog.py#L32-L53 |
8,937 | delph-in/pydelphin | delphin/mrs/prolog.py | dumps | def dumps(ms, single=False, pretty_print=False, **kwargs):
"""
Serialize an Xmrs object to the Prolog representation
Args:
ms: an iterator of Xmrs objects to serialize (unless the
*single* option is `True`)
single: if `True`, treat *ms* as a single Xmrs object instead
of as an iterator
pretty_print: if `True`, add newlines and indentation
Returns:
the Prolog string representation of a corpus of Xmrs
"""
if single:
ms = [ms]
return serialize(ms, pretty_print=pretty_print, **kwargs) | python | def dumps(ms, single=False, pretty_print=False, **kwargs):
if single:
ms = [ms]
return serialize(ms, pretty_print=pretty_print, **kwargs) | [
"def",
"dumps",
"(",
"ms",
",",
"single",
"=",
"False",
",",
"pretty_print",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"single",
":",
"ms",
"=",
"[",
"ms",
"]",
"return",
"serialize",
"(",
"ms",
",",
"pretty_print",
"=",
"pretty_print",
... | Serialize an Xmrs object to the Prolog representation
Args:
ms: an iterator of Xmrs objects to serialize (unless the
*single* option is `True`)
single: if `True`, treat *ms* as a single Xmrs object instead
of as an iterator
pretty_print: if `True`, add newlines and indentation
Returns:
the Prolog string representation of a corpus of Xmrs | [
"Serialize",
"an",
"Xmrs",
"object",
"to",
"the",
"Prolog",
"representation"
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/prolog.py#L56-L71 |
8,938 | delph-in/pydelphin | delphin/commands.py | convert | def convert(path, source_fmt, target_fmt, select='result:mrs',
properties=True, show_status=False, predicate_modifiers=False,
color=False, pretty_print=False, indent=None):
"""
Convert between various DELPH-IN Semantics representations.
Args:
path (str, file): filename, testsuite directory, open file, or
stream of input representations
source_fmt (str): convert from this format
target_fmt (str): convert to this format
select (str): TSQL query for selecting data (ignored if *path*
is not a testsuite directory; default: `"result:mrs"`)
properties (bool): include morphosemantic properties if `True`
(default: `True`)
show_status (bool): show disconnected EDS nodes (ignored if
*target_fmt* is not `"eds"`; default: `False`)
predicate_modifiers (bool): apply EDS predicate modification
for certain kinds of patterns (ignored if *target_fmt* is
not an EDS format; default: `False`)
color (bool): apply syntax highlighting if `True` and
*target_fmt* is `"simplemrs"` (default: `False`)
pretty_print (bool): if `True`, format the output with
newlines and default indentation (default: `False`)
indent (int, optional): specifies an explicit number of spaces
for indentation (implies *pretty_print*)
Returns:
str: the converted representation
"""
if source_fmt.startswith('eds') and not target_fmt.startswith('eds'):
raise ValueError(
'Conversion from EDS to non-EDS currently not supported.')
if indent:
pretty_print = True
indent = 4 if indent is True else safe_int(indent)
if len(tsql.inspect_query('select ' + select)['projection']) != 1:
raise ValueError('Exactly 1 column must be given in selection query: '
'(e.g., result:mrs)')
# read
loads = _get_codec(source_fmt)
if path is None:
xs = loads(sys.stdin.read())
elif hasattr(path, 'read'):
xs = loads(path.read())
elif os.path.isdir(path):
ts = itsdb.TestSuite(path)
xs = [
next(iter(loads(r[0])), None)
for r in tsql.select(select, ts)
]
else:
xs = loads(open(path, 'r').read())
# write
dumps = _get_codec(target_fmt, load=False)
kwargs = {}
if color: kwargs['color'] = color
if pretty_print: kwargs['pretty_print'] = pretty_print
if indent: kwargs['indent'] = indent
if target_fmt == 'eds':
kwargs['pretty_print'] = pretty_print
kwargs['show_status'] = show_status
if target_fmt.startswith('eds'):
kwargs['predicate_modifiers'] = predicate_modifiers
kwargs['properties'] = properties
# this is not a great way to improve robustness when converting
# many representations, but it'll do until v1.0.0. Also, it only
# improves robustness on the output, not the input.
# Note that all the code below is to replace the following:
# return dumps(xs, **kwargs)
head, joiner, tail = _get_output_details(target_fmt)
parts = []
if pretty_print:
joiner = joiner.strip() + '\n'
def _trim(s):
if head and s.startswith(head):
s = s[len(head):].lstrip('\n')
if tail and s.endswith(tail):
s = s[:-len(tail)].rstrip('\n')
return s
for x in xs:
try:
s = dumps([x], **kwargs)
except (PyDelphinException, KeyError, IndexError):
logging.exception('could not convert representation')
else:
s = _trim(s)
parts.append(s)
# set these after so head and tail are used correctly in _trim
if pretty_print:
if head:
head += '\n'
if tail:
tail = '\n' + tail
return head + joiner.join(parts) + tail | python | def convert(path, source_fmt, target_fmt, select='result:mrs',
properties=True, show_status=False, predicate_modifiers=False,
color=False, pretty_print=False, indent=None):
if source_fmt.startswith('eds') and not target_fmt.startswith('eds'):
raise ValueError(
'Conversion from EDS to non-EDS currently not supported.')
if indent:
pretty_print = True
indent = 4 if indent is True else safe_int(indent)
if len(tsql.inspect_query('select ' + select)['projection']) != 1:
raise ValueError('Exactly 1 column must be given in selection query: '
'(e.g., result:mrs)')
# read
loads = _get_codec(source_fmt)
if path is None:
xs = loads(sys.stdin.read())
elif hasattr(path, 'read'):
xs = loads(path.read())
elif os.path.isdir(path):
ts = itsdb.TestSuite(path)
xs = [
next(iter(loads(r[0])), None)
for r in tsql.select(select, ts)
]
else:
xs = loads(open(path, 'r').read())
# write
dumps = _get_codec(target_fmt, load=False)
kwargs = {}
if color: kwargs['color'] = color
if pretty_print: kwargs['pretty_print'] = pretty_print
if indent: kwargs['indent'] = indent
if target_fmt == 'eds':
kwargs['pretty_print'] = pretty_print
kwargs['show_status'] = show_status
if target_fmt.startswith('eds'):
kwargs['predicate_modifiers'] = predicate_modifiers
kwargs['properties'] = properties
# this is not a great way to improve robustness when converting
# many representations, but it'll do until v1.0.0. Also, it only
# improves robustness on the output, not the input.
# Note that all the code below is to replace the following:
# return dumps(xs, **kwargs)
head, joiner, tail = _get_output_details(target_fmt)
parts = []
if pretty_print:
joiner = joiner.strip() + '\n'
def _trim(s):
if head and s.startswith(head):
s = s[len(head):].lstrip('\n')
if tail and s.endswith(tail):
s = s[:-len(tail)].rstrip('\n')
return s
for x in xs:
try:
s = dumps([x], **kwargs)
except (PyDelphinException, KeyError, IndexError):
logging.exception('could not convert representation')
else:
s = _trim(s)
parts.append(s)
# set these after so head and tail are used correctly in _trim
if pretty_print:
if head:
head += '\n'
if tail:
tail = '\n' + tail
return head + joiner.join(parts) + tail | [
"def",
"convert",
"(",
"path",
",",
"source_fmt",
",",
"target_fmt",
",",
"select",
"=",
"'result:mrs'",
",",
"properties",
"=",
"True",
",",
"show_status",
"=",
"False",
",",
"predicate_modifiers",
"=",
"False",
",",
"color",
"=",
"False",
",",
"pretty_prin... | Convert between various DELPH-IN Semantics representations.
Args:
path (str, file): filename, testsuite directory, open file, or
stream of input representations
source_fmt (str): convert from this format
target_fmt (str): convert to this format
select (str): TSQL query for selecting data (ignored if *path*
is not a testsuite directory; default: `"result:mrs"`)
properties (bool): include morphosemantic properties if `True`
(default: `True`)
show_status (bool): show disconnected EDS nodes (ignored if
*target_fmt* is not `"eds"`; default: `False`)
predicate_modifiers (bool): apply EDS predicate modification
for certain kinds of patterns (ignored if *target_fmt* is
not an EDS format; default: `False`)
color (bool): apply syntax highlighting if `True` and
*target_fmt* is `"simplemrs"` (default: `False`)
pretty_print (bool): if `True`, format the output with
newlines and default indentation (default: `False`)
indent (int, optional): specifies an explicit number of spaces
for indentation (implies *pretty_print*)
Returns:
str: the converted representation | [
"Convert",
"between",
"various",
"DELPH",
"-",
"IN",
"Semantics",
"representations",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/commands.py#L29-L127 |
8,939 | delph-in/pydelphin | delphin/mrs/eds.py | non_argument_modifiers | def non_argument_modifiers(role='ARG1', only_connecting=True):
"""
Return a function that finds non-argument modifier dependencies.
Args:
role (str): the role that is assigned to the dependency
only_connecting (bool): if `True`, only return dependencies
that connect separate components in the basic dependencies;
if `False`, all non-argument modifier dependencies are
included
Returns:
a function with signature `func(xmrs, deps)` that returns a
mapping of non-argument modifier dependencies
Examples:
The default function behaves like the LKB:
>>> func = non_argument_modifiers()
A variation is similar to DMRS's MOD/EQ links:
>>> func = non_argument_modifiers(role="MOD", only_connecting=False)
"""
def func(xmrs, deps):
edges = []
for src in deps:
for _, tgt in deps[src]:
edges.append((src, tgt))
components = _connected_components(xmrs.nodeids(), edges)
ccmap = {}
for i, component in enumerate(components):
for n in component:
ccmap[n] = i
addl = {}
if not only_connecting or len(components) > 1:
lsh = xmrs.labelset_heads
lblheads = {v: lsh(v) for v, vd in xmrs._vars.items()
if 'LBL' in vd['refs']}
for heads in lblheads.values():
if len(heads) > 1:
first = heads[0]
joined = set([ccmap[first]])
for other in heads[1:]:
occ = ccmap[other]
srt = var_sort(xmrs.args(other).get(role, 'u0'))
needs_edge = not only_connecting or occ not in joined
edge_available = srt == 'u'
if needs_edge and edge_available:
addl.setdefault(other, []).append((role, first))
joined.add(occ)
return addl
return func | python | def non_argument_modifiers(role='ARG1', only_connecting=True):
def func(xmrs, deps):
edges = []
for src in deps:
for _, tgt in deps[src]:
edges.append((src, tgt))
components = _connected_components(xmrs.nodeids(), edges)
ccmap = {}
for i, component in enumerate(components):
for n in component:
ccmap[n] = i
addl = {}
if not only_connecting or len(components) > 1:
lsh = xmrs.labelset_heads
lblheads = {v: lsh(v) for v, vd in xmrs._vars.items()
if 'LBL' in vd['refs']}
for heads in lblheads.values():
if len(heads) > 1:
first = heads[0]
joined = set([ccmap[first]])
for other in heads[1:]:
occ = ccmap[other]
srt = var_sort(xmrs.args(other).get(role, 'u0'))
needs_edge = not only_connecting or occ not in joined
edge_available = srt == 'u'
if needs_edge and edge_available:
addl.setdefault(other, []).append((role, first))
joined.add(occ)
return addl
return func | [
"def",
"non_argument_modifiers",
"(",
"role",
"=",
"'ARG1'",
",",
"only_connecting",
"=",
"True",
")",
":",
"def",
"func",
"(",
"xmrs",
",",
"deps",
")",
":",
"edges",
"=",
"[",
"]",
"for",
"src",
"in",
"deps",
":",
"for",
"_",
",",
"tgt",
"in",
"d... | Return a function that finds non-argument modifier dependencies.
Args:
role (str): the role that is assigned to the dependency
only_connecting (bool): if `True`, only return dependencies
that connect separate components in the basic dependencies;
if `False`, all non-argument modifier dependencies are
included
Returns:
a function with signature `func(xmrs, deps)` that returns a
mapping of non-argument modifier dependencies
Examples:
The default function behaves like the LKB:
>>> func = non_argument_modifiers()
A variation is similar to DMRS's MOD/EQ links:
>>> func = non_argument_modifiers(role="MOD", only_connecting=False) | [
"Return",
"a",
"function",
"that",
"finds",
"non",
"-",
"argument",
"modifier",
"dependencies",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/eds.py#L277-L332 |
8,940 | delph-in/pydelphin | delphin/mrs/eds.py | dumps | def dumps(ms, single=False,
properties=False, pretty_print=True,
show_status=False, predicate_modifiers=False, **kwargs):
"""
Serialize an Xmrs object to a Eds representation
Args:
ms: an iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to
serialize (unless the *single* option is `True`)
single (bool): if `True`, treat *ms* as a single
:class:`~delphin.mrs.xmrs.Xmrs` object instead of as an
iterator
properties (bool): if `False`, suppress variable properties
pretty_print (bool): if `True`, add newlines and indentation
show_status (bool): if `True`, annotate disconnected graphs and
nodes
Returns:
an :class:`Eds` string representation of a corpus of Xmrs
"""
if not pretty_print and kwargs.get('indent'):
pretty_print = True
if single:
ms = [ms]
return serialize(
ms,
properties=properties,
pretty_print=pretty_print,
show_status=show_status,
predicate_modifiers=predicate_modifiers,
**kwargs
) | python | def dumps(ms, single=False,
properties=False, pretty_print=True,
show_status=False, predicate_modifiers=False, **kwargs):
if not pretty_print and kwargs.get('indent'):
pretty_print = True
if single:
ms = [ms]
return serialize(
ms,
properties=properties,
pretty_print=pretty_print,
show_status=show_status,
predicate_modifiers=predicate_modifiers,
**kwargs
) | [
"def",
"dumps",
"(",
"ms",
",",
"single",
"=",
"False",
",",
"properties",
"=",
"False",
",",
"pretty_print",
"=",
"True",
",",
"show_status",
"=",
"False",
",",
"predicate_modifiers",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"pret... | Serialize an Xmrs object to a Eds representation
Args:
ms: an iterator of :class:`~delphin.mrs.xmrs.Xmrs` objects to
serialize (unless the *single* option is `True`)
single (bool): if `True`, treat *ms* as a single
:class:`~delphin.mrs.xmrs.Xmrs` object instead of as an
iterator
properties (bool): if `False`, suppress variable properties
pretty_print (bool): if `True`, add newlines and indentation
show_status (bool): if `True`, annotate disconnected graphs and
nodes
Returns:
an :class:`Eds` string representation of a corpus of Xmrs | [
"Serialize",
"an",
"Xmrs",
"object",
"to",
"a",
"Eds",
"representation"
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/eds.py#L438-L468 |
8,941 | delph-in/pydelphin | delphin/mrs/eds.py | Eds.nodes | def nodes(self):
"""Return the list of nodes."""
getnode = self._nodes.__getitem__
return [getnode(nid) for nid in self._nodeids] | python | def nodes(self):
getnode = self._nodes.__getitem__
return [getnode(nid) for nid in self._nodeids] | [
"def",
"nodes",
"(",
"self",
")",
":",
"getnode",
"=",
"self",
".",
"_nodes",
".",
"__getitem__",
"return",
"[",
"getnode",
"(",
"nid",
")",
"for",
"nid",
"in",
"self",
".",
"_nodeids",
"]"
] | Return the list of nodes. | [
"Return",
"the",
"list",
"of",
"nodes",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/eds.py#L129-L132 |
8,942 | delph-in/pydelphin | delphin/mrs/eds.py | Eds.to_dict | def to_dict(self, properties=True):
"""
Encode the Eds as a dictionary suitable for JSON serialization.
"""
nodes = {}
for node in self.nodes():
nd = {
'label': node.pred.short_form(),
'edges': self.edges(node.nodeid)
}
if node.lnk is not None:
nd['lnk'] = {'from': node.cfrom, 'to': node.cto}
if properties:
if node.cvarsort is not None:
nd['type'] = node.cvarsort
props = node.properties
if props:
nd['properties'] = props
if node.carg is not None:
nd['carg'] = node.carg
nodes[node.nodeid] = nd
return {'top': self.top, 'nodes': nodes} | python | def to_dict(self, properties=True):
nodes = {}
for node in self.nodes():
nd = {
'label': node.pred.short_form(),
'edges': self.edges(node.nodeid)
}
if node.lnk is not None:
nd['lnk'] = {'from': node.cfrom, 'to': node.cto}
if properties:
if node.cvarsort is not None:
nd['type'] = node.cvarsort
props = node.properties
if props:
nd['properties'] = props
if node.carg is not None:
nd['carg'] = node.carg
nodes[node.nodeid] = nd
return {'top': self.top, 'nodes': nodes} | [
"def",
"to_dict",
"(",
"self",
",",
"properties",
"=",
"True",
")",
":",
"nodes",
"=",
"{",
"}",
"for",
"node",
"in",
"self",
".",
"nodes",
"(",
")",
":",
"nd",
"=",
"{",
"'label'",
":",
"node",
".",
"pred",
".",
"short_form",
"(",
")",
",",
"'... | Encode the Eds as a dictionary suitable for JSON serialization. | [
"Encode",
"the",
"Eds",
"as",
"a",
"dictionary",
"suitable",
"for",
"JSON",
"serialization",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/eds.py#L138-L159 |
8,943 | delph-in/pydelphin | delphin/mrs/eds.py | Eds.to_triples | def to_triples(self, short_pred=True, properties=True):
"""
Encode the Eds as triples suitable for PENMAN serialization.
"""
node_triples, edge_triples = [], []
# sort nodeids just so top var is first
nodes = sorted(self.nodes(), key=lambda n: n.nodeid != self.top)
for node in nodes:
nid = node.nodeid
pred = node.pred.short_form() if short_pred else node.pred.string
node_triples.append((nid, 'predicate', pred))
if node.lnk:
node_triples.append((nid, 'lnk', '"{}"'.format(str(node.lnk))))
if node.carg:
node_triples.append((nid, 'carg', '"{}"'.format(node.carg)))
if properties:
if node.cvarsort is not None:
node_triples.append((nid, 'type', node.cvarsort))
props = node.properties
node_triples.extend((nid, p, v) for p, v in props.items())
edge_triples.extend(
(nid, rargname, tgt)
for rargname, tgt in sorted(
self.edges(nid).items(),
key=lambda x: rargname_sortkey(x[0])
)
)
return node_triples + edge_triples | python | def to_triples(self, short_pred=True, properties=True):
node_triples, edge_triples = [], []
# sort nodeids just so top var is first
nodes = sorted(self.nodes(), key=lambda n: n.nodeid != self.top)
for node in nodes:
nid = node.nodeid
pred = node.pred.short_form() if short_pred else node.pred.string
node_triples.append((nid, 'predicate', pred))
if node.lnk:
node_triples.append((nid, 'lnk', '"{}"'.format(str(node.lnk))))
if node.carg:
node_triples.append((nid, 'carg', '"{}"'.format(node.carg)))
if properties:
if node.cvarsort is not None:
node_triples.append((nid, 'type', node.cvarsort))
props = node.properties
node_triples.extend((nid, p, v) for p, v in props.items())
edge_triples.extend(
(nid, rargname, tgt)
for rargname, tgt in sorted(
self.edges(nid).items(),
key=lambda x: rargname_sortkey(x[0])
)
)
return node_triples + edge_triples | [
"def",
"to_triples",
"(",
"self",
",",
"short_pred",
"=",
"True",
",",
"properties",
"=",
"True",
")",
":",
"node_triples",
",",
"edge_triples",
"=",
"[",
"]",
",",
"[",
"]",
"# sort nodeids just so top var is first",
"nodes",
"=",
"sorted",
"(",
"self",
"."... | Encode the Eds as triples suitable for PENMAN serialization. | [
"Encode",
"the",
"Eds",
"as",
"triples",
"suitable",
"for",
"PENMAN",
"serialization",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/eds.py#L194-L221 |
8,944 | delph-in/pydelphin | delphin/util.py | LookaheadIterator.next | def next(self, skip=None):
"""
Remove the next datum from the buffer and return it.
"""
buffer = self._buffer
popleft = buffer.popleft
if skip is not None:
while True:
try:
if not skip(buffer[0]):
break
popleft()
except IndexError:
self._buffer_fill()
try:
datum = popleft()
except IndexError:
self._buffer_fill()
datum = popleft()
return datum | python | def next(self, skip=None):
buffer = self._buffer
popleft = buffer.popleft
if skip is not None:
while True:
try:
if not skip(buffer[0]):
break
popleft()
except IndexError:
self._buffer_fill()
try:
datum = popleft()
except IndexError:
self._buffer_fill()
datum = popleft()
return datum | [
"def",
"next",
"(",
"self",
",",
"skip",
"=",
"None",
")",
":",
"buffer",
"=",
"self",
".",
"_buffer",
"popleft",
"=",
"buffer",
".",
"popleft",
"if",
"skip",
"is",
"not",
"None",
":",
"while",
"True",
":",
"try",
":",
"if",
"not",
"skip",
"(",
"... | Remove the next datum from the buffer and return it. | [
"Remove",
"the",
"next",
"datum",
"from",
"the",
"buffer",
"and",
"return",
"it",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/util.py#L266-L285 |
8,945 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultPhoto.to_array | def to_array(self):
"""
Serializes this InlineQueryResultPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['photo_url'] = u(self.photo_url) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.photo_width is not None:
array['photo_width'] = int(self.photo_width) # type int
if self.photo_height is not None:
array['photo_height'] = int(self.photo_height) # type int
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['photo_url'] = u(self.photo_url) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.photo_width is not None:
array['photo_width'] = int(self.photo_width) # type int
if self.photo_height is not None:
array['photo_height'] = int(self.photo_height) # type int
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultPhoto",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"array"... | Serializes this InlineQueryResultPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultPhoto",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L374-L412 |
8,946 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultMpeg4Gif.to_array | def to_array(self):
"""
Serializes this InlineQueryResultMpeg4Gif to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultMpeg4Gif, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['mpeg4_url'] = u(self.mpeg4_url) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.mpeg4_width is not None:
array['mpeg4_width'] = int(self.mpeg4_width) # type int
if self.mpeg4_height is not None:
array['mpeg4_height'] = int(self.mpeg4_height) # type int
if self.mpeg4_duration is not None:
array['mpeg4_duration'] = int(self.mpeg4_duration) # type int
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultMpeg4Gif, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['mpeg4_url'] = u(self.mpeg4_url) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.mpeg4_width is not None:
array['mpeg4_width'] = int(self.mpeg4_width) # type int
if self.mpeg4_height is not None:
array['mpeg4_height'] = int(self.mpeg4_height) # type int
if self.mpeg4_duration is not None:
array['mpeg4_duration'] = int(self.mpeg4_duration) # type int
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultMpeg4Gif",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"arr... | Serializes this InlineQueryResultMpeg4Gif to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultMpeg4Gif",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L853-L890 |
8,947 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultVideo.to_array | def to_array(self):
"""
Serializes this InlineQueryResultVideo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultVideo, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['video_url'] = u(self.video_url) # py2: type unicode, py3: type str
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.video_width is not None:
array['video_width'] = int(self.video_width) # type int
if self.video_height is not None:
array['video_height'] = int(self.video_height) # type int
if self.video_duration is not None:
array['video_duration'] = int(self.video_duration) # type int
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultVideo, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['video_url'] = u(self.video_url) # py2: type unicode, py3: type str
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.video_width is not None:
array['video_width'] = int(self.video_width) # type int
if self.video_height is not None:
array['video_height'] = int(self.video_height) # type int
if self.video_duration is not None:
array['video_duration'] = int(self.video_duration) # type int
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultVideo",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"array"... | Serializes this InlineQueryResultVideo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultVideo",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L1114-L1155 |
8,948 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultVoice.to_array | def to_array(self):
"""
Serializes this InlineQueryResultVoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultVoice, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['voice_url'] = u(self.voice_url) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.voice_duration is not None:
array['voice_duration'] = int(self.voice_duration) # type int
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultVoice, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['voice_url'] = u(self.voice_url) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.voice_duration is not None:
array['voice_duration'] = int(self.voice_duration) # type int
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultVoice",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"array"... | Serializes this InlineQueryResultVoice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultVoice",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L1551-L1581 |
8,949 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultDocument.to_array | def to_array(self):
"""
Serializes this InlineQueryResultDocument to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultDocument, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['document_url'] = u(self.document_url) # py2: type unicode, py3: type str
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
if self.thumb_url is not None:
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.thumb_width is not None:
array['thumb_width'] = int(self.thumb_width) # type int
if self.thumb_height is not None:
array['thumb_height'] = int(self.thumb_height) # type int
return array | python | def to_array(self):
array = super(InlineQueryResultDocument, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['document_url'] = u(self.document_url) # py2: type unicode, py3: type str
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
if self.thumb_url is not None:
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.thumb_width is not None:
array['thumb_width'] = int(self.thumb_width) # type int
if self.thumb_height is not None:
array['thumb_height'] = int(self.thumb_height) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultDocument",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"arr... | Serializes this InlineQueryResultDocument to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultDocument",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L1791-L1831 |
8,950 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultVenue.to_array | def to_array(self):
"""
Serializes this InlineQueryResultVenue to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultVenue, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['latitude'] = float(self.latitude) # type float
array['longitude'] = float(self.longitude) # type float
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['address'] = u(self.address) # py2: type unicode, py3: type str
if self.foursquare_id is not None:
array['foursquare_id'] = u(self.foursquare_id) # py2: type unicode, py3: type str
if self.foursquare_type is not None:
array['foursquare_type'] = u(self.foursquare_type) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
if self.thumb_url is not None:
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.thumb_width is not None:
array['thumb_width'] = int(self.thumb_width) # type int
if self.thumb_height is not None:
array['thumb_height'] = int(self.thumb_height) # type int
return array | python | def to_array(self):
array = super(InlineQueryResultVenue, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['latitude'] = float(self.latitude) # type float
array['longitude'] = float(self.longitude) # type float
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['address'] = u(self.address) # py2: type unicode, py3: type str
if self.foursquare_id is not None:
array['foursquare_id'] = u(self.foursquare_id) # py2: type unicode, py3: type str
if self.foursquare_type is not None:
array['foursquare_type'] = u(self.foursquare_type) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
if self.thumb_url is not None:
array['thumb_url'] = u(self.thumb_url) # py2: type unicode, py3: type str
if self.thumb_width is not None:
array['thumb_width'] = int(self.thumb_width) # type int
if self.thumb_height is not None:
array['thumb_height'] = int(self.thumb_height) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultVenue",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"array"... | Serializes this InlineQueryResultVenue to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultVenue",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L2270-L2307 |
8,951 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultCachedPhoto.to_array | def to_array(self):
"""
Serializes this InlineQueryResultCachedPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['photo_file_id'] = u(self.photo_file_id) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultCachedPhoto, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['photo_file_id'] = u(self.photo_file_id) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultCachedPhoto",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"... | Serializes this InlineQueryResultCachedPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultCachedPhoto",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L2851-L2883 |
8,952 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultCachedMpeg4Gif.to_array | def to_array(self):
"""
Serializes this InlineQueryResultCachedMpeg4Gif to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedMpeg4Gif, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['mpeg4_file_id'] = u(self.mpeg4_file_id) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultCachedMpeg4Gif, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['mpeg4_file_id'] = u(self.mpeg4_file_id) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultCachedMpeg4Gif",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
... | Serializes this InlineQueryResultCachedMpeg4Gif to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultCachedMpeg4Gif",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L3237-L3266 |
8,953 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultCachedSticker.to_array | def to_array(self):
"""
Serializes this InlineQueryResultCachedSticker to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedSticker, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['sticker_file_id'] = u(self.sticker_file_id) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultCachedSticker, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['sticker_file_id'] = u(self.sticker_file_id) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultCachedSticker",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
... | Serializes this InlineQueryResultCachedSticker to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultCachedSticker",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L3403-L3423 |
8,954 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultCachedVideo.to_array | def to_array(self):
"""
Serializes this InlineQueryResultCachedVideo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedVideo, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['video_file_id'] = u(self.video_file_id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultCachedVideo, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['video_file_id'] = u(self.video_file_id) # py2: type unicode, py3: type str
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.description is not None:
array['description'] = u(self.description) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultCachedVideo",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"... | Serializes this InlineQueryResultCachedVideo to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultCachedVideo",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L3796-L3827 |
8,955 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/inline.py | InlineQueryResultCachedAudio.to_array | def to_array(self):
"""
Serializes this InlineQueryResultCachedAudio to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQueryResultCachedAudio, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['audio_file_id'] = u(self.audio_file_id) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | python | def to_array(self):
array = super(InlineQueryResultCachedAudio, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['audio_file_id'] = u(self.audio_file_id) # py2: type unicode, py3: type str
if self.caption is not None:
array['caption'] = u(self.caption) # py2: type unicode, py3: type str
if self.parse_mode is not None:
array['parse_mode'] = u(self.parse_mode) # py2: type unicode, py3: type str
if self.reply_markup is not None:
array['reply_markup'] = self.reply_markup.to_array() # type InlineKeyboardMarkup
if self.input_message_content is not None:
array['input_message_content'] = self.input_message_content.to_array() # type InputMessageContent
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQueryResultCachedAudio",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"... | Serializes this InlineQueryResultCachedAudio to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQueryResultCachedAudio",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/inline.py#L4175-L4201 |
8,956 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | MessageEntity.to_array | def to_array(self):
"""
Serializes this MessageEntity to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(MessageEntity, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['offset'] = int(self.offset) # type int
array['length'] = int(self.length) # type int
if self.url is not None:
array['url'] = u(self.url) # py2: type unicode, py3: type str
if self.user is not None:
array['user'] = self.user.to_array() # type User
return array | python | def to_array(self):
array = super(MessageEntity, self).to_array()
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['offset'] = int(self.offset) # type int
array['length'] = int(self.length) # type int
if self.url is not None:
array['url'] = u(self.url) # py2: type unicode, py3: type str
if self.user is not None:
array['user'] = self.user.to_array() # type User
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"MessageEntity",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'type'",
"]",
"=",
"u",
"(",
"self",
".",
"type",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
... | Serializes this MessageEntity to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"MessageEntity",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L92-L110 |
8,957 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | PhotoSize.to_array | def to_array(self):
"""
Serializes this PhotoSize to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PhotoSize, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
array['height'] = int(self.height) # type int
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | python | def to_array(self):
array = super(PhotoSize, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
array['height'] = int(self.height) # type int
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"PhotoSize",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"array",
"["... | Serializes this PhotoSize to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"PhotoSize",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L235-L249 |
8,958 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Audio.to_array | def to_array(self):
"""
Serializes this Audio to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Audio, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['duration'] = int(self.duration) # type int
if self.performer is not None:
array['performer'] = u(self.performer) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.mime_type is not None:
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
return array | python | def to_array(self):
array = super(Audio, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['duration'] = int(self.duration) # type int
if self.performer is not None:
array['performer'] = u(self.performer) # py2: type unicode, py3: type str
if self.title is not None:
array['title'] = u(self.title) # py2: type unicode, py3: type str
if self.mime_type is not None:
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Audio",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
... | Serializes this Audio to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Audio",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L400-L425 |
8,959 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Audio.from_array | def from_array(array):
"""
Deserialize a new Audio from a given dictionary.
:return: new Audio instance.
:rtype: Audio
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.media import PhotoSize
data = {}
data['file_id'] = u(array.get('file_id'))
data['duration'] = int(array.get('duration'))
data['performer'] = u(array.get('performer')) if array.get('performer') is not None else None
data['title'] = u(array.get('title')) if array.get('title') is not None else None
data['mime_type'] = u(array.get('mime_type')) if array.get('mime_type') is not None else None
data['file_size'] = int(array.get('file_size')) if array.get('file_size') is not None else None
data['thumb'] = PhotoSize.from_array(array.get('thumb')) if array.get('thumb') is not None else None
data['_raw'] = array
return Audio(**data) | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.media import PhotoSize
data = {}
data['file_id'] = u(array.get('file_id'))
data['duration'] = int(array.get('duration'))
data['performer'] = u(array.get('performer')) if array.get('performer') is not None else None
data['title'] = u(array.get('title')) if array.get('title') is not None else None
data['mime_type'] = u(array.get('mime_type')) if array.get('mime_type') is not None else None
data['file_size'] = int(array.get('file_size')) if array.get('file_size') is not None else None
data['thumb'] = PhotoSize.from_array(array.get('thumb')) if array.get('thumb') is not None else None
data['_raw'] = array
return Audio(**data) | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
"pytgbot",
".",
"api... | Deserialize a new Audio from a given dictionary.
:return: new Audio instance.
:rtype: Audio | [
"Deserialize",
"a",
"new",
"Audio",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L429-L452 |
8,960 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Document.to_array | def to_array(self):
"""
Serializes this Document to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Document, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.file_name is not None:
array['file_name'] = u(self.file_name) # py2: type unicode, py3: type str
if self.mime_type is not None:
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | python | def to_array(self):
array = super(Document, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.file_name is not None:
array['file_name'] = u(self.file_name) # py2: type unicode, py3: type str
if self.mime_type is not None:
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Document",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"if",
"self",... | Serializes this Document to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Document",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L563-L584 |
8,961 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Animation.to_array | def to_array(self):
"""
Serializes this Animation to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Animation, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
array['height'] = int(self.height) # type int
array['duration'] = int(self.duration) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.file_name is not None:
array['file_name'] = u(self.file_name) # py2: type unicode, py3: type str
if self.mime_type is not None:
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | python | def to_array(self):
array = super(Animation, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
array['height'] = int(self.height) # type int
array['duration'] = int(self.duration) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.file_name is not None:
array['file_name'] = u(self.file_name) # py2: type unicode, py3: type str
if self.mime_type is not None:
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Animation",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"array",
"["... | Serializes this Animation to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Animation",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L924-L948 |
8,962 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Voice.to_array | def to_array(self):
"""
Serializes this Voice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Voice, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['duration'] = int(self.duration) # type int
if self.mime_type is not None:
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | python | def to_array(self):
array = super(Voice, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['duration'] = int(self.duration) # type int
if self.mime_type is not None:
array['mime_type'] = u(self.mime_type) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Voice",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
... | Serializes this Voice to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Voice",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1076-L1092 |
8,963 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | VideoNote.to_array | def to_array(self):
"""
Serializes this VideoNote to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(VideoNote, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['length'] = int(self.length) # type int
array['duration'] = int(self.duration) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | python | def to_array(self):
array = super(VideoNote, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['length'] = int(self.length) # type int
array['duration'] = int(self.duration) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"VideoNote",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"array",
"["... | Serializes this VideoNote to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"VideoNote",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1225-L1242 |
8,964 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Contact.to_array | def to_array(self):
"""
Serializes this Contact to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Contact, self).to_array()
array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str
array['first_name'] = u(self.first_name) # py2: type unicode, py3: type str
if self.last_name is not None:
array['last_name'] = u(self.last_name) # py2: type unicode, py3: type str
if self.user_id is not None:
array['user_id'] = int(self.user_id) # type int
if self.vcard is not None:
array['vcard'] = u(self.vcard) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(Contact, self).to_array()
array['phone_number'] = u(self.phone_number) # py2: type unicode, py3: type str
array['first_name'] = u(self.first_name) # py2: type unicode, py3: type str
if self.last_name is not None:
array['last_name'] = u(self.last_name) # py2: type unicode, py3: type str
if self.user_id is not None:
array['user_id'] = int(self.user_id) # type int
if self.vcard is not None:
array['vcard'] = u(self.vcard) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Contact",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'phone_number'",
"]",
"=",
"u",
"(",
"self",
".",
"phone_number",
")",
"# py2: type unicode, py3: type str",
"array... | Serializes this Contact to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Contact",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1376-L1396 |
8,965 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Location.to_array | def to_array(self):
"""
Serializes this Location to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Location, self).to_array()
array['longitude'] = float(self.longitude) # type float
array['latitude'] = float(self.latitude) # type float
return array | python | def to_array(self):
array = super(Location, self).to_array()
array['longitude'] = float(self.longitude) # type float
array['latitude'] = float(self.latitude) # type float
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Location",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'longitude'",
"]",
"=",
"float",
"(",
"self",
".",
"longitude",
")",
"# type float",
"array",
"[",
"'latitude'... | Serializes this Location to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Location",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1501-L1511 |
8,966 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Location.from_array | def from_array(array):
"""
Deserialize a new Location from a given dictionary.
:return: new Location instance.
:rtype: Location
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['longitude'] = float(array.get('longitude'))
data['latitude'] = float(array.get('latitude'))
data['_raw'] = array
return Location(**data) | python | 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['longitude'] = float(array.get('longitude'))
data['latitude'] = float(array.get('latitude'))
data['_raw'] = array
return Location(**data) | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new Location from a given dictionary.
:return: new Location instance.
:rtype: Location | [
"Deserialize",
"a",
"new",
"Location",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1515-L1531 |
8,967 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Venue.to_array | def to_array(self):
"""
Serializes this Venue to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Venue, self).to_array()
array['location'] = self.location.to_array() # type Location
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['address'] = u(self.address) # py2: type unicode, py3: type str
if self.foursquare_id is not None:
array['foursquare_id'] = u(self.foursquare_id) # py2: type unicode, py3: type str
if self.foursquare_type is not None:
array['foursquare_type'] = u(self.foursquare_type) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(Venue, self).to_array()
array['location'] = self.location.to_array() # type Location
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['address'] = u(self.address) # py2: type unicode, py3: type str
if self.foursquare_id is not None:
array['foursquare_id'] = u(self.foursquare_id) # py2: type unicode, py3: type str
if self.foursquare_type is not None:
array['foursquare_type'] = u(self.foursquare_type) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Venue",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'location'",
"]",
"=",
"self",
".",
"location",
".",
"to_array",
"(",
")",
"# type Location",
"array",
"[",
"'t... | Serializes this Venue to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Venue",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1642-L1662 |
8,968 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | UserProfilePhotos.to_array | def to_array(self):
"""
Serializes this UserProfilePhotos to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(UserProfilePhotos, self).to_array()
array['total_count'] = int(self.total_count) # type int
array['photos'] = self._as_array(self.photos) # type list of list of PhotoSize
return array | python | def to_array(self):
array = super(UserProfilePhotos, self).to_array()
array['total_count'] = int(self.total_count) # type int
array['photos'] = self._as_array(self.photos) # type list of list of PhotoSize
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"UserProfilePhotos",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'total_count'",
"]",
"=",
"int",
"(",
"self",
".",
"total_count",
")",
"# type int",
"array",
"[",
"'... | Serializes this UserProfilePhotos to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"UserProfilePhotos",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1771-L1782 |
8,969 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | File.to_array | def to_array(self):
"""
Serializes this File to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(File, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
if self.file_path is not None:
array['file_path'] = u(self.file_path) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(File, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
if self.file_path is not None:
array['file_path'] = u(self.file_path) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"File",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"if",
"self",
"... | Serializes this File to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"File",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L1899-L1914 |
8,970 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | ChatPhoto.to_array | def to_array(self):
"""
Serializes this ChatPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ChatPhoto, self).to_array()
array['small_file_id'] = u(self.small_file_id) # py2: type unicode, py3: type str
array['big_file_id'] = u(self.big_file_id) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(ChatPhoto, self).to_array()
array['small_file_id'] = u(self.small_file_id) # py2: type unicode, py3: type str
array['big_file_id'] = u(self.big_file_id) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"ChatPhoto",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'small_file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"small_file_id",
")",
"# py2: type unicode, py3: type str",
"a... | Serializes this ChatPhoto to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"ChatPhoto",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L2017-L2029 |
8,971 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Sticker.to_array | def to_array(self):
"""
Serializes this Sticker to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Sticker, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
array['height'] = int(self.height) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.emoji is not None:
array['emoji'] = u(self.emoji) # py2: type unicode, py3: type str
if self.set_name is not None:
array['set_name'] = u(self.set_name) # py2: type unicode, py3: type str
if self.mask_position is not None:
array['mask_position'] = self.mask_position.to_array() # type MaskPosition
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | python | def to_array(self):
array = super(Sticker, self).to_array()
array['file_id'] = u(self.file_id) # py2: type unicode, py3: type str
array['width'] = int(self.width) # type int
array['height'] = int(self.height) # type int
if self.thumb is not None:
array['thumb'] = self.thumb.to_array() # type PhotoSize
if self.emoji is not None:
array['emoji'] = u(self.emoji) # py2: type unicode, py3: type str
if self.set_name is not None:
array['set_name'] = u(self.set_name) # py2: type unicode, py3: type str
if self.mask_position is not None:
array['mask_position'] = self.mask_position.to_array() # type MaskPosition
if self.file_size is not None:
array['file_size'] = int(self.file_size) # type int
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Sticker",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'file_id'",
"]",
"=",
"u",
"(",
"self",
".",
"file_id",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
... | Serializes this Sticker to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Sticker",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L2188-L2214 |
8,972 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/media.py | Game.to_array | def to_array(self):
"""
Serializes this Game to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(Game, self).to_array()
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['description'] = u(self.description) # py2: type unicode, py3: type str
array['photo'] = self._as_array(self.photo) # type list of PhotoSize
if self.text is not None:
array['text'] = u(self.text) # py2: type unicode, py3: type str
if self.text_entities is not None:
array['text_entities'] = self._as_array(self.text_entities) # type list of MessageEntity
if self.animation is not None:
array['animation'] = self.animation.to_array() # type Animation
return array | python | def to_array(self):
array = super(Game, self).to_array()
array['title'] = u(self.title) # py2: type unicode, py3: type str
array['description'] = u(self.description) # py2: type unicode, py3: type str
array['photo'] = self._as_array(self.photo) # type list of PhotoSize
if self.text is not None:
array['text'] = u(self.text) # py2: type unicode, py3: type str
if self.text_entities is not None:
array['text_entities'] = self._as_array(self.text_entities) # type list of MessageEntity
if self.animation is not None:
array['animation'] = self.animation.to_array() # type Animation
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"Game",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'title'",
"]",
"=",
"u",
"(",
"self",
".",
"title",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
"'des... | Serializes this Game to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"Game",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/media.py#L2365-L2388 |
8,973 | luckydonald/pytgbot | pytgbot/api_types/receivable/media.py | VideoNote.from_array | def from_array(array):
"""
Deserialize a new VideoNote from a given dictionary.
:return: new VideoNote instance.
:rtype: VideoNote
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['file_id'] = u(array.get('file_id'))
data['length'] = int(array.get('length'))
data['duration'] = int(array.get('duration'))
data['thumb'] = PhotoSize.from_array(array.get('thumb')) if array.get('thumb') is not None else None
data['file_size'] = int(array.get('file_size')) if array.get('file_size') is not None else None
data['_raw'] = array
return VideoNote(**data) | python | 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['file_id'] = u(array.get('file_id'))
data['length'] = int(array.get('length'))
data['duration'] = int(array.get('duration'))
data['thumb'] = PhotoSize.from_array(array.get('thumb')) if array.get('thumb') is not None else None
data['file_size'] = int(array.get('file_size')) if array.get('file_size') is not None else None
data['_raw'] = array
return VideoNote(**data) | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new VideoNote from a given dictionary.
:return: new VideoNote instance.
:rtype: VideoNote | [
"Deserialize",
"a",
"new",
"VideoNote",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/media.py#L1428-L1447 |
8,974 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | ReplyKeyboardMarkup.to_array | def to_array(self):
"""
Serializes this ReplyKeyboardMarkup to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ReplyKeyboardMarkup, self).to_array()
array['keyboard'] = self._as_array(self.keyboard) # type list of list of KeyboardButton
if self.resize_keyboard is not None:
array['resize_keyboard'] = bool(self.resize_keyboard) # type bool
if self.one_time_keyboard is not None:
array['one_time_keyboard'] = bool(self.one_time_keyboard) # type bool
if self.selective is not None:
array['selective'] = bool(self.selective) # type bool
return array | python | def to_array(self):
array = super(ReplyKeyboardMarkup, self).to_array()
array['keyboard'] = self._as_array(self.keyboard) # type list of list of KeyboardButton
if self.resize_keyboard is not None:
array['resize_keyboard'] = bool(self.resize_keyboard) # type bool
if self.one_time_keyboard is not None:
array['one_time_keyboard'] = bool(self.one_time_keyboard) # type bool
if self.selective is not None:
array['selective'] = bool(self.selective) # type bool
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"ReplyKeyboardMarkup",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'keyboard'",
"]",
"=",
"self",
".",
"_as_array",
"(",
"self",
".",
"keyboard",
")",
"# type list of l... | Serializes this ReplyKeyboardMarkup to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"ReplyKeyboardMarkup",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L74-L90 |
8,975 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | KeyboardButton.to_array | def to_array(self):
"""
Serializes this KeyboardButton to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(KeyboardButton, self).to_array()
array['text'] = u(self.text) # py2: type unicode, py3: type str
if self.request_contact is not None:
array['request_contact'] = bool(self.request_contact) # type bool
if self.request_location is not None:
array['request_location'] = bool(self.request_location) # type bool
return array | python | def to_array(self):
array = super(KeyboardButton, self).to_array()
array['text'] = u(self.text) # py2: type unicode, py3: type str
if self.request_contact is not None:
array['request_contact'] = bool(self.request_contact) # type bool
if self.request_location is not None:
array['request_location'] = bool(self.request_location) # type bool
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"KeyboardButton",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'text'",
"]",
"=",
"u",
"(",
"self",
".",
"text",
")",
"# py2: type unicode, py3: type str",
"if",
"self",... | Serializes this KeyboardButton to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"KeyboardButton",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L201-L215 |
8,976 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | KeyboardButton.from_array | def from_array(array):
"""
Deserialize a new KeyboardButton from a given dictionary.
:return: new KeyboardButton instance.
:rtype: KeyboardButton
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['text'] = u(array.get('text'))
data['request_contact'] = bool(array.get('request_contact')) if array.get('request_contact') is not None else None
data['request_location'] = bool(array.get('request_location')) if array.get('request_location') is not None else None
instance = KeyboardButton(**data)
instance._raw = array
return instance | python | 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['text'] = u(array.get('text'))
data['request_contact'] = bool(array.get('request_contact')) if array.get('request_contact') is not None else None
data['request_location'] = bool(array.get('request_location')) if array.get('request_location') is not None else None
instance = KeyboardButton(**data)
instance._raw = array
return instance | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new KeyboardButton from a given dictionary.
:return: new KeyboardButton instance.
:rtype: KeyboardButton | [
"Deserialize",
"a",
"new",
"KeyboardButton",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L219-L238 |
8,977 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | ReplyKeyboardRemove.to_array | def to_array(self):
"""
Serializes this ReplyKeyboardRemove to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ReplyKeyboardRemove, self).to_array()
array['remove_keyboard'] = bool(self.remove_keyboard) # type bool
if self.selective is not None:
array['selective'] = bool(self.selective) # type bool
return array | python | def to_array(self):
array = super(ReplyKeyboardRemove, self).to_array()
array['remove_keyboard'] = bool(self.remove_keyboard) # type bool
if self.selective is not None:
array['selective'] = bool(self.selective) # type bool
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"ReplyKeyboardRemove",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'remove_keyboard'",
"]",
"=",
"bool",
"(",
"self",
".",
"remove_keyboard",
")",
"# type bool",
"if",
... | Serializes this ReplyKeyboardRemove to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"ReplyKeyboardRemove",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L312-L323 |
8,978 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | InlineKeyboardMarkup.to_array | def to_array(self):
"""
Serializes this InlineKeyboardMarkup to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineKeyboardMarkup, self).to_array()
array['inline_keyboard'] = self._as_array(self.inline_keyboard) # type list of list of InlineKeyboardButton
return array | python | def to_array(self):
array = super(InlineKeyboardMarkup, self).to_array()
array['inline_keyboard'] = self._as_array(self.inline_keyboard) # type list of list of InlineKeyboardButton
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineKeyboardMarkup",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'inline_keyboard'",
"]",
"=",
"self",
".",
"_as_array",
"(",
"self",
".",
"inline_keyboard",
")",
"#... | Serializes this InlineKeyboardMarkup to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineKeyboardMarkup",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L414-L424 |
8,979 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | InlineKeyboardButton.to_array | def to_array(self):
"""
Serializes this InlineKeyboardButton to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineKeyboardButton, self).to_array()
array['text'] = u(self.text) # py2: type unicode, py3: type str
if self.url is not None:
array['url'] = u(self.url) # py2: type unicode, py3: type str
if self.callback_data is not None:
array['callback_data'] = u(self.callback_data) # py2: type unicode, py3: type str
if self.switch_inline_query is not None:
array['switch_inline_query'] = u(self.switch_inline_query) # py2: type unicode, py3: type str
if self.switch_inline_query_current_chat is not None:
array['switch_inline_query_current_chat'] = u(self.switch_inline_query_current_chat) # py2: type unicode, py3: type str
if self.callback_game is not None:
array['callback_game'] = self.callback_game.to_array() # type CallbackGame
if self.pay is not None:
array['pay'] = bool(self.pay) # type bool
return array | python | def to_array(self):
array = super(InlineKeyboardButton, self).to_array()
array['text'] = u(self.text) # py2: type unicode, py3: type str
if self.url is not None:
array['url'] = u(self.url) # py2: type unicode, py3: type str
if self.callback_data is not None:
array['callback_data'] = u(self.callback_data) # py2: type unicode, py3: type str
if self.switch_inline_query is not None:
array['switch_inline_query'] = u(self.switch_inline_query) # py2: type unicode, py3: type str
if self.switch_inline_query_current_chat is not None:
array['switch_inline_query_current_chat'] = u(self.switch_inline_query_current_chat) # py2: type unicode, py3: type str
if self.callback_game is not None:
array['callback_game'] = self.callback_game.to_array() # type CallbackGame
if self.pay is not None:
array['pay'] = bool(self.pay) # type bool
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineKeyboardButton",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'text'",
"]",
"=",
"u",
"(",
"self",
".",
"text",
")",
"# py2: type unicode, py3: type str",
"if",
"... | Serializes this InlineKeyboardButton to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineKeyboardButton",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L568-L595 |
8,980 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | InlineKeyboardButton.from_array | def from_array(array):
"""
Deserialize a new InlineKeyboardButton from a given dictionary.
:return: new InlineKeyboardButton instance.
:rtype: InlineKeyboardButton
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.updates import CallbackGame
data = {}
data['text'] = u(array.get('text'))
data['url'] = u(array.get('url')) if array.get('url') is not None else None
data['callback_data'] = u(array.get('callback_data')) if array.get('callback_data') is not None else None
data['switch_inline_query'] = u(array.get('switch_inline_query')) if array.get('switch_inline_query') is not None else None
data['switch_inline_query_current_chat'] = u(array.get('switch_inline_query_current_chat')) if array.get('switch_inline_query_current_chat') is not None else None
data['callback_game'] = CallbackGame.from_array(array.get('callback_game')) if array.get('callback_game') is not None else None
data['pay'] = bool(array.get('pay')) if array.get('pay') is not None else None
instance = InlineKeyboardButton(**data)
instance._raw = array
return instance | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.updates import CallbackGame
data = {}
data['text'] = u(array.get('text'))
data['url'] = u(array.get('url')) if array.get('url') is not None else None
data['callback_data'] = u(array.get('callback_data')) if array.get('callback_data') is not None else None
data['switch_inline_query'] = u(array.get('switch_inline_query')) if array.get('switch_inline_query') is not None else None
data['switch_inline_query_current_chat'] = u(array.get('switch_inline_query_current_chat')) if array.get('switch_inline_query_current_chat') is not None else None
data['callback_game'] = CallbackGame.from_array(array.get('callback_game')) if array.get('callback_game') is not None else None
data['pay'] = bool(array.get('pay')) if array.get('pay') is not None else None
instance = InlineKeyboardButton(**data)
instance._raw = array
return instance | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
"pytgbot",
".",
"api... | Deserialize a new InlineKeyboardButton from a given dictionary.
:return: new InlineKeyboardButton instance.
:rtype: InlineKeyboardButton | [
"Deserialize",
"a",
"new",
"InlineKeyboardButton",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L599-L624 |
8,981 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | ForceReply.to_array | def to_array(self):
"""
Serializes this ForceReply to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ForceReply, self).to_array()
array['force_reply'] = bool(self.force_reply) # type bool
if self.selective is not None:
array['selective'] = bool(self.selective) # type bool
return array | python | def to_array(self):
array = super(ForceReply, self).to_array()
array['force_reply'] = bool(self.force_reply) # type bool
if self.selective is not None:
array['selective'] = bool(self.selective) # type bool
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"ForceReply",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'force_reply'",
"]",
"=",
"bool",
"(",
"self",
".",
"force_reply",
")",
"# type bool",
"if",
"self",
".",
... | Serializes this ForceReply to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"ForceReply",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L706-L717 |
8,982 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/sendable/reply_markup.py | ForceReply.from_array | def from_array(array):
"""
Deserialize a new ForceReply from a given dictionary.
:return: new ForceReply instance.
:rtype: ForceReply
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['force_reply'] = bool(array.get('force_reply'))
data['selective'] = bool(array.get('selective')) if array.get('selective') is not None else None
instance = ForceReply(**data)
instance._raw = array
return instance | python | 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['force_reply'] = bool(array.get('force_reply'))
data['selective'] = bool(array.get('selective')) if array.get('selective') is not None else None
instance = ForceReply(**data)
instance._raw = array
return instance | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new ForceReply from a given dictionary.
:return: new ForceReply instance.
:rtype: ForceReply | [
"Deserialize",
"a",
"new",
"ForceReply",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/sendable/reply_markup.py#L721-L739 |
8,983 | luckydonald/pytgbot | pytgbot/api_types/sendable/passport.py | PassportElementErrorDataField.to_array | def to_array(self):
"""
Serializes this PassportElementErrorDataField to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PassportElementErrorDataField, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['field_name'] = u(self.field_name) # py2: type unicode, py3: type str
array['data_hash'] = u(self.data_hash) # py2: type unicode, py3: type str
array['message'] = u(self.message) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(PassportElementErrorDataField, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['field_name'] = u(self.field_name) # py2: type unicode, py3: type str
array['data_hash'] = u(self.data_hash) # py2: type unicode, py3: type str
array['message'] = u(self.message) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"PassportElementErrorDataField",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'source'",
"]",
"=",
"u",
"(",
"self",
".",
"source",
")",
"# py2: type unicode, py3: type str"... | Serializes this PassportElementErrorDataField to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"PassportElementErrorDataField",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/passport.py#L91-L104 |
8,984 | luckydonald/pytgbot | pytgbot/api_types/sendable/passport.py | PassportElementErrorReverseSide.to_array | def to_array(self):
"""
Serializes this PassportElementErrorReverseSide to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PassportElementErrorReverseSide, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['file_hash'] = u(self.file_hash) # py2: type unicode, py3: type str
array['message'] = u(self.message) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(PassportElementErrorReverseSide, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['file_hash'] = u(self.file_hash) # py2: type unicode, py3: type str
array['message'] = u(self.message) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"PassportElementErrorReverseSide",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'source'",
"]",
"=",
"u",
"(",
"self",
".",
"source",
")",
"# py2: type unicode, py3: type st... | Serializes this PassportElementErrorReverseSide to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"PassportElementErrorReverseSide",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/passport.py#L351-L363 |
8,985 | luckydonald/pytgbot | pytgbot/api_types/sendable/passport.py | PassportElementErrorFiles.to_array | def to_array(self):
"""
Serializes this PassportElementErrorFiles to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PassportElementErrorFiles, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['file_hashes'] = self._as_array(self.file_hashes) # type list of str
array['message'] = u(self.message) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(PassportElementErrorFiles, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['file_hashes'] = self._as_array(self.file_hashes) # type list of str
array['message'] = u(self.message) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"PassportElementErrorFiles",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'source'",
"]",
"=",
"u",
"(",
"self",
".",
"source",
")",
"# py2: type unicode, py3: type str",
... | Serializes this PassportElementErrorFiles to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"PassportElementErrorFiles",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/passport.py#L738-L750 |
8,986 | luckydonald/pytgbot | pytgbot/api_types/sendable/passport.py | PassportElementErrorFiles.from_array | def from_array(array):
"""
Deserialize a new PassportElementErrorFiles from a given dictionary.
:return: new PassportElementErrorFiles instance.
:rtype: PassportElementErrorFiles
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['source'] = u(array.get('source'))
data['type'] = u(array.get('type'))
data['file_hashes'] = PassportElementErrorFiles._builtin_from_array_list(required_type=unicode_type, value=array.get('file_hashes'), list_level=1)
data['message'] = u(array.get('message'))
instance = PassportElementErrorFiles(**data)
instance._raw = array
return instance | python | 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['source'] = u(array.get('source'))
data['type'] = u(array.get('type'))
data['file_hashes'] = PassportElementErrorFiles._builtin_from_array_list(required_type=unicode_type, value=array.get('file_hashes'), list_level=1)
data['message'] = u(array.get('message'))
instance = PassportElementErrorFiles(**data)
instance._raw = array
return instance | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new PassportElementErrorFiles from a given dictionary.
:return: new PassportElementErrorFiles instance.
:rtype: PassportElementErrorFiles | [
"Deserialize",
"a",
"new",
"PassportElementErrorFiles",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/passport.py#L754-L774 |
8,987 | luckydonald/pytgbot | pytgbot/api_types/sendable/passport.py | PassportElementErrorUnspecified.to_array | def to_array(self):
"""
Serializes this PassportElementErrorUnspecified to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(PassportElementErrorUnspecified, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['element_hash'] = u(self.element_hash) # py2: type unicode, py3: type str
array['message'] = u(self.message) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(PassportElementErrorUnspecified, self).to_array()
array['source'] = u(self.source) # py2: type unicode, py3: type str
array['type'] = u(self.type) # py2: type unicode, py3: type str
array['element_hash'] = u(self.element_hash) # py2: type unicode, py3: type str
array['message'] = u(self.message) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"PassportElementErrorUnspecified",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'source'",
"]",
"=",
"u",
"(",
"self",
".",
"source",
")",
"# py2: type unicode, py3: type st... | Serializes this PassportElementErrorUnspecified to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"PassportElementErrorUnspecified",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/passport.py#L1130-L1146 |
8,988 | luckydonald/pytgbot | pytgbot/api_types/sendable/passport.py | PassportElementErrorUnspecified.from_array | def from_array(array):
"""
Deserialize a new PassportElementErrorUnspecified from a given dictionary.
:return: new PassportElementErrorUnspecified instance.
:rtype: PassportElementErrorUnspecified
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
data = {}
data['source'] = u(array.get('source'))
data['type'] = u(array.get('type'))
data['element_hash'] = u(array.get('element_hash'))
data['message'] = u(array.get('message'))
instance = PassportElementErrorUnspecified(**data)
instance._raw = array
return instance | python | 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['source'] = u(array.get('source'))
data['type'] = u(array.get('type'))
data['element_hash'] = u(array.get('element_hash'))
data['message'] = u(array.get('message'))
instance = PassportElementErrorUnspecified(**data)
instance._raw = array
return instance | [
"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",
"=",
"{",
"}",
"da... | Deserialize a new PassportElementErrorUnspecified from a given dictionary.
:return: new PassportElementErrorUnspecified instance.
:rtype: PassportElementErrorUnspecified | [
"Deserialize",
"a",
"new",
"PassportElementErrorUnspecified",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/sendable/passport.py#L1150-L1170 |
8,989 | luckydonald/pytgbot | pytgbot/api_types/receivable/inline.py | InlineQuery.to_array | def to_array(self):
"""
Serializes this InlineQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(InlineQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['query'] = u(self.query) # py2: type unicode, py3: type str
array['offset'] = u(self.offset) # py2: type unicode, py3: type str
if self.location is not None:
array['location'] = self.location.to_array() # type Location
return array | python | def to_array(self):
array = super(InlineQuery, self).to_array()
array['id'] = u(self.id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['query'] = u(self.query) # py2: type unicode, py3: type str
array['offset'] = u(self.offset) # py2: type unicode, py3: type str
if self.location is not None:
array['location'] = self.location.to_array() # type Location
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"InlineQuery",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'id'",
"]",
"=",
"u",
"(",
"self",
".",
"id",
")",
"# py2: type unicode, py3: type str",
"array",
"[",
"'fr... | Serializes this InlineQuery to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"InlineQuery",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/inline.py#L95-L109 |
8,990 | luckydonald/pytgbot | pytgbot/api_types/receivable/inline.py | InlineQuery.from_array | def from_array(array):
"""
Deserialize a new InlineQuery from a given dictionary.
:return: new InlineQuery instance.
:rtype: InlineQuery
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.media import Location
from pytgbot.api_types.receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['query'] = u(array.get('query'))
data['offset'] = u(array.get('offset'))
data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None
data['_raw'] = array
return InlineQuery(**data) | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.media import Location
from pytgbot.api_types.receivable.peer import User
data = {}
data['id'] = u(array.get('id'))
data['from_peer'] = User.from_array(array.get('from'))
data['query'] = u(array.get('query'))
data['offset'] = u(array.get('offset'))
data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None
data['_raw'] = array
return InlineQuery(**data) | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
"pytgbot",
".",
"api... | Deserialize a new InlineQuery from a given dictionary.
:return: new InlineQuery instance.
:rtype: InlineQuery | [
"Deserialize",
"a",
"new",
"InlineQuery",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/inline.py#L113-L134 |
8,991 | luckydonald/pytgbot | pytgbot/api_types/receivable/inline.py | ChosenInlineResult.to_array | def to_array(self):
"""
Serializes this ChosenInlineResult to a dictionary.
:return: dictionary representation of this object.
:rtype: dict
"""
array = super(ChosenInlineResult, self).to_array()
array['result_id'] = u(self.result_id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['query'] = u(self.query) # py2: type unicode, py3: type str
if self.location is not None:
array['location'] = self.location.to_array() # type Location
if self.inline_message_id is not None:
array['inline_message_id'] = u(self.inline_message_id) # py2: type unicode, py3: type str
return array | python | def to_array(self):
array = super(ChosenInlineResult, self).to_array()
array['result_id'] = u(self.result_id) # py2: type unicode, py3: type str
array['from'] = self.from_peer.to_array() # type User
array['query'] = u(self.query) # py2: type unicode, py3: type str
if self.location is not None:
array['location'] = self.location.to_array() # type Location
if self.inline_message_id is not None:
array['inline_message_id'] = u(self.inline_message_id) # py2: type unicode, py3: type str
return array | [
"def",
"to_array",
"(",
"self",
")",
":",
"array",
"=",
"super",
"(",
"ChosenInlineResult",
",",
"self",
")",
".",
"to_array",
"(",
")",
"array",
"[",
"'result_id'",
"]",
"=",
"u",
"(",
"self",
".",
"result_id",
")",
"# py2: type unicode, py3: type str",
"... | Serializes this ChosenInlineResult to a dictionary.
:return: dictionary representation of this object.
:rtype: dict | [
"Serializes",
"this",
"ChosenInlineResult",
"to",
"a",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/inline.py#L248-L263 |
8,992 | luckydonald/pytgbot | pytgbot/api_types/receivable/inline.py | ChosenInlineResult.from_array | def from_array(array):
"""
Deserialize a new ChosenInlineResult from a given dictionary.
:return: new ChosenInlineResult instance.
:rtype: ChosenInlineResult
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from ..receivable.media import Location
from ..receivable.peer import User
data = {}
data['result_id'] = u(array.get('result_id'))
data['from_peer'] = User.from_array(array.get('from'))
data['query'] = u(array.get('query'))
data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None
data['inline_message_id'] = u(array.get('inline_message_id')) if array.get('inline_message_id') is not None else None
data['_raw'] = array
return ChosenInlineResult(**data) | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from ..receivable.media import Location
from ..receivable.peer import User
data = {}
data['result_id'] = u(array.get('result_id'))
data['from_peer'] = User.from_array(array.get('from'))
data['query'] = u(array.get('query'))
data['location'] = Location.from_array(array.get('location')) if array.get('location') is not None else None
data['inline_message_id'] = u(array.get('inline_message_id')) if array.get('inline_message_id') is not None else None
data['_raw'] = array
return ChosenInlineResult(**data) | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
".",
".",
"receivabl... | Deserialize a new ChosenInlineResult from a given dictionary.
:return: new ChosenInlineResult instance.
:rtype: ChosenInlineResult | [
"Deserialize",
"a",
"new",
"ChosenInlineResult",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/pytgbot/api_types/receivable/inline.py#L267-L289 |
8,993 | luckydonald/pytgbot | code_generation/output/pytgbot/api_types/receivable/updates.py | Update.from_array | def from_array(array):
"""
Deserialize a new Update from a given dictionary.
:return: new Update instance.
:rtype: Update
"""
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.inline import ChosenInlineResult
from pytgbot.api_types.receivable.inline import InlineQuery
from pytgbot.api_types.receivable.payments import PreCheckoutQuery
from pytgbot.api_types.receivable.payments import ShippingQuery
from pytgbot.api_types.receivable.updates import CallbackQuery
from pytgbot.api_types.receivable.updates import Message
data = {}
data['update_id'] = int(array.get('update_id'))
data['message'] = Message.from_array(array.get('message')) if array.get('message') is not None else None
data['edited_message'] = Message.from_array(array.get('edited_message')) if array.get('edited_message') is not None else None
data['channel_post'] = Message.from_array(array.get('channel_post')) if array.get('channel_post') is not None else None
data['edited_channel_post'] = Message.from_array(array.get('edited_channel_post')) if array.get('edited_channel_post') is not None else None
data['inline_query'] = InlineQuery.from_array(array.get('inline_query')) if array.get('inline_query') is not None else None
data['chosen_inline_result'] = ChosenInlineResult.from_array(array.get('chosen_inline_result')) if array.get('chosen_inline_result') is not None else None
data['callback_query'] = CallbackQuery.from_array(array.get('callback_query')) if array.get('callback_query') is not None else None
data['shipping_query'] = ShippingQuery.from_array(array.get('shipping_query')) if array.get('shipping_query') is not None else None
data['pre_checkout_query'] = PreCheckoutQuery.from_array(array.get('pre_checkout_query')) if array.get('pre_checkout_query') is not None else None
data['_raw'] = array
return Update(**data) | python | def from_array(array):
if array is None or not array:
return None
# end if
assert_type_or_raise(array, dict, parameter_name="array")
from pytgbot.api_types.receivable.inline import ChosenInlineResult
from pytgbot.api_types.receivable.inline import InlineQuery
from pytgbot.api_types.receivable.payments import PreCheckoutQuery
from pytgbot.api_types.receivable.payments import ShippingQuery
from pytgbot.api_types.receivable.updates import CallbackQuery
from pytgbot.api_types.receivable.updates import Message
data = {}
data['update_id'] = int(array.get('update_id'))
data['message'] = Message.from_array(array.get('message')) if array.get('message') is not None else None
data['edited_message'] = Message.from_array(array.get('edited_message')) if array.get('edited_message') is not None else None
data['channel_post'] = Message.from_array(array.get('channel_post')) if array.get('channel_post') is not None else None
data['edited_channel_post'] = Message.from_array(array.get('edited_channel_post')) if array.get('edited_channel_post') is not None else None
data['inline_query'] = InlineQuery.from_array(array.get('inline_query')) if array.get('inline_query') is not None else None
data['chosen_inline_result'] = ChosenInlineResult.from_array(array.get('chosen_inline_result')) if array.get('chosen_inline_result') is not None else None
data['callback_query'] = CallbackQuery.from_array(array.get('callback_query')) if array.get('callback_query') is not None else None
data['shipping_query'] = ShippingQuery.from_array(array.get('shipping_query')) if array.get('shipping_query') is not None else None
data['pre_checkout_query'] = PreCheckoutQuery.from_array(array.get('pre_checkout_query')) if array.get('pre_checkout_query') is not None else None
data['_raw'] = array
return Update(**data) | [
"def",
"from_array",
"(",
"array",
")",
":",
"if",
"array",
"is",
"None",
"or",
"not",
"array",
":",
"return",
"None",
"# end if",
"assert_type_or_raise",
"(",
"array",
",",
"dict",
",",
"parameter_name",
"=",
"\"array\"",
")",
"from",
"pytgbot",
".",
"api... | Deserialize a new Update from a given dictionary.
:return: new Update instance.
:rtype: Update | [
"Deserialize",
"a",
"new",
"Update",
"from",
"a",
"given",
"dictionary",
"."
] | 67f4b5a1510d4583d40b5477e876b1ef0eb8971b | https://github.com/luckydonald/pytgbot/blob/67f4b5a1510d4583d40b5477e876b1ef0eb8971b/code_generation/output/pytgbot/api_types/receivable/updates.py#L181-L212 |
8,994 | delph-in/pydelphin | delphin/tokens.py | YyToken.to_dict | def to_dict(self):
"""
Encode the token as a dictionary suitable for JSON serialization.
"""
d = {
'id': self.id,
'start': self.start,
'end': self.end,
'form': self.form
}
if self.lnk is not None:
cfrom, cto = self.lnk.data
d['from'] = cfrom
d['to'] = cto
# d['paths'] = self.paths
if self.surface is not None:
d['surface'] = self.surface
# d['ipos'] = self.ipos
# d['lrules'] = self.lrules
if self.pos:
d['tags'] = [ps[0] for ps in self.pos]
d['probabilities'] = [ps[1] for ps in self.pos]
return d | python | def to_dict(self):
d = {
'id': self.id,
'start': self.start,
'end': self.end,
'form': self.form
}
if self.lnk is not None:
cfrom, cto = self.lnk.data
d['from'] = cfrom
d['to'] = cto
# d['paths'] = self.paths
if self.surface is not None:
d['surface'] = self.surface
# d['ipos'] = self.ipos
# d['lrules'] = self.lrules
if self.pos:
d['tags'] = [ps[0] for ps in self.pos]
d['probabilities'] = [ps[1] for ps in self.pos]
return d | [
"def",
"to_dict",
"(",
"self",
")",
":",
"d",
"=",
"{",
"'id'",
":",
"self",
".",
"id",
",",
"'start'",
":",
"self",
".",
"start",
",",
"'end'",
":",
"self",
".",
"end",
",",
"'form'",
":",
"self",
".",
"form",
"}",
"if",
"self",
".",
"lnk",
... | Encode the token as a dictionary suitable for JSON serialization. | [
"Encode",
"the",
"token",
"as",
"a",
"dictionary",
"suitable",
"for",
"JSON",
"serialization",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tokens.py#L85-L107 |
8,995 | delph-in/pydelphin | delphin/tokens.py | YyTokenLattice.from_string | def from_string(cls, s):
"""
Decode from the YY token lattice format.
"""
def _qstrip(s):
return s[1:-1] # remove assumed quote characters
tokens = []
for match in _yy_re.finditer(s):
d = match.groupdict()
lnk, pos = None, []
if d['lnkfrom'] is not None:
lnk = Lnk.charspan(d['lnkfrom'], d['lnkto'])
if d['pos'] is not None:
ps = d['pos'].strip().split()
pos = list(zip(map(_qstrip, ps[::2]), map(float, ps[1::2])))
tokens.append(
YyToken(
int(d['id']),
int(d['start']),
int(d['end']),
lnk,
list(map(int, d['paths'].strip().split())),
_qstrip(d['form']),
None if d['surface'] is None else _qstrip(d['surface']),
int(d['ipos']),
list(map(_qstrip, d['lrules'].strip().split())),
pos
)
)
return cls(tokens) | python | def from_string(cls, s):
def _qstrip(s):
return s[1:-1] # remove assumed quote characters
tokens = []
for match in _yy_re.finditer(s):
d = match.groupdict()
lnk, pos = None, []
if d['lnkfrom'] is not None:
lnk = Lnk.charspan(d['lnkfrom'], d['lnkto'])
if d['pos'] is not None:
ps = d['pos'].strip().split()
pos = list(zip(map(_qstrip, ps[::2]), map(float, ps[1::2])))
tokens.append(
YyToken(
int(d['id']),
int(d['start']),
int(d['end']),
lnk,
list(map(int, d['paths'].strip().split())),
_qstrip(d['form']),
None if d['surface'] is None else _qstrip(d['surface']),
int(d['ipos']),
list(map(_qstrip, d['lrules'].strip().split())),
pos
)
)
return cls(tokens) | [
"def",
"from_string",
"(",
"cls",
",",
"s",
")",
":",
"def",
"_qstrip",
"(",
"s",
")",
":",
"return",
"s",
"[",
"1",
":",
"-",
"1",
"]",
"# remove assumed quote characters",
"tokens",
"=",
"[",
"]",
"for",
"match",
"in",
"_yy_re",
".",
"finditer",
"(... | Decode from the YY token lattice format. | [
"Decode",
"from",
"the",
"YY",
"token",
"lattice",
"format",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/tokens.py#L145-L174 |
8,996 | delph-in/pydelphin | delphin/mrs/simplemrs.py | loads | def loads(s, single=False, version=_default_version,
strict=False, errors='warn'):
"""
Deserialize SimpleMRS string representations
Args:
s (str): a SimpleMRS string
single (bool): if `True`, only return the first Xmrs object
Returns:
a generator of Xmrs objects (unless *single* is `True`)
"""
ms = deserialize(s, version=version, strict=strict, errors=errors)
if single:
return next(ms)
else:
return ms | python | def loads(s, single=False, version=_default_version,
strict=False, errors='warn'):
ms = deserialize(s, version=version, strict=strict, errors=errors)
if single:
return next(ms)
else:
return ms | [
"def",
"loads",
"(",
"s",
",",
"single",
"=",
"False",
",",
"version",
"=",
"_default_version",
",",
"strict",
"=",
"False",
",",
"errors",
"=",
"'warn'",
")",
":",
"ms",
"=",
"deserialize",
"(",
"s",
",",
"version",
"=",
"version",
",",
"strict",
"=... | Deserialize SimpleMRS string representations
Args:
s (str): a SimpleMRS string
single (bool): if `True`, only return the first Xmrs object
Returns:
a generator of Xmrs objects (unless *single* is `True`) | [
"Deserialize",
"SimpleMRS",
"string",
"representations"
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L84-L99 |
8,997 | delph-in/pydelphin | delphin/mrs/simplemrs.py | dumps | def dumps(ms, single=False, version=_default_version, properties=True,
pretty_print=False, color=False, **kwargs):
"""
Serialize an Xmrs object to a SimpleMRS representation
Args:
ms: an iterator of Xmrs objects to serialize (unless the
*single* option is `True`)
single: if `True`, treat *ms* as a single Xmrs object instead
of as an iterator
properties: if `False`, suppress variable properties
pretty_print: if `True`, add newlines and indentation
color: if `True`, colorize the output with ANSI color codes
Returns:
a SimpleMrs string representation of a corpus of Xmrs
"""
if not pretty_print and kwargs.get('indent'):
pretty_print = True
if single:
ms = [ms]
return serialize(ms, version=version, properties=properties,
pretty_print=pretty_print, color=color) | python | def dumps(ms, single=False, version=_default_version, properties=True,
pretty_print=False, color=False, **kwargs):
if not pretty_print and kwargs.get('indent'):
pretty_print = True
if single:
ms = [ms]
return serialize(ms, version=version, properties=properties,
pretty_print=pretty_print, color=color) | [
"def",
"dumps",
"(",
"ms",
",",
"single",
"=",
"False",
",",
"version",
"=",
"_default_version",
",",
"properties",
"=",
"True",
",",
"pretty_print",
"=",
"False",
",",
"color",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"pretty_prin... | Serialize an Xmrs object to a SimpleMRS representation
Args:
ms: an iterator of Xmrs objects to serialize (unless the
*single* option is `True`)
single: if `True`, treat *ms* as a single Xmrs object instead
of as an iterator
properties: if `False`, suppress variable properties
pretty_print: if `True`, add newlines and indentation
color: if `True`, colorize the output with ANSI color codes
Returns:
a SimpleMrs string representation of a corpus of Xmrs | [
"Serialize",
"an",
"Xmrs",
"object",
"to",
"a",
"SimpleMRS",
"representation"
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L132-L153 |
8,998 | delph-in/pydelphin | delphin/mrs/simplemrs.py | _read_lnk | def _read_lnk(tokens):
"""Read and return a tuple of the pred's lnk type and lnk value,
if a pred lnk is specified."""
# < FROM : TO > or < FROM # TO > or < TOK... > or < @ EDGE >
lnk = None
if tokens[0] == '<':
tokens.popleft() # we just checked this is a left angle
if tokens[0] == '>':
pass # empty <> brackets the same as no lnk specified
# edge lnk: ['@', EDGE, ...]
elif tokens[0] == '@':
tokens.popleft() # remove the @
lnk = Lnk.edge(tokens.popleft()) # edge lnks only have one number
# character span lnk: [FROM, ':', TO, ...]
elif tokens[1] == ':':
lnk = Lnk.charspan(tokens.popleft(), tokens[1])
tokens.popleft() # this should be the colon
tokens.popleft() # and this is the cto
# chart vertex range lnk: [FROM, '#', TO, ...]
elif tokens[1] == '#':
lnk = Lnk.chartspan(tokens.popleft(), tokens[1])
tokens.popleft() # this should be the hash
tokens.popleft() # and this is the to vertex
# tokens lnk: [(TOK,)+ ...]
else:
lnkdata = []
while tokens[0] != '>':
lnkdata.append(int(tokens.popleft()))
lnk = Lnk.tokens(lnkdata)
_read_literals(tokens, '>')
return lnk | python | def _read_lnk(tokens):
# < FROM : TO > or < FROM # TO > or < TOK... > or < @ EDGE >
lnk = None
if tokens[0] == '<':
tokens.popleft() # we just checked this is a left angle
if tokens[0] == '>':
pass # empty <> brackets the same as no lnk specified
# edge lnk: ['@', EDGE, ...]
elif tokens[0] == '@':
tokens.popleft() # remove the @
lnk = Lnk.edge(tokens.popleft()) # edge lnks only have one number
# character span lnk: [FROM, ':', TO, ...]
elif tokens[1] == ':':
lnk = Lnk.charspan(tokens.popleft(), tokens[1])
tokens.popleft() # this should be the colon
tokens.popleft() # and this is the cto
# chart vertex range lnk: [FROM, '#', TO, ...]
elif tokens[1] == '#':
lnk = Lnk.chartspan(tokens.popleft(), tokens[1])
tokens.popleft() # this should be the hash
tokens.popleft() # and this is the to vertex
# tokens lnk: [(TOK,)+ ...]
else:
lnkdata = []
while tokens[0] != '>':
lnkdata.append(int(tokens.popleft()))
lnk = Lnk.tokens(lnkdata)
_read_literals(tokens, '>')
return lnk | [
"def",
"_read_lnk",
"(",
"tokens",
")",
":",
"# < FROM : TO > or < FROM # TO > or < TOK... > or < @ EDGE >",
"lnk",
"=",
"None",
"if",
"tokens",
"[",
"0",
"]",
"==",
"'<'",
":",
"tokens",
".",
"popleft",
"(",
")",
"# we just checked this is a left angle",
"if",
"tok... | Read and return a tuple of the pred's lnk type and lnk value,
if a pred lnk is specified. | [
"Read",
"and",
"return",
"a",
"tuple",
"of",
"the",
"pred",
"s",
"lnk",
"type",
"and",
"lnk",
"value",
"if",
"a",
"pred",
"lnk",
"is",
"specified",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L338-L368 |
8,999 | delph-in/pydelphin | delphin/mrs/simplemrs.py | serialize | def serialize(ms, version=_default_version, properties=True,
pretty_print=False, color=False):
"""Serialize an MRS structure into a SimpleMRS string."""
delim = '\n' if pretty_print else _default_mrs_delim
output = delim.join(
_serialize_mrs(m, properties=properties,
version=version, pretty_print=pretty_print)
for m in ms
)
if color:
output = highlight(output)
return output | python | def serialize(ms, version=_default_version, properties=True,
pretty_print=False, color=False):
delim = '\n' if pretty_print else _default_mrs_delim
output = delim.join(
_serialize_mrs(m, properties=properties,
version=version, pretty_print=pretty_print)
for m in ms
)
if color:
output = highlight(output)
return output | [
"def",
"serialize",
"(",
"ms",
",",
"version",
"=",
"_default_version",
",",
"properties",
"=",
"True",
",",
"pretty_print",
"=",
"False",
",",
"color",
"=",
"False",
")",
":",
"delim",
"=",
"'\\n'",
"if",
"pretty_print",
"else",
"_default_mrs_delim",
"outpu... | Serialize an MRS structure into a SimpleMRS string. | [
"Serialize",
"an",
"MRS",
"structure",
"into",
"a",
"SimpleMRS",
"string",
"."
] | 7bd2cd63ab7cf74803e1d6547b9ebc014b382abd | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/simplemrs.py#L379-L390 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.