partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | asciiblock._generate_art | Return an iterator that produces the ascii art. | luma/emulator/device.py | 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):
"""
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)... | [
"Return",
"an",
"iterator",
"that",
"produces",
"the",
"ascii",
"art",
"."
] | rm-hull/luma.emulator | python | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L341-L353 | [
"def",
"_generate_art",
"(",
"self",
",",
"image",
",",
"width",
",",
"height",
")",
":",
"image",
"=",
"image",
".",
"resize",
"(",
"(",
"width",
",",
"height",
")",
",",
"Image",
".",
"ANTIALIAS",
")",
".",
"convert",
"(",
"\"RGB\"",
")",
"pixels",... | ca3db028b33d17cda9247ea5189873ff0408d013 |
train | asciiblock._CSI | Control sequence introducer | luma/emulator/device.py | def _CSI(self, cmd):
"""
Control sequence introducer
"""
sys.stdout.write('\x1b[')
sys.stdout.write(cmd) | def _CSI(self, cmd):
"""
Control sequence introducer
"""
sys.stdout.write('\x1b[')
sys.stdout.write(cmd) | [
"Control",
"sequence",
"introducer"
] | rm-hull/luma.emulator | python | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L355-L360 | [
"def",
"_CSI",
"(",
"self",
",",
"cmd",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"'\\x1b['",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"cmd",
")"
] | ca3db028b33d17cda9247ea5189873ff0408d013 |
train | asciiblock.display | Takes a :py:mod:`PIL.Image` and renders it to the current terminal as
ASCII-blocks. | luma/emulator/device.py | 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):
"""
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... | [
"Takes",
"a",
":",
"py",
":",
"mod",
":",
"PIL",
".",
"Image",
"and",
"renders",
"it",
"to",
"the",
"current",
"terminal",
"as",
"ASCII",
"-",
"blocks",
"."
] | rm-hull/luma.emulator | python | https://github.com/rm-hull/luma.emulator/blob/ca3db028b33d17cda9247ea5189873ff0408d013/luma/emulator/device.py#L362-L384 | [
"def",
"display",
"(",
"self",
",",
"image",
")",
":",
"assert",
"(",
"image",
".",
"size",
"==",
"self",
".",
"size",
")",
"self",
".",
"_last_image",
"=",
"image",
"surface",
"=",
"self",
".",
"to_surface",
"(",
"self",
".",
"preprocess",
"(",
"ima... | ca3db028b33d17cda9247ea5189873ff0408d013 |
train | chunk_sequence | Yield successive n-sized chunks from l. | routes1846/find_best_routes.py | 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):
"""Yield successive n-sized chunks from l."""
for index in range(0, len(sequence), chunk_length):
yield sequence[index:index + chunk_length] | [
"Yield",
"successive",
"n",
"-",
"sized",
"chunks",
"from",
"l",
"."
] | Auzzy/1846-routes | python | https://github.com/Auzzy/1846-routes/blob/60c90928e184cbcc09c9fef46c2df07f5f14c2c2/routes1846/find_best_routes.py#L72-L75 | [
"def",
"chunk_sequence",
"(",
"sequence",
",",
"chunk_length",
")",
":",
"for",
"index",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"sequence",
")",
",",
"chunk_length",
")",
":",
"yield",
"sequence",
"[",
"index",
":",
"index",
"+",
"chunk_length",
"]"
] | 60c90928e184cbcc09c9fef46c2df07f5f14c2c2 |
train | _filter_invalid_routes | 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... | routes1846/find_best_routes.py | 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):
"""
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... | [
"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"... | Auzzy/1846-routes | python | https://github.com/Auzzy/1846-routes/blob/60c90928e184cbcc09c9fef46c2df07f5f14c2c2/routes1846/find_best_routes.py#L171-L224 | [
"def",
"_filter_invalid_routes",
"(",
"routes",
",",
"board",
",",
"railroad",
")",
":",
"chicago_space",
"=",
"board",
".",
"get_space",
"(",
"CHICAGO_CELL",
")",
"chicago_neighbor_cells",
"=",
"[",
"cell",
"for",
"cell",
"in",
"CHICAGO_CELL",
".",
"neighbors",... | 60c90928e184cbcc09c9fef46c2df07f5f14c2c2 |
train | find | Filter log message.
**中文文档**
根据level名称, message中的关键字, 和log的时间的区间, 筛选出相关的日志 | loggerFactory/logfilter.py | 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
"""
Filter log message.
**中文文档**
根据level名称, message中的关键字, 和log的时间的区间, 筛选出相关的日志
"""
if level:
level = level.upper() # level name has... | [
"Filter",
"log",
"message",
"."
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logfilter.py#L49-L101 | [
"def",
"find",
"(",
"path",
",",
"level",
"=",
"None",
",",
"message",
"=",
"None",
",",
"time_lower",
"=",
"None",
",",
"time_upper",
"=",
"None",
",",
"case_sensitive",
"=",
"False",
")",
":",
"# pragma: no cover",
"if",
"level",
":",
"level",
"=",
"... | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | get_logger_by_name | 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. | loggerFactory/logger.py | 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):
"""
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... | [
"Get",
"a",
"logger",
"by",
"name",
"."
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L17-L27 | [
"def",
"get_logger_by_name",
"(",
"name",
"=",
"None",
",",
"rand_name",
"=",
"False",
",",
"charset",
"=",
"Charset",
".",
"HEX",
")",
":",
"if",
"rand_name",
":",
"name",
"=",
"rand_str",
"(",
"charset",
")",
"logger",
"=",
"logging",
".",
"getLogger",... | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | BaseLogger.debug | invoke ``self.logger.debug`` | loggerFactory/logger.py | 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):
"""invoke ``self.logger.debug``"""
return self.logger.debug(self._indent(msg, indent), **kwargs) | [
"invoke",
"self",
".",
"logger",
".",
"debug"
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L59-L61 | [
"def",
"debug",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"debug",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | BaseLogger.info | invoke ``self.info.debug`` | loggerFactory/logger.py | 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):
"""invoke ``self.info.debug``"""
return self.logger.info(self._indent(msg, indent), **kwargs) | [
"invoke",
"self",
".",
"info",
".",
"debug"
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L63-L65 | [
"def",
"info",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"info",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | BaseLogger.warning | invoke ``self.logger.warning`` | loggerFactory/logger.py | 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):
"""invoke ``self.logger.warning``"""
return self.logger.warning(self._indent(msg, indent), **kwargs) | [
"invoke",
"self",
".",
"logger",
".",
"warning"
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L67-L69 | [
"def",
"warning",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"warning",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | BaseLogger.error | invoke ``self.logger.error`` | loggerFactory/logger.py | 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):
"""invoke ``self.logger.error``"""
return self.logger.error(self._indent(msg, indent), **kwargs) | [
"invoke",
"self",
".",
"logger",
".",
"error"
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L71-L73 | [
"def",
"error",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"error",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | BaseLogger.critical | invoke ``self.logger.critical`` | loggerFactory/logger.py | 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):
"""invoke ``self.logger.critical``"""
return self.logger.critical(self._indent(msg, indent), **kwargs) | [
"invoke",
"self",
".",
"logger",
".",
"critical"
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L75-L77 | [
"def",
"critical",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"logger",
".",
"critical",
"(",
"self",
".",
"_indent",
"(",
"msg",
",",
"indent",
")",
",",
"*",
"*",
"kwargs",
")"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | BaseLogger.show | Print message to console, indent format may apply. | loggerFactory/logger.py | 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):
"""
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... | [
"Print",
"message",
"to",
"console",
"indent",
"format",
"may",
"apply",
"."
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L79-L89 | [
"def",
"show",
"(",
"self",
",",
"msg",
",",
"indent",
"=",
"0",
",",
"style",
"=",
"\"\"",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"enable_verbose",
":",
"new_msg",
"=",
"self",
".",
"MessageTemplate",
".",
"with_style",
".",
"format",... | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | BaseLogger.remove_all_handler | Unlink the file handler association. | loggerFactory/logger.py | 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):
"""
Unlink the file handler association.
"""
for handler in self.logger.handlers[:]:
self.logger.removeHandler(handler)
self._handler_cache.append(handler) | [
"Unlink",
"the",
"file",
"handler",
"association",
"."
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L111-L117 | [
"def",
"remove_all_handler",
"(",
"self",
")",
":",
"for",
"handler",
"in",
"self",
".",
"logger",
".",
"handlers",
"[",
":",
"]",
":",
"self",
".",
"logger",
".",
"removeHandler",
"(",
"handler",
")",
"self",
".",
"_handler_cache",
".",
"append",
"(",
... | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | BaseLogger.recover_all_handler | Relink the file handler association you just removed. | loggerFactory/logger.py | 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):
"""
Relink the file handler association you just removed.
"""
for handler in self._handler_cache:
self.logger.addHandler(handler)
self._handler_cache = list() | [
"Relink",
"the",
"file",
"handler",
"association",
"you",
"just",
"removed",
"."
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/logger.py#L119-L125 | [
"def",
"recover_all_handler",
"(",
"self",
")",
":",
"for",
"handler",
"in",
"self",
".",
"_handler_cache",
":",
"self",
".",
"logger",
".",
"addHandler",
"(",
"handler",
")",
"self",
".",
"_handler_cache",
"=",
"list",
"(",
")"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | LinkItem.from_protobuf | 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 | unidown/plugin/link_item.py | 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:
"""
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... | [
"Constructor",
"from",
"protobuf",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/link_item.py#L37-L49 | [
"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",... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | LinkItem.to_protobuf | Create protobuf item.
:return: protobuf structure
:rtype: ~unidown.plugin.protobuf.link_item_pb2.LinkItemProto | unidown/plugin/link_item.py | 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:
"""
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... | [
"Create",
"protobuf",
"item",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/link_item.py#L70-L80 | [
"def",
"to_protobuf",
"(",
"self",
")",
"->",
"LinkItemProto",
":",
"result",
"=",
"LinkItemProto",
"(",
")",
"result",
".",
"name",
"=",
"self",
".",
"_name",
"result",
".",
"time",
".",
"CopyFrom",
"(",
"datetime_to_timestamp",
"(",
"self",
".",
"_time",... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | Logger.update | Adds a handler to save to a file. Includes debug stuff. | hcam_widgets/logs.py | 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):
"""
Adds a handler to save to a file. Includes debug stuff.
"""
ltfh = FileHandler(fname)
self._log.addHandler(ltfh) | [
"Adds",
"a",
"handler",
"to",
"save",
"to",
"a",
"file",
".",
"Includes",
"debug",
"stuff",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/logs.py#L117-L122 | [
"def",
"update",
"(",
"self",
",",
"fname",
")",
":",
"ltfh",
"=",
"FileHandler",
"(",
"fname",
")",
"self",
".",
"_log",
".",
"addHandler",
"(",
"ltfh",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | delete_dir_rec | Delete a folder recursive.
:param path: folder to deleted
:type path: ~pathlib.Path | unidown/tools.py | 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):
"""
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:
... | [
"Delete",
"a",
"folder",
"recursive",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/tools.py#L13-L27 | [
"def",
"delete_dir_rec",
"(",
"path",
":",
"Path",
")",
":",
"if",
"not",
"path",
".",
"exists",
"(",
")",
"or",
"not",
"path",
".",
"is_dir",
"(",
")",
":",
"return",
"for",
"sub",
"in",
"path",
".",
"iterdir",
"(",
")",
":",
"if",
"sub",
".",
... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | create_dir_rec | Create a folder recursive.
:param path: path
:type path: ~pathlib.Path | unidown/tools.py | 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):
"""
Create a folder recursive.
:param path: path
:type path: ~pathlib.Path
"""
if not path.exists():
Path.mkdir(path, parents=True, exist_ok=True) | [
"Create",
"a",
"folder",
"recursive",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/tools.py#L30-L38 | [
"def",
"create_dir_rec",
"(",
"path",
":",
"Path",
")",
":",
"if",
"not",
"path",
".",
"exists",
"(",
")",
":",
"Path",
".",
"mkdir",
"(",
"path",
",",
"parents",
"=",
"True",
",",
"exist_ok",
"=",
"True",
")"
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | datetime_to_timestamp | Convert datetime to protobuf.timestamp.
:param time: time
:type time: ~datetime.datetime
:return: protobuf.timestamp
:rtype: ~google.protobuf.timestamp_pb2.Timestamp | unidown/tools.py | 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:
"""
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)
... | [
"Convert",
"datetime",
"to",
"protobuf",
".",
"timestamp",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/tools.py#L41-L52 | [
"def",
"datetime_to_timestamp",
"(",
"time",
":",
"datetime",
")",
"->",
"Timestamp",
":",
"protime",
"=",
"Timestamp",
"(",
")",
"protime",
".",
"FromDatetime",
"(",
"time",
")",
"return",
"protime"
] | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | print_plugin_list | Prints all registered plugins and checks if they can be loaded or not.
:param plugins: plugins
:type plugins: Dict[str, ~pkg_resources.EntryPoint] | unidown/tools.py | 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]):
"""
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... | [
"Prints",
"all",
"registered",
"plugins",
"and",
"checks",
"if",
"they",
"can",
"be",
"loaded",
"or",
"not",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/tools.py#L55-L73 | [
"def",
"print_plugin_list",
"(",
"plugins",
":",
"Dict",
"[",
"str",
",",
"pkg_resources",
".",
"EntryPoint",
"]",
")",
":",
"for",
"trigger",
",",
"entry_point",
"in",
"plugins",
".",
"items",
"(",
")",
":",
"try",
":",
"plugin_class",
"=",
"entry_point",... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | overlap | Determines whether two windows overlap | hcam_widgets/misc.py | 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):
"""
Determines whether two windows overlap
"""
return (xl2 < xl1+nx1 and xl2+nx2 > xl1 and
yl2 < yl1+ny1 and yl2+ny2 > yl1) | [
"Determines",
"whether",
"two",
"windows",
"overlap"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L140-L145 | [
"def",
"overlap",
"(",
"xl1",
",",
"yl1",
",",
"nx1",
",",
"ny1",
",",
"xl2",
",",
"yl2",
",",
"nx2",
",",
"ny2",
")",
":",
"return",
"(",
"xl2",
"<",
"xl1",
"+",
"nx1",
"and",
"xl2",
"+",
"nx2",
">",
"xl1",
"and",
"yl2",
"<",
"yl1",
"+",
"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | saveJSON | 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 | hcam_widgets/misc.py | 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):
"""
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",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L195-L227 | [
"def",
"saveJSON",
"(",
"g",
",",
"data",
",",
"backup",
"=",
"False",
")",
":",
"if",
"not",
"backup",
":",
"fname",
"=",
"filedialog",
".",
"asksaveasfilename",
"(",
"defaultextension",
"=",
"'.json'",
",",
"filetypes",
"=",
"[",
"(",
"'json files'",
"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | postJSON | 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. | hcam_widgets/misc.py | 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):
"""
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... | [
"Posts",
"the",
"current",
"setup",
"to",
"the",
"camera",
"and",
"data",
"servers",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L230-L280 | [
"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... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | createJSON | Create JSON compatible dictionary from current settings
Parameters
----------
g : hcam_drivers.globals.Container
Container with globals | hcam_widgets/misc.py | 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):
"""
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... | [
"Create",
"JSON",
"compatible",
"dictionary",
"from",
"current",
"settings"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L283-L311 | [
"def",
"createJSON",
"(",
"g",
",",
"full",
"=",
"True",
")",
":",
"data",
"=",
"dict",
"(",
")",
"if",
"'gps_attached'",
"not",
"in",
"g",
".",
"cpars",
":",
"data",
"[",
"'gps_attached'",
"]",
"=",
"1",
"else",
":",
"data",
"[",
"'gps_attached'",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | insertFITSHDU | 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 | hcam_widgets/misc.py | 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):
"""
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... | [
"Uploads",
"a",
"table",
"of",
"TCS",
"data",
"to",
"the",
"servers",
"which",
"is",
"appended",
"onto",
"a",
"run",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L395-L430 | [
"def",
"insertFITSHDU",
"(",
"g",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"g",
".",
"clog",
".",
"warn",
"(",
"'insertFITSHDU: servers are not active'",
")",
"return",
"False",
"run_number",
"=",
"getRunNumber",
"(",
"g",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | execCommand | 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 ... | hcam_widgets/misc.py | 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):
"""
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... | [
"Executes",
"a",
"command",
"by",
"sending",
"it",
"to",
"the",
"rack",
"server"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L433-L478 | [
"def",
"execCommand",
"(",
"g",
",",
"command",
",",
"timeout",
"=",
"10",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"g",
".",
"clog",
".",
"warn",
"(",
"'execCommand: servers are not active'",
")",
"return",
"False",
"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | isRunActive | Polls the data server to see if a run is active | hcam_widgets/misc.py | 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):
"""
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:
... | [
"Polls",
"the",
"data",
"server",
"to",
"see",
"if",
"a",
"run",
"is",
"active"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L481-L498 | [
"def",
"isRunActive",
"(",
"g",
")",
":",
"if",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"url",
"=",
"g",
".",
"cpars",
"[",
"'hipercam_server'",
"]",
"+",
"'summary'",
"response",
"=",
"urllib",
".",
"request",
".",
"urlopen",
"(",
"url",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | getFrameNumber | Polls the data server to find the current frame number.
Throws an exceotion if it cannot determine it. | hcam_widgets/misc.py | 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):
"""
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... | [
"Polls",
"the",
"data",
"server",
"to",
"find",
"the",
"current",
"frame",
"number",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L535-L554 | [
"def",
"getFrameNumber",
"(",
"g",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"raise",
"DriverError",
"(",
"'getRunNumber error: servers are not active'",
")",
"url",
"=",
"g",
".",
"cpars",
"[",
"'hipercam_server'",
"]",
"+",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | getRunNumber | Polls the data server to find the current run number. Throws
exceptions if it can't determine it. | hcam_widgets/misc.py | 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):
"""
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... | [
"Polls",
"the",
"data",
"server",
"to",
"find",
"the",
"current",
"run",
"number",
".",
"Throws",
"exceptions",
"if",
"it",
"can",
"t",
"determine",
"it",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L557-L570 | [
"def",
"getRunNumber",
"(",
"g",
")",
":",
"if",
"not",
"g",
".",
"cpars",
"[",
"'hcam_server_on'",
"]",
":",
"raise",
"DriverError",
"(",
"'getRunNumber error: servers are not active'",
")",
"url",
"=",
"g",
".",
"cpars",
"[",
"'hipercam_server'",
"]",
"+",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | checkSimbad | 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 | hcam_widgets/misc.py | 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):
"""
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) + \
'... | [
"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"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L573-L603 | [
"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 \"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | FifoThread.run | Version of run that traps Exceptions and stores
them in the fifo | hcam_widgets/misc.py | 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):
"""
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 ... | [
"Version",
"of",
"run",
"that",
"traps",
"Exceptions",
"and",
"stores",
"them",
"in",
"the",
"fifo"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/misc.py#L618-L630 | [
"def",
"run",
"(",
"self",
")",
":",
"try",
":",
"threading",
".",
"Thread",
".",
"run",
"(",
"self",
")",
"except",
"Exception",
":",
"t",
",",
"v",
",",
"tb",
"=",
"sys",
".",
"exc_info",
"(",
")",
"error",
"=",
"traceback",
".",
"format_exceptio... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | rand_str | Generate random string. | loggerFactory/rand_str.py | def rand_str(charset, length=32):
"""
Generate random string.
"""
return "".join([random.choice(charset) for _ in range(length)]) | def rand_str(charset, length=32):
"""
Generate random string.
"""
return "".join([random.choice(charset) for _ in range(length)]) | [
"Generate",
"random",
"string",
"."
] | MacHu-GWU/loggerFactory-project | python | https://github.com/MacHu-GWU/loggerFactory-project/blob/4de19e275e01dc583b1af9ceeacef0c6084cd6e0/loggerFactory/rand_str.py#L16-L20 | [
"def",
"rand_str",
"(",
"charset",
",",
"length",
"=",
"32",
")",
":",
"return",
"\"\"",
".",
"join",
"(",
"[",
"random",
".",
"choice",
"(",
"charset",
")",
"for",
"_",
"in",
"range",
"(",
"length",
")",
"]",
")"
] | 4de19e275e01dc583b1af9ceeacef0c6084cd6e0 |
train | get_root | Simple method to access root for a widget | hcam_widgets/tkutils.py | 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):
"""
Simple method to access root for a widget
"""
next_level = w
while next_level.master:
next_level = next_level.master
return next_level | [
"Simple",
"method",
"to",
"access",
"root",
"for",
"a",
"widget"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/tkutils.py#L18-L25 | [
"def",
"get_root",
"(",
"w",
")",
":",
"next_level",
"=",
"w",
"while",
"next_level",
".",
"master",
":",
"next_level",
"=",
"next_level",
".",
"master",
"return",
"next_level"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | addStyle | Styles the GUI: global fonts and colours.
Parameters
----------
w : tkinter.tk
widget element to style | hcam_widgets/tkutils.py | 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):
"""
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']
... | [
"Styles",
"the",
"GUI",
":",
"global",
"fonts",
"and",
"colours",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/tkutils.py#L28-L65 | [
"def",
"addStyle",
"(",
"w",
")",
":",
"# access global container in root widget",
"root",
"=",
"get_root",
"(",
"w",
")",
"g",
"=",
"root",
".",
"globals",
"fsize",
"=",
"g",
".",
"cpars",
"[",
"'font_size'",
"]",
"family",
"=",
"g",
".",
"cpars",
"[",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | init | 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 | unidown/core/manager.py | 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):
"""
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",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/manager.py#L17-L56 | [
"def",
"init",
"(",
"main_dir",
":",
"Path",
",",
"logfile_path",
":",
"Path",
",",
"log_level",
":",
"str",
")",
":",
"dynamic_data",
".",
"reset",
"(",
")",
"dynamic_data",
".",
"init_dirs",
"(",
"main_dir",
",",
"logfile_path",
")",
"dynamic_data",
".",... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | download_from_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... | unidown/core/manager.py | 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):
"""
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.... | [
"Download",
"routine",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/manager.py#L66-L111 | [
"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",
... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | run | 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 | unidown/core/manager.py | 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:
"""
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]
... | [
"Run",
"a",
"plugin",
"so",
"use",
"the",
"download",
"routine",
"and",
"clean",
"up",
"after",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/manager.py#L114-L160 | [
"def",
"run",
"(",
"plugin_name",
":",
"str",
",",
"options",
":",
"List",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"PluginState",
":",
"if",
"options",
"is",
"None",
":",
"options",
"=",
"[",
"]",
"if",
"plugin_name",
"not",
"in",
"dynamic_data",
".... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | check_update | Check for app updates and print/log them. | unidown/core/manager.py | 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():
"""
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... | [
"Check",
"for",
"app",
"updates",
"and",
"print",
"/",
"log",
"them",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/manager.py#L163-L178 | [
"def",
"check_update",
"(",
")",
":",
"logging",
".",
"info",
"(",
"'Check for app updates.'",
")",
"try",
":",
"update",
"=",
"updater",
".",
"check_for_app_updates",
"(",
")",
"except",
"Exception",
":",
"logging",
".",
"exception",
"(",
"'Check for updates fa... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | get_newest_app_version | Download the version tag from remote.
:return: version from remote
:rtype: ~packaging.version.Version | unidown/core/updater.py | 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:
"""
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... | [
"Download",
"the",
"version",
"tag",
"from",
"remote",
"."
] | IceflowRE/unidown | python | https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/core/updater.py#L13-L28 | [
"def",
"get_newest_app_version",
"(",
")",
"->",
"Version",
":",
"with",
"urllib3",
".",
"PoolManager",
"(",
"cert_reqs",
"=",
"'CERT_REQUIRED'",
",",
"ca_certs",
"=",
"certifi",
".",
"where",
"(",
")",
")",
"as",
"p_man",
":",
"pypi_json",
"=",
"p_man",
"... | 2a6f82ab780bb825668bfc55b67c11c4f72ec05c |
train | InstPars.setupNodding | Setup Nodding for GTC | hcam_widgets/hcam.py | 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):
"""
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... | [
"Setup",
"Nodding",
"for",
"GTC"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L286-L357 | [
"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",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | InstPars.dumpJSON | Encodes current parameters to JSON compatible dictionary | hcam_widgets/hcam.py | 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):
"""
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... | [
"Encodes",
"current",
"parameters",
"to",
"JSON",
"compatible",
"dictionary"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L404-L464 | [
"def",
"dumpJSON",
"(",
"self",
")",
":",
"numexp",
"=",
"self",
".",
"number",
".",
"get",
"(",
")",
"expTime",
",",
"_",
",",
"_",
",",
"_",
",",
"_",
"=",
"self",
".",
"timing",
"(",
")",
"if",
"numexp",
"==",
"0",
":",
"numexp",
"=",
"-",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | InstPars.loadJSON | Loads in an application saved in JSON format. | hcam_widgets/hcam.py | 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):
"""
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('... | [
"Loads",
"in",
"an",
"application",
"saved",
"in",
"JSON",
"format",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L466-L571 | [
"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",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | InstPars.check | 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... | hcam_widgets/hcam.py | 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):
"""
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... | [
"Callback",
"to",
"check",
"validity",
"of",
"instrument",
"parameters",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L573-L717 | [
"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",
",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | InstPars.freeze | Freeze all settings so they cannot be altered | hcam_widgets/hcam.py | 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):
"""
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... | [
"Freeze",
"all",
"settings",
"so",
"they",
"cannot",
"be",
"altered"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L719-L733 | [
"def",
"freeze",
"(",
"self",
")",
":",
"self",
".",
"app",
".",
"disable",
"(",
")",
"self",
".",
"clear",
".",
"disable",
"(",
")",
"self",
".",
"nod",
".",
"disable",
"(",
")",
"self",
".",
"led",
".",
"disable",
"(",
")",
"self",
".",
"dumm... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | InstPars.unfreeze | Reverse of freeze | hcam_widgets/hcam.py | 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):
"""
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... | [
"Reverse",
"of",
"freeze"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L735-L749 | [
"def",
"unfreeze",
"(",
"self",
")",
":",
"self",
".",
"app",
".",
"enable",
"(",
")",
"self",
".",
"clear",
".",
"enable",
"(",
")",
"self",
".",
"nod",
".",
"enable",
"(",
")",
"self",
".",
"led",
".",
"enable",
"(",
")",
"self",
".",
"dummy"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | InstPars.getRtplotWins | 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 ... | hcam_widgets/hcam.py | 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):
""""
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... | [
"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",
... | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L751-L797 | [
"def",
"getRtplotWins",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"isFF",
"(",
")",
":",
"return",
"'fullframe\\r\\n'",
"elif",
"self",
".",
"isDrift",
"(",
")",
":",
"xbin",
"=",
"self",
".",
"wframe",
".",
"xbin",
".",
"value",
"(",
"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | InstPars.timing | 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... | hcam_widgets/hcam.py | 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):
"""
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 ... | [
"Estimates",
"timing",
"information",
"for",
"the",
"current",
"setup",
".",
"You",
"should",
"run",
"a",
"check",
"on",
"the",
"instrument",
"parameters",
"before",
"calling",
"this",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L799-L1009 | [
"def",
"timing",
"(",
"self",
")",
":",
"# drift mode y/n?",
"isDriftMode",
"=",
"self",
".",
"isDrift",
"(",
")",
"# FF y/n?",
"isFF",
"=",
"self",
".",
"isFF",
"(",
")",
"# Set the readout speed",
"readSpeed",
"=",
"self",
".",
"readSpeed",
"(",
")",
"if... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RunPars.loadJSON | Sets the values of the run parameters given an JSON string | hcam_widgets/hcam.py | 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):
"""
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:
... | [
"Sets",
"the",
"values",
"of",
"the",
"run",
"parameters",
"given",
"an",
"JSON",
"string"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1075-L1094 | [
"def",
"loadJSON",
"(",
"self",
",",
"json_string",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"user",
"=",
"json",
".",
"loads",
"(",
"json_string",
")",
"[",
"'user'",
"]",
"def",
"setField",
"(",
"widget",
",",
"field",
")",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RunPars.dumpJSON | Encodes current parameters to JSON compatible dictionary | hcam_widgets/hcam.py | 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):
"""
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'... | [
"Encodes",
"current",
"parameters",
"to",
"JSON",
"compatible",
"dictionary"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1096-L1120 | [
"def",
"dumpJSON",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"dtype",
"=",
"g",
".",
"observe",
".",
"rtype",
"(",
")",
"if",
"dtype",
"==",
"'bias'",
":",
"target",
"=",
"'BIAS'",
"elif",
"dtype",
"==",
"'flat'... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RunPars.check | 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. | hcam_widgets/hcam.py | 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):
"""
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... | [
"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",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1122-L1181 | [
"def",
"check",
"(",
"self",
",",
"*",
"args",
")",
":",
"ok",
"=",
"True",
"msg",
"=",
"''",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"dtype",
"=",
"g",
".",
"observe",
".",
"rtype",
"(",
")",
"expert",
"=",
"g",
".",
"cpars",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RunPars.freeze | Freeze all settings so that they can't be altered | hcam_widgets/hcam.py | 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):
"""
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')
... | [
"Freeze",
"all",
"settings",
"so",
"that",
"they",
"can",
"t",
"be",
"altered"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1195-L1204 | [
"def",
"freeze",
"(",
"self",
")",
":",
"self",
".",
"target",
".",
"disable",
"(",
")",
"self",
".",
"filter",
".",
"configure",
"(",
"state",
"=",
"'disable'",
")",
"self",
".",
"prog_ob",
".",
"configure",
"(",
"state",
"=",
"'disable'",
")",
"sel... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RunPars.unfreeze | Unfreeze all settings so that they can be altered | hcam_widgets/hcam.py | 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):
"""
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... | [
"Unfreeze",
"all",
"settings",
"so",
"that",
"they",
"can",
"be",
"altered"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1206-L1218 | [
"def",
"unfreeze",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"self",
".",
"filter",
".",
"configure",
"(",
"state",
"=",
"'normal'",
")",
"dtype",
"=",
"g",
".",
"observe",
".",
"rtype",
"(",
")",
"if",
"dtype",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | CountsFrame.checkUpdate | 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. | hcam_widgets/hcam.py | 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):
"""
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():
... | [
"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",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1314-L1327 | [
"def",
"checkUpdate",
"(",
"self",
",",
"*",
"args",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"if",
"not",
"self",
".",
"check",
"(",
")",
":",
"g",
".",
"clog",
".",
"warn",
"(",
"'Current observing parameters are not valid.'",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | CountsFrame.check | Checks values | hcam_widgets/hcam.py | 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):
"""
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():
... | [
"Checks",
"values"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1329-L1353 | [
"def",
"check",
"(",
"self",
")",
":",
"status",
"=",
"True",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"if",
"self",
".",
"mag",
".",
"ok",
"(",
")",
":",
"self",
".",
"mag",
".",
"config",
"(",
"bg",
"=",
"g",
".",
"COL",
"[",... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | CountsFrame.update | Updates values. You should run a check on the instrument and
target parameters before calling this. | hcam_widgets/hcam.py | 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):
"""
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... | [
"Updates",
"values",
".",
"You",
"should",
"run",
"a",
"check",
"on",
"the",
"instrument",
"and",
"target",
"parameters",
"before",
"calling",
"this",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1355-L1407 | [
"def",
"update",
"(",
"self",
",",
"*",
"args",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"expTime",
",",
"deadTime",
",",
"cycleTime",
",",
"dutyCycle",
",",
"frameRate",
"=",
"g",
".",
"ipars",
".",
"timing",
"(",
")",
"to... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | CountsFrame.counts | 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... | hcam_widgets/hcam.py | 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):
"""
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... | [
"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",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1409-L1515 | [
"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",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | Start.disable | Disable the button, if in non-expert mode. | hcam_widgets/hcam.py | 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):
"""
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']) | [
"Disable",
"the",
"button",
"if",
"in",
"non",
"-",
"expert",
"mode",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1592-L1601 | [
"def",
"disable",
"(",
"self",
")",
":",
"w",
".",
"ActButton",
".",
"disable",
"(",
"self",
")",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"if",
"self",
".",
"_expert",
":",
"self",
".",
"config",
"(",
"bg",
"=",
"g",
".",
"COL",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | Start.setExpert | Turns on 'expert' status whereby the button is always enabled,
regardless of its activity status. | hcam_widgets/hcam.py | 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):
"""
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']) | [
"Turns",
"on",
"expert",
"status",
"whereby",
"the",
"button",
"is",
"always",
"enabled",
"regardless",
"of",
"its",
"activity",
"status",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1603-L1610 | [
"def",
"setExpert",
"(",
"self",
")",
":",
"w",
".",
"ActButton",
".",
"setExpert",
"(",
"self",
")",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"self",
".",
"config",
"(",
"bg",
"=",
"g",
".",
"COL",
"[",
"'start'",
"]",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | Start.act | Carries out action associated with start button | hcam_widgets/hcam.py | 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):
"""
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 ... | [
"Carries",
"out",
"action",
"associated",
"with",
"start",
"button"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1622-L1700 | [
"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... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | Load.act | Carries out the action associated with the Load button | hcam_widgets/hcam.py | 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):
"""
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... | [
"Carries",
"out",
"the",
"action",
"associated",
"with",
"the",
"Load",
"button"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1716-L1742 | [
"def",
"act",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"fname",
"=",
"filedialog",
".",
"askopenfilename",
"(",
"defaultextension",
"=",
"'.json'",
",",
"filetypes",
"=",
"[",
"(",
"'json files'",
",",
"'.json'",
")"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | Save.act | Carries out the action associated with the Save button | hcam_widgets/hcam.py | 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):
"""
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... | [
"Carries",
"out",
"the",
"action",
"associated",
"with",
"the",
"Save",
"button"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1757-L1790 | [
"def",
"act",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"g",
".",
"clog",
".",
"info",
"(",
"'\\nSaving current application to disk'",
")",
"# check instrument parameters",
"if",
"not",
"g",
".",
"ipars",
".",
"check",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | Unfreeze.act | Carries out the action associated with the Unfreeze button | hcam_widgets/hcam.py | 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):
"""
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() | [
"Carries",
"out",
"the",
"action",
"associated",
"with",
"the",
"Unfreeze",
"button"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1804-L1812 | [
"def",
"act",
"(",
"self",
")",
":",
"g",
"=",
"get_root",
"(",
"self",
")",
".",
"globals",
"g",
".",
"ipars",
".",
"unfreeze",
"(",
")",
"g",
".",
"rpars",
".",
"unfreeze",
"(",
")",
"g",
".",
"observe",
".",
"load",
".",
"enable",
"(",
")",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | Observe.setExpertLevel | Set expert level | hcam_widgets/hcam.py | 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):
"""
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... | [
"Set",
"expert",
"level"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/hcam.py#L1846-L1866 | [
"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... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | process_factory_meta_options | 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... | py_meta_utils.py | 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) \
-> MetaOptionsFactory:
"""
Main entry point for consumer metaclasses. Usage::
from ... | [
"Main",
"entry",
"point",
"for",
"consumer",
"metaclasses",
".",
"Usage",
"::"
] | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L321-L386 | [
"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... | 8de20be00768b7749dc2207a98331a9f23187918 |
train | deep_getattr | 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... | py_meta_utils.py | 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... | [
"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... | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L437-L458 | [
"def",
"deep_getattr",
"(",
"clsdict",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
",",
"bases",
":",
"Tuple",
"[",
"Type",
"[",
"object",
"]",
",",
"...",
"]",
",",
"name",
":",
"str",
",",
"default",
":",
"Any",
"=",
"_missing",
")",
"->",
"Any",... | 8de20be00768b7749dc2207a98331a9f23187918 |
train | McsArgs.getattr | Convenience method equivalent to
``deep_getattr(mcs_args.clsdict, mcs_args.bases, 'attr_name'[, default])`` | py_meta_utils.py | 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):
"""
Convenience method equivalent to
``deep_getattr(mcs_args.clsdict, mcs_args.bases, 'attr_name'[, default])``
"""
return deep_getattr(self.clsdict, self.bases, name, default) | [
"Convenience",
"method",
"equivalent",
"to",
"deep_getattr",
"(",
"mcs_args",
".",
"clsdict",
"mcs_args",
".",
"bases",
"attr_name",
"[",
"default",
"]",
")"
] | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L42-L47 | [
"def",
"getattr",
"(",
"self",
",",
"name",
",",
"default",
":",
"Any",
"=",
"_missing",
")",
":",
"return",
"deep_getattr",
"(",
"self",
".",
"clsdict",
",",
"self",
".",
"bases",
",",
"name",
",",
"default",
")"
] | 8de20be00768b7749dc2207a98331a9f23187918 |
train | McsArgs.qualname | Returns the fully qualified name of the class-under-construction, if possible,
otherwise just the class name. | py_meta_utils.py | 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:
"""
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 | [
"Returns",
"the",
"fully",
"qualified",
"name",
"of",
"the",
"class",
"-",
"under",
"-",
"construction",
"if",
"possible",
"otherwise",
"just",
"the",
"class",
"name",
"."
] | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L57-L64 | [
"def",
"qualname",
"(",
"self",
")",
"->",
"str",
":",
"if",
"self",
".",
"module",
":",
"return",
"self",
".",
"module",
"+",
"'.'",
"+",
"self",
".",
"name",
"return",
"self",
".",
"name"
] | 8de20be00768b7749dc2207a98331a9f23187918 |
train | McsArgs.is_abstract | Whether or not the class-under-construction was declared as abstract (**NOTE:**
this property is usable even *before* the :class:`MetaOptionsFactory` has run) | py_meta_utils.py | 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:
"""
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... | [
"Whether",
"or",
"not",
"the",
"class",
"-",
"under",
"-",
"construction",
"was",
"declared",
"as",
"abstract",
"(",
"**",
"NOTE",
":",
"**",
"this",
"property",
"is",
"usable",
"even",
"*",
"before",
"*",
"the",
":",
"class",
":",
"MetaOptionsFactory",
... | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L76-L82 | [
"def",
"is_abstract",
"(",
"self",
")",
"->",
"bool",
":",
"meta_value",
"=",
"getattr",
"(",
"self",
".",
"clsdict",
".",
"get",
"(",
"'Meta'",
")",
",",
"'abstract'",
",",
"False",
")",
"return",
"self",
".",
"clsdict",
".",
"get",
"(",
"ABSTRACT_ATT... | 8de20be00768b7749dc2207a98331a9f23187918 |
train | MetaOption.get_value | 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... | py_meta_utils.py | 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:
"""
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... | [
"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",
... | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L113-L131 | [
"def",
"get_value",
"(",
"self",
",",
"Meta",
":",
"Type",
"[",
"object",
"]",
",",
"base_classes_meta",
",",
"mcs_args",
":",
"McsArgs",
")",
"->",
"Any",
":",
"value",
"=",
"self",
".",
"default",
"if",
"self",
".",
"inherit",
"and",
"base_classes_meta... | 8de20be00768b7749dc2207a98331a9f23187918 |
train | MetaOptionsFactory._get_meta_options | Returns a list of :class:`MetaOption` instances that this factory supports. | py_meta_utils.py | 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]:
"""
Returns a list of :class:`MetaOption` instances that this factory supports.
"""
return [option if isinstance(option, MetaOption) else option()
for option in self._options] | [
"Returns",
"a",
"list",
"of",
":",
"class",
":",
"MetaOption",
"instances",
"that",
"this",
"factory",
"supports",
"."
] | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L245-L250 | [
"def",
"_get_meta_options",
"(",
"self",
")",
"->",
"List",
"[",
"MetaOption",
"]",
":",
"return",
"[",
"option",
"if",
"isinstance",
"(",
"option",
",",
"MetaOption",
")",
"else",
"option",
"(",
")",
"for",
"option",
"in",
"self",
".",
"_options",
"]"
] | 8de20be00768b7749dc2207a98331a9f23187918 |
train | MetaOptionsFactory._contribute_to_class | 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... | py_meta_utils.py | 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):
"""
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,
... | [
"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",
")... | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L252-L273 | [
"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",... | 8de20be00768b7749dc2207a98331a9f23187918 |
train | MetaOptionsFactory._fill_from_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 unsupported meta options on the class-under-construction's
``class Meta``. | py_meta_utils.py | 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):
"""
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... | [
"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... | briancappello/py-meta-utils | python | https://github.com/briancappello/py-meta-utils/blob/8de20be00768b7749dc2207a98331a9f23187918/py_meta_utils.py#L275-L303 | [
"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"... | 8de20be00768b7749dc2207a98331a9f23187918 |
train | CORBAConnection.get_object | Get a reference to a remote object using CORBA | hcam_widgets/gtc/corba.py | 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):
"""
Get a reference to a remote object using CORBA
"""
return self._state.get_object(self, binding_name, cls) | [
"Get",
"a",
"reference",
"to",
"a",
"remote",
"object",
"using",
"CORBA"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/gtc/corba.py#L40-L44 | [
"def",
"get_object",
"(",
"self",
",",
"binding_name",
",",
"cls",
")",
":",
"return",
"self",
".",
"_state",
".",
"get_object",
"(",
"self",
",",
"binding_name",
",",
"cls",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | ReadyCORBAState.get_object | Get a reference to a remote object using CORBA | hcam_widgets/gtc/corba.py | 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):
"""
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... | [
"Get",
"a",
"reference",
"to",
"a",
"remote",
"object",
"using",
"CORBA"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/gtc/corba.py#L116-L129 | [
"def",
"get_object",
"(",
"conn",
",",
"binding_name",
",",
"object_cls",
")",
":",
"try",
":",
"obj",
"=",
"conn",
".",
"rootContext",
".",
"resolve",
"(",
"binding_name",
")",
"narrowed",
"=",
"obj",
".",
"_narrow",
"(",
"object_cls",
")",
"except",
"C... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | IntegerEntry.set | Sets the current value equal to num | hcam_widgets/widgets.py | def set(self, num):
"""
Sets the current value equal to num
"""
self._value = str(int(num))
self._variable.set(self._value) | def set(self, num):
"""
Sets the current value equal to num
"""
self._value = str(int(num))
self._variable.set(self._value) | [
"Sets",
"the",
"current",
"value",
"equal",
"to",
"num"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L142-L147 | [
"def",
"set",
"(",
"self",
",",
"num",
")",
":",
"self",
".",
"_value",
"=",
"str",
"(",
"int",
"(",
"num",
")",
")",
"self",
".",
"_variable",
".",
"set",
"(",
"self",
".",
"_value",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | IntegerEntry.on_key_release_repeat | Avoid repeated trigger of callback.
When holding a key down, multiple key press and release events
are fired in succession. Debouncing is implemented to squash these. | hcam_widgets/widgets.py | def on_key_release_repeat(self, *dummy):
"""
Avoid repeated trigger of callback.
When holding a key down, multiple key press and release events
are fired in succession. Debouncing is implemented to squash these.
"""
self.has_prev_key_release = self.after_idle(self.on_key... | def on_key_release_repeat(self, *dummy):
"""
Avoid repeated trigger of callback.
When holding a key down, multiple key press and release events
are fired in succession. Debouncing is implemented to squash these.
"""
self.has_prev_key_release = self.after_idle(self.on_key... | [
"Avoid",
"repeated",
"trigger",
"of",
"callback",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L192-L199 | [
"def",
"on_key_release_repeat",
"(",
"self",
",",
"*",
"dummy",
")",
":",
"self",
".",
"has_prev_key_release",
"=",
"self",
".",
"after_idle",
"(",
"self",
".",
"on_key_release",
",",
"dummy",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | IntegerEntry.set_bind | Sets key bindings. | hcam_widgets/widgets.py | def set_bind(self):
"""
Sets key bindings.
"""
# Arrow keys and enter
self.bind('<Up>', lambda e: self.on_key_press_repeat('Up'))
self.bind('<Down>', lambda e: self.on_key_press_repeat('Down'))
self.bind('<Shift-Up>', lambda e: self.on_key_press_repeat('Shift-Up')... | def set_bind(self):
"""
Sets key bindings.
"""
# Arrow keys and enter
self.bind('<Up>', lambda e: self.on_key_press_repeat('Up'))
self.bind('<Down>', lambda e: self.on_key_press_repeat('Down'))
self.bind('<Shift-Up>', lambda e: self.on_key_press_repeat('Shift-Up')... | [
"Sets",
"key",
"bindings",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L218-L252 | [
"def",
"set_bind",
"(",
"self",
")",
":",
"# Arrow keys and enter",
"self",
".",
"bind",
"(",
"'<Up>'",
",",
"lambda",
"e",
":",
"self",
".",
"on_key_press_repeat",
"(",
"'Up'",
")",
")",
"self",
".",
"bind",
"(",
"'<Down>'",
",",
"lambda",
"e",
":",
"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | IntegerEntry._pollMouse | Polls @10Hz, with a slight delay at the
start. | hcam_widgets/widgets.py | def _pollMouse(self):
"""
Polls @10Hz, with a slight delay at the
start.
"""
if self._mouseJustPressed:
delay = 300
self._mouseJustPressed = False
else:
delay = 100
if self._leftMousePressed:
self.add(1)
... | def _pollMouse(self):
"""
Polls @10Hz, with a slight delay at the
start.
"""
if self._mouseJustPressed:
delay = 300
self._mouseJustPressed = False
else:
delay = 100
if self._leftMousePressed:
self.add(1)
... | [
"Polls"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L302-L327 | [
"def",
"_pollMouse",
"(",
"self",
")",
":",
"if",
"self",
".",
"_mouseJustPressed",
":",
"delay",
"=",
"300",
"self",
".",
"_mouseJustPressed",
"=",
"False",
"else",
":",
"delay",
"=",
"100",
"if",
"self",
".",
"_leftMousePressed",
":",
"self",
".",
"add... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | IntegerEntry._callback | This gets called on any attempt to change the value | hcam_widgets/widgets.py | def _callback(self, *dummy):
"""
This gets called on any attempt to change the value
"""
# retrieve the value from the Entry
value = self._variable.get()
# run the validation. Returns None if no good
newvalue = self.validate(value)
if newvalue is None:
... | def _callback(self, *dummy):
"""
This gets called on any attempt to change the value
"""
# retrieve the value from the Entry
value = self._variable.get()
# run the validation. Returns None if no good
newvalue = self.validate(value)
if newvalue is None:
... | [
"This",
"gets",
"called",
"on",
"any",
"attempt",
"to",
"change",
"the",
"value"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L356-L378 | [
"def",
"_callback",
"(",
"self",
",",
"*",
"dummy",
")",
":",
"# retrieve the value from the Entry",
"value",
"=",
"self",
".",
"_variable",
".",
"get",
"(",
")",
"# run the validation. Returns None if no good",
"newvalue",
"=",
"self",
".",
"validate",
"(",
"valu... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | PosInt.set_bind | Sets key bindings -- we need this more than once | hcam_widgets/widgets.py | def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
IntegerEntry.set_bind(self)
self.bind('<Next>', lambda e: self.set(0)) | def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
IntegerEntry.set_bind(self)
self.bind('<Next>', lambda e: self.set(0)) | [
"Sets",
"key",
"bindings",
"--",
"we",
"need",
"this",
"more",
"than",
"once"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L416-L421 | [
"def",
"set_bind",
"(",
"self",
")",
":",
"IntegerEntry",
".",
"set_bind",
"(",
"self",
")",
"self",
".",
"bind",
"(",
"'<Next>'",
",",
"lambda",
"e",
":",
"self",
".",
"set",
"(",
"0",
")",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | PosInt.validate | Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes. | hcam_widgets/widgets.py | def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
v = int(value)
... | def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
v = int(value)
... | [
"Applies",
"the",
"validation",
"criteria",
".",
"Returns",
"value",
"new",
"value",
"or",
"None",
"if",
"invalid",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L430-L445 | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"# trap blank fields here",
"if",
"not",
"self",
".",
"blank",
"or",
"value",
":",
"v",
"=",
"int",
"(",
"value",
")",
"if",
"v",
"<",
"0",
":",
"return",
"None",
"return",
"value",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | PosInt.add | Adds num to the current value | hcam_widgets/widgets.py | def add(self, num):
"""
Adds num to the current value
"""
try:
val = self.value() + num
except:
val = num
self.set(max(0, val)) | def add(self, num):
"""
Adds num to the current value
"""
try:
val = self.value() + num
except:
val = num
self.set(max(0, val)) | [
"Adds",
"num",
"to",
"the",
"current",
"value"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L447-L455 | [
"def",
"add",
"(",
"self",
",",
"num",
")",
":",
"try",
":",
"val",
"=",
"self",
".",
"value",
"(",
")",
"+",
"num",
"except",
":",
"val",
"=",
"num",
"self",
".",
"set",
"(",
"max",
"(",
"0",
",",
"val",
")",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | PosInt.sub | Subtracts num from the current value | hcam_widgets/widgets.py | def sub(self, num):
"""
Subtracts num from the current value
"""
try:
val = self.value() - num
except:
val = -num
self.set(max(0, val)) | def sub(self, num):
"""
Subtracts num from the current value
"""
try:
val = self.value() - num
except:
val = -num
self.set(max(0, val)) | [
"Subtracts",
"num",
"from",
"the",
"current",
"value"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L457-L465 | [
"def",
"sub",
"(",
"self",
",",
"num",
")",
":",
"try",
":",
"val",
"=",
"self",
".",
"value",
"(",
")",
"-",
"num",
"except",
":",
"val",
"=",
"-",
"num",
"self",
".",
"set",
"(",
"max",
"(",
"0",
",",
"val",
")",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | PosInt.ok | Returns True if OK to use, else False | hcam_widgets/widgets.py | def ok(self):
"""
Returns True if OK to use, else False
"""
try:
v = int(self._value)
if v < 0:
return False
else:
return True
except:
return False | def ok(self):
"""
Returns True if OK to use, else False
"""
try:
v = int(self._value)
if v < 0:
return False
else:
return True
except:
return False | [
"Returns",
"True",
"if",
"OK",
"to",
"use",
"else",
"False"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L467-L478 | [
"def",
"ok",
"(",
"self",
")",
":",
"try",
":",
"v",
"=",
"int",
"(",
"self",
".",
"_value",
")",
"if",
"v",
"<",
"0",
":",
"return",
"False",
"else",
":",
"return",
"True",
"except",
":",
"return",
"False"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RangedInt.set_bind | Sets key bindings -- we need this more than once | hcam_widgets/widgets.py | def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
IntegerEntry.set_bind(self)
self.bind('<Next>', lambda e: self.set(self.imin))
self.bind('<Prior>', lambda e: self.set(self.imax)) | def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
IntegerEntry.set_bind(self)
self.bind('<Next>', lambda e: self.set(self.imin))
self.bind('<Prior>', lambda e: self.set(self.imax)) | [
"Sets",
"key",
"bindings",
"--",
"we",
"need",
"this",
"more",
"than",
"once"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L504-L510 | [
"def",
"set_bind",
"(",
"self",
")",
":",
"IntegerEntry",
".",
"set_bind",
"(",
"self",
")",
"self",
".",
"bind",
"(",
"'<Next>'",
",",
"lambda",
"e",
":",
"self",
".",
"set",
"(",
"self",
".",
"imin",
")",
")",
"self",
".",
"bind",
"(",
"'<Prior>'... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RangedInt.validate | Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes. | hcam_widgets/widgets.py | def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
v = int(value)
... | def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
v = int(value)
... | [
"Applies",
"the",
"validation",
"criteria",
".",
"Returns",
"value",
"new",
"value",
"or",
"None",
"if",
"invalid",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L520-L535 | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"# trap blank fields here",
"if",
"not",
"self",
".",
"blank",
"or",
"value",
":",
"v",
"=",
"int",
"(",
"value",
")",
"if",
"v",
"<",
"self",
".",
"imin",
"or",
"v",
">",
"self",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RangedInt.add | Adds num to the current value | hcam_widgets/widgets.py | def add(self, num):
"""
Adds num to the current value
"""
try:
val = self.value() + num
except:
val = num
self.set(min(self.imax, max(self.imin, val))) | def add(self, num):
"""
Adds num to the current value
"""
try:
val = self.value() + num
except:
val = num
self.set(min(self.imax, max(self.imin, val))) | [
"Adds",
"num",
"to",
"the",
"current",
"value"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L537-L545 | [
"def",
"add",
"(",
"self",
",",
"num",
")",
":",
"try",
":",
"val",
"=",
"self",
".",
"value",
"(",
")",
"+",
"num",
"except",
":",
"val",
"=",
"num",
"self",
".",
"set",
"(",
"min",
"(",
"self",
".",
"imax",
",",
"max",
"(",
"self",
".",
"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RangedInt.ok | Returns True if OK to use, else False | hcam_widgets/widgets.py | def ok(self):
"""
Returns True if OK to use, else False
"""
try:
v = int(self._value)
if v < self.imin or v > self.imax:
return False
else:
return True
except:
return False | def ok(self):
"""
Returns True if OK to use, else False
"""
try:
v = int(self._value)
if v < self.imin or v > self.imax:
return False
else:
return True
except:
return False | [
"Returns",
"True",
"if",
"OK",
"to",
"use",
"else",
"False"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L557-L568 | [
"def",
"ok",
"(",
"self",
")",
":",
"try",
":",
"v",
"=",
"int",
"(",
"self",
".",
"_value",
")",
"if",
"v",
"<",
"self",
".",
"imin",
"or",
"v",
">",
"self",
".",
"imax",
":",
"return",
"False",
"else",
":",
"return",
"True",
"except",
":",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RangedMint.set_bind | Sets key bindings -- we need this more than once | hcam_widgets/widgets.py | def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
RangedInt.set_bind(self)
self.unbind('<Next>')
self.unbind('<Prior>')
self.bind('<Next>', lambda e: self.set(self._min()))
self.bind('<Prior>', lambda e: self.set(self._max())) | def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
RangedInt.set_bind(self)
self.unbind('<Next>')
self.unbind('<Prior>')
self.bind('<Next>', lambda e: self.set(self._min()))
self.bind('<Prior>', lambda e: self.set(self._max())) | [
"Sets",
"key",
"bindings",
"--",
"we",
"need",
"this",
"more",
"than",
"once"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L589-L597 | [
"def",
"set_bind",
"(",
"self",
")",
":",
"RangedInt",
".",
"set_bind",
"(",
"self",
")",
"self",
".",
"unbind",
"(",
"'<Next>'",
")",
"self",
".",
"unbind",
"(",
"'<Prior>'",
")",
"self",
".",
"bind",
"(",
"'<Next>'",
",",
"lambda",
"e",
":",
"self"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RangedMint.add | Adds num to the current value, jumping up the next
multiple of mfac if the result is not a multiple already | hcam_widgets/widgets.py | def add(self, num):
"""
Adds num to the current value, jumping up the next
multiple of mfac if the result is not a multiple already
"""
try:
val = self.value() + num
except:
val = num
chunk = self.mfac.value()
if val % chunk > 0:
... | def add(self, num):
"""
Adds num to the current value, jumping up the next
multiple of mfac if the result is not a multiple already
"""
try:
val = self.value() + num
except:
val = num
chunk = self.mfac.value()
if val % chunk > 0:
... | [
"Adds",
"num",
"to",
"the",
"current",
"value",
"jumping",
"up",
"the",
"next",
"multiple",
"of",
"mfac",
"if",
"the",
"result",
"is",
"not",
"a",
"multiple",
"already"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L607-L625 | [
"def",
"add",
"(",
"self",
",",
"num",
")",
":",
"try",
":",
"val",
"=",
"self",
".",
"value",
"(",
")",
"+",
"num",
"except",
":",
"val",
"=",
"num",
"chunk",
"=",
"self",
".",
"mfac",
".",
"value",
"(",
")",
"if",
"val",
"%",
"chunk",
">",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | RangedMint.ok | Returns True if OK to use, else False | hcam_widgets/widgets.py | def ok(self):
"""
Returns True if OK to use, else False
"""
try:
v = int(self._value)
chunk = self.mfac.value()
if v < self.imin or v > self.imax or (v % chunk != 0):
return False
else:
return True
ex... | def ok(self):
"""
Returns True if OK to use, else False
"""
try:
v = int(self._value)
chunk = self.mfac.value()
if v < self.imin or v > self.imax or (v % chunk != 0):
return False
else:
return True
ex... | [
"Returns",
"True",
"if",
"OK",
"to",
"use",
"else",
"False"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L647-L659 | [
"def",
"ok",
"(",
"self",
")",
":",
"try",
":",
"v",
"=",
"int",
"(",
"self",
".",
"_value",
")",
"chunk",
"=",
"self",
".",
"mfac",
".",
"value",
"(",
")",
"if",
"v",
"<",
"self",
".",
"imin",
"or",
"v",
">",
"self",
".",
"imax",
"or",
"("... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | ListInt.set_bind | Sets key bindings -- we need this more than once | hcam_widgets/widgets.py | def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
IntegerEntry.set_bind(self)
self.unbind('<Shift-Up>')
self.unbind('<Shift-Down>')
self.unbind('<Control-Up>')
self.unbind('<Control-Down>')
self.unbind('<Double-Button-1>'... | def set_bind(self):
"""
Sets key bindings -- we need this more than once
"""
IntegerEntry.set_bind(self)
self.unbind('<Shift-Up>')
self.unbind('<Shift-Down>')
self.unbind('<Control-Up>')
self.unbind('<Control-Down>')
self.unbind('<Double-Button-1>'... | [
"Sets",
"key",
"bindings",
"--",
"we",
"need",
"this",
"more",
"than",
"once"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L697-L719 | [
"def",
"set_bind",
"(",
"self",
")",
":",
"IntegerEntry",
".",
"set_bind",
"(",
"self",
")",
"self",
".",
"unbind",
"(",
"'<Shift-Up>'",
")",
"self",
".",
"unbind",
"(",
"'<Shift-Down>'",
")",
"self",
".",
"unbind",
"(",
"'<Control-Up>'",
")",
"self",
".... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | ListInt.set_unbind | Unsets key bindings -- we need this more than once | hcam_widgets/widgets.py | def set_unbind(self):
"""
Unsets key bindings -- we need this more than once
"""
IntegerEntry.set_unbind(self)
self.unbind('<Button-1>')
self.unbind('<Button-3>')
self.unbind('<Up>')
self.unbind('<Down>')
self.unbind('<Enter>')
self.unbind(... | def set_unbind(self):
"""
Unsets key bindings -- we need this more than once
"""
IntegerEntry.set_unbind(self)
self.unbind('<Button-1>')
self.unbind('<Button-3>')
self.unbind('<Up>')
self.unbind('<Down>')
self.unbind('<Enter>')
self.unbind(... | [
"Unsets",
"key",
"bindings",
"--",
"we",
"need",
"this",
"more",
"than",
"once"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L721-L732 | [
"def",
"set_unbind",
"(",
"self",
")",
":",
"IntegerEntry",
".",
"set_unbind",
"(",
"self",
")",
"self",
".",
"unbind",
"(",
"'<Button-1>'",
")",
"self",
".",
"unbind",
"(",
"'<Button-3>'",
")",
"self",
".",
"unbind",
"(",
"'<Up>'",
")",
"self",
".",
"... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | ListInt.validate | Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes. | hcam_widgets/widgets.py | def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
v = int(value)
if v not in self.allowed:
return None
return value
... | def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
v = int(value)
if v not in self.allowed:
return None
return value
... | [
"Applies",
"the",
"validation",
"criteria",
".",
"Returns",
"value",
"new",
"value",
"or",
"None",
"if",
"invalid",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L734-L747 | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"v",
"=",
"int",
"(",
"value",
")",
"if",
"v",
"not",
"in",
"self",
".",
"allowed",
":",
"return",
"None",
"return",
"value",
"except",
"ValueError",
":",
"return",
"None"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | ListInt.set | Sets current value to num | hcam_widgets/widgets.py | def set(self, num):
"""
Sets current value to num
"""
if self.validate(num) is not None:
self.index = self.allowed.index(num)
IntegerEntry.set(self, num) | def set(self, num):
"""
Sets current value to num
"""
if self.validate(num) is not None:
self.index = self.allowed.index(num)
IntegerEntry.set(self, num) | [
"Sets",
"current",
"value",
"to",
"num"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L749-L755 | [
"def",
"set",
"(",
"self",
",",
"num",
")",
":",
"if",
"self",
".",
"validate",
"(",
"num",
")",
"is",
"not",
"None",
":",
"self",
".",
"index",
"=",
"self",
".",
"allowed",
".",
"index",
"(",
"num",
")",
"IntegerEntry",
".",
"set",
"(",
"self",
... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | ListInt.add | Adds num to the current value | hcam_widgets/widgets.py | def add(self, num):
"""
Adds num to the current value
"""
self.index = max(0, min(len(self.allowed)-1, self.index+num))
self.set(self.allowed[self.index]) | def add(self, num):
"""
Adds num to the current value
"""
self.index = max(0, min(len(self.allowed)-1, self.index+num))
self.set(self.allowed[self.index]) | [
"Adds",
"num",
"to",
"the",
"current",
"value"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L757-L762 | [
"def",
"add",
"(",
"self",
",",
"num",
")",
":",
"self",
".",
"index",
"=",
"max",
"(",
"0",
",",
"min",
"(",
"len",
"(",
"self",
".",
"allowed",
")",
"-",
"1",
",",
"self",
".",
"index",
"+",
"num",
")",
")",
"self",
".",
"set",
"(",
"self... | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | FloatEntry.validate | Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes. | hcam_widgets/widgets.py | def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
float(value)
... | def validate(self, value):
"""
Applies the validation criteria.
Returns value, new value, or None if invalid.
Overload this in derived classes.
"""
try:
# trap blank fields here
if not self.blank or value:
float(value)
... | [
"Applies",
"the",
"validation",
"criteria",
".",
"Returns",
"value",
"new",
"value",
"or",
"None",
"if",
"invalid",
"."
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L810-L823 | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"try",
":",
"# trap blank fields here",
"if",
"not",
"self",
".",
"blank",
"or",
"value",
":",
"float",
"(",
"value",
")",
"return",
"value",
"except",
"ValueError",
":",
"return",
"None"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
train | FloatEntry.set | Sets the current value equal to num | hcam_widgets/widgets.py | def set(self, num):
"""
Sets the current value equal to num
"""
self._value = str(round(float(num), self.nplaces))
self._variable.set(self._value) | def set(self, num):
"""
Sets the current value equal to num
"""
self._value = str(round(float(num), self.nplaces))
self._variable.set(self._value) | [
"Sets",
"the",
"current",
"value",
"equal",
"to",
"num"
] | HiPERCAM/hcam_widgets | python | https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/widgets.py#L834-L839 | [
"def",
"set",
"(",
"self",
",",
"num",
")",
":",
"self",
".",
"_value",
"=",
"str",
"(",
"round",
"(",
"float",
"(",
"num",
")",
",",
"self",
".",
"nplaces",
")",
")",
"self",
".",
"_variable",
".",
"set",
"(",
"self",
".",
"_value",
")"
] | 7219f0d96dd3a8ebe3139c7f542a72c02d02fce8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.