repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserAction.update | def update(self, email=None, username=None, first_name=None, last_name=None, country=None):
"""
Update values on an existing user. See the API docs for what kinds of update are possible.
:param email: new email for this user
:param username: new username for this user
:param fir... | python | def update(self, email=None, username=None, first_name=None, last_name=None, country=None):
"""
Update values on an existing user. See the API docs for what kinds of update are possible.
:param email: new email for this user
:param username: new username for this user
:param fir... | [
"def",
"update",
"(",
"self",
",",
"email",
"=",
"None",
",",
"username",
"=",
"None",
",",
"first_name",
"=",
"None",
",",
"last_name",
"=",
"None",
",",
"country",
"=",
"None",
")",
":",
"if",
"username",
"and",
"self",
".",
"id_type",
"!=",
"Ident... | Update values on an existing user. See the API docs for what kinds of update are possible.
:param email: new email for this user
:param username: new username for this user
:param first_name: new first name for this user
:param last_name: new last name for this user
:param count... | [
"Update",
"values",
"on",
"an",
"existing",
"user",
".",
"See",
"the",
"API",
"docs",
"for",
"what",
"kinds",
"of",
"update",
"are",
"possible",
".",
":",
"param",
"email",
":",
"new",
"email",
"for",
"this",
"user",
":",
"param",
"username",
":",
"new... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L158-L180 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserAction.add_to_groups | def add_to_groups(self, groups=None, all_groups=False, group_type=None):
"""
Add user to some (typically PLC) groups. Note that, if you add to no groups, the effect
is simply to do an "add to organization Everybody group", so we let that be done.
:param groups: list of group names the u... | python | def add_to_groups(self, groups=None, all_groups=False, group_type=None):
"""
Add user to some (typically PLC) groups. Note that, if you add to no groups, the effect
is simply to do an "add to organization Everybody group", so we let that be done.
:param groups: list of group names the u... | [
"def",
"add_to_groups",
"(",
"self",
",",
"groups",
"=",
"None",
",",
"all_groups",
"=",
"False",
",",
"group_type",
"=",
"None",
")",
":",
"if",
"all_groups",
":",
"if",
"groups",
"or",
"group_type",
":",
"raise",
"ArgumentError",
"(",
"\"When adding to all... | Add user to some (typically PLC) groups. Note that, if you add to no groups, the effect
is simply to do an "add to organization Everybody group", so we let that be done.
:param groups: list of group names the user should be added to
:param all_groups: a boolean meaning add to all (don't specify... | [
"Add",
"user",
"to",
"some",
"(",
"typically",
"PLC",
")",
"groups",
".",
"Note",
"that",
"if",
"you",
"add",
"to",
"no",
"groups",
"the",
"effect",
"is",
"simply",
"to",
"do",
"an",
"add",
"to",
"organization",
"Everybody",
"group",
"so",
"we",
"let",... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L182-L205 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserAction.remove_from_groups | def remove_from_groups(self, groups=None, all_groups=False, group_type=None):
"""
Remove user from some PLC groups, or all of them.
:param groups: list of group names the user should be removed from
:param all_groups: a boolean meaning remove from all (don't specify groups or group_type ... | python | def remove_from_groups(self, groups=None, all_groups=False, group_type=None):
"""
Remove user from some PLC groups, or all of them.
:param groups: list of group names the user should be removed from
:param all_groups: a boolean meaning remove from all (don't specify groups or group_type ... | [
"def",
"remove_from_groups",
"(",
"self",
",",
"groups",
"=",
"None",
",",
"all_groups",
"=",
"False",
",",
"group_type",
"=",
"None",
")",
":",
"if",
"all_groups",
":",
"if",
"groups",
"or",
"group_type",
":",
"raise",
"ArgumentError",
"(",
"\"When removing... | Remove user from some PLC groups, or all of them.
:param groups: list of group names the user should be removed from
:param all_groups: a boolean meaning remove from all (don't specify groups or group_type in this case)
:param group_type: the type of group (defaults to "product")
:return... | [
"Remove",
"user",
"from",
"some",
"PLC",
"groups",
"or",
"all",
"of",
"them",
".",
":",
"param",
"groups",
":",
"list",
"of",
"group",
"names",
"the",
"user",
"should",
"be",
"removed",
"from",
":",
"param",
"all_groups",
":",
"a",
"boolean",
"meaning",
... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L207-L229 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserAction.add_role | def add_role(self, groups=None, role_type=RoleTypes.admin):
"""
Make user have a role (typically PLC admin) with respect to some PLC groups.
:param groups: list of group names the user should have this role for
:param role_type: the role (defaults to "admin")
:return: the User, s... | python | def add_role(self, groups=None, role_type=RoleTypes.admin):
"""
Make user have a role (typically PLC admin) with respect to some PLC groups.
:param groups: list of group names the user should have this role for
:param role_type: the role (defaults to "admin")
:return: the User, s... | [
"def",
"add_role",
"(",
"self",
",",
"groups",
"=",
"None",
",",
"role_type",
"=",
"RoleTypes",
".",
"admin",
")",
":",
"if",
"not",
"groups",
":",
"raise",
"ArgumentError",
"(",
"\"You must specify groups to which to add the role for this user\"",
")",
"if",
"rol... | Make user have a role (typically PLC admin) with respect to some PLC groups.
:param groups: list of group names the user should have this role for
:param role_type: the role (defaults to "admin")
:return: the User, so you can do User(...).add_role(...).add_to_groups(...) | [
"Make",
"user",
"have",
"a",
"role",
"(",
"typically",
"PLC",
"admin",
")",
"with",
"respect",
"to",
"some",
"PLC",
"groups",
".",
":",
"param",
"groups",
":",
"list",
"of",
"group",
"names",
"the",
"user",
"should",
"have",
"this",
"role",
"for",
":",... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L231-L245 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserAction.remove_role | def remove_role(self, groups=None, role_type=RoleTypes.admin):
"""
Remove user from a role (typically admin) of some groups.
:param groups: list of group names the user should NOT have this role for
:param role_type: the type of role (defaults to "admin")
:return: the User, so yo... | python | def remove_role(self, groups=None, role_type=RoleTypes.admin):
"""
Remove user from a role (typically admin) of some groups.
:param groups: list of group names the user should NOT have this role for
:param role_type: the type of role (defaults to "admin")
:return: the User, so yo... | [
"def",
"remove_role",
"(",
"self",
",",
"groups",
"=",
"None",
",",
"role_type",
"=",
"RoleTypes",
".",
"admin",
")",
":",
"if",
"not",
"groups",
":",
"raise",
"ArgumentError",
"(",
"\"You must specify groups from which to remove the role for this user\"",
")",
"if"... | Remove user from a role (typically admin) of some groups.
:param groups: list of group names the user should NOT have this role for
:param role_type: the type of role (defaults to "admin")
:return: the User, so you can do User(...).remove_role(...).remove_from_groups(...) | [
"Remove",
"user",
"from",
"a",
"role",
"(",
"typically",
"admin",
")",
"of",
"some",
"groups",
".",
":",
"param",
"groups",
":",
"list",
"of",
"group",
"names",
"the",
"user",
"should",
"NOT",
"have",
"this",
"role",
"for",
":",
"param",
"role_type",
"... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L247-L261 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserAction.remove_from_organization | def remove_from_organization(self, delete_account=False):
"""
Remove a user from the organization's list of visible users. Optionally also delete the account.
Deleting the account can only be done if the organization owns the account's domain.
:param delete_account: Whether to delete th... | python | def remove_from_organization(self, delete_account=False):
"""
Remove a user from the organization's list of visible users. Optionally also delete the account.
Deleting the account can only be done if the organization owns the account's domain.
:param delete_account: Whether to delete th... | [
"def",
"remove_from_organization",
"(",
"self",
",",
"delete_account",
"=",
"False",
")",
":",
"self",
".",
"append",
"(",
"removeFromOrg",
"=",
"{",
"\"deleteAccount\"",
":",
"True",
"if",
"delete_account",
"else",
"False",
"}",
")",
"return",
"None"
] | Remove a user from the organization's list of visible users. Optionally also delete the account.
Deleting the account can only be done if the organization owns the account's domain.
:param delete_account: Whether to delete the account after removing from the organization (default false)
:return... | [
"Remove",
"a",
"user",
"from",
"the",
"organization",
"s",
"list",
"of",
"visible",
"users",
".",
"Optionally",
"also",
"delete",
"the",
"account",
".",
"Deleting",
"the",
"account",
"can",
"only",
"be",
"done",
"if",
"the",
"organization",
"owns",
"the",
... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L263-L271 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserAction.delete_account | def delete_account(self):
"""
Delete a user's account.
Deleting the user's account can only be done if the user's domain is controlled by the authorized organization,
and removing the account will also remove the user from all organizations with access to that domain.
:return: No... | python | def delete_account(self):
"""
Delete a user's account.
Deleting the user's account can only be done if the user's domain is controlled by the authorized organization,
and removing the account will also remove the user from all organizations with access to that domain.
:return: No... | [
"def",
"delete_account",
"(",
"self",
")",
":",
"if",
"self",
".",
"id_type",
"==",
"IdentityTypes",
".",
"adobeID",
":",
"raise",
"ArgumentError",
"(",
"\"You cannot delete an Adobe ID account.\"",
")",
"self",
".",
"append",
"(",
"removeFromDomain",
"=",
"{",
... | Delete a user's account.
Deleting the user's account can only be done if the user's domain is controlled by the authorized organization,
and removing the account will also remove the user from all organizations with access to that domain.
:return: None, because you cannot follow this command wit... | [
"Delete",
"a",
"user",
"s",
"account",
".",
"Deleting",
"the",
"user",
"s",
"account",
"can",
"only",
"be",
"done",
"if",
"the",
"user",
"s",
"domain",
"is",
"controlled",
"by",
"the",
"authorized",
"organization",
"and",
"removing",
"the",
"account",
"wil... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L273-L283 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserGroupAction._validate | def _validate(cls, group_name):
"""
Validates the group name
Input values must be strings (standard or unicode). Throws ArgumentError if any input is invalid
:param group_name: name of group
"""
if group_name and not cls._group_name_regex.match(group_name):
r... | python | def _validate(cls, group_name):
"""
Validates the group name
Input values must be strings (standard or unicode). Throws ArgumentError if any input is invalid
:param group_name: name of group
"""
if group_name and not cls._group_name_regex.match(group_name):
r... | [
"def",
"_validate",
"(",
"cls",
",",
"group_name",
")",
":",
"if",
"group_name",
"and",
"not",
"cls",
".",
"_group_name_regex",
".",
"match",
"(",
"group_name",
")",
":",
"raise",
"ArgumentError",
"(",
"\"'%s': Illegal group name\"",
"%",
"(",
"group_name",
",... | Validates the group name
Input values must be strings (standard or unicode). Throws ArgumentError if any input is invalid
:param group_name: name of group | [
"Validates",
"the",
"group",
"name",
"Input",
"values",
"must",
"be",
"strings",
"(",
"standard",
"or",
"unicode",
")",
".",
"Throws",
"ArgumentError",
"if",
"any",
"input",
"is",
"invalid",
":",
"param",
"group_name",
":",
"name",
"of",
"group"
] | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L329-L338 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserGroupAction.add_to_products | def add_to_products(self, products=None, all_products=False):
"""
Add user group to some product license configuration groups (PLCs), or all of them.
:param products: list of product names the user should be added to
:param all_products: a boolean meaning add to all (don't specify produc... | python | def add_to_products(self, products=None, all_products=False):
"""
Add user group to some product license configuration groups (PLCs), or all of them.
:param products: list of product names the user should be added to
:param all_products: a boolean meaning add to all (don't specify produc... | [
"def",
"add_to_products",
"(",
"self",
",",
"products",
"=",
"None",
",",
"all_products",
"=",
"False",
")",
":",
"if",
"all_products",
":",
"if",
"products",
":",
"raise",
"ArgumentError",
"(",
"\"When adding to all products, do not specify specific products\"",
")",... | Add user group to some product license configuration groups (PLCs), or all of them.
:param products: list of product names the user should be added to
:param all_products: a boolean meaning add to all (don't specify products in this case)
:return: the Group, so you can do Group(...).add_to_produ... | [
"Add",
"user",
"group",
"to",
"some",
"product",
"license",
"configuration",
"groups",
"(",
"PLCs",
")",
"or",
"all",
"of",
"them",
".",
":",
"param",
"products",
":",
"list",
"of",
"product",
"names",
"the",
"user",
"should",
"be",
"added",
"to",
":",
... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L350-L365 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserGroupAction.remove_from_products | def remove_from_products(self, products=None, all_products=False):
"""
Remove user group from some product license configuration groups (PLCs), or all of them.
:param products: list of product names the user group should be removed from
:param all_products: a boolean meaning remove from ... | python | def remove_from_products(self, products=None, all_products=False):
"""
Remove user group from some product license configuration groups (PLCs), or all of them.
:param products: list of product names the user group should be removed from
:param all_products: a boolean meaning remove from ... | [
"def",
"remove_from_products",
"(",
"self",
",",
"products",
"=",
"None",
",",
"all_products",
"=",
"False",
")",
":",
"if",
"all_products",
":",
"if",
"products",
":",
"raise",
"ArgumentError",
"(",
"\"When removing from all products, do not specify specific products\"... | Remove user group from some product license configuration groups (PLCs), or all of them.
:param products: list of product names the user group should be removed from
:param all_products: a boolean meaning remove from all (don't specify products in this case)
:return: the Group, so you can do Gro... | [
"Remove",
"user",
"group",
"from",
"some",
"product",
"license",
"configuration",
"groups",
"(",
"PLCs",
")",
"or",
"all",
"of",
"them",
".",
":",
"param",
"products",
":",
"list",
"of",
"product",
"names",
"the",
"user",
"group",
"should",
"be",
"removed"... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L367-L382 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserGroupAction.add_users | def add_users(self, users=None):
"""
Add users (specified by email address) to this user group.
In case of ambiguity (two users with same email address), the non-AdobeID user is preferred.
:param users: list of emails for users to add to the group.
:return: the Group, so you can ... | python | def add_users(self, users=None):
"""
Add users (specified by email address) to this user group.
In case of ambiguity (two users with same email address), the non-AdobeID user is preferred.
:param users: list of emails for users to add to the group.
:return: the Group, so you can ... | [
"def",
"add_users",
"(",
"self",
",",
"users",
"=",
"None",
")",
":",
"if",
"not",
"users",
":",
"raise",
"ArgumentError",
"(",
"\"You must specify emails for users to add to the user group\"",
")",
"ulist",
"=",
"{",
"\"user\"",
":",
"[",
"user",
"for",
"user",... | Add users (specified by email address) to this user group.
In case of ambiguity (two users with same email address), the non-AdobeID user is preferred.
:param users: list of emails for users to add to the group.
:return: the Group, so you can do Group(...).add_users(...).add_to_products(...) | [
"Add",
"users",
"(",
"specified",
"by",
"email",
"address",
")",
"to",
"this",
"user",
"group",
".",
"In",
"case",
"of",
"ambiguity",
"(",
"two",
"users",
"with",
"same",
"email",
"address",
")",
"the",
"non",
"-",
"AdobeID",
"user",
"is",
"preferred",
... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L384-L394 | train |
adobe-apiplatform/umapi-client.py | umapi_client/functional.py | UserGroupAction.remove_users | def remove_users(self, users=None):
"""
Remove users (specified by email address) from this user group.
In case of ambiguity (two users with same email address), the non-AdobeID user is preferred.
:param users: list of emails for users to remove from the group.
:return: the Group... | python | def remove_users(self, users=None):
"""
Remove users (specified by email address) from this user group.
In case of ambiguity (two users with same email address), the non-AdobeID user is preferred.
:param users: list of emails for users to remove from the group.
:return: the Group... | [
"def",
"remove_users",
"(",
"self",
",",
"users",
"=",
"None",
")",
":",
"if",
"not",
"users",
":",
"raise",
"ArgumentError",
"(",
"\"You must specify emails for users to remove from the user group\"",
")",
"ulist",
"=",
"{",
"\"user\"",
":",
"[",
"user",
"for",
... | Remove users (specified by email address) from this user group.
In case of ambiguity (two users with same email address), the non-AdobeID user is preferred.
:param users: list of emails for users to remove from the group.
:return: the Group, so you can do Group(...).remove_users(...).add_to_prod... | [
"Remove",
"users",
"(",
"specified",
"by",
"email",
"address",
")",
"from",
"this",
"user",
"group",
".",
"In",
"case",
"of",
"ambiguity",
"(",
"two",
"users",
"with",
"same",
"email",
"address",
")",
"the",
"non",
"-",
"AdobeID",
"user",
"is",
"preferre... | 1c446d79643cc8615adaa23e12dce3ac5782cf76 | https://github.com/adobe-apiplatform/umapi-client.py/blob/1c446d79643cc8615adaa23e12dce3ac5782cf76/umapi_client/functional.py#L396-L406 | train |
rm-hull/luma.emulator | luma/emulator/render.py | transformer.scale2x | def scale2x(self, surface):
"""
Scales using the AdvanceMAME Scale2X algorithm which does a
'jaggie-less' scale of bitmap graphics.
"""
assert(self._scale == 2)
return self._pygame.transform.scale2x(surface) | python | def scale2x(self, surface):
"""
Scales using the AdvanceMAME Scale2X algorithm which does a
'jaggie-less' scale of bitmap graphics.
"""
assert(self._scale == 2)
return self._pygame.transform.scale2x(surface) | [
"def",
"scale2x",
"(",
"self",
",",
"surface",
")",
":",
"assert",
"(",
"self",
".",
"_scale",
"==",
"2",
")",
"return",
"self",
".",
"_pygame",
".",
"transform",
".",
"scale2x",
"(",
"surface",
")"
] | Scales using the AdvanceMAME Scale2X algorithm which does a
'jaggie-less' scale of bitmap graphics. | [
"Scales",
"using",
"the",
"AdvanceMAME",
"Scale2X",
"algorithm",
"which",
"does",
"a",
"jaggie",
"-",
"less",
"scale",
"of",
"bitmap",
"graphics",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/render.py#L31-L37 | train |
rm-hull/luma.emulator | luma/emulator/render.py | transformer.smoothscale | def smoothscale(self, surface):
"""
Smooth scaling using MMX or SSE extensions if available
"""
return self._pygame.transform.smoothscale(surface, self._output_size) | python | def smoothscale(self, surface):
"""
Smooth scaling using MMX or SSE extensions if available
"""
return self._pygame.transform.smoothscale(surface, self._output_size) | [
"def",
"smoothscale",
"(",
"self",
",",
"surface",
")",
":",
"return",
"self",
".",
"_pygame",
".",
"transform",
".",
"smoothscale",
"(",
"surface",
",",
"self",
".",
"_output_size",
")"
] | Smooth scaling using MMX or SSE extensions if available | [
"Smooth",
"scaling",
"using",
"MMX",
"or",
"SSE",
"extensions",
"if",
"available"
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/render.py#L39-L43 | train |
rm-hull/luma.emulator | luma/emulator/render.py | transformer.identity | def identity(self, surface):
"""
Fast scale operation that does not sample the results
"""
return self._pygame.transform.scale(surface, self._output_size) | python | def identity(self, surface):
"""
Fast scale operation that does not sample the results
"""
return self._pygame.transform.scale(surface, self._output_size) | [
"def",
"identity",
"(",
"self",
",",
"surface",
")",
":",
"return",
"self",
".",
"_pygame",
".",
"transform",
".",
"scale",
"(",
"surface",
",",
"self",
".",
"_output_size",
")"
] | Fast scale operation that does not sample the results | [
"Fast",
"scale",
"operation",
"that",
"does",
"not",
"sample",
"the",
"results"
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/render.py#L45-L49 | train |
rm-hull/luma.emulator | luma/emulator/render.py | transformer.led_matrix | def led_matrix(self, surface):
"""
Transforms the input surface into an LED matrix (1 pixel = 1 LED)
"""
scale = self._led_on.get_width()
w, h = self._input_size
pix = self._pygame.PixelArray(surface)
img = self._pygame.Surface((w * scale, h * scale))
for... | python | def led_matrix(self, surface):
"""
Transforms the input surface into an LED matrix (1 pixel = 1 LED)
"""
scale = self._led_on.get_width()
w, h = self._input_size
pix = self._pygame.PixelArray(surface)
img = self._pygame.Surface((w * scale, h * scale))
for... | [
"def",
"led_matrix",
"(",
"self",
",",
"surface",
")",
":",
"scale",
"=",
"self",
".",
"_led_on",
".",
"get_width",
"(",
")",
"w",
",",
"h",
"=",
"self",
".",
"_input_size",
"pix",
"=",
"self",
".",
"_pygame",
".",
"PixelArray",
"(",
"surface",
")",
... | Transforms the input surface into an LED matrix (1 pixel = 1 LED) | [
"Transforms",
"the",
"input",
"surface",
"into",
"an",
"LED",
"matrix",
"(",
"1",
"pixel",
"=",
"1",
"LED",
")"
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/render.py#L51-L65 | train |
rm-hull/luma.emulator | luma/emulator/clut.py | rgb2short | def rgb2short(r, g, b):
"""
Converts RGB values to the nearest equivalent xterm-256 color.
"""
# Using list of snap points, convert RGB value to cube indexes
r, g, b = [len(tuple(s for s in snaps if s < x)) for x in (r, g, b)]
# Simple colorcube transform
return (r * 36) + (g * 6) + b + 16 | python | def rgb2short(r, g, b):
"""
Converts RGB values to the nearest equivalent xterm-256 color.
"""
# Using list of snap points, convert RGB value to cube indexes
r, g, b = [len(tuple(s for s in snaps if s < x)) for x in (r, g, b)]
# Simple colorcube transform
return (r * 36) + (g * 6) + b + 16 | [
"def",
"rgb2short",
"(",
"r",
",",
"g",
",",
"b",
")",
":",
"# Using list of snap points, convert RGB value to cube indexes",
"r",
",",
"g",
",",
"b",
"=",
"[",
"len",
"(",
"tuple",
"(",
"s",
"for",
"s",
"in",
"snaps",
"if",
"s",
"<",
"x",
")",
")",
... | Converts RGB values to the nearest equivalent xterm-256 color. | [
"Converts",
"RGB",
"values",
"to",
"the",
"nearest",
"equivalent",
"xterm",
"-",
"256",
"color",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/clut.py#L14-L22 | train |
rm-hull/luma.emulator | luma/emulator/device.py | emulator.to_surface | def to_surface(self, image, alpha=1.0):
"""
Converts a :py:mod:`PIL.Image` into a :class:`pygame.Surface`,
transforming it according to the ``transform`` and ``scale``
constructor arguments.
"""
assert(0.0 <= alpha <= 1.0)
if alpha < 1.0:
im = image.co... | python | def to_surface(self, image, alpha=1.0):
"""
Converts a :py:mod:`PIL.Image` into a :class:`pygame.Surface`,
transforming it according to the ``transform`` and ``scale``
constructor arguments.
"""
assert(0.0 <= alpha <= 1.0)
if alpha < 1.0:
im = image.co... | [
"def",
"to_surface",
"(",
"self",
",",
"image",
",",
"alpha",
"=",
"1.0",
")",
":",
"assert",
"(",
"0.0",
"<=",
"alpha",
"<=",
"1.0",
")",
"if",
"alpha",
"<",
"1.0",
":",
"im",
"=",
"image",
".",
"convert",
"(",
"\"RGBA\"",
")",
"black",
"=",
"Im... | Converts a :py:mod:`PIL.Image` into a :class:`pygame.Surface`,
transforming it according to the ``transform`` and ``scale``
constructor arguments. | [
"Converts",
"a",
":",
"py",
":",
"mod",
":",
"PIL",
".",
"Image",
"into",
"a",
":",
"class",
":",
"pygame",
".",
"Surface",
"transforming",
"it",
"according",
"to",
"the",
"transform",
"and",
"scale",
"constructor",
"arguments",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L64-L84 | train |
rm-hull/luma.emulator | luma/emulator/device.py | capture.display | def display(self, image):
"""
Takes a :py:mod:`PIL.Image` and dumps it to a numbered PNG file.
"""
assert(image.size == self.size)
self._last_image = image
self._count += 1
filename = self._file_template.format(self._count)
image = self.preprocess(image)
... | python | def display(self, image):
"""
Takes a :py:mod:`PIL.Image` and dumps it to a numbered PNG file.
"""
assert(image.size == self.size)
self._last_image = image
self._count += 1
filename = self._file_template.format(self._count)
image = self.preprocess(image)
... | [
"def",
"display",
"(",
"self",
",",
"image",
")",
":",
"assert",
"(",
"image",
".",
"size",
"==",
"self",
".",
"size",
")",
"self",
".",
"_last_image",
"=",
"image",
"self",
".",
"_count",
"+=",
"1",
"filename",
"=",
"self",
".",
"_file_template",
".... | Takes a :py:mod:`PIL.Image` and dumps it to a numbered PNG file. | [
"Takes",
"a",
":",
"py",
":",
"mod",
":",
"PIL",
".",
"Image",
"and",
"dumps",
"it",
"to",
"a",
"numbered",
"PNG",
"file",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L100-L112 | train |
rm-hull/luma.emulator | luma/emulator/device.py | gifanim.display | def display(self, image):
"""
Takes an image, scales it according to the nominated transform, and
stores it for later building into an animated GIF.
"""
assert(image.size == self.size)
self._last_image = image
image = self.preprocess(image)
surface = self... | python | def display(self, image):
"""
Takes an image, scales it according to the nominated transform, and
stores it for later building into an animated GIF.
"""
assert(image.size == self.size)
self._last_image = image
image = self.preprocess(image)
surface = self... | [
"def",
"display",
"(",
"self",
",",
"image",
")",
":",
"assert",
"(",
"image",
".",
"size",
"==",
"self",
".",
"size",
")",
"self",
".",
"_last_image",
"=",
"image",
"image",
"=",
"self",
".",
"preprocess",
"(",
"image",
")",
"surface",
"=",
"self",
... | Takes an image, scales it according to the nominated transform, and
stores it for later building into an animated GIF. | [
"Takes",
"an",
"image",
"scales",
"it",
"according",
"to",
"the",
"nominated",
"transform",
"and",
"stores",
"it",
"for",
"later",
"building",
"into",
"an",
"animated",
"GIF",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L134-L152 | train |
rm-hull/luma.emulator | luma/emulator/device.py | pygame.display | def display(self, image):
"""
Takes a :py:mod:`PIL.Image` and renders it to a pygame display surface.
"""
assert(image.size == self.size)
self._last_image = image
image = self.preprocess(image)
self._clock.tick(self._fps)
self._pygame.event.pump()
... | python | def display(self, image):
"""
Takes a :py:mod:`PIL.Image` and renders it to a pygame display surface.
"""
assert(image.size == self.size)
self._last_image = image
image = self.preprocess(image)
self._clock.tick(self._fps)
self._pygame.event.pump()
... | [
"def",
"display",
"(",
"self",
",",
"image",
")",
":",
"assert",
"(",
"image",
".",
"size",
"==",
"self",
".",
"size",
")",
"self",
".",
"_last_image",
"=",
"image",
"image",
"=",
"self",
".",
"preprocess",
"(",
"image",
")",
"self",
".",
"_clock",
... | Takes a :py:mod:`PIL.Image` and renders it to a pygame display surface. | [
"Takes",
"a",
":",
"py",
":",
"mod",
":",
"PIL",
".",
"Image",
"and",
"renders",
"it",
"to",
"a",
"pygame",
"display",
"surface",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L193-L212 | train |
rm-hull/luma.emulator | luma/emulator/device.py | asciiart._char_density | def _char_density(self, c, font=ImageFont.load_default()):
"""
Count the number of black pixels in a rendered character.
"""
image = Image.new('1', font.getsize(c), color=255)
draw = ImageDraw.Draw(image)
draw.text((0, 0), c, fill="white", font=font)
return collec... | python | def _char_density(self, c, font=ImageFont.load_default()):
"""
Count the number of black pixels in a rendered character.
"""
image = Image.new('1', font.getsize(c), color=255)
draw = ImageDraw.Draw(image)
draw.text((0, 0), c, fill="white", font=font)
return collec... | [
"def",
"_char_density",
"(",
"self",
",",
"c",
",",
"font",
"=",
"ImageFont",
".",
"load_default",
"(",
")",
")",
":",
"image",
"=",
"Image",
".",
"new",
"(",
"'1'",
",",
"font",
".",
"getsize",
"(",
"c",
")",
",",
"color",
"=",
"255",
")",
"draw... | Count the number of black pixels in a rendered character. | [
"Count",
"the",
"number",
"of",
"black",
"pixels",
"in",
"a",
"rendered",
"character",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L253-L260 | train |
rm-hull/luma.emulator | luma/emulator/device.py | asciiart._generate_art | def _generate_art(self, image, width, height):
"""
Return an iterator that produces the ascii art.
"""
# Characters aren't square, so scale the output by the aspect ratio of a charater
height = int(height * self._char_width / float(self._char_height))
image = image.resize... | python | def _generate_art(self, image, width, height):
"""
Return an iterator that produces the ascii art.
"""
# Characters aren't square, so scale the output by the aspect ratio of a charater
height = int(height * self._char_width / float(self._char_height))
image = image.resize... | [
"def",
"_generate_art",
"(",
"self",
",",
"image",
",",
"width",
",",
"height",
")",
":",
"# Characters aren't square, so scale the output by the aspect ratio of a charater",
"height",
"=",
"int",
"(",
"height",
"*",
"self",
".",
"_char_width",
"/",
"float",
"(",
"s... | Return an iterator that produces the ascii art. | [
"Return",
"an",
"iterator",
"that",
"produces",
"the",
"ascii",
"art",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L262-L273 | train |
rm-hull/luma.emulator | luma/emulator/device.py | asciiart.display | def display(self, image):
"""
Takes a :py:mod:`PIL.Image` and renders it to the current terminal as
ASCII-art.
"""
assert(image.size == self.size)
self._last_image = image
surface = self.to_surface(self.preprocess(image), alpha=self._contrast)
rawbytes = ... | python | def display(self, image):
"""
Takes a :py:mod:`PIL.Image` and renders it to the current terminal as
ASCII-art.
"""
assert(image.size == self.size)
self._last_image = image
surface = self.to_surface(self.preprocess(image), alpha=self._contrast)
rawbytes = ... | [
"def",
"display",
"(",
"self",
",",
"image",
")",
":",
"assert",
"(",
"image",
".",
"size",
"==",
"self",
".",
"size",
")",
"self",
".",
"_last_image",
"=",
"image",
"surface",
"=",
"self",
".",
"to_surface",
"(",
"self",
".",
"preprocess",
"(",
"ima... | Takes a :py:mod:`PIL.Image` and renders it to the current terminal as
ASCII-art. | [
"Takes",
"a",
":",
"py",
":",
"mod",
":",
"PIL",
".",
"Image",
"and",
"renders",
"it",
"to",
"the",
"current",
"terminal",
"as",
"ASCII",
"-",
"art",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L275-L300 | train |
rm-hull/luma.emulator | luma/emulator/device.py | asciiblock._generate_art | def _generate_art(self, image, width, height):
"""
Return an iterator that produces the ascii art.
"""
image = image.resize((width, height), Image.ANTIALIAS).convert("RGB")
pixels = list(image.getdata())
for y in range(0, height - 1, 2):
for x in range(width)... | python | def _generate_art(self, image, width, height):
"""
Return an iterator that produces the ascii art.
"""
image = image.resize((width, height), Image.ANTIALIAS).convert("RGB")
pixels = list(image.getdata())
for y in range(0, height - 1, 2):
for x in range(width)... | [
"def",
"_generate_art",
"(",
"self",
",",
"image",
",",
"width",
",",
"height",
")",
":",
"image",
"=",
"image",
".",
"resize",
"(",
"(",
"width",
",",
"height",
")",
",",
"Image",
".",
"ANTIALIAS",
")",
".",
"convert",
"(",
"\"RGB\"",
")",
"pixels",... | Return an iterator that produces the ascii art. | [
"Return",
"an",
"iterator",
"that",
"produces",
"the",
"ascii",
"art",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L341-L353 | train |
rm-hull/luma.emulator | luma/emulator/device.py | asciiblock._CSI | def _CSI(self, cmd):
"""
Control sequence introducer
"""
sys.stdout.write('\x1b[')
sys.stdout.write(cmd) | python | def _CSI(self, cmd):
"""
Control sequence introducer
"""
sys.stdout.write('\x1b[')
sys.stdout.write(cmd) | [
"def",
"_CSI",
"(",
"self",
",",
"cmd",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"'\\x1b['",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"cmd",
")"
] | Control sequence introducer | [
"Control",
"sequence",
"introducer"
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L355-L360 | train |
rm-hull/luma.emulator | luma/emulator/device.py | asciiblock.display | def display(self, image):
"""
Takes a :py:mod:`PIL.Image` and renders it to the current terminal as
ASCII-blocks.
"""
assert(image.size == self.size)
self._last_image = image
surface = self.to_surface(self.preprocess(image), alpha=self._contrast)
rawbytes... | python | def display(self, image):
"""
Takes a :py:mod:`PIL.Image` and renders it to the current terminal as
ASCII-blocks.
"""
assert(image.size == self.size)
self._last_image = image
surface = self.to_surface(self.preprocess(image), alpha=self._contrast)
rawbytes... | [
"def",
"display",
"(",
"self",
",",
"image",
")",
":",
"assert",
"(",
"image",
".",
"size",
"==",
"self",
".",
"size",
")",
"self",
".",
"_last_image",
"=",
"image",
"surface",
"=",
"self",
".",
"to_surface",
"(",
"self",
".",
"preprocess",
"(",
"ima... | Takes a :py:mod:`PIL.Image` and renders it to the current terminal as
ASCII-blocks. | [
"Takes",
"a",
":",
"py",
":",
"mod",
":",
"PIL",
".",
"Image",
"and",
"renders",
"it",
"to",
"the",
"current",
"terminal",
"as",
"ASCII",
"-",
"blocks",
"."
] | ca3db028b33d17cda9247ea5189873ff0408d013 | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L362-L384 | train |
Auzzy/1846-routes | routes1846/find_best_routes.py | chunk_sequence | def chunk_sequence(sequence, chunk_length):
"""Yield successive n-sized chunks from l."""
for index in range(0, len(sequence), chunk_length):
yield sequence[index:index + chunk_length] | python | def chunk_sequence(sequence, chunk_length):
"""Yield successive n-sized chunks from l."""
for index in range(0, len(sequence), chunk_length):
yield sequence[index:index + chunk_length] | [
"def",
"chunk_sequence",
"(",
"sequence",
",",
"chunk_length",
")",
":",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"sequence",
")",
",",
"chunk_length",
")",
":",
"yield",
"sequence",
"[",
"index",
":",
"index",
"+",
"chunk_length",
"]"
] | Yield successive n-sized chunks from l. | [
"Yield",
"successive",
"n",
"-",
"sized",
"chunks",
"from",
"l",
"."
] | 60c90928e184cbcc09c9fef46c2df07f5f14c2c2 | https://github.com/Auzzy/1846-routes/blob/60c90928e184cbcc09c9fef46c2df07f5f14c2c2/routes1846/find_best_routes.py#L72-L75 | train |
Auzzy/1846-routes | routes1846/find_best_routes.py | _filter_invalid_routes | def _filter_invalid_routes(routes, board, railroad):
"""
Given a collection of routes, returns a new set containing only valid routes. Invalid routes removed:
- contain less than 2 cities, or
- go through Chicago using an impassable exit
- only contain Chicago as a station, but don't use the correct... | python | def _filter_invalid_routes(routes, board, railroad):
"""
Given a collection of routes, returns a new set containing only valid routes. Invalid routes removed:
- contain less than 2 cities, or
- go through Chicago using an impassable exit
- only contain Chicago as a station, but don't use the correct... | [
"def",
"_filter_invalid_routes",
"(",
"routes",
",",
"board",
",",
"railroad",
")",
":",
"chicago_space",
"=",
"board",
".",
"get_space",
"(",
"CHICAGO_CELL",
")",
"chicago_neighbor_cells",
"=",
"[",
"cell",
"for",
"cell",
"in",
"CHICAGO_CELL",
".",
"neighbors",... | Given a collection of routes, returns a new set containing only valid routes. Invalid routes removed:
- contain less than 2 cities, or
- go through Chicago using an impassable exit
- only contain Chicago as a station, but don't use the correct exit path
This fltering after the fact keeps the path findi... | [
"Given",
"a",
"collection",
"of",
"routes",
"returns",
"a",
"new",
"set",
"containing",
"only",
"valid",
"routes",
".",
"Invalid",
"routes",
"removed",
":",
"-",
"contain",
"less",
"than",
"2",
"cities",
"or",
"-",
"go",
"through",
"Chicago",
"using",
"an"... | 60c90928e184cbcc09c9fef46c2df07f5f14c2c2 | https://github.com/Auzzy/1846-routes/blob/60c90928e184cbcc09c9fef46c2df07f5f14c2c2/routes1846/find_best_routes.py#L171-L224 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logfilter.py | find | def find(path,
level=None,
message=None,
time_lower=None, time_upper=None,
case_sensitive=False): # pragma: no cover
"""
Filter log message.
**中文文档**
根据level名称, message中的关键字, 和log的时间的区间, 筛选出相关的日志
"""
if level:
level = level.upper() # level name has... | python | def find(path,
level=None,
message=None,
time_lower=None, time_upper=None,
case_sensitive=False): # pragma: no cover
"""
Filter log message.
**中文文档**
根据level名称, message中的关键字, 和log的时间的区间, 筛选出相关的日志
"""
if level:
level = level.upper() # level name has... | [
"def",
"find",
"(",
"path",
",",
"level",
"=",
"None",
",",
"message",
"=",
"None",
",",
"time_lower",
"=",
"None",
",",
"time_upper",
"=",
"None",
",",
"case_sensitive",
"=",
"False",
")",
":",
"# pragma: no cover",
"if",
"level",
":",
"level",
"=",
"... | Filter log message.
**中文文档**
根据level名称, message中的关键字, 和log的时间的区间, 筛选出相关的日志 | [
"Filter",
"log",
"message",
"."
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logfilter.py#L49-L101 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | get_logger_by_name | def get_logger_by_name(name=None, rand_name=False, charset=Charset.HEX):
"""
Get a logger by name.
:param name: None / str, logger name.
:param rand_name: if True, ``name`` will be ignored, a random name will be used.
"""
if rand_name:
name = rand_str(charset)
logger = logging.getLo... | python | def get_logger_by_name(name=None, rand_name=False, charset=Charset.HEX):
"""
Get a logger by name.
:param name: None / str, logger name.
:param rand_name: if True, ``name`` will be ignored, a random name will be used.
"""
if rand_name:
name = rand_str(charset)
logger = logging.getLo... | [
"def",
"get_logger_by_name",
"(",
"name",
"=",
"None",
",",
"rand_name",
"=",
"False",
",",
"charset",
"=",
"Charset",
".",
"HEX",
")",
":",
"if",
"rand_name",
":",
"name",
"=",
"rand_str",
"(",
"charset",
")",
"logger",
"=",
"logging",
".",
"getLogger",... | Get a logger by name.
:param name: None / str, logger name.
:param rand_name: if True, ``name`` will be ignored, a random name will be used. | [
"Get",
"a",
"logger",
"by",
"name",
"."
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L17-L27 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | BaseLogger.debug | def debug(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.debug``"""
return self.logger.debug(self._indent(msg, indent), **kwargs) | python | def debug(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.debug``"""
return self.logger.debug(self._indent(msg, indent), **kwargs) | [
"def",
"debug",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"debug",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | invoke ``self.logger.debug`` | [
"invoke",
"self",
".",
"logger",
".",
"debug"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L59-L61 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | BaseLogger.info | def info(self, msg, indent=0, **kwargs):
"""invoke ``self.info.debug``"""
return self.logger.info(self._indent(msg, indent), **kwargs) | python | def info(self, msg, indent=0, **kwargs):
"""invoke ``self.info.debug``"""
return self.logger.info(self._indent(msg, indent), **kwargs) | [
"def",
"info",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"info",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | invoke ``self.info.debug`` | [
"invoke",
"self",
".",
"info",
".",
"debug"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L63-L65 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | BaseLogger.warning | def warning(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.warning``"""
return self.logger.warning(self._indent(msg, indent), **kwargs) | python | def warning(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.warning``"""
return self.logger.warning(self._indent(msg, indent), **kwargs) | [
"def",
"warning",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"warning",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | invoke ``self.logger.warning`` | [
"invoke",
"self",
".",
"logger",
".",
"warning"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L67-L69 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | BaseLogger.error | def error(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.error``"""
return self.logger.error(self._indent(msg, indent), **kwargs) | python | def error(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.error``"""
return self.logger.error(self._indent(msg, indent), **kwargs) | [
"def",
"error",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"error",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | invoke ``self.logger.error`` | [
"invoke",
"self",
".",
"logger",
".",
"error"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L71-L73 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | BaseLogger.critical | def critical(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.critical``"""
return self.logger.critical(self._indent(msg, indent), **kwargs) | python | def critical(self, msg, indent=0, **kwargs):
"""invoke ``self.logger.critical``"""
return self.logger.critical(self._indent(msg, indent), **kwargs) | [
"def",
"critical",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"critical",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | invoke ``self.logger.critical`` | [
"invoke",
"self",
".",
"logger",
".",
"critical"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L75-L77 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | BaseLogger.show | def show(self, msg, indent=0, style="", **kwargs):
"""
Print message to console, indent format may apply.
"""
if self.enable_verbose:
new_msg = self.MessageTemplate.with_style.format(
indent=self.tab * indent,
style=style,
msg=m... | python | def show(self, msg, indent=0, style="", **kwargs):
"""
Print message to console, indent format may apply.
"""
if self.enable_verbose:
new_msg = self.MessageTemplate.with_style.format(
indent=self.tab * indent,
style=style,
msg=m... | [
"def",
"show",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"style",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"enable_verbose",
":",
"new_msg",
"=",
"self",
".",
"MessageTemplate",
".",
"with_style",
".",
"format",... | Print message to console, indent format may apply. | [
"Print",
"message",
"to",
"console",
"indent",
"format",
"may",
"apply",
"."
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L79-L89 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | BaseLogger.remove_all_handler | def remove_all_handler(self):
"""
Unlink the file handler association.
"""
for handler in self.logger.handlers[:]:
self.logger.removeHandler(handler)
self._handler_cache.append(handler) | python | def remove_all_handler(self):
"""
Unlink the file handler association.
"""
for handler in self.logger.handlers[:]:
self.logger.removeHandler(handler)
self._handler_cache.append(handler) | [
"def",
"remove_all_handler",
"(",
"self",
")",
":",
"for",
"handler",
"in",
"self",
".",
"logger",
".",
"handlers",
"[",
":",
"]",
":",
"self",
".",
"logger",
".",
"removeHandler",
"(",
"handler",
")",
"self",
".",
"_handler_cache",
".",
"append",
"(",
... | Unlink the file handler association. | [
"Unlink",
"the",
"file",
"handler",
"association",
"."
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L111-L117 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/logger.py | BaseLogger.recover_all_handler | def recover_all_handler(self):
"""
Relink the file handler association you just removed.
"""
for handler in self._handler_cache:
self.logger.addHandler(handler)
self._handler_cache = list() | python | def recover_all_handler(self):
"""
Relink the file handler association you just removed.
"""
for handler in self._handler_cache:
self.logger.addHandler(handler)
self._handler_cache = list() | [
"def",
"recover_all_handler",
"(",
"self",
")",
":",
"for",
"handler",
"in",
"self",
".",
"_handler_cache",
":",
"self",
".",
"logger",
".",
"addHandler",
"(",
"handler",
")",
"self",
".",
"_handler_cache",
"=",
"list",
"(",
")"
] | Relink the file handler association you just removed. | [
"Relink",
"the",
"file",
"handler",
"association",
"you",
"just",
"removed",
"."
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L119-L125 | train |
IceflowRE/unidown | unidown/plugin/link_item.py | LinkItem.from_protobuf | def from_protobuf(cls, proto: LinkItemProto) -> LinkItem:
"""
Constructor from protobuf.
:param proto: protobuf structure
:type proto: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto
:return: the LinkItem
:rtype: ~unidown.plugin.link_item.LinkItem
:raises Va... | python | def from_protobuf(cls, proto: LinkItemProto) -> LinkItem:
"""
Constructor from protobuf.
:param proto: protobuf structure
:type proto: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto
:return: the LinkItem
:rtype: ~unidown.plugin.link_item.LinkItem
:raises Va... | [
"def",
"from_protobuf",
"(",
"cls",
",",
"proto",
":",
"LinkItemProto",
")",
"->",
"LinkItem",
":",
"if",
"proto",
".",
"name",
"==",
"''",
":",
"raise",
"ValueError",
"(",
"\"name of LinkItem does not exist or is empty inside the protobuf.\"",
")",
"return",
"cls",... | Constructor from protobuf.
:param proto: protobuf structure
:type proto: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto
:return: the LinkItem
:rtype: ~unidown.plugin.link_item.LinkItem
:raises ValueError: name of LinkItem does not exist inside the protobuf or is empty | [
"Constructor",
"from",
"protobuf",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/link_item.py#L37-L49 | train |
IceflowRE/unidown | unidown/plugin/link_item.py | LinkItem.to_protobuf | def to_protobuf(self) -> LinkItemProto:
"""
Create protobuf item.
:return: protobuf structure
:rtype: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto
"""
result = LinkItemProto()
result.name = self._name
result.time.CopyFrom(datetime_to_timestamp(sel... | python | def to_protobuf(self) -> LinkItemProto:
"""
Create protobuf item.
:return: protobuf structure
:rtype: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto
"""
result = LinkItemProto()
result.name = self._name
result.time.CopyFrom(datetime_to_timestamp(sel... | [
"def",
"to_protobuf",
"(",
"self",
")",
"->",
"LinkItemProto",
":",
"result",
"=",
"LinkItemProto",
"(",
")",
"result",
".",
"name",
"=",
"self",
".",
"_name",
"result",
".",
"time",
".",
"CopyFrom",
"(",
"datetime_to_timestamp",
"(",
"self",
".",
"_time",... | Create protobuf item.
:return: protobuf structure
:rtype: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto | [
"Create",
"protobuf",
"item",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/link_item.py#L70-L80 | train |
HiPERCAM/hcam_widgets | hcam_widgets/logs.py | Logger.update | def update(self, fname):
"""
Adds a handler to save to a file. Includes debug stuff.
"""
ltfh = FileHandler(fname)
self._log.addHandler(ltfh) | python | def update(self, fname):
"""
Adds a handler to save to a file. Includes debug stuff.
"""
ltfh = FileHandler(fname)
self._log.addHandler(ltfh) | [
"def",
"update",
"(",
"self",
",",
"fname",
")",
":",
"ltfh",
"=",
"FileHandler",
"(",
"fname",
")",
"self",
".",
"_log",
".",
"addHandler",
"(",
"ltfh",
")"
] | Adds a handler to save to a file. Includes debug stuff. | [
"Adds",
"a",
"handler",
"to",
"save",
"to",
"a",
"file",
".",
"Includes",
"debug",
"stuff",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/logs.py#L117-L122 | train |
IceflowRE/unidown | unidown/tools.py | delete_dir_rec | def delete_dir_rec(path: Path):
"""
Delete a folder recursive.
:param path: folder to deleted
:type path: ~pathlib.Path
"""
if not path.exists() or not path.is_dir():
return
for sub in path.iterdir():
if sub.is_dir():
delete_dir_rec(sub)
else:
... | python | def delete_dir_rec(path: Path):
"""
Delete a folder recursive.
:param path: folder to deleted
:type path: ~pathlib.Path
"""
if not path.exists() or not path.is_dir():
return
for sub in path.iterdir():
if sub.is_dir():
delete_dir_rec(sub)
else:
... | [
"def",
"delete_dir_rec",
"(",
"path",
":",
"Path",
")",
":",
"if",
"not",
"path",
".",
"exists",
"(",
")",
"or",
"not",
"path",
".",
"is_dir",
"(",
")",
":",
"return",
"for",
"sub",
"in",
"path",
".",
"iterdir",
"(",
")",
":",
"if",
"sub",
".",
... | Delete a folder recursive.
:param path: folder to deleted
:type path: ~pathlib.Path | [
"Delete",
"a",
"folder",
"recursive",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/tools.py#L13-L27 | train |
IceflowRE/unidown | unidown/tools.py | create_dir_rec | def create_dir_rec(path: Path):
"""
Create a folder recursive.
:param path: path
:type path: ~pathlib.Path
"""
if not path.exists():
Path.mkdir(path, parents=True, exist_ok=True) | python | def create_dir_rec(path: Path):
"""
Create a folder recursive.
:param path: path
:type path: ~pathlib.Path
"""
if not path.exists():
Path.mkdir(path, parents=True, exist_ok=True) | [
"def",
"create_dir_rec",
"(",
"path",
":",
"Path",
")",
":",
"if",
"not",
"path",
".",
"exists",
"(",
")",
":",
"Path",
".",
"mkdir",
"(",
"path",
",",
"parents",
"=",
"True",
",",
"exist_ok",
"=",
"True",
")"
] | Create a folder recursive.
:param path: path
:type path: ~pathlib.Path | [
"Create",
"a",
"folder",
"recursive",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/tools.py#L30-L38 | train |
IceflowRE/unidown | unidown/tools.py | datetime_to_timestamp | def datetime_to_timestamp(time: datetime) -> Timestamp:
"""
Convert datetime to protobuf.timestamp.
:param time: time
:type time: ~datetime.datetime
:return: protobuf.timestamp
:rtype: ~google.protobuf.timestamp_pb2.Timestamp
"""
protime = Timestamp()
protime.FromDatetime(time)
... | python | def datetime_to_timestamp(time: datetime) -> Timestamp:
"""
Convert datetime to protobuf.timestamp.
:param time: time
:type time: ~datetime.datetime
:return: protobuf.timestamp
:rtype: ~google.protobuf.timestamp_pb2.Timestamp
"""
protime = Timestamp()
protime.FromDatetime(time)
... | [
"def",
"datetime_to_timestamp",
"(",
"time",
":",
"datetime",
")",
"->",
"Timestamp",
":",
"protime",
"=",
"Timestamp",
"(",
")",
"protime",
".",
"FromDatetime",
"(",
"time",
")",
"return",
"protime"
] | Convert datetime to protobuf.timestamp.
:param time: time
:type time: ~datetime.datetime
:return: protobuf.timestamp
:rtype: ~google.protobuf.timestamp_pb2.Timestamp | [
"Convert",
"datetime",
"to",
"protobuf",
".",
"timestamp",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/tools.py#L41-L52 | train |
IceflowRE/unidown | unidown/tools.py | print_plugin_list | def print_plugin_list(plugins: Dict[str, pkg_resources.EntryPoint]):
"""
Prints all registered plugins and checks if they can be loaded or not.
:param plugins: plugins
:type plugins: Dict[str, ~pkg_resources.EntryPoint]
"""
for trigger, entry_point in plugins.items():
try:
p... | python | def print_plugin_list(plugins: Dict[str, pkg_resources.EntryPoint]):
"""
Prints all registered plugins and checks if they can be loaded or not.
:param plugins: plugins
:type plugins: Dict[str, ~pkg_resources.EntryPoint]
"""
for trigger, entry_point in plugins.items():
try:
p... | [
"def",
"print_plugin_list",
"(",
"plugins",
":",
"Dict",
"[",
"str",
",",
"pkg_resources",
".",
"EntryPoint",
"]",
")",
":",
"for",
"trigger",
",",
"entry_point",
"in",
"plugins",
".",
"items",
"(",
")",
":",
"try",
":",
"plugin_class",
"=",
"entry_point",... | Prints all registered plugins and checks if they can be loaded or not.
:param plugins: plugins
:type plugins: Dict[str, ~pkg_resources.EntryPoint] | [
"Prints",
"all",
"registered",
"plugins",
"and",
"checks",
"if",
"they",
"can",
"be",
"loaded",
"or",
"not",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/tools.py#L55-L73 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | overlap | def overlap(xl1, yl1, nx1, ny1, xl2, yl2, nx2, ny2):
"""
Determines whether two windows overlap
"""
return (xl2 < xl1+nx1 and xl2+nx2 > xl1 and
yl2 < yl1+ny1 and yl2+ny2 > yl1) | python | def overlap(xl1, yl1, nx1, ny1, xl2, yl2, nx2, ny2):
"""
Determines whether two windows overlap
"""
return (xl2 < xl1+nx1 and xl2+nx2 > xl1 and
yl2 < yl1+ny1 and yl2+ny2 > yl1) | [
"def",
"overlap",
"(",
"xl1",
",",
"yl1",
",",
"nx1",
",",
"ny1",
",",
"xl2",
",",
"yl2",
",",
"nx2",
",",
"ny2",
")",
":",
"return",
"(",
"xl2",
"<",
"xl1",
"+",
"nx1",
"and",
"xl2",
"+",
"nx2",
">",
"xl1",
"and",
"yl2",
"<",
"yl1",
"+",
"... | Determines whether two windows overlap | [
"Determines",
"whether",
"two",
"windows",
"overlap"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L140-L145 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | saveJSON | def saveJSON(g, data, backup=False):
"""
Saves the current setup to disk.
g : hcam_drivers.globals.Container
Container with globals
data : dict
The current setup in JSON compatible dictionary format.
backup : bool
If we are saving a backup on close, don't prompt for filename
"""
... | python | def saveJSON(g, data, backup=False):
"""
Saves the current setup to disk.
g : hcam_drivers.globals.Container
Container with globals
data : dict
The current setup in JSON compatible dictionary format.
backup : bool
If we are saving a backup on close, don't prompt for filename
"""
... | [
"def",
"saveJSON",
"(",
"g",
",",
"data",
",",
"backup",
"=",
"False",
")",
":",
"if",
"not",
"backup",
":",
"fname",
"=",
"filedialog",
".",
"asksaveasfilename",
"(",
"defaultextension",
"=",
"'.json'",
",",
"filetypes",
"=",
"[",
"(",
"'json files'",
"... | Saves the current setup to disk.
g : hcam_drivers.globals.Container
Container with globals
data : dict
The current setup in JSON compatible dictionary format.
backup : bool
If we are saving a backup on close, don't prompt for filename | [
"Saves",
"the",
"current",
"setup",
"to",
"disk",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L195-L227 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | postJSON | def postJSON(g, data):
"""
Posts the current setup to the camera and data servers.
g : hcam_drivers.globals.Container
Container with globals
data : dict
The current setup in JSON compatible dictionary format.
"""
g.clog.debug('Entering postJSON')
# encode data as json
json_dat... | python | def postJSON(g, data):
"""
Posts the current setup to the camera and data servers.
g : hcam_drivers.globals.Container
Container with globals
data : dict
The current setup in JSON compatible dictionary format.
"""
g.clog.debug('Entering postJSON')
# encode data as json
json_dat... | [
"def",
"postJSON",
"(",
"g",
",",
"data",
")",
":",
"g",
".",
"clog",
".",
"debug",
"(",
"'Entering postJSON'",
")",
"# encode data as json",
"json_data",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
".",
"encode",
"(",
"'utf-8'",
")",
"# Send the xml to t... | Posts the current setup to the camera and data servers.
g : hcam_drivers.globals.Container
Container with globals
data : dict
The current setup in JSON compatible dictionary format. | [
"Posts",
"the",
"current",
"setup",
"to",
"the",
"camera",
"and",
"data",
"servers",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L230-L280 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | createJSON | def createJSON(g, full=True):
"""
Create JSON compatible dictionary from current settings
Parameters
----------
g : hcam_drivers.globals.Container
Container with globals
"""
data = dict()
if 'gps_attached' not in g.cpars:
data['gps_attached'] = 1
else:
data['gps... | python | def createJSON(g, full=True):
"""
Create JSON compatible dictionary from current settings
Parameters
----------
g : hcam_drivers.globals.Container
Container with globals
"""
data = dict()
if 'gps_attached' not in g.cpars:
data['gps_attached'] = 1
else:
data['gps... | [
"def",
"createJSON",
"(",
"g",
",",
"full",
"=",
"True",
")",
":",
"data",
"=",
"dict",
"(",
")",
"if",
"'gps_attached'",
"not",
"in",
"g",
".",
"cpars",
":",
"data",
"[",
"'gps_attached'",
"]",
"=",
"1",
"else",
":",
"data",
"[",
"'gps_attached'",
... | Create JSON compatible dictionary from current settings
Parameters
----------
g : hcam_drivers.globals.Container
Container with globals | [
"Create",
"JSON",
"compatible",
"dictionary",
"from",
"current",
"settings"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L283-L311 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | insertFITSHDU | def insertFITSHDU(g):
"""
Uploads a table of TCS data to the servers, which is appended onto a run.
Arguments
---------
g : hcam_drivers.globals.Container
the Container object of application globals
"""
if not g.cpars['hcam_server_on']:
g.clog.warn('insertFITSHDU: servers ar... | python | def insertFITSHDU(g):
"""
Uploads a table of TCS data to the servers, which is appended onto a run.
Arguments
---------
g : hcam_drivers.globals.Container
the Container object of application globals
"""
if not g.cpars['hcam_server_on']:
g.clog.warn('insertFITSHDU: servers ar... | [
"def",
"insertFITSHDU",
"(",
"g",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"g",
".",
"clog",
".",
"warn",
"(",
"'insertFITSHDU: servers are not active'",
")",
"return",
"False",
"run_number",
"=",
"getRunNumber",
"(",
"g",... | Uploads a table of TCS data to the servers, which is appended onto a run.
Arguments
---------
g : hcam_drivers.globals.Container
the Container object of application globals | [
"Uploads",
"a",
"table",
"of",
"TCS",
"data",
"to",
"the",
"servers",
"which",
"is",
"appended",
"onto",
"a",
"run",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L395-L430 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | execCommand | def execCommand(g, command, timeout=10):
"""
Executes a command by sending it to the rack server
Arguments:
g : hcam_drivers.globals.Container
the Container object of application globals
command : (string)
the command (see below)
Possible commands are:
start : s... | python | def execCommand(g, command, timeout=10):
"""
Executes a command by sending it to the rack server
Arguments:
g : hcam_drivers.globals.Container
the Container object of application globals
command : (string)
the command (see below)
Possible commands are:
start : s... | [
"def",
"execCommand",
"(",
"g",
",",
"command",
",",
"timeout",
"=",
"10",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"g",
".",
"clog",
".",
"warn",
"(",
"'execCommand: servers are not active'",
")",
"return",
"False",
"... | Executes a command by sending it to the rack server
Arguments:
g : hcam_drivers.globals.Container
the Container object of application globals
command : (string)
the command (see below)
Possible commands are:
start : starts a run
stop : stops a run
abort ... | [
"Executes",
"a",
"command",
"by",
"sending",
"it",
"to",
"the",
"rack",
"server"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L433-L478 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | isRunActive | def isRunActive(g):
"""
Polls the data server to see if a run is active
"""
if g.cpars['hcam_server_on']:
url = g.cpars['hipercam_server'] + 'summary'
response = urllib.request.urlopen(url, timeout=2)
rs = ReadServer(response.read(), status_msg=True)
if not rs.ok:
... | python | def isRunActive(g):
"""
Polls the data server to see if a run is active
"""
if g.cpars['hcam_server_on']:
url = g.cpars['hipercam_server'] + 'summary'
response = urllib.request.urlopen(url, timeout=2)
rs = ReadServer(response.read(), status_msg=True)
if not rs.ok:
... | [
"def",
"isRunActive",
"(",
"g",
")",
":",
"if",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"url",
"=",
"g",
".",
"cpars",
"[",
"'hipercam_server'",
"]",
"+",
"'summary'",
"response",
"=",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"url",... | Polls the data server to see if a run is active | [
"Polls",
"the",
"data",
"server",
"to",
"see",
"if",
"a",
"run",
"is",
"active"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L481-L498 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | getFrameNumber | def getFrameNumber(g):
"""
Polls the data server to find the current frame number.
Throws an exceotion if it cannot determine it.
"""
if not g.cpars['hcam_server_on']:
raise DriverError('getRunNumber error: servers are not active')
url = g.cpars['hipercam_server'] + 'status/DET.FRAM2.NO... | python | def getFrameNumber(g):
"""
Polls the data server to find the current frame number.
Throws an exceotion if it cannot determine it.
"""
if not g.cpars['hcam_server_on']:
raise DriverError('getRunNumber error: servers are not active')
url = g.cpars['hipercam_server'] + 'status/DET.FRAM2.NO... | [
"def",
"getFrameNumber",
"(",
"g",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"raise",
"DriverError",
"(",
"'getRunNumber error: servers are not active'",
")",
"url",
"=",
"g",
".",
"cpars",
"[",
"'hipercam_server'",
"]",
"+",... | Polls the data server to find the current frame number.
Throws an exceotion if it cannot determine it. | [
"Polls",
"the",
"data",
"server",
"to",
"find",
"the",
"current",
"frame",
"number",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L535-L554 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | getRunNumber | def getRunNumber(g):
"""
Polls the data server to find the current run number. Throws
exceptions if it can't determine it.
"""
if not g.cpars['hcam_server_on']:
raise DriverError('getRunNumber error: servers are not active')
url = g.cpars['hipercam_server'] + 'summary'
response = url... | python | def getRunNumber(g):
"""
Polls the data server to find the current run number. Throws
exceptions if it can't determine it.
"""
if not g.cpars['hcam_server_on']:
raise DriverError('getRunNumber error: servers are not active')
url = g.cpars['hipercam_server'] + 'summary'
response = url... | [
"def",
"getRunNumber",
"(",
"g",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"raise",
"DriverError",
"(",
"'getRunNumber error: servers are not active'",
")",
"url",
"=",
"g",
".",
"cpars",
"[",
"'hipercam_server'",
"]",
"+",
... | Polls the data server to find the current run number. Throws
exceptions if it can't determine it. | [
"Polls",
"the",
"data",
"server",
"to",
"find",
"the",
"current",
"run",
"number",
".",
"Throws",
"exceptions",
"if",
"it",
"can",
"t",
"determine",
"it",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L557-L570 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | checkSimbad | def checkSimbad(g, target, maxobj=5, timeout=5):
"""
Sends off a request to Simbad to check whether a target is recognised.
Returns with a list of results, or raises an exception if it times out
"""
url = 'http://simbad.u-strasbg.fr/simbad/sim-script'
q = 'set limit ' + str(maxobj) + \
'... | python | def checkSimbad(g, target, maxobj=5, timeout=5):
"""
Sends off a request to Simbad to check whether a target is recognised.
Returns with a list of results, or raises an exception if it times out
"""
url = 'http://simbad.u-strasbg.fr/simbad/sim-script'
q = 'set limit ' + str(maxobj) + \
'... | [
"def",
"checkSimbad",
"(",
"g",
",",
"target",
",",
"maxobj",
"=",
"5",
",",
"timeout",
"=",
"5",
")",
":",
"url",
"=",
"'http://simbad.u-strasbg.fr/simbad/sim-script'",
"q",
"=",
"'set limit '",
"+",
"str",
"(",
"maxobj",
")",
"+",
"'\\nformat object form1 \"... | Sends off a request to Simbad to check whether a target is recognised.
Returns with a list of results, or raises an exception if it times out | [
"Sends",
"off",
"a",
"request",
"to",
"Simbad",
"to",
"check",
"whether",
"a",
"target",
"is",
"recognised",
".",
"Returns",
"with",
"a",
"list",
"of",
"results",
"or",
"raises",
"an",
"exception",
"if",
"it",
"times",
"out"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L573-L603 | train |
HiPERCAM/hcam_widgets | hcam_widgets/misc.py | FifoThread.run | def run(self):
"""
Version of run that traps Exceptions and stores
them in the fifo
"""
try:
threading.Thread.run(self)
except Exception:
t, v, tb = sys.exc_info()
error = traceback.format_exception_only(t, v)[0][:-1]
tback ... | python | def run(self):
"""
Version of run that traps Exceptions and stores
them in the fifo
"""
try:
threading.Thread.run(self)
except Exception:
t, v, tb = sys.exc_info()
error = traceback.format_exception_only(t, v)[0][:-1]
tback ... | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"threading",
".",
"Thread",
".",
"run",
"(",
"self",
")",
"except",
"Exception",
":",
"t",
",",
"v",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"error",
"=",
"traceback",
".",
"format_exceptio... | Version of run that traps Exceptions and stores
them in the fifo | [
"Version",
"of",
"run",
"that",
"traps",
"Exceptions",
"and",
"stores",
"them",
"in",
"the",
"fifo"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L618-L630 | train |
MacHu-GWU/loggerFactory-project | loggerFactory/rand_str.py | rand_str | def rand_str(charset, length=32):
"""
Generate random string.
"""
return "".join([random.choice(charset) for _ in range(length)]) | python | def rand_str(charset, length=32):
"""
Generate random string.
"""
return "".join([random.choice(charset) for _ in range(length)]) | [
"def",
"rand_str",
"(",
"charset",
",",
"length",
"=",
"32",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"[",
"random",
".",
"choice",
"(",
"charset",
")",
"for",
"_",
"in",
"range",
"(",
"length",
")",
"]",
")"
] | Generate random string. | [
"Generate",
"random",
"string",
"."
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/rand_str.py#L16-L20 | train |
HiPERCAM/hcam_widgets | hcam_widgets/tkutils.py | get_root | def get_root(w):
"""
Simple method to access root for a widget
"""
next_level = w
while next_level.master:
next_level = next_level.master
return next_level | python | def get_root(w):
"""
Simple method to access root for a widget
"""
next_level = w
while next_level.master:
next_level = next_level.master
return next_level | [
"def",
"get_root",
"(",
"w",
")",
":",
"next_level",
"=",
"w",
"while",
"next_level",
".",
"master",
":",
"next_level",
"=",
"next_level",
".",
"master",
"return",
"next_level"
] | Simple method to access root for a widget | [
"Simple",
"method",
"to",
"access",
"root",
"for",
"a",
"widget"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/tkutils.py#L18-L25 | train |
HiPERCAM/hcam_widgets | hcam_widgets/tkutils.py | addStyle | def addStyle(w):
"""
Styles the GUI: global fonts and colours.
Parameters
----------
w : tkinter.tk
widget element to style
"""
# access global container in root widget
root = get_root(w)
g = root.globals
fsize = g.cpars['font_size']
family = g.cpars['font_family']
... | python | def addStyle(w):
"""
Styles the GUI: global fonts and colours.
Parameters
----------
w : tkinter.tk
widget element to style
"""
# access global container in root widget
root = get_root(w)
g = root.globals
fsize = g.cpars['font_size']
family = g.cpars['font_family']
... | [
"def",
"addStyle",
"(",
"w",
")",
":",
"# access global container in root widget",
"root",
"=",
"get_root",
"(",
"w",
")",
"g",
"=",
"root",
".",
"globals",
"fsize",
"=",
"g",
".",
"cpars",
"[",
"'font_size'",
"]",
"family",
"=",
"g",
".",
"cpars",
"[",
... | Styles the GUI: global fonts and colours.
Parameters
----------
w : tkinter.tk
widget element to style | [
"Styles",
"the",
"GUI",
":",
"global",
"fonts",
"and",
"colours",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/tkutils.py#L28-L65 | train |
IceflowRE/unidown | unidown/core/manager.py | init | def init(main_dir: Path, logfile_path: Path, log_level: str):
"""
Initialize the _downloader. TODO.
:param main_dir: main directory
:type main_dir: ~pathlib.Path
:param logfile_path: logfile path
:type logfile_path: ~pathlib.Path
:param log_level: logging level
:type log_level: str
... | python | def init(main_dir: Path, logfile_path: Path, log_level: str):
"""
Initialize the _downloader. TODO.
:param main_dir: main directory
:type main_dir: ~pathlib.Path
:param logfile_path: logfile path
:type logfile_path: ~pathlib.Path
:param log_level: logging level
:type log_level: str
... | [
"def",
"init",
"(",
"main_dir",
":",
"Path",
",",
"logfile_path",
":",
"Path",
",",
"log_level",
":",
"str",
")",
":",
"dynamic_data",
".",
"reset",
"(",
")",
"dynamic_data",
".",
"init_dirs",
"(",
"main_dir",
",",
"logfile_path",
")",
"dynamic_data",
".",... | Initialize the _downloader. TODO.
:param main_dir: main directory
:type main_dir: ~pathlib.Path
:param logfile_path: logfile path
:type logfile_path: ~pathlib.Path
:param log_level: logging level
:type log_level: str | [
"Initialize",
"the",
"_downloader",
".",
"TODO",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/manager.py#L17-L56 | train |
IceflowRE/unidown | unidown/core/manager.py | download_from_plugin | def download_from_plugin(plugin: APlugin):
"""
Download routine.
1. get newest update time
2. load savestate
3. compare last update time with savestate time
4. get download links
5. compare with savestate
6. download new/updated data
7. check downloads
8. update savestate
9.... | python | def download_from_plugin(plugin: APlugin):
"""
Download routine.
1. get newest update time
2. load savestate
3. compare last update time with savestate time
4. get download links
5. compare with savestate
6. download new/updated data
7. check downloads
8. update savestate
9.... | [
"def",
"download_from_plugin",
"(",
"plugin",
":",
"APlugin",
")",
":",
"# get last update date",
"plugin",
".",
"log",
".",
"info",
"(",
"'Get last update'",
")",
"plugin",
".",
"update_last_update",
"(",
")",
"# load old save state",
"save_state",
"=",
"plugin",
... | Download routine.
1. get newest update time
2. load savestate
3. compare last update time with savestate time
4. get download links
5. compare with savestate
6. download new/updated data
7. check downloads
8. update savestate
9. write new savestate
:param plugin: plugin
:ty... | [
"Download",
"routine",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/manager.py#L66-L111 | train |
IceflowRE/unidown | unidown/core/manager.py | run | def run(plugin_name: str, options: List[str] = None) -> PluginState:
"""
Run a plugin so use the download routine and clean up after.
:param plugin_name: name of plugin
:type plugin_name: str
:param options: parameters which will be send to the plugin initialization
:type options: List[str]
... | python | def run(plugin_name: str, options: List[str] = None) -> PluginState:
"""
Run a plugin so use the download routine and clean up after.
:param plugin_name: name of plugin
:type plugin_name: str
:param options: parameters which will be send to the plugin initialization
:type options: List[str]
... | [
"def",
"run",
"(",
"plugin_name",
":",
"str",
",",
"options",
":",
"List",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"PluginState",
":",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"[",
"]",
"if",
"plugin_name",
"not",
"in",
"dynamic_data",
".... | Run a plugin so use the download routine and clean up after.
:param plugin_name: name of plugin
:type plugin_name: str
:param options: parameters which will be send to the plugin initialization
:type options: List[str]
:return: success
:rtype: ~unidown.plugin.plugin_state.PluginState | [
"Run",
"a",
"plugin",
"so",
"use",
"the",
"download",
"routine",
"and",
"clean",
"up",
"after",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/manager.py#L114-L160 | train |
IceflowRE/unidown | unidown/core/manager.py | check_update | def check_update():
"""
Check for app updates and print/log them.
"""
logging.info('Check for app updates.')
try:
update = updater.check_for_app_updates()
except Exception:
logging.exception('Check for updates failed.')
return
if update:
print("!!! UPDATE AVAI... | python | def check_update():
"""
Check for app updates and print/log them.
"""
logging.info('Check for app updates.')
try:
update = updater.check_for_app_updates()
except Exception:
logging.exception('Check for updates failed.')
return
if update:
print("!!! UPDATE AVAI... | [
"def",
"check_update",
"(",
")",
":",
"logging",
".",
"info",
"(",
"'Check for app updates.'",
")",
"try",
":",
"update",
"=",
"updater",
".",
"check_for_app_updates",
"(",
")",
"except",
"Exception",
":",
"logging",
".",
"exception",
"(",
"'Check for updates fa... | Check for app updates and print/log them. | [
"Check",
"for",
"app",
"updates",
"and",
"print",
"/",
"log",
"them",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/manager.py#L163-L178 | train |
IceflowRE/unidown | unidown/core/updater.py | get_newest_app_version | def get_newest_app_version() -> Version:
"""
Download the version tag from remote.
:return: version from remote
:rtype: ~packaging.version.Version
"""
with urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where()) as p_man:
pypi_json = p_man.urlopen('GET', static_data.PYP... | python | def get_newest_app_version() -> Version:
"""
Download the version tag from remote.
:return: version from remote
:rtype: ~packaging.version.Version
"""
with urllib3.PoolManager(cert_reqs='CERT_REQUIRED', ca_certs=certifi.where()) as p_man:
pypi_json = p_man.urlopen('GET', static_data.PYP... | [
"def",
"get_newest_app_version",
"(",
")",
"->",
"Version",
":",
"with",
"urllib3",
".",
"PoolManager",
"(",
"cert_reqs",
"=",
"'CERT_REQUIRED'",
",",
"ca_certs",
"=",
"certifi",
".",
"where",
"(",
")",
")",
"as",
"p_man",
":",
"pypi_json",
"=",
"p_man",
"... | Download the version tag from remote.
:return: version from remote
:rtype: ~packaging.version.Version | [
"Download",
"the",
"version",
"tag",
"from",
"remote",
"."
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/updater.py#L13-L28 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | InstPars.setupNodding | def setupNodding(self):
"""
Setup Nodding for GTC
"""
g = get_root(self).globals
if not self.nod():
# re-enable clear mode box if not drift
if not self.isDrift():
self.clear.enable()
# clear existing nod pattern
se... | python | def setupNodding(self):
"""
Setup Nodding for GTC
"""
g = get_root(self).globals
if not self.nod():
# re-enable clear mode box if not drift
if not self.isDrift():
self.clear.enable()
# clear existing nod pattern
se... | [
"def",
"setupNodding",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"if",
"not",
"self",
".",
"nod",
"(",
")",
":",
"# re-enable clear mode box if not drift",
"if",
"not",
"self",
".",
"isDrift",
"(",
")",
":",
"self",
... | Setup Nodding for GTC | [
"Setup",
"Nodding",
"for",
"GTC"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L286-L357 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | InstPars.dumpJSON | def dumpJSON(self):
"""
Encodes current parameters to JSON compatible dictionary
"""
numexp = self.number.get()
expTime, _, _, _, _ = self.timing()
if numexp == 0:
numexp = -1
data = dict(
numexp=self.number.value(),
app=self.a... | python | def dumpJSON(self):
"""
Encodes current parameters to JSON compatible dictionary
"""
numexp = self.number.get()
expTime, _, _, _, _ = self.timing()
if numexp == 0:
numexp = -1
data = dict(
numexp=self.number.value(),
app=self.a... | [
"def",
"dumpJSON",
"(",
"self",
")",
":",
"numexp",
"=",
"self",
".",
"number",
".",
"get",
"(",
")",
"expTime",
",",
"_",
",",
"_",
",",
"_",
",",
"_",
"=",
"self",
".",
"timing",
"(",
")",
"if",
"numexp",
"==",
"0",
":",
"numexp",
"=",
"-",... | Encodes current parameters to JSON compatible dictionary | [
"Encodes",
"current",
"parameters",
"to",
"JSON",
"compatible",
"dictionary"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L404-L464 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | InstPars.loadJSON | def loadJSON(self, json_string):
"""
Loads in an application saved in JSON format.
"""
g = get_root(self).globals
data = json.loads(json_string)['appdata']
# first set the parameters which change regardless of mode
# number of exposures
numexp = data.get('... | python | def loadJSON(self, json_string):
"""
Loads in an application saved in JSON format.
"""
g = get_root(self).globals
data = json.loads(json_string)['appdata']
# first set the parameters which change regardless of mode
# number of exposures
numexp = data.get('... | [
"def",
"loadJSON",
"(",
"self",
",",
"json_string",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"data",
"=",
"json",
".",
"loads",
"(",
"json_string",
")",
"[",
"'appdata'",
"]",
"# first set the parameters which change regardless of mode",... | Loads in an application saved in JSON format. | [
"Loads",
"in",
"an",
"application",
"saved",
"in",
"JSON",
"format",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L466-L571 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | InstPars.check | def check(self, *args):
"""
Callback to check validity of instrument parameters.
Performs the following tasks:
- spots and flags overlapping windows or null window parameters
- flags windows with invalid dimensions given the binning parameter
- sets the corre... | python | def check(self, *args):
"""
Callback to check validity of instrument parameters.
Performs the following tasks:
- spots and flags overlapping windows or null window parameters
- flags windows with invalid dimensions given the binning parameter
- sets the corre... | [
"def",
"check",
"(",
"self",
",",
"*",
"args",
")",
":",
"status",
"=",
"True",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"# clear errors on binning (may be set later if FF)",
"xbinw",
",",
"ybinw",
"=",
"self",
".",
"wframe",
".",
"xbin",
",... | Callback to check validity of instrument parameters.
Performs the following tasks:
- spots and flags overlapping windows or null window parameters
- flags windows with invalid dimensions given the binning parameter
- sets the correct number of enabled windows
- d... | [
"Callback",
"to",
"check",
"validity",
"of",
"instrument",
"parameters",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L573-L717 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | InstPars.freeze | def freeze(self):
"""
Freeze all settings so they cannot be altered
"""
self.app.disable()
self.clear.disable()
self.nod.disable()
self.led.disable()
self.dummy.disable()
self.readSpeed.disable()
self.expose.disable()
self.number.di... | python | def freeze(self):
"""
Freeze all settings so they cannot be altered
"""
self.app.disable()
self.clear.disable()
self.nod.disable()
self.led.disable()
self.dummy.disable()
self.readSpeed.disable()
self.expose.disable()
self.number.di... | [
"def",
"freeze",
"(",
"self",
")",
":",
"self",
".",
"app",
".",
"disable",
"(",
")",
"self",
".",
"clear",
".",
"disable",
"(",
")",
"self",
".",
"nod",
".",
"disable",
"(",
")",
"self",
".",
"led",
".",
"disable",
"(",
")",
"self",
".",
"dumm... | Freeze all settings so they cannot be altered | [
"Freeze",
"all",
"settings",
"so",
"they",
"cannot",
"be",
"altered"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L719-L733 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | InstPars.unfreeze | def unfreeze(self):
"""
Reverse of freeze
"""
self.app.enable()
self.clear.enable()
self.nod.enable()
self.led.enable()
self.dummy.enable()
self.readSpeed.enable()
self.expose.enable()
self.number.enable()
self.wframe.enable... | python | def unfreeze(self):
"""
Reverse of freeze
"""
self.app.enable()
self.clear.enable()
self.nod.enable()
self.led.enable()
self.dummy.enable()
self.readSpeed.enable()
self.expose.enable()
self.number.enable()
self.wframe.enable... | [
"def",
"unfreeze",
"(",
"self",
")",
":",
"self",
".",
"app",
".",
"enable",
"(",
")",
"self",
".",
"clear",
".",
"enable",
"(",
")",
"self",
".",
"nod",
".",
"enable",
"(",
")",
"self",
".",
"led",
".",
"enable",
"(",
")",
"self",
".",
"dummy"... | Reverse of freeze | [
"Reverse",
"of",
"freeze"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L735-L749 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | InstPars.getRtplotWins | def getRtplotWins(self):
""""
Returns a string suitable to sending off to rtplot when
it asks for window parameters. Returns null string '' if
the windows are not OK. This operates on the basis of
trying to send something back, even if it might not be
OK as a window setup... | python | def getRtplotWins(self):
""""
Returns a string suitable to sending off to rtplot when
it asks for window parameters. Returns null string '' if
the windows are not OK. This operates on the basis of
trying to send something back, even if it might not be
OK as a window setup... | [
"def",
"getRtplotWins",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"isFF",
"(",
")",
":",
"return",
"'fullframe\\r\\n'",
"elif",
"self",
".",
"isDrift",
"(",
")",
":",
"xbin",
"=",
"self",
".",
"wframe",
".",
"xbin",
".",
"value",
"(",
"... | Returns a string suitable to sending off to rtplot when
it asks for window parameters. Returns null string '' if
the windows are not OK. This operates on the basis of
trying to send something back, even if it might not be
OK as a window setup. Note that we have to take care
here ... | [
"Returns",
"a",
"string",
"suitable",
"to",
"sending",
"off",
"to",
"rtplot",
"when",
"it",
"asks",
"for",
"window",
"parameters",
".",
"Returns",
"null",
"string",
"if",
"the",
"windows",
"are",
"not",
"OK",
".",
"This",
"operates",
"on",
"the",
"basis",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L751-L797 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | InstPars.timing | def timing(self):
"""
Estimates timing information for the current setup. You should
run a check on the instrument parameters before calling this.
Returns: (expTime, deadTime, cycleTime, dutyCycle)
expTime : exposure time per frame (seconds)
deadTime : dead time per ... | python | def timing(self):
"""
Estimates timing information for the current setup. You should
run a check on the instrument parameters before calling this.
Returns: (expTime, deadTime, cycleTime, dutyCycle)
expTime : exposure time per frame (seconds)
deadTime : dead time per ... | [
"def",
"timing",
"(",
"self",
")",
":",
"# drift mode y/n?",
"isDriftMode",
"=",
"self",
".",
"isDrift",
"(",
")",
"# FF y/n?",
"isFF",
"=",
"self",
".",
"isFF",
"(",
")",
"# Set the readout speed",
"readSpeed",
"=",
"self",
".",
"readSpeed",
"(",
")",
"if... | Estimates timing information for the current setup. You should
run a check on the instrument parameters before calling this.
Returns: (expTime, deadTime, cycleTime, dutyCycle)
expTime : exposure time per frame (seconds)
deadTime : dead time per frame (seconds)
cycleTime : sa... | [
"Estimates",
"timing",
"information",
"for",
"the",
"current",
"setup",
".",
"You",
"should",
"run",
"a",
"check",
"on",
"the",
"instrument",
"parameters",
"before",
"calling",
"this",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L799-L1009 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | RunPars.loadJSON | def loadJSON(self, json_string):
"""
Sets the values of the run parameters given an JSON string
"""
g = get_root(self).globals
user = json.loads(json_string)['user']
def setField(widget, field):
val = user.get(field)
if val is not None:
... | python | def loadJSON(self, json_string):
"""
Sets the values of the run parameters given an JSON string
"""
g = get_root(self).globals
user = json.loads(json_string)['user']
def setField(widget, field):
val = user.get(field)
if val is not None:
... | [
"def",
"loadJSON",
"(",
"self",
",",
"json_string",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"user",
"=",
"json",
".",
"loads",
"(",
"json_string",
")",
"[",
"'user'",
"]",
"def",
"setField",
"(",
"widget",
",",
"field",
")",... | Sets the values of the run parameters given an JSON string | [
"Sets",
"the",
"values",
"of",
"the",
"run",
"parameters",
"given",
"an",
"JSON",
"string"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1075-L1094 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | RunPars.dumpJSON | def dumpJSON(self):
"""
Encodes current parameters to JSON compatible dictionary
"""
g = get_root(self).globals
dtype = g.observe.rtype()
if dtype == 'bias':
target = 'BIAS'
elif dtype == 'flat':
target = 'FLAT'
elif dtype == 'dark'... | python | def dumpJSON(self):
"""
Encodes current parameters to JSON compatible dictionary
"""
g = get_root(self).globals
dtype = g.observe.rtype()
if dtype == 'bias':
target = 'BIAS'
elif dtype == 'flat':
target = 'FLAT'
elif dtype == 'dark'... | [
"def",
"dumpJSON",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"dtype",
"=",
"g",
".",
"observe",
".",
"rtype",
"(",
")",
"if",
"dtype",
"==",
"'bias'",
":",
"target",
"=",
"'BIAS'",
"elif",
"dtype",
"==",
"'flat'... | Encodes current parameters to JSON compatible dictionary | [
"Encodes",
"current",
"parameters",
"to",
"JSON",
"compatible",
"dictionary"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1096-L1120 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | RunPars.check | def check(self, *args):
"""
Checks the validity of the run parameters. Returns
flag (True = OK), and a message which indicates the
nature of the problem if the flag is False.
"""
ok = True
msg = ''
g = get_root(self).globals
dtype = g.observe.rtyp... | python | def check(self, *args):
"""
Checks the validity of the run parameters. Returns
flag (True = OK), and a message which indicates the
nature of the problem if the flag is False.
"""
ok = True
msg = ''
g = get_root(self).globals
dtype = g.observe.rtyp... | [
"def",
"check",
"(",
"self",
",",
"*",
"args",
")",
":",
"ok",
"=",
"True",
"msg",
"=",
"''",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"dtype",
"=",
"g",
".",
"observe",
".",
"rtype",
"(",
")",
"expert",
"=",
"g",
".",
"cpars",
... | Checks the validity of the run parameters. Returns
flag (True = OK), and a message which indicates the
nature of the problem if the flag is False. | [
"Checks",
"the",
"validity",
"of",
"the",
"run",
"parameters",
".",
"Returns",
"flag",
"(",
"True",
"=",
"OK",
")",
"and",
"a",
"message",
"which",
"indicates",
"the",
"nature",
"of",
"the",
"problem",
"if",
"the",
"flag",
"is",
"False",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1122-L1181 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | RunPars.freeze | def freeze(self):
"""
Freeze all settings so that they can't be altered
"""
self.target.disable()
self.filter.configure(state='disable')
self.prog_ob.configure(state='disable')
self.pi.configure(state='disable')
self.observers.configure(state='disable')
... | python | def freeze(self):
"""
Freeze all settings so that they can't be altered
"""
self.target.disable()
self.filter.configure(state='disable')
self.prog_ob.configure(state='disable')
self.pi.configure(state='disable')
self.observers.configure(state='disable')
... | [
"def",
"freeze",
"(",
"self",
")",
":",
"self",
".",
"target",
".",
"disable",
"(",
")",
"self",
".",
"filter",
".",
"configure",
"(",
"state",
"=",
"'disable'",
")",
"self",
".",
"prog_ob",
".",
"configure",
"(",
"state",
"=",
"'disable'",
")",
"sel... | Freeze all settings so that they can't be altered | [
"Freeze",
"all",
"settings",
"so",
"that",
"they",
"can",
"t",
"be",
"altered"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1195-L1204 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | RunPars.unfreeze | def unfreeze(self):
"""
Unfreeze all settings so that they can be altered
"""
g = get_root(self).globals
self.filter.configure(state='normal')
dtype = g.observe.rtype()
if dtype == 'data caution' or dtype == 'data' or dtype == 'technical':
self.prog_ob... | python | def unfreeze(self):
"""
Unfreeze all settings so that they can be altered
"""
g = get_root(self).globals
self.filter.configure(state='normal')
dtype = g.observe.rtype()
if dtype == 'data caution' or dtype == 'data' or dtype == 'technical':
self.prog_ob... | [
"def",
"unfreeze",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"self",
".",
"filter",
".",
"configure",
"(",
"state",
"=",
"'normal'",
")",
"dtype",
"=",
"g",
".",
"observe",
".",
"rtype",
"(",
")",
"if",
"dtype",... | Unfreeze all settings so that they can be altered | [
"Unfreeze",
"all",
"settings",
"so",
"that",
"they",
"can",
"be",
"altered"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1206-L1218 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | CountsFrame.checkUpdate | def checkUpdate(self, *args):
"""
Updates values after first checking instrument parameters are OK.
This is not integrated within update to prevent ifinite recursion
since update gets called from ipars.
"""
g = get_root(self).globals
if not self.check():
... | python | def checkUpdate(self, *args):
"""
Updates values after first checking instrument parameters are OK.
This is not integrated within update to prevent ifinite recursion
since update gets called from ipars.
"""
g = get_root(self).globals
if not self.check():
... | [
"def",
"checkUpdate",
"(",
"self",
",",
"*",
"args",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"if",
"not",
"self",
".",
"check",
"(",
")",
":",
"g",
".",
"clog",
".",
"warn",
"(",
"'Current observing parameters are not valid.'",
... | Updates values after first checking instrument parameters are OK.
This is not integrated within update to prevent ifinite recursion
since update gets called from ipars. | [
"Updates",
"values",
"after",
"first",
"checking",
"instrument",
"parameters",
"are",
"OK",
".",
"This",
"is",
"not",
"integrated",
"within",
"update",
"to",
"prevent",
"ifinite",
"recursion",
"since",
"update",
"gets",
"called",
"from",
"ipars",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1314-L1327 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | CountsFrame.check | def check(self):
"""
Checks values
"""
status = True
g = get_root(self).globals
if self.mag.ok():
self.mag.config(bg=g.COL['main'])
else:
self.mag.config(bg=g.COL['warn'])
status = False
if self.airmass.ok():
... | python | def check(self):
"""
Checks values
"""
status = True
g = get_root(self).globals
if self.mag.ok():
self.mag.config(bg=g.COL['main'])
else:
self.mag.config(bg=g.COL['warn'])
status = False
if self.airmass.ok():
... | [
"def",
"check",
"(",
"self",
")",
":",
"status",
"=",
"True",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"if",
"self",
".",
"mag",
".",
"ok",
"(",
")",
":",
"self",
".",
"mag",
".",
"config",
"(",
"bg",
"=",
"g",
".",
"COL",
"[",... | Checks values | [
"Checks",
"values"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1329-L1353 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | CountsFrame.update | def update(self, *args):
"""
Updates values. You should run a check on the instrument and
target parameters before calling this.
"""
g = get_root(self).globals
expTime, deadTime, cycleTime, dutyCycle, frameRate = g.ipars.timing()
total, peak, peakSat, peakWarn, s... | python | def update(self, *args):
"""
Updates values. You should run a check on the instrument and
target parameters before calling this.
"""
g = get_root(self).globals
expTime, deadTime, cycleTime, dutyCycle, frameRate = g.ipars.timing()
total, peak, peakSat, peakWarn, s... | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"expTime",
",",
"deadTime",
",",
"cycleTime",
",",
"dutyCycle",
",",
"frameRate",
"=",
"g",
".",
"ipars",
".",
"timing",
"(",
")",
"to... | Updates values. You should run a check on the instrument and
target parameters before calling this. | [
"Updates",
"values",
".",
"You",
"should",
"run",
"a",
"check",
"on",
"the",
"instrument",
"and",
"target",
"parameters",
"before",
"calling",
"this",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1355-L1407 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | CountsFrame.counts | def counts(self, expTime, cycleTime, ap_scale=1.6, ndiv=5):
"""
Computes counts per pixel, total counts, sky counts
etc given current magnitude, seeing etc. You should
run a check on the instrument parameters before calling
this.
expTime : exposure time per frame (seco... | python | def counts(self, expTime, cycleTime, ap_scale=1.6, ndiv=5):
"""
Computes counts per pixel, total counts, sky counts
etc given current magnitude, seeing etc. You should
run a check on the instrument parameters before calling
this.
expTime : exposure time per frame (seco... | [
"def",
"counts",
"(",
"self",
",",
"expTime",
",",
"cycleTime",
",",
"ap_scale",
"=",
"1.6",
",",
"ndiv",
"=",
"5",
")",
":",
"# code directly translated from Java equivalent.",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"# Set the readout speed",
... | Computes counts per pixel, total counts, sky counts
etc given current magnitude, seeing etc. You should
run a check on the instrument parameters before calling
this.
expTime : exposure time per frame (seconds)
cycleTime : sampling, cadence (seconds)
ap_scale : apertur... | [
"Computes",
"counts",
"per",
"pixel",
"total",
"counts",
"sky",
"counts",
"etc",
"given",
"current",
"magnitude",
"seeing",
"etc",
".",
"You",
"should",
"run",
"a",
"check",
"on",
"the",
"instrument",
"parameters",
"before",
"calling",
"this",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1409-L1515 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | Start.disable | def disable(self):
"""
Disable the button, if in non-expert mode.
"""
w.ActButton.disable(self)
g = get_root(self).globals
if self._expert:
self.config(bg=g.COL['start'])
else:
self.config(bg=g.COL['startD']) | python | def disable(self):
"""
Disable the button, if in non-expert mode.
"""
w.ActButton.disable(self)
g = get_root(self).globals
if self._expert:
self.config(bg=g.COL['start'])
else:
self.config(bg=g.COL['startD']) | [
"def",
"disable",
"(",
"self",
")",
":",
"w",
".",
"ActButton",
".",
"disable",
"(",
"self",
")",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"if",
"self",
".",
"_expert",
":",
"self",
".",
"config",
"(",
"bg",
"=",
"g",
".",
"COL",
... | Disable the button, if in non-expert mode. | [
"Disable",
"the",
"button",
"if",
"in",
"non",
"-",
"expert",
"mode",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1592-L1601 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | Start.setExpert | def setExpert(self):
"""
Turns on 'expert' status whereby the button is always enabled,
regardless of its activity status.
"""
w.ActButton.setExpert(self)
g = get_root(self).globals
self.config(bg=g.COL['start']) | python | def setExpert(self):
"""
Turns on 'expert' status whereby the button is always enabled,
regardless of its activity status.
"""
w.ActButton.setExpert(self)
g = get_root(self).globals
self.config(bg=g.COL['start']) | [
"def",
"setExpert",
"(",
"self",
")",
":",
"w",
".",
"ActButton",
".",
"setExpert",
"(",
"self",
")",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"self",
".",
"config",
"(",
"bg",
"=",
"g",
".",
"COL",
"[",
"'start'",
"]",
")"
] | Turns on 'expert' status whereby the button is always enabled,
regardless of its activity status. | [
"Turns",
"on",
"expert",
"status",
"whereby",
"the",
"button",
"is",
"always",
"enabled",
"regardless",
"of",
"its",
"activity",
"status",
"."
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1603-L1610 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | Start.act | def act(self):
"""
Carries out action associated with start button
"""
g = get_root(self).globals
# check binning against overscan
msg = """
HiperCAM has an o/scan of 50 pixels.
Your binning does not fit into this
region. Some columns will contain ... | python | def act(self):
"""
Carries out action associated with start button
"""
g = get_root(self).globals
# check binning against overscan
msg = """
HiperCAM has an o/scan of 50 pixels.
Your binning does not fit into this
region. Some columns will contain ... | [
"def",
"act",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"# check binning against overscan",
"msg",
"=",
"\"\"\"\n HiperCAM has an o/scan of 50 pixels.\n Your binning does not fit into this\n region. Some columns will contain... | Carries out action associated with start button | [
"Carries",
"out",
"action",
"associated",
"with",
"start",
"button"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1622-L1700 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | Load.act | def act(self):
"""
Carries out the action associated with the Load button
"""
g = get_root(self).globals
fname = filedialog.askopenfilename(
defaultextension='.json',
filetypes=[('json files', '.json'), ('fits files', '.fits')],
initialdir=g.cp... | python | def act(self):
"""
Carries out the action associated with the Load button
"""
g = get_root(self).globals
fname = filedialog.askopenfilename(
defaultextension='.json',
filetypes=[('json files', '.json'), ('fits files', '.fits')],
initialdir=g.cp... | [
"def",
"act",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"fname",
"=",
"filedialog",
".",
"askopenfilename",
"(",
"defaultextension",
"=",
"'.json'",
",",
"filetypes",
"=",
"[",
"(",
"'json files'",
",",
"'.json'",
")"... | Carries out the action associated with the Load button | [
"Carries",
"out",
"the",
"action",
"associated",
"with",
"the",
"Load",
"button"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1716-L1742 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | Save.act | def act(self):
"""
Carries out the action associated with the Save button
"""
g = get_root(self).globals
g.clog.info('\nSaving current application to disk')
# check instrument parameters
if not g.ipars.check():
g.clog.warn('Invalid instrument paramete... | python | def act(self):
"""
Carries out the action associated with the Save button
"""
g = get_root(self).globals
g.clog.info('\nSaving current application to disk')
# check instrument parameters
if not g.ipars.check():
g.clog.warn('Invalid instrument paramete... | [
"def",
"act",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"g",
".",
"clog",
".",
"info",
"(",
"'\\nSaving current application to disk'",
")",
"# check instrument parameters",
"if",
"not",
"g",
".",
"ipars",
".",
"check",
... | Carries out the action associated with the Save button | [
"Carries",
"out",
"the",
"action",
"associated",
"with",
"the",
"Save",
"button"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1757-L1790 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | Unfreeze.act | def act(self):
"""
Carries out the action associated with the Unfreeze button
"""
g = get_root(self).globals
g.ipars.unfreeze()
g.rpars.unfreeze()
g.observe.load.enable()
self.disable() | python | def act(self):
"""
Carries out the action associated with the Unfreeze button
"""
g = get_root(self).globals
g.ipars.unfreeze()
g.rpars.unfreeze()
g.observe.load.enable()
self.disable() | [
"def",
"act",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"g",
".",
"ipars",
".",
"unfreeze",
"(",
")",
"g",
".",
"rpars",
".",
"unfreeze",
"(",
")",
"g",
".",
"observe",
".",
"load",
".",
"enable",
"(",
")",
... | Carries out the action associated with the Unfreeze button | [
"Carries",
"out",
"the",
"action",
"associated",
"with",
"the",
"Unfreeze",
"button"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1804-L1812 | train |
HiPERCAM/hcam_widgets | hcam_widgets/hcam.py | Observe.setExpertLevel | def setExpertLevel(self):
"""
Set expert level
"""
g = get_root(self).globals
level = g.cpars['expert_level']
# now set whether buttons are permanently enabled or not
if level == 0 or level == 1:
self.load.setNonExpert()
self.save.setNonEx... | python | def setExpertLevel(self):
"""
Set expert level
"""
g = get_root(self).globals
level = g.cpars['expert_level']
# now set whether buttons are permanently enabled or not
if level == 0 or level == 1:
self.load.setNonExpert()
self.save.setNonEx... | [
"def",
"setExpertLevel",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"level",
"=",
"g",
".",
"cpars",
"[",
"'expert_level'",
"]",
"# now set whether buttons are permanently enabled or not",
"if",
"level",
"==",
"0",
"or",
"le... | Set expert level | [
"Set",
"expert",
"level"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1846-L1866 | train |
briancappello/py-meta-utils | py_meta_utils.py | process_factory_meta_options | def process_factory_meta_options(
mcs_args: McsArgs,
default_factory_class: Type[MetaOptionsFactory] = MetaOptionsFactory,
factory_attr_name: str = META_OPTIONS_FACTORY_CLASS_ATTR_NAME) \
-> MetaOptionsFactory:
"""
Main entry point for consumer metaclasses. Usage::
from ... | python | def process_factory_meta_options(
mcs_args: McsArgs,
default_factory_class: Type[MetaOptionsFactory] = MetaOptionsFactory,
factory_attr_name: str = META_OPTIONS_FACTORY_CLASS_ATTR_NAME) \
-> MetaOptionsFactory:
"""
Main entry point for consumer metaclasses. Usage::
from ... | [
"def",
"process_factory_meta_options",
"(",
"mcs_args",
":",
"McsArgs",
",",
"default_factory_class",
":",
"Type",
"[",
"MetaOptionsFactory",
"]",
"=",
"MetaOptionsFactory",
",",
"factory_attr_name",
":",
"str",
"=",
"META_OPTIONS_FACTORY_CLASS_ATTR_NAME",
")",
"->",
"M... | Main entry point for consumer metaclasses. Usage::
from py_meta_utils import (AbstractMetaOption, McsArgs, MetaOptionsFactory,
process_factory_meta_options)
class YourMetaOptionsFactory(MetaOptionsFactory):
_options = [AbstractMetaOption]
class... | [
"Main",
"entry",
"point",
"for",
"consumer",
"metaclasses",
".",
"Usage",
"::"
] | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L321-L386 | train |
briancappello/py-meta-utils | py_meta_utils.py | deep_getattr | def deep_getattr(clsdict: Dict[str, Any],
bases: Tuple[Type[object], ...],
name: str,
default: Any = _missing) -> Any:
"""
Acts just like ``getattr`` would on a constructed class object, except this operates
on the pre-construction class dictionary and base... | python | def deep_getattr(clsdict: Dict[str, Any],
bases: Tuple[Type[object], ...],
name: str,
default: Any = _missing) -> Any:
"""
Acts just like ``getattr`` would on a constructed class object, except this operates
on the pre-construction class dictionary and base... | [
"def",
"deep_getattr",
"(",
"clsdict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"bases",
":",
"Tuple",
"[",
"Type",
"[",
"object",
"]",
",",
"...",
"]",
",",
"name",
":",
"str",
",",
"default",
":",
"Any",
"=",
"_missing",
")",
"->",
"Any",... | Acts just like ``getattr`` would on a constructed class object, except this operates
on the pre-construction class dictionary and base classes. In other words, first we
look for the attribute in the class dictionary, and then we search all the base
classes (in method resolution order), finally returning the... | [
"Acts",
"just",
"like",
"getattr",
"would",
"on",
"a",
"constructed",
"class",
"object",
"except",
"this",
"operates",
"on",
"the",
"pre",
"-",
"construction",
"class",
"dictionary",
"and",
"base",
"classes",
".",
"In",
"other",
"words",
"first",
"we",
"look... | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L437-L458 | train |
briancappello/py-meta-utils | py_meta_utils.py | McsArgs.getattr | def getattr(self, name, default: Any = _missing):
"""
Convenience method equivalent to
``deep_getattr(mcs_args.clsdict, mcs_args.bases, 'attr_name'[, default])``
"""
return deep_getattr(self.clsdict, self.bases, name, default) | python | def getattr(self, name, default: Any = _missing):
"""
Convenience method equivalent to
``deep_getattr(mcs_args.clsdict, mcs_args.bases, 'attr_name'[, default])``
"""
return deep_getattr(self.clsdict, self.bases, name, default) | [
"def",
"getattr",
"(",
"self",
",",
"name",
",",
"default",
":",
"Any",
"=",
"_missing",
")",
":",
"return",
"deep_getattr",
"(",
"self",
".",
"clsdict",
",",
"self",
".",
"bases",
",",
"name",
",",
"default",
")"
] | Convenience method equivalent to
``deep_getattr(mcs_args.clsdict, mcs_args.bases, 'attr_name'[, default])`` | [
"Convenience",
"method",
"equivalent",
"to",
"deep_getattr",
"(",
"mcs_args",
".",
"clsdict",
"mcs_args",
".",
"bases",
"attr_name",
"[",
"default",
"]",
")"
] | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L42-L47 | train |
briancappello/py-meta-utils | py_meta_utils.py | McsArgs.qualname | def qualname(self) -> str:
"""
Returns the fully qualified name of the class-under-construction, if possible,
otherwise just the class name.
"""
if self.module:
return self.module + '.' + self.name
return self.name | python | def qualname(self) -> str:
"""
Returns the fully qualified name of the class-under-construction, if possible,
otherwise just the class name.
"""
if self.module:
return self.module + '.' + self.name
return self.name | [
"def",
"qualname",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"module",
":",
"return",
"self",
".",
"module",
"+",
"'.'",
"+",
"self",
".",
"name",
"return",
"self",
".",
"name"
] | Returns the fully qualified name of the class-under-construction, if possible,
otherwise just the class name. | [
"Returns",
"the",
"fully",
"qualified",
"name",
"of",
"the",
"class",
"-",
"under",
"-",
"construction",
"if",
"possible",
"otherwise",
"just",
"the",
"class",
"name",
"."
] | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L57-L64 | train |
briancappello/py-meta-utils | py_meta_utils.py | McsArgs.is_abstract | def is_abstract(self) -> bool:
"""
Whether or not the class-under-construction was declared as abstract (**NOTE:**
this property is usable even *before* the :class:`MetaOptionsFactory` has run)
"""
meta_value = getattr(self.clsdict.get('Meta'), 'abstract', False)
return s... | python | def is_abstract(self) -> bool:
"""
Whether or not the class-under-construction was declared as abstract (**NOTE:**
this property is usable even *before* the :class:`MetaOptionsFactory` has run)
"""
meta_value = getattr(self.clsdict.get('Meta'), 'abstract', False)
return s... | [
"def",
"is_abstract",
"(",
"self",
")",
"->",
"bool",
":",
"meta_value",
"=",
"getattr",
"(",
"self",
".",
"clsdict",
".",
"get",
"(",
"'Meta'",
")",
",",
"'abstract'",
",",
"False",
")",
"return",
"self",
".",
"clsdict",
".",
"get",
"(",
"ABSTRACT_ATT... | Whether or not the class-under-construction was declared as abstract (**NOTE:**
this property is usable even *before* the :class:`MetaOptionsFactory` has run) | [
"Whether",
"or",
"not",
"the",
"class",
"-",
"under",
"-",
"construction",
"was",
"declared",
"as",
"abstract",
"(",
"**",
"NOTE",
":",
"**",
"this",
"property",
"is",
"usable",
"even",
"*",
"before",
"*",
"the",
":",
"class",
":",
"MetaOptionsFactory",
... | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L76-L82 | train |
briancappello/py-meta-utils | py_meta_utils.py | MetaOption.get_value | def get_value(self, Meta: Type[object], base_classes_meta, mcs_args: McsArgs) -> Any:
"""
Returns the value for ``self.name`` given the class-under-construction's class
``Meta``. If it's not found there, and ``self.inherit == True`` and there is a
base class that has a class ``Meta``, us... | python | def get_value(self, Meta: Type[object], base_classes_meta, mcs_args: McsArgs) -> Any:
"""
Returns the value for ``self.name`` given the class-under-construction's class
``Meta``. If it's not found there, and ``self.inherit == True`` and there is a
base class that has a class ``Meta``, us... | [
"def",
"get_value",
"(",
"self",
",",
"Meta",
":",
"Type",
"[",
"object",
"]",
",",
"base_classes_meta",
",",
"mcs_args",
":",
"McsArgs",
")",
"->",
"Any",
":",
"value",
"=",
"self",
".",
"default",
"if",
"self",
".",
"inherit",
"and",
"base_classes_meta... | Returns the value for ``self.name`` given the class-under-construction's class
``Meta``. If it's not found there, and ``self.inherit == True`` and there is a
base class that has a class ``Meta``, use that value, otherwise ``self.default``.
:param Meta: the class ``Meta`` (if any) from the class... | [
"Returns",
"the",
"value",
"for",
"self",
".",
"name",
"given",
"the",
"class",
"-",
"under",
"-",
"construction",
"s",
"class",
"Meta",
".",
"If",
"it",
"s",
"not",
"found",
"there",
"and",
"self",
".",
"inherit",
"==",
"True",
"and",
"there",
"is",
... | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L113-L131 | train |
briancappello/py-meta-utils | py_meta_utils.py | MetaOptionsFactory._get_meta_options | def _get_meta_options(self) -> List[MetaOption]:
"""
Returns a list of :class:`MetaOption` instances that this factory supports.
"""
return [option if isinstance(option, MetaOption) else option()
for option in self._options] | python | def _get_meta_options(self) -> List[MetaOption]:
"""
Returns a list of :class:`MetaOption` instances that this factory supports.
"""
return [option if isinstance(option, MetaOption) else option()
for option in self._options] | [
"def",
"_get_meta_options",
"(",
"self",
")",
"->",
"List",
"[",
"MetaOption",
"]",
":",
"return",
"[",
"option",
"if",
"isinstance",
"(",
"option",
",",
"MetaOption",
")",
"else",
"option",
"(",
")",
"for",
"option",
"in",
"self",
".",
"_options",
"]"
] | Returns a list of :class:`MetaOption` instances that this factory supports. | [
"Returns",
"a",
"list",
"of",
":",
"class",
":",
"MetaOption",
"instances",
"that",
"this",
"factory",
"supports",
"."
] | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L245-L250 | train |
briancappello/py-meta-utils | py_meta_utils.py | MetaOptionsFactory._contribute_to_class | def _contribute_to_class(self, mcs_args: McsArgs):
"""
Where the magic happens. Takes one parameter, the :class:`McsArgs` of the
class-under-construction, and processes the declared ``class Meta`` from
it (if any). We fill ourself with the declared meta options' name/value pairs,
... | python | def _contribute_to_class(self, mcs_args: McsArgs):
"""
Where the magic happens. Takes one parameter, the :class:`McsArgs` of the
class-under-construction, and processes the declared ``class Meta`` from
it (if any). We fill ourself with the declared meta options' name/value pairs,
... | [
"def",
"_contribute_to_class",
"(",
"self",
",",
"mcs_args",
":",
"McsArgs",
")",
":",
"self",
".",
"_mcs_args",
"=",
"mcs_args",
"Meta",
"=",
"mcs_args",
".",
"clsdict",
".",
"pop",
"(",
"'Meta'",
",",
"None",
")",
"# type: Type[object]",
"base_classes_meta",... | Where the magic happens. Takes one parameter, the :class:`McsArgs` of the
class-under-construction, and processes the declared ``class Meta`` from
it (if any). We fill ourself with the declared meta options' name/value pairs,
give the declared meta options a chance to also contribute to the clas... | [
"Where",
"the",
"magic",
"happens",
".",
"Takes",
"one",
"parameter",
"the",
":",
"class",
":",
"McsArgs",
"of",
"the",
"class",
"-",
"under",
"-",
"construction",
"and",
"processes",
"the",
"declared",
"class",
"Meta",
"from",
"it",
"(",
"if",
"any",
")... | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L252-L273 | train |
briancappello/py-meta-utils | py_meta_utils.py | MetaOptionsFactory._fill_from_meta | def _fill_from_meta(self, Meta: Type[object], base_classes_meta, mcs_args: McsArgs):
"""
Iterate over our supported meta options, and set attributes on the factory
instance (self) for each meta option's name/value. Raises ``TypeError`` if
we discover any unsupported meta options on the c... | python | def _fill_from_meta(self, Meta: Type[object], base_classes_meta, mcs_args: McsArgs):
"""
Iterate over our supported meta options, and set attributes on the factory
instance (self) for each meta option's name/value. Raises ``TypeError`` if
we discover any unsupported meta options on the c... | [
"def",
"_fill_from_meta",
"(",
"self",
",",
"Meta",
":",
"Type",
"[",
"object",
"]",
",",
"base_classes_meta",
",",
"mcs_args",
":",
"McsArgs",
")",
":",
"# Exclude private/protected fields from the Meta",
"meta_attrs",
"=",
"{",
"}",
"if",
"not",
"Meta",
"else"... | Iterate over our supported meta options, and set attributes on the factory
instance (self) for each meta option's name/value. Raises ``TypeError`` if
we discover any unsupported meta options on the class-under-construction's
``class Meta``. | [
"Iterate",
"over",
"our",
"supported",
"meta",
"options",
"and",
"set",
"attributes",
"on",
"the",
"factory",
"instance",
"(",
"self",
")",
"for",
"each",
"meta",
"option",
"s",
"name",
"/",
"value",
".",
"Raises",
"TypeError",
"if",
"we",
"discover",
"any... | 8de20be00768b7749dc2207a98331a9f23187918 | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L275-L303 | train |
HiPERCAM/hcam_widgets | hcam_widgets/gtc/corba.py | CORBAConnection.get_object | def get_object(self, binding_name, cls):
"""
Get a reference to a remote object using CORBA
"""
return self._state.get_object(self, binding_name, cls) | python | def get_object(self, binding_name, cls):
"""
Get a reference to a remote object using CORBA
"""
return self._state.get_object(self, binding_name, cls) | [
"def",
"get_object",
"(",
"self",
",",
"binding_name",
",",
"cls",
")",
":",
"return",
"self",
".",
"_state",
".",
"get_object",
"(",
"self",
",",
"binding_name",
",",
"cls",
")"
] | Get a reference to a remote object using CORBA | [
"Get",
"a",
"reference",
"to",
"a",
"remote",
"object",
"using",
"CORBA"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/gtc/corba.py#L40-L44 | train |
HiPERCAM/hcam_widgets | hcam_widgets/gtc/corba.py | ReadyCORBAState.get_object | def get_object(conn, binding_name, object_cls):
"""
Get a reference to a remote object using CORBA
"""
try:
obj = conn.rootContext.resolve(binding_name)
narrowed = obj._narrow(object_cls)
except CORBA.TRANSIENT:
raise IOError('Attempt to retrie... | python | def get_object(conn, binding_name, object_cls):
"""
Get a reference to a remote object using CORBA
"""
try:
obj = conn.rootContext.resolve(binding_name)
narrowed = obj._narrow(object_cls)
except CORBA.TRANSIENT:
raise IOError('Attempt to retrie... | [
"def",
"get_object",
"(",
"conn",
",",
"binding_name",
",",
"object_cls",
")",
":",
"try",
":",
"obj",
"=",
"conn",
".",
"rootContext",
".",
"resolve",
"(",
"binding_name",
")",
"narrowed",
"=",
"obj",
".",
"_narrow",
"(",
"object_cls",
")",
"except",
"C... | Get a reference to a remote object using CORBA | [
"Get",
"a",
"reference",
"to",
"a",
"remote",
"object",
"using",
"CORBA"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/gtc/corba.py#L116-L129 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.