repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
jldantas/libmft | libmft/attribute.py | _from_binary_obj_ace | def _from_binary_obj_ace(cls, binary_stream):
"""See base class."""
''' Access rights flags - 4
Flags - 4
Object type class identifier (GUID) - 16
Inherited object type class identifier (GUID) - 16
SID - n
'''
#content = cls._REPR.unpack(binary_stream[:cls._REPR.size])
... | python | def _from_binary_obj_ace(cls, binary_stream):
"""See base class."""
''' Access rights flags - 4
Flags - 4
Object type class identifier (GUID) - 16
Inherited object type class identifier (GUID) - 16
SID - n
'''
#content = cls._REPR.unpack(binary_stream[:cls._REPR.size])
... | [
"def",
"_from_binary_obj_ace",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Access rights flags - 4\n Flags - 4\n Object type class identifier (GUID) - 16\n Inherited object type class identifier (GUID) - 16\n SID - n\n '''",
"#content = cls._REPR.unpack(binary_s... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L2071-L2085 |
jldantas/libmft | libmft/attribute.py | _from_binary_acl | def _from_binary_acl(cls, binary_stream):
"""See base class."""
''' Revision number - 1
Padding - 1
Size - 2
ACE Count - 2
Padding - 2
'''
rev_number, size, ace_len = cls._REPR.unpack(binary_stream[:cls._REPR.size])
#content = cls._REPR.unpack(binary_stream[:cls._REPR... | python | def _from_binary_acl(cls, binary_stream):
"""See base class."""
''' Revision number - 1
Padding - 1
Size - 2
ACE Count - 2
Padding - 2
'''
rev_number, size, ace_len = cls._REPR.unpack(binary_stream[:cls._REPR.size])
#content = cls._REPR.unpack(binary_stream[:cls._REPR... | [
"def",
"_from_binary_acl",
"(",
"cls",
",",
"binary_stream",
")",
":",
"''' Revision number - 1\n Padding - 1\n Size - 2\n ACE Count - 2\n Padding - 2\n '''",
"rev_number",
",",
"size",
",",
"ace_len",
"=",
"cls",
".",
"_REPR",
".",
"unpack",
"(... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L2190-L2212 |
jldantas/libmft | libmft/attribute.py | _from_binary_sec_desc | def _from_binary_sec_desc(cls, binary_stream):
"""See base class."""
header = SecurityDescriptorHeader.create_from_binary(binary_stream[:SecurityDescriptorHeader.get_representation_size()])
owner_sid = SID.create_from_binary(binary_stream[header.owner_sid_offset:])
group_sid = SID.create_from_binary(bi... | python | def _from_binary_sec_desc(cls, binary_stream):
"""See base class."""
header = SecurityDescriptorHeader.create_from_binary(binary_stream[:SecurityDescriptorHeader.get_representation_size()])
owner_sid = SID.create_from_binary(binary_stream[header.owner_sid_offset:])
group_sid = SID.create_from_binary(bi... | [
"def",
"_from_binary_sec_desc",
"(",
"cls",
",",
"binary_stream",
")",
":",
"header",
"=",
"SecurityDescriptorHeader",
".",
"create_from_binary",
"(",
"binary_stream",
"[",
":",
"SecurityDescriptorHeader",
".",
"get_representation_size",
"(",
")",
"]",
")",
"owner_sid... | See base class. | [
"See",
"base",
"class",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L2250-L2266 |
jldantas/libmft | libmft/attribute.py | _len_sec_desc | def _len_sec_desc(self):
'''Returns the logical size of the file'''
return len(self.header) + len(self.owner_sid) + len(self.group_sid) + len(self.sacl) + len(self.dacl) | python | def _len_sec_desc(self):
'''Returns the logical size of the file'''
return len(self.header) + len(self.owner_sid) + len(self.group_sid) + len(self.sacl) + len(self.dacl) | [
"def",
"_len_sec_desc",
"(",
"self",
")",
":",
"return",
"len",
"(",
"self",
".",
"header",
")",
"+",
"len",
"(",
"self",
".",
"owner_sid",
")",
"+",
"len",
"(",
"self",
".",
"group_sid",
")",
"+",
"len",
"(",
"self",
".",
"sacl",
")",
"+",
"len"... | Returns the logical size of the file | [
"Returns",
"the",
"logical",
"size",
"of",
"the",
"file"
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L2269-L2271 |
jldantas/libmft | libmft/attribute.py | DataRuns.create_from_binary | def create_from_binary(cls, binary_view):
'''Creates a new object DataRuns from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | python | def create_from_binary(cls, binary_view):
'''Creates a new object DataRuns from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | [
"def",
"create_from_binary",
"(",
"cls",
",",
"binary_view",
")",
":",
"nw_obj",
"=",
"cls",
"(",
")",
"offset",
"=",
"0",
"previous_dr_offset",
"=",
"0",
"header_size",
"=",
"cls",
".",
"_INFO",
".",
"size",
"#\"header\" of a data run is always a byte",
"while"... | Creates a new object DataRuns from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
information of the attribute
Returns... | [
"Creates",
"a",
"new",
"object",
"DataRuns",
"from",
"a",
"binary",
"stream",
".",
"The",
"binary",
"stream",
"can",
"be",
"represented",
"by",
"a",
"byte",
"string",
"bytearray",
"or",
"a",
"memoryview",
"of",
"the",
"bytearray",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L276-L311 |
jldantas/libmft | libmft/attribute.py | ResidentAttrHeader.create_from_binary | def create_from_binary(cls, binary_view):
'''Creates a new object AttributeHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | python | def create_from_binary(cls, binary_view):
'''Creates a new object AttributeHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
... | [
"def",
"create_from_binary",
"(",
"cls",
",",
"binary_view",
")",
":",
"attr_type",
",",
"attr_len",
",",
"non_resident",
",",
"name_len",
",",
"name_offset",
",",
"flags",
",",
"attr_id",
",",
"content_len",
",",
"content_offset",
",",
"indexed_flag",
"=",
"c... | Creates a new object AttributeHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
binary_view (memoryview of bytearray) - A binary stream with the
information of the attribute
... | [
"Creates",
"a",
"new",
"object",
"AttributeHeader",
"from",
"a",
"binary",
"stream",
".",
"The",
"binary",
"stream",
"can",
"be",
"represented",
"by",
"a",
"byte",
"string",
"bytearray",
"or",
"a",
"memoryview",
"of",
"the",
"bytearray",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L470-L493 |
jldantas/libmft | libmft/attribute.py | NonResidentAttrHeader.create_from_binary | def create_from_binary(cls, load_dataruns, binary_view):
'''Creates a new object NonResidentAttrHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
load_dataruns (bool) - Indicates if the datar... | python | def create_from_binary(cls, load_dataruns, binary_view):
'''Creates a new object NonResidentAttrHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
load_dataruns (bool) - Indicates if the datar... | [
"def",
"create_from_binary",
"(",
"cls",
",",
"load_dataruns",
",",
"binary_view",
")",
":",
"attr_type",
",",
"attr_len",
",",
"non_resident",
",",
"name_len",
",",
"name_offset",
",",
"flags",
",",
"attr_id",
",",
"start_vcn",
",",
"end_vcn",
",",
"rl_offset... | Creates a new object NonResidentAttrHeader from a binary stream. The binary
stream can be represented by a byte string, bytearray or a memoryview of the
bytearray.
Args:
load_dataruns (bool) - Indicates if the dataruns are to be loaded
binary_view (memoryview of bytearra... | [
"Creates",
"a",
"new",
"object",
"NonResidentAttrHeader",
"from",
"a",
"binary",
"stream",
".",
"The",
"binary",
"stream",
"can",
"be",
"represented",
"by",
"a",
"byte",
"string",
"bytearray",
"or",
"a",
"memoryview",
"of",
"the",
"bytearray",
"."
] | train | https://github.com/jldantas/libmft/blob/65a988605fe7663b788bd81dcb52c0a4eaad1549/libmft/attribute.py#L561-L593 |
openbermuda/ripl | ripl/slide2png.py | Slide2png.interpret | def interpret(self, msg):
""" Load input """
slides = msg.get('slides', [])
self.cache = msg.get('folder', '.')
self.gallery = msg.get('gallery', ['..'])
self.finder.interpret(dict(galleries=self.gallery))
# in case slides is a generator, turn it into a list
# si... | python | def interpret(self, msg):
""" Load input """
slides = msg.get('slides', [])
self.cache = msg.get('folder', '.')
self.gallery = msg.get('gallery', ['..'])
self.finder.interpret(dict(galleries=self.gallery))
# in case slides is a generator, turn it into a list
# si... | [
"def",
"interpret",
"(",
"self",
",",
"msg",
")",
":",
"slides",
"=",
"msg",
".",
"get",
"(",
"'slides'",
",",
"[",
"]",
")",
"self",
".",
"cache",
"=",
"msg",
".",
"get",
"(",
"'folder'",
",",
"'.'",
")",
"self",
".",
"gallery",
"=",
"msg",
".... | Load input | [
"Load",
"input"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L30-L56 |
openbermuda/ripl | ripl/slide2png.py | Slide2png.write_slide_list | def write_slide_list(self, logname, slides):
""" Write list of slides to logfile """
# Write slides.txt with list of slides
with open('%s/%s' % (self.cache, logname), 'w') as logfile:
for slide in slides:
heading = slide['heading']['text']
filename = s... | python | def write_slide_list(self, logname, slides):
""" Write list of slides to logfile """
# Write slides.txt with list of slides
with open('%s/%s' % (self.cache, logname), 'w') as logfile:
for slide in slides:
heading = slide['heading']['text']
filename = s... | [
"def",
"write_slide_list",
"(",
"self",
",",
"logname",
",",
"slides",
")",
":",
"# Write slides.txt with list of slides",
"with",
"open",
"(",
"'%s/%s'",
"%",
"(",
"self",
".",
"cache",
",",
"logname",
")",
",",
"'w'",
")",
"as",
"logfile",
":",
"for",
"s... | Write list of slides to logfile | [
"Write",
"list",
"of",
"slides",
"to",
"logfile"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L58-L67 |
openbermuda/ripl | ripl/slide2png.py | Slide2png.draw_slide | def draw_slide(self, slide):
""" Return layout information for slide """
image = Image.new('RGB', (WIDTH, HEIGHT), 'black')
draw = ImageDraw.Draw(image)
draw.font = self.font
self.draw_slide_text(draw, slide)
self.draw_slide_images(draw, slide, image)
... | python | def draw_slide(self, slide):
""" Return layout information for slide """
image = Image.new('RGB', (WIDTH, HEIGHT), 'black')
draw = ImageDraw.Draw(image)
draw.font = self.font
self.draw_slide_text(draw, slide)
self.draw_slide_images(draw, slide, image)
... | [
"def",
"draw_slide",
"(",
"self",
",",
"slide",
")",
":",
"image",
"=",
"Image",
".",
"new",
"(",
"'RGB'",
",",
"(",
"WIDTH",
",",
"HEIGHT",
")",
",",
"'black'",
")",
"draw",
"=",
"ImageDraw",
".",
"Draw",
"(",
"image",
")",
"draw",
".",
"font",
... | Return layout information for slide | [
"Return",
"layout",
"information",
"for",
"slide"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L69-L80 |
openbermuda/ripl | ripl/slide2png.py | Slide2png.rotate | def rotate(self, img):
""" Rotate image if exif says it needs it """
try:
exif = image2exif.get_exif(img)
except AttributeError:
# image format doesn't support exif
return img
orientation = exif.get('Orientation', 1)
landscape = img.h... | python | def rotate(self, img):
""" Rotate image if exif says it needs it """
try:
exif = image2exif.get_exif(img)
except AttributeError:
# image format doesn't support exif
return img
orientation = exif.get('Orientation', 1)
landscape = img.h... | [
"def",
"rotate",
"(",
"self",
",",
"img",
")",
":",
"try",
":",
"exif",
"=",
"image2exif",
".",
"get_exif",
"(",
"img",
")",
"except",
"AttributeError",
":",
"# image format doesn't support exif",
"return",
"img",
"orientation",
"=",
"exif",
".",
"get",
"(",... | Rotate image if exif says it needs it | [
"Rotate",
"image",
"if",
"exif",
"says",
"it",
"needs",
"it"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L147-L163 |
openbermuda/ripl | ripl/slide2png.py | Slide2png.draw_image | def draw_image(self, image, item, source):
""" Add an image to the image """
top, left = item['top'], item['left']
width, height = item['width'], item['height']
image_file = item['image']
img = Image.open(source)
img = self.rotate(img)
iwidth, iheight = img.siz... | python | def draw_image(self, image, item, source):
""" Add an image to the image """
top, left = item['top'], item['left']
width, height = item['width'], item['height']
image_file = item['image']
img = Image.open(source)
img = self.rotate(img)
iwidth, iheight = img.siz... | [
"def",
"draw_image",
"(",
"self",
",",
"image",
",",
"item",
",",
"source",
")",
":",
"top",
",",
"left",
"=",
"item",
"[",
"'top'",
"]",
",",
"item",
"[",
"'left'",
"]",
"width",
",",
"height",
"=",
"item",
"[",
"'width'",
"]",
",",
"item",
"[",... | Add an image to the image | [
"Add",
"an",
"image",
"to",
"the",
"image"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L166-L198 |
openbermuda/ripl | ripl/slide2png.py | Slide2png.slugify | def slugify(self, name):
""" Turn name into a slug suitable for an image file name """
slug = ''
last = ''
for char in name.replace('#', '').lower().strip():
if not char.isalnum():
char = '_'
if last == '_' and char == '_':
continu... | python | def slugify(self, name):
""" Turn name into a slug suitable for an image file name """
slug = ''
last = ''
for char in name.replace('#', '').lower().strip():
if not char.isalnum():
char = '_'
if last == '_' and char == '_':
continu... | [
"def",
"slugify",
"(",
"self",
",",
"name",
")",
":",
"slug",
"=",
"''",
"last",
"=",
"''",
"for",
"char",
"in",
"name",
".",
"replace",
"(",
"'#'",
",",
"''",
")",
".",
"lower",
"(",
")",
".",
"strip",
"(",
")",
":",
"if",
"not",
"char",
"."... | Turn name into a slug suitable for an image file name | [
"Turn",
"name",
"into",
"a",
"slug",
"suitable",
"for",
"an",
"image",
"file",
"name"
] | train | https://github.com/openbermuda/ripl/blob/4886b1a697e4b81c2202db9cb977609e034f8e70/ripl/slide2png.py#L201-L215 |
hapylestat/apputils | apputils/utils/storages/in_memory.py | InMemoryKeyStore.list_keys | def list_keys(self):
"""
Returns list of the available keys
:return: List of the keys available in the storage
:rtype list
"""
return [k for k, el in self._keystore.items() if not el.is_expired] | python | def list_keys(self):
"""
Returns list of the available keys
:return: List of the keys available in the storage
:rtype list
"""
return [k for k, el in self._keystore.items() if not el.is_expired] | [
"def",
"list_keys",
"(",
"self",
")",
":",
"return",
"[",
"k",
"for",
"k",
",",
"el",
"in",
"self",
".",
"_keystore",
".",
"items",
"(",
")",
"if",
"not",
"el",
".",
"is_expired",
"]"
] | Returns list of the available keys
:return: List of the keys available in the storage
:rtype list | [
"Returns",
"list",
"of",
"the",
"available",
"keys"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/utils/storages/in_memory.py#L59-L66 |
hapylestat/apputils | apputils/utils/storages/in_memory.py | InMemoryKeyStore.set | def set(self, key, value, expire_in=None):
"""
Function to set or change particular property in the storage
:param key: key name
:param value: value to set
:param expire_in: seconds to expire key
:type key str
:type expire_in int
"""
if key not in self._keystore:
self._keysto... | python | def set(self, key, value, expire_in=None):
"""
Function to set or change particular property in the storage
:param key: key name
:param value: value to set
:param expire_in: seconds to expire key
:type key str
:type expire_in int
"""
if key not in self._keystore:
self._keysto... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
",",
"expire_in",
"=",
"None",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_keystore",
":",
"self",
".",
"_keystore",
"[",
"key",
"]",
"=",
"InMemoryItemValue",
"(",
"expire_in",
"=",
"expire... | Function to set or change particular property in the storage
:param key: key name
:param value: value to set
:param expire_in: seconds to expire key
:type key str
:type expire_in int | [
"Function",
"to",
"set",
"or",
"change",
"particular",
"property",
"in",
"the",
"storage"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/utils/storages/in_memory.py#L68-L84 |
hapylestat/apputils | apputils/utils/storages/in_memory.py | InMemoryKeyStore.get | def get(self, key):
"""
Retrieves previously stored key from the storage
:return value, stored in the storage
"""
if key not in self._keystore:
return None
rec = self._keystore[key]
""":type rec InMemoryItemValue"""
if rec.is_expired:
self.delete(key)
return None
... | python | def get(self, key):
"""
Retrieves previously stored key from the storage
:return value, stored in the storage
"""
if key not in self._keystore:
return None
rec = self._keystore[key]
""":type rec InMemoryItemValue"""
if rec.is_expired:
self.delete(key)
return None
... | [
"def",
"get",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"not",
"in",
"self",
".",
"_keystore",
":",
"return",
"None",
"rec",
"=",
"self",
".",
"_keystore",
"[",
"key",
"]",
"\"\"\":type rec InMemoryItemValue\"\"\"",
"if",
"rec",
".",
"is_expired",
... | Retrieves previously stored key from the storage
:return value, stored in the storage | [
"Retrieves",
"previously",
"stored",
"key",
"from",
"the",
"storage"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/utils/storages/in_memory.py#L86-L102 |
hapylestat/apputils | apputils/utils/storages/in_memory.py | InMemoryKeyStore.exists | def exists(self, key):
"""
Check if the particular key exists in the storage
:param key: name of the key which existence need to be checked
:return:
:type key str
:rtype bool
"""
if key in self._keystore and not self._keystore[key].is_expired:
return True
elif key in self._ke... | python | def exists(self, key):
"""
Check if the particular key exists in the storage
:param key: name of the key which existence need to be checked
:return:
:type key str
:rtype bool
"""
if key in self._keystore and not self._keystore[key].is_expired:
return True
elif key in self._ke... | [
"def",
"exists",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"_keystore",
"and",
"not",
"self",
".",
"_keystore",
"[",
"key",
"]",
".",
"is_expired",
":",
"return",
"True",
"elif",
"key",
"in",
"self",
".",
"_keystore",
"and",
... | Check if the particular key exists in the storage
:param key: name of the key which existence need to be checked
:return:
:type key str
:rtype bool | [
"Check",
"if",
"the",
"particular",
"key",
"exists",
"in",
"the",
"storage"
] | train | https://github.com/hapylestat/apputils/blob/5d185616feda27e6e21273307161471ef11a3518/apputils/utils/storages/in_memory.py#L104-L120 |
calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.parse_data_to_internal | def parse_data_to_internal(self, include_custom=False):
"""
Invoke parse_data_to_internal() for every element
in self.data
"""
for element in self.data:
self.data[element].parse_data_to_internal()
if include_custom:
for element in self.custom_data:... | python | def parse_data_to_internal(self, include_custom=False):
"""
Invoke parse_data_to_internal() for every element
in self.data
"""
for element in self.data:
self.data[element].parse_data_to_internal()
if include_custom:
for element in self.custom_data:... | [
"def",
"parse_data_to_internal",
"(",
"self",
",",
"include_custom",
"=",
"False",
")",
":",
"for",
"element",
"in",
"self",
".",
"data",
":",
"self",
".",
"data",
"[",
"element",
"]",
".",
"parse_data_to_internal",
"(",
")",
"if",
"include_custom",
":",
"... | Invoke parse_data_to_internal() for every element
in self.data | [
"Invoke",
"parse_data_to_internal",
"()",
"for",
"every",
"element",
"in",
"self",
".",
"data"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L49-L58 |
calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.plot_2d_single | def plot_2d_single(x, y, pdffilename, **kwargs):
"""
Do make_2d_single_plot and pass all arguments
args:
x: array_like
xdata
y: array_like
ydata
filepath: string
filepath of pdf to save
**kwargs:
... | python | def plot_2d_single(x, y, pdffilename, **kwargs):
"""
Do make_2d_single_plot and pass all arguments
args:
x: array_like
xdata
y: array_like
ydata
filepath: string
filepath of pdf to save
**kwargs:
... | [
"def",
"plot_2d_single",
"(",
"x",
",",
"y",
",",
"pdffilename",
",",
"*",
"*",
"kwargs",
")",
":",
"pdffilepath",
"=",
"DataSets",
".",
"get_pdffilepath",
"(",
"pdffilename",
")",
"plotsingle2d",
"=",
"PlotSingle2D",
"(",
"x",
",",
"y",
",",
"pdffilepath"... | Do make_2d_single_plot and pass all arguments
args:
x: array_like
xdata
y: array_like
ydata
filepath: string
filepath of pdf to save
**kwargs:
figure_options: passed to matplotlib.pyplot.figure
... | [
"Do",
"make_2d_single_plot",
"and",
"pass",
"all",
"arguments"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L73-L129 |
calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.get_pdffilepath | def get_pdffilepath(pdffilename):
"""
Returns the path for the pdf file
args:
pdffilename: string
returns path for the plots folder / pdffilename.pdf
"""
return FILEPATHSTR.format(
root_dir=ROOT_DIR, os_sep=os.sep, os_extsep=os.extsep,
... | python | def get_pdffilepath(pdffilename):
"""
Returns the path for the pdf file
args:
pdffilename: string
returns path for the plots folder / pdffilename.pdf
"""
return FILEPATHSTR.format(
root_dir=ROOT_DIR, os_sep=os.sep, os_extsep=os.extsep,
... | [
"def",
"get_pdffilepath",
"(",
"pdffilename",
")",
":",
"return",
"FILEPATHSTR",
".",
"format",
"(",
"root_dir",
"=",
"ROOT_DIR",
",",
"os_sep",
"=",
"os",
".",
"sep",
",",
"os_extsep",
"=",
"os",
".",
"extsep",
",",
"name",
"=",
"pdffilename",
",",
"fol... | Returns the path for the pdf file
args:
pdffilename: string
returns path for the plots folder / pdffilename.pdf | [
"Returns",
"the",
"path",
"for",
"the",
"pdf",
"file"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L132-L145 |
calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.make_tex_table | def make_tex_table(inputlist, outputfilename, fmt=None, **kwargs):
"""
Do make_tex_table and pass all arguments
args:
inputlist: list
outputfilename: string
fmt: dictionary
key: integer
column index starting with 0
... | python | def make_tex_table(inputlist, outputfilename, fmt=None, **kwargs):
"""
Do make_tex_table and pass all arguments
args:
inputlist: list
outputfilename: string
fmt: dictionary
key: integer
column index starting with 0
... | [
"def",
"make_tex_table",
"(",
"inputlist",
",",
"outputfilename",
",",
"fmt",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"outputfilepath",
"=",
"FILEPATHSTR",
".",
"format",
"(",
"root_dir",
"=",
"ROOT_DIR",
",",
"os_sep",
"=",
"os",
".",
"sep",
","... | Do make_tex_table and pass all arguments
args:
inputlist: list
outputfilename: string
fmt: dictionary
key: integer
column index starting with 0
values: string
format string. eg "{:g}"
**kwarg... | [
"Do",
"make_tex_table",
"and",
"pass",
"all",
"arguments"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L148-L171 |
calvinku96/labreporthelper | labreporthelper/dataset.py | DataSets.make_compute_file | def make_compute_file(self):
"""
Make the compute file from the self.vardict and self.vardictformat
"""
string = ""
try:
vardict_items = self.vardict.iteritems()
except AttributeError:
vardict_items = self.vardict.items()
for key, val in va... | python | def make_compute_file(self):
"""
Make the compute file from the self.vardict and self.vardictformat
"""
string = ""
try:
vardict_items = self.vardict.iteritems()
except AttributeError:
vardict_items = self.vardict.items()
for key, val in va... | [
"def",
"make_compute_file",
"(",
"self",
")",
":",
"string",
"=",
"\"\"",
"try",
":",
"vardict_items",
"=",
"self",
".",
"vardict",
".",
"iteritems",
"(",
")",
"except",
"AttributeError",
":",
"vardict_items",
"=",
"self",
".",
"vardict",
".",
"items",
"("... | Make the compute file from the self.vardict and self.vardictformat | [
"Make",
"the",
"compute",
"file",
"from",
"the",
"self",
".",
"vardict",
"and",
"self",
".",
"vardictformat"
] | train | https://github.com/calvinku96/labreporthelper/blob/4d436241f389c02eb188c313190df62ab28c3763/labreporthelper/dataset.py#L173-L196 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | mapping_fields | def mapping_fields(mapping, parent=[]):
"""
reads an elasticsearh mapping dictionary and returns a list of fields
cojoined with a dot notation
args:
obj: the dictionary to parse
parent: name for a parent key. used with a recursive call
"""
rtn_obj = {}
for key, val... | python | def mapping_fields(mapping, parent=[]):
"""
reads an elasticsearh mapping dictionary and returns a list of fields
cojoined with a dot notation
args:
obj: the dictionary to parse
parent: name for a parent key. used with a recursive call
"""
rtn_obj = {}
for key, val... | [
"def",
"mapping_fields",
"(",
"mapping",
",",
"parent",
"=",
"[",
"]",
")",
":",
"rtn_obj",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"mapping",
".",
"items",
"(",
")",
":",
"new_key",
"=",
"parent",
"+",
"[",
"key",
"]",
"new_key",
"=",
"... | reads an elasticsearh mapping dictionary and returns a list of fields
cojoined with a dot notation
args:
obj: the dictionary to parse
parent: name for a parent key. used with a recursive call | [
"reads",
"an",
"elasticsearh",
"mapping",
"dictionary",
"and",
"returns",
"a",
"list",
"of",
"fields",
"cojoined",
"with",
"a",
"dot",
"notation",
"args",
":",
"obj",
":",
"the",
"dictionary",
"to",
"parse",
"parent",
":",
"name",
"for",
"a",
"parent",
"ke... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L310-L330 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | dict_fields | def dict_fields(obj, parent=[]):
"""
reads a dictionary and returns a list of fields cojoined with a dot
notation
args:
obj: the dictionary to parse
parent: name for a parent key. used with a recursive call
"""
rtn_obj = {}
for key, value in obj.items():
n... | python | def dict_fields(obj, parent=[]):
"""
reads a dictionary and returns a list of fields cojoined with a dot
notation
args:
obj: the dictionary to parse
parent: name for a parent key. used with a recursive call
"""
rtn_obj = {}
for key, value in obj.items():
n... | [
"def",
"dict_fields",
"(",
"obj",
",",
"parent",
"=",
"[",
"]",
")",
":",
"rtn_obj",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"obj",
".",
"items",
"(",
")",
":",
"new_key",
"=",
"parent",
"+",
"[",
"key",
"]",
"new_key",
"=",
"\".\"",
"... | reads a dictionary and returns a list of fields cojoined with a dot
notation
args:
obj: the dictionary to parse
parent: name for a parent key. used with a recursive call | [
"reads",
"a",
"dictionary",
"and",
"returns",
"a",
"list",
"of",
"fields",
"cojoined",
"with",
"a",
"dot",
"notation",
"args",
":",
"obj",
":",
"the",
"dictionary",
"to",
"parse",
"parent",
":",
"name",
"for",
"a",
"parent",
"key",
".",
"used",
"with",
... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L332-L352 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | EsMappings.list_mapped_classes | def list_mapped_classes():
"""
Returns all the rdfclasses that have and associated elasticsearch
mapping
Args:
None
"""
cls_dict = {key: value
for key, value in MODULE.rdfclass.__dict__.items()
if not isinst... | python | def list_mapped_classes():
"""
Returns all the rdfclasses that have and associated elasticsearch
mapping
Args:
None
"""
cls_dict = {key: value
for key, value in MODULE.rdfclass.__dict__.items()
if not isinst... | [
"def",
"list_mapped_classes",
"(",
")",
":",
"cls_dict",
"=",
"{",
"key",
":",
"value",
"for",
"key",
",",
"value",
"in",
"MODULE",
".",
"rdfclass",
".",
"__dict__",
".",
"items",
"(",
")",
"if",
"not",
"isinstance",
"(",
"value",
",",
"RdfConfigManager"... | Returns all the rdfclasses that have and associated elasticsearch
mapping
Args:
None | [
"Returns",
"all",
"the",
"rdfclasses",
"that",
"have",
"and",
"associated",
"elasticsearch",
"mapping",
"Args",
":",
"None"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L43-L68 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | EsMappings.list_indexes | def list_indexes(cls):
"""
Returns a dictionary with the key as the es_index name and the
object is a list of rdfclasses for that index
args:
None
"""
cls_list = cls.list_mapped_classes()
rtn_obj = {}
for key, value in cls_list.ite... | python | def list_indexes(cls):
"""
Returns a dictionary with the key as the es_index name and the
object is a list of rdfclasses for that index
args:
None
"""
cls_list = cls.list_mapped_classes()
rtn_obj = {}
for key, value in cls_list.ite... | [
"def",
"list_indexes",
"(",
"cls",
")",
":",
"cls_list",
"=",
"cls",
".",
"list_mapped_classes",
"(",
")",
"rtn_obj",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"cls_list",
".",
"items",
"(",
")",
":",
"idx",
"=",
"value",
".",
"es_defs",
".",
... | Returns a dictionary with the key as the es_index name and the
object is a list of rdfclasses for that index
args:
None | [
"Returns",
"a",
"dictionary",
"with",
"the",
"key",
"as",
"the",
"es_index",
"name",
"and",
"the",
"object",
"is",
"a",
"list",
"of",
"rdfclasses",
"for",
"that",
"index",
"args",
":",
"None"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L71-L88 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | EsMappings.get_rdf_es_idx_map | def get_rdf_es_idx_map(cls, idx_obj):
"""
Returns an elasticsearch mapping for the specified index based off
of the mapping defined by rdf class definitions
args:
idx_obj: Dictionary of the index and a list of rdfclasses
included in the mapping
... | python | def get_rdf_es_idx_map(cls, idx_obj):
"""
Returns an elasticsearch mapping for the specified index based off
of the mapping defined by rdf class definitions
args:
idx_obj: Dictionary of the index and a list of rdfclasses
included in the mapping
... | [
"def",
"get_rdf_es_idx_map",
"(",
"cls",
",",
"idx_obj",
")",
":",
"idx_name",
"=",
"list",
"(",
"idx_obj",
")",
"[",
"0",
"]",
"es_map",
"=",
"{",
"\"index\"",
":",
"idx_name",
",",
"\"body\"",
":",
"{",
"\"mappings\"",
":",
"{",
"}",
",",
"\"settings... | Returns an elasticsearch mapping for the specified index based off
of the mapping defined by rdf class definitions
args:
idx_obj: Dictionary of the index and a list of rdfclasses
included in the mapping | [
"Returns",
"an",
"elasticsearch",
"mapping",
"for",
"the",
"specified",
"index",
"based",
"off",
"of",
"the",
"mapping",
"defined",
"by",
"rdf",
"class",
"definitions",
"args",
":",
"idx_obj",
":",
"Dictionary",
"of",
"the",
"index",
"and",
"a",
"list",
"of"... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L91-L132 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | EsMappings.send_es_mapping | def send_es_mapping(self, es_map, **kwargs):
"""
sends the mapping to elasticsearch
args:
es_map: dictionary of the index mapping
kwargs:
reset_idx: WARNING! If True the current referenced es index
will be deleted destroying all data... | python | def send_es_mapping(self, es_map, **kwargs):
"""
sends the mapping to elasticsearch
args:
es_map: dictionary of the index mapping
kwargs:
reset_idx: WARNING! If True the current referenced es index
will be deleted destroying all data... | [
"def",
"send_es_mapping",
"(",
"self",
",",
"es_map",
",",
"*",
"*",
"kwargs",
")",
":",
"log",
".",
"setLevel",
"(",
"kwargs",
".",
"get",
"(",
"'log_level'",
",",
"self",
".",
"log_level",
")",
")",
"def",
"next_es_index_version",
"(",
"curr_alias",
")... | sends the mapping to elasticsearch
args:
es_map: dictionary of the index mapping
kwargs:
reset_idx: WARNING! If True the current referenced es index
will be deleted destroying all data in that index in
elasticsearch. if False an i... | [
"sends",
"the",
"mapping",
"to",
"elasticsearch",
"args",
":",
"es_map",
":",
"dictionary",
"of",
"the",
"index",
"mapping",
"kwargs",
":",
"reset_idx",
":",
"WARNING!",
"If",
"True",
"the",
"current",
"referenced",
"es",
"index",
"will",
"be",
"deleted",
"d... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L134-L198 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | EsMappings.initialize_indices | def initialize_indices(self, **kwargs):
"""
creates all the indicies that are defined in the rdf definitions
kwargs:
action: which action is to be perfomed
initialize: (default) tests to see if the index exisits
if not creat... | python | def initialize_indices(self, **kwargs):
"""
creates all the indicies that are defined in the rdf definitions
kwargs:
action: which action is to be perfomed
initialize: (default) tests to see if the index exisits
if not creat... | [
"def",
"initialize_indices",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"action",
"=",
"kwargs",
".",
"get",
"(",
"'action'",
",",
"'initialize'",
")",
"if",
"action",
"==",
"'update'",
":",
"kwargs",
"[",
"'reset_idx'",
"]",
"=",
"False",
"elif",
... | creates all the indicies that are defined in the rdf definitions
kwargs:
action: which action is to be perfomed
initialize: (default) tests to see if the index exisits
if not creates it
reset: deletes all of the indexes a... | [
"creates",
"all",
"the",
"indicies",
"that",
"are",
"defined",
"in",
"the",
"rdf",
"definitions",
"kwargs",
":",
"action",
":",
"which",
"action",
"is",
"to",
"be",
"perfomed",
"initialize",
":",
"(",
"default",
")",
"tests",
"to",
"see",
"if",
"the",
"i... | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L201-L223 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | EsMappings.get_es_mappings | def get_es_mappings(self):
"""
Returns the mapping defitions presetn in elasticsearh
"""
es_mappings = json.loads(requests.get(self.mapping_url).text)
es_mappings = {"_".join(key.split("_")[:-1]): value['mappings'] \
for key, value in es_mappings.it... | python | def get_es_mappings(self):
"""
Returns the mapping defitions presetn in elasticsearh
"""
es_mappings = json.loads(requests.get(self.mapping_url).text)
es_mappings = {"_".join(key.split("_")[:-1]): value['mappings'] \
for key, value in es_mappings.it... | [
"def",
"get_es_mappings",
"(",
"self",
")",
":",
"es_mappings",
"=",
"json",
".",
"loads",
"(",
"requests",
".",
"get",
"(",
"self",
".",
"mapping_url",
")",
".",
"text",
")",
"es_mappings",
"=",
"{",
"\"_\"",
".",
"join",
"(",
"key",
".",
"split",
"... | Returns the mapping defitions presetn in elasticsearh | [
"Returns",
"the",
"mapping",
"defitions",
"presetn",
"in",
"elasticsearh"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L225-L233 |
KnowledgeLinks/rdfframework | rdfframework/search/esmappings.py | EsMappings.mapping_ref | def mapping_ref(self, es_mappings):
"""
Retruns a dictionary of mappings and the fiels names in dot notation
args:
mappings: es mapping defitions to parse
"""
new_map = {}
for key, value in es_mappings.items():
for sub_key, sub_value in... | python | def mapping_ref(self, es_mappings):
"""
Retruns a dictionary of mappings and the fiels names in dot notation
args:
mappings: es mapping defitions to parse
"""
new_map = {}
for key, value in es_mappings.items():
for sub_key, sub_value in... | [
"def",
"mapping_ref",
"(",
"self",
",",
"es_mappings",
")",
":",
"new_map",
"=",
"{",
"}",
"for",
"key",
",",
"value",
"in",
"es_mappings",
".",
"items",
"(",
")",
":",
"for",
"sub_key",
",",
"sub_value",
"in",
"value",
".",
"items",
"(",
")",
":",
... | Retruns a dictionary of mappings and the fiels names in dot notation
args:
mappings: es mapping defitions to parse | [
"Retruns",
"a",
"dictionary",
"of",
"mappings",
"and",
"the",
"fiels",
"names",
"in",
"dot",
"notation",
"args",
":",
"mappings",
":",
"es",
"mapping",
"defitions",
"to",
"parse"
] | train | https://github.com/KnowledgeLinks/rdfframework/blob/9ec32dcc4bed51650a4b392cc5c15100fef7923a/rdfframework/search/esmappings.py#L235-L248 |
shaunduncan/helga-reminders | helga_reminders.py | readable_time_delta | def readable_time_delta(seconds):
"""
Convert a number of seconds into readable days, hours, and minutes
"""
days = seconds // 86400
seconds -= days * 86400
hours = seconds // 3600
seconds -= hours * 3600
minutes = seconds // 60
m_suffix = 's' if minutes != 1 else ''
h_suffix = ... | python | def readable_time_delta(seconds):
"""
Convert a number of seconds into readable days, hours, and minutes
"""
days = seconds // 86400
seconds -= days * 86400
hours = seconds // 3600
seconds -= hours * 3600
minutes = seconds // 60
m_suffix = 's' if minutes != 1 else ''
h_suffix = ... | [
"def",
"readable_time_delta",
"(",
"seconds",
")",
":",
"days",
"=",
"seconds",
"//",
"86400",
"seconds",
"-=",
"days",
"*",
"86400",
"hours",
"=",
"seconds",
"//",
"3600",
"seconds",
"-=",
"hours",
"*",
"3600",
"minutes",
"=",
"seconds",
"//",
"60",
"m_... | Convert a number of seconds into readable days, hours, and minutes | [
"Convert",
"a",
"number",
"of",
"seconds",
"into",
"readable",
"days",
"hours",
"and",
"minutes"
] | train | https://github.com/shaunduncan/helga-reminders/blob/e2b88cb65eade270ed175ceb6a4d6339554b893b/helga_reminders.py#L82-L104 |
shaunduncan/helga-reminders | helga_reminders.py | next_occurrence | def next_occurrence(reminder):
"""
Calculate the next occurrence of a repeatable reminder
"""
now = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
now_dow = now.weekday()
# Start/end dow starting from tomorrow
start_dow = now_dow + 1
end_dow = start_dow + 7
# Modded range from... | python | def next_occurrence(reminder):
"""
Calculate the next occurrence of a repeatable reminder
"""
now = datetime.datetime.utcnow().replace(tzinfo=pytz.UTC)
now_dow = now.weekday()
# Start/end dow starting from tomorrow
start_dow = now_dow + 1
end_dow = start_dow + 7
# Modded range from... | [
"def",
"next_occurrence",
"(",
"reminder",
")",
":",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"UTC",
")",
"now_dow",
"=",
"now",
".",
"weekday",
"(",
")",
"# Start/end dow starting... | Calculate the next occurrence of a repeatable reminder | [
"Calculate",
"the",
"next",
"occurrence",
"of",
"a",
"repeatable",
"reminder"
] | train | https://github.com/shaunduncan/helga-reminders/blob/e2b88cb65eade270ed175ceb6a4d6339554b893b/helga_reminders.py#L107-L143 |
shaunduncan/helga-reminders | helga_reminders.py | in_reminder | def in_reminder(client, channel, nick, args):
"""
Create a one-time reminder to occur at some amount of minutes, hours, or days
in the future. This is used like:
<sduncan> helga in 12h submit timesheet
This will create a reminder 12 hours from now with the message "submit timesheet".
Opti... | python | def in_reminder(client, channel, nick, args):
"""
Create a one-time reminder to occur at some amount of minutes, hours, or days
in the future. This is used like:
<sduncan> helga in 12h submit timesheet
This will create a reminder 12 hours from now with the message "submit timesheet".
Opti... | [
"def",
"in_reminder",
"(",
"client",
",",
"channel",
",",
"nick",
",",
"args",
")",
":",
"global",
"_scheduled",
"amount",
",",
"quantity",
"=",
"int",
"(",
"args",
"[",
"0",
"]",
"[",
":",
"-",
"1",
"]",
")",
",",
"args",
"[",
"0",
"]",
"[",
"... | Create a one-time reminder to occur at some amount of minutes, hours, or days
in the future. This is used like:
<sduncan> helga in 12h submit timesheet
This will create a reminder 12 hours from now with the message "submit timesheet".
Optionally, a specific channel can be specified to receive the... | [
"Create",
"a",
"one",
"-",
"time",
"reminder",
"to",
"occur",
"at",
"some",
"amount",
"of",
"minutes",
"hours",
"or",
"days",
"in",
"the",
"future",
".",
"This",
"is",
"used",
"like",
":"
] | train | https://github.com/shaunduncan/helga-reminders/blob/e2b88cb65eade270ed175ceb6a4d6339554b893b/helga_reminders.py#L170-L220 |
shaunduncan/helga-reminders | helga_reminders.py | at_reminder | def at_reminder(client, channel, nick, args):
"""
Schedule a reminder to occur at a specific time. The given time can optionally
be specified to occur at a specific timezone, but will default to the value
of settings.TIMEZONE if none is specified. Times should be on a 24-hour clock.
These types of ... | python | def at_reminder(client, channel, nick, args):
"""
Schedule a reminder to occur at a specific time. The given time can optionally
be specified to occur at a specific timezone, but will default to the value
of settings.TIMEZONE if none is specified. Times should be on a 24-hour clock.
These types of ... | [
"def",
"at_reminder",
"(",
"client",
",",
"channel",
",",
"nick",
",",
"args",
")",
":",
"global",
"_scheduled",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
".",
"replace",
"(",
"tzinfo",
"=",
"pytz",
".",
"UTC",
")",
"# Parse the... | Schedule a reminder to occur at a specific time. The given time can optionally
be specified to occur at a specific timezone, but will default to the value
of settings.TIMEZONE if none is specified. Times should be on a 24-hour clock.
These types of reminders are repeatable, should the last two words of the... | [
"Schedule",
"a",
"reminder",
"to",
"occur",
"at",
"a",
"specific",
"time",
".",
"The",
"given",
"time",
"can",
"optionally",
"be",
"specified",
"to",
"occur",
"at",
"a",
"specific",
"timezone",
"but",
"will",
"default",
"to",
"the",
"value",
"of",
"setting... | train | https://github.com/shaunduncan/helga-reminders/blob/e2b88cb65eade270ed175ceb6a4d6339554b893b/helga_reminders.py#L223-L324 |
gebn/nibble | nibble/expression/parser.py | Parser.p_information_constructor | def p_information_constructor(self, p):
'information : NUMBER INFORMATION_UNIT'
logger.debug('information = number %s, information unit %s', p[1], p[2])
p[0] = Information.from_quantity_unit(p[1], p[2]) | python | def p_information_constructor(self, p):
'information : NUMBER INFORMATION_UNIT'
logger.debug('information = number %s, information unit %s', p[1], p[2])
p[0] = Information.from_quantity_unit(p[1], p[2]) | [
"def",
"p_information_constructor",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'information = number %s, information unit %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"Information",
".",
"from_... | information : NUMBER INFORMATION_UNIT | [
"information",
":",
"NUMBER",
"INFORMATION_UNIT"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L62-L65 |
gebn/nibble | nibble/expression/parser.py | Parser.p_information_duration_speed | def p_information_duration_speed(self, p):
'information : duration AT speed'
logger.debug('information = duration %s at speed %s', p[1], p[3])
p[0] = p[3].for_duration(p[1]) | python | def p_information_duration_speed(self, p):
'information : duration AT speed'
logger.debug('information = duration %s at speed %s', p[1], p[3])
p[0] = p[3].for_duration(p[1]) | [
"def",
"p_information_duration_speed",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'information = duration %s at speed %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"3",
"]",
".",
... | information : duration AT speed | [
"information",
":",
"duration",
"AT",
"speed"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L67-L70 |
gebn/nibble | nibble/expression/parser.py | Parser.p_information_speed_duration | def p_information_speed_duration(self, p):
'information : speed FOR duration'
logger.debug('information = speed %s for duration %s', p[1], p[3])
p[0] = p[1].for_duration(p[3]) | python | def p_information_speed_duration(self, p):
'information : speed FOR duration'
logger.debug('information = speed %s for duration %s', p[1], p[3])
p[0] = p[1].for_duration(p[3]) | [
"def",
"p_information_speed_duration",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'information = speed %s for duration %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
".",
... | information : speed FOR duration | [
"information",
":",
"speed",
"FOR",
"duration"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L72-L75 |
gebn/nibble | nibble/expression/parser.py | Parser.p_information_conversion | def p_information_conversion(self, p):
'information : information IN INFORMATION_UNIT'
logger.debug(
'information = information %s in information unit %s', p[1], p[3])
p[0] = '{0: {1}}'.format(p[1], p[3]) | python | def p_information_conversion(self, p):
'information : information IN INFORMATION_UNIT'
logger.debug(
'information = information %s in information unit %s', p[1], p[3])
p[0] = '{0: {1}}'.format(p[1], p[3]) | [
"def",
"p_information_conversion",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'information = information %s in information unit %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"'{0: {1}}'",
".",
"... | information : information IN INFORMATION_UNIT | [
"information",
":",
"information",
"IN",
"INFORMATION_UNIT"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L77-L81 |
gebn/nibble | nibble/expression/parser.py | Parser.p_duration_duration_unit | def p_duration_duration_unit(self, p):
'duration : DURATION_UNIT'
logger.debug('duration = 1 of duration unit %s', p[1])
p[0] = Duration.from_quantity_unit(1, p[1]) | python | def p_duration_duration_unit(self, p):
'duration : DURATION_UNIT'
logger.debug('duration = 1 of duration unit %s', p[1])
p[0] = Duration.from_quantity_unit(1, p[1]) | [
"def",
"p_duration_duration_unit",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'duration = 1 of duration unit %s'",
",",
"p",
"[",
"1",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"Duration",
".",
"from_quantity_unit",
"(",
"1",
",",
"p",
"[",
... | duration : DURATION_UNIT | [
"duration",
":",
"DURATION_UNIT"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L89-L92 |
gebn/nibble | nibble/expression/parser.py | Parser.p_duration_number_duration_unit | def p_duration_number_duration_unit(self, p):
'duration : NUMBER DURATION_UNIT'
logger.debug('duration = number %s, duration unit %s', p[1], p[2])
p[0] = Duration.from_quantity_unit(p[1], p[2]) | python | def p_duration_number_duration_unit(self, p):
'duration : NUMBER DURATION_UNIT'
logger.debug('duration = number %s, duration unit %s', p[1], p[2])
p[0] = Duration.from_quantity_unit(p[1], p[2]) | [
"def",
"p_duration_number_duration_unit",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'duration = number %s, duration unit %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"2",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"Duration",
".",
"from_qua... | duration : NUMBER DURATION_UNIT | [
"duration",
":",
"NUMBER",
"DURATION_UNIT"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L94-L97 |
gebn/nibble | nibble/expression/parser.py | Parser.p_duration_number_duration_unit_duration | def p_duration_number_duration_unit_duration(self, p):
'duration : NUMBER DURATION_UNIT duration'
logger.debug(
'duration = number %s, duration unit %s, duration %s', p[1], p[2],
p[3])
duration = Duration.from_quantity_unit(p[1], p[2])
p[0] = duration + p[3] | python | def p_duration_number_duration_unit_duration(self, p):
'duration : NUMBER DURATION_UNIT duration'
logger.debug(
'duration = number %s, duration unit %s, duration %s', p[1], p[2],
p[3])
duration = Duration.from_quantity_unit(p[1], p[2])
p[0] = duration + p[3] | [
"def",
"p_duration_number_duration_unit_duration",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'duration = number %s, duration unit %s, duration %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"2",
"]",
",",
"p",
"[",
"3",
"]",
")",
"duratio... | duration : NUMBER DURATION_UNIT duration | [
"duration",
":",
"NUMBER",
"DURATION_UNIT",
"duration"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L99-L105 |
gebn/nibble | nibble/expression/parser.py | Parser.p_duration_information_speed | def p_duration_information_speed(self, p):
'duration : information AT speed'
logger.debug('duration = information %s at speed %s', p[1], p[3])
p[0] = p[1].at_speed(p[3]) | python | def p_duration_information_speed(self, p):
'duration : information AT speed'
logger.debug('duration = information %s at speed %s', p[1], p[3])
p[0] = p[1].at_speed(p[3]) | [
"def",
"p_duration_information_speed",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'duration = information %s at speed %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
".",
... | duration : information AT speed | [
"duration",
":",
"information",
"AT",
"speed"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L107-L110 |
gebn/nibble | nibble/expression/parser.py | Parser.p_duration_conversion | def p_duration_conversion(self, p):
'duration : duration IN DURATION_UNIT'
logger.debug('duration = duration %s in duration unit %s', p[1], p[3])
p[0] = '{0: {1}}'.format(p[1], p[3]) | python | def p_duration_conversion(self, p):
'duration : duration IN DURATION_UNIT'
logger.debug('duration = duration %s in duration unit %s', p[1], p[3])
p[0] = '{0: {1}}'.format(p[1], p[3]) | [
"def",
"p_duration_conversion",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'duration = duration %s in duration unit %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"'{0: {1}}'",
".",
"format",
"... | duration : duration IN DURATION_UNIT | [
"duration",
":",
"duration",
"IN",
"DURATION_UNIT"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L112-L115 |
gebn/nibble | nibble/expression/parser.py | Parser.p_speed_constructor | def p_speed_constructor(self, p):
'speed : NUMBER speed_unit'
logger.debug('speed = number %s, speed unit %s', p[1], p[2])
information_unit, duration = p[2]
information = Information.from_quantity_unit(p[1], information_unit)
p[0] = information.in_duration(duration) | python | def p_speed_constructor(self, p):
'speed : NUMBER speed_unit'
logger.debug('speed = number %s, speed unit %s', p[1], p[2])
information_unit, duration = p[2]
information = Information.from_quantity_unit(p[1], information_unit)
p[0] = information.in_duration(duration) | [
"def",
"p_speed_constructor",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'speed = number %s, speed unit %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"2",
"]",
")",
"information_unit",
",",
"duration",
"=",
"p",
"[",
"2",
"]",
"info... | speed : NUMBER speed_unit | [
"speed",
":",
"NUMBER",
"speed_unit"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L121-L126 |
gebn/nibble | nibble/expression/parser.py | Parser.p_speed_information_duration | def p_speed_information_duration(self, p):
'speed : information IN duration'
logger.debug('speed = information %s in duration %s', p[1], p[3])
p[0] = p[1].in_duration(p[3]) | python | def p_speed_information_duration(self, p):
'speed : information IN duration'
logger.debug('speed = information %s in duration %s', p[1], p[3])
p[0] = p[1].in_duration(p[3]) | [
"def",
"p_speed_information_duration",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'speed = information %s in duration %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"p",
"[",
"1",
"]",
".",
... | speed : information IN duration | [
"speed",
":",
"information",
"IN",
"duration"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L128-L131 |
gebn/nibble | nibble/expression/parser.py | Parser.p_speed_conversion | def p_speed_conversion(self, p):
'speed : speed IN speed_unit'
logger.debug('speed = speed %s in speed unit %s', p[1], p[3])
information_unit, duration = p[3]
p[0] = '{0: {1}}'.format(p[1],
'{0}/{1}'.format(information_unit, duration)) | python | def p_speed_conversion(self, p):
'speed : speed IN speed_unit'
logger.debug('speed = speed %s in speed unit %s', p[1], p[3])
information_unit, duration = p[3]
p[0] = '{0: {1}}'.format(p[1],
'{0}/{1}'.format(information_unit, duration)) | [
"def",
"p_speed_conversion",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'speed = speed %s in speed unit %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"information_unit",
",",
"duration",
"=",
"p",
"[",
"3",
"]",
"p",
... | speed : speed IN speed_unit | [
"speed",
":",
"speed",
"IN",
"speed_unit"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L133-L138 |
gebn/nibble | nibble/expression/parser.py | Parser.p_speed_unit | def p_speed_unit(self, p):
'speed_unit : INFORMATION_UNIT PER duration'
logger.debug(
'speed unit = information unit %s per duration %s', p[1], p[3])
p[0] = (p[1], p[3]) | python | def p_speed_unit(self, p):
'speed_unit : INFORMATION_UNIT PER duration'
logger.debug(
'speed unit = information unit %s per duration %s', p[1], p[3])
p[0] = (p[1], p[3]) | [
"def",
"p_speed_unit",
"(",
"self",
",",
"p",
")",
":",
"logger",
".",
"debug",
"(",
"'speed unit = information unit %s per duration %s'",
",",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"p",
"[",
"0",
"]",
"=",
"(",
"p",
"[",
"1",
"]",
",",... | speed_unit : INFORMATION_UNIT PER duration | [
"speed_unit",
":",
"INFORMATION_UNIT",
"PER",
"duration"
] | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L142-L146 |
gebn/nibble | nibble/expression/parser.py | Parser.parse | def parse(self, string, lexer=None):
"""
Interpret a string.
:param string: The input to lex and parse.
:param lexer: The lexer to use. A new one will be created if not
provided.
:return: An object representation of the input.
"""
if... | python | def parse(self, string, lexer=None):
"""
Interpret a string.
:param string: The input to lex and parse.
:param lexer: The lexer to use. A new one will be created if not
provided.
:return: An object representation of the input.
"""
if... | [
"def",
"parse",
"(",
"self",
",",
"string",
",",
"lexer",
"=",
"None",
")",
":",
"if",
"not",
"lexer",
":",
"lexer",
"=",
"Lexer",
"(",
")",
".",
"lexer",
"return",
"self",
".",
"parser",
".",
"parse",
"(",
"string",
",",
"lexer",
"=",
"lexer",
"... | Interpret a string.
:param string: The input to lex and parse.
:param lexer: The lexer to use. A new one will be created if not
provided.
:return: An object representation of the input. | [
"Interpret",
"a",
"string",
".",
":",
"param",
"string",
":",
"The",
"input",
"to",
"lex",
"and",
"parse",
".",
":",
"param",
"lexer",
":",
"The",
"lexer",
"to",
"use",
".",
"A",
"new",
"one",
"will",
"be",
"created",
"if",
"not",
"provided",
".",
... | train | https://github.com/gebn/nibble/blob/e82a2c43509ed38f3d039040591cc630fa676cb0/nibble/expression/parser.py#L172-L184 |
minhhoit/yacms | yacms/bin/management/commands/yacms_project.py | Command.get_project_directory | def get_project_directory(self, name, target):
"""
This code is copied verbatim from Django's
TemplateCommand.handle(), but with the directory creation
code removed.
"""
# if some directory is given, make sure it's nicely expanded.
if target is None:
t... | python | def get_project_directory(self, name, target):
"""
This code is copied verbatim from Django's
TemplateCommand.handle(), but with the directory creation
code removed.
"""
# if some directory is given, make sure it's nicely expanded.
if target is None:
t... | [
"def",
"get_project_directory",
"(",
"self",
",",
"name",
",",
"target",
")",
":",
"# if some directory is given, make sure it's nicely expanded.",
"if",
"target",
"is",
"None",
":",
"top_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
... | This code is copied verbatim from Django's
TemplateCommand.handle(), but with the directory creation
code removed. | [
"This",
"code",
"is",
"copied",
"verbatim",
"from",
"Django",
"s",
"TemplateCommand",
".",
"handle",
"()",
"but",
"with",
"the",
"directory",
"creation",
"code",
"removed",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/bin/management/commands/yacms_project.py#L63-L78 |
minhhoit/yacms | yacms/bin/management/commands/yacms_project.py | Command.handle_template | def handle_template(self, template, subdir):
"""
Use yacms's project template by default. The method of
picking the default directory is copied from Django's
TemplateCommand.
"""
if template is None:
return six.text_type(os.path.join(yacms.__path__[0], subdir)... | python | def handle_template(self, template, subdir):
"""
Use yacms's project template by default. The method of
picking the default directory is copied from Django's
TemplateCommand.
"""
if template is None:
return six.text_type(os.path.join(yacms.__path__[0], subdir)... | [
"def",
"handle_template",
"(",
"self",
",",
"template",
",",
"subdir",
")",
":",
"if",
"template",
"is",
"None",
":",
"return",
"six",
".",
"text_type",
"(",
"os",
".",
"path",
".",
"join",
"(",
"yacms",
".",
"__path__",
"[",
"0",
"]",
",",
"subdir",... | Use yacms's project template by default. The method of
picking the default directory is copied from Django's
TemplateCommand. | [
"Use",
"yacms",
"s",
"project",
"template",
"by",
"default",
".",
"The",
"method",
"of",
"picking",
"the",
"default",
"directory",
"is",
"copied",
"from",
"Django",
"s",
"TemplateCommand",
"."
] | train | https://github.com/minhhoit/yacms/blob/2921b706b7107c6e8c5f2bbf790ff11f85a2167f/yacms/bin/management/commands/yacms_project.py#L80-L88 |
praekelt/jmbo-gallery | gallery/models.py | VideoEmbed.youtube_id | def youtube_id(self):
"""Extract and return Youtube video id"""
m = re.search(r'/embed/([A-Za-z0-9\-=_]*)', self.embed)
if m:
return m.group(1)
return '' | python | def youtube_id(self):
"""Extract and return Youtube video id"""
m = re.search(r'/embed/([A-Za-z0-9\-=_]*)', self.embed)
if m:
return m.group(1)
return '' | [
"def",
"youtube_id",
"(",
"self",
")",
":",
"m",
"=",
"re",
".",
"search",
"(",
"r'/embed/([A-Za-z0-9\\-=_]*)'",
",",
"self",
".",
"embed",
")",
"if",
"m",
":",
"return",
"m",
".",
"group",
"(",
"1",
")",
"return",
"''"
] | Extract and return Youtube video id | [
"Extract",
"and",
"return",
"Youtube",
"video",
"id"
] | train | https://github.com/praekelt/jmbo-gallery/blob/064e005913d79e456ba014b50205c7916df4714a/gallery/models.py#L64-L69 |
praekelt/jmbo-gallery | gallery/models.py | VideoEmbed.save | def save(self, *args, **kwargs):
"""Automatically set image"""
if not self.image:
# Fetch image
url = "http://img.youtube.com/vi/%s/0.jpg" % self.youtube_id
response = None
try:
response = requests.get(url)
except requests.exc... | python | def save(self, *args, **kwargs):
"""Automatically set image"""
if not self.image:
# Fetch image
url = "http://img.youtube.com/vi/%s/0.jpg" % self.youtube_id
response = None
try:
response = requests.get(url)
except requests.exc... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"self",
".",
"image",
":",
"# Fetch image",
"url",
"=",
"\"http://img.youtube.com/vi/%s/0.jpg\"",
"%",
"self",
".",
"youtube_id",
"response",
"=",
"None",
"try",
... | Automatically set image | [
"Automatically",
"set",
"image"
] | train | https://github.com/praekelt/jmbo-gallery/blob/064e005913d79e456ba014b50205c7916df4714a/gallery/models.py#L71-L140 |
kodexlab/reliure | reliure/engine.py | BasicPlayMeta.run_with | def run_with(self, inputs, options):
""" Store the run parameters (inputs and options)
"""
self._inputs = inputs
self._options = options | python | def run_with(self, inputs, options):
""" Store the run parameters (inputs and options)
"""
self._inputs = inputs
self._options = options | [
"def",
"run_with",
"(",
"self",
",",
"inputs",
",",
"options",
")",
":",
"self",
".",
"_inputs",
"=",
"inputs",
"self",
".",
"_options",
"=",
"options"
] | Store the run parameters (inputs and options) | [
"Store",
"the",
"run",
"parameters",
"(",
"inputs",
"and",
"options",
")"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L91-L95 |
kodexlab/reliure | reliure/engine.py | BasicPlayMeta.as_dict | def as_dict(self):
""" Pre-serialisation of the meta data """
drepr = {}
drepr["name"] = self.name
drepr["time"] = self.time
# error pre-serialisation
drepr["errors"] = [str(err) for err in self.errors]
# warning pre-serialisation
drepr["warnings"] = [str... | python | def as_dict(self):
""" Pre-serialisation of the meta data """
drepr = {}
drepr["name"] = self.name
drepr["time"] = self.time
# error pre-serialisation
drepr["errors"] = [str(err) for err in self.errors]
# warning pre-serialisation
drepr["warnings"] = [str... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"drepr",
"=",
"{",
"}",
"drepr",
"[",
"\"name\"",
"]",
"=",
"self",
".",
"name",
"drepr",
"[",
"\"time\"",
"]",
"=",
"self",
".",
"time",
"# error pre-serialisation",
"drepr",
"[",
"\"errors\"",
"]",
"=",
"[",
... | Pre-serialisation of the meta data | [
"Pre",
"-",
"serialisation",
"of",
"the",
"meta",
"data"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L126-L135 |
kodexlab/reliure | reliure/engine.py | PlayMeta.name | def name(self):
""" Compute a name according to sub meta results names
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>> gres.append(res_plus)
>>> gres.append(res_moins)
... | python | def name(self):
""" Compute a name according to sub meta results names
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>> gres.append(res_plus)
>>> gres.append(res_moins)
... | [
"def",
"name",
"(",
"self",
")",
":",
"return",
"\"%s:[%s]\"",
"%",
"(",
"self",
".",
"_name",
",",
"\", \"",
".",
"join",
"(",
"meta",
".",
"name",
"for",
"meta",
"in",
"self",
".",
"_metas",
")",
")"
] | Compute a name according to sub meta results names
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>> gres.append(res_plus)
>>> gres.append(res_moins)
>>> gres.name
'o... | [
"Compute",
"a",
"name",
"according",
"to",
"sub",
"meta",
"results",
"names"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L163-L174 |
kodexlab/reliure | reliure/engine.py | PlayMeta.errors | def errors(self):
""" get all the errors
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> gres.append(res_plus)
>>> res_plus.add_error(ValueError("invalid data"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>... | python | def errors(self):
""" get all the errors
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> gres.append(res_plus)
>>> res_plus.add_error(ValueError("invalid data"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>... | [
"def",
"errors",
"(",
"self",
")",
":",
"errors",
"=",
"[",
"]",
"for",
"meta",
"in",
"self",
":",
"errors",
".",
"extend",
"(",
"meta",
".",
"errors",
")",
"return",
"errors"
] | get all the errors
>>> gres = PlayMeta("operation")
>>> res_plus = BasicPlayMeta(Composable(name="plus"))
>>> gres.append(res_plus)
>>> res_plus.add_error(ValueError("invalid data"))
>>> res_moins = BasicPlayMeta(Composable(name="moins"))
>>> gres.append(res_moins)
... | [
"get",
"all",
"the",
"errors"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L193-L209 |
kodexlab/reliure | reliure/engine.py | PlayMeta.append | def append(self, meta):
""" Add a :class:`BasicPlayMeta`
"""
assert isinstance(meta, BasicPlayMeta)
self._metas.append(meta) | python | def append(self, meta):
""" Add a :class:`BasicPlayMeta`
"""
assert isinstance(meta, BasicPlayMeta)
self._metas.append(meta) | [
"def",
"append",
"(",
"self",
",",
"meta",
")",
":",
"assert",
"isinstance",
"(",
"meta",
",",
"BasicPlayMeta",
")",
"self",
".",
"_metas",
".",
"append",
"(",
"meta",
")"
] | Add a :class:`BasicPlayMeta` | [
"Add",
"a",
":",
"class",
":",
"BasicPlayMeta"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L222-L226 |
kodexlab/reliure | reliure/engine.py | PlayMeta.as_dict | def as_dict(self):
""" Pre-serialisation of the meta data """
drepr = super(PlayMeta, self).as_dict()
drepr["details"] = [meta.as_dict() for meta in self._metas]
return drepr | python | def as_dict(self):
""" Pre-serialisation of the meta data """
drepr = super(PlayMeta, self).as_dict()
drepr["details"] = [meta.as_dict() for meta in self._metas]
return drepr | [
"def",
"as_dict",
"(",
"self",
")",
":",
"drepr",
"=",
"super",
"(",
"PlayMeta",
",",
"self",
")",
".",
"as_dict",
"(",
")",
"drepr",
"[",
"\"details\"",
"]",
"=",
"[",
"meta",
".",
"as_dict",
"(",
")",
"for",
"meta",
"in",
"self",
".",
"_metas",
... | Pre-serialisation of the meta data | [
"Pre",
"-",
"serialisation",
"of",
"the",
"meta",
"data"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L234-L238 |
kodexlab/reliure | reliure/engine.py | Block.defaults | def defaults(self):
""" component default component
.. Note:: default components is just an indication for user and the
views, except if the Block is required. If required then default is
selected if nothing explisitely selected.
"""
default = self._defaults
... | python | def defaults(self):
""" component default component
.. Note:: default components is just an indication for user and the
views, except if the Block is required. If required then default is
selected if nothing explisitely selected.
"""
default = self._defaults
... | [
"def",
"defaults",
"(",
"self",
")",
":",
"default",
"=",
"self",
".",
"_defaults",
"# if require and no default, the first component as default",
"if",
"not",
"len",
"(",
"default",
")",
"and",
"self",
".",
"required",
"and",
"len",
"(",
"self",
".",
"_componen... | component default component
.. Note:: default components is just an indication for user and the
views, except if the Block is required. If required then default is
selected if nothing explisitely selected. | [
"component",
"default",
"component"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L340-L351 |
kodexlab/reliure | reliure/engine.py | Block.selected | def selected(self):
""" returns the list of selected component names.
if no component selected return the one marked as default.
If the block is required and no component where indicated as default,
then the first component is selected.
"""
selected = self._selected
... | python | def selected(self):
""" returns the list of selected component names.
if no component selected return the one marked as default.
If the block is required and no component where indicated as default,
then the first component is selected.
"""
selected = self._selected
... | [
"def",
"selected",
"(",
"self",
")",
":",
"selected",
"=",
"self",
".",
"_selected",
"if",
"len",
"(",
"self",
".",
"_selected",
")",
"==",
"0",
"and",
"self",
".",
"required",
":",
"# nothing has been selected yet BUT the component is required",
"selected",
"="... | returns the list of selected component names.
if no component selected return the one marked as default.
If the block is required and no component where indicated as default,
then the first component is selected. | [
"returns",
"the",
"list",
"of",
"selected",
"component",
"names",
"."
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L362-L373 |
kodexlab/reliure | reliure/engine.py | Block.as_dict | def as_dict(self):
""" returns a dictionary representation of the block and of all
component options
"""
#TODO/FIXME: add selected information
if self.hidden:
rdict = {}
else:
def_selected = self.selected()
comps = [
{
... | python | def as_dict(self):
""" returns a dictionary representation of the block and of all
component options
"""
#TODO/FIXME: add selected information
if self.hidden:
rdict = {}
else:
def_selected = self.selected()
comps = [
{
... | [
"def",
"as_dict",
"(",
"self",
")",
":",
"#TODO/FIXME: add selected information",
"if",
"self",
".",
"hidden",
":",
"rdict",
"=",
"{",
"}",
"else",
":",
"def_selected",
"=",
"self",
".",
"selected",
"(",
")",
"comps",
"=",
"[",
"{",
"'name'",
":",
"comp"... | returns a dictionary representation of the block and of all
component options | [
"returns",
"a",
"dictionary",
"representation",
"of",
"the",
"block",
"and",
"of",
"all",
"component",
"options"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L375-L400 |
kodexlab/reliure | reliure/engine.py | Block.reset | def reset(self):
""" Removes all the components of the block
"""
self._components = OrderedDict()
self.clear_selections()
self._logger.info("<block: %s> reset component list" % (self.name)) | python | def reset(self):
""" Removes all the components of the block
"""
self._components = OrderedDict()
self.clear_selections()
self._logger.info("<block: %s> reset component list" % (self.name)) | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_components",
"=",
"OrderedDict",
"(",
")",
"self",
".",
"clear_selections",
"(",
")",
"self",
".",
"_logger",
".",
"info",
"(",
"\"<block: %s> reset component list\"",
"%",
"(",
"self",
".",
"name",
")"... | Removes all the components of the block | [
"Removes",
"all",
"the",
"components",
"of",
"the",
"block"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L402-L407 |
kodexlab/reliure | reliure/engine.py | Block.clear_selections | def clear_selections(self):
""" Reset the current selections and **reset option** values to default
for all components
.. Warning:: This method also reset the components options values to
the defaults values.
"""
self._selected = []
for component in s... | python | def clear_selections(self):
""" Reset the current selections and **reset option** values to default
for all components
.. Warning:: This method also reset the components options values to
the defaults values.
"""
self._selected = []
for component in s... | [
"def",
"clear_selections",
"(",
"self",
")",
":",
"self",
".",
"_selected",
"=",
"[",
"]",
"for",
"component",
"in",
"self",
".",
"_components",
".",
"values",
"(",
")",
":",
"if",
"isinstance",
"(",
"component",
",",
"Optionable",
")",
":",
"self",
".... | Reset the current selections and **reset option** values to default
for all components
.. Warning:: This method also reset the components options values to
the defaults values. | [
"Reset",
"the",
"current",
"selections",
"and",
"**",
"reset",
"option",
"**",
"values",
"to",
"default",
"for",
"all",
"components",
"..",
"Warning",
"::",
"This",
"method",
"also",
"reset",
"the",
"components",
"options",
"values",
"to",
"the",
"defaults",
... | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L409-L420 |
kodexlab/reliure | reliure/engine.py | Block.setup | def setup(self, in_name=None, out_name=None, required=None, hidden=None,
multiple=None, defaults=None):
""" Set the options of the block.
Only the not None given options are set
.. note:: a block may have multiple inputs but have only one output
:param in_name: name(s) ... | python | def setup(self, in_name=None, out_name=None, required=None, hidden=None,
multiple=None, defaults=None):
""" Set the options of the block.
Only the not None given options are set
.. note:: a block may have multiple inputs but have only one output
:param in_name: name(s) ... | [
"def",
"setup",
"(",
"self",
",",
"in_name",
"=",
"None",
",",
"out_name",
"=",
"None",
",",
"required",
"=",
"None",
",",
"hidden",
"=",
"None",
",",
"multiple",
"=",
"None",
",",
"defaults",
"=",
"None",
")",
":",
"if",
"in_name",
"is",
"not",
"N... | Set the options of the block.
Only the not None given options are set
.. note:: a block may have multiple inputs but have only one output
:param in_name: name(s) of the block input data
:type in_name: str or list of str
:param out_name: name of the block output data
:ty... | [
"Set",
"the",
"options",
"of",
"the",
"block",
".",
"Only",
"the",
"not",
"None",
"given",
"options",
"are",
"set"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L422-L454 |
kodexlab/reliure | reliure/engine.py | Block.set | def set(self, *components):
""" Set the possible components of the block
:param components: components to append Optionables or Composables
"""
self.reset()
if len(components) == 1:
self.append(components[0])
else:
for comp in components:
... | python | def set(self, *components):
""" Set the possible components of the block
:param components: components to append Optionables or Composables
"""
self.reset()
if len(components) == 1:
self.append(components[0])
else:
for comp in components:
... | [
"def",
"set",
"(",
"self",
",",
"*",
"components",
")",
":",
"self",
".",
"reset",
"(",
")",
"if",
"len",
"(",
"components",
")",
"==",
"1",
":",
"self",
".",
"append",
"(",
"components",
"[",
"0",
"]",
")",
"else",
":",
"for",
"comp",
"in",
"c... | Set the possible components of the block
:param components: components to append Optionables or Composables | [
"Set",
"the",
"possible",
"components",
"of",
"the",
"block",
":",
"param",
"components",
":",
"components",
"to",
"append",
"Optionables",
"or",
"Composables"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L456-L466 |
kodexlab/reliure | reliure/engine.py | Block.append | def append(self, component, default=False):
""" Add one component to the block
:param default: if true this component will be use by default
:type default: bool
"""
if not isinstance(component, Composable):
if callable(component):
component = ... | python | def append(self, component, default=False):
""" Add one component to the block
:param default: if true this component will be use by default
:type default: bool
"""
if not isinstance(component, Composable):
if callable(component):
component = ... | [
"def",
"append",
"(",
"self",
",",
"component",
",",
"default",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"component",
",",
"Composable",
")",
":",
"if",
"callable",
"(",
"component",
")",
":",
"component",
"=",
"Composable",
"(",
"componen... | Add one component to the block
:param default: if true this component will be use by default
:type default: bool | [
"Add",
"one",
"component",
"to",
"the",
"block",
":",
"param",
"default",
":",
"if",
"true",
"this",
"component",
"will",
"be",
"use",
"by",
"default",
":",
"type",
"default",
":",
"bool"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L468-L487 |
kodexlab/reliure | reliure/engine.py | Block.select | def select(self, comp_name, options=None):
""" Select the components that will by played (with given options).
`options` will be passed to :func:`.Optionable.parse_options` if the
component is a subclass of :class:`Optionable`.
.. Warning:: this function also setup the options (if give... | python | def select(self, comp_name, options=None):
""" Select the components that will by played (with given options).
`options` will be passed to :func:`.Optionable.parse_options` if the
component is a subclass of :class:`Optionable`.
.. Warning:: this function also setup the options (if give... | [
"def",
"select",
"(",
"self",
",",
"comp_name",
",",
"options",
"=",
"None",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"select comp '%s' for block '%s' (options: %s)\"",
"%",
"(",
"comp_name",
",",
"self",
".",
"_name",
",",
"options",
")",
")",
... | Select the components that will by played (with given options).
`options` will be passed to :func:`.Optionable.parse_options` if the
component is a subclass of :class:`Optionable`.
.. Warning:: this function also setup the options (if given) of the
selected component. Use :func:`cl... | [
"Select",
"the",
"components",
"that",
"will",
"by",
"played",
"(",
"with",
"given",
"options",
")",
"."
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L489-L531 |
kodexlab/reliure | reliure/engine.py | Block.configure | def configure(self, config):
""" Configure the block from an (horible) configuration dictionary (or
list) this data are coming from a json client request and has to be
parsed. It takes the default value if missing (for component selection
and options).
:param config: component t... | python | def configure(self, config):
""" Configure the block from an (horible) configuration dictionary (or
list) this data are coming from a json client request and has to be
parsed. It takes the default value if missing (for component selection
and options).
:param config: component t... | [
"def",
"configure",
"(",
"self",
",",
"config",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"configure block <%s>\"",
"%",
"self",
".",
"name",
")",
"# normalise input format",
"if",
"isinstance",
"(",
"config",
",",
"dict",
")",
":",
"if",
"len"... | Configure the block from an (horible) configuration dictionary (or
list) this data are coming from a json client request and has to be
parsed. It takes the default value if missing (for component selection
and options).
:param config: component to use and the associated options
... | [
"Configure",
"the",
"block",
"from",
"an",
"(",
"horible",
")",
"configuration",
"dictionary",
"(",
"or",
"list",
")",
"this",
"data",
"are",
"coming",
"from",
"a",
"json",
"client",
"request",
"and",
"has",
"to",
"be",
"parsed",
".",
"It",
"takes",
"the... | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L533-L597 |
kodexlab/reliure | reliure/engine.py | Block.validate | def validate(self):
""" check that the block can be run
"""
if self.required and len(self.selected()) == 0:
raise ReliureError("No component selected for block '%s'" % self.name) | python | def validate(self):
""" check that the block can be run
"""
if self.required and len(self.selected()) == 0:
raise ReliureError("No component selected for block '%s'" % self.name) | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"self",
".",
"required",
"and",
"len",
"(",
"self",
".",
"selected",
"(",
")",
")",
"==",
"0",
":",
"raise",
"ReliureError",
"(",
"\"No component selected for block '%s'\"",
"%",
"self",
".",
"name",
")"
] | check that the block can be run | [
"check",
"that",
"the",
"block",
"can",
"be",
"run"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L599-L603 |
kodexlab/reliure | reliure/engine.py | Block.play | def play(self, *inputs, **named_inputs):
""" Run the selected components of the block. The selected components
are run with the already setted options.
.. warning:: Defaut 'multiple' behavior is a **pipeline** !
:param *inputs: arguments (i.e. inputs) to give to the components
... | python | def play(self, *inputs, **named_inputs):
""" Run the selected components of the block. The selected components
are run with the already setted options.
.. warning:: Defaut 'multiple' behavior is a **pipeline** !
:param *inputs: arguments (i.e. inputs) to give to the components
... | [
"def",
"play",
"(",
"self",
",",
"*",
"inputs",
",",
"*",
"*",
"named_inputs",
")",
":",
"# TODO: multi mode option(False, pipeline, map)",
"self",
".",
"validate",
"(",
")",
"# TODO what if validate fails ?",
"# intialise run meta data",
"start",
"=",
"time",
".",
... | Run the selected components of the block. The selected components
are run with the already setted options.
.. warning:: Defaut 'multiple' behavior is a **pipeline** !
:param *inputs: arguments (i.e. inputs) to give to the components | [
"Run",
"the",
"selected",
"components",
"of",
"the",
"block",
".",
"The",
"selected",
"components",
"are",
"run",
"with",
"the",
"already",
"setted",
"options",
"."
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L605-L693 |
kodexlab/reliure | reliure/engine.py | Engine.requires | def requires(self, *names):
""" Declare what block will be used in this engine.
It should be call before adding or setting any component.
Blocks order will be preserved for runnning task.
"""
if len(names) == 0:
raise ValueError("You should give at least one block na... | python | def requires(self, *names):
""" Declare what block will be used in this engine.
It should be call before adding or setting any component.
Blocks order will be preserved for runnning task.
"""
if len(names) == 0:
raise ValueError("You should give at least one block na... | [
"def",
"requires",
"(",
"self",
",",
"*",
"names",
")",
":",
"if",
"len",
"(",
"names",
")",
"==",
"0",
":",
"raise",
"ValueError",
"(",
"\"You should give at least one block name\"",
")",
"if",
"self",
".",
"_blocks",
"is",
"not",
"None",
"and",
"len",
... | Declare what block will be used in this engine.
It should be call before adding or setting any component.
Blocks order will be preserved for runnning task. | [
"Declare",
"what",
"block",
"will",
"be",
"used",
"in",
"this",
"engine",
"."
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L713-L728 |
kodexlab/reliure | reliure/engine.py | Engine.set | def set(self, name, *components, **parameters):
""" Set available components and the options of one block.
:param name: block name
:param components: the components (see :meth:`Block.set`)
:param parameters: block configuration (see :meth:`Block.setup`)
for exam... | python | def set(self, name, *components, **parameters):
""" Set available components and the options of one block.
:param name: block name
:param components: the components (see :meth:`Block.set`)
:param parameters: block configuration (see :meth:`Block.setup`)
for exam... | [
"def",
"set",
"(",
"self",
",",
"name",
",",
"*",
"components",
",",
"*",
"*",
"parameters",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\" ** SET ** '%s' \"",
"%",
"name",
")",
"if",
"name",
"not",
"in",
"self",
":",
"raise",
"ValueError",
... | Set available components and the options of one block.
:param name: block name
:param components: the components (see :meth:`Block.set`)
:param parameters: block configuration (see :meth:`Block.setup`)
for example :
>>> engine = Engine("op1")
>>... | [
"Set",
"available",
"components",
"and",
"the",
"options",
"of",
"one",
"block",
".",
":",
"param",
"name",
":",
"block",
"name",
":",
"param",
"components",
":",
"the",
"components",
"(",
"see",
":",
"meth",
":",
"Block",
".",
"set",
")",
":",
"param"... | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L730-L747 |
kodexlab/reliure | reliure/engine.py | Engine.configure | def configure(self, config):
""" Configure all the blocks from an (horible) configuration dictionary
this data are coming from a json client request and has to be parsed.
It takes the default value if missing (for component selection and
options).
:param config: dictionary that... | python | def configure(self, config):
""" Configure all the blocks from an (horible) configuration dictionary
this data are coming from a json client request and has to be parsed.
It takes the default value if missing (for component selection and
options).
:param config: dictionary that... | [
"def",
"configure",
"(",
"self",
",",
"config",
")",
":",
"##TODO use block configuration",
"self",
".",
"_logger",
".",
"info",
"(",
"\"\\n\\n\\t\\t\\t ** ============= configure engine ============= ** \\n\"",
")",
"# normalise input format",
"for",
"block_name",
"in",
"c... | Configure all the blocks from an (horible) configuration dictionary
this data are coming from a json client request and has to be parsed.
It takes the default value if missing (for component selection and
options).
:param config: dictionary that give the component to use for each step
... | [
"Configure",
"all",
"the",
"blocks",
"from",
"an",
"(",
"horible",
")",
"configuration",
"dictionary",
"this",
"data",
"are",
"coming",
"from",
"a",
"json",
"client",
"request",
"and",
"has",
"to",
"be",
"parsed",
".",
"It",
"takes",
"the",
"default",
"val... | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L790-L852 |
kodexlab/reliure | reliure/engine.py | Engine.validate | def validate(self, inputs=None):
""" Check that the blocks configuration is ok
:param inputs: the names of the play inputs
:type inputs: list of str
"""
# if no blocks...
if not len(self._blocks):
#TODO: find better error than ReliureError ?
... | python | def validate(self, inputs=None):
""" Check that the blocks configuration is ok
:param inputs: the names of the play inputs
:type inputs: list of str
"""
# if no blocks...
if not len(self._blocks):
#TODO: find better error than ReliureError ?
... | [
"def",
"validate",
"(",
"self",
",",
"inputs",
"=",
"None",
")",
":",
"# if no blocks...",
"if",
"not",
"len",
"(",
"self",
".",
"_blocks",
")",
":",
"#TODO: find better error than ReliureError ?",
"raise",
"ReliureError",
"(",
"\"There is no block in this engine\"",
... | Check that the blocks configuration is ok
:param inputs: the names of the play inputs
:type inputs: list of str | [
"Check",
"that",
"the",
"blocks",
"configuration",
"is",
"ok",
":",
"param",
"inputs",
":",
"the",
"names",
"of",
"the",
"play",
"inputs",
":",
"type",
"inputs",
":",
"list",
"of",
"str"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L854-L890 |
kodexlab/reliure | reliure/engine.py | Engine.needed_inputs | def needed_inputs(self):
""" List all the needed inputs of a configured engine
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
>>> engine.op1.append(lambda x:x+2)
... | python | def needed_inputs(self):
""" List all the needed inputs of a configured engine
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
>>> engine.op1.append(lambda x:x+2)
... | [
"def",
"needed_inputs",
"(",
"self",
")",
":",
"needed",
"=",
"set",
"(",
")",
"available",
"=",
"set",
"(",
")",
"# set of available data",
"for",
"bnum",
",",
"block",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"not",
"block",
".",
"selected",
"... | List all the needed inputs of a configured engine
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
>>> engine.op1.append(lambda x:x+2)
>>> engine.op2.append(lambda x:x*2... | [
"List",
"all",
"the",
"needed",
"inputs",
"of",
"a",
"configured",
"engine"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L892-L942 |
kodexlab/reliure | reliure/engine.py | Engine.all_outputs | def all_outputs(self):
""" Returns a list of all engine possible outputs (note that inputs are
also possible inputs)
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
... | python | def all_outputs(self):
""" Returns a list of all engine possible outputs (note that inputs are
also possible inputs)
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
... | [
"def",
"all_outputs",
"(",
"self",
")",
":",
"outputs",
"=",
"set",
"(",
")",
"for",
"block",
"in",
"self",
":",
"outputs",
".",
"update",
"(",
"block",
".",
"in_name",
"or",
"[",
"Engine",
".",
"DEFAULT_IN_NAME",
"]",
")",
"outputs",
".",
"update",
... | Returns a list of all engine possible outputs (note that inputs are
also possible inputs)
>>> engine = Engine("op1", "op2")
>>> engine.op1.setup(in_name="in", out_name="middle", required=False)
>>> engine.op2.setup(in_name="middle", out_name="out")
>>> sorted(list(engine.all_out... | [
"Returns",
"a",
"list",
"of",
"all",
"engine",
"possible",
"outputs",
"(",
"note",
"that",
"inputs",
"are",
"also",
"possible",
"inputs",
")"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L944-L975 |
kodexlab/reliure | reliure/engine.py | Engine.play | def play(self, *inputs, **named_inputs):
""" Run the engine (that should have been configured first)
if the `inputs` are given without name it should be the inputs of the
first block, ig `named_inputs` are used it may be the inputs of any
block.
.. note:: Either... | python | def play(self, *inputs, **named_inputs):
""" Run the engine (that should have been configured first)
if the `inputs` are given without name it should be the inputs of the
first block, ig `named_inputs` are used it may be the inputs of any
block.
.. note:: Either... | [
"def",
"play",
"(",
"self",
",",
"*",
"inputs",
",",
"*",
"*",
"named_inputs",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"\"\\n\\n\\t\\t\\t ** ============= play engine ============= ** \\n\"",
")",
"#",
"# create data structure for results and metaresults",
"... | Run the engine (that should have been configured first)
if the `inputs` are given without name it should be the inputs of the
first block, ig `named_inputs` are used it may be the inputs of any
block.
.. note:: Either `inputs` or `named_inputs` should be provided, not b... | [
"Run",
"the",
"engine",
"(",
"that",
"should",
"have",
"been",
"configured",
"first",
")",
"if",
"the",
"inputs",
"are",
"given",
"without",
"name",
"it",
"should",
"be",
"the",
"inputs",
"of",
"the",
"first",
"block",
"ig",
"named_inputs",
"are",
"used",
... | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L977-L1031 |
kodexlab/reliure | reliure/engine.py | Engine.as_dict | def as_dict(self):
""" dict repr of the components """
drepr = {
'blocks': [
block.as_dict() for block in self if block.hidden == False
],
'args': list(self.needed_inputs())
}
return drepr | python | def as_dict(self):
""" dict repr of the components """
drepr = {
'blocks': [
block.as_dict() for block in self if block.hidden == False
],
'args': list(self.needed_inputs())
}
return drepr | [
"def",
"as_dict",
"(",
"self",
")",
":",
"drepr",
"=",
"{",
"'blocks'",
":",
"[",
"block",
".",
"as_dict",
"(",
")",
"for",
"block",
"in",
"self",
"if",
"block",
".",
"hidden",
"==",
"False",
"]",
",",
"'args'",
":",
"list",
"(",
"self",
".",
"ne... | dict repr of the components | [
"dict",
"repr",
"of",
"the",
"components"
] | train | https://github.com/kodexlab/reliure/blob/0450c7a9254c5c003162738458bbe0c49e777ba5/reliure/engine.py#L1033-L1041 |
messense/extender | extender/manager.py | InstanceManager.all | def all(self):
"""
Returns a list of cached instances.
"""
class_list = list(self.get_class_list())
if not class_list:
self.cache = []
return []
if self.cache is not None:
return self.cache
results = []
for cls_path in... | python | def all(self):
"""
Returns a list of cached instances.
"""
class_list = list(self.get_class_list())
if not class_list:
self.cache = []
return []
if self.cache is not None:
return self.cache
results = []
for cls_path in... | [
"def",
"all",
"(",
"self",
")",
":",
"class_list",
"=",
"list",
"(",
"self",
".",
"get_class_list",
"(",
")",
")",
"if",
"not",
"class_list",
":",
"self",
".",
"cache",
"=",
"[",
"]",
"return",
"[",
"]",
"if",
"self",
".",
"cache",
"is",
"not",
"... | Returns a list of cached instances. | [
"Returns",
"a",
"list",
"of",
"cached",
"instances",
"."
] | train | https://github.com/messense/extender/blob/511a1712494d65133a0dbabca3d849e2f8c500c2/extender/manager.py#L38-L65 |
eeue56/PyChat.js | pychatjs/server/parser.py | Parser.parse_message | def parse_message(self, message):
""" Parse a given message and run the command using the
connection and the json protocals """
service = None
try:
service = get_service(message)
except ValueError:
pass
conn = self.connec... | python | def parse_message(self, message):
""" Parse a given message and run the command using the
connection and the json protocals """
service = None
try:
service = get_service(message)
except ValueError:
pass
conn = self.connec... | [
"def",
"parse_message",
"(",
"self",
",",
"message",
")",
":",
"service",
"=",
"None",
"try",
":",
"service",
"=",
"get_service",
"(",
"message",
")",
"except",
"ValueError",
":",
"pass",
"conn",
"=",
"self",
".",
"connection",
"# check if valid request\r",
... | Parse a given message and run the command using the
connection and the json protocals | [
"Parse",
"a",
"given",
"message",
"and",
"run",
"the",
"command",
"using",
"the",
"connection",
"and",
"the",
"json",
"protocals"
] | train | https://github.com/eeue56/PyChat.js/blob/45056de6f988350c90a6dbe674459a4affde8abc/pychatjs/server/parser.py#L15-L107 |
HEPData/hepdata-converter-ws-client | hepdata_converter_ws_client/__init__.py | convert | def convert(url, input, output=None, options={}, id=None, extract=True):
"""Wrapper function around requests library providing easy way to interact
with hepdata-converter-ws (web services).
:param url: path to server hosting hepdata-converter-ws (web services) - url has to point to root server
(not ```... | python | def convert(url, input, output=None, options={}, id=None, extract=True):
"""Wrapper function around requests library providing easy way to interact
with hepdata-converter-ws (web services).
:param url: path to server hosting hepdata-converter-ws (web services) - url has to point to root server
(not ```... | [
"def",
"convert",
"(",
"url",
",",
"input",
",",
"output",
"=",
"None",
",",
"options",
"=",
"{",
"}",
",",
"id",
"=",
"None",
",",
"extract",
"=",
"True",
")",
":",
"input_stream",
"=",
"cStringIO",
".",
"StringIO",
"(",
")",
"output_defined",
"=",
... | Wrapper function around requests library providing easy way to interact
with hepdata-converter-ws (web services).
:param url: path to server hosting hepdata-converter-ws (web services) - url has to point to root server
(not ```/convert``` or any other specific route) just http(s)://address:port
:type u... | [
"Wrapper",
"function",
"around",
"requests",
"library",
"providing",
"easy",
"way",
"to",
"interact",
"with",
"hepdata",
"-",
"converter",
"-",
"ws",
"(",
"web",
"services",
")",
"."
] | train | https://github.com/HEPData/hepdata-converter-ws-client/blob/0be5c6d284e0be4b69240ad2798faf802c088738/hepdata_converter_ws_client/__init__.py#L16-L130 |
mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig._download_initial_config | def _download_initial_config(self):
"""Loads the initial config."""
_initial_config = self._download_running_config() # this is a bit slow!
self._last_working_config = _initial_config
self._config_history.append(_initial_config)
self._config_history.append(_initial_config) | python | def _download_initial_config(self):
"""Loads the initial config."""
_initial_config = self._download_running_config() # this is a bit slow!
self._last_working_config = _initial_config
self._config_history.append(_initial_config)
self._config_history.append(_initial_config) | [
"def",
"_download_initial_config",
"(",
"self",
")",
":",
"_initial_config",
"=",
"self",
".",
"_download_running_config",
"(",
")",
"# this is a bit slow!",
"self",
".",
"_last_working_config",
"=",
"_initial_config",
"self",
".",
"_config_history",
".",
"append",
"(... | Loads the initial config. | [
"Loads",
"the",
"initial",
"config",
"."
] | train | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L52-L57 |
mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig._upload_config_content | def _upload_config_content(self, configuration, rollbacked=False):
"""Will try to upload a specific configuration on the device."""
try:
for configuration_line in configuration.splitlines():
self._device.cli(configuration_line)
self._config_changed = True # confi... | python | def _upload_config_content(self, configuration, rollbacked=False):
"""Will try to upload a specific configuration on the device."""
try:
for configuration_line in configuration.splitlines():
self._device.cli(configuration_line)
self._config_changed = True # confi... | [
"def",
"_upload_config_content",
"(",
"self",
",",
"configuration",
",",
"rollbacked",
"=",
"False",
")",
":",
"try",
":",
"for",
"configuration_line",
"in",
"configuration",
".",
"splitlines",
"(",
")",
":",
"self",
".",
"_device",
".",
"cli",
"(",
"configu... | Will try to upload a specific configuration on the device. | [
"Will",
"try",
"to",
"upload",
"a",
"specific",
"configuration",
"on",
"the",
"device",
"."
] | train | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L63-L78 |
mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.load_candidate | def load_candidate(self, filename=None, config=None):
"""
Loads a candidate configuration on the device.
In case the load fails at any point, will automatically rollback to last working configuration.
:param filename: Specifies the name of the file with the configuration content.
... | python | def load_candidate(self, filename=None, config=None):
"""
Loads a candidate configuration on the device.
In case the load fails at any point, will automatically rollback to last working configuration.
:param filename: Specifies the name of the file with the configuration content.
... | [
"def",
"load_candidate",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"config",
"=",
"None",
")",
":",
"configuration",
"=",
"''",
"if",
"filename",
"is",
"None",
":",
"configuration",
"=",
"config",
"else",
":",
"with",
"open",
"(",
"filename",
")",
... | Loads a candidate configuration on the device.
In case the load fails at any point, will automatically rollback to last working configuration.
:param filename: Specifies the name of the file with the configuration content.
:param config: New configuration to be uploaded on the device.
:... | [
"Loads",
"a",
"candidate",
"configuration",
"on",
"the",
"device",
".",
"In",
"case",
"the",
"load",
"fails",
"at",
"any",
"point",
"will",
"automatically",
"rollback",
"to",
"last",
"working",
"configuration",
"."
] | train | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L88-L106 |
mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.discard | def discard(self): # pylint: disable=no-self-use
"""
Clears uncommited changes.
:raise pyPluribus.exceptions.ConfigurationDiscardError: If the configuration applied cannot be discarded.
"""
try:
self.rollback(0)
except pyPluribus.exceptions.RollbackError as ... | python | def discard(self): # pylint: disable=no-self-use
"""
Clears uncommited changes.
:raise pyPluribus.exceptions.ConfigurationDiscardError: If the configuration applied cannot be discarded.
"""
try:
self.rollback(0)
except pyPluribus.exceptions.RollbackError as ... | [
"def",
"discard",
"(",
"self",
")",
":",
"# pylint: disable=no-self-use",
"try",
":",
"self",
".",
"rollback",
"(",
"0",
")",
"except",
"pyPluribus",
".",
"exceptions",
".",
"RollbackError",
"as",
"rbackerr",
":",
"raise",
"pyPluribus",
".",
"exceptions",
".",... | Clears uncommited changes.
:raise pyPluribus.exceptions.ConfigurationDiscardError: If the configuration applied cannot be discarded. | [
"Clears",
"uncommited",
"changes",
"."
] | train | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L108-L118 |
mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.commit | def commit(self): # pylint: disable=no-self-use
"""Will commit the changes on the device"""
if self._config_changed:
self._last_working_config = self._download_running_config()
self._config_history.append(self._last_working_config)
self._committed = True # comfigura... | python | def commit(self): # pylint: disable=no-self-use
"""Will commit the changes on the device"""
if self._config_changed:
self._last_working_config = self._download_running_config()
self._config_history.append(self._last_working_config)
self._committed = True # comfigura... | [
"def",
"commit",
"(",
"self",
")",
":",
"# pylint: disable=no-self-use",
"if",
"self",
".",
"_config_changed",
":",
"self",
".",
"_last_working_config",
"=",
"self",
".",
"_download_running_config",
"(",
")",
"self",
".",
"_config_history",
".",
"append",
"(",
"... | Will commit the changes on the device | [
"Will",
"commit",
"the",
"changes",
"on",
"the",
"device"
] | train | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L120-L130 |
mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.compare | def compare(self): # pylint: disable=no-self-use
"""
Computes the difference between the candidate config and the running config.
"""
# becuase we emulate the configuration history
# the difference is between the last committed config and the running-config
running_confi... | python | def compare(self): # pylint: disable=no-self-use
"""
Computes the difference between the candidate config and the running config.
"""
# becuase we emulate the configuration history
# the difference is between the last committed config and the running-config
running_confi... | [
"def",
"compare",
"(",
"self",
")",
":",
"# pylint: disable=no-self-use",
"# becuase we emulate the configuration history",
"# the difference is between the last committed config and the running-config",
"running_config",
"=",
"self",
".",
"_download_running_config",
"(",
")",
"runni... | Computes the difference between the candidate config and the running config. | [
"Computes",
"the",
"difference",
"between",
"the",
"candidate",
"config",
"and",
"the",
"running",
"config",
"."
] | train | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L132-L143 |
mirceaulinic/pypluribus | pyPluribus/config.py | PluribusConfig.rollback | def rollback(self, number=0):
"""
Will rollback the configuration to a previous state.
Can be called also when
:param number: How many steps back in the configuration history must look back.
:raise pyPluribus.exceptions.RollbackError: In case the configuration cannot be rolled b... | python | def rollback(self, number=0):
"""
Will rollback the configuration to a previous state.
Can be called also when
:param number: How many steps back in the configuration history must look back.
:raise pyPluribus.exceptions.RollbackError: In case the configuration cannot be rolled b... | [
"def",
"rollback",
"(",
"self",
",",
"number",
"=",
"0",
")",
":",
"if",
"number",
"<",
"0",
":",
"raise",
"pyPluribus",
".",
"exceptions",
".",
"RollbackError",
"(",
"\"Please provide a positive number to rollback to!\"",
")",
"available_configs",
"=",
"len",
"... | Will rollback the configuration to a previous state.
Can be called also when
:param number: How many steps back in the configuration history must look back.
:raise pyPluribus.exceptions.RollbackError: In case the configuration cannot be rolled back. | [
"Will",
"rollback",
"the",
"configuration",
"to",
"a",
"previous",
"state",
".",
"Can",
"be",
"called",
"also",
"when"
] | train | https://github.com/mirceaulinic/pypluribus/blob/99bb9b6de40a0e465e3f0e6636b26acdeabbbd90/pyPluribus/config.py#L145-L176 |
nens/turn | turn/core.py | Queue.draw | def draw(self, label, expire):
"""
Return a Serial number for this resource queue, after bootstrapping.
"""
# get next number
with self.client.pipeline() as pipe:
pipe.msetnx({self.keys.dispenser: 0, self.keys.indicator: 1})
pipe.incr(self.keys.dispenser)
... | python | def draw(self, label, expire):
"""
Return a Serial number for this resource queue, after bootstrapping.
"""
# get next number
with self.client.pipeline() as pipe:
pipe.msetnx({self.keys.dispenser: 0, self.keys.indicator: 1})
pipe.incr(self.keys.dispenser)
... | [
"def",
"draw",
"(",
"self",
",",
"label",
",",
"expire",
")",
":",
"# get next number",
"with",
"self",
".",
"client",
".",
"pipeline",
"(",
")",
"as",
"pipe",
":",
"pipe",
".",
"msetnx",
"(",
"{",
"self",
".",
"keys",
".",
"dispenser",
":",
"0",
"... | Return a Serial number for this resource queue, after bootstrapping. | [
"Return",
"a",
"Serial",
"number",
"for",
"this",
"resource",
"queue",
"after",
"bootstrapping",
"."
] | train | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L98-L126 |
nens/turn | turn/core.py | Queue.wait | def wait(self, number, patience):
""" Waits and resets if necessary. """
# inspect indicator for our number
waiting = int(self.client.get(self.keys.indicator)) != number
# wait until someone announces our number
while waiting:
message = self.subscription.listen(patie... | python | def wait(self, number, patience):
""" Waits and resets if necessary. """
# inspect indicator for our number
waiting = int(self.client.get(self.keys.indicator)) != number
# wait until someone announces our number
while waiting:
message = self.subscription.listen(patie... | [
"def",
"wait",
"(",
"self",
",",
"number",
",",
"patience",
")",
":",
"# inspect indicator for our number",
"waiting",
"=",
"int",
"(",
"self",
".",
"client",
".",
"get",
"(",
"self",
".",
"keys",
".",
"indicator",
")",
")",
"!=",
"number",
"# wait until s... | Waits and resets if necessary. | [
"Waits",
"and",
"resets",
"if",
"necessary",
"."
] | train | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L128-L147 |
nens/turn | turn/core.py | Queue.message | def message(self, text):
""" Public message. """
self.client.publish(self.keys.external,
'{}: {}'.format(self.resource, text)) | python | def message(self, text):
""" Public message. """
self.client.publish(self.keys.external,
'{}: {}'.format(self.resource, text)) | [
"def",
"message",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"client",
".",
"publish",
"(",
"self",
".",
"keys",
".",
"external",
",",
"'{}: {}'",
".",
"format",
"(",
"self",
".",
"resource",
",",
"text",
")",
")"
] | Public message. | [
"Public",
"message",
"."
] | train | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L149-L152 |
nens/turn | turn/core.py | Queue.announce | def announce(self, number):
""" Announce an indicator change on both channels. """
self.client.publish(self.keys.internal, self.keys.key(number))
self.message('{} granted'.format(number)) | python | def announce(self, number):
""" Announce an indicator change on both channels. """
self.client.publish(self.keys.internal, self.keys.key(number))
self.message('{} granted'.format(number)) | [
"def",
"announce",
"(",
"self",
",",
"number",
")",
":",
"self",
".",
"client",
".",
"publish",
"(",
"self",
".",
"keys",
".",
"internal",
",",
"self",
".",
"keys",
".",
"key",
"(",
"number",
")",
")",
"self",
".",
"message",
"(",
"'{} granted'",
"... | Announce an indicator change on both channels. | [
"Announce",
"an",
"indicator",
"change",
"on",
"both",
"channels",
"."
] | train | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L154-L157 |
nens/turn | turn/core.py | Queue.bump | def bump(self):
""" Fix indicator in case of unnanounced departments. """
# read client
values = self.client.mget(self.keys.indicator, self.keys.dispenser)
indicator, dispenser = map(int, values)
# determine active users
numbers = range(indicator, dispenser + 1)
... | python | def bump(self):
""" Fix indicator in case of unnanounced departments. """
# read client
values = self.client.mget(self.keys.indicator, self.keys.dispenser)
indicator, dispenser = map(int, values)
# determine active users
numbers = range(indicator, dispenser + 1)
... | [
"def",
"bump",
"(",
"self",
")",
":",
"# read client",
"values",
"=",
"self",
".",
"client",
".",
"mget",
"(",
"self",
".",
"keys",
".",
"indicator",
",",
"self",
".",
"keys",
".",
"dispenser",
")",
"indicator",
",",
"dispenser",
"=",
"map",
"(",
"in... | Fix indicator in case of unnanounced departments. | [
"Fix",
"indicator",
"in",
"case",
"of",
"unnanounced",
"departments",
"."
] | train | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L159-L184 |
nens/turn | turn/core.py | Locker.lock | def lock(self, resource, label='', expire=60, patience=60):
"""
Lock a resource.
:param resource: String corresponding to resource type
:param label: String label to attach
:param expire: int seconds
:param patience: int seconds
"""
queue = Queue(client=s... | python | def lock(self, resource, label='', expire=60, patience=60):
"""
Lock a resource.
:param resource: String corresponding to resource type
:param label: String label to attach
:param expire: int seconds
:param patience: int seconds
"""
queue = Queue(client=s... | [
"def",
"lock",
"(",
"self",
",",
"resource",
",",
"label",
"=",
"''",
",",
"expire",
"=",
"60",
",",
"patience",
"=",
"60",
")",
":",
"queue",
"=",
"Queue",
"(",
"client",
"=",
"self",
".",
"client",
",",
"resource",
"=",
"resource",
")",
"with",
... | Lock a resource.
:param resource: String corresponding to resource type
:param label: String label to attach
:param expire: int seconds
:param patience: int seconds | [
"Lock",
"a",
"resource",
"."
] | train | https://github.com/nens/turn/blob/98e806a0749ada0ddfd04b3c29fb04c15bf5ac18/turn/core.py#L205-L218 |
pysigma/core | sigma/core/validator.py | FieldValidator.validate | def validate(self, value):
""" Validate value.
Args:
value:
Returns:
A validated value.
Raises:
UnitError
"""
for validate in self.validates:
value = validate(value)
return value | python | def validate(self, value):
""" Validate value.
Args:
value:
Returns:
A validated value.
Raises:
UnitError
"""
for validate in self.validates:
value = validate(value)
return value | [
"def",
"validate",
"(",
"self",
",",
"value",
")",
":",
"for",
"validate",
"in",
"self",
".",
"validates",
":",
"value",
"=",
"validate",
"(",
"value",
")",
"return",
"value"
] | Validate value.
Args:
value:
Returns:
A validated value.
Raises:
UnitError | [
"Validate",
"value",
".",
"Args",
":",
"value",
":",
"Returns",
":",
"A",
"validated",
"value",
".",
"Raises",
":",
"UnitError"
] | train | https://github.com/pysigma/core/blob/89fe0d99e8cba015aad245dfda8465af99d1ab9d/sigma/core/validator.py#L39-L50 |
jtpaasch/simplygithub | simplygithub/internals/refs.py | prepare | def prepare(data):
"""Restructure/prepare data about refs for output."""
ref = data.get("ref")
obj = data.get("object")
sha = obj.get("sha")
return {"ref": ref, "head": {"sha": sha}} | python | def prepare(data):
"""Restructure/prepare data about refs for output."""
ref = data.get("ref")
obj = data.get("object")
sha = obj.get("sha")
return {"ref": ref, "head": {"sha": sha}} | [
"def",
"prepare",
"(",
"data",
")",
":",
"ref",
"=",
"data",
".",
"get",
"(",
"\"ref\"",
")",
"obj",
"=",
"data",
".",
"get",
"(",
"\"object\"",
")",
"sha",
"=",
"obj",
".",
"get",
"(",
"\"sha\"",
")",
"return",
"{",
"\"ref\"",
":",
"ref",
",",
... | Restructure/prepare data about refs for output. | [
"Restructure",
"/",
"prepare",
"data",
"about",
"refs",
"for",
"output",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/refs.py#L8-L13 |
jtpaasch/simplygithub | simplygithub/internals/refs.py | list_refs | def list_refs(profile, ref_type=None):
"""List all refs.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref_type
... | python | def list_refs(profile, ref_type=None):
"""List all refs.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref_type
... | [
"def",
"list_refs",
"(",
"profile",
",",
"ref_type",
"=",
"None",
")",
":",
"resource",
"=",
"\"/refs\"",
"if",
"ref_type",
":",
"resource",
"+=",
"\"/\"",
"+",
"ref_type",
"data",
"=",
"api",
".",
"get_request",
"(",
"profile",
",",
"resource",
")",
"re... | List all refs.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref_type
The type of ref you want. For heads, it's ... | [
"List",
"all",
"refs",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/refs.py#L16-L40 |
jtpaasch/simplygithub | simplygithub/internals/refs.py | get_ref | def get_ref(profile, ref):
"""Fetch a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to fetc... | python | def get_ref(profile, ref):
"""Fetch a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to fetc... | [
"def",
"get_ref",
"(",
"profile",
",",
"ref",
")",
":",
"resource",
"=",
"\"/refs/\"",
"+",
"ref",
"data",
"=",
"api",
".",
"get_request",
"(",
"profile",
",",
"resource",
")",
"return",
"prepare",
"(",
"data",
")"
] | Fetch a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to fetch, e.g., ``heads/my-feature-branch... | [
"Fetch",
"a",
"ref",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/refs.py#L43-L62 |
jtpaasch/simplygithub | simplygithub/internals/refs.py | create_ref | def create_ref(profile, ref, sha):
"""Create a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The re... | python | def create_ref(profile, ref, sha):
"""Create a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The re... | [
"def",
"create_ref",
"(",
"profile",
",",
"ref",
",",
"sha",
")",
":",
"resource",
"=",
"\"/refs\"",
"payload",
"=",
"{",
"\"ref\"",
":",
"\"refs/\"",
"+",
"ref",
",",
"\"sha\"",
":",
"sha",
"}",
"data",
"=",
"api",
".",
"post_request",
"(",
"profile",... | Create a ref.
Args:
profile
A profile generated from ``simplygithub.authentication.profile``.
Such profiles tell this module (i) the ``repo`` to connect to,
and (ii) the ``token`` to connect with.
ref
The ref to create, e.g., ``heads/my-feature-bran... | [
"Create",
"a",
"ref",
"."
] | train | https://github.com/jtpaasch/simplygithub/blob/b77506275ec276ce90879bf1ea9299a79448b903/simplygithub/internals/refs.py#L65-L88 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.