_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q255600 | TDependentProperty.load_all_methods | validation | def load_all_methods(self):
r'''Method to load all data, and set all_methods based on the available
data and properties. Demo function for testing only; must be
implemented according to the methods available for each individual
method.
'''
methods = []
Tmins, Tmax... | python | {
"resource": ""
} |
q255601 | TDependentProperty.calculate | validation | def calculate(self, T, method):
r'''Method to calculate a property with a specified method, with no
validity checking or error handling. Demo function for testing only;
must be implemented according to the methods available for each
individual method. Include the interpolation call here.... | python | {
"resource": ""
} |
q255602 | TPDependentProperty.set_user_methods_P | validation | def set_user_methods_P(self, user_methods_P, forced_P=False):
r'''Method to set the pressure-dependent property methods desired for
consideration by the user. Can be used to exclude certain methods which
might have unacceptable accuracy.
As a side effect, the previously selected method ... | python | {
"resource": ""
} |
q255603 | TPDependentProperty.select_valid_methods_P | validation | def select_valid_methods_P(self, T, P):
r'''Method to obtain a sorted list methods which are valid at `T`
according to `test_method_validity`. Considers either only user methods
if forced is True, or all methods. User methods are first tested
according to their listed order, and unless f... | python | {
"resource": ""
} |
q255604 | TPDependentProperty.TP_dependent_property | validation | def TP_dependent_property(self, T, P):
r'''Method to calculate the property with sanity checking and without
specifying a specific method. `select_valid_methods_P` is used to obtain
a sorted list of methods to try. Methods are then tried in order until
one succeeds. The methods are allow... | python | {
"resource": ""
} |
q255605 | TPDependentProperty.interpolate_P | validation | def interpolate_P(self, T, P, name):
r'''Method to perform interpolation on a given tabular data set
previously added via `set_tabular_data_P`. This method will create the
interpolators the first time it is used on a property set, and store
them for quick future use.
Interpolati... | python | {
"resource": ""
} |
q255606 | TPDependentProperty.TP_dependent_property_derivative_T | validation | def TP_dependent_property_derivative_T(self, T, P, order=1):
r'''Method to calculate a derivative of a temperature and pressure
dependent property with respect to temperature at constant pressure,
of a given order. Methods found valid by `select_valid_methods_P` are
attempted until a me... | python | {
"resource": ""
} |
q255607 | TPDependentProperty.TP_dependent_property_derivative_P | validation | def TP_dependent_property_derivative_P(self, T, P, order=1):
r'''Method to calculate a derivative of a temperature and pressure
dependent property with respect to pressure at constant temperature,
of a given order. Methods found valid by `select_valid_methods_P` are
attempted until a me... | python | {
"resource": ""
} |
q255608 | MixtureProperty.set_user_method | validation | def set_user_method(self, user_methods, forced=False):
r'''Method to set the T, P, and composition dependent property methods
desired for consideration by the user. Can be used to exclude certain
methods which might have unacceptable accuracy.
As a side effect, the previously selected... | python | {
"resource": ""
} |
q255609 | MixtureProperty.property_derivative_T | validation | def property_derivative_T(self, T, P, zs, ws, order=1):
r'''Method to calculate a derivative of a mixture property with respect
to temperature at constant pressure and composition,
of a given order. Methods found valid by `select_valid_methods` are
attempted until a method succeeds. If ... | python | {
"resource": ""
} |
q255610 | MixtureProperty.property_derivative_P | validation | def property_derivative_P(self, T, P, zs, ws, order=1):
r'''Method to calculate a derivative of a mixture property with respect
to pressure at constant temperature and composition,
of a given order. Methods found valid by `select_valid_methods` are
attempted until a method succeeds. If ... | python | {
"resource": ""
} |
q255611 | refractive_index | validation | def refractive_index(CASRN, T=None, AvailableMethods=False, Method=None,
full_info=True):
r'''This function handles the retrieval of a chemical's refractive
index. Lookup is based on CASRNs. Will automatically select a data source
to use if no Method is provided; returns None if the dat... | python | {
"resource": ""
} |
q255612 | GCEOSMIX.solve_T | validation | def solve_T(self, P, V, quick=True):
r'''Generic method to calculate `T` from a specified `P` and `V`.
Provides SciPy's `newton` solver, and iterates to solve the general
equation for `P`, recalculating `a_alpha` as a function of temperature
using `a_alpha_and_derivatives` each iteration... | python | {
"resource": ""
} |
q255613 | PRMIX.setup_a_alpha_and_derivatives | validation | def setup_a_alpha_and_derivatives(self, i, T=None):
r'''Sets `a`, `kappa`, and `Tc` for a specific component before the
pure-species EOS's `a_alpha_and_derivatives` method is called. Both are
called by `GCEOSMIX.a_alpha_and_derivatives` for every component.'''
self.a, self.kappa, self.... | python | {
"resource": ""
} |
q255614 | SRKMIX.setup_a_alpha_and_derivatives | validation | def setup_a_alpha_and_derivatives(self, i, T=None):
r'''Sets `a`, `m`, and `Tc` for a specific component before the
pure-species EOS's `a_alpha_and_derivatives` method is called. Both are
called by `GCEOSMIX.a_alpha_and_derivatives` for every component.'''
self.a, self.m, self.Tc = sel... | python | {
"resource": ""
} |
q255615 | PRSVMIX.setup_a_alpha_and_derivatives | validation | def setup_a_alpha_and_derivatives(self, i, T=None):
r'''Sets `a`, `kappa0`, `kappa1`, and `Tc` for a specific component before the
pure-species EOS's `a_alpha_and_derivatives` method is called. Both are
called by `GCEOSMIX.a_alpha_and_derivatives` for every component.'''
if not hasattr... | python | {
"resource": ""
} |
q255616 | PRSV2MIX.setup_a_alpha_and_derivatives | validation | def setup_a_alpha_and_derivatives(self, i, T=None):
r'''Sets `a`, `kappa`, `kappa0`, `kappa1`, `kappa2`, `kappa3` and `Tc`
for a specific component before the
pure-species EOS's `a_alpha_and_derivatives` method is called. Both are
called by `GCEOSMIX.a_alpha_and_derivatives` for every ... | python | {
"resource": ""
} |
q255617 | TWUPRMIX.setup_a_alpha_and_derivatives | validation | def setup_a_alpha_and_derivatives(self, i, T=None):
r'''Sets `a`, `omega`, and `Tc` for a specific component before the
pure-species EOS's `a_alpha_and_derivatives` method is called. Both are
called by `GCEOSMIX.a_alpha_and_derivatives` for every component.'''
self.a, self.Tc, self.ome... | python | {
"resource": ""
} |
q255618 | APISRKMIX.setup_a_alpha_and_derivatives | validation | def setup_a_alpha_and_derivatives(self, i, T=None):
r'''Sets `a`, `S1`, `S2` and `Tc` for a specific component before the
pure-species EOS's `a_alpha_and_derivatives` method is called. Both are
called by `GCEOSMIX.a_alpha_and_derivatives` for every component.'''
self.a, self.Tc, self.S... | python | {
"resource": ""
} |
q255619 | Bahadori_liquid | validation | def Bahadori_liquid(T, M):
r'''Estimates the thermal conductivity of parafin liquid hydrocarbons.
Fits their data well, and is useful as only MW is required.
X is the Molecular weight, and Y the temperature.
.. math::
K = a + bY + CY^2 + dY^3
a = A_1 + B_1 X + C_1 X^2 + D_1 X^3
... | python | {
"resource": ""
} |
q255620 | Bahadori_gas | validation | def Bahadori_gas(T, MW):
r'''Estimates the thermal conductivity of hydrocarbons gases at low P.
Fits their data well, and is useful as only MW is required.
Y is the Molecular weight, and X the temperature.
.. math::
K = a + bY + CY^2 + dY^3
a = A_1 + B_1 X + C_1 X^2 + D_1 X^3
... | python | {
"resource": ""
} |
q255621 | ThermalConductivityLiquid.calculate | validation | def calculate(self, T, method):
r'''Method to calculate low-pressure liquid thermal conductivity at
tempearture `T` with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Tempe... | python | {
"resource": ""
} |
q255622 | ThermalConductivityLiquid.calculate_P | validation | def calculate_P(self, T, P, method):
r'''Method to calculate pressure-dependent liquid thermal conductivity
at temperature `T` and pressure `P` with a given method.
This method has no exception handling; see `TP_dependent_property`
for that.
Parameters
----------
... | python | {
"resource": ""
} |
q255623 | ThermalConductivityLiquidMixture.calculate | validation | def calculate(self, T, P, zs, ws, method):
r'''Method to calculate thermal conductivity of a liquid mixture at
temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
`ws` with a given method.
This method has no exception handling; see `mixture_property`
for tha... | python | {
"resource": ""
} |
q255624 | ThermalConductivityGas.calculate | validation | def calculate(self, T, method):
r'''Method to calculate low-pressure gas thermal conductivity at
tempearture `T` with a given method.
This method has no exception handling; see `T_dependent_property`
for that.
Parameters
----------
T : float
Temperat... | python | {
"resource": ""
} |
q255625 | ThermalConductivityGas.calculate_P | validation | def calculate_P(self, T, P, method):
r'''Method to calculate pressure-dependent gas thermal conductivity
at temperature `T` and pressure `P` with a given method.
This method has no exception handling; see `TP_dependent_property`
for that.
Parameters
----------
T... | python | {
"resource": ""
} |
q255626 | ThermalConductivityGasMixture.calculate | validation | def calculate(self, T, P, zs, ws, method):
r'''Method to calculate thermal conductivity of a gas mixture at
temperature `T`, pressure `P`, mole fractions `zs` and weight fractions
`ws` with a given method.
This method has no exception handling; see `mixture_property`
for that.
... | python | {
"resource": ""
} |
q255627 | nested_formula_parser | validation | def nested_formula_parser(formula, check=True):
r'''Improved formula parser which handles braces and their multipliers,
as well as rational element counts.
Strips charges from the end of a formula first. Accepts repeated chemical
units. Performs no sanity checking that elements are actually elements.
... | python | {
"resource": ""
} |
q255628 | charge_from_formula | validation | def charge_from_formula(formula):
r'''Basic formula parser to determine the charge from a formula - given
that the charge is already specified as one element of the formula.
Performs no sanity checking that elements are actually elements.
Parameters
----------
formula : str
Formula... | python | {
"resource": ""
} |
q255629 | serialize_formula | validation | def serialize_formula(formula):
r'''Basic formula serializer to construct a consistently-formatted formula.
This is necessary for handling user-supplied formulas, which are not always
well formatted.
Performs no sanity checking that elements are actually elements.
Parameters
----------
... | python | {
"resource": ""
} |
q255630 | Client.connect | validation | async def connect(self):
"""Establish a connection to the chat server.
Returns when an error has occurred, or :func:`disconnect` has been
called.
"""
proxy = os.environ.get('HTTP_PROXY')
self._session = http_utils.Session(self._cookies, proxy=proxy)
try:
... | python | {
"resource": ""
} |
q255631 | Client.get_request_header | validation | def get_request_header(self):
"""Return ``request_header`` for use when constructing requests.
Returns:
Populated request header.
"""
# resource is allowed to be null if it's not available yet (the Chrome
# client does this for the first getentitybyid call)
i... | python | {
"resource": ""
} |
q255632 | Client.set_active | validation | async def set_active(self):
"""Set this client as active.
While a client is active, no other clients will raise notifications.
Call this method whenever there is an indication the user is
interacting with this client. This method may be called very
frequently, and it will only m... | python | {
"resource": ""
} |
q255633 | Client.upload_image | validation | async def upload_image(self, image_file, filename=None, *,
return_uploaded_image=False):
"""Upload an image that can be later attached to a chat message.
Args:
image_file: A file-like object containing an image.
filename (str): (optional) Custom name f... | python | {
"resource": ""
} |
q255634 | Client._get_upload_session_status | validation | def _get_upload_session_status(res):
"""Parse the image upload response to obtain status.
Args:
res: http_utils.FetchResponse instance, the upload response
Returns:
dict, sessionStatus of the response
Raises:
hangups.NetworkError: If the upload requ... | python | {
"resource": ""
} |
q255635 | Client._on_receive_array | validation | async def _on_receive_array(self, array):
"""Parse channel array and call the appropriate events."""
if array[0] == 'noop':
pass # This is just a keep-alive, ignore it.
else:
wrapper = json.loads(array[0]['p'])
# Wrapper appears to be a Protocol Buffer messag... | python | {
"resource": ""
} |
q255636 | Client._add_channel_services | validation | async def _add_channel_services(self):
"""Add services to the channel.
The services we add to the channel determine what kind of data we will
receive on it.
The "babel" service includes what we need for Hangouts. If this fails
for some reason, hangups will never receive any eve... | python | {
"resource": ""
} |
q255637 | Client._pb_request | validation | async def _pb_request(self, endpoint, request_pb, response_pb):
"""Send a Protocol Buffer formatted chat API request.
Args:
endpoint (str): The chat API endpoint to use.
request_pb: The request body as a Protocol Buffer message.
response_pb: The response body as a Pr... | python | {
"resource": ""
} |
q255638 | Client._base_request | validation | async def _base_request(self, url, content_type, response_type, data):
"""Send a generic authenticated POST request.
Args:
url (str): URL of request.
content_type (str): Request content type.
response_type (str): The desired response format. Valid options
... | python | {
"resource": ""
} |
q255639 | Client.add_user | validation | async def add_user(self, add_user_request):
"""Invite users to join an existing group conversation."""
response = hangouts_pb2.AddUserResponse()
await self._pb_request('conversations/adduser',
add_user_request, response)
return response | python | {
"resource": ""
} |
q255640 | Client.create_conversation | validation | async def create_conversation(self, create_conversation_request):
"""Create a new conversation."""
response = hangouts_pb2.CreateConversationResponse()
await self._pb_request('conversations/createconversation',
create_conversation_request, response)
return ... | python | {
"resource": ""
} |
q255641 | Client.delete_conversation | validation | async def delete_conversation(self, delete_conversation_request):
"""Leave a one-to-one conversation.
One-to-one conversations are "sticky"; they can't actually be deleted.
This API clears the event history of the specified conversation up to
``delete_upper_bound_timestamp``, hiding it ... | python | {
"resource": ""
} |
q255642 | Client.easter_egg | validation | async def easter_egg(self, easter_egg_request):
"""Send an easter egg event to a conversation."""
response = hangouts_pb2.EasterEggResponse()
await self._pb_request('conversations/easteregg',
easter_egg_request, response)
return response | python | {
"resource": ""
} |
q255643 | Client.get_conversation | validation | async def get_conversation(self, get_conversation_request):
"""Return conversation info and recent events."""
response = hangouts_pb2.GetConversationResponse()
await self._pb_request('conversations/getconversation',
get_conversation_request, response)
retur... | python | {
"resource": ""
} |
q255644 | Client.get_entity_by_id | validation | async def get_entity_by_id(self, get_entity_by_id_request):
"""Return one or more user entities.
Searching by phone number only finds entities when their phone number
is in your contacts (and not always even then), and can't be used to
find Google Voice contacts.
"""
res... | python | {
"resource": ""
} |
q255645 | Client.get_group_conversation_url | validation | async def get_group_conversation_url(self,
get_group_conversation_url_request):
"""Get URL to allow others to join a group conversation."""
response = hangouts_pb2.GetGroupConversationUrlResponse()
await self._pb_request('conversations/getgroupconversatio... | python | {
"resource": ""
} |
q255646 | Client.get_self_info | validation | async def get_self_info(self, get_self_info_request):
"""Return info about the current user."""
response = hangouts_pb2.GetSelfInfoResponse()
await self._pb_request('contacts/getselfinfo',
get_self_info_request, response)
return response | python | {
"resource": ""
} |
q255647 | Client.get_suggested_entities | validation | async def get_suggested_entities(self, get_suggested_entities_request):
"""Return suggested contacts."""
response = hangouts_pb2.GetSuggestedEntitiesResponse()
await self._pb_request('contacts/getsuggestedentities',
get_suggested_entities_request, response)
... | python | {
"resource": ""
} |
q255648 | Client.query_presence | validation | async def query_presence(self, query_presence_request):
"""Return presence status for a list of users."""
response = hangouts_pb2.QueryPresenceResponse()
await self._pb_request('presence/querypresence',
query_presence_request, response)
return response | python | {
"resource": ""
} |
q255649 | Client.remove_user | validation | async def remove_user(self, remove_user_request):
"""Remove a participant from a group conversation."""
response = hangouts_pb2.RemoveUserResponse()
await self._pb_request('conversations/removeuser',
remove_user_request, response)
return response | python | {
"resource": ""
} |
q255650 | Client.rename_conversation | validation | async def rename_conversation(self, rename_conversation_request):
"""Rename a conversation.
Both group and one-to-one conversations may be renamed, but the
official Hangouts clients have mixed support for one-to-one
conversations with custom names.
"""
response = hangout... | python | {
"resource": ""
} |
q255651 | Client.search_entities | validation | async def search_entities(self, search_entities_request):
"""Return user entities based on a query."""
response = hangouts_pb2.SearchEntitiesResponse()
await self._pb_request('contacts/searchentities',
search_entities_request, response)
return response | python | {
"resource": ""
} |
q255652 | Client.send_chat_message | validation | async def send_chat_message(self, send_chat_message_request):
"""Send a chat message to a conversation."""
response = hangouts_pb2.SendChatMessageResponse()
await self._pb_request('conversations/sendchatmessage',
send_chat_message_request, response)
return ... | python | {
"resource": ""
} |
q255653 | Client.modify_otr_status | validation | async def modify_otr_status(self, modify_otr_status_request):
"""Enable or disable message history in a conversation."""
response = hangouts_pb2.ModifyOTRStatusResponse()
await self._pb_request('conversations/modifyotrstatus',
modify_otr_status_request, response)
... | python | {
"resource": ""
} |
q255654 | Client.send_offnetwork_invitation | validation | async def send_offnetwork_invitation(
self, send_offnetwork_invitation_request
):
"""Send an email to invite a non-Google contact to Hangouts."""
response = hangouts_pb2.SendOffnetworkInvitationResponse()
await self._pb_request('devices/sendoffnetworkinvitation',
... | python | {
"resource": ""
} |
q255655 | Client.set_active_client | validation | async def set_active_client(self, set_active_client_request):
"""Set the active client."""
response = hangouts_pb2.SetActiveClientResponse()
await self._pb_request('clients/setactiveclient',
set_active_client_request, response)
return response | python | {
"resource": ""
} |
q255656 | Client.set_conversation_notification_level | validation | async def set_conversation_notification_level(
self, set_conversation_notification_level_request
):
"""Set the notification level of a conversation."""
response = hangouts_pb2.SetConversationNotificationLevelResponse()
await self._pb_request(
'conversations/setconvers... | python | {
"resource": ""
} |
q255657 | Client.set_focus | validation | async def set_focus(self, set_focus_request):
"""Set focus to a conversation."""
response = hangouts_pb2.SetFocusResponse()
await self._pb_request('conversations/setfocus',
set_focus_request, response)
return response | python | {
"resource": ""
} |
q255658 | Client.set_group_link_sharing_enabled | validation | async def set_group_link_sharing_enabled(
self, set_group_link_sharing_enabled_request
):
"""Set whether group link sharing is enabled for a conversation."""
response = hangouts_pb2.SetGroupLinkSharingEnabledResponse()
await self._pb_request('conversations/setgrouplinksharingenab... | python | {
"resource": ""
} |
q255659 | Client.set_presence | validation | async def set_presence(self, set_presence_request):
"""Set the presence status."""
response = hangouts_pb2.SetPresenceResponse()
await self._pb_request('presence/setpresence',
set_presence_request, response)
return response | python | {
"resource": ""
} |
q255660 | Client.set_typing | validation | async def set_typing(self, set_typing_request):
"""Set the typing status of a conversation."""
response = hangouts_pb2.SetTypingResponse()
await self._pb_request('conversations/settyping',
set_typing_request, response)
return response | python | {
"resource": ""
} |
q255661 | Client.sync_all_new_events | validation | async def sync_all_new_events(self, sync_all_new_events_request):
"""List all events occurring at or after a timestamp."""
response = hangouts_pb2.SyncAllNewEventsResponse()
await self._pb_request('conversations/syncallnewevents',
sync_all_new_events_request, respo... | python | {
"resource": ""
} |
q255662 | Client.sync_recent_conversations | validation | async def sync_recent_conversations(
self, sync_recent_conversations_request
):
"""Return info on recent conversations and their events."""
response = hangouts_pb2.SyncRecentConversationsResponse()
await self._pb_request('conversations/syncrecentconversations',
... | python | {
"resource": ""
} |
q255663 | from_timestamp | validation | def from_timestamp(microsecond_timestamp):
"""Convert a microsecond timestamp to a UTC datetime instance."""
# Create datetime without losing precision from floating point (yes, this
# is actually needed):
return datetime.datetime.fromtimestamp(
microsecond_timestamp // 1000000, datetime.timezon... | python | {
"resource": ""
} |
q255664 | from_participantid | validation | def from_participantid(participant_id):
"""Convert hangouts_pb2.ParticipantId to UserID."""
return user.UserID(
chat_id=participant_id.chat_id,
gaia_id=participant_id.gaia_id
) | python | {
"resource": ""
} |
q255665 | to_participantid | validation | def to_participantid(user_id):
"""Convert UserID to hangouts_pb2.ParticipantId."""
return hangouts_pb2.ParticipantId(
chat_id=user_id.chat_id,
gaia_id=user_id.gaia_id
) | python | {
"resource": ""
} |
q255666 | parse_typing_status_message | validation | def parse_typing_status_message(p):
"""Return TypingStatusMessage from hangouts_pb2.SetTypingNotification.
The same status may be sent multiple times consecutively, and when a
message is sent the typing status will not change to stopped.
"""
return TypingStatusMessage(
conv_id=p.conversatio... | python | {
"resource": ""
} |
q255667 | parse_watermark_notification | validation | def parse_watermark_notification(p):
"""Return WatermarkNotification from hangouts_pb2.WatermarkNotification."""
return WatermarkNotification(
conv_id=p.conversation_id.id,
user_id=from_participantid(p.sender_id),
read_timestamp=from_timestamp(
p.latest_read_timestamp
... | python | {
"resource": ""
} |
q255668 | _get_authorization_headers | validation | def _get_authorization_headers(sapisid_cookie):
"""Return authorization headers for API request."""
# It doesn't seem to matter what the url and time are as long as they are
# consistent.
time_msec = int(time.time() * 1000)
auth_string = '{} {} {}'.format(time_msec, sapisid_cookie, ORIGIN_URL)
a... | python | {
"resource": ""
} |
q255669 | Session.fetch | validation | async def fetch(self, method, url, params=None, headers=None, data=None):
"""Make an HTTP request.
Automatically uses configured HTTP proxy, and adds Google authorization
header and cookies.
Failures will be retried MAX_RETRIES times before raising NetworkError.
Args:
... | python | {
"resource": ""
} |
q255670 | Session.fetch_raw | validation | def fetch_raw(self, method, url, params=None, headers=None, data=None):
"""Make an HTTP request using aiohttp directly.
Automatically uses configured HTTP proxy, and adds Google authorization
header and cookies.
Args:
method (str): Request method.
url (str): Req... | python | {
"resource": ""
} |
q255671 | lookup_entities | validation | async def lookup_entities(client, args):
"""Search for entities by phone number, email, or gaia_id."""
lookup_spec = _get_lookup_spec(args.entity_identifier)
request = hangups.hangouts_pb2.GetEntityByIdRequest(
request_header=client.get_request_header(),
batch_lookup_spec=[lookup_spec],
... | python | {
"resource": ""
} |
q255672 | _get_lookup_spec | validation | def _get_lookup_spec(identifier):
"""Return EntityLookupSpec from phone number, email address, or gaia ID."""
if identifier.startswith('+'):
return hangups.hangouts_pb2.EntityLookupSpec(
phone=identifier, create_offnetwork_gaia=True
)
elif '@' in identifier:
return hangup... | python | {
"resource": ""
} |
q255673 | get_conv_name | validation | def get_conv_name(conv, truncate=False, show_unread=False):
"""Return a readable name for a conversation.
If the conversation has a custom name, use the custom name. Otherwise, for
one-to-one conversations, the name is the full name of the other user. For
group conversations, the name is a comma-separa... | python | {
"resource": ""
} |
q255674 | add_color_to_scheme | validation | def add_color_to_scheme(scheme, name, foreground, background, palette_colors):
"""Add foreground and background colours to a color scheme"""
if foreground is None and background is None:
return scheme
new_scheme = []
for item in scheme:
if item[0] == name:
if foreground is N... | python | {
"resource": ""
} |
q255675 | _sync_all_conversations | validation | async def _sync_all_conversations(client):
"""Sync all conversations by making paginated requests.
Conversations are ordered by ascending sort timestamp.
Args:
client (Client): Connected client.
Raises:
NetworkError: If the requests fail.
Returns:
tuple of list of ``Conve... | python | {
"resource": ""
} |
q255676 | Conversation.unread_events | validation | def unread_events(self):
"""Loaded events which are unread sorted oldest to newest.
Some Hangouts clients don't update the read timestamp for certain event
types, such as membership changes, so this may return more unread
events than these clients will show. There's also a delay between... | python | {
"resource": ""
} |
q255677 | Conversation.is_quiet | validation | def is_quiet(self):
"""``True`` if notification level for this conversation is quiet."""
level = self._conversation.self_conversation_state.notification_level
return level == hangouts_pb2.NOTIFICATION_LEVEL_QUIET | python | {
"resource": ""
} |
q255678 | Conversation._on_watermark_notification | validation | def _on_watermark_notification(self, notif):
"""Handle a watermark notification."""
# Update the conversation:
if self.get_user(notif.user_id).is_self:
logger.info('latest_read_timestamp for {} updated to {}'
.format(self.id_, notif.read_timestamp))
... | python | {
"resource": ""
} |
q255679 | Conversation.update_conversation | validation | def update_conversation(self, conversation):
"""Update the internal state of the conversation.
This method is used by :class:`.ConversationList` to maintain this
instance.
Args:
conversation: ``Conversation`` message.
"""
# StateUpdate.conversation is actual... | python | {
"resource": ""
} |
q255680 | Conversation._wrap_event | validation | def _wrap_event(event_):
"""Wrap hangouts_pb2.Event in ConversationEvent subclass."""
cls = conversation_event.ConversationEvent
if event_.HasField('chat_message'):
cls = conversation_event.ChatMessageEvent
elif event_.HasField('otr_modification'):
cls = conversat... | python | {
"resource": ""
} |
q255681 | Conversation.add_event | validation | def add_event(self, event_):
"""Add an event to the conversation.
This method is used by :class:`.ConversationList` to maintain this
instance.
Args:
event_: ``Event`` message.
Returns:
:class:`.ConversationEvent` representing the event.
"""
... | python | {
"resource": ""
} |
q255682 | Conversation._get_default_delivery_medium | validation | def _get_default_delivery_medium(self):
"""Return default DeliveryMedium to use for sending messages.
Use the first option, or an option that's marked as the current
default.
"""
medium_options = (
self._conversation.self_conversation_state.delivery_medium_option
... | python | {
"resource": ""
} |
q255683 | Conversation._get_event_request_header | validation | def _get_event_request_header(self):
"""Return EventRequestHeader for conversation."""
otr_status = (hangouts_pb2.OFF_THE_RECORD_STATUS_OFF_THE_RECORD
if self.is_off_the_record else
hangouts_pb2.OFF_THE_RECORD_STATUS_ON_THE_RECORD)
return hangouts_pb2.... | python | {
"resource": ""
} |
q255684 | Conversation.send_message | validation | async def send_message(self, segments, image_file=None, image_id=None,
image_user_id=None):
"""Send a message to this conversation.
A per-conversation lock is acquired to ensure that messages are sent in
the correct order when this method is called multiple times
... | python | {
"resource": ""
} |
q255685 | Conversation.leave | validation | async def leave(self):
"""Leave this conversation.
Raises:
.NetworkError: If conversation cannot be left.
"""
is_group_conversation = (self._conversation.type ==
hangouts_pb2.CONVERSATION_TYPE_GROUP)
try:
if is_group_conve... | python | {
"resource": ""
} |
q255686 | Conversation.rename | validation | async def rename(self, name):
"""Rename this conversation.
Hangouts only officially supports renaming group conversations, so
custom names for one-to-one conversations may or may not appear in all
first party clients.
Args:
name (str): New name.
Raises:
... | python | {
"resource": ""
} |
q255687 | Conversation.set_notification_level | validation | async def set_notification_level(self, level):
"""Set the notification level of this conversation.
Args:
level: ``NOTIFICATION_LEVEL_QUIET`` to disable notifications, or
``NOTIFICATION_LEVEL_RING`` to enable them.
Raises:
.NetworkError: If the request fa... | python | {
"resource": ""
} |
q255688 | Conversation.set_typing | validation | async def set_typing(self, typing=hangouts_pb2.TYPING_TYPE_STARTED):
"""Set your typing status in this conversation.
Args:
typing: (optional) ``TYPING_TYPE_STARTED``, ``TYPING_TYPE_PAUSED``,
or ``TYPING_TYPE_STOPPED`` to start, pause, or stop typing,
respecti... | python | {
"resource": ""
} |
q255689 | Conversation.update_read_timestamp | validation | async def update_read_timestamp(self, read_timestamp=None):
"""Update the timestamp of the latest event which has been read.
This method will avoid making an API request if it will have no effect.
Args:
read_timestamp (datetime.datetime): (optional) Timestamp to set.
... | python | {
"resource": ""
} |
q255690 | Conversation.get_events | validation | async def get_events(self, event_id=None, max_events=50):
"""Get events from this conversation.
Makes a request to load historical events if necessary.
Args:
event_id (str): (optional) If provided, return events preceding
this event, otherwise return the newest even... | python | {
"resource": ""
} |
q255691 | Conversation.next_event | validation | def next_event(self, event_id, prev=False):
"""Get the event following another event in this conversation.
Args:
event_id (str): ID of the event.
prev (bool): If ``True``, return the previous event rather than the
next event. Defaults to ``False``.
Raise... | python | {
"resource": ""
} |
q255692 | ConversationList.get_all | validation | def get_all(self, include_archived=False):
"""Get all the conversations.
Args:
include_archived (bool): (optional) Whether to include archived
conversations. Defaults to ``False``.
Returns:
List of all :class:`.Conversation` objects.
"""
... | python | {
"resource": ""
} |
q255693 | ConversationList.leave_conversation | validation | async def leave_conversation(self, conv_id):
"""Leave a conversation.
Args:
conv_id (str): ID of conversation to leave.
"""
logger.info('Leaving conversation: {}'.format(conv_id))
await self._conv_dict[conv_id].leave()
del self._conv_dict[conv_id] | python | {
"resource": ""
} |
q255694 | ConversationList._add_conversation | validation | def _add_conversation(self, conversation, events=[],
event_cont_token=None):
"""Add new conversation from hangouts_pb2.Conversation"""
# pylint: disable=dangerous-default-value
conv_id = conversation.conversation_id.id
logger.debug('Adding new conversation: {}'.... | python | {
"resource": ""
} |
q255695 | ConversationList._on_state_update | validation | async def _on_state_update(self, state_update):
"""Receive a StateUpdate and fan out to Conversations.
Args:
state_update: hangouts_pb2.StateUpdate instance
"""
# The state update will include some type of notification:
notification_type = state_update.WhichOneof('st... | python | {
"resource": ""
} |
q255696 | ConversationList._get_or_fetch_conversation | validation | async def _get_or_fetch_conversation(self, conv_id):
"""Get a cached conversation or fetch a missing conversation.
Args:
conv_id: string, conversation identifier
Raises:
NetworkError: If the request to fetch the conversation fails.
Returns:
:class:`... | python | {
"resource": ""
} |
q255697 | ConversationList._on_event | validation | async def _on_event(self, event_):
"""Receive a hangouts_pb2.Event and fan out to Conversations.
Args:
event_: hangouts_pb2.Event instance
"""
conv_id = event_.conversation_id.id
try:
conv = await self._get_or_fetch_conversation(conv_id)
except ex... | python | {
"resource": ""
} |
q255698 | ConversationList._handle_conversation_delta | validation | async def _handle_conversation_delta(self, conversation):
"""Receive Conversation delta and create or update the conversation.
Args:
conversation: hangouts_pb2.Conversation instance
Raises:
NetworkError: A request to fetch the complete conversation failed.
"""
... | python | {
"resource": ""
} |
q255699 | ConversationList._handle_set_typing_notification | validation | async def _handle_set_typing_notification(self, set_typing_notification):
"""Receive SetTypingNotification and update the conversation.
Args:
set_typing_notification: hangouts_pb2.SetTypingNotification
instance
"""
conv_id = set_typing_notification.conversati... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.