id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
52,300 | dcaune/perseus-lib-python-common | exifread/exif_log.py | setup_logger | def setup_logger(debug, color):
"""Configure the logger."""
if debug:
log_level = logging.DEBUG
else:
log_level = logging.INFO
logger = logging.getLogger('exifread')
stream = Handler(log_level, debug, color)
logger.addHandler(stream)
logger.setLevel(log_level) | python | def setup_logger(debug, color):
"""Configure the logger."""
if debug:
log_level = logging.DEBUG
else:
log_level = logging.INFO
logger = logging.getLogger('exifread')
stream = Handler(log_level, debug, color)
logger.addHandler(stream)
logger.setLevel(log_level) | [
"def",
"setup_logger",
"(",
"debug",
",",
"color",
")",
":",
"if",
"debug",
":",
"log_level",
"=",
"logging",
".",
"DEBUG",
"else",
":",
"log_level",
"=",
"logging",
".",
"INFO",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'exifread'",
")",
"stream... | Configure the logger. | [
"Configure",
"the",
"logger",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/exif_log.py#L22-L32 |
52,301 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/sanitizer.py | sanitize | def sanitize(configuration, error_fn):
"""
Run all availalbe sanitizers across a configuration.
Arguments:
configuration - a full project configuration
error_fn - A function to call if a sanitizer check fails. The function
takes a single argument: a description of the problem; provi... | python | def sanitize(configuration, error_fn):
"""
Run all availalbe sanitizers across a configuration.
Arguments:
configuration - a full project configuration
error_fn - A function to call if a sanitizer check fails. The function
takes a single argument: a description of the problem; provi... | [
"def",
"sanitize",
"(",
"configuration",
",",
"error_fn",
")",
":",
"for",
"name",
",",
"sanitize_fn",
"in",
"_SANITIZERS",
".",
"items",
"(",
")",
":",
"sanitize_fn",
"(",
"configuration",
",",
"lambda",
"warning",
",",
"n",
"=",
"name",
":",
"error_fn",
... | Run all availalbe sanitizers across a configuration.
Arguments:
configuration - a full project configuration
error_fn - A function to call if a sanitizer check fails. The function
takes a single argument: a description of the problem; provide
specifics if possible, including ... | [
"Run",
"all",
"availalbe",
"sanitizers",
"across",
"a",
"configuration",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/sanitizer.py#L61-L73 |
52,302 | dcaune/perseus-lib-python-common | exifread/classes.py | ExifHeader.s2n | def s2n(self, offset, length, signed=0):
"""
Convert slice to integer, based on sign and endian flags.
Usually this offset is assumed to be relative to the beginning of the
start of the EXIF information.
For some cameras that use relative tags, this offset may be relative
... | python | def s2n(self, offset, length, signed=0):
"""
Convert slice to integer, based on sign and endian flags.
Usually this offset is assumed to be relative to the beginning of the
start of the EXIF information.
For some cameras that use relative tags, this offset may be relative
... | [
"def",
"s2n",
"(",
"self",
",",
"offset",
",",
"length",
",",
"signed",
"=",
"0",
")",
":",
"self",
".",
"file",
".",
"seek",
"(",
"self",
".",
"offset",
"+",
"offset",
")",
"sliced",
"=",
"self",
".",
"file",
".",
"read",
"(",
"length",
")",
"... | Convert slice to integer, based on sign and endian flags.
Usually this offset is assumed to be relative to the beginning of the
start of the EXIF information.
For some cameras that use relative tags, this offset may be relative
to some other starting point. | [
"Convert",
"slice",
"to",
"integer",
"based",
"on",
"sign",
"and",
"endian",
"flags",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L64-L84 |
52,303 | dcaune/perseus-lib-python-common | exifread/classes.py | ExifHeader.n2s | def n2s(self, offset, length):
"""Convert offset to string."""
s = ''
for dummy in range(length):
if self.endian == 'I':
s += chr(offset & 0xFF)
else:
s = chr(offset & 0xFF) + s
offset = offset >> 8
return s | python | def n2s(self, offset, length):
"""Convert offset to string."""
s = ''
for dummy in range(length):
if self.endian == 'I':
s += chr(offset & 0xFF)
else:
s = chr(offset & 0xFF) + s
offset = offset >> 8
return s | [
"def",
"n2s",
"(",
"self",
",",
"offset",
",",
"length",
")",
":",
"s",
"=",
"''",
"for",
"dummy",
"in",
"range",
"(",
"length",
")",
":",
"if",
"self",
".",
"endian",
"==",
"'I'",
":",
"s",
"+=",
"chr",
"(",
"offset",
"&",
"0xFF",
")",
"else",... | Convert offset to string. | [
"Convert",
"offset",
"to",
"string",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L86-L95 |
52,304 | dcaune/perseus-lib-python-common | exifread/classes.py | ExifHeader._next_ifd | def _next_ifd(self, ifd):
"""Return the pointer to next IFD."""
entries = self.s2n(ifd, 2)
next_ifd = self.s2n(ifd + 2 + 12 * entries, 4)
if next_ifd == ifd:
return 0
else:
return next_ifd | python | def _next_ifd(self, ifd):
"""Return the pointer to next IFD."""
entries = self.s2n(ifd, 2)
next_ifd = self.s2n(ifd + 2 + 12 * entries, 4)
if next_ifd == ifd:
return 0
else:
return next_ifd | [
"def",
"_next_ifd",
"(",
"self",
",",
"ifd",
")",
":",
"entries",
"=",
"self",
".",
"s2n",
"(",
"ifd",
",",
"2",
")",
"next_ifd",
"=",
"self",
".",
"s2n",
"(",
"ifd",
"+",
"2",
"+",
"12",
"*",
"entries",
",",
"4",
")",
"if",
"next_ifd",
"==",
... | Return the pointer to next IFD. | [
"Return",
"the",
"pointer",
"to",
"next",
"IFD",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L101-L108 |
52,305 | dcaune/perseus-lib-python-common | exifread/classes.py | ExifHeader.list_ifd | def list_ifd(self):
"""Return the list of IFDs in the header."""
i = self._first_ifd()
ifds = []
while i:
ifds.append(i)
i = self._next_ifd(i)
return ifds | python | def list_ifd(self):
"""Return the list of IFDs in the header."""
i = self._first_ifd()
ifds = []
while i:
ifds.append(i)
i = self._next_ifd(i)
return ifds | [
"def",
"list_ifd",
"(",
"self",
")",
":",
"i",
"=",
"self",
".",
"_first_ifd",
"(",
")",
"ifds",
"=",
"[",
"]",
"while",
"i",
":",
"ifds",
".",
"append",
"(",
"i",
")",
"i",
"=",
"self",
".",
"_next_ifd",
"(",
"i",
")",
"return",
"ifds"
] | Return the list of IFDs in the header. | [
"Return",
"the",
"list",
"of",
"IFDs",
"in",
"the",
"header",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L110-L117 |
52,306 | dcaune/perseus-lib-python-common | exifread/classes.py | ExifHeader.extract_tiff_thumbnail | def extract_tiff_thumbnail(self, thumb_ifd):
"""
Extract uncompressed TIFF thumbnail.
Take advantage of the pre-existing layout in the thumbnail IFD as
much as possible
"""
thumb = self.tags.get('Thumbnail Compression')
if not thumb or thumb.printable != 'Uncompr... | python | def extract_tiff_thumbnail(self, thumb_ifd):
"""
Extract uncompressed TIFF thumbnail.
Take advantage of the pre-existing layout in the thumbnail IFD as
much as possible
"""
thumb = self.tags.get('Thumbnail Compression')
if not thumb or thumb.printable != 'Uncompr... | [
"def",
"extract_tiff_thumbnail",
"(",
"self",
",",
"thumb_ifd",
")",
":",
"thumb",
"=",
"self",
".",
"tags",
".",
"get",
"(",
"'Thumbnail Compression'",
")",
"if",
"not",
"thumb",
"or",
"thumb",
".",
"printable",
"!=",
"'Uncompressed TIFF'",
":",
"return",
"... | Extract uncompressed TIFF thumbnail.
Take advantage of the pre-existing layout in the thumbnail IFD as
much as possible | [
"Extract",
"uncompressed",
"TIFF",
"thumbnail",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L272-L333 |
52,307 | dcaune/perseus-lib-python-common | exifread/classes.py | ExifHeader.extract_jpeg_thumbnail | def extract_jpeg_thumbnail(self):
"""
Extract JPEG thumbnail.
(Thankfully the JPEG data is stored as a unit.)
"""
thumb_offset = self.tags.get('Thumbnail JPEGInterchangeFormat')
if thumb_offset:
self.file.seek(self.offset + thumb_offset.values[0])
... | python | def extract_jpeg_thumbnail(self):
"""
Extract JPEG thumbnail.
(Thankfully the JPEG data is stored as a unit.)
"""
thumb_offset = self.tags.get('Thumbnail JPEGInterchangeFormat')
if thumb_offset:
self.file.seek(self.offset + thumb_offset.values[0])
... | [
"def",
"extract_jpeg_thumbnail",
"(",
"self",
")",
":",
"thumb_offset",
"=",
"self",
".",
"tags",
".",
"get",
"(",
"'Thumbnail JPEGInterchangeFormat'",
")",
"if",
"thumb_offset",
":",
"self",
".",
"file",
".",
"seek",
"(",
"self",
".",
"offset",
"+",
"thumb_... | Extract JPEG thumbnail.
(Thankfully the JPEG data is stored as a unit.) | [
"Extract",
"JPEG",
"thumbnail",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L335-L353 |
52,308 | dcaune/perseus-lib-python-common | exifread/classes.py | ExifHeader._canon_decode_tag | def _canon_decode_tag(self, value, mn_tags):
"""
Decode Canon MakerNote tag based on offset within tag.
See http://www.burren.cx/david/canon.html by David Burren
"""
for i in range(1, len(value)):
tag = mn_tags.get(i, ('Unknown', ))
name = tag[0]
... | python | def _canon_decode_tag(self, value, mn_tags):
"""
Decode Canon MakerNote tag based on offset within tag.
See http://www.burren.cx/david/canon.html by David Burren
"""
for i in range(1, len(value)):
tag = mn_tags.get(i, ('Unknown', ))
name = tag[0]
... | [
"def",
"_canon_decode_tag",
"(",
"self",
",",
"value",
",",
"mn_tags",
")",
":",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"value",
")",
")",
":",
"tag",
"=",
"mn_tags",
".",
"get",
"(",
"i",
",",
"(",
"'Unknown'",
",",
")",
")",
"n... | Decode Canon MakerNote tag based on offset within tag.
See http://www.burren.cx/david/canon.html by David Burren | [
"Decode",
"Canon",
"MakerNote",
"tag",
"based",
"on",
"offset",
"within",
"tag",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L474-L495 |
52,309 | dcaune/perseus-lib-python-common | exifread/classes.py | ExifHeader._canon_decode_camera_info | def _canon_decode_camera_info(self, camera_info_tag):
"""
Decode the variable length encoded camera info section.
"""
model = self.tags.get('Image Model', None)
if not model:
return
model = str(model.values)
camera_info_tags = None
for (model_... | python | def _canon_decode_camera_info(self, camera_info_tag):
"""
Decode the variable length encoded camera info section.
"""
model = self.tags.get('Image Model', None)
if not model:
return
model = str(model.values)
camera_info_tags = None
for (model_... | [
"def",
"_canon_decode_camera_info",
"(",
"self",
",",
"camera_info_tag",
")",
":",
"model",
"=",
"self",
".",
"tags",
".",
"get",
"(",
"'Image Model'",
",",
"None",
")",
"if",
"not",
"model",
":",
"return",
"model",
"=",
"str",
"(",
"model",
".",
"values... | Decode the variable length encoded camera info section. | [
"Decode",
"the",
"variable",
"length",
"encoded",
"camera",
"info",
"section",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/classes.py#L497-L539 |
52,310 | sci-bots/pygtkhelpers | pygtkhelpers/ui/views/shapes_canvas_view.py | GtkShapesCanvasView.on_widget__configure_event | def on_widget__configure_event(self, widget, event):
'''
Called when size of drawing area changes.
'''
if event.x < 0 and event.y < 0:
# Widget has not been allocated a size yet, so do nothing.
return
self.resize(event.width, event.height) | python | def on_widget__configure_event(self, widget, event):
'''
Called when size of drawing area changes.
'''
if event.x < 0 and event.y < 0:
# Widget has not been allocated a size yet, so do nothing.
return
self.resize(event.width, event.height) | [
"def",
"on_widget__configure_event",
"(",
"self",
",",
"widget",
",",
"event",
")",
":",
"if",
"event",
".",
"x",
"<",
"0",
"and",
"event",
".",
"y",
"<",
"0",
":",
"# Widget has not been allocated a size yet, so do nothing.",
"return",
"self",
".",
"resize",
... | Called when size of drawing area changes. | [
"Called",
"when",
"size",
"of",
"drawing",
"area",
"changes",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/views/shapes_canvas_view.py#L113-L120 |
52,311 | sci-bots/pygtkhelpers | pygtkhelpers/ui/views/shapes_canvas_view.py | GtkShapesCanvasView.render_label | def render_label(self, cairo_context, shape_id, text=None, label_scale=.9):
'''
Draw label on specified shape.
Parameters
----------
cairo_context : cairo.Context
Cairo context to draw text width. Can be preconfigured, for
example, to set font style, etc... | python | def render_label(self, cairo_context, shape_id, text=None, label_scale=.9):
'''
Draw label on specified shape.
Parameters
----------
cairo_context : cairo.Context
Cairo context to draw text width. Can be preconfigured, for
example, to set font style, etc... | [
"def",
"render_label",
"(",
"self",
",",
"cairo_context",
",",
"shape_id",
",",
"text",
"=",
"None",
",",
"label_scale",
"=",
".9",
")",
":",
"text",
"=",
"shape_id",
"if",
"text",
"is",
"None",
"else",
"text",
"shape",
"=",
"self",
".",
"canvas",
".",... | Draw label on specified shape.
Parameters
----------
cairo_context : cairo.Context
Cairo context to draw text width. Can be preconfigured, for
example, to set font style, etc.
shape_id : str
Shape identifier.
text : str, optional
... | [
"Draw",
"label",
"on",
"specified",
"shape",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/views/shapes_canvas_view.py#L180-L206 |
52,312 | sci-bots/pygtkhelpers | examples/manual/d2.py | UserView.create_ui | def create_ui(self):
"""Create the user interface
create_ui is a method called during the Delegate's
initialisation process, to create, add to, or modify any UI
created by GtkBuilder files.
"""
self.entry = gtk.Entry()
self.widget.add(self.entry) | python | def create_ui(self):
"""Create the user interface
create_ui is a method called during the Delegate's
initialisation process, to create, add to, or modify any UI
created by GtkBuilder files.
"""
self.entry = gtk.Entry()
self.widget.add(self.entry) | [
"def",
"create_ui",
"(",
"self",
")",
":",
"self",
".",
"entry",
"=",
"gtk",
".",
"Entry",
"(",
")",
"self",
".",
"widget",
".",
"add",
"(",
"self",
".",
"entry",
")"
] | Create the user interface
create_ui is a method called during the Delegate's
initialisation process, to create, add to, or modify any UI
created by GtkBuilder files. | [
"Create",
"the",
"user",
"interface"
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/examples/manual/d2.py#L9-L17 |
52,313 | the01/paps-settings | paps_settings/settable_plugin.py | get_file_hash | def get_file_hash(file_path, block_size=1024, hasher=None):
"""
Generate hash for given file
:param file_path: Path to file
:type file_path: str
:param block_size: Size of block to be read at once (default: 1024)
:type block_size: int
:param hasher: Use specific hasher, defaults to md5 (def... | python | def get_file_hash(file_path, block_size=1024, hasher=None):
"""
Generate hash for given file
:param file_path: Path to file
:type file_path: str
:param block_size: Size of block to be read at once (default: 1024)
:type block_size: int
:param hasher: Use specific hasher, defaults to md5 (def... | [
"def",
"get_file_hash",
"(",
"file_path",
",",
"block_size",
"=",
"1024",
",",
"hasher",
"=",
"None",
")",
":",
"if",
"hasher",
"is",
"None",
":",
"hasher",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"open",
"(",
"file_path",
",",
"'rb'",
")",
"as... | Generate hash for given file
:param file_path: Path to file
:type file_path: str
:param block_size: Size of block to be read at once (default: 1024)
:type block_size: int
:param hasher: Use specific hasher, defaults to md5 (default: None)
:type hasher: _hashlib.HASH
:return: Hash of file
... | [
"Generate",
"hash",
"for",
"given",
"file"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/paps_settings/settable_plugin.py#L24-L45 |
52,314 | the01/paps-settings | paps_settings/settable_plugin.py | SettablePlugin.resource_get_list | def resource_get_list(self):
"""
Get list of this plugins resources and a hash to check for file changes
(It is recommended to keep a in memory representation of this struct
and not to generate it upon each request)
:return: List of supported resources and hashes
:rtype... | python | def resource_get_list(self):
"""
Get list of this plugins resources and a hash to check for file changes
(It is recommended to keep a in memory representation of this struct
and not to generate it upon each request)
:return: List of supported resources and hashes
:rtype... | [
"def",
"resource_get_list",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_resources",
":",
"return",
"self",
".",
"resource_update_list",
"(",
")",
"res",
"=",
"[",
"]",
"with",
"self",
".",
"_resource_lock",
":",
"for",
"key",
"in",
"self",
".",
... | Get list of this plugins resources and a hash to check for file changes
(It is recommended to keep a in memory representation of this struct
and not to generate it upon each request)
:return: List of supported resources and hashes
:rtype: list[(unicode, unicode)] | [
"Get",
"list",
"of",
"this",
"plugins",
"resources",
"and",
"a",
"hash",
"to",
"check",
"for",
"file",
"changes"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/paps_settings/settable_plugin.py#L118-L134 |
52,315 | the01/paps-settings | paps_settings/settable_plugin.py | SettablePlugin.resource_update_list | def resource_update_list(self, reset=False):
"""
Update internal struct of resource, hash list and get diff
(Warning: Resource names have to be unique!!)
:param reset: Should resources be rebuild from scratch (default: False)
:type reset: bool
:return: List of resources... | python | def resource_update_list(self, reset=False):
"""
Update internal struct of resource, hash list and get diff
(Warning: Resource names have to be unique!!)
:param reset: Should resources be rebuild from scratch (default: False)
:type reset: bool
:return: List of resources... | [
"def",
"resource_update_list",
"(",
"self",
",",
"reset",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"_resource_path",
":",
"raise",
"PluginException",
"(",
"\"No resource path set\"",
")",
"if",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"self",
... | Update internal struct of resource, hash list and get diff
(Warning: Resource names have to be unique!!)
:param reset: Should resources be rebuild from scratch (default: False)
:type reset: bool
:return: List of resources and hashes that changed
:rtype: list[(unicode, unicode)] | [
"Update",
"internal",
"struct",
"of",
"resource",
"hash",
"list",
"and",
"get",
"diff"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/paps_settings/settable_plugin.py#L136-L187 |
52,316 | the01/paps-settings | paps_settings/settable_plugin.py | SettablePlugin.resource_get | def resource_get(self, resource_name):
"""
Return resource info
:param resource_name: Resource name as returned by resource_get_list()
:type resource_name: str
:return: Resource information (empty if not found)
name: Resource name
hash: Resource hash
... | python | def resource_get(self, resource_name):
"""
Return resource info
:param resource_name: Resource name as returned by resource_get_list()
:type resource_name: str
:return: Resource information (empty if not found)
name: Resource name
hash: Resource hash
... | [
"def",
"resource_get",
"(",
"self",
",",
"resource_name",
")",
":",
"try",
":",
"with",
"self",
".",
"_resource_lock",
":",
"res",
"=",
"self",
".",
"_resources",
"[",
"resource_name",
"]",
"except",
"KeyError",
":",
"return",
"{",
"}",
"return",
"res"
] | Return resource info
:param resource_name: Resource name as returned by resource_get_list()
:type resource_name: str
:return: Resource information (empty if not found)
name: Resource name
hash: Resource hash
path: Path to resource
checked: Last ti... | [
"Return",
"resource",
"info"
] | 48fb65eb0fa7929a0bb381c6dad28d0197b44c83 | https://github.com/the01/paps-settings/blob/48fb65eb0fa7929a0bb381c6dad28d0197b44c83/paps_settings/settable_plugin.py#L189-L207 |
52,317 | dcaune/perseus-lib-python-common | exifread/tags/makernote/olympus.py | special_mode | def special_mode(v):
"""decode Olympus SpecialMode tag in MakerNote"""
mode1 = {
0: 'Normal',
1: 'Unknown',
2: 'Fast',
3: 'Panorama',
}
mode2 = {
0: 'Non-panoramic',
1: 'Left to right',
2: 'Right to left',
3: 'Bottom to top',
4: 'To... | python | def special_mode(v):
"""decode Olympus SpecialMode tag in MakerNote"""
mode1 = {
0: 'Normal',
1: 'Unknown',
2: 'Fast',
3: 'Panorama',
}
mode2 = {
0: 'Non-panoramic',
1: 'Left to right',
2: 'Right to left',
3: 'Bottom to top',
4: 'To... | [
"def",
"special_mode",
"(",
"v",
")",
":",
"mode1",
"=",
"{",
"0",
":",
"'Normal'",
",",
"1",
":",
"'Unknown'",
",",
"2",
":",
"'Fast'",
",",
"3",
":",
"'Panorama'",
",",
"}",
"mode2",
"=",
"{",
"0",
":",
"'Non-panoramic'",
",",
"1",
":",
"'Left ... | decode Olympus SpecialMode tag in MakerNote | [
"decode",
"Olympus",
"SpecialMode",
"tag",
"in",
"MakerNote"
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/tags/makernote/olympus.py#L4-L21 |
52,318 | klmitch/requiem | requiem/processor.py | _safe_call | def _safe_call(obj, methname, *args, **kwargs):
"""
Safely calls the method with the given methname on the given
object. Remaining positional and keyword arguments are passed to
the method. The return value is None, if the method is not
available, or the return value of the method.
"""
me... | python | def _safe_call(obj, methname, *args, **kwargs):
"""
Safely calls the method with the given methname on the given
object. Remaining positional and keyword arguments are passed to
the method. The return value is None, if the method is not
available, or the return value of the method.
"""
me... | [
"def",
"_safe_call",
"(",
"obj",
",",
"methname",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"meth",
"=",
"getattr",
"(",
"obj",
",",
"methname",
",",
"None",
")",
"if",
"meth",
"is",
"None",
"or",
"not",
"callable",
"(",
"meth",
")",
"... | Safely calls the method with the given methname on the given
object. Remaining positional and keyword arguments are passed to
the method. The return value is None, if the method is not
available, or the return value of the method. | [
"Safely",
"calls",
"the",
"method",
"with",
"the",
"given",
"methname",
"on",
"the",
"given",
"object",
".",
"Remaining",
"positional",
"and",
"keyword",
"arguments",
"are",
"passed",
"to",
"the",
"method",
".",
"The",
"return",
"value",
"is",
"None",
"if",
... | 0b3b5252e1b3487af732a8666b3bdc2e7035fef5 | https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/processor.py#L57-L69 |
52,319 | klmitch/requiem | requiem/processor.py | ProcessorStack.proc_response | def proc_response(self, resp, startidx=None):
"""
Post-process a response through all processors in the stack,
in reverse order. For convenience, returns the response
passed to the method.
The startidx argument is an internal interface only used by
the proc_request() an... | python | def proc_response(self, resp, startidx=None):
"""
Post-process a response through all processors in the stack,
in reverse order. For convenience, returns the response
passed to the method.
The startidx argument is an internal interface only used by
the proc_request() an... | [
"def",
"proc_response",
"(",
"self",
",",
"resp",
",",
"startidx",
"=",
"None",
")",
":",
"# If we're empty, bail out early",
"if",
"not",
"self",
":",
"return",
"resp",
"# Select appropriate starting index",
"if",
"startidx",
"is",
"None",
":",
"startidx",
"=",
... | Post-process a response through all processors in the stack,
in reverse order. For convenience, returns the response
passed to the method.
The startidx argument is an internal interface only used by
the proc_request() and proc_exception() methods to process a
response through a... | [
"Post",
"-",
"process",
"a",
"response",
"through",
"all",
"processors",
"in",
"the",
"stack",
"in",
"reverse",
"order",
".",
"For",
"convenience",
"returns",
"the",
"response",
"passed",
"to",
"the",
"method",
"."
] | 0b3b5252e1b3487af732a8666b3bdc2e7035fef5 | https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/processor.py#L104-L127 |
52,320 | dev-pipeline/dev-pipeline-configure | lib/devpipeline_configure/load.py | find_config | def find_config():
"""Find a build cache somewhere in a parent directory."""
previous = ""
current = os.getcwd()
while previous != current:
check_path = os.path.join(current, "build.cache")
if os.path.isfile(check_path):
return check_path
else:
previous = ... | python | def find_config():
"""Find a build cache somewhere in a parent directory."""
previous = ""
current = os.getcwd()
while previous != current:
check_path = os.path.join(current, "build.cache")
if os.path.isfile(check_path):
return check_path
else:
previous = ... | [
"def",
"find_config",
"(",
")",
":",
"previous",
"=",
"\"\"",
"current",
"=",
"os",
".",
"getcwd",
"(",
")",
"while",
"previous",
"!=",
"current",
":",
"check_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"current",
",",
"\"build.cache\"",
")",
"if"... | Find a build cache somewhere in a parent directory. | [
"Find",
"a",
"build",
"cache",
"somewhere",
"in",
"a",
"parent",
"directory",
"."
] | 26de2dd1b39d9a77d5417244f09319e7dce47495 | https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/load.py#L15-L26 |
52,321 | dev-pipeline/dev-pipeline-configure | lib/devpipeline_configure/load.py | update_cache | def update_cache(force=False, cache_file=None):
"""
Load a build cache, updating it if necessary.
A cache is considered outdated if any of its inputs have changed.
Arguments
force -- Consider a cache outdated regardless of whether its inputs have
been modified.
"""
if not cach... | python | def update_cache(force=False, cache_file=None):
"""
Load a build cache, updating it if necessary.
A cache is considered outdated if any of its inputs have changed.
Arguments
force -- Consider a cache outdated regardless of whether its inputs have
been modified.
"""
if not cach... | [
"def",
"update_cache",
"(",
"force",
"=",
"False",
",",
"cache_file",
"=",
"None",
")",
":",
"if",
"not",
"cache_file",
":",
"cache_file",
"=",
"find_config",
"(",
")",
"cache_config",
"=",
"devpipeline_configure",
".",
"parser",
".",
"read_config",
"(",
"ca... | Load a build cache, updating it if necessary.
A cache is considered outdated if any of its inputs have changed.
Arguments
force -- Consider a cache outdated regardless of whether its inputs have
been modified. | [
"Load",
"a",
"build",
"cache",
"updating",
"it",
"if",
"necessary",
"."
] | 26de2dd1b39d9a77d5417244f09319e7dce47495 | https://github.com/dev-pipeline/dev-pipeline-configure/blob/26de2dd1b39d9a77d5417244f09319e7dce47495/lib/devpipeline_configure/load.py#L117-L142 |
52,322 | ProjetPP/PPP-Core | ppp_core/__init__.py | app | def app(environ, start_response):
"""Function called by the WSGI server."""
r = HttpRequestHandler(environ, start_response, Router).dispatch()
return r | python | def app(environ, start_response):
"""Function called by the WSGI server."""
r = HttpRequestHandler(environ, start_response, Router).dispatch()
return r | [
"def",
"app",
"(",
"environ",
",",
"start_response",
")",
":",
"r",
"=",
"HttpRequestHandler",
"(",
"environ",
",",
"start_response",
",",
"Router",
")",
".",
"dispatch",
"(",
")",
"return",
"r"
] | Function called by the WSGI server. | [
"Function",
"called",
"by",
"the",
"WSGI",
"server",
"."
] | 49ee5b16325aa7134e2e423cf75e7b2609df96a0 | https://github.com/ProjetPP/PPP-Core/blob/49ee5b16325aa7134e2e423cf75e7b2609df96a0/ppp_core/__init__.py#L6-L9 |
52,323 | ronhanson/python-jobmanager-common | jobmanager/common/job.py | make_job | def make_job(job_name, **kwargs):
"""
Decorator to create a Job from a function.
Give a job name and add extra fields to the job.
@make_job("ExecuteDecJob",
command=mongoengine.StringField(required=True),
output=mongoengine.StringField(default=None))
def ... | python | def make_job(job_name, **kwargs):
"""
Decorator to create a Job from a function.
Give a job name and add extra fields to the job.
@make_job("ExecuteDecJob",
command=mongoengine.StringField(required=True),
output=mongoengine.StringField(default=None))
def ... | [
"def",
"make_job",
"(",
"job_name",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wraps",
"(",
"func",
")",
":",
"kwargs",
"[",
"'process'",
"]",
"=",
"func",
"job",
"=",
"type",
"(",
"job_name",
",",
"(",
"Job",
",",
")",
",",
"kwargs",
")",
"globa... | Decorator to create a Job from a function.
Give a job name and add extra fields to the job.
@make_job("ExecuteDecJob",
command=mongoengine.StringField(required=True),
output=mongoengine.StringField(default=None))
def execute(job: Job):
job.log_info('E... | [
"Decorator",
"to",
"create",
"a",
"Job",
"from",
"a",
"function",
".",
"Give",
"a",
"job",
"name",
"and",
"add",
"extra",
"fields",
"to",
"the",
"job",
"."
] | a61fadcdfcfe111bc0bf3b195c9accc0293f2888 | https://github.com/ronhanson/python-jobmanager-common/blob/a61fadcdfcfe111bc0bf3b195c9accc0293f2888/jobmanager/common/job.py#L176-L195 |
52,324 | mogproject/mog-commons-python | src/mog_commons/io.py | print_safe | def print_safe(str_or_bytes, encoding='utf-8', errors='ignore', output=sys.stdout, newline='\n'):
"""
Print unicode or bytes universally.
:param str_or_bytes: string
:param encoding: encoding
:param output: output file handler
:param errors: error handling scheme. Refer to codecs.register_error... | python | def print_safe(str_or_bytes, encoding='utf-8', errors='ignore', output=sys.stdout, newline='\n'):
"""
Print unicode or bytes universally.
:param str_or_bytes: string
:param encoding: encoding
:param output: output file handler
:param errors: error handling scheme. Refer to codecs.register_error... | [
"def",
"print_safe",
"(",
"str_or_bytes",
",",
"encoding",
"=",
"'utf-8'",
",",
"errors",
"=",
"'ignore'",
",",
"output",
"=",
"sys",
".",
"stdout",
",",
"newline",
"=",
"'\\n'",
")",
":",
"writer",
"=",
"output",
".",
"buffer",
"if",
"hasattr",
"(",
"... | Print unicode or bytes universally.
:param str_or_bytes: string
:param encoding: encoding
:param output: output file handler
:param errors: error handling scheme. Refer to codecs.register_error. | [
"Print",
"unicode",
"or",
"bytes",
"universally",
"."
] | 951cf0fa9a56248b4d45be720be25f1d4b7e1bff | https://github.com/mogproject/mog-commons-python/blob/951cf0fa9a56248b4d45be720be25f1d4b7e1bff/src/mog_commons/io.py#L7-L23 |
52,325 | MatiasSM/fcb | fcb/checker/mail.py | CheckHistoryVerifier.set_verified | def set_verified(self, msg_info):
"""
expects "msg_info" to have the field 'files_containers_id'
This call already executes "update_last_checked_time" so it doesn't need to be called separately
"""
assert hasattr(msg_info, 'files_containers_id')
with self._sessio... | python | def set_verified(self, msg_info):
"""
expects "msg_info" to have the field 'files_containers_id'
This call already executes "update_last_checked_time" so it doesn't need to be called separately
"""
assert hasattr(msg_info, 'files_containers_id')
with self._sessio... | [
"def",
"set_verified",
"(",
"self",
",",
"msg_info",
")",
":",
"assert",
"hasattr",
"(",
"msg_info",
",",
"'files_containers_id'",
")",
"with",
"self",
".",
"_session_resource",
"as",
"session",
":",
"session",
".",
"execute",
"(",
"update",
"(",
"FilesDestina... | expects "msg_info" to have the field 'files_containers_id'
This call already executes "update_last_checked_time" so it doesn't need to be called separately | [
"expects",
"msg_info",
"to",
"have",
"the",
"field",
"files_containers_id"
] | 92a6c535287ea1c1ef986954a5d66e7905fb6221 | https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/checker/mail.py#L73-L87 |
52,326 | MatiasSM/fcb | fcb/checker/mail.py | Checker.is_uploaded_container | def is_uploaded_container(self, msg_info):
"""
returns 0 if it doesn't correspond to an uploaded container
-1 if it corresponds to an uploaded container but it is corrupted
1 if it corresponds to an uploaded container and is OK
"""
results = {
... | python | def is_uploaded_container(self, msg_info):
"""
returns 0 if it doesn't correspond to an uploaded container
-1 if it corresponds to an uploaded container but it is corrupted
1 if it corresponds to an uploaded container and is OK
"""
results = {
... | [
"def",
"is_uploaded_container",
"(",
"self",
",",
"msg_info",
")",
":",
"results",
"=",
"{",
"'BAD'",
":",
"-",
"1",
",",
"'NOT_FCB'",
":",
"0",
",",
"'OK'",
":",
"1",
"}",
"for",
"part",
"in",
"msg_info",
".",
"msg_body",
".",
"walk",
"(",
")",
":... | returns 0 if it doesn't correspond to an uploaded container
-1 if it corresponds to an uploaded container but it is corrupted
1 if it corresponds to an uploaded container and is OK | [
"returns",
"0",
"if",
"it",
"doesn",
"t",
"correspond",
"to",
"an",
"uploaded",
"container",
"-",
"1",
"if",
"it",
"corresponds",
"to",
"an",
"uploaded",
"container",
"but",
"it",
"is",
"corrupted",
"1",
"if",
"it",
"corresponds",
"to",
"an",
"uploaded",
... | 92a6c535287ea1c1ef986954a5d66e7905fb6221 | https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/checker/mail.py#L170-L224 |
52,327 | decryptus/sonicprobe | sonicprobe/xmodem/__init__.py | XMODEM.abort | def abort(self, count=2, timeout=60):
'''
Send an abort sequence using CAN bytes.
'''
for counter in xrange(0, count):
self.putc(CAN, timeout) | python | def abort(self, count=2, timeout=60):
'''
Send an abort sequence using CAN bytes.
'''
for counter in xrange(0, count):
self.putc(CAN, timeout) | [
"def",
"abort",
"(",
"self",
",",
"count",
"=",
"2",
",",
"timeout",
"=",
"60",
")",
":",
"for",
"counter",
"in",
"xrange",
"(",
"0",
",",
"count",
")",
":",
"self",
".",
"putc",
"(",
"CAN",
",",
"timeout",
")"
] | Send an abort sequence using CAN bytes. | [
"Send",
"an",
"abort",
"sequence",
"using",
"CAN",
"bytes",
"."
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/xmodem/__init__.py#L202-L207 |
52,328 | decryptus/sonicprobe | sonicprobe/xmodem/__init__.py | XMODEM.send | def send(self, stream, retry=16, timeout=60, quiet=0, callback=None):
'''
Send a stream via the XMODEM protocol.
>>> stream = file('/etc/issue', 'rb')
>>> print modem.send(stream)
True
Returns ``True`` upon succesful transmission or ``False`` in case of
... | python | def send(self, stream, retry=16, timeout=60, quiet=0, callback=None):
'''
Send a stream via the XMODEM protocol.
>>> stream = file('/etc/issue', 'rb')
>>> print modem.send(stream)
True
Returns ``True`` upon succesful transmission or ``False`` in case of
... | [
"def",
"send",
"(",
"self",
",",
"stream",
",",
"retry",
"=",
"16",
",",
"timeout",
"=",
"60",
",",
"quiet",
"=",
"0",
",",
"callback",
"=",
"None",
")",
":",
"# initialize protocol",
"try",
":",
"packet_size",
"=",
"dict",
"(",
"xmodem",
"=",
"128",... | Send a stream via the XMODEM protocol.
>>> stream = file('/etc/issue', 'rb')
>>> print modem.send(stream)
True
Returns ``True`` upon succesful transmission or ``False`` in case of
failure.
:param stream: The stream object to send data from.
:type st... | [
"Send",
"a",
"stream",
"via",
"the",
"XMODEM",
"protocol",
"."
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/xmodem/__init__.py#L209-L352 |
52,329 | decryptus/sonicprobe | sonicprobe/xmodem/__init__.py | XMODEM.recv | def recv(self, stream, crc_mode=1, retry=16, timeout=60, delay=1, quiet=0):
'''
Receive a stream via the XMODEM protocol.
>>> stream = file('/etc/issue', 'wb')
>>> print modem.recv(stream)
2342
Returns the number of bytes received on success or ``None`` in c... | python | def recv(self, stream, crc_mode=1, retry=16, timeout=60, delay=1, quiet=0):
'''
Receive a stream via the XMODEM protocol.
>>> stream = file('/etc/issue', 'wb')
>>> print modem.recv(stream)
2342
Returns the number of bytes received on success or ``None`` in c... | [
"def",
"recv",
"(",
"self",
",",
"stream",
",",
"crc_mode",
"=",
"1",
",",
"retry",
"=",
"16",
",",
"timeout",
"=",
"60",
",",
"delay",
"=",
"1",
",",
"quiet",
"=",
"0",
")",
":",
"# initiate protocol",
"error_count",
"=",
"0",
"char",
"=",
"0",
... | Receive a stream via the XMODEM protocol.
>>> stream = file('/etc/issue', 'wb')
>>> print modem.recv(stream)
2342
Returns the number of bytes received on success or ``None`` in case of
failure. | [
"Receive",
"a",
"stream",
"via",
"the",
"XMODEM",
"protocol",
"."
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/xmodem/__init__.py#L354-L473 |
52,330 | decryptus/sonicprobe | sonicprobe/xmodem/__init__.py | XMODEM.calc_crc | def calc_crc(self, data, crc=0):
'''
Calculate the Cyclic Redundancy Check for a given block of data, can
also be used to update a CRC.
>>> crc = modem.calc_crc('hello')
>>> crc = modem.calc_crc('world', crc)
>>> hex(crc)
'0xd5e3'
'''
... | python | def calc_crc(self, data, crc=0):
'''
Calculate the Cyclic Redundancy Check for a given block of data, can
also be used to update a CRC.
>>> crc = modem.calc_crc('hello')
>>> crc = modem.calc_crc('world', crc)
>>> hex(crc)
'0xd5e3'
'''
... | [
"def",
"calc_crc",
"(",
"self",
",",
"data",
",",
"crc",
"=",
"0",
")",
":",
"for",
"char",
"in",
"data",
":",
"crc",
"=",
"(",
"crc",
"<<",
"8",
")",
"^",
"self",
".",
"crctable",
"[",
"(",
"(",
"crc",
">>",
"8",
")",
"^",
"ord",
"(",
"cha... | Calculate the Cyclic Redundancy Check for a given block of data, can
also be used to update a CRC.
>>> crc = modem.calc_crc('hello')
>>> crc = modem.calc_crc('world', crc)
>>> hex(crc)
'0xd5e3' | [
"Calculate",
"the",
"Cyclic",
"Redundancy",
"Check",
"for",
"a",
"given",
"block",
"of",
"data",
"can",
"also",
"be",
"used",
"to",
"update",
"a",
"CRC",
"."
] | 72f73f3a40d2982d79ad68686e36aa31d94b76f8 | https://github.com/decryptus/sonicprobe/blob/72f73f3a40d2982d79ad68686e36aa31d94b76f8/sonicprobe/xmodem/__init__.py#L488-L501 |
52,331 | sci-bots/pygtkhelpers | pygtkhelpers/ui/extra_dialogs.py | combobox_set_model_from_list | def combobox_set_model_from_list(cb, items):
"""Setup a ComboBox or ComboBoxEntry based on a list of strings."""
cb.clear()
model = gtk.ListStore(str)
for i in items:
model.append([i])
cb.set_model(model)
if type(cb) == gtk.ComboBoxEntry:
cb.set_text_column(0)
elif type(cb) =... | python | def combobox_set_model_from_list(cb, items):
"""Setup a ComboBox or ComboBoxEntry based on a list of strings."""
cb.clear()
model = gtk.ListStore(str)
for i in items:
model.append([i])
cb.set_model(model)
if type(cb) == gtk.ComboBoxEntry:
cb.set_text_column(0)
elif type(cb) =... | [
"def",
"combobox_set_model_from_list",
"(",
"cb",
",",
"items",
")",
":",
"cb",
".",
"clear",
"(",
")",
"model",
"=",
"gtk",
".",
"ListStore",
"(",
"str",
")",
"for",
"i",
"in",
"items",
":",
"model",
".",
"append",
"(",
"[",
"i",
"]",
")",
"cb",
... | Setup a ComboBox or ComboBoxEntry based on a list of strings. | [
"Setup",
"a",
"ComboBox",
"or",
"ComboBoxEntry",
"based",
"on",
"a",
"list",
"of",
"strings",
"."
] | 3a6e6d6340221c686229cd1c951d7537dae81b07 | https://github.com/sci-bots/pygtkhelpers/blob/3a6e6d6340221c686229cd1c951d7537dae81b07/pygtkhelpers/ui/extra_dialogs.py#L27-L39 |
52,332 | Met48/raf | raf/formats.py | LastOf | def LastOf(*subcons):
"""
Create an adapter which uses only the last construct.
If first argument is a string it will be the name.
"""
name = "seq"
if isinstance(subcons[0], six.string_types):
name = subcons[0]
subcons = subcons[1:]
return IndexingAdapter(Sequence(name, *su... | python | def LastOf(*subcons):
"""
Create an adapter which uses only the last construct.
If first argument is a string it will be the name.
"""
name = "seq"
if isinstance(subcons[0], six.string_types):
name = subcons[0]
subcons = subcons[1:]
return IndexingAdapter(Sequence(name, *su... | [
"def",
"LastOf",
"(",
"*",
"subcons",
")",
":",
"name",
"=",
"\"seq\"",
"if",
"isinstance",
"(",
"subcons",
"[",
"0",
"]",
",",
"six",
".",
"string_types",
")",
":",
"name",
"=",
"subcons",
"[",
"0",
"]",
"subcons",
"=",
"subcons",
"[",
"1",
":",
... | Create an adapter which uses only the last construct.
If first argument is a string it will be the name. | [
"Create",
"an",
"adapter",
"which",
"uses",
"only",
"the",
"last",
"construct",
"."
] | cd5d19f705f22ac87e2fd3fc800c66960e987078 | https://github.com/Met48/raf/blob/cd5d19f705f22ac87e2fd3fc800c66960e987078/raf/formats.py#L4-L15 |
52,333 | dev-pipeline/dev-pipeline-scm | lib/devpipeline_scm/scm.py | _make_scm | def _make_scm(current_target):
"""
Create an Scm for a component.
Arguments
component - The component being operated on.
"""
# pylint: disable=protected-access
tool_key = devpipeline_core.toolsupport.choose_tool_key(
current_target, devpipeline_scm._SCM_TOOL_KEYS
)
return d... | python | def _make_scm(current_target):
"""
Create an Scm for a component.
Arguments
component - The component being operated on.
"""
# pylint: disable=protected-access
tool_key = devpipeline_core.toolsupport.choose_tool_key(
current_target, devpipeline_scm._SCM_TOOL_KEYS
)
return d... | [
"def",
"_make_scm",
"(",
"current_target",
")",
":",
"# pylint: disable=protected-access",
"tool_key",
"=",
"devpipeline_core",
".",
"toolsupport",
".",
"choose_tool_key",
"(",
"current_target",
",",
"devpipeline_scm",
".",
"_SCM_TOOL_KEYS",
")",
"return",
"devpipeline_co... | Create an Scm for a component.
Arguments
component - The component being operated on. | [
"Create",
"an",
"Scm",
"for",
"a",
"component",
"."
] | 58c1c4b1787df9f7c83b9f096aeb548d17b8c0ca | https://github.com/dev-pipeline/dev-pipeline-scm/blob/58c1c4b1787df9f7c83b9f096aeb548d17b8c0ca/lib/devpipeline_scm/scm.py#L29-L43 |
52,334 | dev-pipeline/dev-pipeline-scm | lib/devpipeline_scm/scm.py | checkout_task | def checkout_task(current_target):
"""
Update or a local checkout.
Arguments
target - The target to operate on.
"""
try:
scm = _make_scm(current_target)
src_dir = current_target.config.get("dp.src_dir")
shared_dir = current_target.config.get("dp.src_dir_shared")
... | python | def checkout_task(current_target):
"""
Update or a local checkout.
Arguments
target - The target to operate on.
"""
try:
scm = _make_scm(current_target)
src_dir = current_target.config.get("dp.src_dir")
shared_dir = current_target.config.get("dp.src_dir_shared")
... | [
"def",
"checkout_task",
"(",
"current_target",
")",
":",
"try",
":",
"scm",
"=",
"_make_scm",
"(",
"current_target",
")",
"src_dir",
"=",
"current_target",
".",
"config",
".",
"get",
"(",
"\"dp.src_dir\"",
")",
"shared_dir",
"=",
"current_target",
".",
"config... | Update or a local checkout.
Arguments
target - The target to operate on. | [
"Update",
"or",
"a",
"local",
"checkout",
"."
] | 58c1c4b1787df9f7c83b9f096aeb548d17b8c0ca | https://github.com/dev-pipeline/dev-pipeline-scm/blob/58c1c4b1787df9f7c83b9f096aeb548d17b8c0ca/lib/devpipeline_scm/scm.py#L46-L60 |
52,335 | klmitch/requiem | requiem/jsclient.py | JSONRequest.proc_response | def proc_response(self, resp):
"""Process JSON data found in the response."""
# Try to interpret any JSON
try:
resp.obj = json.loads(resp.body)
self._debug(" Received entity: %r", resp.obj)
except ValueError:
resp.obj = None
self._debug("... | python | def proc_response(self, resp):
"""Process JSON data found in the response."""
# Try to interpret any JSON
try:
resp.obj = json.loads(resp.body)
self._debug(" Received entity: %r", resp.obj)
except ValueError:
resp.obj = None
self._debug("... | [
"def",
"proc_response",
"(",
"self",
",",
"resp",
")",
":",
"# Try to interpret any JSON",
"try",
":",
"resp",
".",
"obj",
"=",
"json",
".",
"loads",
"(",
"resp",
".",
"body",
")",
"self",
".",
"_debug",
"(",
"\" Received entity: %r\"",
",",
"resp",
".",
... | Process JSON data found in the response. | [
"Process",
"JSON",
"data",
"found",
"in",
"the",
"response",
"."
] | 0b3b5252e1b3487af732a8666b3bdc2e7035fef5 | https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/jsclient.py#L56-L68 |
52,336 | klmitch/requiem | requiem/jsclient.py | JSONClient._attach_obj | def _attach_obj(self, req, obj):
"""Helper method to attach obj to req as JSON data."""
# Attach the object to the request
json.dump(obj, req)
# Also set the content-type header
req['content-type'] = self._content_type | python | def _attach_obj(self, req, obj):
"""Helper method to attach obj to req as JSON data."""
# Attach the object to the request
json.dump(obj, req)
# Also set the content-type header
req['content-type'] = self._content_type | [
"def",
"_attach_obj",
"(",
"self",
",",
"req",
",",
"obj",
")",
":",
"# Attach the object to the request",
"json",
".",
"dump",
"(",
"obj",
",",
"req",
")",
"# Also set the content-type header",
"req",
"[",
"'content-type'",
"]",
"=",
"self",
".",
"_content_type... | Helper method to attach obj to req as JSON data. | [
"Helper",
"method",
"to",
"attach",
"obj",
"to",
"req",
"as",
"JSON",
"data",
"."
] | 0b3b5252e1b3487af732a8666b3bdc2e7035fef5 | https://github.com/klmitch/requiem/blob/0b3b5252e1b3487af732a8666b3bdc2e7035fef5/requiem/jsclient.py#L92-L99 |
52,337 | dcaune/perseus-lib-python-common | majormode/perseus/utils/egg_util.py | find_module_egg_path | def find_module_egg_path(module_path):
"""
Find the path of the deployed egg package that may contain the
specified module path.
@param module_path: the path of a Python module.
@return: the absolute path of the deployed egg package that contains
the specified module path, or ``None`` if... | python | def find_module_egg_path(module_path):
"""
Find the path of the deployed egg package that may contain the
specified module path.
@param module_path: the path of a Python module.
@return: the absolute path of the deployed egg package that contains
the specified module path, or ``None`` if... | [
"def",
"find_module_egg_path",
"(",
"module_path",
")",
":",
"if",
"module_path",
".",
"find",
"(",
"'.egg'",
")",
"==",
"-",
"1",
":",
"return",
"None",
"_module_absolute_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"module_path",
")",
"egg_paths",
... | Find the path of the deployed egg package that may contain the
specified module path.
@param module_path: the path of a Python module.
@return: the absolute path of the deployed egg package that contains
the specified module path, or ``None`` if no deployed egg
package contains this modu... | [
"Find",
"the",
"path",
"of",
"the",
"deployed",
"egg",
"package",
"that",
"may",
"contain",
"the",
"specified",
"module",
"path",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/majormode/perseus/utils/egg_util.py#L30-L53 |
52,338 | Josef-Friedrich/tmep | tmep/functions.py | Functions.tmpl_shorten | def tmpl_shorten(text, max_size=32):
"""Shorten the given text to ``max_size``
* synopsis: ``%shorten{text}`` or ``%shorten{text,max_size}``
* example: ``%shorten{$title,32}``
* description: Shorten “text” on word boundarys.
"""
max_size = int(max_size)
if len(te... | python | def tmpl_shorten(text, max_size=32):
"""Shorten the given text to ``max_size``
* synopsis: ``%shorten{text}`` or ``%shorten{text,max_size}``
* example: ``%shorten{$title,32}``
* description: Shorten “text” on word boundarys.
"""
max_size = int(max_size)
if len(te... | [
"def",
"tmpl_shorten",
"(",
"text",
",",
"max_size",
"=",
"32",
")",
":",
"max_size",
"=",
"int",
"(",
"max_size",
")",
"if",
"len",
"(",
"text",
")",
"<=",
"max_size",
":",
"return",
"text",
"text",
"=",
"textwrap",
".",
"wrap",
"(",
"text",
",",
... | Shorten the given text to ``max_size``
* synopsis: ``%shorten{text}`` or ``%shorten{text,max_size}``
* example: ``%shorten{$title,32}``
* description: Shorten “text” on word boundarys. | [
"Shorten",
"the",
"given",
"text",
"to",
"max_size"
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/functions.py#L321-L334 |
52,339 | Josef-Friedrich/tmep | tmep/functions.py | Functions.tmpl_time | def tmpl_time(text, fmt, cur_fmt):
"""Format a time value using `strftime`.
* synopsis: ``%time{date_time,format,curformat}``
* description: Return the date and time in any format accepted by \
strftime. For example, to get the year some music was added to \
your library... | python | def tmpl_time(text, fmt, cur_fmt):
"""Format a time value using `strftime`.
* synopsis: ``%time{date_time,format,curformat}``
* description: Return the date and time in any format accepted by \
strftime. For example, to get the year some music was added to \
your library... | [
"def",
"tmpl_time",
"(",
"text",
",",
"fmt",
",",
"cur_fmt",
")",
":",
"return",
"time",
".",
"strftime",
"(",
"fmt",
",",
"time",
".",
"strptime",
"(",
"text",
",",
"cur_fmt",
")",
")"
] | Format a time value using `strftime`.
* synopsis: ``%time{date_time,format,curformat}``
* description: Return the date and time in any format accepted by \
strftime. For example, to get the year some music was added to \
your library, use %time{$added,%Y}. | [
"Format",
"a",
"time",
"value",
"using",
"strftime",
"."
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/functions.py#L337-L345 |
52,340 | RI-imaging/qpsphere | qpsphere/util.py | download_binaries | def download_binaries(package_dir=False):
"""Download all binaries for the current platform
Parameters
----------
package_dir: bool
If set to `True`, the binaries will be downloaded to the
`resources` directory of the qpsphere package instead of
to the users application data dir... | python | def download_binaries(package_dir=False):
"""Download all binaries for the current platform
Parameters
----------
package_dir: bool
If set to `True`, the binaries will be downloaded to the
`resources` directory of the qpsphere package instead of
to the users application data dir... | [
"def",
"download_binaries",
"(",
"package_dir",
"=",
"False",
")",
":",
"# bhfield",
"# make sure the binary is available on the system",
"paths",
"=",
"_bhfield",
".",
"fetch",
".",
"get_binaries",
"(",
")",
"if",
"package_dir",
":",
"# Copy the binaries to the `resource... | Download all binaries for the current platform
Parameters
----------
package_dir: bool
If set to `True`, the binaries will be downloaded to the
`resources` directory of the qpsphere package instead of
to the users application data directory. Note that this
might require admi... | [
"Download",
"all",
"binaries",
"for",
"the",
"current",
"platform"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/util.py#L15-L51 |
52,341 | RI-imaging/qpsphere | qpsphere/util.py | remove_binaries | def remove_binaries(package_dir=False):
"""Remove all binaries for the current platform
Parameters
----------
package_dir: bool
If True, remove all binaries from the `resources`
directory of the qpsphere package. If False,
remove all binaries from the user's cache directory.
... | python | def remove_binaries(package_dir=False):
"""Remove all binaries for the current platform
Parameters
----------
package_dir: bool
If True, remove all binaries from the `resources`
directory of the qpsphere package. If False,
remove all binaries from the user's cache directory.
... | [
"def",
"remove_binaries",
"(",
"package_dir",
"=",
"False",
")",
":",
"paths",
"=",
"[",
"]",
"if",
"package_dir",
":",
"pdir",
"=",
"RESCR_PATH",
"else",
":",
"pdir",
"=",
"CACHE_PATH",
"for",
"pp",
"in",
"pdir",
".",
"iterdir",
"(",
")",
":",
"if",
... | Remove all binaries for the current platform
Parameters
----------
package_dir: bool
If True, remove all binaries from the `resources`
directory of the qpsphere package. If False,
remove all binaries from the user's cache directory. | [
"Remove",
"all",
"binaries",
"for",
"the",
"current",
"platform"
] | 3cfa0e9fb8e81be8c820abbeccd47242e7972ac1 | https://github.com/RI-imaging/qpsphere/blob/3cfa0e9fb8e81be8c820abbeccd47242e7972ac1/qpsphere/util.py#L54-L76 |
52,342 | zengbin93/zb | zb/utils.py | elapsed | def elapsed(func):
"""A decorator for calculating time elapsed when execute function"""
@functools.wraps(func)
def wrapper(*args, **kw):
start = time.time()
print('Running `%s()` ...' % func.__name__)
res = func(*args, **kw)
end = time.time()
print('Function `%s()` r... | python | def elapsed(func):
"""A decorator for calculating time elapsed when execute function"""
@functools.wraps(func)
def wrapper(*args, **kw):
start = time.time()
print('Running `%s()` ...' % func.__name__)
res = func(*args, **kw)
end = time.time()
print('Function `%s()` r... | [
"def",
"elapsed",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"start",
"=",
"time",
".",
"time",
"(",
")",
"print",
"(",
"'Running `%s()` ...'",
"%",
... | A decorator for calculating time elapsed when execute function | [
"A",
"decorator",
"for",
"calculating",
"time",
"elapsed",
"when",
"execute",
"function"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/utils.py#L9-L22 |
52,343 | zengbin93/zb | zb/utils.py | create_logger | def create_logger(log_file, name='logger', cmd=True):
"""define a logger for your program
parameters
------------
log_file file name of log
name name of logger
example
------------
logger = create_logger('example.log',name='logger',)
logger.info('This is an example!')
... | python | def create_logger(log_file, name='logger', cmd=True):
"""define a logger for your program
parameters
------------
log_file file name of log
name name of logger
example
------------
logger = create_logger('example.log',name='logger',)
logger.info('This is an example!')
... | [
"def",
"create_logger",
"(",
"log_file",
",",
"name",
"=",
"'logger'",
",",
"cmd",
"=",
"True",
")",
":",
"import",
"logging",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
")",
"logger",
".",
"setLevel",
"(",
"logging",
".",
"DEBUG",
")",
"... | define a logger for your program
parameters
------------
log_file file name of log
name name of logger
example
------------
logger = create_logger('example.log',name='logger',)
logger.info('This is an example!')
logger.warning('This is a warn!') | [
"define",
"a",
"logger",
"for",
"your",
"program"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/utils.py#L27-L63 |
52,344 | YavorPaunov/time2words | time2words/__init__.py | relative_time_to_text | def relative_time_to_text(l10n=locales.get(_default), **kwargs):
"""
Return an aproximate textual representation of the provioded duration of
time.
Examples:
relative_time_to_text(hours=6, minutes=34) -> "six and a half hours"
relative_time_to_text(years=5, months=8, days=5) -> "less than six y... | python | def relative_time_to_text(l10n=locales.get(_default), **kwargs):
"""
Return an aproximate textual representation of the provioded duration of
time.
Examples:
relative_time_to_text(hours=6, minutes=34) -> "six and a half hours"
relative_time_to_text(years=5, months=8, days=5) -> "less than six y... | [
"def",
"relative_time_to_text",
"(",
"l10n",
"=",
"locales",
".",
"get",
"(",
"_default",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"kwargs",
"=",
"_normalize",
"(",
"*",
"*",
"kwargs",
")",
"cor",
"=",
"_Chain",
"(",
")",
"cor",
".",
"add",
"(",
"_L... | Return an aproximate textual representation of the provioded duration of
time.
Examples:
relative_time_to_text(hours=6, minutes=34) -> "six and a half hours"
relative_time_to_text(years=5, months=8, days=5) -> "less than six years"
Keyword arguments:
l10n -- The locale of the language for the ... | [
"Return",
"an",
"aproximate",
"textual",
"representation",
"of",
"the",
"provioded",
"duration",
"of",
"time",
"."
] | f0bb059f8f5a81e1215071c5ab6a5f7ad022b719 | https://github.com/YavorPaunov/time2words/blob/f0bb059f8f5a81e1215071c5ab6a5f7ad022b719/time2words/__init__.py#L10-L40 |
52,345 | MatiasSM/fcb | fcb/processing/models/FileInfo.py | FileInfo.size | def size(self):
""" size in bytes """
if not self._size:
self._size = os.path.getsize(self._path)
return self._size | python | def size(self):
""" size in bytes """
if not self._size:
self._size = os.path.getsize(self._path)
return self._size | [
"def",
"size",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_size",
":",
"self",
".",
"_size",
"=",
"os",
".",
"path",
".",
"getsize",
"(",
"self",
".",
"_path",
")",
"return",
"self",
".",
"_size"
] | size in bytes | [
"size",
"in",
"bytes"
] | 92a6c535287ea1c1ef986954a5d66e7905fb6221 | https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/processing/models/FileInfo.py#L27-L31 |
52,346 | MatiasSM/fcb | fcb/processing/transformations/Cipher.py | Cipher.do_heavy_work | def do_heavy_work(self, block):
"""
Expects Compressor Block like objects
"""
cipher_key = self.gen_key(32)
in_file_path = block.latest_file_info.path
dst_file_path = block.processed_data_file_info.path + self.get_extension()
self.log.debug("Encrypting file '%s' w... | python | def do_heavy_work(self, block):
"""
Expects Compressor Block like objects
"""
cipher_key = self.gen_key(32)
in_file_path = block.latest_file_info.path
dst_file_path = block.processed_data_file_info.path + self.get_extension()
self.log.debug("Encrypting file '%s' w... | [
"def",
"do_heavy_work",
"(",
"self",
",",
"block",
")",
":",
"cipher_key",
"=",
"self",
".",
"gen_key",
"(",
"32",
")",
"in_file_path",
"=",
"block",
".",
"latest_file_info",
".",
"path",
"dst_file_path",
"=",
"block",
".",
"processed_data_file_info",
".",
"... | Expects Compressor Block like objects | [
"Expects",
"Compressor",
"Block",
"like",
"objects"
] | 92a6c535287ea1c1ef986954a5d66e7905fb6221 | https://github.com/MatiasSM/fcb/blob/92a6c535287ea1c1ef986954a5d66e7905fb6221/fcb/processing/transformations/Cipher.py#L27-L42 |
52,347 | brunobord/meuhdb | meuhdb/core.py | autocommit | def autocommit(f):
"A decorator to commit to the storage if autocommit is set to True."
@wraps(f)
def wrapper(self, *args, **kwargs):
result = f(self, *args, **kwargs)
if self._meta.commit_ready():
self.commit()
return result
return wrapper | python | def autocommit(f):
"A decorator to commit to the storage if autocommit is set to True."
@wraps(f)
def wrapper(self, *args, **kwargs):
result = f(self, *args, **kwargs)
if self._meta.commit_ready():
self.commit()
return result
return wrapper | [
"def",
"autocommit",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"wrapper",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"f",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"if",
... | A decorator to commit to the storage if autocommit is set to True. | [
"A",
"decorator",
"to",
"commit",
"to",
"the",
"storage",
"if",
"autocommit",
"is",
"set",
"to",
"True",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L18-L26 |
52,348 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.set | def set(self, key, value):
"Set value to the key store."
# if key already in data, update indexes
if not isinstance(value, dict):
raise BadValueError(
'The value {} is incorrect.'
' Values should be strings'.format(value))
_value = deepcopy(val... | python | def set(self, key, value):
"Set value to the key store."
# if key already in data, update indexes
if not isinstance(value, dict):
raise BadValueError(
'The value {} is incorrect.'
' Values should be strings'.format(value))
_value = deepcopy(val... | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# if key already in data, update indexes",
"if",
"not",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"raise",
"BadValueError",
"(",
"'The value {} is incorrect.'",
"' Values should be strings'",
"... | Set value to the key store. | [
"Set",
"value",
"to",
"the",
"key",
"store",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L157-L168 |
52,349 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.insert | def insert(self, value):
"Insert value in the keystore. Return the UUID key."
key = str(uuid4())
self.set(key, value)
return key | python | def insert(self, value):
"Insert value in the keystore. Return the UUID key."
key = str(uuid4())
self.set(key, value)
return key | [
"def",
"insert",
"(",
"self",
",",
"value",
")",
":",
"key",
"=",
"str",
"(",
"uuid4",
"(",
")",
")",
"self",
".",
"set",
"(",
"key",
",",
"value",
")",
"return",
"key"
] | Insert value in the keystore. Return the UUID key. | [
"Insert",
"value",
"in",
"the",
"keystore",
".",
"Return",
"the",
"UUID",
"key",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L171-L175 |
52,350 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.delete | def delete(self, key):
"Delete a `key` from the keystore."
if key in self.data:
self.delete_from_index(key)
del self.data[key] | python | def delete(self, key):
"Delete a `key` from the keystore."
if key in self.data:
self.delete_from_index(key)
del self.data[key] | [
"def",
"delete",
"(",
"self",
",",
"key",
")",
":",
"if",
"key",
"in",
"self",
".",
"data",
":",
"self",
".",
"delete_from_index",
"(",
"key",
")",
"del",
"self",
".",
"data",
"[",
"key",
"]"
] | Delete a `key` from the keystore. | [
"Delete",
"a",
"key",
"from",
"the",
"keystore",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L178-L182 |
52,351 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.update | def update(self, key, value):
"""Update a `key` in the keystore.
If the key is non-existent, it's being created
"""
if not isinstance(value, dict):
raise BadValueError(
'The value {} is incorrect.'
' Values should be strings'.format(value))
... | python | def update(self, key, value):
"""Update a `key` in the keystore.
If the key is non-existent, it's being created
"""
if not isinstance(value, dict):
raise BadValueError(
'The value {} is incorrect.'
' Values should be strings'.format(value))
... | [
"def",
"update",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"dict",
")",
":",
"raise",
"BadValueError",
"(",
"'The value {} is incorrect.'",
"' Values should be strings'",
".",
"format",
"(",
"value",
")",
... | Update a `key` in the keystore.
If the key is non-existent, it's being created | [
"Update",
"a",
"key",
"in",
"the",
"keystore",
".",
"If",
"the",
"key",
"is",
"non",
"-",
"existent",
"it",
"s",
"being",
"created"
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L185-L198 |
52,352 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.del_key | def del_key(self, key, key_to_delete):
"Delete the `key_to_delete` for the record found with `key`."
v = self.get(key)
if key_to_delete in v:
del v[key_to_delete]
self.set(key, v) | python | def del_key(self, key, key_to_delete):
"Delete the `key_to_delete` for the record found with `key`."
v = self.get(key)
if key_to_delete in v:
del v[key_to_delete]
self.set(key, v) | [
"def",
"del_key",
"(",
"self",
",",
"key",
",",
"key_to_delete",
")",
":",
"v",
"=",
"self",
".",
"get",
"(",
"key",
")",
"if",
"key_to_delete",
"in",
"v",
":",
"del",
"v",
"[",
"key_to_delete",
"]",
"self",
".",
"set",
"(",
"key",
",",
"v",
")"
... | Delete the `key_to_delete` for the record found with `key`. | [
"Delete",
"the",
"key_to_delete",
"for",
"the",
"record",
"found",
"with",
"key",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L208-L213 |
52,353 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.commit | def commit(self):
"Commit data to the storage."
if self._meta.path:
with open(self._meta.path, 'wb') as fd:
raw = deepcopy(self.raw)
# LAZY INDEX PROCESSING
# Save indexes only if not lazy
lazy_indexes = self.lazy_indexes # Kee... | python | def commit(self):
"Commit data to the storage."
if self._meta.path:
with open(self._meta.path, 'wb') as fd:
raw = deepcopy(self.raw)
# LAZY INDEX PROCESSING
# Save indexes only if not lazy
lazy_indexes = self.lazy_indexes # Kee... | [
"def",
"commit",
"(",
"self",
")",
":",
"if",
"self",
".",
"_meta",
".",
"path",
":",
"with",
"open",
"(",
"self",
".",
"_meta",
".",
"path",
",",
"'wb'",
")",
"as",
"fd",
":",
"raw",
"=",
"deepcopy",
"(",
"self",
".",
"raw",
")",
"# LAZY INDEX P... | Commit data to the storage. | [
"Commit",
"data",
"to",
"the",
"storage",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L215-L236 |
52,354 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.keys_to_values | def keys_to_values(self, keys):
"Return the items in the keystore with keys in `keys`."
return dict((k, v) for k, v in self.data.items() if k in keys) | python | def keys_to_values(self, keys):
"Return the items in the keystore with keys in `keys`."
return dict((k, v) for k, v in self.data.items() if k in keys) | [
"def",
"keys_to_values",
"(",
"self",
",",
"keys",
")",
":",
"return",
"dict",
"(",
"(",
"k",
",",
"v",
")",
"for",
"k",
",",
"v",
"in",
"self",
".",
"data",
".",
"items",
"(",
")",
"if",
"k",
"in",
"keys",
")"
] | Return the items in the keystore with keys in `keys`. | [
"Return",
"the",
"items",
"in",
"the",
"keystore",
"with",
"keys",
"in",
"keys",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L242-L244 |
52,355 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.filter_keys | def filter_keys(self, **kwargs):
"Return a set of keys filtered according to the given arguments."
self._used_index = False
keys = set(self.data.keys())
for key_filter, v_filter in kwargs.items():
if key_filter in self.indexes:
self._used_index = True
... | python | def filter_keys(self, **kwargs):
"Return a set of keys filtered according to the given arguments."
self._used_index = False
keys = set(self.data.keys())
for key_filter, v_filter in kwargs.items():
if key_filter in self.indexes:
self._used_index = True
... | [
"def",
"filter_keys",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"_used_index",
"=",
"False",
"keys",
"=",
"set",
"(",
"self",
".",
"data",
".",
"keys",
"(",
")",
")",
"for",
"key_filter",
",",
"v_filter",
"in",
"kwargs",
".",
"it... | Return a set of keys filtered according to the given arguments. | [
"Return",
"a",
"set",
"of",
"keys",
"filtered",
"according",
"to",
"the",
"given",
"arguments",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L246-L261 |
52,356 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.simple_filter | def simple_filter(self, key, value):
"Search keys whose values match with the searched values"
searched = {key: value}
return set([k for k, v in self.data.items() if
intersect(searched, v) == searched]) | python | def simple_filter(self, key, value):
"Search keys whose values match with the searched values"
searched = {key: value}
return set([k for k, v in self.data.items() if
intersect(searched, v) == searched]) | [
"def",
"simple_filter",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"searched",
"=",
"{",
"key",
":",
"value",
"}",
"return",
"set",
"(",
"[",
"k",
"for",
"k",
",",
"v",
"in",
"self",
".",
"data",
".",
"items",
"(",
")",
"if",
"intersect",
... | Search keys whose values match with the searched values | [
"Search",
"keys",
"whose",
"values",
"match",
"with",
"the",
"searched",
"values"
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L263-L267 |
52,357 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.filter | def filter(self, **kwargs):
"""
Filter data according to the given arguments.
"""
keys = self.filter_keys(**kwargs)
return self.keys_to_values(keys) | python | def filter(self, **kwargs):
"""
Filter data according to the given arguments.
"""
keys = self.filter_keys(**kwargs)
return self.keys_to_values(keys) | [
"def",
"filter",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"keys",
"=",
"self",
".",
"filter_keys",
"(",
"*",
"*",
"kwargs",
")",
"return",
"self",
".",
"keys_to_values",
"(",
"keys",
")"
] | Filter data according to the given arguments. | [
"Filter",
"data",
"according",
"to",
"the",
"given",
"arguments",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L269-L274 |
52,358 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.create_index | def create_index(self, name, recreate=False, _type='default'):
"""
Create an index.
If recreate is True, recreate even if already there.
"""
if name not in self.indexes or recreate:
self.build_index(name, _type) | python | def create_index(self, name, recreate=False, _type='default'):
"""
Create an index.
If recreate is True, recreate even if already there.
"""
if name not in self.indexes or recreate:
self.build_index(name, _type) | [
"def",
"create_index",
"(",
"self",
",",
"name",
",",
"recreate",
"=",
"False",
",",
"_type",
"=",
"'default'",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"indexes",
"or",
"recreate",
":",
"self",
".",
"build_index",
"(",
"name",
",",
"_type",
... | Create an index.
If recreate is True, recreate even if already there. | [
"Create",
"an",
"index",
".",
"If",
"recreate",
"is",
"True",
"recreate",
"even",
"if",
"already",
"there",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L296-L302 |
52,359 | brunobord/meuhdb | meuhdb/core.py | MeuhDb.build_index | def build_index(self, idx_name, _type='default'):
"Build the index related to the `name`."
indexes = {}
has_non_string_values = False
for key, item in self.data.items():
if idx_name in item:
value = item[idx_name]
# A non-string index value swi... | python | def build_index(self, idx_name, _type='default'):
"Build the index related to the `name`."
indexes = {}
has_non_string_values = False
for key, item in self.data.items():
if idx_name in item:
value = item[idx_name]
# A non-string index value swi... | [
"def",
"build_index",
"(",
"self",
",",
"idx_name",
",",
"_type",
"=",
"'default'",
")",
":",
"indexes",
"=",
"{",
"}",
"has_non_string_values",
"=",
"False",
"for",
"key",
",",
"item",
"in",
"self",
".",
"data",
".",
"items",
"(",
")",
":",
"if",
"i... | Build the index related to the `name`. | [
"Build",
"the",
"index",
"related",
"to",
"the",
"name",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L305-L322 |
52,360 | brunobord/meuhdb | meuhdb/core.py | MeuhDb._clean_index | def _clean_index(self):
"Clean index values after loading."
for idx_name, idx_def in self.index_defs.items():
if idx_def['type'] == 'lazy':
self.build_index(idx_name)
for index_name, values in self.indexes.items():
for value in values:
if n... | python | def _clean_index(self):
"Clean index values after loading."
for idx_name, idx_def in self.index_defs.items():
if idx_def['type'] == 'lazy':
self.build_index(idx_name)
for index_name, values in self.indexes.items():
for value in values:
if n... | [
"def",
"_clean_index",
"(",
"self",
")",
":",
"for",
"idx_name",
",",
"idx_def",
"in",
"self",
".",
"index_defs",
".",
"items",
"(",
")",
":",
"if",
"idx_def",
"[",
"'type'",
"]",
"==",
"'lazy'",
":",
"self",
".",
"build_index",
"(",
"idx_name",
")",
... | Clean index values after loading. | [
"Clean",
"index",
"values",
"after",
"loading",
"."
] | 2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb | https://github.com/brunobord/meuhdb/blob/2ef2ea0b1065768d88f52bacf1b94b3d3ce3d9eb/meuhdb/core.py#L330-L338 |
52,361 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/command.py | make_command | def make_command(tasks, *args, **kwargs):
"""
Create a TaskCommand with defined tasks.
This is a helper function to avoid boiletplate when dealing with simple
cases (e.g., all cli arguments can be handled by TaskCommand), with no
special processing. In general, this means a command only needs to r... | python | def make_command(tasks, *args, **kwargs):
"""
Create a TaskCommand with defined tasks.
This is a helper function to avoid boiletplate when dealing with simple
cases (e.g., all cli arguments can be handled by TaskCommand), with no
special processing. In general, this means a command only needs to r... | [
"def",
"make_command",
"(",
"tasks",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"command",
"=",
"TaskCommand",
"(",
"tasks",
"=",
"tasks",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"command"
] | Create a TaskCommand with defined tasks.
This is a helper function to avoid boiletplate when dealing with simple
cases (e.g., all cli arguments can be handled by TaskCommand), with no
special processing. In general, this means a command only needs to run
established tasks.
Arguments:
tasks - ... | [
"Create",
"a",
"TaskCommand",
"with",
"defined",
"tasks",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/command.py#L257-L272 |
52,362 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/command.py | execute_command | def execute_command(command, args):
"""
Runs the provided command with the given args.
Exceptions, if any, are propogated to the caller.
Arguments:
command - something that extends the Command class
args - A list of command line arguments. If args is None, sys.argv
(without the fir... | python | def execute_command(command, args):
"""
Runs the provided command with the given args.
Exceptions, if any, are propogated to the caller.
Arguments:
command - something that extends the Command class
args - A list of command line arguments. If args is None, sys.argv
(without the fir... | [
"def",
"execute_command",
"(",
"command",
",",
"args",
")",
":",
"if",
"args",
"is",
"None",
":",
"args",
"=",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
"try",
":",
"command",
".",
"execute",
"(",
"args",
")",
"except",
"IOError",
"as",
"failure",
":... | Runs the provided command with the given args.
Exceptions, if any, are propogated to the caller.
Arguments:
command - something that extends the Command class
args - A list of command line arguments. If args is None, sys.argv
(without the first argument--assumed to be the command name) wil... | [
"Runs",
"the",
"provided",
"command",
"with",
"the",
"given",
"args",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/command.py#L275-L308 |
52,363 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/command.py | Command.execute | def execute(self, *args, **kwargs):
"""
Initializes and runs the tool.
This is shorhand to parse command line arguments, then calling:
self.setup(parsed_arguments)
self.process()
"""
args = self.parser.parse_args(*args, **kwargs)
self.process(args... | python | def execute(self, *args, **kwargs):
"""
Initializes and runs the tool.
This is shorhand to parse command line arguments, then calling:
self.setup(parsed_arguments)
self.process()
"""
args = self.parser.parse_args(*args, **kwargs)
self.process(args... | [
"def",
"execute",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"self",
".",
"parser",
".",
"parse_args",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"process",
"(",
"args",
")"
] | Initializes and runs the tool.
This is shorhand to parse command line arguments, then calling:
self.setup(parsed_arguments)
self.process() | [
"Initializes",
"and",
"runs",
"the",
"tool",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/command.py#L68-L77 |
52,364 | dev-pipeline/dev-pipeline-core | lib/devpipeline_core/command.py | TaskCommand.process_targets | def process_targets(self, targets, full_config, arguments):
"""
Calls the tasks with the appropriate options for each of the targets.
"""
executor = _get_executor(arguments)
resolver = _get_resolver(arguments)
dep_manager = resolver(targets, full_config, self._task_order)... | python | def process_targets(self, targets, full_config, arguments):
"""
Calls the tasks with the appropriate options for each of the targets.
"""
executor = _get_executor(arguments)
resolver = _get_resolver(arguments)
dep_manager = resolver(targets, full_config, self._task_order)... | [
"def",
"process_targets",
"(",
"self",
",",
"targets",
",",
"full_config",
",",
"arguments",
")",
":",
"executor",
"=",
"_get_executor",
"(",
"arguments",
")",
"resolver",
"=",
"_get_resolver",
"(",
"arguments",
")",
"dep_manager",
"=",
"resolver",
"(",
"targe... | Calls the tasks with the appropriate options for each of the targets. | [
"Calls",
"the",
"tasks",
"with",
"the",
"appropriate",
"options",
"for",
"each",
"of",
"the",
"targets",
"."
] | fa40c050a56202485070b0300bb8695e9388c34f | https://github.com/dev-pipeline/dev-pipeline-core/blob/fa40c050a56202485070b0300bb8695e9388c34f/lib/devpipeline_core/command.py#L225-L254 |
52,365 | singularitti/text-stream | text_stream/__init__.py | _user_input | def _user_input() -> str:
"""
A helper function which waits for user multi-line input.
:return: A string input by user, separated by ``'\\n'``.
"""
lines = []
try:
while True:
line = input()
if line != '':
lines.append(line)
else:
... | python | def _user_input() -> str:
"""
A helper function which waits for user multi-line input.
:return: A string input by user, separated by ``'\\n'``.
"""
lines = []
try:
while True:
line = input()
if line != '':
lines.append(line)
else:
... | [
"def",
"_user_input",
"(",
")",
"->",
"str",
":",
"lines",
"=",
"[",
"]",
"try",
":",
"while",
"True",
":",
"line",
"=",
"input",
"(",
")",
"if",
"line",
"!=",
"''",
":",
"lines",
".",
"append",
"(",
"line",
")",
"else",
":",
"break",
"except",
... | A helper function which waits for user multi-line input.
:return: A string input by user, separated by ``'\\n'``. | [
"A",
"helper",
"function",
"which",
"waits",
"for",
"user",
"multi",
"-",
"line",
"input",
"."
] | 4df53b98e9f61d983dbd46edd96db93122577eb5 | https://github.com/singularitti/text-stream/blob/4df53b98e9f61d983dbd46edd96db93122577eb5/text_stream/__init__.py#L152-L168 |
52,366 | singularitti/text-stream | text_stream/__init__.py | TextStream.infile_path | def infile_path(self) -> Optional[PurePath]:
"""
Read-only property.
:return: A ``pathlib.PurePath`` object or ``None``.
"""
if not self.__infile_path:
return Path(self.__infile_path).expanduser()
return None | python | def infile_path(self) -> Optional[PurePath]:
"""
Read-only property.
:return: A ``pathlib.PurePath`` object or ``None``.
"""
if not self.__infile_path:
return Path(self.__infile_path).expanduser()
return None | [
"def",
"infile_path",
"(",
"self",
")",
"->",
"Optional",
"[",
"PurePath",
"]",
":",
"if",
"not",
"self",
".",
"__infile_path",
":",
"return",
"Path",
"(",
"self",
".",
"__infile_path",
")",
".",
"expanduser",
"(",
")",
"return",
"None"
] | Read-only property.
:return: A ``pathlib.PurePath`` object or ``None``. | [
"Read",
"-",
"only",
"property",
"."
] | 4df53b98e9f61d983dbd46edd96db93122577eb5 | https://github.com/singularitti/text-stream/blob/4df53b98e9f61d983dbd46edd96db93122577eb5/text_stream/__init__.py#L75-L83 |
52,367 | singularitti/text-stream | text_stream/__init__.py | TextStream.generator | def generator(self) -> Iterator[str]:
"""
Create a generate that iterates the whole content of the file or string.
:return: An iterator iterating the lines of the text stream, separated by ``'\\n'`` or ``'\\r'``.
"""
stream = self.stream # In case that ``self.stream`` is change... | python | def generator(self) -> Iterator[str]:
"""
Create a generate that iterates the whole content of the file or string.
:return: An iterator iterating the lines of the text stream, separated by ``'\\n'`` or ``'\\r'``.
"""
stream = self.stream # In case that ``self.stream`` is change... | [
"def",
"generator",
"(",
"self",
")",
"->",
"Iterator",
"[",
"str",
"]",
":",
"stream",
"=",
"self",
".",
"stream",
"# In case that ``self.stream`` is changed.",
"stream",
".",
"seek",
"(",
"0",
")",
"for",
"line",
"in",
"stream",
":",
"yield",
"line"
] | Create a generate that iterates the whole content of the file or string.
:return: An iterator iterating the lines of the text stream, separated by ``'\\n'`` or ``'\\r'``. | [
"Create",
"a",
"generate",
"that",
"iterates",
"the",
"whole",
"content",
"of",
"the",
"file",
"or",
"string",
"."
] | 4df53b98e9f61d983dbd46edd96db93122577eb5 | https://github.com/singularitti/text-stream/blob/4df53b98e9f61d983dbd46edd96db93122577eb5/text_stream/__init__.py#L85-L94 |
52,368 | singularitti/text-stream | text_stream/__init__.py | TextStream.generator_telling_position | def generator_telling_position(self) -> Iterator[Tuple[str, int]]:
"""
Create a generate that iterates the whole content of the file or string, and also tells which offset is now.
:return: An iterator iterating tuples, containing lines of the text stream,...
separated by ``'\\n'`` o... | python | def generator_telling_position(self) -> Iterator[Tuple[str, int]]:
"""
Create a generate that iterates the whole content of the file or string, and also tells which offset is now.
:return: An iterator iterating tuples, containing lines of the text stream,...
separated by ``'\\n'`` o... | [
"def",
"generator_telling_position",
"(",
"self",
")",
"->",
"Iterator",
"[",
"Tuple",
"[",
"str",
",",
"int",
"]",
"]",
":",
"stream",
"=",
"self",
".",
"stream",
"# In case that ``self.stream`` is changed.",
"stream",
".",
"seek",
"(",
"0",
")",
"for",
"li... | Create a generate that iterates the whole content of the file or string, and also tells which offset is now.
:return: An iterator iterating tuples, containing lines of the text stream,...
separated by ``'\\n'`` or ``'\\r'``; and the offset (in bytes) of current line. | [
"Create",
"a",
"generate",
"that",
"iterates",
"the",
"whole",
"content",
"of",
"the",
"file",
"or",
"string",
"and",
"also",
"tells",
"which",
"offset",
"is",
"now",
"."
] | 4df53b98e9f61d983dbd46edd96db93122577eb5 | https://github.com/singularitti/text-stream/blob/4df53b98e9f61d983dbd46edd96db93122577eb5/text_stream/__init__.py#L96-L106 |
52,369 | Josef-Friedrich/tmep | tmep/doc.py | Doc.extract_value | def extract_value(self, string, key, inline_code=True):
"""Extract strings from the docstrings
.. code-block:: text
* synopsis: ``%shorten{text, max_size}``
* example: ``%shorten{$title, 32}``
* description: Shorten “text” on word boundarys.
"""
reg... | python | def extract_value(self, string, key, inline_code=True):
"""Extract strings from the docstrings
.. code-block:: text
* synopsis: ``%shorten{text, max_size}``
* example: ``%shorten{$title, 32}``
* description: Shorten “text” on word boundarys.
"""
reg... | [
"def",
"extract_value",
"(",
"self",
",",
"string",
",",
"key",
",",
"inline_code",
"=",
"True",
")",
":",
"regex",
"=",
"r'\\* '",
"+",
"key",
"+",
"': '",
"if",
"inline_code",
":",
"regex",
"=",
"regex",
"+",
"'``(.*)``'",
"else",
":",
"regex",
"=",
... | Extract strings from the docstrings
.. code-block:: text
* synopsis: ``%shorten{text, max_size}``
* example: ``%shorten{$title, 32}``
* description: Shorten “text” on word boundarys. | [
"Extract",
"strings",
"from",
"the",
"docstrings"
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/doc.py#L33-L52 |
52,370 | Josef-Friedrich/tmep | tmep/doc.py | Doc.underline | def underline(self, text, indent=4):
"""Underline a given text"""
length = len(text)
indentation = (' ' * indent)
return indentation + text + '\n' + indentation + ('-' * length) | python | def underline(self, text, indent=4):
"""Underline a given text"""
length = len(text)
indentation = (' ' * indent)
return indentation + text + '\n' + indentation + ('-' * length) | [
"def",
"underline",
"(",
"self",
",",
"text",
",",
"indent",
"=",
"4",
")",
":",
"length",
"=",
"len",
"(",
"text",
")",
"indentation",
"=",
"(",
"' '",
"*",
"indent",
")",
"return",
"indentation",
"+",
"text",
"+",
"'\\n'",
"+",
"indentation",
"+",
... | Underline a given text | [
"Underline",
"a",
"given",
"text"
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/doc.py#L54-L58 |
52,371 | Josef-Friedrich/tmep | tmep/doc.py | Doc.format | def format(self, text, width=78, indent=4):
"""Apply textwrap to a given text string"""
return textwrap.fill(
text,
width=width,
initial_indent=' ' * indent,
subsequent_indent=' ' * indent,
) | python | def format(self, text, width=78, indent=4):
"""Apply textwrap to a given text string"""
return textwrap.fill(
text,
width=width,
initial_indent=' ' * indent,
subsequent_indent=' ' * indent,
) | [
"def",
"format",
"(",
"self",
",",
"text",
",",
"width",
"=",
"78",
",",
"indent",
"=",
"4",
")",
":",
"return",
"textwrap",
".",
"fill",
"(",
"text",
",",
"width",
"=",
"width",
",",
"initial_indent",
"=",
"' '",
"*",
"indent",
",",
"subsequent_inde... | Apply textwrap to a given text string | [
"Apply",
"textwrap",
"to",
"a",
"given",
"text",
"string"
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/doc.py#L60-L67 |
52,372 | Josef-Friedrich/tmep | tmep/doc.py | Doc.get | def get(self):
"""Retrieve a formated text string"""
output = ''
for f in self.functions:
output += self.underline(f) + '\n\n'
if f in self.synopsises and isinstance(self.synopsises[f], str):
output += self.format(self.synopsises[f]) + '\n'
if ... | python | def get(self):
"""Retrieve a formated text string"""
output = ''
for f in self.functions:
output += self.underline(f) + '\n\n'
if f in self.synopsises and isinstance(self.synopsises[f], str):
output += self.format(self.synopsises[f]) + '\n'
if ... | [
"def",
"get",
"(",
"self",
")",
":",
"output",
"=",
"''",
"for",
"f",
"in",
"self",
".",
"functions",
":",
"output",
"+=",
"self",
".",
"underline",
"(",
"f",
")",
"+",
"'\\n\\n'",
"if",
"f",
"in",
"self",
".",
"synopsises",
"and",
"isinstance",
"(... | Retrieve a formated text string | [
"Retrieve",
"a",
"formated",
"text",
"string"
] | 326de14f5b9498696a1f06a8be3d39e33e376102 | https://github.com/Josef-Friedrich/tmep/blob/326de14f5b9498696a1f06a8be3d39e33e376102/tmep/doc.py#L69-L83 |
52,373 | zengbin93/zb | zb/algorithms/logistic_regression.py | propagate | def propagate(w, b, X, Y):
"""
Implement the cost function and its gradient for the propagation
Arguments:
w weights, a numpy array of size (dim, 1)
b bias, a scalar
X data of size (dim, number of examples)
Y true "label" vector of size (1, number of examples)
R... | python | def propagate(w, b, X, Y):
"""
Implement the cost function and its gradient for the propagation
Arguments:
w weights, a numpy array of size (dim, 1)
b bias, a scalar
X data of size (dim, number of examples)
Y true "label" vector of size (1, number of examples)
R... | [
"def",
"propagate",
"(",
"w",
",",
"b",
",",
"X",
",",
"Y",
")",
":",
"m",
"=",
"X",
".",
"shape",
"[",
"1",
"]",
"A",
"=",
"sigmoid",
"(",
"np",
".",
"dot",
"(",
"w",
".",
"T",
",",
"X",
")",
"+",
"b",
")",
"cost",
"=",
"-",
"1",
"/"... | Implement the cost function and its gradient for the propagation
Arguments:
w weights, a numpy array of size (dim, 1)
b bias, a scalar
X data of size (dim, number of examples)
Y true "label" vector of size (1, number of examples)
Return:
cost negative log-likelih... | [
"Implement",
"the",
"cost",
"function",
"and",
"its",
"gradient",
"for",
"the",
"propagation"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/algorithms/logistic_regression.py#L34-L66 |
52,374 | zengbin93/zb | zb/algorithms/logistic_regression.py | LR_train | def LR_train(w, b, X, Y, num_iterations, learning_rate, print_cost=True):
"""
This function optimizes w and b by running a gradient descent algorithm
Arguments:
w weights, a numpy array of size (dim, 1)
b bias, a scalar
X data of shape (dim, number of examples)
Y tru... | python | def LR_train(w, b, X, Y, num_iterations, learning_rate, print_cost=True):
"""
This function optimizes w and b by running a gradient descent algorithm
Arguments:
w weights, a numpy array of size (dim, 1)
b bias, a scalar
X data of shape (dim, number of examples)
Y tru... | [
"def",
"LR_train",
"(",
"w",
",",
"b",
",",
"X",
",",
"Y",
",",
"num_iterations",
",",
"learning_rate",
",",
"print_cost",
"=",
"True",
")",
":",
"costs",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"num_iterations",
")",
":",
"# Cost and gradient c... | This function optimizes w and b by running a gradient descent algorithm
Arguments:
w weights, a numpy array of size (dim, 1)
b bias, a scalar
X data of shape (dim, number of examples)
Y true "label" vector, of shape (1, number of examples)
num_iterations number of i... | [
"This",
"function",
"optimizes",
"w",
"and",
"b",
"by",
"running",
"a",
"gradient",
"descent",
"algorithm"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/algorithms/logistic_regression.py#L71-L119 |
52,375 | zengbin93/zb | zb/algorithms/logistic_regression.py | model | def model(X_train, Y_train, X_test, Y_test, num_iterations=2000,
learning_rate=0.5, print_cost=True):
"""
Builds the logistic regression model by calling the function
implemented above
Arguments:
X_train training set represented by a numpy array of shape (dim, m_train)
Y_train ... | python | def model(X_train, Y_train, X_test, Y_test, num_iterations=2000,
learning_rate=0.5, print_cost=True):
"""
Builds the logistic regression model by calling the function
implemented above
Arguments:
X_train training set represented by a numpy array of shape (dim, m_train)
Y_train ... | [
"def",
"model",
"(",
"X_train",
",",
"Y_train",
",",
"X_test",
",",
"Y_test",
",",
"num_iterations",
"=",
"2000",
",",
"learning_rate",
"=",
"0.5",
",",
"print_cost",
"=",
"True",
")",
":",
"print",
"(",
"'X_train shape:'",
",",
"X_train",
".",
"shape",
... | Builds the logistic regression model by calling the function
implemented above
Arguments:
X_train training set represented by a numpy array of shape (dim, m_train)
Y_train training labels represented by a numpy array (vector) of shape (1, m_train)
X_test test set represented by a numpy... | [
"Builds",
"the",
"logistic",
"regression",
"model",
"by",
"calling",
"the",
"function",
"implemented",
"above"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/algorithms/logistic_regression.py#L156-L205 |
52,376 | zengbin93/zb | zb/algorithms/logistic_regression.py | plot_lc | def plot_lc(d):
"""plot learning curve
Arguments:
d Returned by model function. Dictionary containing information about the model.
"""
costs = np.squeeze(d['costs'])
plt.plot(costs)
plt.ylabel('cost')
plt.xlabel('iterations (per hundreds)')
plt.title("Learning rate =" + str(d[... | python | def plot_lc(d):
"""plot learning curve
Arguments:
d Returned by model function. Dictionary containing information about the model.
"""
costs = np.squeeze(d['costs'])
plt.plot(costs)
plt.ylabel('cost')
plt.xlabel('iterations (per hundreds)')
plt.title("Learning rate =" + str(d[... | [
"def",
"plot_lc",
"(",
"d",
")",
":",
"costs",
"=",
"np",
".",
"squeeze",
"(",
"d",
"[",
"'costs'",
"]",
")",
"plt",
".",
"plot",
"(",
"costs",
")",
"plt",
".",
"ylabel",
"(",
"'cost'",
")",
"plt",
".",
"xlabel",
"(",
"'iterations (per hundreds)'",
... | plot learning curve
Arguments:
d Returned by model function. Dictionary containing information about the model. | [
"plot",
"learning",
"curve"
] | ccdb384a0b5801b459933220efcb71972c2b89a7 | https://github.com/zengbin93/zb/blob/ccdb384a0b5801b459933220efcb71972c2b89a7/zb/algorithms/logistic_regression.py#L208-L219 |
52,377 | juergberinger/cmdhelper | cmdhelper.py | getLogLevelNo | def getLogLevelNo(level):
"""Return numerical log level or raise ValueError.
A valid level is either an integer or a string such as WARNING etc."""
if isinstance(level,(int,long)):
return level
try:
return(int(logging.getLevelName(level.upper())))
except:
raise ValueError('i... | python | def getLogLevelNo(level):
"""Return numerical log level or raise ValueError.
A valid level is either an integer or a string such as WARNING etc."""
if isinstance(level,(int,long)):
return level
try:
return(int(logging.getLevelName(level.upper())))
except:
raise ValueError('i... | [
"def",
"getLogLevelNo",
"(",
"level",
")",
":",
"if",
"isinstance",
"(",
"level",
",",
"(",
"int",
",",
"long",
")",
")",
":",
"return",
"level",
"try",
":",
"return",
"(",
"int",
"(",
"logging",
".",
"getLevelName",
"(",
"level",
".",
"upper",
"(",
... | Return numerical log level or raise ValueError.
A valid level is either an integer or a string such as WARNING etc. | [
"Return",
"numerical",
"log",
"level",
"or",
"raise",
"ValueError",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L75-L84 |
52,378 | juergberinger/cmdhelper | cmdhelper.py | cmdLine | def cmdLine(useBasename=False):
"""Return full command line with any necessary quoting."""
qargv = []
cmdwords = list(sys.argv)
if useBasename:
cmdwords[0] = os.path.basename(cmdwords[0])
for s in cmdwords:
# any white space or special characters in word so we need quoting?
i... | python | def cmdLine(useBasename=False):
"""Return full command line with any necessary quoting."""
qargv = []
cmdwords = list(sys.argv)
if useBasename:
cmdwords[0] = os.path.basename(cmdwords[0])
for s in cmdwords:
# any white space or special characters in word so we need quoting?
i... | [
"def",
"cmdLine",
"(",
"useBasename",
"=",
"False",
")",
":",
"qargv",
"=",
"[",
"]",
"cmdwords",
"=",
"list",
"(",
"sys",
".",
"argv",
")",
"if",
"useBasename",
":",
"cmdwords",
"[",
"0",
"]",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"cmdword... | Return full command line with any necessary quoting. | [
"Return",
"full",
"command",
"line",
"with",
"any",
"necessary",
"quoting",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L574-L590 |
52,379 | juergberinger/cmdhelper | cmdhelper.py | handleError | def handleError(exception, debugFlag=False, abortFlag=True):
"""Error handling utility. Print more or less error information
depending on debug flag. Unless abort is set False, exits with
error code 1."""
if isinstance(exception, CmdError) or not debugFlag:
error(str(exception))
else:
... | python | def handleError(exception, debugFlag=False, abortFlag=True):
"""Error handling utility. Print more or less error information
depending on debug flag. Unless abort is set False, exits with
error code 1."""
if isinstance(exception, CmdError) or not debugFlag:
error(str(exception))
else:
... | [
"def",
"handleError",
"(",
"exception",
",",
"debugFlag",
"=",
"False",
",",
"abortFlag",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"exception",
",",
"CmdError",
")",
"or",
"not",
"debugFlag",
":",
"error",
"(",
"str",
"(",
"exception",
")",
")",
... | Error handling utility. Print more or less error information
depending on debug flag. Unless abort is set False, exits with
error code 1. | [
"Error",
"handling",
"utility",
".",
"Print",
"more",
"or",
"less",
"error",
"information",
"depending",
"on",
"debug",
"flag",
".",
"Unless",
"abort",
"is",
"set",
"False",
"exits",
"with",
"error",
"code",
"1",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L593-L604 |
52,380 | juergberinger/cmdhelper | cmdhelper.py | confirm | def confirm(msg, acceptByDefault=False, exitCodeOnAbort=1, batch=False):
"""Get user confirmation or abort execution.
confirm returns True (if user confirms) or False (if user declines
and exitCodeOnAbort is None) or aborts with sys.exit(exitCodeOnAbort)
(if user declines and exitCodeOnAbort is not Non... | python | def confirm(msg, acceptByDefault=False, exitCodeOnAbort=1, batch=False):
"""Get user confirmation or abort execution.
confirm returns True (if user confirms) or False (if user declines
and exitCodeOnAbort is None) or aborts with sys.exit(exitCodeOnAbort)
(if user declines and exitCodeOnAbort is not Non... | [
"def",
"confirm",
"(",
"msg",
",",
"acceptByDefault",
"=",
"False",
",",
"exitCodeOnAbort",
"=",
"1",
",",
"batch",
"=",
"False",
")",
":",
"if",
"batch",
":",
"return",
"if",
"acceptByDefault",
":",
"msg",
"+=",
"' - are you sure [y] ? '",
"else",
":",
"m... | Get user confirmation or abort execution.
confirm returns True (if user confirms) or False (if user declines
and exitCodeOnAbort is None) or aborts with sys.exit(exitCodeOnAbort)
(if user declines and exitCodeOnAbort is not None).
Depending on acceptByDefault, the default answer (if user presses
R... | [
"Get",
"user",
"confirmation",
"or",
"abort",
"execution",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L610-L643 |
52,381 | juergberinger/cmdhelper | cmdhelper.py | LogWriter.write | def write(self, text):
"""Write text. An additional attribute terminator with a value of
None is added to the logging record to indicate that StreamHandler
should not add a newline."""
self.logger.log(self.loglevel, text, extra={'terminator': None}) | python | def write(self, text):
"""Write text. An additional attribute terminator with a value of
None is added to the logging record to indicate that StreamHandler
should not add a newline."""
self.logger.log(self.loglevel, text, extra={'terminator': None}) | [
"def",
"write",
"(",
"self",
",",
"text",
")",
":",
"self",
".",
"logger",
".",
"log",
"(",
"self",
".",
"loglevel",
",",
"text",
",",
"extra",
"=",
"{",
"'terminator'",
":",
"None",
"}",
")"
] | Write text. An additional attribute terminator with a value of
None is added to the logging record to indicate that StreamHandler
should not add a newline. | [
"Write",
"text",
".",
"An",
"additional",
"attribute",
"terminator",
"with",
"a",
"value",
"of",
"None",
"is",
"added",
"to",
"the",
"logging",
"record",
"to",
"indicate",
"that",
"StreamHandler",
"should",
"not",
"add",
"a",
"newline",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L110-L114 |
52,382 | juergberinger/cmdhelper | cmdhelper.py | MyStreamHandler.emit | def emit(self, record):
"""Emit a record. Unless record.terminator is set, a trailing
newline will be written to the output stream."""
try:
msg = self.format(record)
if isinstance(msg,unicode):
if hasattr(self.stream, "encoding") and self.stream.encodin... | python | def emit(self, record):
"""Emit a record. Unless record.terminator is set, a trailing
newline will be written to the output stream."""
try:
msg = self.format(record)
if isinstance(msg,unicode):
if hasattr(self.stream, "encoding") and self.stream.encodin... | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"try",
":",
"msg",
"=",
"self",
".",
"format",
"(",
"record",
")",
"if",
"isinstance",
"(",
"msg",
",",
"unicode",
")",
":",
"if",
"hasattr",
"(",
"self",
".",
"stream",
",",
"\"encoding\"",
")",... | Emit a record. Unless record.terminator is set, a trailing
newline will be written to the output stream. | [
"Emit",
"a",
"record",
".",
"Unless",
"record",
".",
"terminator",
"is",
"set",
"a",
"trailing",
"newline",
"will",
"be",
"written",
"to",
"the",
"output",
"stream",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L135-L157 |
52,383 | juergberinger/cmdhelper | cmdhelper.py | MyStreamHandler.flush | def flush(self):
"""Flush the stream.
In contrast to StreamHandler, errors are not caught so the program doesn't iterate
through tons of logging errors e.g. in case of a broken pipe."""
# See /usr/lib64/python2.7/logging/__init__.py, StreamHander.flush()
self.acquire()
t... | python | def flush(self):
"""Flush the stream.
In contrast to StreamHandler, errors are not caught so the program doesn't iterate
through tons of logging errors e.g. in case of a broken pipe."""
# See /usr/lib64/python2.7/logging/__init__.py, StreamHander.flush()
self.acquire()
t... | [
"def",
"flush",
"(",
"self",
")",
":",
"# See /usr/lib64/python2.7/logging/__init__.py, StreamHander.flush()",
"self",
".",
"acquire",
"(",
")",
"try",
":",
"if",
"self",
".",
"stream",
"and",
"hasattr",
"(",
"self",
".",
"stream",
",",
"\"flush\"",
")",
":",
... | Flush the stream.
In contrast to StreamHandler, errors are not caught so the program doesn't iterate
through tons of logging errors e.g. in case of a broken pipe. | [
"Flush",
"the",
"stream",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L159-L175 |
52,384 | juergberinger/cmdhelper | cmdhelper.py | BufferingSMTPHandler.emit | def emit(self, record):
"""Emit record after checking if message triggers later sending of e-mail."""
if self.triggerLevelNo is not None and record.levelno>=self.triggerLevelNo:
self.triggered = True
logging.handlers.BufferingHandler.emit(self,record) | python | def emit(self, record):
"""Emit record after checking if message triggers later sending of e-mail."""
if self.triggerLevelNo is not None and record.levelno>=self.triggerLevelNo:
self.triggered = True
logging.handlers.BufferingHandler.emit(self,record) | [
"def",
"emit",
"(",
"self",
",",
"record",
")",
":",
"if",
"self",
".",
"triggerLevelNo",
"is",
"not",
"None",
"and",
"record",
".",
"levelno",
">=",
"self",
".",
"triggerLevelNo",
":",
"self",
".",
"triggered",
"=",
"True",
"logging",
".",
"handlers",
... | Emit record after checking if message triggers later sending of e-mail. | [
"Emit",
"record",
"after",
"checking",
"if",
"message",
"triggers",
"later",
"sending",
"of",
"e",
"-",
"mail",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L191-L195 |
52,385 | juergberinger/cmdhelper | cmdhelper.py | BufferingSMTPHandler.flush | def flush(self):
"""Send messages by e-mail.
The sending of messages is suppressed if a trigger severity
level has been set and none of the received messages was at
that level or above. In that case the messages are
discarded. Empty e-mails are discarded."""
if self.trig... | python | def flush(self):
"""Send messages by e-mail.
The sending of messages is suppressed if a trigger severity
level has been set and none of the received messages was at
that level or above. In that case the messages are
discarded. Empty e-mails are discarded."""
if self.trig... | [
"def",
"flush",
"(",
"self",
")",
":",
"if",
"self",
".",
"triggered",
"and",
"len",
"(",
"self",
".",
"buffer",
")",
">",
"0",
":",
"# Do not send empty e-mails",
"text",
"=",
"[",
"]",
"for",
"record",
"in",
"self",
".",
"buffer",
":",
"terminator",
... | Send messages by e-mail.
The sending of messages is suppressed if a trigger severity
level has been set and none of the received messages was at
that level or above. In that case the messages are
discarded. Empty e-mails are discarded. | [
"Send",
"messages",
"by",
"e",
"-",
"mail",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L197-L223 |
52,386 | juergberinger/cmdhelper | cmdhelper.py | CmdHelper.add_option | def add_option(self, *args, **kwargs):
"""Add optparse or argparse option depending on CmdHelper initialization."""
if self.parseTool == 'argparse':
if args and args[0] == '': # no short option
args = args[1:]
return self.parser.add_argument(*args, **kwargs)
... | python | def add_option(self, *args, **kwargs):
"""Add optparse or argparse option depending on CmdHelper initialization."""
if self.parseTool == 'argparse':
if args and args[0] == '': # no short option
args = args[1:]
return self.parser.add_argument(*args, **kwargs)
... | [
"def",
"add_option",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"parseTool",
"==",
"'argparse'",
":",
"if",
"args",
"and",
"args",
"[",
"0",
"]",
"==",
"''",
":",
"# no short option",
"args",
"=",
"args",
"... | Add optparse or argparse option depending on CmdHelper initialization. | [
"Add",
"optparse",
"or",
"argparse",
"option",
"depending",
"on",
"CmdHelper",
"initialization",
"."
] | f8453659cf5b43f509a5a01470ea784acae7caac | https://github.com/juergberinger/cmdhelper/blob/f8453659cf5b43f509a5a01470ea784acae7caac/cmdhelper.py#L463-L470 |
52,387 | dcaune/perseus-lib-python-common | exifread/utils.py | make_string | def make_string(seq):
"""
Don't throw an exception when given an out of range character.
"""
string = ''
for c in seq:
# Screen out non-printing characters
try:
if 32 <= c and c < 256:
string += chr(c)
except TypeError:
pass
# I... | python | def make_string(seq):
"""
Don't throw an exception when given an out of range character.
"""
string = ''
for c in seq:
# Screen out non-printing characters
try:
if 32 <= c and c < 256:
string += chr(c)
except TypeError:
pass
# I... | [
"def",
"make_string",
"(",
"seq",
")",
":",
"string",
"=",
"''",
"for",
"c",
"in",
"seq",
":",
"# Screen out non-printing characters",
"try",
":",
"if",
"32",
"<=",
"c",
"and",
"c",
"<",
"256",
":",
"string",
"+=",
"chr",
"(",
"c",
")",
"except",
"Ty... | Don't throw an exception when given an out of range character. | [
"Don",
"t",
"throw",
"an",
"exception",
"when",
"given",
"an",
"out",
"of",
"range",
"character",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/exifread/utils.py#L12-L27 |
52,388 | dcaune/perseus-lib-python-common | setup.py | read_file | def read_file(file_path_name):
"""
Read the content of the specified file.
@param file_path_name: path and name of the file to read.
@return: content of the specified file.
"""
with io.open(os.path.join(os.path.dirname(__file__), file_path_name), mode='rt', encoding='utf-8') as fd:
r... | python | def read_file(file_path_name):
"""
Read the content of the specified file.
@param file_path_name: path and name of the file to read.
@return: content of the specified file.
"""
with io.open(os.path.join(os.path.dirname(__file__), file_path_name), mode='rt', encoding='utf-8') as fd:
r... | [
"def",
"read_file",
"(",
"file_path_name",
")",
":",
"with",
"io",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"file_path_name",
")",
",",
"mode",
"=",
"'rt'",
",",
"encoding",
... | Read the content of the specified file.
@param file_path_name: path and name of the file to read.
@return: content of the specified file. | [
"Read",
"the",
"content",
"of",
"the",
"specified",
"file",
"."
] | ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496 | https://github.com/dcaune/perseus-lib-python-common/blob/ba48fe0fd9bb4a75b53e7d10c41ada36a72d4496/setup.py#L64-L75 |
52,389 | tundish/turberfield-dialogue | turberfield/dialogue/performer.py | Performer.run | def run(self, react=True, strict=True, roles=1):
"""Select a cast and perform the next scene.
:param bool react: If `True`, then Property directives are executed
at the point they are encountered. Pass `False` to skip them
so they can be enacted later on.
:param bool str... | python | def run(self, react=True, strict=True, roles=1):
"""Select a cast and perform the next scene.
:param bool react: If `True`, then Property directives are executed
at the point they are encountered. Pass `False` to skip them
so they can be enacted later on.
:param bool str... | [
"def",
"run",
"(",
"self",
",",
"react",
"=",
"True",
",",
"strict",
"=",
"True",
",",
"roles",
"=",
"1",
")",
":",
"try",
":",
"folder",
",",
"index",
",",
"self",
".",
"script",
",",
"self",
".",
"selection",
",",
"interlude",
"=",
"self",
".",... | Select a cast and perform the next scene.
:param bool react: If `True`, then Property directives are executed
at the point they are encountered. Pass `False` to skip them
so they can be enacted later on.
:param bool strict: Only fully-cast scripts to be performed.
:param... | [
"Select",
"a",
"cast",
"and",
"perform",
"the",
"next",
"scene",
"."
] | e7ccf7c19ae162e2f315ddf2642394e858529b4a | https://github.com/tundish/turberfield-dialogue/blob/e7ccf7c19ae162e2f315ddf2642394e858529b4a/turberfield/dialogue/performer.py#L83-L129 |
52,390 | AbletonAG/abl.vpath | abl/vpath/base/fs.py | BaseUri.md5 | def md5(self):
"""
Returns the md5-sum of this file. This is of course potentially
expensive!
"""
hash_ = hashlib.md5()
with self.open("rb") as inf:
block = inf.read(4096)
while block:
hash_.update(block)
block = inf... | python | def md5(self):
"""
Returns the md5-sum of this file. This is of course potentially
expensive!
"""
hash_ = hashlib.md5()
with self.open("rb") as inf:
block = inf.read(4096)
while block:
hash_.update(block)
block = inf... | [
"def",
"md5",
"(",
"self",
")",
":",
"hash_",
"=",
"hashlib",
".",
"md5",
"(",
")",
"with",
"self",
".",
"open",
"(",
"\"rb\"",
")",
"as",
"inf",
":",
"block",
"=",
"inf",
".",
"read",
"(",
"4096",
")",
"while",
"block",
":",
"hash_",
".",
"upd... | Returns the md5-sum of this file. This is of course potentially
expensive! | [
"Returns",
"the",
"md5",
"-",
"sum",
"of",
"this",
"file",
".",
"This",
"is",
"of",
"course",
"potentially",
"expensive!"
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/fs.py#L788-L800 |
52,391 | AbletonAG/abl.vpath | abl/vpath/base/fs.py | BaseUri.lock | def lock(self, fail_on_lock=False, cleanup=False):
"""
Allows to lock a file via abl.util.LockFile, with the
same parameters there.
Returns an opened, writable file.
"""
return self.connection.lock(self, fail_on_lock, cleanup) | python | def lock(self, fail_on_lock=False, cleanup=False):
"""
Allows to lock a file via abl.util.LockFile, with the
same parameters there.
Returns an opened, writable file.
"""
return self.connection.lock(self, fail_on_lock, cleanup) | [
"def",
"lock",
"(",
"self",
",",
"fail_on_lock",
"=",
"False",
",",
"cleanup",
"=",
"False",
")",
":",
"return",
"self",
".",
"connection",
".",
"lock",
"(",
"self",
",",
"fail_on_lock",
",",
"cleanup",
")"
] | Allows to lock a file via abl.util.LockFile, with the
same parameters there.
Returns an opened, writable file. | [
"Allows",
"to",
"lock",
"a",
"file",
"via",
"abl",
".",
"util",
".",
"LockFile",
"with",
"the",
"same",
"parameters",
"there",
"."
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/fs.py#L804-L811 |
52,392 | AbletonAG/abl.vpath | abl/vpath/base/fs.py | BaseUri._manipulate | def _manipulate(self, *args, **kwargs):
"""
This is a semi-private method. It's current use is to
manipulate memory file system objects so that
you can create certain conditions, to provoke
errors that otherwise won't occur.
"""
self.connection._manipulate(self, *... | python | def _manipulate(self, *args, **kwargs):
"""
This is a semi-private method. It's current use is to
manipulate memory file system objects so that
you can create certain conditions, to provoke
errors that otherwise won't occur.
"""
self.connection._manipulate(self, *... | [
"def",
"_manipulate",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"connection",
".",
"_manipulate",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | This is a semi-private method. It's current use is to
manipulate memory file system objects so that
you can create certain conditions, to provoke
errors that otherwise won't occur. | [
"This",
"is",
"a",
"semi",
"-",
"private",
"method",
".",
"It",
"s",
"current",
"use",
"is",
"to",
"manipulate",
"memory",
"file",
"system",
"objects",
"so",
"that",
"you",
"can",
"create",
"certain",
"conditions",
"to",
"provoke",
"errors",
"that",
"other... | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/fs.py#L815-L822 |
52,393 | AbletonAG/abl.vpath | abl/vpath/base/fs.py | FileSystem.move | def move(self, source, destination):
"""
the semantic should be like unix 'mv' command
"""
if source.isfile():
source.copy(destination)
source.remove()
else:
source.copy(destination, recursive=True)
source.remove('r') | python | def move(self, source, destination):
"""
the semantic should be like unix 'mv' command
"""
if source.isfile():
source.copy(destination)
source.remove()
else:
source.copy(destination, recursive=True)
source.remove('r') | [
"def",
"move",
"(",
"self",
",",
"source",
",",
"destination",
")",
":",
"if",
"source",
".",
"isfile",
"(",
")",
":",
"source",
".",
"copy",
"(",
"destination",
")",
"source",
".",
"remove",
"(",
")",
"else",
":",
"source",
".",
"copy",
"(",
"dest... | the semantic should be like unix 'mv' command | [
"the",
"semantic",
"should",
"be",
"like",
"unix",
"mv",
"command"
] | a57491347f6e7567afa047216e5b6f6035226eaf | https://github.com/AbletonAG/abl.vpath/blob/a57491347f6e7567afa047216e5b6f6035226eaf/abl/vpath/base/fs.py#L985-L994 |
52,394 | bbengfort/commis | commis/program.py | ConsoleProgram.parser | def parser(self):
"""
Instantiates the argparse parser
"""
if self._parser is None:
apkw = {
'description': self.description,
'epilog': self.epilog,
}
self._parser = argparse.ArgumentParser(**apkw)
# Fo... | python | def parser(self):
"""
Instantiates the argparse parser
"""
if self._parser is None:
apkw = {
'description': self.description,
'epilog': self.epilog,
}
self._parser = argparse.ArgumentParser(**apkw)
# Fo... | [
"def",
"parser",
"(",
"self",
")",
":",
"if",
"self",
".",
"_parser",
"is",
"None",
":",
"apkw",
"=",
"{",
"'description'",
":",
"self",
".",
"description",
",",
"'epilog'",
":",
"self",
".",
"epilog",
",",
"}",
"self",
".",
"_parser",
"=",
"argparse... | Instantiates the argparse parser | [
"Instantiates",
"the",
"argparse",
"parser"
] | cea696ccd1fec9c22974ae396b7e66c4275240ad | https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/program.py#L69-L87 |
52,395 | bbengfort/commis | commis/program.py | ConsoleProgram.subparsers | def subparsers(self):
"""
Insantiates the subparsers for all commands
"""
if self._subparsers is None:
apkw = {
'title': 'commands',
'description': 'Commands for the %s program' % self.parser.prog,
}
self._subparsers = s... | python | def subparsers(self):
"""
Insantiates the subparsers for all commands
"""
if self._subparsers is None:
apkw = {
'title': 'commands',
'description': 'Commands for the %s program' % self.parser.prog,
}
self._subparsers = s... | [
"def",
"subparsers",
"(",
"self",
")",
":",
"if",
"self",
".",
"_subparsers",
"is",
"None",
":",
"apkw",
"=",
"{",
"'title'",
":",
"'commands'",
",",
"'description'",
":",
"'Commands for the %s program'",
"%",
"self",
".",
"parser",
".",
"prog",
",",
"}",
... | Insantiates the subparsers for all commands | [
"Insantiates",
"the",
"subparsers",
"for",
"all",
"commands"
] | cea696ccd1fec9c22974ae396b7e66c4275240ad | https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/program.py#L90-L100 |
52,396 | bbengfort/commis | commis/program.py | ConsoleProgram.register | def register(self, command):
"""
Registers a command with the program
"""
command = command()
if command.name in self.commands:
raise ConsoleError(
"Command %s already registered!" % command.name
)
command.create_parser(self.subpar... | python | def register(self, command):
"""
Registers a command with the program
"""
command = command()
if command.name in self.commands:
raise ConsoleError(
"Command %s already registered!" % command.name
)
command.create_parser(self.subpar... | [
"def",
"register",
"(",
"self",
",",
"command",
")",
":",
"command",
"=",
"command",
"(",
")",
"if",
"command",
".",
"name",
"in",
"self",
".",
"commands",
":",
"raise",
"ConsoleError",
"(",
"\"Command %s already registered!\"",
"%",
"command",
".",
"name",
... | Registers a command with the program | [
"Registers",
"a",
"command",
"with",
"the",
"program"
] | cea696ccd1fec9c22974ae396b7e66c4275240ad | https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/program.py#L102-L113 |
52,397 | bbengfort/commis | commis/program.py | ConsoleProgram.exit | def exit(self, code=0, message=None):
"""
Exit the console program sanely.
"""
## If we have a parser, use it to exit
if self._parser:
if code > 0:
self.parser.error(message)
else:
self.parser.exit(code, message)
#... | python | def exit(self, code=0, message=None):
"""
Exit the console program sanely.
"""
## If we have a parser, use it to exit
if self._parser:
if code > 0:
self.parser.error(message)
else:
self.parser.exit(code, message)
#... | [
"def",
"exit",
"(",
"self",
",",
"code",
"=",
"0",
",",
"message",
"=",
"None",
")",
":",
"## If we have a parser, use it to exit",
"if",
"self",
".",
"_parser",
":",
"if",
"code",
">",
"0",
":",
"self",
".",
"parser",
".",
"error",
"(",
"message",
")"... | Exit the console program sanely. | [
"Exit",
"the",
"console",
"program",
"sanely",
"."
] | cea696ccd1fec9c22974ae396b7e66c4275240ad | https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/program.py#L115-L137 |
52,398 | bbengfort/commis | commis/program.py | ConsoleProgram.execute | def execute(self):
"""
Entry point to the execution of the program.
"""
# Ensure that we have commands registered
if not self.commands or self._parser is None:
raise NotImplementedError(
"No commands registered with this program!"
)
... | python | def execute(self):
"""
Entry point to the execution of the program.
"""
# Ensure that we have commands registered
if not self.commands or self._parser is None:
raise NotImplementedError(
"No commands registered with this program!"
)
... | [
"def",
"execute",
"(",
"self",
")",
":",
"# Ensure that we have commands registered",
"if",
"not",
"self",
".",
"commands",
"or",
"self",
".",
"_parser",
"is",
"None",
":",
"raise",
"NotImplementedError",
"(",
"\"No commands registered with this program!\"",
")",
"# H... | Entry point to the execution of the program. | [
"Entry",
"point",
"to",
"the",
"execution",
"of",
"the",
"program",
"."
] | cea696ccd1fec9c22974ae396b7e66c4275240ad | https://github.com/bbengfort/commis/blob/cea696ccd1fec9c22974ae396b7e66c4275240ad/commis/program.py#L139-L169 |
52,399 | Divirad/PythonTranslate | pythontranslate/__init__.py | Translator.get_lang_array | def get_lang_array(self):
"""gets supported langs as an array"""
r = self.yandex_translate_request("getLangs", "")
self.handle_errors(r)
return r.json()["dirs"] | python | def get_lang_array(self):
"""gets supported langs as an array"""
r = self.yandex_translate_request("getLangs", "")
self.handle_errors(r)
return r.json()["dirs"] | [
"def",
"get_lang_array",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"yandex_translate_request",
"(",
"\"getLangs\"",
",",
"\"\"",
")",
"self",
".",
"handle_errors",
"(",
"r",
")",
"return",
"r",
".",
"json",
"(",
")",
"[",
"\"dirs\"",
"]"
] | gets supported langs as an array | [
"gets",
"supported",
"langs",
"as",
"an",
"array"
] | 625e97563bb586692f4a128b284a2aa79f82c279 | https://github.com/Divirad/PythonTranslate/blob/625e97563bb586692f4a128b284a2aa79f82c279/pythontranslate/__init__.py#L34-L40 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.