id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
17,500
jcrobak/parquet-python
parquet/encoding.py
read_plain_int96
def read_plain_int96(file_obj, count): """Read `count` 96-bit ints using the plain encoding.""" items = struct.unpack(b"<" + b"qi" * count, file_obj.read(12 * count)) return [q << 32 | i for (q, i) in zip(items[0::2], items[1::2])]
python
def read_plain_int96(file_obj, count): """Read `count` 96-bit ints using the plain encoding.""" items = struct.unpack(b"<" + b"qi" * count, file_obj.read(12 * count)) return [q << 32 | i for (q, i) in zip(items[0::2], items[1::2])]
[ "def", "read_plain_int96", "(", "file_obj", ",", "count", ")", ":", "items", "=", "struct", ".", "unpack", "(", "b\"<\"", "+", "b\"qi\"", "*", "count", ",", "file_obj", ".", "read", "(", "12", "*", "count", ")", ")", "return", "[", "q", "<<", "32", ...
Read `count` 96-bit ints using the plain encoding.
[ "Read", "count", "96", "-", "bit", "ints", "using", "the", "plain", "encoding", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L51-L54
17,501
jcrobak/parquet-python
parquet/encoding.py
read_plain_float
def read_plain_float(file_obj, count): """Read `count` 32-bit floats using the plain encoding.""" return struct.unpack("<{}f".format(count).encode("utf-8"), file_obj.read(4 * count))
python
def read_plain_float(file_obj, count): """Read `count` 32-bit floats using the plain encoding.""" return struct.unpack("<{}f".format(count).encode("utf-8"), file_obj.read(4 * count))
[ "def", "read_plain_float", "(", "file_obj", ",", "count", ")", ":", "return", "struct", ".", "unpack", "(", "\"<{}f\"", ".", "format", "(", "count", ")", ".", "encode", "(", "\"utf-8\"", ")", ",", "file_obj", ".", "read", "(", "4", "*", "count", ")", ...
Read `count` 32-bit floats using the plain encoding.
[ "Read", "count", "32", "-", "bit", "floats", "using", "the", "plain", "encoding", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L57-L59
17,502
jcrobak/parquet-python
parquet/encoding.py
read_plain_byte_array
def read_plain_byte_array(file_obj, count): """Read `count` byte arrays using the plain encoding.""" return [file_obj.read(struct.unpack(b"<i", file_obj.read(4))[0]) for i in range(count)]
python
def read_plain_byte_array(file_obj, count): """Read `count` byte arrays using the plain encoding.""" return [file_obj.read(struct.unpack(b"<i", file_obj.read(4))[0]) for i in range(count)]
[ "def", "read_plain_byte_array", "(", "file_obj", ",", "count", ")", ":", "return", "[", "file_obj", ".", "read", "(", "struct", ".", "unpack", "(", "b\"<i\"", ",", "file_obj", ".", "read", "(", "4", ")", ")", "[", "0", "]", ")", "for", "i", "in", "...
Read `count` byte arrays using the plain encoding.
[ "Read", "count", "byte", "arrays", "using", "the", "plain", "encoding", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L67-L69
17,503
jcrobak/parquet-python
parquet/encoding.py
read_plain
def read_plain(file_obj, type_, count): """Read `count` items `type` from the fo using the plain encoding.""" if count == 0: return [] conv = DECODE_PLAIN[type_] return conv(file_obj, count)
python
def read_plain(file_obj, type_, count): """Read `count` items `type` from the fo using the plain encoding.""" if count == 0: return [] conv = DECODE_PLAIN[type_] return conv(file_obj, count)
[ "def", "read_plain", "(", "file_obj", ",", "type_", ",", "count", ")", ":", "if", "count", "==", "0", ":", "return", "[", "]", "conv", "=", "DECODE_PLAIN", "[", "type_", "]", "return", "conv", "(", "file_obj", ",", "count", ")" ]
Read `count` items `type` from the fo using the plain encoding.
[ "Read", "count", "items", "type", "from", "the", "fo", "using", "the", "plain", "encoding", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L89-L94
17,504
jcrobak/parquet-python
parquet/encoding.py
read_unsigned_var_int
def read_unsigned_var_int(file_obj): """Read a value using the unsigned, variable int encoding.""" result = 0 shift = 0 while True: byte = struct.unpack(b"<B", file_obj.read(1))[0] result |= ((byte & 0x7F) << shift) if (byte & 0x80) == 0: break shift += 7 ...
python
def read_unsigned_var_int(file_obj): """Read a value using the unsigned, variable int encoding.""" result = 0 shift = 0 while True: byte = struct.unpack(b"<B", file_obj.read(1))[0] result |= ((byte & 0x7F) << shift) if (byte & 0x80) == 0: break shift += 7 ...
[ "def", "read_unsigned_var_int", "(", "file_obj", ")", ":", "result", "=", "0", "shift", "=", "0", "while", "True", ":", "byte", "=", "struct", ".", "unpack", "(", "b\"<B\"", ",", "file_obj", ".", "read", "(", "1", ")", ")", "[", "0", "]", "result", ...
Read a value using the unsigned, variable int encoding.
[ "Read", "a", "value", "using", "the", "unsigned", "variable", "int", "encoding", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L97-L107
17,505
jcrobak/parquet-python
parquet/encoding.py
read_rle
def read_rle(file_obj, header, bit_width, debug_logging): """Read a run-length encoded run from the given fo with the given header and bit_width. The count is determined from the header and the width is used to grab the value that's repeated. Yields the value repeated count times. """ count = heade...
python
def read_rle(file_obj, header, bit_width, debug_logging): """Read a run-length encoded run from the given fo with the given header and bit_width. The count is determined from the header and the width is used to grab the value that's repeated. Yields the value repeated count times. """ count = heade...
[ "def", "read_rle", "(", "file_obj", ",", "header", ",", "bit_width", ",", "debug_logging", ")", ":", "count", "=", "header", ">>", "1", "zero_data", "=", "b\"\\x00\\x00\\x00\\x00\"", "width", "=", "(", "bit_width", "+", "7", ")", "//", "8", "data", "=", ...
Read a run-length encoded run from the given fo with the given header and bit_width. The count is determined from the header and the width is used to grab the value that's repeated. Yields the value repeated count times.
[ "Read", "a", "run", "-", "length", "encoded", "run", "from", "the", "given", "fo", "with", "the", "given", "header", "and", "bit_width", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L110-L126
17,506
jcrobak/parquet-python
parquet/encoding.py
read_bitpacked_deprecated
def read_bitpacked_deprecated(file_obj, byte_count, count, width, debug_logging): """Read `count` values from `fo` using the deprecated bitpacking encoding.""" raw_bytes = array.array(ARRAY_BYTE_STR, file_obj.read(byte_count)).tolist() mask = _mask_for_bits(width) index = 0 res = [] word = 0 ...
python
def read_bitpacked_deprecated(file_obj, byte_count, count, width, debug_logging): """Read `count` values from `fo` using the deprecated bitpacking encoding.""" raw_bytes = array.array(ARRAY_BYTE_STR, file_obj.read(byte_count)).tolist() mask = _mask_for_bits(width) index = 0 res = [] word = 0 ...
[ "def", "read_bitpacked_deprecated", "(", "file_obj", ",", "byte_count", ",", "count", ",", "width", ",", "debug_logging", ")", ":", "raw_bytes", "=", "array", ".", "array", "(", "ARRAY_BYTE_STR", ",", "file_obj", ".", "read", "(", "byte_count", ")", ")", "."...
Read `count` values from `fo` using the deprecated bitpacking encoding.
[ "Read", "count", "values", "from", "fo", "using", "the", "deprecated", "bitpacking", "encoding", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/encoding.py#L183-L213
17,507
jcrobak/parquet-python
parquet/converted_types.py
_convert_unsigned
def _convert_unsigned(data, fmt): """Convert data from signed to unsigned in bulk.""" num = len(data) return struct.unpack( "{}{}".format(num, fmt.upper()).encode("utf-8"), struct.pack("{}{}".format(num, fmt).encode("utf-8"), *data) )
python
def _convert_unsigned(data, fmt): """Convert data from signed to unsigned in bulk.""" num = len(data) return struct.unpack( "{}{}".format(num, fmt.upper()).encode("utf-8"), struct.pack("{}{}".format(num, fmt).encode("utf-8"), *data) )
[ "def", "_convert_unsigned", "(", "data", ",", "fmt", ")", ":", "num", "=", "len", "(", "data", ")", "return", "struct", ".", "unpack", "(", "\"{}{}\"", ".", "format", "(", "num", ",", "fmt", ".", "upper", "(", ")", ")", ".", "encode", "(", "\"utf-8...
Convert data from signed to unsigned in bulk.
[ "Convert", "data", "from", "signed", "to", "unsigned", "in", "bulk", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/converted_types.py#L52-L58
17,508
jcrobak/parquet-python
parquet/converted_types.py
convert_column
def convert_column(data, schemae): """Convert known types from primitive to rich.""" ctype = schemae.converted_type if ctype == parquet_thrift.ConvertedType.DECIMAL: scale_factor = Decimal("10e-{}".format(schemae.scale)) if schemae.type == parquet_thrift.Type.INT32 or schemae.type == parquet...
python
def convert_column(data, schemae): """Convert known types from primitive to rich.""" ctype = schemae.converted_type if ctype == parquet_thrift.ConvertedType.DECIMAL: scale_factor = Decimal("10e-{}".format(schemae.scale)) if schemae.type == parquet_thrift.Type.INT32 or schemae.type == parquet...
[ "def", "convert_column", "(", "data", ",", "schemae", ")", ":", "ctype", "=", "schemae", ".", "converted_type", "if", "ctype", "==", "parquet_thrift", ".", "ConvertedType", ".", "DECIMAL", ":", "scale_factor", "=", "Decimal", "(", "\"10e-{}\"", ".", "format", ...
Convert known types from primitive to rich.
[ "Convert", "known", "types", "from", "primitive", "to", "rich", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/converted_types.py#L61-L92
17,509
jcrobak/parquet-python
parquet/__main__.py
setup_logging
def setup_logging(options=None): """Configure logging based on options.""" level = logging.DEBUG if options is not None and options.debug \ else logging.WARNING console = logging.StreamHandler() console.setLevel(level) formatter = logging.Formatter('%(name)s: %(levelname)-8s %(message)s') ...
python
def setup_logging(options=None): """Configure logging based on options.""" level = logging.DEBUG if options is not None and options.debug \ else logging.WARNING console = logging.StreamHandler() console.setLevel(level) formatter = logging.Formatter('%(name)s: %(levelname)-8s %(message)s') ...
[ "def", "setup_logging", "(", "options", "=", "None", ")", ":", "level", "=", "logging", ".", "DEBUG", "if", "options", "is", "not", "None", "and", "options", ".", "debug", "else", "logging", ".", "WARNING", "console", "=", "logging", ".", "StreamHandler", ...
Configure logging based on options.
[ "Configure", "logging", "based", "on", "options", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/__main__.py#L13-L22
17,510
jcrobak/parquet-python
parquet/__main__.py
main
def main(argv=None): """Run parquet utility application.""" argv = argv or sys.argv[1:] parser = argparse.ArgumentParser('parquet', description='Read parquet files') parser.add_argument('--metadata', action='store_true', help='show metadata o...
python
def main(argv=None): """Run parquet utility application.""" argv = argv or sys.argv[1:] parser = argparse.ArgumentParser('parquet', description='Read parquet files') parser.add_argument('--metadata', action='store_true', help='show metadata o...
[ "def", "main", "(", "argv", "=", "None", ")", ":", "argv", "=", "argv", "or", "sys", ".", "argv", "[", "1", ":", "]", "parser", "=", "argparse", ".", "ArgumentParser", "(", "'parquet'", ",", "description", "=", "'Read parquet files'", ")", "parser", "....
Run parquet utility application.
[ "Run", "parquet", "utility", "application", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/__main__.py#L25-L61
17,511
jcrobak/parquet-python
parquet/schema.py
SchemaHelper.is_required
def is_required(self, name): """Return true iff the schema element with the given name is required.""" return self.schema_element(name).repetition_type == parquet_thrift.FieldRepetitionType.REQUIRED
python
def is_required(self, name): """Return true iff the schema element with the given name is required.""" return self.schema_element(name).repetition_type == parquet_thrift.FieldRepetitionType.REQUIRED
[ "def", "is_required", "(", "self", ",", "name", ")", ":", "return", "self", ".", "schema_element", "(", "name", ")", ".", "repetition_type", "==", "parquet_thrift", ".", "FieldRepetitionType", ".", "REQUIRED" ]
Return true iff the schema element with the given name is required.
[ "Return", "true", "iff", "the", "schema", "element", "with", "the", "given", "name", "is", "required", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/schema.py#L30-L32
17,512
jcrobak/parquet-python
parquet/schema.py
SchemaHelper.max_repetition_level
def max_repetition_level(self, path): """Get the max repetition level for the given schema path.""" max_level = 0 for part in path: element = self.schema_element(part) if element.repetition_type == parquet_thrift.FieldRepetitionType.REQUIRED: max_level += ...
python
def max_repetition_level(self, path): """Get the max repetition level for the given schema path.""" max_level = 0 for part in path: element = self.schema_element(part) if element.repetition_type == parquet_thrift.FieldRepetitionType.REQUIRED: max_level += ...
[ "def", "max_repetition_level", "(", "self", ",", "path", ")", ":", "max_level", "=", "0", "for", "part", "in", "path", ":", "element", "=", "self", ".", "schema_element", "(", "part", ")", "if", "element", ".", "repetition_type", "==", "parquet_thrift", "....
Get the max repetition level for the given schema path.
[ "Get", "the", "max", "repetition", "level", "for", "the", "given", "schema", "path", "." ]
e2caab7aceca91a3075998d0113e186f8ba2ca37
https://github.com/jcrobak/parquet-python/blob/e2caab7aceca91a3075998d0113e186f8ba2ca37/parquet/schema.py#L34-L41
17,513
joke2k/django-faker
django_faker/populator.py
Populator.execute
def execute(self, using=None): """ Populate the database using all the Entity classes previously added. :param using A Django database connection name :rtype: A list of the inserted PKs """ if not using: using = self.getConnection() insertedEntities ...
python
def execute(self, using=None): """ Populate the database using all the Entity classes previously added. :param using A Django database connection name :rtype: A list of the inserted PKs """ if not using: using = self.getConnection() insertedEntities ...
[ "def", "execute", "(", "self", ",", "using", "=", "None", ")", ":", "if", "not", "using", ":", "using", "=", "self", ".", "getConnection", "(", ")", "insertedEntities", "=", "{", "}", "for", "klass", "in", "self", ".", "orders", ":", "number", "=", ...
Populate the database using all the Entity classes previously added. :param using A Django database connection name :rtype: A list of the inserted PKs
[ "Populate", "the", "database", "using", "all", "the", "Entity", "classes", "previously", "added", "." ]
345e3eebcf636e2566d9890ae7b35788ebdb5173
https://github.com/joke2k/django-faker/blob/345e3eebcf636e2566d9890ae7b35788ebdb5173/django_faker/populator.py#L147-L165
17,514
joke2k/django-faker
django_faker/__init__.py
Faker.getGenerator
def getGenerator(cls, locale=None, providers=None, codename=None): """ use a codename to cache generators """ codename = codename or cls.getCodename(locale, providers) if codename not in cls.generators: from faker import Faker as FakerGenerator # initial...
python
def getGenerator(cls, locale=None, providers=None, codename=None): """ use a codename to cache generators """ codename = codename or cls.getCodename(locale, providers) if codename not in cls.generators: from faker import Faker as FakerGenerator # initial...
[ "def", "getGenerator", "(", "cls", ",", "locale", "=", "None", ",", "providers", "=", "None", ",", "codename", "=", "None", ")", ":", "codename", "=", "codename", "or", "cls", ".", "getCodename", "(", "locale", ",", "providers", ")", "if", "codename", ...
use a codename to cache generators
[ "use", "a", "codename", "to", "cache", "generators" ]
345e3eebcf636e2566d9890ae7b35788ebdb5173
https://github.com/joke2k/django-faker/blob/345e3eebcf636e2566d9890ae7b35788ebdb5173/django_faker/__init__.py#L48-L62
17,515
brandonxiang/geojson-python-utils
geojson_utils/geojson_utils.py
_point_in_bbox
def _point_in_bbox(point, bounds): """ valid whether the point is inside the bounding box """ return not(point['coordinates'][1] < bounds[0] or point['coordinates'][1] > bounds[2] or point['coordinates'][0] < bounds[1] or point['coordinates'][0] > bounds[3])
python
def _point_in_bbox(point, bounds): """ valid whether the point is inside the bounding box """ return not(point['coordinates'][1] < bounds[0] or point['coordinates'][1] > bounds[2] or point['coordinates'][0] < bounds[1] or point['coordinates'][0] > bounds[3])
[ "def", "_point_in_bbox", "(", "point", ",", "bounds", ")", ":", "return", "not", "(", "point", "[", "'coordinates'", "]", "[", "1", "]", "<", "bounds", "[", "0", "]", "or", "point", "[", "'coordinates'", "]", "[", "1", "]", ">", "bounds", "[", "2",...
valid whether the point is inside the bounding box
[ "valid", "whether", "the", "point", "is", "inside", "the", "bounding", "box" ]
33d0dcd5f16e0567b48c0d49fd292a4f1db16b41
https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/geojson_utils.py#L56-L61
17,516
brandonxiang/geojson-python-utils
geojson_utils/geojson_utils.py
point_in_polygon
def point_in_polygon(point, poly): """ valid whether the point is located in a polygon Keyword arguments: point -- point geojson object poly -- polygon geojson object if(point inside poly) return true else false """ coords = [poly['coordinates']] if poly[ 'type'] == 'Polygon' ...
python
def point_in_polygon(point, poly): """ valid whether the point is located in a polygon Keyword arguments: point -- point geojson object poly -- polygon geojson object if(point inside poly) return true else false """ coords = [poly['coordinates']] if poly[ 'type'] == 'Polygon' ...
[ "def", "point_in_polygon", "(", "point", ",", "poly", ")", ":", "coords", "=", "[", "poly", "[", "'coordinates'", "]", "]", "if", "poly", "[", "'type'", "]", "==", "'Polygon'", "else", "poly", "[", "'coordinates'", "]", "return", "_point_in_polygon", "(", ...
valid whether the point is located in a polygon Keyword arguments: point -- point geojson object poly -- polygon geojson object if(point inside poly) return true else false
[ "valid", "whether", "the", "point", "is", "located", "in", "a", "polygon" ]
33d0dcd5f16e0567b48c0d49fd292a4f1db16b41
https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/geojson_utils.py#L111-L123
17,517
brandonxiang/geojson-python-utils
geojson_utils/geojson_utils.py
draw_circle
def draw_circle(radius_in_meters, center_point, steps=15): """ get a circle shape polygon based on centerPoint and radius Keyword arguments: point1 -- point one geojson object point2 -- point two geojson object if(point inside multipoly) return true else false """ steps = steps if st...
python
def draw_circle(radius_in_meters, center_point, steps=15): """ get a circle shape polygon based on centerPoint and radius Keyword arguments: point1 -- point one geojson object point2 -- point two geojson object if(point inside multipoly) return true else false """ steps = steps if st...
[ "def", "draw_circle", "(", "radius_in_meters", ",", "center_point", ",", "steps", "=", "15", ")", ":", "steps", "=", "steps", "if", "steps", ">", "15", "else", "15", "center", "=", "[", "center_point", "[", "'coordinates'", "]", "[", "1", "]", ",", "ce...
get a circle shape polygon based on centerPoint and radius Keyword arguments: point1 -- point one geojson object point2 -- point two geojson object if(point inside multipoly) return true else false
[ "get", "a", "circle", "shape", "polygon", "based", "on", "centerPoint", "and", "radius" ]
33d0dcd5f16e0567b48c0d49fd292a4f1db16b41
https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/geojson_utils.py#L170-L194
17,518
brandonxiang/geojson-python-utils
geojson_utils/geojson_utils.py
rectangle_centroid
def rectangle_centroid(rectangle): """ get the centroid of the rectangle Keyword arguments: rectangle -- polygon geojson object return centroid """ bbox = rectangle['coordinates'][0] xmin = bbox[0][0] ymin = bbox[0][1] xmax = bbox[2][0] ymax = bbox[2][1] xwidth = xmax ...
python
def rectangle_centroid(rectangle): """ get the centroid of the rectangle Keyword arguments: rectangle -- polygon geojson object return centroid """ bbox = rectangle['coordinates'][0] xmin = bbox[0][0] ymin = bbox[0][1] xmax = bbox[2][0] ymax = bbox[2][1] xwidth = xmax ...
[ "def", "rectangle_centroid", "(", "rectangle", ")", ":", "bbox", "=", "rectangle", "[", "'coordinates'", "]", "[", "0", "]", "xmin", "=", "bbox", "[", "0", "]", "[", "0", "]", "ymin", "=", "bbox", "[", "0", "]", "[", "1", "]", "xmax", "=", "bbox"...
get the centroid of the rectangle Keyword arguments: rectangle -- polygon geojson object return centroid
[ "get", "the", "centroid", "of", "the", "rectangle" ]
33d0dcd5f16e0567b48c0d49fd292a4f1db16b41
https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/geojson_utils.py#L197-L213
17,519
brandonxiang/geojson-python-utils
geojson_utils/geojson_utils.py
geometry_within_radius
def geometry_within_radius(geometry, center, radius): """ To valid whether point or linestring or polygon is inside a radius around a center Keyword arguments: geometry -- point/linstring/polygon geojson object center -- point geojson object radius -- radius if(geometry inside radiu...
python
def geometry_within_radius(geometry, center, radius): """ To valid whether point or linestring or polygon is inside a radius around a center Keyword arguments: geometry -- point/linstring/polygon geojson object center -- point geojson object radius -- radius if(geometry inside radiu...
[ "def", "geometry_within_radius", "(", "geometry", ",", "center", ",", "radius", ")", ":", "if", "geometry", "[", "'type'", "]", "==", "'Point'", ":", "return", "point_distance", "(", "geometry", ",", "center", ")", "<=", "radius", "elif", "geometry", "[", ...
To valid whether point or linestring or polygon is inside a radius around a center Keyword arguments: geometry -- point/linstring/polygon geojson object center -- point geojson object radius -- radius if(geometry inside radius) return true else false
[ "To", "valid", "whether", "point", "or", "linestring", "or", "polygon", "is", "inside", "a", "radius", "around", "a", "center" ]
33d0dcd5f16e0567b48c0d49fd292a4f1db16b41
https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/geojson_utils.py#L264-L286
17,520
brandonxiang/geojson-python-utils
geojson_utils/geojson_utils.py
area
def area(poly): """ calculate the area of polygon Keyword arguments: poly -- polygon geojson object return polygon area """ poly_area = 0 # TODO: polygon holes at coordinates[1] points = poly['coordinates'][0] j = len(points) - 1 count = len(points) for i in range(0, c...
python
def area(poly): """ calculate the area of polygon Keyword arguments: poly -- polygon geojson object return polygon area """ poly_area = 0 # TODO: polygon holes at coordinates[1] points = poly['coordinates'][0] j = len(points) - 1 count = len(points) for i in range(0, c...
[ "def", "area", "(", "poly", ")", ":", "poly_area", "=", "0", "# TODO: polygon holes at coordinates[1]", "points", "=", "poly", "[", "'coordinates'", "]", "[", "0", "]", "j", "=", "len", "(", "points", ")", "-", "1", "count", "=", "len", "(", "points", ...
calculate the area of polygon Keyword arguments: poly -- polygon geojson object return polygon area
[ "calculate", "the", "area", "of", "polygon" ]
33d0dcd5f16e0567b48c0d49fd292a4f1db16b41
https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/geojson_utils.py#L289-L315
17,521
brandonxiang/geojson-python-utils
geojson_utils/geojson_utils.py
destination_point
def destination_point(point, brng, dist): """ Calculate a destination Point base on a base point and a distance Keyword arguments: pt -- polygon geojson object brng -- an angle in degrees dist -- distance in Kilometer between destination and base point return destination point object ...
python
def destination_point(point, brng, dist): """ Calculate a destination Point base on a base point and a distance Keyword arguments: pt -- polygon geojson object brng -- an angle in degrees dist -- distance in Kilometer between destination and base point return destination point object ...
[ "def", "destination_point", "(", "point", ",", "brng", ",", "dist", ")", ":", "dist", "=", "float", "(", "dist", ")", "/", "6371", "# convert dist to angular distance in radians", "brng", "=", "number2radius", "(", "brng", ")", "lon1", "=", "number2radius", "(...
Calculate a destination Point base on a base point and a distance Keyword arguments: pt -- polygon geojson object brng -- an angle in degrees dist -- distance in Kilometer between destination and base point return destination point object
[ "Calculate", "a", "destination", "Point", "base", "on", "a", "base", "point", "and", "a", "distance" ]
33d0dcd5f16e0567b48c0d49fd292a4f1db16b41
https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/geojson_utils.py#L351-L375
17,522
brandonxiang/geojson-python-utils
geojson_utils/merger.py
merge_featurecollection
def merge_featurecollection(*jsons): """ merge features into one featurecollection Keyword arguments: jsons -- jsons object list return geojson featurecollection """ features = [] for json in jsons: if json['type'] == 'FeatureCollection': for feature in json['fea...
python
def merge_featurecollection(*jsons): """ merge features into one featurecollection Keyword arguments: jsons -- jsons object list return geojson featurecollection """ features = [] for json in jsons: if json['type'] == 'FeatureCollection': for feature in json['fea...
[ "def", "merge_featurecollection", "(", "*", "jsons", ")", ":", "features", "=", "[", "]", "for", "json", "in", "jsons", ":", "if", "json", "[", "'type'", "]", "==", "'FeatureCollection'", ":", "for", "feature", "in", "json", "[", "'features'", "]", ":", ...
merge features into one featurecollection Keyword arguments: jsons -- jsons object list return geojson featurecollection
[ "merge", "features", "into", "one", "featurecollection" ]
33d0dcd5f16e0567b48c0d49fd292a4f1db16b41
https://github.com/brandonxiang/geojson-python-utils/blob/33d0dcd5f16e0567b48c0d49fd292a4f1db16b41/geojson_utils/merger.py#L6-L20
17,523
gotcha/vimpdb
src/vimpdb/debugger.py
trace_dispatch
def trace_dispatch(self, frame, event, arg): """allow to switch to Vimpdb instance""" if hasattr(self, 'vimpdb'): return self.vimpdb.trace_dispatch(frame, event, arg) else: return self._orig_trace_dispatch(frame, event, arg)
python
def trace_dispatch(self, frame, event, arg): """allow to switch to Vimpdb instance""" if hasattr(self, 'vimpdb'): return self.vimpdb.trace_dispatch(frame, event, arg) else: return self._orig_trace_dispatch(frame, event, arg)
[ "def", "trace_dispatch", "(", "self", ",", "frame", ",", "event", ",", "arg", ")", ":", "if", "hasattr", "(", "self", ",", "'vimpdb'", ")", ":", "return", "self", ".", "vimpdb", ".", "trace_dispatch", "(", "frame", ",", "event", ",", "arg", ")", "els...
allow to switch to Vimpdb instance
[ "allow", "to", "switch", "to", "Vimpdb", "instance" ]
1171938751127d23f66f6b750dd79166c64bdf20
https://github.com/gotcha/vimpdb/blob/1171938751127d23f66f6b750dd79166c64bdf20/src/vimpdb/debugger.py#L237-L242
17,524
gotcha/vimpdb
src/vimpdb/debugger.py
hook
def hook(klass): """ monkey-patch pdb.Pdb class adds a 'vim' (and 'v') command: it switches to debugging with vimpdb """ if not hasattr(klass, 'do_vim'): setupMethod(klass, trace_dispatch) klass.__bases__ += (SwitcherToVimpdb, )
python
def hook(klass): """ monkey-patch pdb.Pdb class adds a 'vim' (and 'v') command: it switches to debugging with vimpdb """ if not hasattr(klass, 'do_vim'): setupMethod(klass, trace_dispatch) klass.__bases__ += (SwitcherToVimpdb, )
[ "def", "hook", "(", "klass", ")", ":", "if", "not", "hasattr", "(", "klass", ",", "'do_vim'", ")", ":", "setupMethod", "(", "klass", ",", "trace_dispatch", ")", "klass", ".", "__bases__", "+=", "(", "SwitcherToVimpdb", ",", ")" ]
monkey-patch pdb.Pdb class adds a 'vim' (and 'v') command: it switches to debugging with vimpdb
[ "monkey", "-", "patch", "pdb", ".", "Pdb", "class" ]
1171938751127d23f66f6b750dd79166c64bdf20
https://github.com/gotcha/vimpdb/blob/1171938751127d23f66f6b750dd79166c64bdf20/src/vimpdb/debugger.py#L277-L287
17,525
gotcha/vimpdb
src/vimpdb/debugger.py
VimPdb.trace_dispatch
def trace_dispatch(self, frame, event, arg): """allow to switch to Pdb instance""" if hasattr(self, 'pdb'): return self.pdb.trace_dispatch(frame, event, arg) else: return Pdb.trace_dispatch(self, frame, event, arg)
python
def trace_dispatch(self, frame, event, arg): """allow to switch to Pdb instance""" if hasattr(self, 'pdb'): return self.pdb.trace_dispatch(frame, event, arg) else: return Pdb.trace_dispatch(self, frame, event, arg)
[ "def", "trace_dispatch", "(", "self", ",", "frame", ",", "event", ",", "arg", ")", ":", "if", "hasattr", "(", "self", ",", "'pdb'", ")", ":", "return", "self", ".", "pdb", ".", "trace_dispatch", "(", "frame", ",", "event", ",", "arg", ")", "else", ...
allow to switch to Pdb instance
[ "allow", "to", "switch", "to", "Pdb", "instance" ]
1171938751127d23f66f6b750dd79166c64bdf20
https://github.com/gotcha/vimpdb/blob/1171938751127d23f66f6b750dd79166c64bdf20/src/vimpdb/debugger.py#L97-L102
17,526
rkhleics/wagtailmenus
wagtailmenus/models/mixins.py
DefinesSubMenuTemplatesMixin.get_context_data
def get_context_data(self, **kwargs): """ Include the name of the sub menu template in the context. This is purely for backwards compatibility. Any sub menus rendered as part of this menu will call `sub_menu_template` on the original menu instance to get an actual `Template` ...
python
def get_context_data(self, **kwargs): """ Include the name of the sub menu template in the context. This is purely for backwards compatibility. Any sub menus rendered as part of this menu will call `sub_menu_template` on the original menu instance to get an actual `Template` ...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "data", "=", "{", "}", "if", "self", ".", "_contextual_vals", ".", "current_level", "==", "1", "and", "self", ".", "max_levels", ">", "1", ":", "data", "[", "'sub_menu_template'",...
Include the name of the sub menu template in the context. This is purely for backwards compatibility. Any sub menus rendered as part of this menu will call `sub_menu_template` on the original menu instance to get an actual `Template`
[ "Include", "the", "name", "of", "the", "sub", "menu", "template", "in", "the", "context", ".", "This", "is", "purely", "for", "backwards", "compatibility", ".", "Any", "sub", "menus", "rendered", "as", "part", "of", "this", "menu", "will", "call", "sub_men...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/mixins.py#L105-L116
17,527
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu.render_from_tag
def render_from_tag( cls, context, max_levels=None, use_specific=None, apply_active_classes=True, allow_repeating_parents=True, use_absolute_page_urls=False, add_sub_menus_inline=None, template_name='', **kwargs ): """ A template tag should call this method to render ...
python
def render_from_tag( cls, context, max_levels=None, use_specific=None, apply_active_classes=True, allow_repeating_parents=True, use_absolute_page_urls=False, add_sub_menus_inline=None, template_name='', **kwargs ): """ A template tag should call this method to render ...
[ "def", "render_from_tag", "(", "cls", ",", "context", ",", "max_levels", "=", "None", ",", "use_specific", "=", "None", ",", "apply_active_classes", "=", "True", ",", "allow_repeating_parents", "=", "True", ",", "use_absolute_page_urls", "=", "False", ",", "add_...
A template tag should call this method to render a menu. The ``Context`` instance and option values provided are used to get or create a relevant menu instance, prepare it, then render it and it's menu items to an appropriate template. It shouldn't be neccessary to override this method,...
[ "A", "template", "tag", "should", "call", "this", "method", "to", "render", "a", "menu", ".", "The", "Context", "instance", "and", "option", "values", "provided", "are", "used", "to", "get", "or", "create", "a", "relevant", "menu", "instance", "prepare", "...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L68-L105
17,528
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu._create_contextualvals_obj_from_context
def _create_contextualvals_obj_from_context(cls, context): """ Gathers all of the 'contextual' data needed to render a menu instance and returns it in a structure that can be conveniently referenced throughout the process of preparing the menu and menu items and for rendering. ...
python
def _create_contextualvals_obj_from_context(cls, context): """ Gathers all of the 'contextual' data needed to render a menu instance and returns it in a structure that can be conveniently referenced throughout the process of preparing the menu and menu items and for rendering. ...
[ "def", "_create_contextualvals_obj_from_context", "(", "cls", ",", "context", ")", ":", "context_processor_vals", "=", "context", ".", "get", "(", "'wagtailmenus_vals'", ",", "{", "}", ")", "return", "ContextualVals", "(", "context", ",", "context", "[", "'request...
Gathers all of the 'contextual' data needed to render a menu instance and returns it in a structure that can be conveniently referenced throughout the process of preparing the menu and menu items and for rendering.
[ "Gathers", "all", "of", "the", "contextual", "data", "needed", "to", "render", "a", "menu", "instance", "and", "returns", "it", "in", "a", "structure", "that", "can", "be", "conveniently", "referenced", "throughout", "the", "process", "of", "preparing", "the",...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L128-L146
17,529
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu.render_to_template
def render_to_template(self): """ Render the current menu instance to a template and return a string """ context_data = self.get_context_data() template = self.get_template() context_data['current_template'] = template.template.name return template.render(context...
python
def render_to_template(self): """ Render the current menu instance to a template and return a string """ context_data = self.get_context_data() template = self.get_template() context_data['current_template'] = template.template.name return template.render(context...
[ "def", "render_to_template", "(", "self", ")", ":", "context_data", "=", "self", ".", "get_context_data", "(", ")", "template", "=", "self", ".", "get_template", "(", ")", "context_data", "[", "'current_template'", "]", "=", "template", ".", "template", ".", ...
Render the current menu instance to a template and return a string
[ "Render", "the", "current", "menu", "instance", "to", "a", "template", "and", "return", "a", "string" ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L222-L230
17,530
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu.get_common_hook_kwargs
def get_common_hook_kwargs(self, **kwargs): """ Returns a dictionary of common values to be passed as keyword arguments to methods registered as 'hooks'. """ opt_vals = self._option_vals hook_kwargs = self._contextual_vals._asdict() hook_kwargs.update({ ...
python
def get_common_hook_kwargs(self, **kwargs): """ Returns a dictionary of common values to be passed as keyword arguments to methods registered as 'hooks'. """ opt_vals = self._option_vals hook_kwargs = self._contextual_vals._asdict() hook_kwargs.update({ ...
[ "def", "get_common_hook_kwargs", "(", "self", ",", "*", "*", "kwargs", ")", ":", "opt_vals", "=", "self", ".", "_option_vals", "hook_kwargs", "=", "self", ".", "_contextual_vals", ".", "_asdict", "(", ")", "hook_kwargs", ".", "update", "(", "{", "'menu_insta...
Returns a dictionary of common values to be passed as keyword arguments to methods registered as 'hooks'.
[ "Returns", "a", "dictionary", "of", "common", "values", "to", "be", "passed", "as", "keyword", "arguments", "to", "methods", "registered", "as", "hooks", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L269-L289
17,531
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu.get_page_children_dict
def get_page_children_dict(self, page_qs=None): """ Returns a dictionary of lists, where the keys are 'path' values for pages, and the value is a list of children pages for that page. """ children_dict = defaultdict(list) for page in page_qs or self.pages_for_display: ...
python
def get_page_children_dict(self, page_qs=None): """ Returns a dictionary of lists, where the keys are 'path' values for pages, and the value is a list of children pages for that page. """ children_dict = defaultdict(list) for page in page_qs or self.pages_for_display: ...
[ "def", "get_page_children_dict", "(", "self", ",", "page_qs", "=", "None", ")", ":", "children_dict", "=", "defaultdict", "(", "list", ")", "for", "page", "in", "page_qs", "or", "self", ".", "pages_for_display", ":", "children_dict", "[", "page", ".", "path"...
Returns a dictionary of lists, where the keys are 'path' values for pages, and the value is a list of children pages for that page.
[ "Returns", "a", "dictionary", "of", "lists", "where", "the", "keys", "are", "path", "values", "for", "pages", "and", "the", "value", "is", "a", "list", "of", "children", "pages", "for", "that", "page", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L318-L326
17,532
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu.get_context_data
def get_context_data(self, **kwargs): """ Return a dictionary containing all of the values needed to render the menu instance to a template, including values that might be used by the 'sub_menu' tag to render any additional levels. """ ctx_vals = self._contextual_vals ...
python
def get_context_data(self, **kwargs): """ Return a dictionary containing all of the values needed to render the menu instance to a template, including values that might be used by the 'sub_menu' tag to render any additional levels. """ ctx_vals = self._contextual_vals ...
[ "def", "get_context_data", "(", "self", ",", "*", "*", "kwargs", ")", ":", "ctx_vals", "=", "self", ".", "_contextual_vals", "opt_vals", "=", "self", ".", "_option_vals", "data", "=", "self", ".", "create_dict_from_parent_context", "(", ")", "data", ".", "up...
Return a dictionary containing all of the values needed to render the menu instance to a template, including values that might be used by the 'sub_menu' tag to render any additional levels.
[ "Return", "a", "dictionary", "containing", "all", "of", "the", "values", "needed", "to", "render", "the", "menu", "instance", "to", "a", "template", "including", "values", "that", "might", "be", "used", "by", "the", "sub_menu", "tag", "to", "render", "any", ...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L385-L412
17,533
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu.get_menu_items_for_rendering
def get_menu_items_for_rendering(self): """ Return a list of 'menu items' to be included in the context for rendering the current level of the menu. The responsibility for sourcing, priming, and modifying menu items is split between three methods: ``get_raw_menu_items()``, ...
python
def get_menu_items_for_rendering(self): """ Return a list of 'menu items' to be included in the context for rendering the current level of the menu. The responsibility for sourcing, priming, and modifying menu items is split between three methods: ``get_raw_menu_items()``, ...
[ "def", "get_menu_items_for_rendering", "(", "self", ")", ":", "items", "=", "self", ".", "get_raw_menu_items", "(", ")", "# Allow hooks to modify the raw list", "for", "hook", "in", "hooks", ".", "get_hooks", "(", "'menus_modify_raw_menu_items'", ")", ":", "items", ...
Return a list of 'menu items' to be included in the context for rendering the current level of the menu. The responsibility for sourcing, priming, and modifying menu items is split between three methods: ``get_raw_menu_items()``, ``prime_menu_items()`` and ``modify_menu_items()``, respe...
[ "Return", "a", "list", "of", "menu", "items", "to", "be", "included", "in", "the", "context", "for", "rendering", "the", "current", "level", "of", "the", "menu", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L414-L438
17,534
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu._replace_with_specific_page
def _replace_with_specific_page(page, menu_item): """ If ``page`` is a vanilla ``Page` object, replace it with a 'specific' version of itself. Also update ``menu_item``, depending on whether it's a ``MenuItem`` object or a ``Page`` object. """ if type(page) is Page: ...
python
def _replace_with_specific_page(page, menu_item): """ If ``page`` is a vanilla ``Page` object, replace it with a 'specific' version of itself. Also update ``menu_item``, depending on whether it's a ``MenuItem`` object or a ``Page`` object. """ if type(page) is Page: ...
[ "def", "_replace_with_specific_page", "(", "page", ",", "menu_item", ")", ":", "if", "type", "(", "page", ")", "is", "Page", ":", "page", "=", "page", ".", "specific", "if", "isinstance", "(", "menu_item", ",", "MenuItem", ")", ":", "menu_item", ".", "li...
If ``page`` is a vanilla ``Page` object, replace it with a 'specific' version of itself. Also update ``menu_item``, depending on whether it's a ``MenuItem`` object or a ``Page`` object.
[ "If", "page", "is", "a", "vanilla", "Page", "object", "replace", "it", "with", "a", "specific", "version", "of", "itself", ".", "Also", "update", "menu_item", "depending", "on", "whether", "it", "s", "a", "MenuItem", "object", "or", "a", "Page", "object", ...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L451-L463
17,535
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
Menu.prime_menu_items
def prime_menu_items(self, menu_items): """ A generator method that takes a list of ``MenuItem`` or ``Page`` objects and sets a number of additional attributes on each item that are useful in menu templates. """ for item in menu_items: item = self._prime_menu_...
python
def prime_menu_items(self, menu_items): """ A generator method that takes a list of ``MenuItem`` or ``Page`` objects and sets a number of additional attributes on each item that are useful in menu templates. """ for item in menu_items: item = self._prime_menu_...
[ "def", "prime_menu_items", "(", "self", ",", "menu_items", ")", ":", "for", "item", "in", "menu_items", ":", "item", "=", "self", ".", "_prime_menu_item", "(", "item", ")", "if", "item", "is", "not", "None", ":", "yield", "item" ]
A generator method that takes a list of ``MenuItem`` or ``Page`` objects and sets a number of additional attributes on each item that are useful in menu templates.
[ "A", "generator", "method", "that", "takes", "a", "list", "of", "MenuItem", "or", "Page", "objects", "and", "sets", "a", "number", "of", "additional", "attributes", "on", "each", "item", "that", "are", "useful", "in", "menu", "templates", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L603-L612
17,536
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
MenuFromPage.get_children_for_page
def get_children_for_page(self, page): """Return a list of relevant child pages for a given page""" if self.max_levels == 1: # If there's only a single level of pages to display, skip the # dict creation / lookup and just return the QuerySet result return self.pages_f...
python
def get_children_for_page(self, page): """Return a list of relevant child pages for a given page""" if self.max_levels == 1: # If there's only a single level of pages to display, skip the # dict creation / lookup and just return the QuerySet result return self.pages_f...
[ "def", "get_children_for_page", "(", "self", ",", "page", ")", ":", "if", "self", ".", "max_levels", "==", "1", ":", "# If there's only a single level of pages to display, skip the", "# dict creation / lookup and just return the QuerySet result", "return", "self", ".", "pages...
Return a list of relevant child pages for a given page
[ "Return", "a", "list", "of", "relevant", "child", "pages", "for", "a", "given", "page" ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L705-L711
17,537
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
MenuWithMenuItems.get_top_level_items
def get_top_level_items(self): """Return a list of menu items with link_page objects supplemented with 'specific' pages where appropriate.""" menu_items = self.get_base_menuitem_queryset() # Identify which pages to fetch for the top level items page_ids = tuple( obj....
python
def get_top_level_items(self): """Return a list of menu items with link_page objects supplemented with 'specific' pages where appropriate.""" menu_items = self.get_base_menuitem_queryset() # Identify which pages to fetch for the top level items page_ids = tuple( obj....
[ "def", "get_top_level_items", "(", "self", ")", ":", "menu_items", "=", "self", ".", "get_base_menuitem_queryset", "(", ")", "# Identify which pages to fetch for the top level items", "page_ids", "=", "tuple", "(", "obj", ".", "link_page_id", "for", "obj", "in", "menu...
Return a list of menu items with link_page objects supplemented with 'specific' pages where appropriate.
[ "Return", "a", "list", "of", "menu", "items", "with", "link_page", "objects", "supplemented", "with", "specific", "pages", "where", "appropriate", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L1015-L1054
17,538
rkhleics/wagtailmenus
wagtailmenus/models/menus.py
AbstractMainMenu.get_for_site
def get_for_site(cls, site): """Return the 'main menu' instance for the provided site""" instance, created = cls.objects.get_or_create(site=site) return instance
python
def get_for_site(cls, site): """Return the 'main menu' instance for the provided site""" instance, created = cls.objects.get_or_create(site=site) return instance
[ "def", "get_for_site", "(", "cls", ",", "site", ")", ":", "instance", ",", "created", "=", "cls", ".", "objects", ".", "get_or_create", "(", "site", "=", "site", ")", "return", "instance" ]
Return the 'main menu' instance for the provided site
[ "Return", "the", "main", "menu", "instance", "for", "the", "provided", "site" ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/menus.py#L1207-L1210
17,539
rkhleics/wagtailmenus
wagtailmenus/views.py
FlatMenuCopyView.get_form_kwargs
def get_form_kwargs(self): kwargs = super().get_form_kwargs() """ When the form is posted, don't pass an instance to the form. It should create a new one out of the posted data. We also need to nullify any IDs posted for inline menu items, so that new instances of those are ...
python
def get_form_kwargs(self): kwargs = super().get_form_kwargs() """ When the form is posted, don't pass an instance to the form. It should create a new one out of the posted data. We also need to nullify any IDs posted for inline menu items, so that new instances of those are ...
[ "def", "get_form_kwargs", "(", "self", ")", ":", "kwargs", "=", "super", "(", ")", ".", "get_form_kwargs", "(", ")", "if", "self", ".", "request", ".", "method", "==", "'POST'", ":", "data", "=", "copy", "(", "self", ".", "request", ".", "POST", ")",...
When the form is posted, don't pass an instance to the form. It should create a new one out of the posted data. We also need to nullify any IDs posted for inline menu items, so that new instances of those are created too.
[ "When", "the", "form", "is", "posted", "don", "t", "pass", "an", "instance", "to", "the", "form", ".", "It", "should", "create", "a", "new", "one", "out", "of", "the", "posted", "data", ".", "We", "also", "need", "to", "nullify", "any", "IDs", "poste...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/views.py#L156-L178
17,540
rkhleics/wagtailmenus
wagtailmenus/models/pages.py
MenuPageMixin.modify_submenu_items
def modify_submenu_items( self, menu_items, current_page, current_ancestor_ids, current_site, allow_repeating_parents, apply_active_classes, original_menu_tag, menu_instance=None, request=None, use_absolute_page_urls=False, ): """ Make any necessary modifications to `menu_ite...
python
def modify_submenu_items( self, menu_items, current_page, current_ancestor_ids, current_site, allow_repeating_parents, apply_active_classes, original_menu_tag, menu_instance=None, request=None, use_absolute_page_urls=False, ): """ Make any necessary modifications to `menu_ite...
[ "def", "modify_submenu_items", "(", "self", ",", "menu_items", ",", "current_page", ",", "current_ancestor_ids", ",", "current_site", ",", "allow_repeating_parents", ",", "apply_active_classes", ",", "original_menu_tag", ",", "menu_instance", "=", "None", ",", "request"...
Make any necessary modifications to `menu_items` and return the list back to the calling menu tag to render in templates. Any additional items added should have a `text` and `href` attribute as a minimum. `original_menu_tag` should be one of 'main_menu', 'section_menu' or 'children_menu...
[ "Make", "any", "necessary", "modifications", "to", "menu_items", "and", "return", "the", "list", "back", "to", "the", "calling", "menu", "tag", "to", "render", "in", "templates", ".", "Any", "additional", "items", "added", "should", "have", "a", "text", "and...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/pages.py#L37-L65
17,541
rkhleics/wagtailmenus
wagtailmenus/models/pages.py
MenuPageMixin.has_submenu_items
def has_submenu_items(self, current_page, allow_repeating_parents, original_menu_tag, menu_instance=None, request=None): """ When rendering pages in a menu template a `has_children_in_menu` attribute is added to each page, letting template developers know whethe...
python
def has_submenu_items(self, current_page, allow_repeating_parents, original_menu_tag, menu_instance=None, request=None): """ When rendering pages in a menu template a `has_children_in_menu` attribute is added to each page, letting template developers know whethe...
[ "def", "has_submenu_items", "(", "self", ",", "current_page", ",", "allow_repeating_parents", ",", "original_menu_tag", ",", "menu_instance", "=", "None", ",", "request", "=", "None", ")", ":", "return", "menu_instance", ".", "page_has_children", "(", "self", ")" ...
When rendering pages in a menu template a `has_children_in_menu` attribute is added to each page, letting template developers know whether or not the item has a submenu that must be rendered. By default, we return a boolean indicating whether the page has suitable child pages to include...
[ "When", "rendering", "pages", "in", "a", "menu", "template", "a", "has_children_in_menu", "attribute", "is", "added", "to", "each", "page", "letting", "template", "developers", "know", "whether", "or", "not", "the", "item", "has", "a", "submenu", "that", "must...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/pages.py#L67-L80
17,542
rkhleics/wagtailmenus
wagtailmenus/models/pages.py
MenuPageMixin.get_text_for_repeated_menu_item
def get_text_for_repeated_menu_item( self, request=None, current_site=None, original_menu_tag='', **kwargs ): """Return the a string to use as 'text' for this page when it is being included as a 'repeated' menu item in a menu. You might want to override this method if you're creating...
python
def get_text_for_repeated_menu_item( self, request=None, current_site=None, original_menu_tag='', **kwargs ): """Return the a string to use as 'text' for this page when it is being included as a 'repeated' menu item in a menu. You might want to override this method if you're creating...
[ "def", "get_text_for_repeated_menu_item", "(", "self", ",", "request", "=", "None", ",", "current_site", "=", "None", ",", "original_menu_tag", "=", "''", ",", "*", "*", "kwargs", ")", ":", "source_field_name", "=", "settings", ".", "PAGE_FIELD_FOR_MENU_ITEM_TEXT"...
Return the a string to use as 'text' for this page when it is being included as a 'repeated' menu item in a menu. You might want to override this method if you're creating a multilingual site and you have different translations of 'repeated_item_text' that you wish to surface.
[ "Return", "the", "a", "string", "to", "use", "as", "text", "for", "this", "page", "when", "it", "is", "being", "included", "as", "a", "repeated", "menu", "item", "in", "a", "menu", ".", "You", "might", "want", "to", "override", "this", "method", "if", ...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/pages.py#L82-L93
17,543
rkhleics/wagtailmenus
wagtailmenus/models/pages.py
MenuPageMixin.get_repeated_menu_item
def get_repeated_menu_item( self, current_page, current_site, apply_active_classes, original_menu_tag, request=None, use_absolute_page_urls=False, ): """Return something that can be used to display a 'repeated' menu item for this specific page.""" menuitem = copy(self) ...
python
def get_repeated_menu_item( self, current_page, current_site, apply_active_classes, original_menu_tag, request=None, use_absolute_page_urls=False, ): """Return something that can be used to display a 'repeated' menu item for this specific page.""" menuitem = copy(self) ...
[ "def", "get_repeated_menu_item", "(", "self", ",", "current_page", ",", "current_site", ",", "apply_active_classes", ",", "original_menu_tag", ",", "request", "=", "None", ",", "use_absolute_page_urls", "=", "False", ",", ")", ":", "menuitem", "=", "copy", "(", ...
Return something that can be used to display a 'repeated' menu item for this specific page.
[ "Return", "something", "that", "can", "be", "used", "to", "display", "a", "repeated", "menu", "item", "for", "this", "specific", "page", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/pages.py#L95-L126
17,544
rkhleics/wagtailmenus
wagtailmenus/models/pages.py
AbstractLinkPage.menu_text
def menu_text(self, request=None): """Return a string to use as link text when this page appears in menus.""" source_field_name = settings.PAGE_FIELD_FOR_MENU_ITEM_TEXT if( source_field_name != 'menu_text' and hasattr(self, source_field_name) ): ...
python
def menu_text(self, request=None): """Return a string to use as link text when this page appears in menus.""" source_field_name = settings.PAGE_FIELD_FOR_MENU_ITEM_TEXT if( source_field_name != 'menu_text' and hasattr(self, source_field_name) ): ...
[ "def", "menu_text", "(", "self", ",", "request", "=", "None", ")", ":", "source_field_name", "=", "settings", ".", "PAGE_FIELD_FOR_MENU_ITEM_TEXT", "if", "(", "source_field_name", "!=", "'menu_text'", "and", "hasattr", "(", "self", ",", "source_field_name", ")", ...
Return a string to use as link text when this page appears in menus.
[ "Return", "a", "string", "to", "use", "as", "link", "text", "when", "this", "page", "appears", "in", "menus", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/pages.py#L184-L193
17,545
rkhleics/wagtailmenus
wagtailmenus/models/pages.py
AbstractLinkPage.link_page_is_suitable_for_display
def link_page_is_suitable_for_display( self, request=None, current_site=None, menu_instance=None, original_menu_tag='' ): """ Like menu items, link pages linking to pages should only be included in menus when the target page is live and is itself configured to appear ...
python
def link_page_is_suitable_for_display( self, request=None, current_site=None, menu_instance=None, original_menu_tag='' ): """ Like menu items, link pages linking to pages should only be included in menus when the target page is live and is itself configured to appear ...
[ "def", "link_page_is_suitable_for_display", "(", "self", ",", "request", "=", "None", ",", "current_site", "=", "None", ",", "menu_instance", "=", "None", ",", "original_menu_tag", "=", "''", ")", ":", "if", "self", ".", "link_page", ":", "if", "(", "not", ...
Like menu items, link pages linking to pages should only be included in menus when the target page is live and is itself configured to appear in menus. Returns a boolean indicating as much
[ "Like", "menu", "items", "link", "pages", "linking", "to", "pages", "should", "only", "be", "included", "in", "menus", "when", "the", "target", "page", "is", "live", "and", "is", "itself", "configured", "to", "appear", "in", "menus", ".", "Returns", "a", ...
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/pages.py#L217-L233
17,546
rkhleics/wagtailmenus
wagtailmenus/models/pages.py
AbstractLinkPage.show_in_menus_custom
def show_in_menus_custom(self, request=None, current_site=None, menu_instance=None, original_menu_tag=''): """ Return a boolean indicating whether this page should be included in menus being rendered. """ if not self.show_in_menus: return ...
python
def show_in_menus_custom(self, request=None, current_site=None, menu_instance=None, original_menu_tag=''): """ Return a boolean indicating whether this page should be included in menus being rendered. """ if not self.show_in_menus: return ...
[ "def", "show_in_menus_custom", "(", "self", ",", "request", "=", "None", ",", "current_site", "=", "None", ",", "menu_instance", "=", "None", ",", "original_menu_tag", "=", "''", ")", ":", "if", "not", "self", ".", "show_in_menus", ":", "return", "False", ...
Return a boolean indicating whether this page should be included in menus being rendered.
[ "Return", "a", "boolean", "indicating", "whether", "this", "page", "should", "be", "included", "in", "menus", "being", "rendered", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/models/pages.py#L235-L245
17,547
rkhleics/wagtailmenus
wagtailmenus/utils/inspection.py
accepts_kwarg
def accepts_kwarg(func, kwarg): """ Determine whether the callable `func` has a signature that accepts the keyword argument `kwarg` """ signature = inspect.signature(func) try: signature.bind_partial(**{kwarg: None}) return True except TypeError: return False
python
def accepts_kwarg(func, kwarg): """ Determine whether the callable `func` has a signature that accepts the keyword argument `kwarg` """ signature = inspect.signature(func) try: signature.bind_partial(**{kwarg: None}) return True except TypeError: return False
[ "def", "accepts_kwarg", "(", "func", ",", "kwarg", ")", ":", "signature", "=", "inspect", ".", "signature", "(", "func", ")", "try", ":", "signature", ".", "bind_partial", "(", "*", "*", "{", "kwarg", ":", "None", "}", ")", "return", "True", "except", ...
Determine whether the callable `func` has a signature that accepts the keyword argument `kwarg`
[ "Determine", "whether", "the", "callable", "func", "has", "a", "signature", "that", "accepts", "the", "keyword", "argument", "kwarg" ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/utils/inspection.py#L10-L20
17,548
rkhleics/wagtailmenus
wagtailmenus/templatetags/menu_tags.py
section_menu
def section_menu( context, show_section_root=True, show_multiple_levels=True, apply_active_classes=True, allow_repeating_parents=True, max_levels=settings.DEFAULT_SECTION_MENU_MAX_LEVELS, template='', sub_menu_template='', sub_menu_templates=None, use_specific=settings.DEFAULT_SECTION_MENU_USE_SPECI...
python
def section_menu( context, show_section_root=True, show_multiple_levels=True, apply_active_classes=True, allow_repeating_parents=True, max_levels=settings.DEFAULT_SECTION_MENU_MAX_LEVELS, template='', sub_menu_template='', sub_menu_templates=None, use_specific=settings.DEFAULT_SECTION_MENU_USE_SPECI...
[ "def", "section_menu", "(", "context", ",", "show_section_root", "=", "True", ",", "show_multiple_levels", "=", "True", ",", "apply_active_classes", "=", "True", ",", "allow_repeating_parents", "=", "True", ",", "max_levels", "=", "settings", ".", "DEFAULT_SECTION_M...
Render a section menu for the current section.
[ "Render", "a", "section", "menu", "for", "the", "current", "section", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/templatetags/menu_tags.py#L84-L113
17,549
rkhleics/wagtailmenus
wagtailmenus/templatetags/menu_tags.py
sub_menu
def sub_menu( context, menuitem_or_page, use_specific=None, allow_repeating_parents=None, apply_active_classes=None, template='', use_absolute_page_urls=None, add_sub_menus_inline=None, **kwargs ): """ Retrieve the children pages for the `menuitem_or_page` provided, turn them into menu items, an...
python
def sub_menu( context, menuitem_or_page, use_specific=None, allow_repeating_parents=None, apply_active_classes=None, template='', use_absolute_page_urls=None, add_sub_menus_inline=None, **kwargs ): """ Retrieve the children pages for the `menuitem_or_page` provided, turn them into menu items, an...
[ "def", "sub_menu", "(", "context", ",", "menuitem_or_page", ",", "use_specific", "=", "None", ",", "allow_repeating_parents", "=", "None", ",", "apply_active_classes", "=", "None", ",", "template", "=", "''", ",", "use_absolute_page_urls", "=", "None", ",", "add...
Retrieve the children pages for the `menuitem_or_page` provided, turn them into menu items, and render them to a template.
[ "Retrieve", "the", "children", "pages", "for", "the", "menuitem_or_page", "provided", "turn", "them", "into", "menu", "items", "and", "render", "them", "to", "a", "template", "." ]
a41f240bed0d362e0d4dd4ef04a230f2b1827a93
https://github.com/rkhleics/wagtailmenus/blob/a41f240bed0d362e0d4dd4ef04a230f2b1827a93/wagtailmenus/templatetags/menu_tags.py#L147-L200
17,550
opentracing-contrib/python-flask
flask_opentracing/tracing.py
FlaskTracing.trace
def trace(self, *attributes): """ Function decorator that traces functions NOTE: Must be placed after the @app.route decorator @param attributes any number of flask.Request attributes (strings) to be set as tags on the created span """ def decorator(f): ...
python
def trace(self, *attributes): """ Function decorator that traces functions NOTE: Must be placed after the @app.route decorator @param attributes any number of flask.Request attributes (strings) to be set as tags on the created span """ def decorator(f): ...
[ "def", "trace", "(", "self", ",", "*", "attributes", ")", ":", "def", "decorator", "(", "f", ")", ":", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "self", ".", "_trace_all_requests", ":", "return", "f", "(", "*", ...
Function decorator that traces functions NOTE: Must be placed after the @app.route decorator @param attributes any number of flask.Request attributes (strings) to be set as tags on the created span
[ "Function", "decorator", "that", "traces", "functions" ]
74bfe8bcd00eee9ce75a15c1634fda4c5d5f26ca
https://github.com/opentracing-contrib/python-flask/blob/74bfe8bcd00eee9ce75a15c1634fda4c5d5f26ca/flask_opentracing/tracing.py#L66-L93
17,551
opentracing-contrib/python-flask
flask_opentracing/tracing.py
FlaskTracing.get_span
def get_span(self, request=None): """ Returns the span tracing `request`, or the current request if `request==None`. If there is no such span, get_span returns None. @param request the request to get the span from """ if request is None and stack.top: ...
python
def get_span(self, request=None): """ Returns the span tracing `request`, or the current request if `request==None`. If there is no such span, get_span returns None. @param request the request to get the span from """ if request is None and stack.top: ...
[ "def", "get_span", "(", "self", ",", "request", "=", "None", ")", ":", "if", "request", "is", "None", "and", "stack", ".", "top", ":", "request", "=", "stack", ".", "top", ".", "request", "scope", "=", "self", ".", "_current_scopes", ".", "get", "(",...
Returns the span tracing `request`, or the current request if `request==None`. If there is no such span, get_span returns None. @param request the request to get the span from
[ "Returns", "the", "span", "tracing", "request", "or", "the", "current", "request", "if", "request", "==", "None", "." ]
74bfe8bcd00eee9ce75a15c1634fda4c5d5f26ca
https://github.com/opentracing-contrib/python-flask/blob/74bfe8bcd00eee9ce75a15c1634fda4c5d5f26ca/flask_opentracing/tracing.py#L95-L108
17,552
rsinger86/django-lifecycle
django_lifecycle/__init__.py
LifecycleModelMixin.initial_value
def initial_value(self, field_name: str = None): """ Get initial value of field when model was instantiated. """ if self._meta.get_field(field_name).get_internal_type() == 'ForeignKey': if not field_name.endswith('_id'): field_name = field_name+'_id' ...
python
def initial_value(self, field_name: str = None): """ Get initial value of field when model was instantiated. """ if self._meta.get_field(field_name).get_internal_type() == 'ForeignKey': if not field_name.endswith('_id'): field_name = field_name+'_id' ...
[ "def", "initial_value", "(", "self", ",", "field_name", ":", "str", "=", "None", ")", ":", "if", "self", ".", "_meta", ".", "get_field", "(", "field_name", ")", ".", "get_internal_type", "(", ")", "==", "'ForeignKey'", ":", "if", "not", "field_name", "."...
Get initial value of field when model was instantiated.
[ "Get", "initial", "value", "of", "field", "when", "model", "was", "instantiated", "." ]
2196908ef0e242e52aab5bfaa3d337930700c106
https://github.com/rsinger86/django-lifecycle/blob/2196908ef0e242e52aab5bfaa3d337930700c106/django_lifecycle/__init__.py#L94-L107
17,553
rsinger86/django-lifecycle
django_lifecycle/__init__.py
LifecycleModelMixin.has_changed
def has_changed(self, field_name: str = None) -> bool: """ Check if a field has changed since the model was instantiated. """ changed = self._diff_with_initial.keys() if self._meta.get_field(field_name).get_internal_type() == 'ForeignKey': if not field_name.endswith(...
python
def has_changed(self, field_name: str = None) -> bool: """ Check if a field has changed since the model was instantiated. """ changed = self._diff_with_initial.keys() if self._meta.get_field(field_name).get_internal_type() == 'ForeignKey': if not field_name.endswith(...
[ "def", "has_changed", "(", "self", ",", "field_name", ":", "str", "=", "None", ")", "->", "bool", ":", "changed", "=", "self", ".", "_diff_with_initial", ".", "keys", "(", ")", "if", "self", ".", "_meta", ".", "get_field", "(", "field_name", ")", ".", ...
Check if a field has changed since the model was instantiated.
[ "Check", "if", "a", "field", "has", "changed", "since", "the", "model", "was", "instantiated", "." ]
2196908ef0e242e52aab5bfaa3d337930700c106
https://github.com/rsinger86/django-lifecycle/blob/2196908ef0e242e52aab5bfaa3d337930700c106/django_lifecycle/__init__.py#L109-L122
17,554
rsinger86/django-lifecycle
django_lifecycle/__init__.py
LifecycleModelMixin._descriptor_names
def _descriptor_names(self): """ Attributes which are Django descriptors. These represent a field which is a one-to-many or many-to-many relationship that is potentially defined in another model, and doesn't otherwise appear as a field on this model. """ descript...
python
def _descriptor_names(self): """ Attributes which are Django descriptors. These represent a field which is a one-to-many or many-to-many relationship that is potentially defined in another model, and doesn't otherwise appear as a field on this model. """ descript...
[ "def", "_descriptor_names", "(", "self", ")", ":", "descriptor_names", "=", "[", "]", "for", "name", "in", "dir", "(", "self", ")", ":", "try", ":", "attr", "=", "getattr", "(", "type", "(", "self", ")", ",", "name", ")", "if", "isinstance", "(", "...
Attributes which are Django descriptors. These represent a field which is a one-to-many or many-to-many relationship that is potentially defined in another model, and doesn't otherwise appear as a field on this model.
[ "Attributes", "which", "are", "Django", "descriptors", ".", "These", "represent", "a", "field", "which", "is", "a", "one", "-", "to", "-", "many", "or", "many", "-", "to", "-", "many", "relationship", "that", "is", "potentially", "defined", "in", "another"...
2196908ef0e242e52aab5bfaa3d337930700c106
https://github.com/rsinger86/django-lifecycle/blob/2196908ef0e242e52aab5bfaa3d337930700c106/django_lifecycle/__init__.py#L181-L201
17,555
rsinger86/django-lifecycle
django_lifecycle/__init__.py
LifecycleModelMixin._run_hooked_methods
def _run_hooked_methods(self, hook: str): """ Iterate through decorated methods to find those that should be triggered by the current hook. If conditions exist, check them before running otherwise go ahead and run. """ for method in self._potentially_hooked_me...
python
def _run_hooked_methods(self, hook: str): """ Iterate through decorated methods to find those that should be triggered by the current hook. If conditions exist, check them before running otherwise go ahead and run. """ for method in self._potentially_hooked_me...
[ "def", "_run_hooked_methods", "(", "self", ",", "hook", ":", "str", ")", ":", "for", "method", "in", "self", ".", "_potentially_hooked_methods", ":", "for", "callback_specs", "in", "method", ".", "_hooked", ":", "if", "callback_specs", "[", "'hook'", "]", "!...
Iterate through decorated methods to find those that should be triggered by the current hook. If conditions exist, check them before running otherwise go ahead and run.
[ "Iterate", "through", "decorated", "methods", "to", "find", "those", "that", "should", "be", "triggered", "by", "the", "current", "hook", ".", "If", "conditions", "exist", "check", "them", "before", "running", "otherwise", "go", "ahead", "and", "run", "." ]
2196908ef0e242e52aab5bfaa3d337930700c106
https://github.com/rsinger86/django-lifecycle/blob/2196908ef0e242e52aab5bfaa3d337930700c106/django_lifecycle/__init__.py#L228-L245
17,556
llimllib/limbo
limbo/limbo.py
loop
def loop(server, test_loop=None): """Run the main loop server is a limbo Server object test_loop, if present, is a number of times to run the loop """ try: loops_without_activity = 0 while test_loop is None or test_loop > 0: start = time.time() loops_without_...
python
def loop(server, test_loop=None): """Run the main loop server is a limbo Server object test_loop, if present, is a number of times to run the loop """ try: loops_without_activity = 0 while test_loop is None or test_loop > 0: start = time.time() loops_without_...
[ "def", "loop", "(", "server", ",", "test_loop", "=", "None", ")", ":", "try", ":", "loops_without_activity", "=", "0", "while", "test_loop", "is", "None", "or", "test_loop", ">", "0", ":", "start", "=", "time", ".", "time", "(", ")", "loops_without_activ...
Run the main loop server is a limbo Server object test_loop, if present, is a number of times to run the loop
[ "Run", "the", "main", "loop" ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/limbo.py#L189-L258
17,557
llimllib/limbo
limbo/slack.py
SlackClient.post_message
def post_message(self, channel_id, message, **kwargs): """ Send a message using the slack Event API. Event messages should be used for more complex messages. See https://api.slack.com/methods/chat.postMessage for details on arguments can be included with your message. W...
python
def post_message(self, channel_id, message, **kwargs): """ Send a message using the slack Event API. Event messages should be used for more complex messages. See https://api.slack.com/methods/chat.postMessage for details on arguments can be included with your message. W...
[ "def", "post_message", "(", "self", ",", "channel_id", ",", "message", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "\"post_data\"", ":", "{", "\"text\"", ":", "message", ",", "\"channel\"", ":", "channel_id", ",", "}", "}", "params", "[", "\...
Send a message using the slack Event API. Event messages should be used for more complex messages. See https://api.slack.com/methods/chat.postMessage for details on arguments can be included with your message. When using the post_message API, to have your message look like it's sent fr...
[ "Send", "a", "message", "using", "the", "slack", "Event", "API", "." ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/slack.py#L99-L119
17,558
llimllib/limbo
limbo/slack.py
SlackClient.post_reaction
def post_reaction(self, channel_id, timestamp, reaction_name, **kwargs): """ Send a reaction to a message using slack Event API """ params = { "post_data": { "name": reaction_name, "channel": channel_id, "timestamp": timestamp, ...
python
def post_reaction(self, channel_id, timestamp, reaction_name, **kwargs): """ Send a reaction to a message using slack Event API """ params = { "post_data": { "name": reaction_name, "channel": channel_id, "timestamp": timestamp, ...
[ "def", "post_reaction", "(", "self", ",", "channel_id", ",", "timestamp", ",", "reaction_name", ",", "*", "*", "kwargs", ")", ":", "params", "=", "{", "\"post_data\"", ":", "{", "\"name\"", ":", "reaction_name", ",", "\"channel\"", ":", "channel_id", ",", ...
Send a reaction to a message using slack Event API
[ "Send", "a", "reaction", "to", "a", "message", "using", "slack", "Event", "API" ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/slack.py#L121-L134
17,559
llimllib/limbo
limbo/slack.py
SlackClient.get_all
def get_all(self, api_method, collection_name, **kwargs): """ Return all objects in an api_method, handle pagination, and pass kwargs on to the method being called. For example, "users.list" returns an object like: { "members": [{<member_obj>}, {<member_obj_2>}], ...
python
def get_all(self, api_method, collection_name, **kwargs): """ Return all objects in an api_method, handle pagination, and pass kwargs on to the method being called. For example, "users.list" returns an object like: { "members": [{<member_obj>}, {<member_obj_2>}], ...
[ "def", "get_all", "(", "self", ",", "api_method", ",", "collection_name", ",", "*", "*", "kwargs", ")", ":", "objs", "=", "[", "]", "limit", "=", "250", "# if you don't provide a limit, the slack API won't return a cursor to you", "page", "=", "json", ".", "loads"...
Return all objects in an api_method, handle pagination, and pass kwargs on to the method being called. For example, "users.list" returns an object like: { "members": [{<member_obj>}, {<member_obj_2>}], "response_metadata": { "next_cursor": "cursor_id" ...
[ "Return", "all", "objects", "in", "an", "api_method", "handle", "pagination", "and", "pass", "kwargs", "on", "to", "the", "method", "being", "called", "." ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/slack.py#L182-L225
17,560
llimllib/limbo
limbo/plugins/poll.py
poll
def poll(poll, msg, server): """Given a question and answers, present a poll""" poll = remove_smart_quotes(poll.replace(u"\u2014", u"--")) try: args = ARGPARSE.parse_args(shlex.split(poll)).poll except ValueError: return ERROR_INVALID_FORMAT if not 2 < len(args) < len(POLL_EMOJIS) ...
python
def poll(poll, msg, server): """Given a question and answers, present a poll""" poll = remove_smart_quotes(poll.replace(u"\u2014", u"--")) try: args = ARGPARSE.parse_args(shlex.split(poll)).poll except ValueError: return ERROR_INVALID_FORMAT if not 2 < len(args) < len(POLL_EMOJIS) ...
[ "def", "poll", "(", "poll", ",", "msg", ",", "server", ")", ":", "poll", "=", "remove_smart_quotes", "(", "poll", ".", "replace", "(", "u\"\\u2014\"", ",", "u\"--\"", ")", ")", "try", ":", "args", "=", "ARGPARSE", ".", "parse_args", "(", "shlex", ".", ...
Given a question and answers, present a poll
[ "Given", "a", "question", "and", "answers", "present", "a", "poll" ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/plugins/poll.py#L28-L50
17,561
llimllib/limbo
limbo/plugins/emoji.py
emoji_list
def emoji_list(server, n=1): """return a list of `n` random emoji""" global EMOJI if EMOJI is None: EMOJI = EmojiCache(server) return EMOJI.get(n)
python
def emoji_list(server, n=1): """return a list of `n` random emoji""" global EMOJI if EMOJI is None: EMOJI = EmojiCache(server) return EMOJI.get(n)
[ "def", "emoji_list", "(", "server", ",", "n", "=", "1", ")", ":", "global", "EMOJI", "if", "EMOJI", "is", "None", ":", "EMOJI", "=", "EmojiCache", "(", "server", ")", "return", "EMOJI", ".", "get", "(", "n", ")" ]
return a list of `n` random emoji
[ "return", "a", "list", "of", "n", "random", "emoji" ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/plugins/emoji.py#L46-L51
17,562
llimllib/limbo
limbo/plugins/wiki.py
wiki
def wiki(searchterm): """return the top wiki search result for the term""" searchterm = quote(searchterm) url = "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&format=json" url = url.format(searchterm) result = requests.get(url).json() pages = result["query"]["search...
python
def wiki(searchterm): """return the top wiki search result for the term""" searchterm = quote(searchterm) url = "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&format=json" url = url.format(searchterm) result = requests.get(url).json() pages = result["query"]["search...
[ "def", "wiki", "(", "searchterm", ")", ":", "searchterm", "=", "quote", "(", "searchterm", ")", "url", "=", "\"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&format=json\"", "url", "=", "url", ".", "format", "(", "searchterm", ")", "result", ...
return the top wiki search result for the term
[ "return", "the", "top", "wiki", "search", "result", "for", "the", "term" ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/plugins/wiki.py#L12-L39
17,563
llimllib/limbo
limbo/plugins/gif.py
gif
def gif(search, unsafe=False): """given a search string, return a gif URL via google search""" searchb = quote(search.encode("utf8")) safe = "&safe=" if unsafe else "&safe=active" searchurl = "https://www.google.com/search?tbs=itp:animated&tbm=isch&q={0}{1}" \ .format(searchb, safe) # this...
python
def gif(search, unsafe=False): """given a search string, return a gif URL via google search""" searchb = quote(search.encode("utf8")) safe = "&safe=" if unsafe else "&safe=active" searchurl = "https://www.google.com/search?tbs=itp:animated&tbm=isch&q={0}{1}" \ .format(searchb, safe) # this...
[ "def", "gif", "(", "search", ",", "unsafe", "=", "False", ")", ":", "searchb", "=", "quote", "(", "search", ".", "encode", "(", "\"utf8\"", ")", ")", "safe", "=", "\"&safe=\"", "if", "unsafe", "else", "\"&safe=active\"", "searchurl", "=", "\"https://www.go...
given a search string, return a gif URL via google search
[ "given", "a", "search", "string", "return", "a", "gif", "URL", "via", "google", "search" ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/plugins/gif.py#L19-L38
17,564
llimllib/limbo
limbo/plugins/gif.py
on_message
def on_message(msg, server): """handle a message and return an gif""" text = msg.get("text", "") match = re.findall(r"!gif (.*)", text) if not match: return res = gif(match[0]) if not res: return attachment = { "fallback": match[0], "title": match[0], ...
python
def on_message(msg, server): """handle a message and return an gif""" text = msg.get("text", "") match = re.findall(r"!gif (.*)", text) if not match: return res = gif(match[0]) if not res: return attachment = { "fallback": match[0], "title": match[0], ...
[ "def", "on_message", "(", "msg", ",", "server", ")", ":", "text", "=", "msg", ".", "get", "(", "\"text\"", ",", "\"\"", ")", "match", "=", "re", ".", "findall", "(", "r\"!gif (.*)\"", ",", "text", ")", "if", "not", "match", ":", "return", "res", "=...
handle a message and return an gif
[ "handle", "a", "message", "and", "return", "an", "gif" ]
f0980f20f733b670debcae454b167da32c57a044
https://github.com/llimllib/limbo/blob/f0980f20f733b670debcae454b167da32c57a044/limbo/plugins/gif.py#L41-L62
17,565
btel/svg_utils
src/svgutils/transform.py
fromfile
def fromfile(fname): """Open SVG figure from file. Parameters ---------- fname : str name of the SVG file Returns ------- SVGFigure newly created :py:class:`SVGFigure` initialised with the file content """ fig = SVGFigure() with open(fname) as fid: svg_f...
python
def fromfile(fname): """Open SVG figure from file. Parameters ---------- fname : str name of the SVG file Returns ------- SVGFigure newly created :py:class:`SVGFigure` initialised with the file content """ fig = SVGFigure() with open(fname) as fid: svg_f...
[ "def", "fromfile", "(", "fname", ")", ":", "fig", "=", "SVGFigure", "(", ")", "with", "open", "(", "fname", ")", "as", "fid", ":", "svg_file", "=", "etree", ".", "parse", "(", "fid", ")", "fig", ".", "root", "=", "svg_file", ".", "getroot", "(", ...
Open SVG figure from file. Parameters ---------- fname : str name of the SVG file Returns ------- SVGFigure newly created :py:class:`SVGFigure` initialised with the file content
[ "Open", "SVG", "figure", "from", "file", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L294-L312
17,566
btel/svg_utils
src/svgutils/transform.py
fromstring
def fromstring(text): """Create a SVG figure from a string. Parameters ---------- text : str string representing the SVG content. Must be valid SVG. Returns ------- SVGFigure newly created :py:class:`SVGFigure` initialised with the string content. """ fig = ...
python
def fromstring(text): """Create a SVG figure from a string. Parameters ---------- text : str string representing the SVG content. Must be valid SVG. Returns ------- SVGFigure newly created :py:class:`SVGFigure` initialised with the string content. """ fig = ...
[ "def", "fromstring", "(", "text", ")", ":", "fig", "=", "SVGFigure", "(", ")", "svg", "=", "etree", ".", "fromstring", "(", "text", ".", "encode", "(", ")", ")", "fig", ".", "root", "=", "svg", "return", "fig" ]
Create a SVG figure from a string. Parameters ---------- text : str string representing the SVG content. Must be valid SVG. Returns ------- SVGFigure newly created :py:class:`SVGFigure` initialised with the string content.
[ "Create", "a", "SVG", "figure", "from", "a", "string", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L315-L334
17,567
btel/svg_utils
src/svgutils/transform.py
from_mpl
def from_mpl(fig, savefig_kw=None): """Create a SVG figure from a ``matplotlib`` figure. Parameters ---------- fig : matplotlib.Figure instance savefig_kw : dict keyword arguments to be passed to matplotlib's `savefig` Returns ------- SVGFigure newly create...
python
def from_mpl(fig, savefig_kw=None): """Create a SVG figure from a ``matplotlib`` figure. Parameters ---------- fig : matplotlib.Figure instance savefig_kw : dict keyword arguments to be passed to matplotlib's `savefig` Returns ------- SVGFigure newly create...
[ "def", "from_mpl", "(", "fig", ",", "savefig_kw", "=", "None", ")", ":", "fid", "=", "StringIO", "(", ")", "if", "savefig_kw", "is", "None", ":", "savefig_kw", "=", "{", "}", "try", ":", "fig", ".", "savefig", "(", "fid", ",", "format", "=", "'svg'...
Create a SVG figure from a ``matplotlib`` figure. Parameters ---------- fig : matplotlib.Figure instance savefig_kw : dict keyword arguments to be passed to matplotlib's `savefig` Returns ------- SVGFigure newly created :py:class:`SVGFigure` initialised with th...
[ "Create", "a", "SVG", "figure", "from", "a", "matplotlib", "figure", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L337-L390
17,568
btel/svg_utils
src/svgutils/transform.py
FigureElement.moveto
def moveto(self, x, y, scale=1): """Move and scale element. Parameters ---------- x, y : float displacement in x and y coordinates in user units ('px'). scale : float scaling factor. To scale down scale < 1, scale up scale > 1. For no scal...
python
def moveto(self, x, y, scale=1): """Move and scale element. Parameters ---------- x, y : float displacement in x and y coordinates in user units ('px'). scale : float scaling factor. To scale down scale < 1, scale up scale > 1. For no scal...
[ "def", "moveto", "(", "self", ",", "x", ",", "y", ",", "scale", "=", "1", ")", ":", "self", ".", "root", ".", "set", "(", "\"transform\"", ",", "\"translate(%s, %s) scale(%s) %s\"", "%", "(", "x", ",", "y", ",", "scale", ",", "self", ".", "root", "...
Move and scale element. Parameters ---------- x, y : float displacement in x and y coordinates in user units ('px'). scale : float scaling factor. To scale down scale < 1, scale up scale > 1. For no scaling scale = 1.
[ "Move", "and", "scale", "element", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L24-L36
17,569
btel/svg_utils
src/svgutils/transform.py
FigureElement.rotate
def rotate(self, angle, x=0, y=0): """Rotate element by given angle around given pivot. Parameters ---------- angle : float rotation angle in degrees x, y : float pivot coordinates in user coordinate system (defaults to top-left corner of the ...
python
def rotate(self, angle, x=0, y=0): """Rotate element by given angle around given pivot. Parameters ---------- angle : float rotation angle in degrees x, y : float pivot coordinates in user coordinate system (defaults to top-left corner of the ...
[ "def", "rotate", "(", "self", ",", "angle", ",", "x", "=", "0", ",", "y", "=", "0", ")", ":", "self", ".", "root", ".", "set", "(", "\"transform\"", ",", "\"%s rotate(%f %f %f)\"", "%", "(", "self", ".", "root", ".", "get", "(", "\"transform\"", ")...
Rotate element by given angle around given pivot. Parameters ---------- angle : float rotation angle in degrees x, y : float pivot coordinates in user coordinate system (defaults to top-left corner of the figure)
[ "Rotate", "element", "by", "given", "angle", "around", "given", "pivot", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L38-L50
17,570
btel/svg_utils
src/svgutils/transform.py
FigureElement.skew
def skew(self, x=0, y=0): """Skew the element by x and y degrees Convenience function which calls skew_x and skew_y Parameters ---------- x,y : float, float skew angle in degrees (default 0) If an x/y angle is given as zero degrees, that transformation i...
python
def skew(self, x=0, y=0): """Skew the element by x and y degrees Convenience function which calls skew_x and skew_y Parameters ---------- x,y : float, float skew angle in degrees (default 0) If an x/y angle is given as zero degrees, that transformation i...
[ "def", "skew", "(", "self", ",", "x", "=", "0", ",", "y", "=", "0", ")", ":", "if", "x", "is", "not", "0", ":", "self", ".", "skew_x", "(", "x", ")", "if", "y", "is", "not", "0", ":", "self", ".", "skew_y", "(", "y", ")", "return", "self"...
Skew the element by x and y degrees Convenience function which calls skew_x and skew_y Parameters ---------- x,y : float, float skew angle in degrees (default 0) If an x/y angle is given as zero degrees, that transformation is omitted.
[ "Skew", "the", "element", "by", "x", "and", "y", "degrees", "Convenience", "function", "which", "calls", "skew_x", "and", "skew_y" ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L52-L68
17,571
btel/svg_utils
src/svgutils/transform.py
FigureElement.skew_x
def skew_x(self, x): """Skew element along the x-axis by the given angle. Parameters ---------- x : float x-axis skew angle in degrees """ self.root.set("transform", "%s skewX(%f)" % (self.root.get("transform") or '', x)) return ...
python
def skew_x(self, x): """Skew element along the x-axis by the given angle. Parameters ---------- x : float x-axis skew angle in degrees """ self.root.set("transform", "%s skewX(%f)" % (self.root.get("transform") or '', x)) return ...
[ "def", "skew_x", "(", "self", ",", "x", ")", ":", "self", ".", "root", ".", "set", "(", "\"transform\"", ",", "\"%s skewX(%f)\"", "%", "(", "self", ".", "root", ".", "get", "(", "\"transform\"", ")", "or", "''", ",", "x", ")", ")", "return", "self"...
Skew element along the x-axis by the given angle. Parameters ---------- x : float x-axis skew angle in degrees
[ "Skew", "element", "along", "the", "x", "-", "axis", "by", "the", "given", "angle", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L70-L80
17,572
btel/svg_utils
src/svgutils/transform.py
FigureElement.skew_y
def skew_y(self, y): """Skew element along the y-axis by the given angle. Parameters ---------- y : float y-axis skew angle in degrees """ self.root.set("transform", "%s skewY(%f)" % (self.root.get("transform") or '', y)) return ...
python
def skew_y(self, y): """Skew element along the y-axis by the given angle. Parameters ---------- y : float y-axis skew angle in degrees """ self.root.set("transform", "%s skewY(%f)" % (self.root.get("transform") or '', y)) return ...
[ "def", "skew_y", "(", "self", ",", "y", ")", ":", "self", ".", "root", ".", "set", "(", "\"transform\"", ",", "\"%s skewY(%f)\"", "%", "(", "self", ".", "root", ".", "get", "(", "\"transform\"", ")", "or", "''", ",", "y", ")", ")", "return", "self"...
Skew element along the y-axis by the given angle. Parameters ---------- y : float y-axis skew angle in degrees
[ "Skew", "element", "along", "the", "y", "-", "axis", "by", "the", "given", "angle", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L82-L92
17,573
btel/svg_utils
src/svgutils/transform.py
FigureElement.find_id
def find_id(self, element_id): """Find element by its id. Parameters ---------- element_id : str ID of the element to find Returns ------- FigureElement one of the children element with the given ID.""" find = etree.XPath("//*[@id...
python
def find_id(self, element_id): """Find element by its id. Parameters ---------- element_id : str ID of the element to find Returns ------- FigureElement one of the children element with the given ID.""" find = etree.XPath("//*[@id...
[ "def", "find_id", "(", "self", ",", "element_id", ")", ":", "find", "=", "etree", ".", "XPath", "(", "\"//*[@id=$id]\"", ")", "return", "FigureElement", "(", "find", "(", "self", ".", "root", ",", "id", "=", "element_id", ")", "[", "0", "]", ")" ]
Find element by its id. Parameters ---------- element_id : str ID of the element to find Returns ------- FigureElement one of the children element with the given ID.
[ "Find", "element", "by", "its", "id", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L122-L135
17,574
btel/svg_utils
src/svgutils/transform.py
SVGFigure.append
def append(self, element): """Append new element to the SVG figure""" try: self.root.append(element.root) except AttributeError: self.root.append(GroupElement(element).root)
python
def append(self, element): """Append new element to the SVG figure""" try: self.root.append(element.root) except AttributeError: self.root.append(GroupElement(element).root)
[ "def", "append", "(", "self", ",", "element", ")", ":", "try", ":", "self", ".", "root", ".", "append", "(", "element", ".", "root", ")", "except", "AttributeError", ":", "self", ".", "root", ".", "append", "(", "GroupElement", "(", "element", ")", "...
Append new element to the SVG figure
[ "Append", "new", "element", "to", "the", "SVG", "figure" ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L238-L243
17,575
btel/svg_utils
src/svgutils/transform.py
SVGFigure.getroot
def getroot(self): """Return the root element of the figure. The root element is a group of elements after stripping the toplevel ``<svg>`` tag. Returns ------- GroupElement All elements of the figure without the ``<svg>`` tag. """ if 'class'...
python
def getroot(self): """Return the root element of the figure. The root element is a group of elements after stripping the toplevel ``<svg>`` tag. Returns ------- GroupElement All elements of the figure without the ``<svg>`` tag. """ if 'class'...
[ "def", "getroot", "(", "self", ")", ":", "if", "'class'", "in", "self", ".", "root", ".", "attrib", ":", "attrib", "=", "{", "'class'", ":", "self", ".", "root", ".", "attrib", "[", "'class'", "]", "}", "else", ":", "attrib", "=", "None", "return",...
Return the root element of the figure. The root element is a group of elements after stripping the toplevel ``<svg>`` tag. Returns ------- GroupElement All elements of the figure without the ``<svg>`` tag.
[ "Return", "the", "root", "element", "of", "the", "figure", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L245-L260
17,576
btel/svg_utils
src/svgutils/transform.py
SVGFigure.to_str
def to_str(self): """ Returns a string of the SVG figure. """ return etree.tostring(self.root, xml_declaration=True, standalone=True, pretty_print=True)
python
def to_str(self): """ Returns a string of the SVG figure. """ return etree.tostring(self.root, xml_declaration=True, standalone=True, pretty_print=True)
[ "def", "to_str", "(", "self", ")", ":", "return", "etree", ".", "tostring", "(", "self", ".", "root", ",", "xml_declaration", "=", "True", ",", "standalone", "=", "True", ",", "pretty_print", "=", "True", ")" ]
Returns a string of the SVG figure.
[ "Returns", "a", "string", "of", "the", "SVG", "figure", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L262-L268
17,577
btel/svg_utils
src/svgutils/transform.py
SVGFigure.save
def save(self, fname): """Save figure to a file""" out = etree.tostring(self.root, xml_declaration=True, standalone=True, pretty_print=True) with open(fname, 'wb') as fid: fid.write(out)
python
def save(self, fname): """Save figure to a file""" out = etree.tostring(self.root, xml_declaration=True, standalone=True, pretty_print=True) with open(fname, 'wb') as fid: fid.write(out)
[ "def", "save", "(", "self", ",", "fname", ")", ":", "out", "=", "etree", ".", "tostring", "(", "self", ".", "root", ",", "xml_declaration", "=", "True", ",", "standalone", "=", "True", ",", "pretty_print", "=", "True", ")", "with", "open", "(", "fnam...
Save figure to a file
[ "Save", "figure", "to", "a", "file" ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L270-L276
17,578
btel/svg_utils
src/svgutils/transform.py
SVGFigure.set_size
def set_size(self, size): """Set figure size""" w, h = size self.root.set('width', w) self.root.set('height', h)
python
def set_size(self, size): """Set figure size""" w, h = size self.root.set('width', w) self.root.set('height', h)
[ "def", "set_size", "(", "self", ",", "size", ")", ":", "w", ",", "h", "=", "size", "self", ".", "root", ".", "set", "(", "'width'", ",", "w", ")", "self", ".", "root", ".", "set", "(", "'height'", ",", "h", ")" ]
Set figure size
[ "Set", "figure", "size" ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/transform.py#L287-L291
17,579
btel/svg_utils
src/svgutils/compose.py
Element.find_id
def find_id(self, element_id): """Find a single element with the given ID. Parameters ---------- element_id : str ID of the element to find Returns ------- found element """ element = _transform.FigureElement.find_id(self, element_id)...
python
def find_id(self, element_id): """Find a single element with the given ID. Parameters ---------- element_id : str ID of the element to find Returns ------- found element """ element = _transform.FigureElement.find_id(self, element_id)...
[ "def", "find_id", "(", "self", ",", "element_id", ")", ":", "element", "=", "_transform", ".", "FigureElement", ".", "find_id", "(", "self", ",", "element_id", ")", "return", "Element", "(", "element", ".", "root", ")" ]
Find a single element with the given ID. Parameters ---------- element_id : str ID of the element to find Returns ------- found element
[ "Find", "a", "single", "element", "with", "the", "given", "ID", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/compose.py#L67-L80
17,580
btel/svg_utils
src/svgutils/compose.py
Element.find_ids
def find_ids(self, element_ids): """Find elements with given IDs. Parameters ---------- element_ids : list of strings list of IDs to find Returns ------- a new `Panel` object which contains all the found elements. """ elements = [_tra...
python
def find_ids(self, element_ids): """Find elements with given IDs. Parameters ---------- element_ids : list of strings list of IDs to find Returns ------- a new `Panel` object which contains all the found elements. """ elements = [_tra...
[ "def", "find_ids", "(", "self", ",", "element_ids", ")", ":", "elements", "=", "[", "_transform", ".", "FigureElement", ".", "find_id", "(", "self", ",", "eid", ")", "for", "eid", "in", "element_ids", "]", "return", "Panel", "(", "*", "elements", ")" ]
Find elements with given IDs. Parameters ---------- element_ids : list of strings list of IDs to find Returns ------- a new `Panel` object which contains all the found elements.
[ "Find", "elements", "with", "given", "IDs", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/compose.py#L82-L96
17,581
btel/svg_utils
src/svgutils/compose.py
Figure.save
def save(self, fname): """Save figure to SVG file. Parameters ---------- fname : str Full path to file. """ element = _transform.SVGFigure(self.width, self.height) element.append(self) element.save(os.path.join(CONFIG['figure.save_path'], fnam...
python
def save(self, fname): """Save figure to SVG file. Parameters ---------- fname : str Full path to file. """ element = _transform.SVGFigure(self.width, self.height) element.append(self) element.save(os.path.join(CONFIG['figure.save_path'], fnam...
[ "def", "save", "(", "self", ",", "fname", ")", ":", "element", "=", "_transform", ".", "SVGFigure", "(", "self", ".", "width", ",", "self", ".", "height", ")", "element", ".", "append", "(", "self", ")", "element", ".", "save", "(", "os", ".", "pat...
Save figure to SVG file. Parameters ---------- fname : str Full path to file.
[ "Save", "figure", "to", "SVG", "file", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/compose.py#L292-L302
17,582
btel/svg_utils
src/svgutils/compose.py
Figure.tostr
def tostr(self): """Export SVG as a string""" element = _transform.SVGFigure(self.width, self.height) element.append(self) svgstr = element.to_str() return svgstr
python
def tostr(self): """Export SVG as a string""" element = _transform.SVGFigure(self.width, self.height) element.append(self) svgstr = element.to_str() return svgstr
[ "def", "tostr", "(", "self", ")", ":", "element", "=", "_transform", ".", "SVGFigure", "(", "self", ".", "width", ",", "self", ".", "height", ")", "element", ".", "append", "(", "self", ")", "svgstr", "=", "element", ".", "to_str", "(", ")", "return"...
Export SVG as a string
[ "Export", "SVG", "as", "a", "string" ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/compose.py#L304-L309
17,583
btel/svg_utils
src/svgutils/compose.py
Figure.tile
def tile(self, ncols, nrows): """Automatically tile the panels of the figure. This will re-arranged all elements of the figure (first in the hierarchy) so that they will uniformly cover the figure area. Parameters ---------- ncols, nrows : type The number of...
python
def tile(self, ncols, nrows): """Automatically tile the panels of the figure. This will re-arranged all elements of the figure (first in the hierarchy) so that they will uniformly cover the figure area. Parameters ---------- ncols, nrows : type The number of...
[ "def", "tile", "(", "self", ",", "ncols", ",", "nrows", ")", ":", "dx", "=", "(", "self", ".", "width", "/", "ncols", ")", ".", "to", "(", "'px'", ")", ".", "value", "dy", "=", "(", "self", ".", "height", "/", "nrows", ")", ".", "to", "(", ...
Automatically tile the panels of the figure. This will re-arranged all elements of the figure (first in the hierarchy) so that they will uniformly cover the figure area. Parameters ---------- ncols, nrows : type The number of columns and rows to arange the elements ...
[ "Automatically", "tile", "the", "panels", "of", "the", "figure", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/compose.py#L314-L342
17,584
btel/svg_utils
src/svgutils/compose.py
Unit.to
def to(self, unit): """Convert to a given unit. Parameters ---------- unit : str Name of the unit to convert to. Returns ------- u : Unit new Unit object with the requested unit and computed value. """ u = Unit("0cm") ...
python
def to(self, unit): """Convert to a given unit. Parameters ---------- unit : str Name of the unit to convert to. Returns ------- u : Unit new Unit object with the requested unit and computed value. """ u = Unit("0cm") ...
[ "def", "to", "(", "self", ",", "unit", ")", ":", "u", "=", "Unit", "(", "\"0cm\"", ")", "u", ".", "value", "=", "self", ".", "value", "/", "self", ".", "per_inch", "[", "self", ".", "unit", "]", "*", "self", ".", "per_inch", "[", "unit", "]", ...
Convert to a given unit. Parameters ---------- unit : str Name of the unit to convert to. Returns ------- u : Unit new Unit object with the requested unit and computed value.
[ "Convert", "to", "a", "given", "unit", "." ]
ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3
https://github.com/btel/svg_utils/blob/ee00726ebed1bd97fd496b15b6a8e7f233ebb5e3/src/svgutils/compose.py#L369-L385
17,585
Kozea/cairocffi
cairocffi/__init__.py
dlopen
def dlopen(ffi, *names): """Try various names for the same library, for different platforms.""" for name in names: for lib_name in (name, 'lib' + name): try: path = ctypes.util.find_library(lib_name) lib = ffi.dlopen(path or lib_name) if lib: ...
python
def dlopen(ffi, *names): """Try various names for the same library, for different platforms.""" for name in names: for lib_name in (name, 'lib' + name): try: path = ctypes.util.find_library(lib_name) lib = ffi.dlopen(path or lib_name) if lib: ...
[ "def", "dlopen", "(", "ffi", ",", "*", "names", ")", ":", "for", "name", "in", "names", ":", "for", "lib_name", "in", "(", "name", ",", "'lib'", "+", "name", ")", ":", "try", ":", "path", "=", "ctypes", ".", "util", ".", "find_library", "(", "lib...
Try various names for the same library, for different platforms.
[ "Try", "various", "names", "for", "the", "same", "library", "for", "different", "platforms", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/__init__.py#L25-L36
17,586
Kozea/cairocffi
cairocffi/context.py
Context.set_source_rgba
def set_source_rgba(self, red, green, blue, alpha=1): """Sets the source pattern within this context to a solid color. This color will then be used for any subsequent drawing operation until a new source pattern is set. The color and alpha components are floating point numbers ...
python
def set_source_rgba(self, red, green, blue, alpha=1): """Sets the source pattern within this context to a solid color. This color will then be used for any subsequent drawing operation until a new source pattern is set. The color and alpha components are floating point numbers ...
[ "def", "set_source_rgba", "(", "self", ",", "red", ",", "green", ",", "blue", ",", "alpha", "=", "1", ")", ":", "cairo", ".", "cairo_set_source_rgba", "(", "self", ".", "_pointer", ",", "red", ",", "green", ",", "blue", ",", "alpha", ")", "self", "."...
Sets the source pattern within this context to a solid color. This color will then be used for any subsequent drawing operation until a new source pattern is set. The color and alpha components are floating point numbers in the range 0 to 1. If the values passed in are outside ...
[ "Sets", "the", "source", "pattern", "within", "this", "context", "to", "a", "solid", "color", ".", "This", "color", "will", "then", "be", "used", "for", "any", "subsequent", "drawing", "operation", "until", "a", "new", "source", "pattern", "is", "set", "."...
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L306-L331
17,587
Kozea/cairocffi
cairocffi/context.py
Context.get_dash
def get_dash(self): """Return the current dash pattern. :returns: A ``(dashes, offset)`` tuple of a list and a float. :obj:`dashes` is a list of floats, empty if no dashing is in effect. """ dashes = ffi.new('double[]', cairo.cairo_get_dash_count(sel...
python
def get_dash(self): """Return the current dash pattern. :returns: A ``(dashes, offset)`` tuple of a list and a float. :obj:`dashes` is a list of floats, empty if no dashing is in effect. """ dashes = ffi.new('double[]', cairo.cairo_get_dash_count(sel...
[ "def", "get_dash", "(", "self", ")", ":", "dashes", "=", "ffi", ".", "new", "(", "'double[]'", ",", "cairo", ".", "cairo_get_dash_count", "(", "self", ".", "_pointer", ")", ")", "offset", "=", "ffi", ".", "new", "(", "'double *'", ")", "cairo", ".", ...
Return the current dash pattern. :returns: A ``(dashes, offset)`` tuple of a list and a float. :obj:`dashes` is a list of floats, empty if no dashing is in effect.
[ "Return", "the", "current", "dash", "pattern", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L472-L485
17,588
Kozea/cairocffi
cairocffi/context.py
Context.set_miter_limit
def set_miter_limit(self, limit): """Sets the current miter limit within the cairo context. If the current line join style is set to :obj:`MITER <LINE_JOIN_MITER>` (see :meth:`set_line_join`), the miter limit is used to determine whether the lines should be joined with a bevel i...
python
def set_miter_limit(self, limit): """Sets the current miter limit within the cairo context. If the current line join style is set to :obj:`MITER <LINE_JOIN_MITER>` (see :meth:`set_line_join`), the miter limit is used to determine whether the lines should be joined with a bevel i...
[ "def", "set_miter_limit", "(", "self", ",", "limit", ")", ":", "cairo", ".", "cairo_set_miter_limit", "(", "self", ".", "_pointer", ",", "limit", ")", "self", ".", "_check_status", "(", ")" ]
Sets the current miter limit within the cairo context. If the current line join style is set to :obj:`MITER <LINE_JOIN_MITER>` (see :meth:`set_line_join`), the miter limit is used to determine whether the lines should be joined with a bevel instead of a miter. Cairo divides the ...
[ "Sets", "the", "current", "miter", "limit", "within", "the", "cairo", "context", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L587-L618
17,589
Kozea/cairocffi
cairocffi/context.py
Context.get_current_point
def get_current_point(self): """Return the current point of the current path, which is conceptually the final point reached by the path so far. The current point is returned in the user-space coordinate system. If there is no defined current point or if the context is in an erro...
python
def get_current_point(self): """Return the current point of the current path, which is conceptually the final point reached by the path so far. The current point is returned in the user-space coordinate system. If there is no defined current point or if the context is in an erro...
[ "def", "get_current_point", "(", "self", ")", ":", "# I’d prefer returning None if self.has_current_point() is False", "# But keep (0, 0) for compat with pycairo.", "xy", "=", "ffi", ".", "new", "(", "'double[2]'", ")", "cairo", ".", "cairo_get_current_point", "(", "self", ...
Return the current point of the current path, which is conceptually the final point reached by the path so far. The current point is returned in the user-space coordinate system. If there is no defined current point or if the context is in an error status, ``(0, 0)`` is returned...
[ "Return", "the", "current", "point", "of", "the", "current", "path", "which", "is", "conceptually", "the", "final", "point", "reached", "by", "the", "path", "so", "far", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L850-L898
17,590
Kozea/cairocffi
cairocffi/context.py
Context.copy_path
def copy_path(self): """Return a copy of the current path. :returns: A list of ``(path_operation, coordinates)`` tuples of a :ref:`PATH_OPERATION` string and a tuple of floats coordinates whose content depends on the operation type: * :obj:`M...
python
def copy_path(self): """Return a copy of the current path. :returns: A list of ``(path_operation, coordinates)`` tuples of a :ref:`PATH_OPERATION` string and a tuple of floats coordinates whose content depends on the operation type: * :obj:`M...
[ "def", "copy_path", "(", "self", ")", ":", "path", "=", "cairo", ".", "cairo_copy_path", "(", "self", ".", "_pointer", ")", "result", "=", "list", "(", "_iter_path", "(", "path", ")", ")", "cairo", ".", "cairo_path_destroy", "(", "path", ")", "return", ...
Return a copy of the current path. :returns: A list of ``(path_operation, coordinates)`` tuples of a :ref:`PATH_OPERATION` string and a tuple of floats coordinates whose content depends on the operation type: * :obj:`MOVE_TO <PATH_MOVE_TO>`: 1 point ...
[ "Return", "a", "copy", "of", "the", "current", "path", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1245-L1264
17,591
Kozea/cairocffi
cairocffi/context.py
Context.copy_path_flat
def copy_path_flat(self): """Return a flattened copy of the current path This method is like :meth:`copy_path` except that any curves in the path will be approximated with piecewise-linear approximations, (accurate to within the current tolerance value, see :meth:`set_to...
python
def copy_path_flat(self): """Return a flattened copy of the current path This method is like :meth:`copy_path` except that any curves in the path will be approximated with piecewise-linear approximations, (accurate to within the current tolerance value, see :meth:`set_to...
[ "def", "copy_path_flat", "(", "self", ")", ":", "path", "=", "cairo", ".", "cairo_copy_path_flat", "(", "self", ".", "_pointer", ")", "result", "=", "list", "(", "_iter_path", "(", "path", ")", ")", "cairo", ".", "cairo_path_destroy", "(", "path", ")", "...
Return a flattened copy of the current path This method is like :meth:`copy_path` except that any curves in the path will be approximated with piecewise-linear approximations, (accurate to within the current tolerance value, see :meth:`set_tolerance`). That is, t...
[ "Return", "a", "flattened", "copy", "of", "the", "current", "path" ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1266-L1288
17,592
Kozea/cairocffi
cairocffi/context.py
Context.clip_extents
def clip_extents(self): """Computes a bounding box in user coordinates covering the area inside the current clip. :return: A ``(x1, y1, x2, y2)`` tuple of floats: the left, top, right and bottom of the resulting extents, respectively. """ ext...
python
def clip_extents(self): """Computes a bounding box in user coordinates covering the area inside the current clip. :return: A ``(x1, y1, x2, y2)`` tuple of floats: the left, top, right and bottom of the resulting extents, respectively. """ ext...
[ "def", "clip_extents", "(", "self", ")", ":", "extents", "=", "ffi", ".", "new", "(", "'double[4]'", ")", "cairo", ".", "cairo_clip_extents", "(", "self", ".", "_pointer", ",", "extents", "+", "0", ",", "extents", "+", "1", ",", "extents", "+", "2", ...
Computes a bounding box in user coordinates covering the area inside the current clip. :return: A ``(x1, y1, x2, y2)`` tuple of floats: the left, top, right and bottom of the resulting extents, respectively.
[ "Computes", "a", "bounding", "box", "in", "user", "coordinates", "covering", "the", "area", "inside", "the", "current", "clip", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1629-L1643
17,593
Kozea/cairocffi
cairocffi/context.py
Context.copy_clip_rectangle_list
def copy_clip_rectangle_list(self): """Return the current clip region as a list of rectangles in user coordinates. :return: A list of rectangles, as ``(x, y, width, height)`` tuples of floats. :raises: :exc:`CairoError` if the clip region...
python
def copy_clip_rectangle_list(self): """Return the current clip region as a list of rectangles in user coordinates. :return: A list of rectangles, as ``(x, y, width, height)`` tuples of floats. :raises: :exc:`CairoError` if the clip region...
[ "def", "copy_clip_rectangle_list", "(", "self", ")", ":", "rectangle_list", "=", "cairo", ".", "cairo_copy_clip_rectangle_list", "(", "self", ".", "_pointer", ")", "_check_status", "(", "rectangle_list", ".", "status", ")", "rectangles", "=", "rectangle_list", ".", ...
Return the current clip region as a list of rectangles in user coordinates. :return: A list of rectangles, as ``(x, y, width, height)`` tuples of floats. :raises: :exc:`CairoError` if the clip region cannot be represented as a list of...
[ "Return", "the", "current", "clip", "region", "as", "a", "list", "of", "rectangles", "in", "user", "coordinates", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1645-L1666
17,594
Kozea/cairocffi
cairocffi/context.py
Context.select_font_face
def select_font_face(self, family='', slant=constants.FONT_SLANT_NORMAL, weight=constants.FONT_WEIGHT_NORMAL): """Selects a family and style of font from a simplified description as a family name, slant and weight. .. note:: The :meth:`select_font_face` met...
python
def select_font_face(self, family='', slant=constants.FONT_SLANT_NORMAL, weight=constants.FONT_WEIGHT_NORMAL): """Selects a family and style of font from a simplified description as a family name, slant and weight. .. note:: The :meth:`select_font_face` met...
[ "def", "select_font_face", "(", "self", ",", "family", "=", "''", ",", "slant", "=", "constants", ".", "FONT_SLANT_NORMAL", ",", "weight", "=", "constants", ".", "FONT_WEIGHT_NORMAL", ")", ":", "cairo", ".", "cairo_select_font_face", "(", "self", ".", "_pointe...
Selects a family and style of font from a simplified description as a family name, slant and weight. .. note:: The :meth:`select_font_face` method is part of what the cairo designers call the "toy" text API. It is convenient for short demos and simple programs, ...
[ "Selects", "a", "family", "and", "style", "of", "font", "from", "a", "simplified", "description", "as", "a", "family", "name", "slant", "and", "weight", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1709-L1752
17,595
Kozea/cairocffi
cairocffi/context.py
Context.get_font_face
def get_font_face(self): """Return the current font face. :param font_face: A new :class:`FontFace` object wrapping an existing cairo object. """ return FontFace._from_pointer( cairo.cairo_get_font_face(self._pointer), incref=True)
python
def get_font_face(self): """Return the current font face. :param font_face: A new :class:`FontFace` object wrapping an existing cairo object. """ return FontFace._from_pointer( cairo.cairo_get_font_face(self._pointer), incref=True)
[ "def", "get_font_face", "(", "self", ")", ":", "return", "FontFace", ".", "_from_pointer", "(", "cairo", ".", "cairo_get_font_face", "(", "self", ".", "_pointer", ")", ",", "incref", "=", "True", ")" ]
Return the current font face. :param font_face: A new :class:`FontFace` object wrapping an existing cairo object.
[ "Return", "the", "current", "font", "face", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1766-L1775
17,596
Kozea/cairocffi
cairocffi/context.py
Context.get_scaled_font
def get_scaled_font(self): """Return the current scaled font. :return: A new :class:`ScaledFont` object, wrapping an existing cairo object. """ return ScaledFont._from_pointer( cairo.cairo_get_scaled_font(self._pointer), incref=True)
python
def get_scaled_font(self): """Return the current scaled font. :return: A new :class:`ScaledFont` object, wrapping an existing cairo object. """ return ScaledFont._from_pointer( cairo.cairo_get_scaled_font(self._pointer), incref=True)
[ "def", "get_scaled_font", "(", "self", ")", ":", "return", "ScaledFont", ".", "_from_pointer", "(", "cairo", ".", "cairo_get_scaled_font", "(", "self", ".", "_pointer", ")", ",", "incref", "=", "True", ")" ]
Return the current scaled font. :return: A new :class:`ScaledFont` object, wrapping an existing cairo object.
[ "Return", "the", "current", "scaled", "font", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1865-L1874
17,597
Kozea/cairocffi
cairocffi/context.py
Context.font_extents
def font_extents(self): """Return the extents of the currently selected font. Values are given in the current user-space coordinate system. Because font metrics are in user-space coordinates, they are mostly, but not entirely, independent of the current transformation matrix. I...
python
def font_extents(self): """Return the extents of the currently selected font. Values are given in the current user-space coordinate system. Because font metrics are in user-space coordinates, they are mostly, but not entirely, independent of the current transformation matrix. I...
[ "def", "font_extents", "(", "self", ")", ":", "extents", "=", "ffi", ".", "new", "(", "'cairo_font_extents_t *'", ")", "cairo", ".", "cairo_font_extents", "(", "self", ".", "_pointer", ",", "extents", ")", "self", ".", "_check_status", "(", ")", "# returning...
Return the extents of the currently selected font. Values are given in the current user-space coordinate system. Because font metrics are in user-space coordinates, they are mostly, but not entirely, independent of the current transformation matrix. If you call :meth:`context.scale(2) ...
[ "Return", "the", "extents", "of", "the", "currently", "selected", "font", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1876-L1933
17,598
Kozea/cairocffi
cairocffi/context.py
Context.text_extents
def text_extents(self, text): """Returns the extents for a string of text. The extents describe a user-space rectangle that encloses the "inked" portion of the text, (as it would be drawn by :meth:`show_text`). Additionally, the :obj:`x_advance` and :obj:`y_advance` values ...
python
def text_extents(self, text): """Returns the extents for a string of text. The extents describe a user-space rectangle that encloses the "inked" portion of the text, (as it would be drawn by :meth:`show_text`). Additionally, the :obj:`x_advance` and :obj:`y_advance` values ...
[ "def", "text_extents", "(", "self", ",", "text", ")", ":", "extents", "=", "ffi", ".", "new", "(", "'cairo_text_extents_t *'", ")", "cairo", ".", "cairo_text_extents", "(", "self", ".", "_pointer", ",", "_encode_string", "(", "text", ")", ",", "extents", "...
Returns the extents for a string of text. The extents describe a user-space rectangle that encloses the "inked" portion of the text, (as it would be drawn by :meth:`show_text`). Additionally, the :obj:`x_advance` and :obj:`y_advance` values indicate the amount by which the curre...
[ "Returns", "the", "extents", "for", "a", "string", "of", "text", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L1939-L2009
17,599
Kozea/cairocffi
cairocffi/context.py
Context.glyph_extents
def glyph_extents(self, glyphs): """Returns the extents for a list of glyphs. The extents describe a user-space rectangle that encloses the "inked" portion of the glyphs, (as it would be drawn by :meth:`show_glyphs`). Additionally, the :obj:`x_advance` and :obj:`y_advance` value...
python
def glyph_extents(self, glyphs): """Returns the extents for a list of glyphs. The extents describe a user-space rectangle that encloses the "inked" portion of the glyphs, (as it would be drawn by :meth:`show_glyphs`). Additionally, the :obj:`x_advance` and :obj:`y_advance` value...
[ "def", "glyph_extents", "(", "self", ",", "glyphs", ")", ":", "glyphs", "=", "ffi", ".", "new", "(", "'cairo_glyph_t[]'", ",", "glyphs", ")", "extents", "=", "ffi", ".", "new", "(", "'cairo_text_extents_t *'", ")", "cairo", ".", "cairo_glyph_extents", "(", ...
Returns the extents for a list of glyphs. The extents describe a user-space rectangle that encloses the "inked" portion of the glyphs, (as it would be drawn by :meth:`show_glyphs`). Additionally, the :obj:`x_advance` and :obj:`y_advance` values indicate the amount by which the c...
[ "Returns", "the", "extents", "for", "a", "list", "of", "glyphs", "." ]
450853add7e32eea20985b6aa5f54d9cb3cd04fe
https://github.com/Kozea/cairocffi/blob/450853add7e32eea20985b6aa5f54d9cb3cd04fe/cairocffi/context.py#L2011-L2038