repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
dcos/shakedown | shakedown/cli/main.py | cli | def cli(**args):
""" Shakedown is a DC/OS test-harness wrapper for the pytest tool.
"""
import shakedown
# Read configuration options from ~/.shakedown (if exists)
args = read_config(args)
# Set configuration defaults
args = set_config_defaults(args)
if args['quiet']:
shakedow... | python | def cli(**args):
""" Shakedown is a DC/OS test-harness wrapper for the pytest tool.
"""
import shakedown
# Read configuration options from ~/.shakedown (if exists)
args = read_config(args)
# Set configuration defaults
args = set_config_defaults(args)
if args['quiet']:
shakedow... | [
"def",
"cli",
"(",
"*",
"*",
"args",
")",
":",
"import",
"shakedown",
"# Read configuration options from ~/.shakedown (if exists)",
"args",
"=",
"read_config",
"(",
"args",
")",
"# Set configuration defaults",
"args",
"=",
"set_config_defaults",
"(",
"args",
")",
"if"... | Shakedown is a DC/OS test-harness wrapper for the pytest tool. | [
"Shakedown",
"is",
"a",
"DC",
"/",
"OS",
"test",
"-",
"harness",
"wrapper",
"for",
"the",
"pytest",
"tool",
"."
] | train | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/cli/main.py#L30-L355 |
makinacorpus/landez | landez/sources.py | MBTilesReader.find_coverage | def find_coverage(self, zoom):
"""
Returns the bounding box (minx, miny, maxx, maxy) of an adjacent
group of tiles at this zoom level.
"""
# Find a group of adjacent available tiles at this zoom level
rows = self._query('''SELECT tile_column, tile_row FROM tiles
... | python | def find_coverage(self, zoom):
"""
Returns the bounding box (minx, miny, maxx, maxy) of an adjacent
group of tiles at this zoom level.
"""
# Find a group of adjacent available tiles at this zoom level
rows = self._query('''SELECT tile_column, tile_row FROM tiles
... | [
"def",
"find_coverage",
"(",
"self",
",",
"zoom",
")",
":",
"# Find a group of adjacent available tiles at this zoom level",
"rows",
"=",
"self",
".",
"_query",
"(",
"'''SELECT tile_column, tile_row FROM tiles\n WHERE zoom_level=?\n ... | Returns the bounding box (minx, miny, maxx, maxy) of an adjacent
group of tiles at this zoom level. | [
"Returns",
"the",
"bounding",
"box",
"(",
"minx",
"miny",
"maxx",
"maxy",
")",
"of",
"an",
"adjacent",
"group",
"of",
"tiles",
"at",
"this",
"zoom",
"level",
"."
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/sources.py#L128-L151 |
makinacorpus/landez | landez/sources.py | TileDownloader.tile | def tile(self, z, x, y):
"""
Download the specified tile from `tiles_url`
"""
logger.debug(_("Download tile %s") % ((z, x, y),))
# Render each keyword in URL ({s}, {x}, {y}, {z}, {size} ... )
size = self.tilesize
s = self.tiles_subdomains[(x + y) % len(self.tiles_... | python | def tile(self, z, x, y):
"""
Download the specified tile from `tiles_url`
"""
logger.debug(_("Download tile %s") % ((z, x, y),))
# Render each keyword in URL ({s}, {x}, {y}, {z}, {size} ... )
size = self.tilesize
s = self.tiles_subdomains[(x + y) % len(self.tiles_... | [
"def",
"tile",
"(",
"self",
",",
"z",
",",
"x",
",",
"y",
")",
":",
"logger",
".",
"debug",
"(",
"_",
"(",
"\"Download tile %s\"",
")",
"%",
"(",
"(",
"z",
",",
"x",
",",
"y",
")",
",",
")",
")",
"# Render each keyword in URL ({s}, {x}, {y}, {z}, {size... | Download the specified tile from `tiles_url` | [
"Download",
"the",
"specified",
"tile",
"from",
"tiles_url"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/sources.py#L163-L192 |
makinacorpus/landez | landez/sources.py | MapnikRenderer.tile | def tile(self, z, x, y):
"""
Render the specified tile with Mapnik
"""
logger.debug(_("Render tile %s") % ((z, x, y),))
proj = GoogleProjection(self.tilesize, [z])
return self.render(proj.tile_bbox((z, x, y))) | python | def tile(self, z, x, y):
"""
Render the specified tile with Mapnik
"""
logger.debug(_("Render tile %s") % ((z, x, y),))
proj = GoogleProjection(self.tilesize, [z])
return self.render(proj.tile_bbox((z, x, y))) | [
"def",
"tile",
"(",
"self",
",",
"z",
",",
"x",
",",
"y",
")",
":",
"logger",
".",
"debug",
"(",
"_",
"(",
"\"Render tile %s\"",
")",
"%",
"(",
"(",
"z",
",",
"x",
",",
"y",
")",
",",
")",
")",
"proj",
"=",
"GoogleProjection",
"(",
"self",
".... | Render the specified tile with Mapnik | [
"Render",
"the",
"specified",
"tile",
"with",
"Mapnik"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/sources.py#L247-L253 |
makinacorpus/landez | landez/sources.py | MapnikRenderer.render | def render(self, bbox, width=None, height=None):
"""
Render the specified tile with Mapnik
"""
width = width or self.tilesize
height = height or self.tilesize
self._prepare_rendering(bbox, width=width, height=height)
# Render image with default Agg renderer
... | python | def render(self, bbox, width=None, height=None):
"""
Render the specified tile with Mapnik
"""
width = width or self.tilesize
height = height or self.tilesize
self._prepare_rendering(bbox, width=width, height=height)
# Render image with default Agg renderer
... | [
"def",
"render",
"(",
"self",
",",
"bbox",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
")",
":",
"width",
"=",
"width",
"or",
"self",
".",
"tilesize",
"height",
"=",
"height",
"or",
"self",
".",
"tilesize",
"self",
".",
"_prepare_rendering",... | Render the specified tile with Mapnik | [
"Render",
"the",
"specified",
"tile",
"with",
"Mapnik"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/sources.py#L274-L290 |
makinacorpus/landez | landez/sources.py | MapnikRenderer.grid | def grid(self, z, x, y, fields, layer):
"""
Render the specified grid with Mapnik
"""
logger.debug(_("Render grid %s") % ((z, x, y),))
proj = GoogleProjection(self.tilesize, [z])
return self.render_grid(proj.tile_bbox((z, x, y)), fields, layer) | python | def grid(self, z, x, y, fields, layer):
"""
Render the specified grid with Mapnik
"""
logger.debug(_("Render grid %s") % ((z, x, y),))
proj = GoogleProjection(self.tilesize, [z])
return self.render_grid(proj.tile_bbox((z, x, y)), fields, layer) | [
"def",
"grid",
"(",
"self",
",",
"z",
",",
"x",
",",
"y",
",",
"fields",
",",
"layer",
")",
":",
"logger",
".",
"debug",
"(",
"_",
"(",
"\"Render grid %s\"",
")",
"%",
"(",
"(",
"z",
",",
"x",
",",
"y",
")",
",",
")",
")",
"proj",
"=",
"Goo... | Render the specified grid with Mapnik | [
"Render",
"the",
"specified",
"grid",
"with",
"Mapnik"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/sources.py#L292-L298 |
makinacorpus/landez | landez/sources.py | MapnikRenderer.render_grid | def render_grid(self, bbox, grid_fields, layer, width=None, height=None):
"""
Render the specified grid with Mapnik
"""
width = width or self.tilesize
height = height or self.tilesize
self._prepare_rendering(bbox, width=width, height=height)
grid = mapnik.Grid(wi... | python | def render_grid(self, bbox, grid_fields, layer, width=None, height=None):
"""
Render the specified grid with Mapnik
"""
width = width or self.tilesize
height = height or self.tilesize
self._prepare_rendering(bbox, width=width, height=height)
grid = mapnik.Grid(wi... | [
"def",
"render_grid",
"(",
"self",
",",
"bbox",
",",
"grid_fields",
",",
"layer",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
")",
":",
"width",
"=",
"width",
"or",
"self",
".",
"tilesize",
"height",
"=",
"height",
"or",
"self",
".",
"tile... | Render the specified grid with Mapnik | [
"Render",
"the",
"specified",
"grid",
"with",
"Mapnik"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/sources.py#L300-L311 |
makinacorpus/landez | landez/proj.py | GoogleProjection.tile_at | def tile_at(self, zoom, position):
"""
Returns a tuple of (z, x, y)
"""
x, y = self.project_pixels(position, zoom)
return (zoom, int(x/self.tilesize), int(y/self.tilesize)) | python | def tile_at(self, zoom, position):
"""
Returns a tuple of (z, x, y)
"""
x, y = self.project_pixels(position, zoom)
return (zoom, int(x/self.tilesize), int(y/self.tilesize)) | [
"def",
"tile_at",
"(",
"self",
",",
"zoom",
",",
"position",
")",
":",
"x",
",",
"y",
"=",
"self",
".",
"project_pixels",
"(",
"position",
",",
"zoom",
")",
"return",
"(",
"zoom",
",",
"int",
"(",
"x",
"/",
"self",
".",
"tilesize",
")",
",",
"int... | Returns a tuple of (z, x, y) | [
"Returns",
"a",
"tuple",
"of",
"(",
"z",
"x",
"y",
")"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/proj.py#L66-L71 |
makinacorpus/landez | landez/proj.py | GoogleProjection.project | def project(self, lng_lat):
"""
Returns the coordinates in meters from WGS84
"""
(lng, lat) = lng_lat
x = lng * DEG_TO_RAD
lat = max(min(MAX_LATITUDE, lat), -MAX_LATITUDE)
y = lat * DEG_TO_RAD
y = log(tan((pi / 4) + (y / 2)))
return (x*EARTH_RADIUS... | python | def project(self, lng_lat):
"""
Returns the coordinates in meters from WGS84
"""
(lng, lat) = lng_lat
x = lng * DEG_TO_RAD
lat = max(min(MAX_LATITUDE, lat), -MAX_LATITUDE)
y = lat * DEG_TO_RAD
y = log(tan((pi / 4) + (y / 2)))
return (x*EARTH_RADIUS... | [
"def",
"project",
"(",
"self",
",",
"lng_lat",
")",
":",
"(",
"lng",
",",
"lat",
")",
"=",
"lng_lat",
"x",
"=",
"lng",
"*",
"DEG_TO_RAD",
"lat",
"=",
"max",
"(",
"min",
"(",
"MAX_LATITUDE",
",",
"lat",
")",
",",
"-",
"MAX_LATITUDE",
")",
"y",
"="... | Returns the coordinates in meters from WGS84 | [
"Returns",
"the",
"coordinates",
"in",
"meters",
"from",
"WGS84"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/proj.py#L84-L93 |
makinacorpus/landez | landez/filters.py | Filter.string2rgba | def string2rgba(cls, colorstring):
""" Convert #RRGGBBAA to an (R, G, B, A) tuple """
colorstring = colorstring.strip()
if colorstring[0] == '#':
colorstring = colorstring[1:]
if len(colorstring) < 6:
raise ValueError("input #%s is not in #RRGGBB format" % colorst... | python | def string2rgba(cls, colorstring):
""" Convert #RRGGBBAA to an (R, G, B, A) tuple """
colorstring = colorstring.strip()
if colorstring[0] == '#':
colorstring = colorstring[1:]
if len(colorstring) < 6:
raise ValueError("input #%s is not in #RRGGBB format" % colorst... | [
"def",
"string2rgba",
"(",
"cls",
",",
"colorstring",
")",
":",
"colorstring",
"=",
"colorstring",
".",
"strip",
"(",
")",
"if",
"colorstring",
"[",
"0",
"]",
"==",
"'#'",
":",
"colorstring",
"=",
"colorstring",
"[",
"1",
":",
"]",
"if",
"len",
"(",
... | Convert #RRGGBBAA to an (R, G, B, A) tuple | [
"Convert",
"#RRGGBBAA",
"to",
"an",
"(",
"R",
"G",
"B",
"A",
")",
"tuple"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/filters.py#L10-L22 |
makinacorpus/landez | landez/tiles.py | TilesManager.tileslist | def tileslist(self, bbox, zoomlevels):
"""
Build the tiles list within the bottom-left/top-right bounding
box (minx, miny, maxx, maxy) at the specified zoom levels.
Return a list of tuples (z,x,y)
"""
proj = GoogleProjection(self.tile_size, zoomlevels, self.tile_scheme)
... | python | def tileslist(self, bbox, zoomlevels):
"""
Build the tiles list within the bottom-left/top-right bounding
box (minx, miny, maxx, maxy) at the specified zoom levels.
Return a list of tuples (z,x,y)
"""
proj = GoogleProjection(self.tile_size, zoomlevels, self.tile_scheme)
... | [
"def",
"tileslist",
"(",
"self",
",",
"bbox",
",",
"zoomlevels",
")",
":",
"proj",
"=",
"GoogleProjection",
"(",
"self",
".",
"tile_size",
",",
"zoomlevels",
",",
"self",
".",
"tile_scheme",
")",
"return",
"proj",
".",
"tileslist",
"(",
"bbox",
")"
] | Build the tiles list within the bottom-left/top-right bounding
box (minx, miny, maxx, maxy) at the specified zoom levels.
Return a list of tuples (z,x,y) | [
"Build",
"the",
"tiles",
"list",
"within",
"the",
"bottom",
"-",
"left",
"/",
"top",
"-",
"right",
"bounding",
"box",
"(",
"minx",
"miny",
"maxx",
"maxy",
")",
"at",
"the",
"specified",
"zoom",
"levels",
".",
"Return",
"a",
"list",
"of",
"tuples",
"(",... | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L137-L144 |
makinacorpus/landez | landez/tiles.py | TilesManager.add_layer | def add_layer(self, tilemanager, opacity=1.0):
"""
Add a layer to be blended (alpha-composite) on top of the tile.
tilemanager -- a `TileManager` instance
opacity -- transparency factor for compositing
"""
assert has_pil, _("Cannot blend layers without python PIL")
... | python | def add_layer(self, tilemanager, opacity=1.0):
"""
Add a layer to be blended (alpha-composite) on top of the tile.
tilemanager -- a `TileManager` instance
opacity -- transparency factor for compositing
"""
assert has_pil, _("Cannot blend layers without python PIL")
... | [
"def",
"add_layer",
"(",
"self",
",",
"tilemanager",
",",
"opacity",
"=",
"1.0",
")",
":",
"assert",
"has_pil",
",",
"_",
"(",
"\"Cannot blend layers without python PIL\"",
")",
"assert",
"self",
".",
"tile_size",
"==",
"tilemanager",
".",
"tile_size",
",",
"_... | Add a layer to be blended (alpha-composite) on top of the tile.
tilemanager -- a `TileManager` instance
opacity -- transparency factor for compositing | [
"Add",
"a",
"layer",
"to",
"be",
"blended",
"(",
"alpha",
"-",
"composite",
")",
"on",
"top",
"of",
"the",
"tile",
".",
"tilemanager",
"--",
"a",
"TileManager",
"instance",
"opacity",
"--",
"transparency",
"factor",
"for",
"compositing"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L146-L156 |
makinacorpus/landez | landez/tiles.py | TilesManager.add_filter | def add_filter(self, filter_):
""" Add an image filter for post-processing """
assert has_pil, _("Cannot add filters without python PIL")
self.cache.basename += filter_.basename
self._filters.append(filter_) | python | def add_filter(self, filter_):
""" Add an image filter for post-processing """
assert has_pil, _("Cannot add filters without python PIL")
self.cache.basename += filter_.basename
self._filters.append(filter_) | [
"def",
"add_filter",
"(",
"self",
",",
"filter_",
")",
":",
"assert",
"has_pil",
",",
"_",
"(",
"\"Cannot add filters without python PIL\"",
")",
"self",
".",
"cache",
".",
"basename",
"+=",
"filter_",
".",
"basename",
"self",
".",
"_filters",
".",
"append",
... | Add an image filter for post-processing | [
"Add",
"an",
"image",
"filter",
"for",
"post",
"-",
"processing"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L158-L162 |
makinacorpus/landez | landez/tiles.py | TilesManager.tile | def tile(self, z_x_y):
"""
Return the tile (binary) content of the tile and seed the cache.
"""
(z, x, y) = z_x_y
logger.debug(_("tile method called with %s") % ([z, x, y]))
output = self.cache.read((z, x, y))
if output is None:
output = self.reader.t... | python | def tile(self, z_x_y):
"""
Return the tile (binary) content of the tile and seed the cache.
"""
(z, x, y) = z_x_y
logger.debug(_("tile method called with %s") % ([z, x, y]))
output = self.cache.read((z, x, y))
if output is None:
output = self.reader.t... | [
"def",
"tile",
"(",
"self",
",",
"z_x_y",
")",
":",
"(",
"z",
",",
"x",
",",
"y",
")",
"=",
"z_x_y",
"logger",
".",
"debug",
"(",
"_",
"(",
"\"tile method called with %s\"",
")",
"%",
"(",
"[",
"z",
",",
"x",
",",
"y",
"]",
")",
")",
"output",
... | Return the tile (binary) content of the tile and seed the cache. | [
"Return",
"the",
"tile",
"(",
"binary",
")",
"content",
"of",
"the",
"tile",
"and",
"seed",
"the",
"cache",
"."
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L164-L186 |
makinacorpus/landez | landez/tiles.py | TilesManager.grid | def grid(self, z_x_y):
""" Return the UTFGrid content """
# sources.py -> MapnikRenderer -> grid
(z, x, y) = z_x_y
content = self.reader.grid(z, x, y, self.grid_fields, self.grid_layer)
return content | python | def grid(self, z_x_y):
""" Return the UTFGrid content """
# sources.py -> MapnikRenderer -> grid
(z, x, y) = z_x_y
content = self.reader.grid(z, x, y, self.grid_fields, self.grid_layer)
return content | [
"def",
"grid",
"(",
"self",
",",
"z_x_y",
")",
":",
"# sources.py -> MapnikRenderer -> grid",
"(",
"z",
",",
"x",
",",
"y",
")",
"=",
"z_x_y",
"content",
"=",
"self",
".",
"reader",
".",
"grid",
"(",
"z",
",",
"x",
",",
"y",
",",
"self",
".",
"grid... | Return the UTFGrid content | [
"Return",
"the",
"UTFGrid",
"content"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L188-L193 |
makinacorpus/landez | landez/tiles.py | TilesManager._blend_layers | def _blend_layers(self, imagecontent, z_x_y):
"""
Merge tiles of all layers into the specified tile path
"""
(z, x, y) = z_x_y
result = self._tile_image(imagecontent)
# Paste each layer
for (layer, opacity) in self._layers:
try:
# Prepa... | python | def _blend_layers(self, imagecontent, z_x_y):
"""
Merge tiles of all layers into the specified tile path
"""
(z, x, y) = z_x_y
result = self._tile_image(imagecontent)
# Paste each layer
for (layer, opacity) in self._layers:
try:
# Prepa... | [
"def",
"_blend_layers",
"(",
"self",
",",
"imagecontent",
",",
"z_x_y",
")",
":",
"(",
"z",
",",
"x",
",",
"y",
")",
"=",
"z_x_y",
"result",
"=",
"self",
".",
"_tile_image",
"(",
"imagecontent",
")",
"# Paste each layer",
"for",
"(",
"layer",
",",
"opa... | Merge tiles of all layers into the specified tile path | [
"Merge",
"tiles",
"of",
"all",
"layers",
"into",
"the",
"specified",
"tile",
"path"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L196-L219 |
makinacorpus/landez | landez/tiles.py | TilesManager._tile_image | def _tile_image(self, data):
"""
Tile binary content as PIL Image.
"""
image = Image.open(BytesIO(data))
return image.convert('RGBA') | python | def _tile_image(self, data):
"""
Tile binary content as PIL Image.
"""
image = Image.open(BytesIO(data))
return image.convert('RGBA') | [
"def",
"_tile_image",
"(",
"self",
",",
"data",
")",
":",
"image",
"=",
"Image",
".",
"open",
"(",
"BytesIO",
"(",
"data",
")",
")",
"return",
"image",
".",
"convert",
"(",
"'RGBA'",
")"
] | Tile binary content as PIL Image. | [
"Tile",
"binary",
"content",
"as",
"PIL",
"Image",
"."
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L221-L226 |
makinacorpus/landez | landez/tiles.py | MBTilesBuilder.zoomlevels | def zoomlevels(self):
"""
Return the list of covered zoom levels, in ascending order
"""
zooms = set()
for coverage in self._bboxes:
for zoom in coverage[1]:
zooms.add(zoom)
return sorted(zooms) | python | def zoomlevels(self):
"""
Return the list of covered zoom levels, in ascending order
"""
zooms = set()
for coverage in self._bboxes:
for zoom in coverage[1]:
zooms.add(zoom)
return sorted(zooms) | [
"def",
"zoomlevels",
"(",
"self",
")",
":",
"zooms",
"=",
"set",
"(",
")",
"for",
"coverage",
"in",
"self",
".",
"_bboxes",
":",
"for",
"zoom",
"in",
"coverage",
"[",
"1",
"]",
":",
"zooms",
".",
"add",
"(",
"zoom",
")",
"return",
"sorted",
"(",
... | Return the list of covered zoom levels, in ascending order | [
"Return",
"the",
"list",
"of",
"covered",
"zoom",
"levels",
"in",
"ascending",
"order"
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L263-L271 |
makinacorpus/landez | landez/tiles.py | MBTilesBuilder.run | def run(self, force=False):
"""
Build a MBTile file.
force -- overwrite if MBTiles file already exists.
"""
if os.path.exists(self.filepath):
if force:
logger.warn(_("%s already exists. Overwrite.") % self.filepath)
os.remove(self.file... | python | def run(self, force=False):
"""
Build a MBTile file.
force -- overwrite if MBTiles file already exists.
"""
if os.path.exists(self.filepath):
if force:
logger.warn(_("%s already exists. Overwrite.") % self.filepath)
os.remove(self.file... | [
"def",
"run",
"(",
"self",
",",
"force",
"=",
"False",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"filepath",
")",
":",
"if",
"force",
":",
"logger",
".",
"warn",
"(",
"_",
"(",
"\"%s already exists. Overwrite.\"",
")",
"%",
... | Build a MBTile file.
force -- overwrite if MBTiles file already exists. | [
"Build",
"a",
"MBTile",
"file",
"."
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L280-L370 |
makinacorpus/landez | landez/tiles.py | ImageExporter.grid_tiles | def grid_tiles(self, bbox, zoomlevel):
"""
Return a grid of (x, y) tuples representing the juxtaposition
of tiles on the specified ``bbox`` at the specified ``zoomlevel``.
"""
tiles = self.tileslist(bbox, [zoomlevel])
grid = {}
for (z, x, y) in tiles:
... | python | def grid_tiles(self, bbox, zoomlevel):
"""
Return a grid of (x, y) tuples representing the juxtaposition
of tiles on the specified ``bbox`` at the specified ``zoomlevel``.
"""
tiles = self.tileslist(bbox, [zoomlevel])
grid = {}
for (z, x, y) in tiles:
... | [
"def",
"grid_tiles",
"(",
"self",
",",
"bbox",
",",
"zoomlevel",
")",
":",
"tiles",
"=",
"self",
".",
"tileslist",
"(",
"bbox",
",",
"[",
"zoomlevel",
"]",
")",
"grid",
"=",
"{",
"}",
"for",
"(",
"z",
",",
"x",
",",
"y",
")",
"in",
"tiles",
":"... | Return a grid of (x, y) tuples representing the juxtaposition
of tiles on the specified ``bbox`` at the specified ``zoomlevel``. | [
"Return",
"a",
"grid",
"of",
"(",
"x",
"y",
")",
"tuples",
"representing",
"the",
"juxtaposition",
"of",
"tiles",
"on",
"the",
"specified",
"bbox",
"at",
"the",
"specified",
"zoomlevel",
"."
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L410-L424 |
makinacorpus/landez | landez/tiles.py | ImageExporter.export_image | def export_image(self, bbox, zoomlevel, imagepath):
"""
Writes to ``imagepath`` the tiles for the specified bounding box and zoomlevel.
"""
assert has_pil, _("Cannot export image without python PIL")
grid = self.grid_tiles(bbox, zoomlevel)
width = len(grid[0])
hei... | python | def export_image(self, bbox, zoomlevel, imagepath):
"""
Writes to ``imagepath`` the tiles for the specified bounding box and zoomlevel.
"""
assert has_pil, _("Cannot export image without python PIL")
grid = self.grid_tiles(bbox, zoomlevel)
width = len(grid[0])
hei... | [
"def",
"export_image",
"(",
"self",
",",
"bbox",
",",
"zoomlevel",
",",
"imagepath",
")",
":",
"assert",
"has_pil",
",",
"_",
"(",
"\"Cannot export image without python PIL\"",
")",
"grid",
"=",
"self",
".",
"grid_tiles",
"(",
"bbox",
",",
"zoomlevel",
")",
... | Writes to ``imagepath`` the tiles for the specified bounding box and zoomlevel. | [
"Writes",
"to",
"imagepath",
"the",
"tiles",
"for",
"the",
"specified",
"bounding",
"box",
"and",
"zoomlevel",
"."
] | train | https://github.com/makinacorpus/landez/blob/6e5c71ded6071158e7943df204cd7bd1ed623a30/landez/tiles.py#L426-L445 |
robotools/extractor | Lib/extractor/formats/opentype.py | _makeScriptOrder | def _makeScriptOrder(gpos):
"""
Run therough GPOS and make an alphabetically
ordered list of scripts. If DFLT is in the list,
move it to the front.
"""
scripts = []
for scriptRecord in gpos.ScriptList.ScriptRecord:
scripts.append(scriptRecord.ScriptTag)
if "DFLT" in scripts:
... | python | def _makeScriptOrder(gpos):
"""
Run therough GPOS and make an alphabetically
ordered list of scripts. If DFLT is in the list,
move it to the front.
"""
scripts = []
for scriptRecord in gpos.ScriptList.ScriptRecord:
scripts.append(scriptRecord.ScriptTag)
if "DFLT" in scripts:
... | [
"def",
"_makeScriptOrder",
"(",
"gpos",
")",
":",
"scripts",
"=",
"[",
"]",
"for",
"scriptRecord",
"in",
"gpos",
".",
"ScriptList",
".",
"ScriptRecord",
":",
"scripts",
".",
"append",
"(",
"scriptRecord",
".",
"ScriptTag",
")",
"if",
"\"DFLT\"",
"in",
"scr... | Run therough GPOS and make an alphabetically
ordered list of scripts. If DFLT is in the list,
move it to the front. | [
"Run",
"therough",
"GPOS",
"and",
"make",
"an",
"alphabetically",
"ordered",
"list",
"of",
"scripts",
".",
"If",
"DFLT",
"is",
"in",
"the",
"list",
"move",
"it",
"to",
"the",
"front",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L408-L420 |
robotools/extractor | Lib/extractor/formats/opentype.py | _gatherDataFromLookups | def _gatherDataFromLookups(gpos, scriptOrder):
"""
Gather kerning and classes from the applicable lookups
and return them in script order.
"""
lookupIndexes = _gatherLookupIndexes(gpos)
seenLookups = set()
kerningDictionaries = []
leftClassDictionaries = []
rightClassDictionaries = [... | python | def _gatherDataFromLookups(gpos, scriptOrder):
"""
Gather kerning and classes from the applicable lookups
and return them in script order.
"""
lookupIndexes = _gatherLookupIndexes(gpos)
seenLookups = set()
kerningDictionaries = []
leftClassDictionaries = []
rightClassDictionaries = [... | [
"def",
"_gatherDataFromLookups",
"(",
"gpos",
",",
"scriptOrder",
")",
":",
"lookupIndexes",
"=",
"_gatherLookupIndexes",
"(",
"gpos",
")",
"seenLookups",
"=",
"set",
"(",
")",
"kerningDictionaries",
"=",
"[",
"]",
"leftClassDictionaries",
"=",
"[",
"]",
"rightC... | Gather kerning and classes from the applicable lookups
and return them in script order. | [
"Gather",
"kerning",
"and",
"classes",
"from",
"the",
"applicable",
"lookups",
"and",
"return",
"them",
"in",
"script",
"order",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L422-L451 |
robotools/extractor | Lib/extractor/formats/opentype.py | _gatherLookupIndexes | def _gatherLookupIndexes(gpos):
"""
Gather a mapping of script to lookup indexes
referenced by the kern feature for each script.
Returns a dictionary of this structure:
{
"latn" : [0],
"DFLT" : [0]
}
"""
# gather the indexes of the kern features
kernFe... | python | def _gatherLookupIndexes(gpos):
"""
Gather a mapping of script to lookup indexes
referenced by the kern feature for each script.
Returns a dictionary of this structure:
{
"latn" : [0],
"DFLT" : [0]
}
"""
# gather the indexes of the kern features
kernFe... | [
"def",
"_gatherLookupIndexes",
"(",
"gpos",
")",
":",
"# gather the indexes of the kern features",
"kernFeatureIndexes",
"=",
"[",
"index",
"for",
"index",
",",
"featureRecord",
"in",
"enumerate",
"(",
"gpos",
".",
"FeatureList",
".",
"FeatureRecord",
")",
"if",
"fe... | Gather a mapping of script to lookup indexes
referenced by the kern feature for each script.
Returns a dictionary of this structure:
{
"latn" : [0],
"DFLT" : [0]
} | [
"Gather",
"a",
"mapping",
"of",
"script",
"to",
"lookup",
"indexes",
"referenced",
"by",
"the",
"kern",
"feature",
"for",
"each",
"script",
".",
"Returns",
"a",
"dictionary",
"of",
"this",
"structure",
":",
"{",
"latn",
":",
"[",
"0",
"]",
"DFLT",
":",
... | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L453-L501 |
robotools/extractor | Lib/extractor/formats/opentype.py | _gatherKerningForLookup | def _gatherKerningForLookup(gpos, lookupIndex):
"""
Gather the kerning and class data for a particular lookup.
Returns kerning, left clases, right classes.
The kerning dictionary is of this structure:
{
("a", "a") : 10,
((1, 1, 3), "a") : -20
}
The class dicti... | python | def _gatherKerningForLookup(gpos, lookupIndex):
"""
Gather the kerning and class data for a particular lookup.
Returns kerning, left clases, right classes.
The kerning dictionary is of this structure:
{
("a", "a") : 10,
((1, 1, 3), "a") : -20
}
The class dicti... | [
"def",
"_gatherKerningForLookup",
"(",
"gpos",
",",
"lookupIndex",
")",
":",
"allKerning",
"=",
"{",
"}",
"allLeftClasses",
"=",
"{",
"}",
"allRightClasses",
"=",
"{",
"}",
"lookup",
"=",
"gpos",
".",
"LookupList",
".",
"Lookup",
"[",
"lookupIndex",
"]",
"... | Gather the kerning and class data for a particular lookup.
Returns kerning, left clases, right classes.
The kerning dictionary is of this structure:
{
("a", "a") : 10,
((1, 1, 3), "a") : -20
}
The class dictionaries have this structure:
{
(1, 1, 3)... | [
"Gather",
"the",
"kerning",
"and",
"class",
"data",
"for",
"a",
"particular",
"lookup",
".",
"Returns",
"kerning",
"left",
"clases",
"right",
"classes",
".",
"The",
"kerning",
"dictionary",
"is",
"of",
"this",
"structure",
":",
"{",
"(",
"a",
"a",
")",
"... | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L503-L551 |
robotools/extractor | Lib/extractor/formats/opentype.py | _handleLookupType2Format1 | def _handleLookupType2Format1(subtable):
"""
Extract a kerning dictionary from a Lookup Type 2 Format 1.
"""
kerning = {}
coverage = subtable.Coverage.glyphs
valueFormat1 = subtable.ValueFormat1
pairSets = subtable.PairSet
for index, leftGlyphName in enumerate(coverage):
pairSet ... | python | def _handleLookupType2Format1(subtable):
"""
Extract a kerning dictionary from a Lookup Type 2 Format 1.
"""
kerning = {}
coverage = subtable.Coverage.glyphs
valueFormat1 = subtable.ValueFormat1
pairSets = subtable.PairSet
for index, leftGlyphName in enumerate(coverage):
pairSet ... | [
"def",
"_handleLookupType2Format1",
"(",
"subtable",
")",
":",
"kerning",
"=",
"{",
"}",
"coverage",
"=",
"subtable",
".",
"Coverage",
".",
"glyphs",
"valueFormat1",
"=",
"subtable",
".",
"ValueFormat1",
"pairSets",
"=",
"subtable",
".",
"PairSet",
"for",
"ind... | Extract a kerning dictionary from a Lookup Type 2 Format 1. | [
"Extract",
"a",
"kerning",
"dictionary",
"from",
"a",
"Lookup",
"Type",
"2",
"Format",
"1",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L553-L572 |
robotools/extractor | Lib/extractor/formats/opentype.py | _handleLookupType2Format2 | def _handleLookupType2Format2(subtable, lookupIndex, subtableIndex):
"""
Extract kerning, left class and right class dictionaries from a Lookup Type 2 Format 2.
"""
# extract the classes
leftClasses = _extractFeatureClasses(lookupIndex=lookupIndex, subtableIndex=subtableIndex, classDefs=subtable.Cla... | python | def _handleLookupType2Format2(subtable, lookupIndex, subtableIndex):
"""
Extract kerning, left class and right class dictionaries from a Lookup Type 2 Format 2.
"""
# extract the classes
leftClasses = _extractFeatureClasses(lookupIndex=lookupIndex, subtableIndex=subtableIndex, classDefs=subtable.Cla... | [
"def",
"_handleLookupType2Format2",
"(",
"subtable",
",",
"lookupIndex",
",",
"subtableIndex",
")",
":",
"# extract the classes",
"leftClasses",
"=",
"_extractFeatureClasses",
"(",
"lookupIndex",
"=",
"lookupIndex",
",",
"subtableIndex",
"=",
"subtableIndex",
",",
"clas... | Extract kerning, left class and right class dictionaries from a Lookup Type 2 Format 2. | [
"Extract",
"kerning",
"left",
"class",
"and",
"right",
"class",
"dictionaries",
"from",
"a",
"Lookup",
"Type",
"2",
"Format",
"2",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L574-L595 |
robotools/extractor | Lib/extractor/formats/opentype.py | _mergeKerningDictionaries | def _mergeKerningDictionaries(kerningDictionaries):
"""
Merge all of the kerning dictionaries found into
one flat dictionary.
"""
# work through the dictionaries backwards since
# this uses an update to load the kerning. this
# will ensure that the script order is honored.
kerning = {}
... | python | def _mergeKerningDictionaries(kerningDictionaries):
"""
Merge all of the kerning dictionaries found into
one flat dictionary.
"""
# work through the dictionaries backwards since
# this uses an update to load the kerning. this
# will ensure that the script order is honored.
kerning = {}
... | [
"def",
"_mergeKerningDictionaries",
"(",
"kerningDictionaries",
")",
":",
"# work through the dictionaries backwards since",
"# this uses an update to load the kerning. this",
"# will ensure that the script order is honored.",
"kerning",
"=",
"{",
"}",
"for",
"dictionaryGroup",
"in",
... | Merge all of the kerning dictionaries found into
one flat dictionary. | [
"Merge",
"all",
"of",
"the",
"kerning",
"dictionaries",
"found",
"into",
"one",
"flat",
"dictionary",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L597-L610 |
robotools/extractor | Lib/extractor/formats/opentype.py | _findSingleMemberGroups | def _findSingleMemberGroups(classDictionaries):
"""
Find all classes that have only one member.
"""
toRemove = {}
for classDictionaryGroup in classDictionaries:
for classDictionary in classDictionaryGroup:
for name, members in list(classDictionary.items()):
if len... | python | def _findSingleMemberGroups(classDictionaries):
"""
Find all classes that have only one member.
"""
toRemove = {}
for classDictionaryGroup in classDictionaries:
for classDictionary in classDictionaryGroup:
for name, members in list(classDictionary.items()):
if len... | [
"def",
"_findSingleMemberGroups",
"(",
"classDictionaries",
")",
":",
"toRemove",
"=",
"{",
"}",
"for",
"classDictionaryGroup",
"in",
"classDictionaries",
":",
"for",
"classDictionary",
"in",
"classDictionaryGroup",
":",
"for",
"name",
",",
"members",
"in",
"list",
... | Find all classes that have only one member. | [
"Find",
"all",
"classes",
"that",
"have",
"only",
"one",
"member",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L612-L623 |
robotools/extractor | Lib/extractor/formats/opentype.py | _removeSingleMemberGroupReferences | def _removeSingleMemberGroupReferences(kerning, leftGroups, rightGroups):
"""
Translate group names into glyph names in pairs
if the group only contains one glyph.
"""
new = {}
for (left, right), value in kerning.items():
left = leftGroups.get(left, left)
right = rightGroups.get(... | python | def _removeSingleMemberGroupReferences(kerning, leftGroups, rightGroups):
"""
Translate group names into glyph names in pairs
if the group only contains one glyph.
"""
new = {}
for (left, right), value in kerning.items():
left = leftGroups.get(left, left)
right = rightGroups.get(... | [
"def",
"_removeSingleMemberGroupReferences",
"(",
"kerning",
",",
"leftGroups",
",",
"rightGroups",
")",
":",
"new",
"=",
"{",
"}",
"for",
"(",
"left",
",",
"right",
")",
",",
"value",
"in",
"kerning",
".",
"items",
"(",
")",
":",
"left",
"=",
"leftGroup... | Translate group names into glyph names in pairs
if the group only contains one glyph. | [
"Translate",
"group",
"names",
"into",
"glyph",
"names",
"in",
"pairs",
"if",
"the",
"group",
"only",
"contains",
"one",
"glyph",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L625-L635 |
robotools/extractor | Lib/extractor/formats/opentype.py | _mergeClasses | def _mergeClasses(classDictionaries):
"""
Look for classes that have the exact same list
of members and flag them for removal.
This returns left classes, left rename map,
right classes and right rename map.
The classes have the standard class structure.
The rename maps have this structure:
... | python | def _mergeClasses(classDictionaries):
"""
Look for classes that have the exact same list
of members and flag them for removal.
This returns left classes, left rename map,
right classes and right rename map.
The classes have the standard class structure.
The rename maps have this structure:
... | [
"def",
"_mergeClasses",
"(",
"classDictionaries",
")",
":",
"# build a mapping of members to names",
"memberTree",
"=",
"{",
"}",
"for",
"classDictionaryGroup",
"in",
"classDictionaries",
":",
"for",
"classDictionary",
"in",
"classDictionaryGroup",
":",
"for",
"name",
"... | Look for classes that have the exact same list
of members and flag them for removal.
This returns left classes, left rename map,
right classes and right rename map.
The classes have the standard class structure.
The rename maps have this structure:
{
(1, 1, 3) : (2, 3, 4),
... | [
"Look",
"for",
"classes",
"that",
"have",
"the",
"exact",
"same",
"list",
"of",
"members",
"and",
"flag",
"them",
"for",
"removal",
".",
"This",
"returns",
"left",
"classes",
"left",
"rename",
"map",
"right",
"classes",
"and",
"right",
"rename",
"map",
"."... | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L637-L670 |
robotools/extractor | Lib/extractor/formats/opentype.py | _setGroupNames | def _setGroupNames(classes, classRename):
"""
Set the final names into the groups.
"""
groups = {}
for groupName, glyphList in classes.items():
groupName = classRename.get(groupName, groupName)
# if the glyph list has only one member,
# the glyph name will be used in the pair... | python | def _setGroupNames(classes, classRename):
"""
Set the final names into the groups.
"""
groups = {}
for groupName, glyphList in classes.items():
groupName = classRename.get(groupName, groupName)
# if the glyph list has only one member,
# the glyph name will be used in the pair... | [
"def",
"_setGroupNames",
"(",
"classes",
",",
"classRename",
")",
":",
"groups",
"=",
"{",
"}",
"for",
"groupName",
",",
"glyphList",
"in",
"classes",
".",
"items",
"(",
")",
":",
"groupName",
"=",
"classRename",
".",
"get",
"(",
"groupName",
",",
"group... | Set the final names into the groups. | [
"Set",
"the",
"final",
"names",
"into",
"the",
"groups",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L672-L685 |
robotools/extractor | Lib/extractor/formats/opentype.py | _validateClasses | def _validateClasses(classes):
"""
Check to make sure that a glyph is not part of more than
one class. If this is found, an ExtractorError is raised.
"""
glyphToClass = {}
for className, glyphList in classes.items():
for glyphName in glyphList:
if glyphName not in glyphToClas... | python | def _validateClasses(classes):
"""
Check to make sure that a glyph is not part of more than
one class. If this is found, an ExtractorError is raised.
"""
glyphToClass = {}
for className, glyphList in classes.items():
for glyphName in glyphList:
if glyphName not in glyphToClas... | [
"def",
"_validateClasses",
"(",
"classes",
")",
":",
"glyphToClass",
"=",
"{",
"}",
"for",
"className",
",",
"glyphList",
"in",
"classes",
".",
"items",
"(",
")",
":",
"for",
"glyphName",
"in",
"glyphList",
":",
"if",
"glyphName",
"not",
"in",
"glyphToClas... | Check to make sure that a glyph is not part of more than
one class. If this is found, an ExtractorError is raised. | [
"Check",
"to",
"make",
"sure",
"that",
"a",
"glyph",
"is",
"not",
"part",
"of",
"more",
"than",
"one",
"class",
".",
"If",
"this",
"is",
"found",
"an",
"ExtractorError",
"is",
"raised",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L687-L700 |
robotools/extractor | Lib/extractor/formats/opentype.py | _replaceRenamedPairMembers | def _replaceRenamedPairMembers(kerning, leftRename, rightRename):
"""
Populate the renamed pair members into the kerning.
"""
renamedKerning = {}
for (left, right), value in kerning.items():
left = leftRename.get(left, left)
right = rightRename.get(right, right)
renamedKernin... | python | def _replaceRenamedPairMembers(kerning, leftRename, rightRename):
"""
Populate the renamed pair members into the kerning.
"""
renamedKerning = {}
for (left, right), value in kerning.items():
left = leftRename.get(left, left)
right = rightRename.get(right, right)
renamedKernin... | [
"def",
"_replaceRenamedPairMembers",
"(",
"kerning",
",",
"leftRename",
",",
"rightRename",
")",
":",
"renamedKerning",
"=",
"{",
"}",
"for",
"(",
"left",
",",
"right",
")",
",",
"value",
"in",
"kerning",
".",
"items",
"(",
")",
":",
"left",
"=",
"leftRe... | Populate the renamed pair members into the kerning. | [
"Populate",
"the",
"renamed",
"pair",
"members",
"into",
"the",
"kerning",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L702-L711 |
robotools/extractor | Lib/extractor/formats/opentype.py | _renameClasses | def _renameClasses(classes, prefix):
"""
Replace class IDs with nice strings.
"""
renameMap = {}
for classID, glyphList in classes.items():
if len(glyphList) == 0:
groupName = "%s_empty_lu.%d_st.%d_cl.%d" % (prefix, classID[0], classID[1], classID[2])
elif len(glyphList) ... | python | def _renameClasses(classes, prefix):
"""
Replace class IDs with nice strings.
"""
renameMap = {}
for classID, glyphList in classes.items():
if len(glyphList) == 0:
groupName = "%s_empty_lu.%d_st.%d_cl.%d" % (prefix, classID[0], classID[1], classID[2])
elif len(glyphList) ... | [
"def",
"_renameClasses",
"(",
"classes",
",",
"prefix",
")",
":",
"renameMap",
"=",
"{",
"}",
"for",
"classID",
",",
"glyphList",
"in",
"classes",
".",
"items",
"(",
")",
":",
"if",
"len",
"(",
"glyphList",
")",
"==",
"0",
":",
"groupName",
"=",
"\"%... | Replace class IDs with nice strings. | [
"Replace",
"class",
"IDs",
"with",
"nice",
"strings",
"."
] | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L713-L727 |
robotools/extractor | Lib/extractor/formats/opentype.py | _extractFeatureClasses | def _extractFeatureClasses(lookupIndex, subtableIndex, classDefs, coverage=None):
"""
Extract classes for a specific lookup in a specific subtable.
This is relatively straightforward, except for class 0 interpretation.
Some fonts don't have class 0. Some fonts have a list of class
members that are c... | python | def _extractFeatureClasses(lookupIndex, subtableIndex, classDefs, coverage=None):
"""
Extract classes for a specific lookup in a specific subtable.
This is relatively straightforward, except for class 0 interpretation.
Some fonts don't have class 0. Some fonts have a list of class
members that are c... | [
"def",
"_extractFeatureClasses",
"(",
"lookupIndex",
",",
"subtableIndex",
",",
"classDefs",
",",
"coverage",
"=",
"None",
")",
":",
"# gather the class members",
"classDict",
"=",
"{",
"}",
"for",
"glyphName",
",",
"classIndex",
"in",
"classDefs",
".",
"items",
... | Extract classes for a specific lookup in a specific subtable.
This is relatively straightforward, except for class 0 interpretation.
Some fonts don't have class 0. Some fonts have a list of class
members that are clearly not all to be used in kerning pairs.
In the case of a missing class 0, the coverage... | [
"Extract",
"classes",
"for",
"a",
"specific",
"lookup",
"in",
"a",
"specific",
"subtable",
".",
"This",
"is",
"relatively",
"straightforward",
"except",
"for",
"class",
"0",
"interpretation",
".",
"Some",
"fonts",
"don",
"t",
"have",
"class",
"0",
".",
"Some... | train | https://github.com/robotools/extractor/blob/da3c2c92bfd3da863dd5de29bd8bc94cbbf433df/Lib/extractor/formats/opentype.py#L729-L762 |
sgaynetdinov/py-vkontakte | vk/polls.py | PollAnswer._get_voters | def _get_voters(cls, session, owner_id, poll_id, answer_id):
"""
https://vk.com/dev/polls.getVoters
"""
from .users import User
return session.fetch_items("polls.getVoters", User._get_users, count=100, owner_id=owner_id, poll_id=poll_id, answer_ids=answer_id) | python | def _get_voters(cls, session, owner_id, poll_id, answer_id):
"""
https://vk.com/dev/polls.getVoters
"""
from .users import User
return session.fetch_items("polls.getVoters", User._get_users, count=100, owner_id=owner_id, poll_id=poll_id, answer_ids=answer_id) | [
"def",
"_get_voters",
"(",
"cls",
",",
"session",
",",
"owner_id",
",",
"poll_id",
",",
"answer_id",
")",
":",
"from",
".",
"users",
"import",
"User",
"return",
"session",
".",
"fetch_items",
"(",
"\"polls.getVoters\"",
",",
"User",
".",
"_get_users",
",",
... | https://vk.com/dev/polls.getVoters | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"polls",
".",
"getVoters"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/polls.py#L51-L57 |
thriftrw/thriftrw-python | thriftrw/compile/compiler.py | ModuleSpec.add_include | def add_include(self, name, module_spec):
"""Adds a module as an included module.
:param name:
Name under which the included module should be exposed in the
current module.
:param module_spec:
ModuleSpec of the included module.
"""
assert name... | python | def add_include(self, name, module_spec):
"""Adds a module as an included module.
:param name:
Name under which the included module should be exposed in the
current module.
:param module_spec:
ModuleSpec of the included module.
"""
assert name... | [
"def",
"add_include",
"(",
"self",
",",
"name",
",",
"module_spec",
")",
":",
"assert",
"name",
",",
"'name is required'",
"assert",
"self",
".",
"can_include",
"if",
"name",
"in",
"self",
".",
"includes",
":",
"raise",
"ThriftCompilerError",
"(",
"'Cannot inc... | Adds a module as an included module.
:param name:
Name under which the included module should be exposed in the
current module.
:param module_spec:
ModuleSpec of the included module. | [
"Adds",
"a",
"module",
"as",
"an",
"included",
"module",
"."
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/compiler.py#L90-L110 |
thriftrw/thriftrw-python | thriftrw/compile/compiler.py | ModuleSpec.link | def link(self):
"""Link all the types in this module and all included modules."""
if self.linked:
return self
self.linked = True
included_modules = []
# Link includes
for include in self.includes.values():
included_modules.append(include.link().... | python | def link(self):
"""Link all the types in this module and all included modules."""
if self.linked:
return self
self.linked = True
included_modules = []
# Link includes
for include in self.includes.values():
included_modules.append(include.link().... | [
"def",
"link",
"(",
"self",
")",
":",
"if",
"self",
".",
"linked",
":",
"return",
"self",
"self",
".",
"linked",
"=",
"True",
"included_modules",
"=",
"[",
"]",
"# Link includes",
"for",
"include",
"in",
"self",
".",
"includes",
".",
"values",
"(",
")"... | Link all the types in this module and all included modules. | [
"Link",
"all",
"the",
"types",
"in",
"this",
"module",
"and",
"all",
"included",
"modules",
"."
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/compiler.py#L112-L135 |
thriftrw/thriftrw-python | thriftrw/compile/compiler.py | Compiler.compile | def compile(self, name, contents, path=None):
"""Compile the given Thrift document into a Python module.
The generated module contains,
.. py:attribute:: __services__
A collection of generated classes for all services defined in the
thrift file.
.. version... | python | def compile(self, name, contents, path=None):
"""Compile the given Thrift document into a Python module.
The generated module contains,
.. py:attribute:: __services__
A collection of generated classes for all services defined in the
thrift file.
.. version... | [
"def",
"compile",
"(",
"self",
",",
"name",
",",
"contents",
",",
"path",
"=",
"None",
")",
":",
"assert",
"name",
"if",
"path",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"if",
"path",
"in",
"self",
".",
"_module_specs"... | Compile the given Thrift document into a Python module.
The generated module contains,
.. py:attribute:: __services__
A collection of generated classes for all services defined in the
thrift file.
.. versionchanged:: 1.0
Renamed from ``services`` ... | [
"Compile",
"the",
"given",
"Thrift",
"document",
"into",
"a",
"Python",
"module",
"."
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/compile/compiler.py#L164-L278 |
thriftrw/thriftrw-python | thriftrw/idl/lexer.py | LexerSpec.t_HEXCONSTANT | def t_HEXCONSTANT(self, t):
r'0x[0-9A-Fa-f]+'
t.value = int(t.value, 16)
t.type = 'INTCONSTANT'
return t | python | def t_HEXCONSTANT(self, t):
r'0x[0-9A-Fa-f]+'
t.value = int(t.value, 16)
t.type = 'INTCONSTANT'
return t | [
"def",
"t_HEXCONSTANT",
"(",
"self",
",",
"t",
")",
":",
"t",
".",
"value",
"=",
"int",
"(",
"t",
".",
"value",
",",
"16",
")",
"t",
".",
"type",
"=",
"'INTCONSTANT'",
"return",
"t"
] | r'0x[0-9A-Fa-f]+ | [
"r",
"0x",
"[",
"0",
"-",
"9A",
"-",
"Fa",
"-",
"f",
"]",
"+"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/lexer.py#L113-L117 |
thriftrw/thriftrw-python | thriftrw/idl/lexer.py | LexerSpec.t_LITERAL | def t_LITERAL(self, t):
r'(\"([^\\\n]|(\\.))*?\")|\'([^\\\n]|(\\.))*?\''
s = t.value[1:-1]
maps = {
't': '\t',
'r': '\r',
'n': '\n',
'\\': '\\',
'\'': '\'',
'"': '\"'
}
i = 0
length = len(s)
v... | python | def t_LITERAL(self, t):
r'(\"([^\\\n]|(\\.))*?\")|\'([^\\\n]|(\\.))*?\''
s = t.value[1:-1]
maps = {
't': '\t',
'r': '\r',
'n': '\n',
'\\': '\\',
'\'': '\'',
'"': '\"'
}
i = 0
length = len(s)
v... | [
"def",
"t_LITERAL",
"(",
"self",
",",
"t",
")",
":",
"s",
"=",
"t",
".",
"value",
"[",
"1",
":",
"-",
"1",
"]",
"maps",
"=",
"{",
"'t'",
":",
"'\\t'",
",",
"'r'",
":",
"'\\r'",
",",
"'n'",
":",
"'\\n'",
",",
"'\\\\'",
":",
"'\\\\'",
",",
"'... | r'(\"([^\\\n]|(\\.))*?\")|\'([^\\\n]|(\\.))*?\ | [
"r",
"(",
"\\",
"(",
"[",
"^",
"\\\\\\",
"n",
"]",
"|",
"(",
"\\\\",
".",
"))",
"*",
"?",
"\\",
")",
"|",
"\\",
"(",
"[",
"^",
"\\\\\\",
"n",
"]",
"|",
"(",
"\\\\",
".",
"))",
"*",
"?",
"\\"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/lexer.py#L124-L151 |
thriftrw/thriftrw-python | thriftrw/idl/lexer.py | LexerSpec.t_IDENTIFIER | def t_IDENTIFIER(self, t):
r'[a-zA-Z_](\.[a-zA-Z_0-9]|[a-zA-Z_0-9])*'
if t.value in THRIFT_KEYWORDS:
# Not an identifier after all.
t.type = t.value.upper()
return t | python | def t_IDENTIFIER(self, t):
r'[a-zA-Z_](\.[a-zA-Z_0-9]|[a-zA-Z_0-9])*'
if t.value in THRIFT_KEYWORDS:
# Not an identifier after all.
t.type = t.value.upper()
return t | [
"def",
"t_IDENTIFIER",
"(",
"self",
",",
"t",
")",
":",
"if",
"t",
".",
"value",
"in",
"THRIFT_KEYWORDS",
":",
"# Not an identifier after all.",
"t",
".",
"type",
"=",
"t",
".",
"value",
".",
"upper",
"(",
")",
"return",
"t"
] | r'[a-zA-Z_](\.[a-zA-Z_0-9]|[a-zA-Z_0-9])* | [
"r",
"[",
"a",
"-",
"zA",
"-",
"Z_",
"]",
"(",
"\\",
".",
"[",
"a",
"-",
"zA",
"-",
"Z_0",
"-",
"9",
"]",
"|",
"[",
"a",
"-",
"zA",
"-",
"Z_0",
"-",
"9",
"]",
")",
"*"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/lexer.py#L153-L160 |
thriftrw/thriftrw-python | thriftrw/idl/lexer.py | Lexer.input | def input(self, data):
"""Reset the lexer and feed in new input.
:param data:
String of input data.
"""
# input(..) doesn't reset the lineno. We have to do that manually.
self._lexer.lineno = 1
return self._lexer.input(data) | python | def input(self, data):
"""Reset the lexer and feed in new input.
:param data:
String of input data.
"""
# input(..) doesn't reset the lineno. We have to do that manually.
self._lexer.lineno = 1
return self._lexer.input(data) | [
"def",
"input",
"(",
"self",
",",
"data",
")",
":",
"# input(..) doesn't reset the lineno. We have to do that manually.",
"self",
".",
"_lexer",
".",
"lineno",
"=",
"1",
"return",
"self",
".",
"_lexer",
".",
"input",
"(",
"data",
")"
] | Reset the lexer and feed in new input.
:param data:
String of input data. | [
"Reset",
"the",
"lexer",
"and",
"feed",
"in",
"new",
"input",
"."
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/lexer.py#L169-L177 |
sgaynetdinov/py-vkontakte | vk/photos.py | Photo.from_json | def from_json(cls, session, photo_json):
"""
https://vk.com/dev/objects/photo
"""
photo = cls()
photo.id = photo_json.get('id')
photo.album_id = photo_json.get('album_id')
photo.owner_id = photo_json.get('owner_id')
photo.user_id = photo_json.get('user_id'... | python | def from_json(cls, session, photo_json):
"""
https://vk.com/dev/objects/photo
"""
photo = cls()
photo.id = photo_json.get('id')
photo.album_id = photo_json.get('album_id')
photo.owner_id = photo_json.get('owner_id')
photo.user_id = photo_json.get('user_id'... | [
"def",
"from_json",
"(",
"cls",
",",
"session",
",",
"photo_json",
")",
":",
"photo",
"=",
"cls",
"(",
")",
"photo",
".",
"id",
"=",
"photo_json",
".",
"get",
"(",
"'id'",
")",
"photo",
".",
"album_id",
"=",
"photo_json",
".",
"get",
"(",
"'album_id'... | https://vk.com/dev/objects/photo | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"objects",
"/",
"photo"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/photos.py#L9-L28 |
sgaynetdinov/py-vkontakte | vk/photos.py | Photo._get_photos | def _get_photos(session, user_or_group_id):
"""
https://vk.com/dev/photos.getAll
"""
response = session.fetch_items("photos.getAll", Photo.from_json, count=200, owner_id=user_or_group_id)
return response | python | def _get_photos(session, user_or_group_id):
"""
https://vk.com/dev/photos.getAll
"""
response = session.fetch_items("photos.getAll", Photo.from_json, count=200, owner_id=user_or_group_id)
return response | [
"def",
"_get_photos",
"(",
"session",
",",
"user_or_group_id",
")",
":",
"response",
"=",
"session",
".",
"fetch_items",
"(",
"\"photos.getAll\"",
",",
"Photo",
".",
"from_json",
",",
"count",
"=",
"200",
",",
"owner_id",
"=",
"user_or_group_id",
")",
"return"... | https://vk.com/dev/photos.getAll | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"photos",
".",
"getAll"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/photos.py#L34-L39 |
sgaynetdinov/py-vkontakte | vk/photos.py | Photo._get_owner_cover_photo_upload_server | def _get_owner_cover_photo_upload_server(session, group_id, crop_x=0, crop_y=0, crop_x2=795, crop_y2=200):
"""
https://vk.com/dev/photos.getOwnerCoverPhotoUploadServer
"""
group_id = abs(group_id)
response = session.fetch("photos.getOwnerCoverPhotoUploadServer", group_id=group_id... | python | def _get_owner_cover_photo_upload_server(session, group_id, crop_x=0, crop_y=0, crop_x2=795, crop_y2=200):
"""
https://vk.com/dev/photos.getOwnerCoverPhotoUploadServer
"""
group_id = abs(group_id)
response = session.fetch("photos.getOwnerCoverPhotoUploadServer", group_id=group_id... | [
"def",
"_get_owner_cover_photo_upload_server",
"(",
"session",
",",
"group_id",
",",
"crop_x",
"=",
"0",
",",
"crop_y",
"=",
"0",
",",
"crop_x2",
"=",
"795",
",",
"crop_y2",
"=",
"200",
")",
":",
"group_id",
"=",
"abs",
"(",
"group_id",
")",
"response",
... | https://vk.com/dev/photos.getOwnerCoverPhotoUploadServer | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"photos",
".",
"getOwnerCoverPhotoUploadServer"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/photos.py#L42-L48 |
sgaynetdinov/py-vkontakte | vk/photos.py | Photo._save_owner_cover_photo | def _save_owner_cover_photo(session, hash, photo):
"""
https://vk.com/dev/photos.saveOwnerCoverPhoto
"""
response = session.fetch('photos.saveOwnerCoverPhoto', hash=hash, photo=photo)
return response | python | def _save_owner_cover_photo(session, hash, photo):
"""
https://vk.com/dev/photos.saveOwnerCoverPhoto
"""
response = session.fetch('photos.saveOwnerCoverPhoto', hash=hash, photo=photo)
return response | [
"def",
"_save_owner_cover_photo",
"(",
"session",
",",
"hash",
",",
"photo",
")",
":",
"response",
"=",
"session",
".",
"fetch",
"(",
"'photos.saveOwnerCoverPhoto'",
",",
"hash",
"=",
"hash",
",",
"photo",
"=",
"photo",
")",
"return",
"response"
] | https://vk.com/dev/photos.saveOwnerCoverPhoto | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"photos",
".",
"saveOwnerCoverPhoto"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/photos.py#L51-L56 |
sgaynetdinov/py-vkontakte | vk/photos.py | Photo._get_save_wall_photo | def _get_save_wall_photo(session, photo, server, hash, user_id=None, group_id=None):
"""
https://vk.com/dev/photos.saveWallPhoto
"""
if group_id < 0:
group_id = abs(group_id)
response = session.fetch("photos.saveWallPhoto", photo=photo, server=server, hash=hash, user... | python | def _get_save_wall_photo(session, photo, server, hash, user_id=None, group_id=None):
"""
https://vk.com/dev/photos.saveWallPhoto
"""
if group_id < 0:
group_id = abs(group_id)
response = session.fetch("photos.saveWallPhoto", photo=photo, server=server, hash=hash, user... | [
"def",
"_get_save_wall_photo",
"(",
"session",
",",
"photo",
",",
"server",
",",
"hash",
",",
"user_id",
"=",
"None",
",",
"group_id",
"=",
"None",
")",
":",
"if",
"group_id",
"<",
"0",
":",
"group_id",
"=",
"abs",
"(",
"group_id",
")",
"response",
"="... | https://vk.com/dev/photos.saveWallPhoto | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"photos",
".",
"saveWallPhoto"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/photos.py#L67-L75 |
sgaynetdinov/py-vkontakte | vk/photos.py | Photo._get_save_messages_photo | def _get_save_messages_photo(session, photo, server, hash):
"""
https://vk.com/dev/photos.saveMessagesPhoto
"""
response = session.fetch("photos.saveMessagesPhoto", photo=photo, server=server, hash=hash)[0]
return response['id'], response['owner_id'] | python | def _get_save_messages_photo(session, photo, server, hash):
"""
https://vk.com/dev/photos.saveMessagesPhoto
"""
response = session.fetch("photos.saveMessagesPhoto", photo=photo, server=server, hash=hash)[0]
return response['id'], response['owner_id'] | [
"def",
"_get_save_messages_photo",
"(",
"session",
",",
"photo",
",",
"server",
",",
"hash",
")",
":",
"response",
"=",
"session",
".",
"fetch",
"(",
"\"photos.saveMessagesPhoto\"",
",",
"photo",
"=",
"photo",
",",
"server",
"=",
"server",
",",
"hash",
"=",
... | https://vk.com/dev/photos.saveMessagesPhoto | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"photos",
".",
"saveMessagesPhoto"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/photos.py#L99-L104 |
sgaynetdinov/py-vkontakte | vk/users.py | User.get_city | def get_city(self):
"""
:return: City or None
"""
response = self._session.fetch("users.get", user_ids=self.id, fields="city")[0]
if response.get('city'):
return City.from_json(self._session, response.get('city')) | python | def get_city(self):
"""
:return: City or None
"""
response = self._session.fetch("users.get", user_ids=self.id, fields="city")[0]
if response.get('city'):
return City.from_json(self._session, response.get('city')) | [
"def",
"get_city",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_session",
".",
"fetch",
"(",
"\"users.get\"",
",",
"user_ids",
"=",
"self",
".",
"id",
",",
"fields",
"=",
"\"city\"",
")",
"[",
"0",
"]",
"if",
"response",
".",
"get",
"(",
... | :return: City or None | [
":",
"return",
":",
"City",
"or",
"None"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/users.py#L102-L108 |
sgaynetdinov/py-vkontakte | vk/users.py | User.get_country | def get_country(self):
"""
:return: Country or None
"""
response = self._session.fetch("users.get", user_ids=self.id, fields="country")[0]
if response.get('country'):
return Country.from_json(self._session, response.get('country')) | python | def get_country(self):
"""
:return: Country or None
"""
response = self._session.fetch("users.get", user_ids=self.id, fields="country")[0]
if response.get('country'):
return Country.from_json(self._session, response.get('country')) | [
"def",
"get_country",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_session",
".",
"fetch",
"(",
"\"users.get\"",
",",
"user_ids",
"=",
"self",
".",
"id",
",",
"fields",
"=",
"\"country\"",
")",
"[",
"0",
"]",
"if",
"response",
".",
"get",
"... | :return: Country or None | [
":",
"return",
":",
"Country",
"or",
"None"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/users.py#L130-L136 |
sgaynetdinov/py-vkontakte | vk/users.py | User.get_followers | def get_followers(self):
"""
https://vk.com/dev/users.getFollowers
"""
response = self._session.fetch_items("users.getFollowers", self.from_json, self._session, count=1000, user_id=self.id, fields=self.USER_FIELDS)
return response | python | def get_followers(self):
"""
https://vk.com/dev/users.getFollowers
"""
response = self._session.fetch_items("users.getFollowers", self.from_json, self._session, count=1000, user_id=self.id, fields=self.USER_FIELDS)
return response | [
"def",
"get_followers",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_session",
".",
"fetch_items",
"(",
"\"users.getFollowers\"",
",",
"self",
".",
"from_json",
",",
"self",
".",
"_session",
",",
"count",
"=",
"1000",
",",
"user_id",
"=",
"self",... | https://vk.com/dev/users.getFollowers | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"users",
".",
"getFollowers"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/users.py#L182-L187 |
sgaynetdinov/py-vkontakte | vk/users.py | User._get_user | def _get_user(session, slug_or_user_id):
"""
:param slug_or_user_id: str or int
:return: User
"""
user_json_items = session.fetch('users.get', user_ids=slug_or_user_id, fields=User.USER_FIELDS)
return User.from_json(session, user_json_items[0]) | python | def _get_user(session, slug_or_user_id):
"""
:param slug_or_user_id: str or int
:return: User
"""
user_json_items = session.fetch('users.get', user_ids=slug_or_user_id, fields=User.USER_FIELDS)
return User.from_json(session, user_json_items[0]) | [
"def",
"_get_user",
"(",
"session",
",",
"slug_or_user_id",
")",
":",
"user_json_items",
"=",
"session",
".",
"fetch",
"(",
"'users.get'",
",",
"user_ids",
"=",
"slug_or_user_id",
",",
"fields",
"=",
"User",
".",
"USER_FIELDS",
")",
"return",
"User",
".",
"f... | :param slug_or_user_id: str or int
:return: User | [
":",
"param",
"slug_or_user_id",
":",
"str",
"or",
"int",
":",
"return",
":",
"User"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/users.py#L275-L281 |
Spinmob/spinmob | egg/example_sweeper.py | get_data | def get_data():
"""
Currently pretends to talk to an instrument and get back the magnitud
and phase of the measurement.
"""
# pretend we're measuring a noisy resonance at zero
y = 1.0 / (1.0 + 1j*(n_x.get_value()-0.002)*1000) + _n.random.rand()*0.1
# and that it takes time to do so
_t.... | python | def get_data():
"""
Currently pretends to talk to an instrument and get back the magnitud
and phase of the measurement.
"""
# pretend we're measuring a noisy resonance at zero
y = 1.0 / (1.0 + 1j*(n_x.get_value()-0.002)*1000) + _n.random.rand()*0.1
# and that it takes time to do so
_t.... | [
"def",
"get_data",
"(",
")",
":",
"# pretend we're measuring a noisy resonance at zero",
"y",
"=",
"1.0",
"/",
"(",
"1.0",
"+",
"1j",
"*",
"(",
"n_x",
".",
"get_value",
"(",
")",
"-",
"0.002",
")",
"*",
"1000",
")",
"+",
"_n",
".",
"random",
".",
"rand... | Currently pretends to talk to an instrument and get back the magnitud
and phase of the measurement. | [
"Currently",
"pretends",
"to",
"talk",
"to",
"an",
"instrument",
"and",
"get",
"back",
"the",
"magnitud",
"and",
"phase",
"of",
"the",
"measurement",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/example_sweeper.py#L61-L74 |
Spinmob/spinmob | _settings.py | settings.List | def List(self):
"""
Lists the keys and values.
"""
print()
for key in list(self.keys()):
print(key,'=',self[key])
print() | python | def List(self):
"""
Lists the keys and values.
"""
print()
for key in list(self.keys()):
print(key,'=',self[key])
print() | [
"def",
"List",
"(",
"self",
")",
":",
"print",
"(",
")",
"for",
"key",
"in",
"list",
"(",
"self",
".",
"keys",
"(",
")",
")",
":",
"print",
"(",
"key",
",",
"'='",
",",
"self",
"[",
"key",
"]",
")",
"print",
"(",
")"
] | Lists the keys and values. | [
"Lists",
"the",
"keys",
"and",
"values",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_settings.py#L67-L74 |
Spinmob/spinmob | _settings.py | settings.Set | def Set(self, key, value):
"""
Sets the key-value pair and dumps to the preferences file.
"""
if not value == None: self.prefs[key] = value
else: self.prefs.pop(key)
self.Dump() | python | def Set(self, key, value):
"""
Sets the key-value pair and dumps to the preferences file.
"""
if not value == None: self.prefs[key] = value
else: self.prefs.pop(key)
self.Dump() | [
"def",
"Set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"not",
"value",
"==",
"None",
":",
"self",
".",
"prefs",
"[",
"key",
"]",
"=",
"value",
"else",
":",
"self",
".",
"prefs",
".",
"pop",
"(",
"key",
")",
"self",
".",
"Dump",
... | Sets the key-value pair and dumps to the preferences file. | [
"Sets",
"the",
"key",
"-",
"value",
"pair",
"and",
"dumps",
"to",
"the",
"preferences",
"file",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_settings.py#L85-L92 |
Spinmob/spinmob | _settings.py | settings.MakeDir | def MakeDir(self, path="temp"):
"""
Creates a directory of the specified path in the .spinmob directory.
"""
full_path = _os.path.join(self.path_home, path)
# only make it if it doesn't exist!
if not _os.path.exists(full_path): _os.makedirs(full_path) | python | def MakeDir(self, path="temp"):
"""
Creates a directory of the specified path in the .spinmob directory.
"""
full_path = _os.path.join(self.path_home, path)
# only make it if it doesn't exist!
if not _os.path.exists(full_path): _os.makedirs(full_path) | [
"def",
"MakeDir",
"(",
"self",
",",
"path",
"=",
"\"temp\"",
")",
":",
"full_path",
"=",
"_os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path_home",
",",
"path",
")",
"# only make it if it doesn't exist!",
"if",
"not",
"_os",
".",
"path",
".",
"exist... | Creates a directory of the specified path in the .spinmob directory. | [
"Creates",
"a",
"directory",
"of",
"the",
"specified",
"path",
"in",
"the",
".",
"spinmob",
"directory",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_settings.py#L106-L113 |
Spinmob/spinmob | _settings.py | settings.ListDir | def ListDir(self, path="temp"):
"""
Returns a list of files in the specified path (directory), or an
empty list if the directory doesn't exist.
"""
full_path = _os.path.join(self.path_home, path)
# only if the path exists!
if _os.path.exists(full_path) and _os.pa... | python | def ListDir(self, path="temp"):
"""
Returns a list of files in the specified path (directory), or an
empty list if the directory doesn't exist.
"""
full_path = _os.path.join(self.path_home, path)
# only if the path exists!
if _os.path.exists(full_path) and _os.pa... | [
"def",
"ListDir",
"(",
"self",
",",
"path",
"=",
"\"temp\"",
")",
":",
"full_path",
"=",
"_os",
".",
"path",
".",
"join",
"(",
"self",
".",
"path_home",
",",
"path",
")",
"# only if the path exists!",
"if",
"_os",
".",
"path",
".",
"exists",
"(",
"full... | Returns a list of files in the specified path (directory), or an
empty list if the directory doesn't exist. | [
"Returns",
"a",
"list",
"of",
"files",
"in",
"the",
"specified",
"path",
"(",
"directory",
")",
"or",
"an",
"empty",
"list",
"if",
"the",
"directory",
"doesn",
"t",
"exist",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_settings.py#L115-L126 |
sgaynetdinov/py-vkontakte | vk/fetch.py | Session._convert_list2str | def _convert_list2str(self, fields):
"""
:param fields: ('bdate', 'domain')
:return: 'bdate,domain'
"""
if isinstance(fields, tuple) or isinstance(fields, list):
return ','.join(fields)
return fields | python | def _convert_list2str(self, fields):
"""
:param fields: ('bdate', 'domain')
:return: 'bdate,domain'
"""
if isinstance(fields, tuple) or isinstance(fields, list):
return ','.join(fields)
return fields | [
"def",
"_convert_list2str",
"(",
"self",
",",
"fields",
")",
":",
"if",
"isinstance",
"(",
"fields",
",",
"tuple",
")",
"or",
"isinstance",
"(",
"fields",
",",
"list",
")",
":",
"return",
"','",
".",
"join",
"(",
"fields",
")",
"return",
"fields"
] | :param fields: ('bdate', 'domain')
:return: 'bdate,domain' | [
":",
"param",
"fields",
":",
"(",
"bdate",
"domain",
")",
":",
"return",
":",
"bdate",
"domain"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/fetch.py#L89-L96 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_start | def p_start(self, p):
'''start : header definition'''
p[0] = ast.Program(headers=p[1], definitions=p[2]) | python | def p_start(self, p):
'''start : header definition'''
p[0] = ast.Program(headers=p[1], definitions=p[2]) | [
"def",
"p_start",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Program",
"(",
"headers",
"=",
"p",
"[",
"1",
"]",
",",
"definitions",
"=",
"p",
"[",
"2",
"]",
")"
] | start : header definition | [
"start",
":",
"header",
"definition"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L49-L51 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_include | def p_include(self, p):
'''include : INCLUDE IDENTIFIER LITERAL
| INCLUDE LITERAL'''
if len(p) == 4:
p[0] = ast.Include(name=p[2], path=p[3], lineno=p.lineno(1))
else:
p[0] = ast.Include(name=None, path=p[2], lineno=p.lineno(1)) | python | def p_include(self, p):
'''include : INCLUDE IDENTIFIER LITERAL
| INCLUDE LITERAL'''
if len(p) == 4:
p[0] = ast.Include(name=p[2], path=p[3], lineno=p.lineno(1))
else:
p[0] = ast.Include(name=None, path=p[2], lineno=p.lineno(1)) | [
"def",
"p_include",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Include",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"path",
"=",
"p",
"[",
"3",
"]",
",",
"lineno",
... | include : INCLUDE IDENTIFIER LITERAL
| INCLUDE LITERAL | [
"include",
":",
"INCLUDE",
"IDENTIFIER",
"LITERAL",
"|",
"INCLUDE",
"LITERAL"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L68-L74 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_namespace | def p_namespace(self, p):
'''namespace : NAMESPACE namespace_scope IDENTIFIER'''
p[0] = ast.Namespace(scope=p[2], name=p[3], lineno=p.lineno(1)) | python | def p_namespace(self, p):
'''namespace : NAMESPACE namespace_scope IDENTIFIER'''
p[0] = ast.Namespace(scope=p[2], name=p[3], lineno=p.lineno(1)) | [
"def",
"p_namespace",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Namespace",
"(",
"scope",
"=",
"p",
"[",
"2",
"]",
",",
"name",
"=",
"p",
"[",
"3",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
"... | namespace : NAMESPACE namespace_scope IDENTIFIER | [
"namespace",
":",
"NAMESPACE",
"namespace_scope",
"IDENTIFIER"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L76-L78 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_const | def p_const(self, p):
'''const : CONST field_type IDENTIFIER '=' const_value
| CONST field_type IDENTIFIER '=' const_value sep'''
p[0] = ast.Const(
name=p[3],
value_type=p[2],
value=p[5],
lineno=p.lineno(3),
) | python | def p_const(self, p):
'''const : CONST field_type IDENTIFIER '=' const_value
| CONST field_type IDENTIFIER '=' const_value sep'''
p[0] = ast.Const(
name=p[3],
value_type=p[2],
value=p[5],
lineno=p.lineno(3),
) | [
"def",
"p_const",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Const",
"(",
"name",
"=",
"p",
"[",
"3",
"]",
",",
"value_type",
"=",
"p",
"[",
"2",
"]",
",",
"value",
"=",
"p",
"[",
"5",
"]",
",",
"lineno",
"=",
... | const : CONST field_type IDENTIFIER '=' const_value
| CONST field_type IDENTIFIER '=' const_value sep | [
"const",
":",
"CONST",
"field_type",
"IDENTIFIER",
"=",
"const_value",
"|",
"CONST",
"field_type",
"IDENTIFIER",
"=",
"const_value",
"sep"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L111-L119 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_const_value_primitive | def p_const_value_primitive(self, p):
'''const_value_primitive : INTCONSTANT
| DUBCONSTANT
| LITERAL
| const_bool'''
p[0] = ast.ConstPrimitiveValue(p[1], lineno=p.lineno(1)) | python | def p_const_value_primitive(self, p):
'''const_value_primitive : INTCONSTANT
| DUBCONSTANT
| LITERAL
| const_bool'''
p[0] = ast.ConstPrimitiveValue(p[1], lineno=p.lineno(1)) | [
"def",
"p_const_value_primitive",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"ConstPrimitiveValue",
"(",
"p",
"[",
"1",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
")"
] | const_value_primitive : INTCONSTANT
| DUBCONSTANT
| LITERAL
| const_bool | [
"const_value_primitive",
":",
"INTCONSTANT",
"|",
"DUBCONSTANT",
"|",
"LITERAL",
"|",
"const_bool"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L132-L137 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_const_list | def p_const_list(self, p):
'''const_list : '[' const_list_seq ']' '''
p[0] = ast.ConstList(list(p[2]), p.lineno(1)) | python | def p_const_list(self, p):
'''const_list : '[' const_list_seq ']' '''
p[0] = ast.ConstList(list(p[2]), p.lineno(1)) | [
"def",
"p_const_list",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"ConstList",
"(",
"list",
"(",
"p",
"[",
"2",
"]",
")",
",",
"p",
".",
"lineno",
"(",
"1",
")",
")"
] | const_list : '[' const_list_seq ']' | [
"const_list",
":",
"[",
"const_list_seq",
"]"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L139-L141 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_const_map | def p_const_map(self, p):
'''const_map : '{' const_map_seq '}' '''
p[0] = ast.ConstMap(dict(p[2]), p.lineno(1)) | python | def p_const_map(self, p):
'''const_map : '{' const_map_seq '}' '''
p[0] = ast.ConstMap(dict(p[2]), p.lineno(1)) | [
"def",
"p_const_map",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"ConstMap",
"(",
"dict",
"(",
"p",
"[",
"2",
"]",
")",
",",
"p",
".",
"lineno",
"(",
"1",
")",
")"
] | const_map : '{' const_map_seq '}' | [
"const_map",
":",
"{",
"const_map_seq",
"}"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L149-L151 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_const_ref | def p_const_ref(self, p):
'''const_ref : IDENTIFIER'''
p[0] = ast.ConstReference(p[1], lineno=p.lineno(1)) | python | def p_const_ref(self, p):
'''const_ref : IDENTIFIER'''
p[0] = ast.ConstReference(p[1], lineno=p.lineno(1)) | [
"def",
"p_const_ref",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"ConstReference",
"(",
"p",
"[",
"1",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
")"
] | const_ref : IDENTIFIER | [
"const_ref",
":",
"IDENTIFIER"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L163-L165 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_typedef | def p_typedef(self, p):
'''typedef : TYPEDEF field_type IDENTIFIER annotations'''
p[0] = ast.Typedef(
name=p[3], target_type=p[2], annotations=p[4], lineno=p.lineno(3)
) | python | def p_typedef(self, p):
'''typedef : TYPEDEF field_type IDENTIFIER annotations'''
p[0] = ast.Typedef(
name=p[3], target_type=p[2], annotations=p[4], lineno=p.lineno(3)
) | [
"def",
"p_typedef",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Typedef",
"(",
"name",
"=",
"p",
"[",
"3",
"]",
",",
"target_type",
"=",
"p",
"[",
"2",
"]",
",",
"annotations",
"=",
"p",
"[",
"4",
"]",
",",
"linen... | typedef : TYPEDEF field_type IDENTIFIER annotations | [
"typedef",
":",
"TYPEDEF",
"field_type",
"IDENTIFIER",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L176-L180 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_enum | def p_enum(self, p): # noqa
'''enum : ENUM IDENTIFIER '{' enum_seq '}' annotations'''
p[0] = ast.Enum(
name=p[2], items=p[4], annotations=p[6], lineno=p.lineno(2)
) | python | def p_enum(self, p): # noqa
'''enum : ENUM IDENTIFIER '{' enum_seq '}' annotations'''
p[0] = ast.Enum(
name=p[2], items=p[4], annotations=p[6], lineno=p.lineno(2)
) | [
"def",
"p_enum",
"(",
"self",
",",
"p",
")",
":",
"# noqa",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Enum",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"items",
"=",
"p",
"[",
"4",
"]",
",",
"annotations",
"=",
"p",
"[",
"6",
"]",
",",
"linen... | enum : ENUM IDENTIFIER '{' enum_seq '}' annotations | [
"enum",
":",
"ENUM",
"IDENTIFIER",
"{",
"enum_seq",
"}",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L182-L186 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_enum_item | def p_enum_item(self, p):
'''enum_item : IDENTIFIER '=' INTCONSTANT annotations
| IDENTIFIER annotations'''
if len(p) == 5:
p[0] = ast.EnumItem(
name=p[1], value=p[3], annotations=p[4], lineno=p.lineno(1)
)
else:
p[0] = ast... | python | def p_enum_item(self, p):
'''enum_item : IDENTIFIER '=' INTCONSTANT annotations
| IDENTIFIER annotations'''
if len(p) == 5:
p[0] = ast.EnumItem(
name=p[1], value=p[3], annotations=p[4], lineno=p.lineno(1)
)
else:
p[0] = ast... | [
"def",
"p_enum_item",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"5",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"EnumItem",
"(",
"name",
"=",
"p",
"[",
"1",
"]",
",",
"value",
"=",
"p",
"[",
"3",
"]",
",",
"annotat... | enum_item : IDENTIFIER '=' INTCONSTANT annotations
| IDENTIFIER annotations | [
"enum_item",
":",
"IDENTIFIER",
"=",
"INTCONSTANT",
"annotations",
"|",
"IDENTIFIER",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L194-L204 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_struct | def p_struct(self, p):
'''struct : STRUCT IDENTIFIER '{' field_seq '}' annotations'''
p[0] = ast.Struct(
name=p[2], fields=p[4], annotations=p[6], lineno=p.lineno(2)
) | python | def p_struct(self, p):
'''struct : STRUCT IDENTIFIER '{' field_seq '}' annotations'''
p[0] = ast.Struct(
name=p[2], fields=p[4], annotations=p[6], lineno=p.lineno(2)
) | [
"def",
"p_struct",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Struct",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"fields",
"=",
"p",
"[",
"4",
"]",
",",
"annotations",
"=",
"p",
"[",
"6",
"]",
",",
"lineno",
"... | struct : STRUCT IDENTIFIER '{' field_seq '}' annotations | [
"struct",
":",
"STRUCT",
"IDENTIFIER",
"{",
"field_seq",
"}",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L206-L210 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_union | def p_union(self, p):
'''union : UNION IDENTIFIER '{' field_seq '}' annotations'''
p[0] = ast.Union(
name=p[2], fields=p[4], annotations=p[6], lineno=p.lineno(2)
) | python | def p_union(self, p):
'''union : UNION IDENTIFIER '{' field_seq '}' annotations'''
p[0] = ast.Union(
name=p[2], fields=p[4], annotations=p[6], lineno=p.lineno(2)
) | [
"def",
"p_union",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Union",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"fields",
"=",
"p",
"[",
"4",
"]",
",",
"annotations",
"=",
"p",
"[",
"6",
"]",
",",
"lineno",
"="... | union : UNION IDENTIFIER '{' field_seq '}' annotations | [
"union",
":",
"UNION",
"IDENTIFIER",
"{",
"field_seq",
"}",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L212-L216 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_exception | def p_exception(self, p):
'''exception : EXCEPTION IDENTIFIER '{' field_seq '}' annotations'''
p[0] = ast.Exc(
name=p[2], fields=p[4], annotations=p[6], lineno=p.lineno(2)
) | python | def p_exception(self, p):
'''exception : EXCEPTION IDENTIFIER '{' field_seq '}' annotations'''
p[0] = ast.Exc(
name=p[2], fields=p[4], annotations=p[6], lineno=p.lineno(2)
) | [
"def",
"p_exception",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Exc",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"fields",
"=",
"p",
"[",
"4",
"]",
",",
"annotations",
"=",
"p",
"[",
"6",
"]",
",",
"lineno",
"... | exception : EXCEPTION IDENTIFIER '{' field_seq '}' annotations | [
"exception",
":",
"EXCEPTION",
"IDENTIFIER",
"{",
"field_seq",
"}",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L218-L222 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_service | def p_service(self, p):
'''service : SERVICE IDENTIFIER '{' function_seq '}' annotations
| SERVICE IDENTIFIER EXTENDS IDENTIFIER \
'{' function_seq '}' annotations
'''
if len(p) == 7:
p[0] = ast.Service(
name=p[2],
... | python | def p_service(self, p):
'''service : SERVICE IDENTIFIER '{' function_seq '}' annotations
| SERVICE IDENTIFIER EXTENDS IDENTIFIER \
'{' function_seq '}' annotations
'''
if len(p) == 7:
p[0] = ast.Service(
name=p[2],
... | [
"def",
"p_service",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"7",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Service",
"(",
"name",
"=",
"p",
"[",
"2",
"]",
",",
"functions",
"=",
"p",
"[",
"4",
"]",
",",
"parent... | service : SERVICE IDENTIFIER '{' function_seq '}' annotations
| SERVICE IDENTIFIER EXTENDS IDENTIFIER \
'{' function_seq '}' annotations | [
"service",
":",
"SERVICE",
"IDENTIFIER",
"{",
"function_seq",
"}",
"annotations",
"|",
"SERVICE",
"IDENTIFIER",
"EXTENDS",
"IDENTIFIER",
"\\",
"{",
"function_seq",
"}",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L224-L245 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_function | def p_function(self, p):
'''function : oneway function_type IDENTIFIER '(' field_seq ')' \
throws annotations '''
p[0] = ast.Function(
name=p[3],
parameters=p[5],
return_type=p[2],
exceptions=p[7],
oneway=p[1],
... | python | def p_function(self, p):
'''function : oneway function_type IDENTIFIER '(' field_seq ')' \
throws annotations '''
p[0] = ast.Function(
name=p[3],
parameters=p[5],
return_type=p[2],
exceptions=p[7],
oneway=p[1],
... | [
"def",
"p_function",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Function",
"(",
"name",
"=",
"p",
"[",
"3",
"]",
",",
"parameters",
"=",
"p",
"[",
"5",
"]",
",",
"return_type",
"=",
"p",
"[",
"2",
"]",
",",
"exce... | function : oneway function_type IDENTIFIER '(' field_seq ')' \
throws annotations | [
"function",
":",
"oneway",
"function_type",
"IDENTIFIER",
"(",
"field_seq",
")",
"\\",
"throws",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L252-L263 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_field | def p_field(self, p):
'''field : field_id field_req field_type IDENTIFIER annotations
| field_id field_req field_type IDENTIFIER '=' const_value \
annotations'''
if len(p) == 8:
default = p[6]
annotations = p[7]
else:
defau... | python | def p_field(self, p):
'''field : field_id field_req field_type IDENTIFIER annotations
| field_id field_req field_type IDENTIFIER '=' const_value \
annotations'''
if len(p) == 8:
default = p[6]
annotations = p[7]
else:
defau... | [
"def",
"p_field",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"8",
":",
"default",
"=",
"p",
"[",
"6",
"]",
"annotations",
"=",
"p",
"[",
"7",
"]",
"else",
":",
"default",
"=",
"None",
"annotations",
"=",
"p",
"[",
"5",... | field : field_id field_req field_type IDENTIFIER annotations
| field_id field_req field_type IDENTIFIER '=' const_value \
annotations | [
"field",
":",
"field_id",
"field_req",
"field_type",
"IDENTIFIER",
"annotations",
"|",
"field_id",
"field_req",
"field_type",
"IDENTIFIER",
"=",
"const_value",
"\\",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L293-L313 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_field_id | def p_field_id(self, p):
'''field_id : INTCONSTANT ':'
| '''
if len(p) == 3:
if p[1] == 0:
# Prevent users from ever using field ID 0. It's reserved for
# internal use only.
raise ThriftParserError(
'Lin... | python | def p_field_id(self, p):
'''field_id : INTCONSTANT ':'
| '''
if len(p) == 3:
if p[1] == 0:
# Prevent users from ever using field ID 0. It's reserved for
# internal use only.
raise ThriftParserError(
'Lin... | [
"def",
"p_field_id",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"3",
":",
"if",
"p",
"[",
"1",
"]",
"==",
"0",
":",
"# Prevent users from ever using field ID 0. It's reserved for",
"# internal use only.",
"raise",
"ThriftParserError",
"... | field_id : INTCONSTANT ':'
| | [
"field_id",
":",
"INTCONSTANT",
":",
"|"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L315-L330 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_ref_type | def p_ref_type(self, p):
'''ref_type : IDENTIFIER'''
p[0] = ast.DefinedType(p[1], lineno=p.lineno(1)) | python | def p_ref_type(self, p):
'''ref_type : IDENTIFIER'''
p[0] = ast.DefinedType(p[1], lineno=p.lineno(1)) | [
"def",
"p_ref_type",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"DefinedType",
"(",
"p",
"[",
"1",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno",
"(",
"1",
")",
")"
] | ref_type : IDENTIFIER | [
"ref_type",
":",
"IDENTIFIER"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L346-L348 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_base_type | def p_base_type(self, p): # noqa
'''base_type : BOOL annotations
| BYTE annotations
| I8 annotations
| I16 annotations
| I32 annotations
| I64 annotations
| DOUBLE annotations
... | python | def p_base_type(self, p): # noqa
'''base_type : BOOL annotations
| BYTE annotations
| I8 annotations
| I16 annotations
| I32 annotations
| I64 annotations
| DOUBLE annotations
... | [
"def",
"p_base_type",
"(",
"self",
",",
"p",
")",
":",
"# noqa",
"name",
"=",
"p",
"[",
"1",
"]",
"if",
"name",
"==",
"'i8'",
":",
"name",
"=",
"'byte'",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"PrimitiveType",
"(",
"name",
",",
"p",
"[",
"2",
"... | base_type : BOOL annotations
| BYTE annotations
| I8 annotations
| I16 annotations
| I32 annotations
| I64 annotations
| DOUBLE annotations
| STRING annotations
... | [
"base_type",
":",
"BOOL",
"annotations",
"|",
"BYTE",
"annotations",
"|",
"I8",
"annotations",
"|",
"I16",
"annotations",
"|",
"I32",
"annotations",
"|",
"I64",
"annotations",
"|",
"DOUBLE",
"annotations",
"|",
"STRING",
"annotations",
"|",
"BINARY",
"annotation... | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L350-L365 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_map_type | def p_map_type(self, p):
'''map_type : MAP '<' field_type ',' field_type '>' annotations'''
p[0] = ast.MapType(key_type=p[3], value_type=p[5], annotations=p[7]) | python | def p_map_type(self, p):
'''map_type : MAP '<' field_type ',' field_type '>' annotations'''
p[0] = ast.MapType(key_type=p[3], value_type=p[5], annotations=p[7]) | [
"def",
"p_map_type",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"MapType",
"(",
"key_type",
"=",
"p",
"[",
"3",
"]",
",",
"value_type",
"=",
"p",
"[",
"5",
"]",
",",
"annotations",
"=",
"p",
"[",
"7",
"]",
")"
] | map_type : MAP '<' field_type ',' field_type '>' annotations | [
"map_type",
":",
"MAP",
"<",
"field_type",
"field_type",
">",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L373-L375 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_list_type | def p_list_type(self, p):
'''list_type : LIST '<' field_type '>' annotations'''
p[0] = ast.ListType(value_type=p[3], annotations=p[5]) | python | def p_list_type(self, p):
'''list_type : LIST '<' field_type '>' annotations'''
p[0] = ast.ListType(value_type=p[3], annotations=p[5]) | [
"def",
"p_list_type",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"ListType",
"(",
"value_type",
"=",
"p",
"[",
"3",
"]",
",",
"annotations",
"=",
"p",
"[",
"5",
"]",
")"
] | list_type : LIST '<' field_type '>' annotations | [
"list_type",
":",
"LIST",
"<",
"field_type",
">",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L377-L379 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_set_type | def p_set_type(self, p):
'''set_type : SET '<' field_type '>' annotations'''
p[0] = ast.SetType(value_type=p[3], annotations=p[5]) | python | def p_set_type(self, p):
'''set_type : SET '<' field_type '>' annotations'''
p[0] = ast.SetType(value_type=p[3], annotations=p[5]) | [
"def",
"p_set_type",
"(",
"self",
",",
"p",
")",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"SetType",
"(",
"value_type",
"=",
"p",
"[",
"3",
"]",
",",
"annotations",
"=",
"p",
"[",
"5",
"]",
")"
] | set_type : SET '<' field_type '>' annotations | [
"set_type",
":",
"SET",
"<",
"field_type",
">",
"annotations"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L381-L383 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec.p_annotation | def p_annotation(self, p):
'''annotation : IDENTIFIER '=' LITERAL
| IDENTIFIER'''
if len(p) == 4:
p[0] = ast.Annotation(p[1], p[3], lineno=p.lineno(1))
else:
p[0] = ast.Annotation(p[1], True, lineno=p.lineno(1)) | python | def p_annotation(self, p):
'''annotation : IDENTIFIER '=' LITERAL
| IDENTIFIER'''
if len(p) == 4:
p[0] = ast.Annotation(p[1], p[3], lineno=p.lineno(1))
else:
p[0] = ast.Annotation(p[1], True, lineno=p.lineno(1)) | [
"def",
"p_annotation",
"(",
"self",
",",
"p",
")",
":",
"if",
"len",
"(",
"p",
")",
"==",
"4",
":",
"p",
"[",
"0",
"]",
"=",
"ast",
".",
"Annotation",
"(",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
",",
"lineno",
"=",
"p",
".",
"lineno... | annotation : IDENTIFIER '=' LITERAL
| IDENTIFIER | [
"annotation",
":",
"IDENTIFIER",
"=",
"LITERAL",
"|",
"IDENTIFIER"
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L404-L411 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | ParserSpec._parse_seq | def _parse_seq(self, p):
"""Helper to parse sequence rules.
Sequence rules are in the form::
foo : foo_item sep foo
| foo_item foo
|
This function builds a deque of the items in-order.
If the number of tokens doesn't match, an exception is ... | python | def _parse_seq(self, p):
"""Helper to parse sequence rules.
Sequence rules are in the form::
foo : foo_item sep foo
| foo_item foo
|
This function builds a deque of the items in-order.
If the number of tokens doesn't match, an exception is ... | [
"def",
"_parse_seq",
"(",
"self",
",",
"p",
")",
":",
"# This basically says:",
"#",
"# - When you reach the end of the list, construct and return an empty",
"# deque.",
"# - Otherwise, prepend to start of what you got from the parser.",
"#",
"# So this ends up constructing an in-order... | Helper to parse sequence rules.
Sequence rules are in the form::
foo : foo_item sep foo
| foo_item foo
|
This function builds a deque of the items in-order.
If the number of tokens doesn't match, an exception is raised. | [
"Helper",
"to",
"parse",
"sequence",
"rules",
"."
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L413-L445 |
thriftrw/thriftrw-python | thriftrw/idl/parser.py | Parser.parse | def parse(self, input, **kwargs):
"""Parse the given input.
:param input:
String containing the text to be parsed.
:raises thriftrw.errors.ThriftParserError:
For parsing errors.
"""
return self._parser.parse(input, lexer=self._lexer, **kwargs) | python | def parse(self, input, **kwargs):
"""Parse the given input.
:param input:
String containing the text to be parsed.
:raises thriftrw.errors.ThriftParserError:
For parsing errors.
"""
return self._parser.parse(input, lexer=self._lexer, **kwargs) | [
"def",
"parse",
"(",
"self",
",",
"input",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_parser",
".",
"parse",
"(",
"input",
",",
"lexer",
"=",
"self",
".",
"_lexer",
",",
"*",
"*",
"kwargs",
")"
] | Parse the given input.
:param input:
String containing the text to be parsed.
:raises thriftrw.errors.ThriftParserError:
For parsing errors. | [
"Parse",
"the",
"given",
"input",
"."
] | train | https://github.com/thriftrw/thriftrw-python/blob/4f2f71acd7a0ac716c9ea5cdcea2162aa561304a/thriftrw/idl/parser.py#L460-L468 |
sgaynetdinov/py-vkontakte | vk/comment.py | Comment._get_comments | def _get_comments(session, group_or_user_id, wall_id):
"""
https://vk.com/dev/wall.getComments
"""
return session.fetch_items("wall.getComments", Comment.from_json, count=100, owner_id=group_or_user_id, post_id=wall_id, need_likes=1) | python | def _get_comments(session, group_or_user_id, wall_id):
"""
https://vk.com/dev/wall.getComments
"""
return session.fetch_items("wall.getComments", Comment.from_json, count=100, owner_id=group_or_user_id, post_id=wall_id, need_likes=1) | [
"def",
"_get_comments",
"(",
"session",
",",
"group_or_user_id",
",",
"wall_id",
")",
":",
"return",
"session",
".",
"fetch_items",
"(",
"\"wall.getComments\"",
",",
"Comment",
".",
"from_json",
",",
"count",
"=",
"100",
",",
"owner_id",
"=",
"group_or_user_id",... | https://vk.com/dev/wall.getComments | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"wall",
".",
"getComments"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/comment.py#L27-L31 |
sgaynetdinov/py-vkontakte | vk/comment.py | Comment._get_comments_count | def _get_comments_count(session, group_or_user_id, wall_id):
"""
https://vk.com/dev/wall.getComments
"""
response = session.fetch("wall.getComments", count=100, owner_id=group_or_user_id, post_id=wall_id)
return response.get('count') | python | def _get_comments_count(session, group_or_user_id, wall_id):
"""
https://vk.com/dev/wall.getComments
"""
response = session.fetch("wall.getComments", count=100, owner_id=group_or_user_id, post_id=wall_id)
return response.get('count') | [
"def",
"_get_comments_count",
"(",
"session",
",",
"group_or_user_id",
",",
"wall_id",
")",
":",
"response",
"=",
"session",
".",
"fetch",
"(",
"\"wall.getComments\"",
",",
"count",
"=",
"100",
",",
"owner_id",
"=",
"group_or_user_id",
",",
"post_id",
"=",
"wa... | https://vk.com/dev/wall.getComments | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"wall",
".",
"getComments"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/comment.py#L34-L39 |
sgaynetdinov/py-vkontakte | vk/wall.py | Wall.get_likes | def get_likes(self):
"""
https://vk.com/dev/likes.getList
"""
from .users import User
return self._session.fetch_items('likes.getList', User._get_user, count=100, type='post', owner_id=self.from_id, item_id=self.id) | python | def get_likes(self):
"""
https://vk.com/dev/likes.getList
"""
from .users import User
return self._session.fetch_items('likes.getList', User._get_user, count=100, type='post', owner_id=self.from_id, item_id=self.id) | [
"def",
"get_likes",
"(",
"self",
")",
":",
"from",
".",
"users",
"import",
"User",
"return",
"self",
".",
"_session",
".",
"fetch_items",
"(",
"'likes.getList'",
",",
"User",
".",
"_get_user",
",",
"count",
"=",
"100",
",",
"type",
"=",
"'post'",
",",
... | https://vk.com/dev/likes.getList | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"likes",
".",
"getList"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/wall.py#L43-L48 |
sgaynetdinov/py-vkontakte | vk/wall.py | Wall.get_likes_count | def get_likes_count(self):
"""
https://vk.com/dev/likes.getList
"""
response = self._session.fetch('likes.getList', count=1, type='post', owner_id=self.from_id, item_id=self.id)
likes_count = response.get('count')
return likes_count | python | def get_likes_count(self):
"""
https://vk.com/dev/likes.getList
"""
response = self._session.fetch('likes.getList', count=1, type='post', owner_id=self.from_id, item_id=self.id)
likes_count = response.get('count')
return likes_count | [
"def",
"get_likes_count",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_session",
".",
"fetch",
"(",
"'likes.getList'",
",",
"count",
"=",
"1",
",",
"type",
"=",
"'post'",
",",
"owner_id",
"=",
"self",
".",
"from_id",
",",
"item_id",
"=",
"sel... | https://vk.com/dev/likes.getList | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"likes",
".",
"getList"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/wall.py#L50-L56 |
sgaynetdinov/py-vkontakte | vk/wall.py | Wall.get_reposts | def get_reposts(self):
"""
https://vk.com/dev/wall.getReposts
"""
return self._session.fetch_items('wall.getReposts', self.from_json, count=1000, owner_id=self.from_id, post_id=self.id) | python | def get_reposts(self):
"""
https://vk.com/dev/wall.getReposts
"""
return self._session.fetch_items('wall.getReposts', self.from_json, count=1000, owner_id=self.from_id, post_id=self.id) | [
"def",
"get_reposts",
"(",
"self",
")",
":",
"return",
"self",
".",
"_session",
".",
"fetch_items",
"(",
"'wall.getReposts'",
",",
"self",
".",
"from_json",
",",
"count",
"=",
"1000",
",",
"owner_id",
"=",
"self",
".",
"from_id",
",",
"post_id",
"=",
"se... | https://vk.com/dev/wall.getReposts | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"wall",
".",
"getReposts"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/wall.py#L58-L62 |
sgaynetdinov/py-vkontakte | vk/wall.py | Wall._wall_post | def _wall_post(session, owner_id, message=None, attachments=None, from_group=True):
"""
https://vk.com/dev/wall.post
attachments: "photo100172_166443618,photo-1_265827614"
"""
response = session.fetch("wall.post", owner_id=owner_id, message=message, attachments=attachments, from_... | python | def _wall_post(session, owner_id, message=None, attachments=None, from_group=True):
"""
https://vk.com/dev/wall.post
attachments: "photo100172_166443618,photo-1_265827614"
"""
response = session.fetch("wall.post", owner_id=owner_id, message=message, attachments=attachments, from_... | [
"def",
"_wall_post",
"(",
"session",
",",
"owner_id",
",",
"message",
"=",
"None",
",",
"attachments",
"=",
"None",
",",
"from_group",
"=",
"True",
")",
":",
"response",
"=",
"session",
".",
"fetch",
"(",
"\"wall.post\"",
",",
"owner_id",
"=",
"owner_id",
... | https://vk.com/dev/wall.post
attachments: "photo100172_166443618,photo-1_265827614" | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"wall",
".",
"post",
"attachments",
":",
"photo100172_166443618",
"photo",
"-",
"1_265827614"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/wall.py#L107-L113 |
sgaynetdinov/py-vkontakte | vk/friends.py | Friends._get_friends_count | def _get_friends_count(session, user_id):
"""
https://vk.com/dev/friends.get
"""
response = session.fetch('friends.get', user_id=user_id, count=1)
return response["count"] | python | def _get_friends_count(session, user_id):
"""
https://vk.com/dev/friends.get
"""
response = session.fetch('friends.get', user_id=user_id, count=1)
return response["count"] | [
"def",
"_get_friends_count",
"(",
"session",
",",
"user_id",
")",
":",
"response",
"=",
"session",
".",
"fetch",
"(",
"'friends.get'",
",",
"user_id",
"=",
"user_id",
",",
"count",
"=",
"1",
")",
"return",
"response",
"[",
"\"count\"",
"]"
] | https://vk.com/dev/friends.get | [
"https",
":",
"//",
"vk",
".",
"com",
"/",
"dev",
"/",
"friends",
".",
"get"
] | train | https://github.com/sgaynetdinov/py-vkontakte/blob/c09654f89008b5847418bb66f1f9c408cd7aa128/vk/friends.py#L11-L16 |
Spinmob/spinmob | egg/example_other_widgets.py | acquire_fake_data | def acquire_fake_data(number_of_points=1000):
"""
This function generates some fake data and returns two channels of data
in the form
time_array, [channel1, channel2]
"""
# time array
t = _n.linspace(0,10,number_of_points)
return(t, [_n.cos(t)*(1.0+0.2*_n.random.random(number_of_points... | python | def acquire_fake_data(number_of_points=1000):
"""
This function generates some fake data and returns two channels of data
in the form
time_array, [channel1, channel2]
"""
# time array
t = _n.linspace(0,10,number_of_points)
return(t, [_n.cos(t)*(1.0+0.2*_n.random.random(number_of_points... | [
"def",
"acquire_fake_data",
"(",
"number_of_points",
"=",
"1000",
")",
":",
"# time array",
"t",
"=",
"_n",
".",
"linspace",
"(",
"0",
",",
"10",
",",
"number_of_points",
")",
"return",
"(",
"t",
",",
"[",
"_n",
".",
"cos",
"(",
"t",
")",
"*",
"(",
... | This function generates some fake data and returns two channels of data
in the form
time_array, [channel1, channel2] | [
"This",
"function",
"generates",
"some",
"fake",
"data",
"and",
"returns",
"two",
"channels",
"of",
"data",
"in",
"the",
"form"
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/egg/example_other_widgets.py#L90-L101 |
Spinmob/spinmob | _data.py | load | def load(path=None, first_data_line='auto', filters='*.*', text='Select a file, FACEHEAD.', default_directory='default_directory', quiet=True, header_only=False, transpose=False, **kwargs):
"""
Loads a data file into the databox data class. Returns the data object.
Most keyword arguments are sent to databo... | python | def load(path=None, first_data_line='auto', filters='*.*', text='Select a file, FACEHEAD.', default_directory='default_directory', quiet=True, header_only=False, transpose=False, **kwargs):
"""
Loads a data file into the databox data class. Returns the data object.
Most keyword arguments are sent to databo... | [
"def",
"load",
"(",
"path",
"=",
"None",
",",
"first_data_line",
"=",
"'auto'",
",",
"filters",
"=",
"'*.*'",
",",
"text",
"=",
"'Select a file, FACEHEAD.'",
",",
"default_directory",
"=",
"'default_directory'",
",",
"quiet",
"=",
"True",
",",
"header_only",
"... | Loads a data file into the databox data class. Returns the data object.
Most keyword arguments are sent to databox.load() so check there
for documentation.(if their function isn't obvious).
Parameters
----------
path=None
Supply a path to a data file; None means use a dialog.
first_dat... | [
"Loads",
"a",
"data",
"file",
"into",
"the",
"databox",
"data",
"class",
".",
"Returns",
"the",
"data",
"object",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L3013-L3051 |
Spinmob/spinmob | _data.py | load_multiple | def load_multiple(paths=None, first_data_line="auto", filters="*.*", text="Select some files, FACEHEAD.", default_directory="default_directory", quiet=True, header_only=False, transpose=False, **kwargs):
"""
Loads a list of data files into a list of databox data objects.
Returns said list.
Paramete... | python | def load_multiple(paths=None, first_data_line="auto", filters="*.*", text="Select some files, FACEHEAD.", default_directory="default_directory", quiet=True, header_only=False, transpose=False, **kwargs):
"""
Loads a list of data files into a list of databox data objects.
Returns said list.
Paramete... | [
"def",
"load_multiple",
"(",
"paths",
"=",
"None",
",",
"first_data_line",
"=",
"\"auto\"",
",",
"filters",
"=",
"\"*.*\"",
",",
"text",
"=",
"\"Select some files, FACEHEAD.\"",
",",
"default_directory",
"=",
"\"default_directory\"",
",",
"quiet",
"=",
"True",
","... | Loads a list of data files into a list of databox data objects.
Returns said list.
Parameters
----------
path=None
Supply a path to a data file; None means pop up a dialog.
first_data_line="auto"
Specify the index of the first data line, or have it figure this out
automa... | [
"Loads",
"a",
"list",
"of",
"data",
"files",
"into",
"a",
"list",
"of",
"databox",
"data",
"objects",
".",
"Returns",
"said",
"list",
".",
"Parameters",
"----------",
"path",
"=",
"None",
"Supply",
"a",
"path",
"to",
"a",
"data",
"file",
";",
"None",
"... | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L3053-L3089 |
Spinmob/spinmob | _data.py | databox.more_info | def more_info(self):
"""
Prints out more information about the databox.
"""
print("\nDatabox Instance", self.path)
print("\nHeader")
for h in self.hkeys: print(" "+h+":", self.h(h))
s = "\nColumns ("+str(len(self.ckeys))+"): "
for c in self.ckeys: s = s+c... | python | def more_info(self):
"""
Prints out more information about the databox.
"""
print("\nDatabox Instance", self.path)
print("\nHeader")
for h in self.hkeys: print(" "+h+":", self.h(h))
s = "\nColumns ("+str(len(self.ckeys))+"): "
for c in self.ckeys: s = s+c... | [
"def",
"more_info",
"(",
"self",
")",
":",
"print",
"(",
"\"\\nDatabox Instance\"",
",",
"self",
".",
"path",
")",
"print",
"(",
"\"\\nHeader\"",
")",
"for",
"h",
"in",
"self",
".",
"hkeys",
":",
"print",
"(",
"\" \"",
"+",
"h",
"+",
"\":\"",
",",
"... | Prints out more information about the databox. | [
"Prints",
"out",
"more",
"information",
"about",
"the",
"databox",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L101-L110 |
Spinmob/spinmob | _data.py | databox._globals | def _globals(self):
"""
Returns the globals needed for eval() statements.
"""
# start with numpy
globbies = dict(_n.__dict__)
globbies.update(_special.__dict__)
# update with required stuff
globbies.update({'h':self.h, 'c':self.c, 'd':self, 'self':self})... | python | def _globals(self):
"""
Returns the globals needed for eval() statements.
"""
# start with numpy
globbies = dict(_n.__dict__)
globbies.update(_special.__dict__)
# update with required stuff
globbies.update({'h':self.h, 'c':self.c, 'd':self, 'self':self})... | [
"def",
"_globals",
"(",
"self",
")",
":",
"# start with numpy",
"globbies",
"=",
"dict",
"(",
"_n",
".",
"__dict__",
")",
"globbies",
".",
"update",
"(",
"_special",
".",
"__dict__",
")",
"# update with required stuff",
"globbies",
".",
"update",
"(",
"{",
"... | Returns the globals needed for eval() statements. | [
"Returns",
"the",
"globals",
"needed",
"for",
"eval",
"()",
"statements",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L113-L128 |
Spinmob/spinmob | _data.py | databox.load_file | def load_file(self, path=None, first_data_line='auto', filters='*.*', text='Select a file, FACEPANTS.', default_directory=None, header_only=False, quiet=False):
"""
This will clear the databox, load a file, storing the header info in
self.headers, and the data in self.columns
If first_... | python | def load_file(self, path=None, first_data_line='auto', filters='*.*', text='Select a file, FACEPANTS.', default_directory=None, header_only=False, quiet=False):
"""
This will clear the databox, load a file, storing the header info in
self.headers, and the data in self.columns
If first_... | [
"def",
"load_file",
"(",
"self",
",",
"path",
"=",
"None",
",",
"first_data_line",
"=",
"'auto'",
",",
"filters",
"=",
"'*.*'",
",",
"text",
"=",
"'Select a file, FACEPANTS.'",
",",
"default_directory",
"=",
"None",
",",
"header_only",
"=",
"False",
",",
"qu... | This will clear the databox, load a file, storing the header info in
self.headers, and the data in self.columns
If first_data_line="auto", then the first data line is assumed to be
the first line where all the elements are numbers.
If you specify a first_data_line (index, starting at... | [
"This",
"will",
"clear",
"the",
"databox",
"load",
"a",
"file",
"storing",
"the",
"header",
"info",
"in",
"self",
".",
"headers",
"and",
"the",
"data",
"in",
"self",
".",
"columns"
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L130-L460 |
Spinmob/spinmob | _data.py | databox.save_file | def save_file(self, path=None, filters='*.dat', force_extension=None, force_overwrite=False, header_only=False, delimiter='use current', binary=None):
"""
This will save all the header info and columns to an ascii file with
the specified path.
Parameters
----------
path=... | python | def save_file(self, path=None, filters='*.dat', force_extension=None, force_overwrite=False, header_only=False, delimiter='use current', binary=None):
"""
This will save all the header info and columns to an ascii file with
the specified path.
Parameters
----------
path=... | [
"def",
"save_file",
"(",
"self",
",",
"path",
"=",
"None",
",",
"filters",
"=",
"'*.dat'",
",",
"force_extension",
"=",
"None",
",",
"force_overwrite",
"=",
"False",
",",
"header_only",
"=",
"False",
",",
"delimiter",
"=",
"'use current'",
",",
"binary",
"... | This will save all the header info and columns to an ascii file with
the specified path.
Parameters
----------
path=None
Path for saving the data. If None, this will bring up
a save file dialog.
filters='*.dat'
File filter for the fil... | [
"This",
"will",
"save",
"all",
"the",
"header",
"info",
"and",
"columns",
"to",
"an",
"ascii",
"file",
"with",
"the",
"specified",
"path",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_data.py#L462-L612 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.