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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
fastavro/fastavro | fastavro/_validation_py.py | validate_int | def validate_int(datum, **kwargs):
"""
Check that the data value is a non floating
point number with size less that Int32.
Also support for logicalType timestamp validation with datetime.
Int32 = -2147483648<=datum<=2147483647
conditional python types
(int, long, numbers.Integral,
date... | python | def validate_int(datum, **kwargs):
"""
Check that the data value is a non floating
point number with size less that Int32.
Also support for logicalType timestamp validation with datetime.
Int32 = -2147483648<=datum<=2147483647
conditional python types
(int, long, numbers.Integral,
date... | [
"def",
"validate_int",
"(",
"datum",
",",
"**",
"kwargs",
")",
":",
"return",
"(",
"(",
"isinstance",
"(",
"datum",
",",
"(",
"int",
",",
"long",
",",
"numbers",
".",
"Integral",
")",
")",
"and",
"INT_MIN_VALUE",
"<=",
"datum",
"<=",
"INT_MAX_VALUE",
"... | Check that the data value is a non floating
point number with size less that Int32.
Also support for logicalType timestamp validation with datetime.
Int32 = -2147483648<=datum<=2147483647
conditional python types
(int, long, numbers.Integral,
datetime.time, datetime.datetime, datetime.date)
... | [
"Check",
"that",
"the",
"data",
"value",
"is",
"a",
"non",
"floating",
"point",
"number",
"with",
"size",
"less",
"that",
"Int32",
".",
"Also",
"support",
"for",
"logicalType",
"timestamp",
"validation",
"with",
"datetime",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L79-L105 | train |
fastavro/fastavro | fastavro/_validation_py.py | validate_float | def validate_float(datum, **kwargs):
"""
Check that the data value is a floating
point number or double precision.
conditional python types
(int, long, float, numbers.Real)
Parameters
----------
datum: Any
Data being validated
kwargs: Any
Unused kwargs
"""
r... | python | def validate_float(datum, **kwargs):
"""
Check that the data value is a floating
point number or double precision.
conditional python types
(int, long, float, numbers.Real)
Parameters
----------
datum: Any
Data being validated
kwargs: Any
Unused kwargs
"""
r... | [
"def",
"validate_float",
"(",
"datum",
",",
"**",
"kwargs",
")",
":",
"return",
"(",
"isinstance",
"(",
"datum",
",",
"(",
"int",
",",
"long",
",",
"float",
",",
"numbers",
".",
"Real",
")",
")",
"and",
"not",
"isinstance",
"(",
"datum",
",",
"bool",... | Check that the data value is a floating
point number or double precision.
conditional python types
(int, long, float, numbers.Real)
Parameters
----------
datum: Any
Data being validated
kwargs: Any
Unused kwargs | [
"Check",
"that",
"the",
"data",
"value",
"is",
"a",
"floating",
"point",
"number",
"or",
"double",
"precision",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L137-L155 | train |
fastavro/fastavro | fastavro/_validation_py.py | validate_record | def validate_record(datum, schema, parent_ns=None, raise_errors=True):
"""
Check that the data is a Mapping type with all schema defined fields
validated as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent name... | python | def validate_record(datum, schema, parent_ns=None, raise_errors=True):
"""
Check that the data is a Mapping type with all schema defined fields
validated as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent name... | [
"def",
"validate_record",
"(",
"datum",
",",
"schema",
",",
"parent_ns",
"=",
"None",
",",
"raise_errors",
"=",
"True",
")",
":",
"_",
",",
"namespace",
"=",
"schema_name",
"(",
"schema",
",",
"parent_ns",
")",
"return",
"(",
"isinstance",
"(",
"datum",
... | Check that the data is a Mapping type with all schema defined fields
validated as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent namespace
raise_errors: bool
If true, raises ValidationError on invalid dat... | [
"Check",
"that",
"the",
"data",
"is",
"a",
"Mapping",
"type",
"with",
"all",
"schema",
"defined",
"fields",
"validated",
"as",
"True",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L245-L270 | train |
fastavro/fastavro | fastavro/_validation_py.py | validate_union | def validate_union(datum, schema, parent_ns=None, raise_errors=True):
"""
Check that the data is a list type with possible options to
validate as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent namespace
r... | python | def validate_union(datum, schema, parent_ns=None, raise_errors=True):
"""
Check that the data is a list type with possible options to
validate as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent namespace
r... | [
"def",
"validate_union",
"(",
"datum",
",",
"schema",
",",
"parent_ns",
"=",
"None",
",",
"raise_errors",
"=",
"True",
")",
":",
"if",
"isinstance",
"(",
"datum",
",",
"tuple",
")",
":",
"(",
"name",
",",
"datum",
")",
"=",
"datum",
"for",
"candidate",... | Check that the data is a list type with possible options to
validate as True.
Parameters
----------
datum: Any
Data being validated
schema: dict
Schema
parent_ns: str
parent namespace
raise_errors: bool
If true, raises ValidationError on invalid data | [
"Check",
"that",
"the",
"data",
"is",
"a",
"list",
"type",
"with",
"possible",
"options",
"to",
"validate",
"as",
"True",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L273-L313 | train |
fastavro/fastavro | fastavro/_validation_py.py | validate_many | def validate_many(records, schema, raise_errors=True):
"""
Validate a list of data!
Parameters
----------
records: iterable
List of records to validate
schema: dict
Schema
raise_errors: bool, optional
If true, errors are raised for invalid data. If false, a simple
... | python | def validate_many(records, schema, raise_errors=True):
"""
Validate a list of data!
Parameters
----------
records: iterable
List of records to validate
schema: dict
Schema
raise_errors: bool, optional
If true, errors are raised for invalid data. If false, a simple
... | [
"def",
"validate_many",
"(",
"records",
",",
"schema",
",",
"raise_errors",
"=",
"True",
")",
":",
"errors",
"=",
"[",
"]",
"results",
"=",
"[",
"]",
"for",
"record",
"in",
"records",
":",
"try",
":",
"results",
".",
"append",
"(",
"validate",
"(",
"... | Validate a list of data!
Parameters
----------
records: iterable
List of records to validate
schema: dict
Schema
raise_errors: bool, optional
If true, errors are raised for invalid data. If false, a simple
True (valid) or False (invalid) result is returned
Exam... | [
"Validate",
"a",
"list",
"of",
"data!"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_validation_py.py#L383-L414 | train |
fastavro/fastavro | fastavro/_schema_py.py | parse_schema | def parse_schema(schema, _write_hint=True, _force=False):
"""Returns a parsed avro schema
It is not necessary to call parse_schema but doing so and saving the parsed
schema for use later will make future operations faster as the schema will
not need to be reparsed.
Parameters
----------
sc... | python | def parse_schema(schema, _write_hint=True, _force=False):
"""Returns a parsed avro schema
It is not necessary to call parse_schema but doing so and saving the parsed
schema for use later will make future operations faster as the schema will
not need to be reparsed.
Parameters
----------
sc... | [
"def",
"parse_schema",
"(",
"schema",
",",
"_write_hint",
"=",
"True",
",",
"_force",
"=",
"False",
")",
":",
"if",
"_force",
":",
"return",
"_parse_schema",
"(",
"schema",
",",
"\"\"",
",",
"_write_hint",
")",
"elif",
"isinstance",
"(",
"schema",
",",
"... | Returns a parsed avro schema
It is not necessary to call parse_schema but doing so and saving the parsed
schema for use later will make future operations faster as the schema will
not need to be reparsed.
Parameters
----------
schema: dict
Input schema
_write_hint: bool
Int... | [
"Returns",
"a",
"parsed",
"avro",
"schema"
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_schema_py.py#L53-L86 | train |
fastavro/fastavro | fastavro/_schema_py.py | load_schema | def load_schema(schema_path):
'''
Returns a schema loaded from the file at `schema_path`.
Will recursively load referenced schemas assuming they can be found in
files in the same directory and named with the convention
`<type_name>.avsc`.
'''
with open(schema_path) as fd:
schema = j... | python | def load_schema(schema_path):
'''
Returns a schema loaded from the file at `schema_path`.
Will recursively load referenced schemas assuming they can be found in
files in the same directory and named with the convention
`<type_name>.avsc`.
'''
with open(schema_path) as fd:
schema = j... | [
"def",
"load_schema",
"(",
"schema_path",
")",
":",
"with",
"open",
"(",
"schema_path",
")",
"as",
"fd",
":",
"schema",
"=",
"json",
".",
"load",
"(",
"fd",
")",
"schema_dir",
",",
"schema_file",
"=",
"path",
".",
"split",
"(",
"schema_path",
")",
"ret... | Returns a schema loaded from the file at `schema_path`.
Will recursively load referenced schemas assuming they can be found in
files in the same directory and named with the convention
`<type_name>.avsc`. | [
"Returns",
"a",
"schema",
"loaded",
"from",
"the",
"file",
"at",
"schema_path",
"."
] | bafe826293e19eb93e77bbb0f6adfa059c7884b2 | https://github.com/fastavro/fastavro/blob/bafe826293e19eb93e77bbb0f6adfa059c7884b2/fastavro/_schema_py.py#L212-L223 | train |
alejandroautalan/pygubu | pygubu/widgets/simpletooltip.py | ToolTip.showtip | def showtip(self, text):
"Display text in tooltip window"
self.text = text
if self.tipwindow or not self.text:
return
x, y, cx, cy = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 27
y = y + cy + self.widget.winfo_rooty() +27
self.tipwi... | python | def showtip(self, text):
"Display text in tooltip window"
self.text = text
if self.tipwindow or not self.text:
return
x, y, cx, cy = self.widget.bbox("insert")
x = x + self.widget.winfo_rootx() + 27
y = y + cy + self.widget.winfo_rooty() +27
self.tipwi... | [
"def",
"showtip",
"(",
"self",
",",
"text",
")",
":",
"\"Display text in tooltip window\"",
"self",
".",
"text",
"=",
"text",
"if",
"self",
".",
"tipwindow",
"or",
"not",
"self",
".",
"text",
":",
"return",
"x",
",",
"y",
",",
"cx",
",",
"cy",
"=",
"... | Display text in tooltip window | [
"Display",
"text",
"in",
"tooltip",
"window"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/simpletooltip.py#L20-L42 | train |
alejandroautalan/pygubu | pygubu/__init__.py | TkApplication.run | def run(self):
"""Ejecute the main loop."""
self.toplevel.protocol("WM_DELETE_WINDOW", self.__on_window_close)
self.toplevel.mainloop() | python | def run(self):
"""Ejecute the main loop."""
self.toplevel.protocol("WM_DELETE_WINDOW", self.__on_window_close)
self.toplevel.mainloop() | [
"def",
"run",
"(",
"self",
")",
":",
"self",
".",
"toplevel",
".",
"protocol",
"(",
"\"WM_DELETE_WINDOW\"",
",",
"self",
".",
"__on_window_close",
")",
"self",
".",
"toplevel",
".",
"mainloop",
"(",
")"
] | Ejecute the main loop. | [
"Ejecute",
"the",
"main",
"loop",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/__init__.py#L41-L45 | train |
alejandroautalan/pygubu | examples/py2exe/myapp.py | MyApplication.create_regpoly | def create_regpoly(self, x0, y0, x1, y1, sides=0, start=90, extent=360, **kw):
"""Create a regular polygon"""
coords = self.__regpoly_coords(x0, y0, x1, y1, sides, start, extent)
return self.canvas.create_polygon(*coords, **kw) | python | def create_regpoly(self, x0, y0, x1, y1, sides=0, start=90, extent=360, **kw):
"""Create a regular polygon"""
coords = self.__regpoly_coords(x0, y0, x1, y1, sides, start, extent)
return self.canvas.create_polygon(*coords, **kw) | [
"def",
"create_regpoly",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"sides",
"=",
"0",
",",
"start",
"=",
"90",
",",
"extent",
"=",
"360",
",",
"**",
"kw",
")",
":",
"coords",
"=",
"self",
".",
"__regpoly_coords",
"(",
"x0",
... | Create a regular polygon | [
"Create",
"a",
"regular",
"polygon"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/examples/py2exe/myapp.py#L131-L134 | train |
alejandroautalan/pygubu | examples/py2exe/myapp.py | MyApplication.__regpoly_coords | def __regpoly_coords(self, x0, y0, x1, y1, sides, start, extent):
"""Create the coordinates of the regular polygon specified"""
coords = []
if extent == 0:
return coords
xm = (x0 + x1) / 2.
ym = (y0 + y1) / 2.
rx = xm - x0
ry = ym - y0
n = s... | python | def __regpoly_coords(self, x0, y0, x1, y1, sides, start, extent):
"""Create the coordinates of the regular polygon specified"""
coords = []
if extent == 0:
return coords
xm = (x0 + x1) / 2.
ym = (y0 + y1) / 2.
rx = xm - x0
ry = ym - y0
n = s... | [
"def",
"__regpoly_coords",
"(",
"self",
",",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
",",
"sides",
",",
"start",
",",
"extent",
")",
":",
"coords",
"=",
"[",
"]",
"if",
"extent",
"==",
"0",
":",
"return",
"coords",
"xm",
"=",
"(",
"x0",
"+",
"x1... | Create the coordinates of the regular polygon specified | [
"Create",
"the",
"coordinates",
"of",
"the",
"regular",
"polygon",
"specified"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/examples/py2exe/myapp.py#L136-L189 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.get_image | def get_image(self, path):
"""Return tk image corresponding to name which is taken form path."""
image = ''
name = os.path.basename(path)
if not StockImage.is_registered(name):
ipath = self.__find_image(path)
if ipath is not None:
StockImage.regist... | python | def get_image(self, path):
"""Return tk image corresponding to name which is taken form path."""
image = ''
name = os.path.basename(path)
if not StockImage.is_registered(name):
ipath = self.__find_image(path)
if ipath is not None:
StockImage.regist... | [
"def",
"get_image",
"(",
"self",
",",
"path",
")",
":",
"image",
"=",
"''",
"name",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"if",
"not",
"StockImage",
".",
"is_registered",
"(",
"name",
")",
":",
"ipath",
"=",
"self",
".",
"__fin... | Return tk image corresponding to name which is taken form path. | [
"Return",
"tk",
"image",
"corresponding",
"to",
"name",
"which",
"is",
"taken",
"form",
"path",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L195-L211 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.import_variables | def import_variables(self, container, varnames=None):
"""Helper method to avoid call get_variable for every variable."""
if varnames is None:
for keyword in self.tkvariables:
setattr(container, keyword, self.tkvariables[keyword])
else:
for keyword in varna... | python | def import_variables(self, container, varnames=None):
"""Helper method to avoid call get_variable for every variable."""
if varnames is None:
for keyword in self.tkvariables:
setattr(container, keyword, self.tkvariables[keyword])
else:
for keyword in varna... | [
"def",
"import_variables",
"(",
"self",
",",
"container",
",",
"varnames",
"=",
"None",
")",
":",
"if",
"varnames",
"is",
"None",
":",
"for",
"keyword",
"in",
"self",
".",
"tkvariables",
":",
"setattr",
"(",
"container",
",",
"keyword",
",",
"self",
".",... | Helper method to avoid call get_variable for every variable. | [
"Helper",
"method",
"to",
"avoid",
"call",
"get_variable",
"for",
"every",
"variable",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L228-L236 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.create_variable | def create_variable(self, varname, vtype=None):
"""Create a tk variable.
If the variable was created previously return that instance.
"""
var_types = ('string', 'int', 'boolean', 'double')
vname = varname
var = None
type_from_name = 'string' # default type
... | python | def create_variable(self, varname, vtype=None):
"""Create a tk variable.
If the variable was created previously return that instance.
"""
var_types = ('string', 'int', 'boolean', 'double')
vname = varname
var = None
type_from_name = 'string' # default type
... | [
"def",
"create_variable",
"(",
"self",
",",
"varname",
",",
"vtype",
"=",
"None",
")",
":",
"var_types",
"=",
"(",
"'string'",
",",
"'int'",
",",
"'boolean'",
",",
"'double'",
")",
"vname",
"=",
"varname",
"var",
"=",
"None",
"type_from_name",
"=",
"'str... | Create a tk variable.
If the variable was created previously return that instance. | [
"Create",
"a",
"tk",
"variable",
".",
"If",
"the",
"variable",
"was",
"created",
"previously",
"return",
"that",
"instance",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L238-L273 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.add_from_file | def add_from_file(self, fpath):
"""Load ui definition from file."""
if self.tree is None:
base, name = os.path.split(fpath)
self.add_resource_path(base)
self.tree = tree = ET.parse(fpath)
self.root = tree.getroot()
self.objects = {}
els... | python | def add_from_file(self, fpath):
"""Load ui definition from file."""
if self.tree is None:
base, name = os.path.split(fpath)
self.add_resource_path(base)
self.tree = tree = ET.parse(fpath)
self.root = tree.getroot()
self.objects = {}
els... | [
"def",
"add_from_file",
"(",
"self",
",",
"fpath",
")",
":",
"if",
"self",
".",
"tree",
"is",
"None",
":",
"base",
",",
"name",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fpath",
")",
"self",
".",
"add_resource_path",
"(",
"base",
")",
"self",
"."... | Load ui definition from file. | [
"Load",
"ui",
"definition",
"from",
"file",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L275-L285 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.add_from_string | def add_from_string(self, strdata):
"""Load ui definition from string."""
if self.tree is None:
self.tree = tree = ET.ElementTree(ET.fromstring(strdata))
self.root = tree.getroot()
self.objects = {}
else:
# TODO: append to current tree
... | python | def add_from_string(self, strdata):
"""Load ui definition from string."""
if self.tree is None:
self.tree = tree = ET.ElementTree(ET.fromstring(strdata))
self.root = tree.getroot()
self.objects = {}
else:
# TODO: append to current tree
... | [
"def",
"add_from_string",
"(",
"self",
",",
"strdata",
")",
":",
"if",
"self",
".",
"tree",
"is",
"None",
":",
"self",
".",
"tree",
"=",
"tree",
"=",
"ET",
".",
"ElementTree",
"(",
"ET",
".",
"fromstring",
"(",
"strdata",
")",
")",
"self",
".",
"ro... | Load ui definition from string. | [
"Load",
"ui",
"definition",
"from",
"string",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L287-L295 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.add_from_xmlnode | def add_from_xmlnode(self, element):
"""Load ui definition from xml.etree.Element node."""
if self.tree is None:
root = ET.Element('interface')
root.append(element)
self.tree = tree = ET.ElementTree(root)
self.root = tree.getroot()
self.objects... | python | def add_from_xmlnode(self, element):
"""Load ui definition from xml.etree.Element node."""
if self.tree is None:
root = ET.Element('interface')
root.append(element)
self.tree = tree = ET.ElementTree(root)
self.root = tree.getroot()
self.objects... | [
"def",
"add_from_xmlnode",
"(",
"self",
",",
"element",
")",
":",
"if",
"self",
".",
"tree",
"is",
"None",
":",
"root",
"=",
"ET",
".",
"Element",
"(",
"'interface'",
")",
"root",
".",
"append",
"(",
"element",
")",
"self",
".",
"tree",
"=",
"tree",
... | Load ui definition from xml.etree.Element node. | [
"Load",
"ui",
"definition",
"from",
"xml",
".",
"etree",
".",
"Element",
"node",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L297-L308 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.get_object | def get_object(self, name, master=None):
"""Find and create the widget named name.
Use master as parent. If widget was already created, return
that instance."""
widget = None
if name in self.objects:
widget = self.objects[name].widget
else:
xpath =... | python | def get_object(self, name, master=None):
"""Find and create the widget named name.
Use master as parent. If widget was already created, return
that instance."""
widget = None
if name in self.objects:
widget = self.objects[name].widget
else:
xpath =... | [
"def",
"get_object",
"(",
"self",
",",
"name",
",",
"master",
"=",
"None",
")",
":",
"widget",
"=",
"None",
"if",
"name",
"in",
"self",
".",
"objects",
":",
"widget",
"=",
"self",
".",
"objects",
"[",
"name",
"]",
".",
"widget",
"else",
":",
"xpath... | Find and create the widget named name.
Use master as parent. If widget was already created, return
that instance. | [
"Find",
"and",
"create",
"the",
"widget",
"named",
"name",
".",
"Use",
"master",
"as",
"parent",
".",
"If",
"widget",
"was",
"already",
"created",
"return",
"that",
"instance",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L310-L328 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder._realize | def _realize(self, master, element):
"""Builds a widget from xml element using master as parent."""
data = data_xmlnode_to_dict(element, self.translator)
cname = data['class']
uniqueid = data['id']
if cname not in CLASS_MAP:
self._import_class(cname)
if cna... | python | def _realize(self, master, element):
"""Builds a widget from xml element using master as parent."""
data = data_xmlnode_to_dict(element, self.translator)
cname = data['class']
uniqueid = data['id']
if cname not in CLASS_MAP:
self._import_class(cname)
if cna... | [
"def",
"_realize",
"(",
"self",
",",
"master",
",",
"element",
")",
":",
"data",
"=",
"data_xmlnode_to_dict",
"(",
"element",
",",
"self",
".",
"translator",
")",
"cname",
"=",
"data",
"[",
"'class'",
"]",
"uniqueid",
"=",
"data",
"[",
"'id'",
"]",
"if... | Builds a widget from xml element using master as parent. | [
"Builds",
"a",
"widget",
"from",
"xml",
"element",
"using",
"master",
"as",
"parent",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L349-L377 | train |
alejandroautalan/pygubu | pygubu/builder/__init__.py | Builder.connect_callbacks | def connect_callbacks(self, callbacks_bag):
"""Connect callbacks specified in callbacks_bag with callbacks
defined in the ui definition.
Return a list with the name of the callbacks not connected.
"""
notconnected = []
for wname, builderobj in self.objects.items():
... | python | def connect_callbacks(self, callbacks_bag):
"""Connect callbacks specified in callbacks_bag with callbacks
defined in the ui definition.
Return a list with the name of the callbacks not connected.
"""
notconnected = []
for wname, builderobj in self.objects.items():
... | [
"def",
"connect_callbacks",
"(",
"self",
",",
"callbacks_bag",
")",
":",
"notconnected",
"=",
"[",
"]",
"for",
"wname",
",",
"builderobj",
"in",
"self",
".",
"objects",
".",
"items",
"(",
")",
":",
"missing",
"=",
"builderobj",
".",
"connect_commands",
"("... | Connect callbacks specified in callbacks_bag with callbacks
defined in the ui definition.
Return a list with the name of the callbacks not connected. | [
"Connect",
"callbacks",
"specified",
"in",
"callbacks_bag",
"with",
"callbacks",
"defined",
"in",
"the",
"ui",
"definition",
".",
"Return",
"a",
"list",
"with",
"the",
"name",
"of",
"the",
"callbacks",
"not",
"connected",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/__init__.py#L388-L407 | train |
alejandroautalan/pygubu | pygubudesigner/util/selecttool.py | SelectTool._start_selecting | def _start_selecting(self, event):
"""Comienza con el proceso de seleccion."""
self._selecting = True
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
self._sstart = (x, y)
if not self._sobject:
self._sobject = canvas.creat... | python | def _start_selecting(self, event):
"""Comienza con el proceso de seleccion."""
self._selecting = True
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
self._sstart = (x, y)
if not self._sobject:
self._sobject = canvas.creat... | [
"def",
"_start_selecting",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_selecting",
"=",
"True",
"canvas",
"=",
"self",
".",
"_canvas",
"x",
"=",
"canvas",
".",
"canvasx",
"(",
"event",
".",
"x",
")",
"y",
"=",
"canvas",
".",
"canvasy",
"(",
... | Comienza con el proceso de seleccion. | [
"Comienza",
"con",
"el",
"proceso",
"de",
"seleccion",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/selecttool.py#L51-L63 | train |
alejandroautalan/pygubu | pygubudesigner/util/selecttool.py | SelectTool._keep_selecting | def _keep_selecting(self, event):
"""Continua con el proceso de seleccion.
Crea o redimensiona el cuadro de seleccion de acuerdo con
la posicion del raton."""
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
canvas.coords(self._sobject... | python | def _keep_selecting(self, event):
"""Continua con el proceso de seleccion.
Crea o redimensiona el cuadro de seleccion de acuerdo con
la posicion del raton."""
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
canvas.coords(self._sobject... | [
"def",
"_keep_selecting",
"(",
"self",
",",
"event",
")",
":",
"canvas",
"=",
"self",
".",
"_canvas",
"x",
"=",
"canvas",
".",
"canvasx",
"(",
"event",
".",
"x",
")",
"y",
"=",
"canvas",
".",
"canvasy",
"(",
"event",
".",
"y",
")",
"canvas",
".",
... | Continua con el proceso de seleccion.
Crea o redimensiona el cuadro de seleccion de acuerdo con
la posicion del raton. | [
"Continua",
"con",
"el",
"proceso",
"de",
"seleccion",
".",
"Crea",
"o",
"redimensiona",
"el",
"cuadro",
"de",
"seleccion",
"de",
"acuerdo",
"con",
"la",
"posicion",
"del",
"raton",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/selecttool.py#L65-L73 | train |
alejandroautalan/pygubu | pygubudesigner/util/selecttool.py | SelectTool._finish_selecting | def _finish_selecting(self, event):
"""Finaliza la seleccion.
Marca como seleccionados todos los objetos que se encuentran
dentro del recuadro de seleccion."""
self._selecting = False
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
... | python | def _finish_selecting(self, event):
"""Finaliza la seleccion.
Marca como seleccionados todos los objetos que se encuentran
dentro del recuadro de seleccion."""
self._selecting = False
canvas = self._canvas
x = canvas.canvasx(event.x)
y = canvas.canvasy(event.y)
... | [
"def",
"_finish_selecting",
"(",
"self",
",",
"event",
")",
":",
"self",
".",
"_selecting",
"=",
"False",
"canvas",
"=",
"self",
".",
"_canvas",
"x",
"=",
"canvas",
".",
"canvasx",
"(",
"event",
".",
"x",
")",
"y",
"=",
"canvas",
".",
"canvasy",
"(",... | Finaliza la seleccion.
Marca como seleccionados todos los objetos que se encuentran
dentro del recuadro de seleccion. | [
"Finaliza",
"la",
"seleccion",
".",
"Marca",
"como",
"seleccionados",
"todos",
"los",
"objetos",
"que",
"se",
"encuentran",
"dentro",
"del",
"recuadro",
"de",
"seleccion",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/selecttool.py#L75-L89 | train |
alejandroautalan/pygubu | pygubu/widgets/calendarframe.py | matrix_coords | def matrix_coords(rows, cols, rowh, colw, ox=0, oy=0):
"Generate coords for a matrix of rects"
for i, f, c in rowmajor(rows, cols):
x = ox + c * colw
y = oy + f * rowh
x1 = x + colw
y1 = y + rowh
yield (i, x, y, x1, y1) | python | def matrix_coords(rows, cols, rowh, colw, ox=0, oy=0):
"Generate coords for a matrix of rects"
for i, f, c in rowmajor(rows, cols):
x = ox + c * colw
y = oy + f * rowh
x1 = x + colw
y1 = y + rowh
yield (i, x, y, x1, y1) | [
"def",
"matrix_coords",
"(",
"rows",
",",
"cols",
",",
"rowh",
",",
"colw",
",",
"ox",
"=",
"0",
",",
"oy",
"=",
"0",
")",
":",
"\"Generate coords for a matrix of rects\"",
"for",
"i",
",",
"f",
",",
"c",
"in",
"rowmajor",
"(",
"rows",
",",
"cols",
"... | Generate coords for a matrix of rects | [
"Generate",
"coords",
"for",
"a",
"matrix",
"of",
"rects"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/calendarframe.py#L40-L47 | train |
alejandroautalan/pygubu | pygubudesigner/util/__init__.py | ArrayVar.get | def get(self):
'''Return a dictionary that represents the Tcl array'''
value = {}
for (elementname, elementvar) in self._elementvars.items():
value[elementname] = elementvar.get()
return value | python | def get(self):
'''Return a dictionary that represents the Tcl array'''
value = {}
for (elementname, elementvar) in self._elementvars.items():
value[elementname] = elementvar.get()
return value | [
"def",
"get",
"(",
"self",
")",
":",
"value",
"=",
"{",
"}",
"for",
"(",
"elementname",
",",
"elementvar",
")",
"in",
"self",
".",
"_elementvars",
".",
"items",
"(",
")",
":",
"value",
"[",
"elementname",
"]",
"=",
"elementvar",
".",
"get",
"(",
")... | Return a dictionary that represents the Tcl array | [
"Return",
"a",
"dictionary",
"that",
"represents",
"the",
"Tcl",
"array"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/util/__init__.py#L96-L101 | train |
alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.yview | def yview(self, *args):
"""Update inplace widgets position when doing vertical scroll"""
self.after_idle(self.__updateWnds)
ttk.Treeview.yview(self, *args) | python | def yview(self, *args):
"""Update inplace widgets position when doing vertical scroll"""
self.after_idle(self.__updateWnds)
ttk.Treeview.yview(self, *args) | [
"def",
"yview",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"after_idle",
"(",
"self",
".",
"__updateWnds",
")",
"ttk",
".",
"Treeview",
".",
"yview",
"(",
"self",
",",
"*",
"args",
")"
] | Update inplace widgets position when doing vertical scroll | [
"Update",
"inplace",
"widgets",
"position",
"when",
"doing",
"vertical",
"scroll"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L106-L109 | train |
alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.xview | def xview(self, *args):
"""Update inplace widgets position when doing horizontal scroll"""
self.after_idle(self.__updateWnds)
ttk.Treeview.xview(self, *args) | python | def xview(self, *args):
"""Update inplace widgets position when doing horizontal scroll"""
self.after_idle(self.__updateWnds)
ttk.Treeview.xview(self, *args) | [
"def",
"xview",
"(",
"self",
",",
"*",
"args",
")",
":",
"self",
".",
"after_idle",
"(",
"self",
".",
"__updateWnds",
")",
"ttk",
".",
"Treeview",
".",
"xview",
"(",
"self",
",",
"*",
"args",
")"
] | Update inplace widgets position when doing horizontal scroll | [
"Update",
"inplace",
"widgets",
"position",
"when",
"doing",
"horizontal",
"scroll"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L119-L122 | train |
alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.__check_focus | def __check_focus(self, event):
"""Checks if the focus has changed"""
#print('Event:', event.type, event.x, event.y)
changed = False
if not self._curfocus:
changed = True
elif self._curfocus != self.focus():
self.__clear_inplace_widgets()
chang... | python | def __check_focus(self, event):
"""Checks if the focus has changed"""
#print('Event:', event.type, event.x, event.y)
changed = False
if not self._curfocus:
changed = True
elif self._curfocus != self.focus():
self.__clear_inplace_widgets()
chang... | [
"def",
"__check_focus",
"(",
"self",
",",
"event",
")",
":",
"changed",
"=",
"False",
"if",
"not",
"self",
".",
"_curfocus",
":",
"changed",
"=",
"True",
"elif",
"self",
".",
"_curfocus",
"!=",
"self",
".",
"focus",
"(",
")",
":",
"self",
".",
"__cle... | Checks if the focus has changed | [
"Checks",
"if",
"the",
"focus",
"has",
"changed"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L132-L147 | train |
alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.__focus | def __focus(self, item):
"""Called when focus item has changed"""
cols = self.__get_display_columns()
for col in cols:
self.__event_info =(col,item)
self.event_generate('<<TreeviewInplaceEdit>>')
if col in self._inplace_widgets:
w = self._inpla... | python | def __focus(self, item):
"""Called when focus item has changed"""
cols = self.__get_display_columns()
for col in cols:
self.__event_info =(col,item)
self.event_generate('<<TreeviewInplaceEdit>>')
if col in self._inplace_widgets:
w = self._inpla... | [
"def",
"__focus",
"(",
"self",
",",
"item",
")",
":",
"cols",
"=",
"self",
".",
"__get_display_columns",
"(",
")",
"for",
"col",
"in",
"cols",
":",
"self",
".",
"__event_info",
"=",
"(",
"col",
",",
"item",
")",
"self",
".",
"event_generate",
"(",
"'... | Called when focus item has changed | [
"Called",
"when",
"focus",
"item",
"has",
"changed"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L149-L160 | train |
alejandroautalan/pygubu | pygubu/widgets/editabletreeview.py | EditableTreeview.__clear_inplace_widgets | def __clear_inplace_widgets(self):
"""Remove all inplace edit widgets."""
cols = self.__get_display_columns()
#print('Clear:', cols)
for c in cols:
if c in self._inplace_widgets:
widget = self._inplace_widgets[c]
widget.place_forget()
... | python | def __clear_inplace_widgets(self):
"""Remove all inplace edit widgets."""
cols = self.__get_display_columns()
#print('Clear:', cols)
for c in cols:
if c in self._inplace_widgets:
widget = self._inplace_widgets[c]
widget.place_forget()
... | [
"def",
"__clear_inplace_widgets",
"(",
"self",
")",
":",
"cols",
"=",
"self",
".",
"__get_display_columns",
"(",
")",
"for",
"c",
"in",
"cols",
":",
"if",
"c",
"in",
"self",
".",
"_inplace_widgets",
":",
"widget",
"=",
"self",
".",
"_inplace_widgets",
"[",... | Remove all inplace edit widgets. | [
"Remove",
"all",
"inplace",
"edit",
"widgets",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/widgets/editabletreeview.py#L179-L187 | train |
alejandroautalan/pygubu | setup.py | CustomInstall.run | def run(self):
"""Run parent install, and then save the install dir in the script."""
install.run(self)
#
# Remove old pygubu.py from scripts path if exists
spath = os.path.join(self.install_scripts, 'pygubu')
for ext in ('.py', '.pyw'):
filename = spath + ex... | python | def run(self):
"""Run parent install, and then save the install dir in the script."""
install.run(self)
#
# Remove old pygubu.py from scripts path if exists
spath = os.path.join(self.install_scripts, 'pygubu')
for ext in ('.py', '.pyw'):
filename = spath + ex... | [
"def",
"run",
"(",
"self",
")",
":",
"install",
".",
"run",
"(",
"self",
")",
"spath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"install_scripts",
",",
"'pygubu'",
")",
"for",
"ext",
"in",
"(",
"'.py'",
",",
"'.pyw'",
")",
":",
"fil... | Run parent install, and then save the install dir in the script. | [
"Run",
"parent",
"install",
"and",
"then",
"save",
"the",
"install",
"dir",
"in",
"the",
"script",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/setup.py#L30-L46 | train |
alejandroautalan/pygubu | pygubudesigner/propertieseditor.py | PropertiesEditor.hide_all | def hide_all(self):
"""Hide all properties from property editor."""
self.current = None
for _v, (label, widget) in self._propbag.items():
label.grid_remove()
widget.grid_remove() | python | def hide_all(self):
"""Hide all properties from property editor."""
self.current = None
for _v, (label, widget) in self._propbag.items():
label.grid_remove()
widget.grid_remove() | [
"def",
"hide_all",
"(",
"self",
")",
":",
"self",
".",
"current",
"=",
"None",
"for",
"_v",
",",
"(",
"label",
",",
"widget",
")",
"in",
"self",
".",
"_propbag",
".",
"items",
"(",
")",
":",
"label",
".",
"grid_remove",
"(",
")",
"widget",
".",
"... | Hide all properties from property editor. | [
"Hide",
"all",
"properties",
"from",
"property",
"editor",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/propertieseditor.py#L150-L156 | train |
alejandroautalan/pygubu | pygubu/builder/builderobject.py | BuilderObject._get_init_args | def _get_init_args(self):
"""Creates dict with properties marked as readonly"""
args = {}
for rop in self.ro_properties:
if rop in self.properties:
args[rop] = self.properties[rop]
return args | python | def _get_init_args(self):
"""Creates dict with properties marked as readonly"""
args = {}
for rop in self.ro_properties:
if rop in self.properties:
args[rop] = self.properties[rop]
return args | [
"def",
"_get_init_args",
"(",
"self",
")",
":",
"args",
"=",
"{",
"}",
"for",
"rop",
"in",
"self",
".",
"ro_properties",
":",
"if",
"rop",
"in",
"self",
".",
"properties",
":",
"args",
"[",
"rop",
"]",
"=",
"self",
".",
"properties",
"[",
"rop",
"]... | Creates dict with properties marked as readonly | [
"Creates",
"dict",
"with",
"properties",
"marked",
"as",
"readonly"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/builder/builderobject.py#L86-L93 | train |
alejandroautalan/pygubu | pygubudesigner/previewer.py | OnCanvasMenuPreview._calculate_menu_wh | def _calculate_menu_wh(self):
""" Calculate menu widht and height."""
w = iw = 50
h = ih = 0
# menu.index returns None if there are no choices
index = self._menu.index(tk.END)
index = index if index is not None else 0
count = index + 1
# First calculate u... | python | def _calculate_menu_wh(self):
""" Calculate menu widht and height."""
w = iw = 50
h = ih = 0
# menu.index returns None if there are no choices
index = self._menu.index(tk.END)
index = index if index is not None else 0
count = index + 1
# First calculate u... | [
"def",
"_calculate_menu_wh",
"(",
"self",
")",
":",
"w",
"=",
"iw",
"=",
"50",
"h",
"=",
"ih",
"=",
"0",
"index",
"=",
"self",
".",
"_menu",
".",
"index",
"(",
"tk",
".",
"END",
")",
"index",
"=",
"index",
"if",
"index",
"is",
"not",
"None",
"e... | Calculate menu widht and height. | [
"Calculate",
"menu",
"widht",
"and",
"height",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L283-L320 | train |
alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper._over_resizer | def _over_resizer(self, x, y):
"Returns True if mouse is over a resizer"
over_resizer = False
c = self.canvas
ids = c.find_overlapping(x, y, x, y)
if ids:
o = ids[0]
tags = c.gettags(o)
if 'resizer' in tags:
over_resizer = True... | python | def _over_resizer(self, x, y):
"Returns True if mouse is over a resizer"
over_resizer = False
c = self.canvas
ids = c.find_overlapping(x, y, x, y)
if ids:
o = ids[0]
tags = c.gettags(o)
if 'resizer' in tags:
over_resizer = True... | [
"def",
"_over_resizer",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"\"Returns True if mouse is over a resizer\"",
"over_resizer",
"=",
"False",
"c",
"=",
"self",
".",
"canvas",
"ids",
"=",
"c",
".",
"find_overlapping",
"(",
"x",
",",
"y",
",",
"x",
",",
... | Returns True if mouse is over a resizer | [
"Returns",
"True",
"if",
"mouse",
"is",
"over",
"a",
"resizer"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L453-L464 | train |
alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper.resize_preview | def resize_preview(self, dw, dh):
"Resizes preview that is currently dragged"
# identify preview
if self._objects_moving:
id_ = self._objects_moving[0]
tags = self.canvas.gettags(id_)
for tag in tags:
if tag.startswith('preview_'):
... | python | def resize_preview(self, dw, dh):
"Resizes preview that is currently dragged"
# identify preview
if self._objects_moving:
id_ = self._objects_moving[0]
tags = self.canvas.gettags(id_)
for tag in tags:
if tag.startswith('preview_'):
... | [
"def",
"resize_preview",
"(",
"self",
",",
"dw",
",",
"dh",
")",
":",
"\"Resizes preview that is currently dragged\"",
"if",
"self",
".",
"_objects_moving",
":",
"id_",
"=",
"self",
".",
"_objects_moving",
"[",
"0",
"]",
"tags",
"=",
"self",
".",
"canvas",
"... | Resizes preview that is currently dragged | [
"Resizes",
"preview",
"that",
"is",
"currently",
"dragged"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L466-L480 | train |
alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper.move_previews | def move_previews(self):
"Move previews after a resize event"
# calculate new positions
min_y = self._calc_preview_ypos()
for idx, (key, p) in enumerate(self.previews.items()):
new_dy = min_y[idx] - p.y
self.previews[key].move_by(0, new_dy)
self._update_c... | python | def move_previews(self):
"Move previews after a resize event"
# calculate new positions
min_y = self._calc_preview_ypos()
for idx, (key, p) in enumerate(self.previews.items()):
new_dy = min_y[idx] - p.y
self.previews[key].move_by(0, new_dy)
self._update_c... | [
"def",
"move_previews",
"(",
"self",
")",
":",
"\"Move previews after a resize event\"",
"min_y",
"=",
"self",
".",
"_calc_preview_ypos",
"(",
")",
"for",
"idx",
",",
"(",
"key",
",",
"p",
")",
"in",
"enumerate",
"(",
"self",
".",
"previews",
".",
"items",
... | Move previews after a resize event | [
"Move",
"previews",
"after",
"a",
"resize",
"event"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L490-L499 | train |
alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper._calc_preview_ypos | def _calc_preview_ypos(self):
"Calculates the previews positions on canvas"
y = 10
min_y = [y]
for k, p in self.previews.items():
y += p.height() + self.padding
min_y.append(y)
return min_y | python | def _calc_preview_ypos(self):
"Calculates the previews positions on canvas"
y = 10
min_y = [y]
for k, p in self.previews.items():
y += p.height() + self.padding
min_y.append(y)
return min_y | [
"def",
"_calc_preview_ypos",
"(",
"self",
")",
":",
"\"Calculates the previews positions on canvas\"",
"y",
"=",
"10",
"min_y",
"=",
"[",
"y",
"]",
"for",
"k",
",",
"p",
"in",
"self",
".",
"previews",
".",
"items",
"(",
")",
":",
"y",
"+=",
"p",
".",
"... | Calculates the previews positions on canvas | [
"Calculates",
"the",
"previews",
"positions",
"on",
"canvas"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L501-L509 | train |
alejandroautalan/pygubu | pygubudesigner/previewer.py | PreviewHelper._get_slot | def _get_slot(self):
"Returns the next coordinates for a preview"
x = y = 10
for k, p in self.previews.items():
y += p.height() + self.padding
return x, y | python | def _get_slot(self):
"Returns the next coordinates for a preview"
x = y = 10
for k, p in self.previews.items():
y += p.height() + self.padding
return x, y | [
"def",
"_get_slot",
"(",
"self",
")",
":",
"\"Returns the next coordinates for a preview\"",
"x",
"=",
"y",
"=",
"10",
"for",
"k",
",",
"p",
"in",
"self",
".",
"previews",
".",
"items",
"(",
")",
":",
"y",
"+=",
"p",
".",
"height",
"(",
")",
"+",
"se... | Returns the next coordinates for a preview | [
"Returns",
"the",
"next",
"coordinates",
"for",
"a",
"preview"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/previewer.py#L511-L517 | train |
alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.clear_cache | def clear_cache(cls):
"""Call this before closing tk root"""
#Prevent tkinter errors on python 2 ??
for key in cls._cached:
cls._cached[key] = None
cls._cached = {} | python | def clear_cache(cls):
"""Call this before closing tk root"""
#Prevent tkinter errors on python 2 ??
for key in cls._cached:
cls._cached[key] = None
cls._cached = {} | [
"def",
"clear_cache",
"(",
"cls",
")",
":",
"for",
"key",
"in",
"cls",
".",
"_cached",
":",
"cls",
".",
"_cached",
"[",
"key",
"]",
"=",
"None",
"cls",
".",
"_cached",
"=",
"{",
"}"
] | Call this before closing tk root | [
"Call",
"this",
"before",
"closing",
"tk",
"root"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L54-L59 | train |
alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.register | def register(cls, key, filename):
"""Register a image file using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'custom', 'filename': filename}
logger.info('%s registered as %s' % (filename, key)) | python | def register(cls, key, filename):
"""Register a image file using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'custom', 'filename': filename}
logger.info('%s registered as %s' % (filename, key)) | [
"def",
"register",
"(",
"cls",
",",
"key",
",",
"filename",
")",
":",
"if",
"key",
"in",
"cls",
".",
"_stock",
":",
"logger",
".",
"info",
"(",
"'Warning, replacing resource '",
"+",
"str",
"(",
"key",
")",
")",
"cls",
".",
"_stock",
"[",
"key",
"]",... | Register a image file using key | [
"Register",
"a",
"image",
"file",
"using",
"key"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L62-L68 | train |
alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.register_from_data | def register_from_data(cls, key, format, data):
"""Register a image data using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'data', 'data': data, 'format': format }
logger.info('%s registered as %s' % ('data',... | python | def register_from_data(cls, key, format, data):
"""Register a image data using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'data', 'data': data, 'format': format }
logger.info('%s registered as %s' % ('data',... | [
"def",
"register_from_data",
"(",
"cls",
",",
"key",
",",
"format",
",",
"data",
")",
":",
"if",
"key",
"in",
"cls",
".",
"_stock",
":",
"logger",
".",
"info",
"(",
"'Warning, replacing resource '",
"+",
"str",
"(",
"key",
")",
")",
"cls",
".",
"_stock... | Register a image data using key | [
"Register",
"a",
"image",
"data",
"using",
"key"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L71-L77 | train |
alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.register_created | def register_created(cls, key, image):
"""Register an already created image using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'created', 'image': image}
logger.info('%s registered as %s' % ('data', key)) | python | def register_created(cls, key, image):
"""Register an already created image using key"""
if key in cls._stock:
logger.info('Warning, replacing resource ' + str(key))
cls._stock[key] = {'type': 'created', 'image': image}
logger.info('%s registered as %s' % ('data', key)) | [
"def",
"register_created",
"(",
"cls",
",",
"key",
",",
"image",
")",
":",
"if",
"key",
"in",
"cls",
".",
"_stock",
":",
"logger",
".",
"info",
"(",
"'Warning, replacing resource '",
"+",
"str",
"(",
"key",
")",
")",
"cls",
".",
"_stock",
"[",
"key",
... | Register an already created image using key | [
"Register",
"an",
"already",
"created",
"image",
"using",
"key"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L80-L86 | train |
alejandroautalan/pygubu | pygubu/stockimage.py | StockImage._load_image | def _load_image(cls, rkey):
"""Load image from file or return the cached instance."""
v = cls._stock[rkey]
img = None
itype = v['type']
if itype in ('stock', 'data'):
img = tk.PhotoImage(format=v['format'], data=v['data'])
elif itype == 'created':
... | python | def _load_image(cls, rkey):
"""Load image from file or return the cached instance."""
v = cls._stock[rkey]
img = None
itype = v['type']
if itype in ('stock', 'data'):
img = tk.PhotoImage(format=v['format'], data=v['data'])
elif itype == 'created':
... | [
"def",
"_load_image",
"(",
"cls",
",",
"rkey",
")",
":",
"v",
"=",
"cls",
".",
"_stock",
"[",
"rkey",
"]",
"img",
"=",
"None",
"itype",
"=",
"v",
"[",
"'type'",
"]",
"if",
"itype",
"in",
"(",
"'stock'",
",",
"'data'",
")",
":",
"img",
"=",
"tk"... | Load image from file or return the cached instance. | [
"Load",
"image",
"from",
"file",
"or",
"return",
"the",
"cached",
"instance",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L107-L121 | train |
alejandroautalan/pygubu | pygubu/stockimage.py | StockImage.get | def get(cls, rkey):
"""Get image previously registered with key rkey.
If key not exist, raise StockImageException
"""
if rkey in cls._cached:
logger.info('Resource %s is in cache.' % rkey)
return cls._cached[rkey]
if rkey in cls._stock:
img = ... | python | def get(cls, rkey):
"""Get image previously registered with key rkey.
If key not exist, raise StockImageException
"""
if rkey in cls._cached:
logger.info('Resource %s is in cache.' % rkey)
return cls._cached[rkey]
if rkey in cls._stock:
img = ... | [
"def",
"get",
"(",
"cls",
",",
"rkey",
")",
":",
"if",
"rkey",
"in",
"cls",
".",
"_cached",
":",
"logger",
".",
"info",
"(",
"'Resource %s is in cache.'",
"%",
"rkey",
")",
"return",
"cls",
".",
"_cached",
"[",
"rkey",
"]",
"if",
"rkey",
"in",
"cls",... | Get image previously registered with key rkey.
If key not exist, raise StockImageException | [
"Get",
"image",
"previously",
"registered",
"with",
"key",
"rkey",
".",
"If",
"key",
"not",
"exist",
"raise",
"StockImageException"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubu/stockimage.py#L124-L136 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.config_treeview | def config_treeview(self):
"""Sets treeview columns and other params"""
tree = self.treeview
tree.bind('<Double-1>', self.on_treeview_double_click)
tree.bind('<<TreeviewSelect>>', self.on_treeview_select, add='+') | python | def config_treeview(self):
"""Sets treeview columns and other params"""
tree = self.treeview
tree.bind('<Double-1>', self.on_treeview_double_click)
tree.bind('<<TreeviewSelect>>', self.on_treeview_select, add='+') | [
"def",
"config_treeview",
"(",
"self",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"tree",
".",
"bind",
"(",
"'<Double-1>'",
",",
"self",
".",
"on_treeview_double_click",
")",
"tree",
".",
"bind",
"(",
"'<<TreeviewSelect>>'",
",",
"self",
".",
"on_treevi... | Sets treeview columns and other params | [
"Sets",
"treeview",
"columns",
"and",
"other",
"params"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L79-L83 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.get_toplevel_parent | def get_toplevel_parent(self, treeitem):
"""Returns the top level parent for treeitem."""
tv = self.treeview
toplevel_items = tv.get_children()
item = treeitem
while not (item in toplevel_items):
item = tv.parent(item)
return item | python | def get_toplevel_parent(self, treeitem):
"""Returns the top level parent for treeitem."""
tv = self.treeview
toplevel_items = tv.get_children()
item = treeitem
while not (item in toplevel_items):
item = tv.parent(item)
return item | [
"def",
"get_toplevel_parent",
"(",
"self",
",",
"treeitem",
")",
":",
"tv",
"=",
"self",
".",
"treeview",
"toplevel_items",
"=",
"tv",
".",
"get_children",
"(",
")",
"item",
"=",
"treeitem",
"while",
"not",
"(",
"item",
"in",
"toplevel_items",
")",
":",
... | Returns the top level parent for treeitem. | [
"Returns",
"the",
"top",
"level",
"parent",
"for",
"treeitem",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L85-L94 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.draw_widget | def draw_widget(self, item):
"""Create a preview of the selected treeview item"""
if item:
self.filter_remove(remember=True)
selected_id = self.treedata[item]['id']
item = self.get_toplevel_parent(item)
widget_id = self.treedata[item]['id']
wcl... | python | def draw_widget(self, item):
"""Create a preview of the selected treeview item"""
if item:
self.filter_remove(remember=True)
selected_id = self.treedata[item]['id']
item = self.get_toplevel_parent(item)
widget_id = self.treedata[item]['id']
wcl... | [
"def",
"draw_widget",
"(",
"self",
",",
"item",
")",
":",
"if",
"item",
":",
"self",
".",
"filter_remove",
"(",
"remember",
"=",
"True",
")",
"selected_id",
"=",
"self",
".",
"treedata",
"[",
"item",
"]",
"[",
"'id'",
"]",
"item",
"=",
"self",
".",
... | Create a preview of the selected treeview item | [
"Create",
"a",
"preview",
"of",
"the",
"selected",
"treeview",
"item"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L96-L107 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.on_treeview_delete_selection | def on_treeview_delete_selection(self, event=None):
"""Removes selected items from treeview"""
tv = self.treeview
selection = tv.selection()
# Need to remove filter
self.filter_remove(remember=True)
toplevel_items = tv.get_children()
parents_to_redraw = set()
... | python | def on_treeview_delete_selection(self, event=None):
"""Removes selected items from treeview"""
tv = self.treeview
selection = tv.selection()
# Need to remove filter
self.filter_remove(remember=True)
toplevel_items = tv.get_children()
parents_to_redraw = set()
... | [
"def",
"on_treeview_delete_selection",
"(",
"self",
",",
"event",
"=",
"None",
")",
":",
"tv",
"=",
"self",
".",
"treeview",
"selection",
"=",
"tv",
".",
"selection",
"(",
")",
"self",
".",
"filter_remove",
"(",
"remember",
"=",
"True",
")",
"toplevel_item... | Removes selected items from treeview | [
"Removes",
"selected",
"items",
"from",
"treeview"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L134-L167 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.tree_to_xml | def tree_to_xml(self):
"""Traverses treeview and generates a ElementTree object"""
# Need to remove filter or hidden items will not be saved.
self.filter_remove(remember=True)
tree = self.treeview
root = ET.Element('interface')
items = tree.get_children()
for it... | python | def tree_to_xml(self):
"""Traverses treeview and generates a ElementTree object"""
# Need to remove filter or hidden items will not be saved.
self.filter_remove(remember=True)
tree = self.treeview
root = ET.Element('interface')
items = tree.get_children()
for it... | [
"def",
"tree_to_xml",
"(",
"self",
")",
":",
"self",
".",
"filter_remove",
"(",
"remember",
"=",
"True",
")",
"tree",
"=",
"self",
".",
"treeview",
"root",
"=",
"ET",
".",
"Element",
"(",
"'interface'",
")",
"items",
"=",
"tree",
".",
"get_children",
"... | Traverses treeview and generates a ElementTree object | [
"Traverses",
"treeview",
"and",
"generates",
"a",
"ElementTree",
"object"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L169-L185 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.tree_node_to_xml | def tree_node_to_xml(self, parent, item):
"""Converts a treeview item and children to xml nodes"""
tree = self.treeview
data = self.treedata[item]
node = data.to_xml_node()
children = tree.get_children(item)
for child in children:
cnode = ET.Element('child')... | python | def tree_node_to_xml(self, parent, item):
"""Converts a treeview item and children to xml nodes"""
tree = self.treeview
data = self.treedata[item]
node = data.to_xml_node()
children = tree.get_children(item)
for child in children:
cnode = ET.Element('child')... | [
"def",
"tree_node_to_xml",
"(",
"self",
",",
"parent",
",",
"item",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"data",
"=",
"self",
".",
"treedata",
"[",
"item",
"]",
"node",
"=",
"data",
".",
"to_xml_node",
"(",
")",
"children",
"=",
"tree",
".... | Converts a treeview item and children to xml nodes | [
"Converts",
"a",
"treeview",
"item",
"and",
"children",
"to",
"xml",
"nodes"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L187-L201 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor._insert_item | def _insert_item(self, root, data, from_file=False):
"""Insert a item on the treeview and fills columns from data"""
tree = self.treeview
treelabel = data.get_id()
row = col = ''
if root != '' and 'layout' in data:
row = data.get_layout_property('row')
co... | python | def _insert_item(self, root, data, from_file=False):
"""Insert a item on the treeview and fills columns from data"""
tree = self.treeview
treelabel = data.get_id()
row = col = ''
if root != '' and 'layout' in data:
row = data.get_layout_property('row')
co... | [
"def",
"_insert_item",
"(",
"self",
",",
"root",
",",
"data",
",",
"from_file",
"=",
"False",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"treelabel",
"=",
"data",
".",
"get_id",
"(",
")",
"row",
"=",
"col",
"=",
"''",
"if",
"root",
"!=",
"''",... | Insert a item on the treeview and fills columns from data | [
"Insert",
"a",
"item",
"on",
"the",
"treeview",
"and",
"fills",
"columns",
"from",
"data"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L203-L243 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.copy_to_clipboard | def copy_to_clipboard(self):
"""
Copies selected items to clipboard.
"""
tree = self.treeview
# get the selected item:
selection = tree.selection()
if selection:
self.filter_remove(remember=True)
root = ET.Element('selection')
f... | python | def copy_to_clipboard(self):
"""
Copies selected items to clipboard.
"""
tree = self.treeview
# get the selected item:
selection = tree.selection()
if selection:
self.filter_remove(remember=True)
root = ET.Element('selection')
f... | [
"def",
"copy_to_clipboard",
"(",
"self",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"selection",
"=",
"tree",
".",
"selection",
"(",
")",
"if",
"selection",
":",
"self",
".",
"filter_remove",
"(",
"remember",
"=",
"True",
")",
"root",
"=",
"ET",
"... | Copies selected items to clipboard. | [
"Copies",
"selected",
"items",
"to",
"clipboard",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L255-L275 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.add_widget | def add_widget(self, wclass):
"""Adds a new item to the treeview."""
tree = self.treeview
# get the selected item:
selected_item = ''
tsel = tree.selection()
if tsel:
selected_item = tsel[0]
# Need to remove filter if set
self.filter_remove... | python | def add_widget(self, wclass):
"""Adds a new item to the treeview."""
tree = self.treeview
# get the selected item:
selected_item = ''
tsel = tree.selection()
if tsel:
selected_item = tsel[0]
# Need to remove filter if set
self.filter_remove... | [
"def",
"add_widget",
"(",
"self",
",",
"wclass",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"selected_item",
"=",
"''",
"tsel",
"=",
"tree",
".",
"selection",
"(",
")",
"if",
"tsel",
":",
"selected_item",
"=",
"tsel",
"[",
"0",
"]",
"self",
".",... | Adds a new item to the treeview. | [
"Adds",
"a",
"new",
"item",
"to",
"the",
"treeview",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L422-L492 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.load_file | def load_file(self, filename):
"""Load file into treeview"""
self.counter.clear()
# python2 issues
try:
etree = ET.parse(filename)
except ET.ParseError:
parser = ET.XMLParser(encoding='UTF-8')
etree = ET.parse(filename, parser)
eroot =... | python | def load_file(self, filename):
"""Load file into treeview"""
self.counter.clear()
# python2 issues
try:
etree = ET.parse(filename)
except ET.ParseError:
parser = ET.XMLParser(encoding='UTF-8')
etree = ET.parse(filename, parser)
eroot =... | [
"def",
"load_file",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"counter",
".",
"clear",
"(",
")",
"try",
":",
"etree",
"=",
"ET",
".",
"parse",
"(",
"filename",
")",
"except",
"ET",
".",
"ParseError",
":",
"parser",
"=",
"ET",
".",
"XMLPa... | Load file into treeview | [
"Load",
"file",
"into",
"treeview"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L501-L523 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.populate_tree | def populate_tree(self, master, parent, element,from_file=False):
"""Reads xml nodes and populates tree item"""
data = WidgetDescr(None, None)
data.from_xml_node(element)
cname = data.get_class()
uniqueid = self.get_unique_id(cname, data.get_id())
data.set_property('id',... | python | def populate_tree(self, master, parent, element,from_file=False):
"""Reads xml nodes and populates tree item"""
data = WidgetDescr(None, None)
data.from_xml_node(element)
cname = data.get_class()
uniqueid = self.get_unique_id(cname, data.get_id())
data.set_property('id',... | [
"def",
"populate_tree",
"(",
"self",
",",
"master",
",",
"parent",
",",
"element",
",",
"from_file",
"=",
"False",
")",
":",
"data",
"=",
"WidgetDescr",
"(",
"None",
",",
"None",
")",
"data",
".",
"from_xml_node",
"(",
"element",
")",
"cname",
"=",
"da... | Reads xml nodes and populates tree item | [
"Reads",
"xml",
"nodes",
"and",
"populates",
"tree",
"item"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L525-L544 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor.update_event | def update_event(self, hint, obj):
"""Updates tree colums when itemdata is changed."""
tree = self.treeview
data = obj
item = self.get_item_by_data(obj)
if item:
if data.get_id() != tree.item(item, 'text'):
tree.item(item, text=data.get_id())
... | python | def update_event(self, hint, obj):
"""Updates tree colums when itemdata is changed."""
tree = self.treeview
data = obj
item = self.get_item_by_data(obj)
if item:
if data.get_id() != tree.item(item, 'text'):
tree.item(item, text=data.get_id())
... | [
"def",
"update_event",
"(",
"self",
",",
"hint",
",",
"obj",
")",
":",
"tree",
"=",
"self",
".",
"treeview",
"data",
"=",
"obj",
"item",
"=",
"self",
".",
"get_item_by_data",
"(",
"obj",
")",
"if",
"item",
":",
"if",
"data",
".",
"get_id",
"(",
")"... | Updates tree colums when itemdata is changed. | [
"Updates",
"tree",
"colums",
"when",
"itemdata",
"is",
"changed",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L586-L604 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor._reatach | def _reatach(self):
"""Reinsert the hidden items."""
for item, p, idx in self._detached:
# The item may have been deleted.
if self.treeview.exists(item) and self.treeview.exists(p):
self.treeview.move(item, p, idx)
self._detached = [] | python | def _reatach(self):
"""Reinsert the hidden items."""
for item, p, idx in self._detached:
# The item may have been deleted.
if self.treeview.exists(item) and self.treeview.exists(p):
self.treeview.move(item, p, idx)
self._detached = [] | [
"def",
"_reatach",
"(",
"self",
")",
":",
"for",
"item",
",",
"p",
",",
"idx",
"in",
"self",
".",
"_detached",
":",
"if",
"self",
".",
"treeview",
".",
"exists",
"(",
"item",
")",
"and",
"self",
".",
"treeview",
".",
"exists",
"(",
"p",
")",
":",... | Reinsert the hidden items. | [
"Reinsert",
"the",
"hidden",
"items",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L741-L747 | train |
alejandroautalan/pygubu | pygubudesigner/uitreeeditor.py | WidgetsTreeEditor._detach | def _detach(self, item):
"""Hide items from treeview that do not match the search string."""
to_detach = []
children_det = []
children_match = False
match_found = False
value = self.filtervar.get()
txt = self.treeview.item(item, 'text').lower()
if value i... | python | def _detach(self, item):
"""Hide items from treeview that do not match the search string."""
to_detach = []
children_det = []
children_match = False
match_found = False
value = self.filtervar.get()
txt = self.treeview.item(item, 'text').lower()
if value i... | [
"def",
"_detach",
"(",
"self",
",",
"item",
")",
":",
"to_detach",
"=",
"[",
"]",
"children_det",
"=",
"[",
"]",
"children_match",
"=",
"False",
"match_found",
"=",
"False",
"value",
"=",
"self",
".",
"filtervar",
".",
"get",
"(",
")",
"txt",
"=",
"s... | Hide items from treeview that do not match the search string. | [
"Hide",
"items",
"from",
"treeview",
"that",
"do",
"not",
"match",
"the",
"search",
"string",
"."
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/uitreeeditor.py#L749-L785 | train |
alejandroautalan/pygubu | pygubudesigner/main.py | PygubuUI.load_file | def load_file(self, filename):
"""Load xml into treeview"""
self.tree_editor.load_file(filename)
self.project_name.configure(text=filename)
self.currentfile = filename
self.is_changed = False | python | def load_file(self, filename):
"""Load xml into treeview"""
self.tree_editor.load_file(filename)
self.project_name.configure(text=filename)
self.currentfile = filename
self.is_changed = False | [
"def",
"load_file",
"(",
"self",
",",
"filename",
")",
":",
"self",
".",
"tree_editor",
".",
"load_file",
"(",
"filename",
")",
"self",
".",
"project_name",
".",
"configure",
"(",
"text",
"=",
"filename",
")",
"self",
".",
"currentfile",
"=",
"filename",
... | Load xml into treeview | [
"Load",
"xml",
"into",
"treeview"
] | 41c8fb37ef973736ec5d68cbe1cd4ecb78712e40 | https://github.com/alejandroautalan/pygubu/blob/41c8fb37ef973736ec5d68cbe1cd4ecb78712e40/pygubudesigner/main.py#L514-L520 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_gremlin/__init__.py | lower_ir | def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None):
"""Lower the IR into an IR form that can be represented in Gremlin queries.
Args:
ir_blocks: list of IR blocks to lower into Gremlin-compatible form
query_metadata_table: QueryMetadataTable object containing all metadat... | python | def lower_ir(ir_blocks, query_metadata_table, type_equivalence_hints=None):
"""Lower the IR into an IR form that can be represented in Gremlin queries.
Args:
ir_blocks: list of IR blocks to lower into Gremlin-compatible form
query_metadata_table: QueryMetadataTable object containing all metadat... | [
"def",
"lower_ir",
"(",
"ir_blocks",
",",
"query_metadata_table",
",",
"type_equivalence_hints",
"=",
"None",
")",
":",
"sanity_check_ir_blocks_from_frontend",
"(",
"ir_blocks",
",",
"query_metadata_table",
")",
"ir_blocks",
"=",
"lower_context_field_existence",
"(",
"ir_... | Lower the IR into an IR form that can be represented in Gremlin queries.
Args:
ir_blocks: list of IR blocks to lower into Gremlin-compatible form
query_metadata_table: QueryMetadataTable object containing all metadata collected during
query processing, including locati... | [
"Lower",
"the",
"IR",
"into",
"an",
"IR",
"form",
"that",
"can",
"be",
"represented",
"in",
"Gremlin",
"queries",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/__init__.py#L13-L53 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py | lower_coerce_type_block_type_data | def lower_coerce_type_block_type_data(ir_blocks, type_equivalence_hints):
"""Rewrite CoerceType blocks to explicitly state which types are allowed in the coercion."""
allowed_key_type_spec = (GraphQLInterfaceType, GraphQLObjectType)
allowed_value_type_spec = GraphQLUnionType
# Validate that the type_eq... | python | def lower_coerce_type_block_type_data(ir_blocks, type_equivalence_hints):
"""Rewrite CoerceType blocks to explicitly state which types are allowed in the coercion."""
allowed_key_type_spec = (GraphQLInterfaceType, GraphQLObjectType)
allowed_value_type_spec = GraphQLUnionType
# Validate that the type_eq... | [
"def",
"lower_coerce_type_block_type_data",
"(",
"ir_blocks",
",",
"type_equivalence_hints",
")",
":",
"allowed_key_type_spec",
"=",
"(",
"GraphQLInterfaceType",
",",
"GraphQLObjectType",
")",
"allowed_value_type_spec",
"=",
"GraphQLUnionType",
"for",
"key",
",",
"value",
... | Rewrite CoerceType blocks to explicitly state which types are allowed in the coercion. | [
"Rewrite",
"CoerceType",
"blocks",
"to",
"explicitly",
"state",
"which",
"types",
"are",
"allowed",
"in",
"the",
"coercion",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L31-L65 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py | lower_coerce_type_blocks | def lower_coerce_type_blocks(ir_blocks):
"""Lower CoerceType blocks into Filter blocks with a type-check predicate."""
new_ir_blocks = []
for block in ir_blocks:
new_block = block
if isinstance(block, CoerceType):
predicate = BinaryComposition(
u'contains', Liter... | python | def lower_coerce_type_blocks(ir_blocks):
"""Lower CoerceType blocks into Filter blocks with a type-check predicate."""
new_ir_blocks = []
for block in ir_blocks:
new_block = block
if isinstance(block, CoerceType):
predicate = BinaryComposition(
u'contains', Liter... | [
"def",
"lower_coerce_type_blocks",
"(",
"ir_blocks",
")",
":",
"new_ir_blocks",
"=",
"[",
"]",
"for",
"block",
"in",
"ir_blocks",
":",
"new_block",
"=",
"block",
"if",
"isinstance",
"(",
"block",
",",
"CoerceType",
")",
":",
"predicate",
"=",
"BinaryCompositio... | Lower CoerceType blocks into Filter blocks with a type-check predicate. | [
"Lower",
"CoerceType",
"blocks",
"into",
"Filter",
"blocks",
"with",
"a",
"type",
"-",
"check",
"predicate",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L68-L81 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py | rewrite_filters_in_optional_blocks | def rewrite_filters_in_optional_blocks(ir_blocks):
"""In optional contexts, add a check for null that allows non-existent optional data through.
Optional traversals in Gremlin represent missing optional data by setting the current vertex
to null until the exit from the optional scope. Therefore, filtering ... | python | def rewrite_filters_in_optional_blocks(ir_blocks):
"""In optional contexts, add a check for null that allows non-existent optional data through.
Optional traversals in Gremlin represent missing optional data by setting the current vertex
to null until the exit from the optional scope. Therefore, filtering ... | [
"def",
"rewrite_filters_in_optional_blocks",
"(",
"ir_blocks",
")",
":",
"new_ir_blocks",
"=",
"[",
"]",
"optional_context_depth",
"=",
"0",
"for",
"block",
"in",
"ir_blocks",
":",
"new_block",
"=",
"block",
"if",
"isinstance",
"(",
"block",
",",
"CoerceType",
"... | In optional contexts, add a check for null that allows non-existent optional data through.
Optional traversals in Gremlin represent missing optional data by setting the current vertex
to null until the exit from the optional scope. Therefore, filtering and type coercions
(which should have been lowered int... | [
"In",
"optional",
"contexts",
"add",
"a",
"check",
"for",
"null",
"that",
"allows",
"non",
"-",
"existent",
"optional",
"data",
"through",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L84-L122 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py | lower_folded_outputs | def lower_folded_outputs(ir_blocks):
"""Lower standard folded output fields into GremlinFoldedContextField objects."""
folds, remaining_ir_blocks = extract_folds_from_ir_blocks(ir_blocks)
if not remaining_ir_blocks:
raise AssertionError(u'Expected at least one non-folded block to remain: {} {} '
... | python | def lower_folded_outputs(ir_blocks):
"""Lower standard folded output fields into GremlinFoldedContextField objects."""
folds, remaining_ir_blocks = extract_folds_from_ir_blocks(ir_blocks)
if not remaining_ir_blocks:
raise AssertionError(u'Expected at least one non-folded block to remain: {} {} '
... | [
"def",
"lower_folded_outputs",
"(",
"ir_blocks",
")",
":",
"folds",
",",
"remaining_ir_blocks",
"=",
"extract_folds_from_ir_blocks",
"(",
"ir_blocks",
")",
"if",
"not",
"remaining_ir_blocks",
":",
"raise",
"AssertionError",
"(",
"u'Expected at least one non-folded block to ... | Lower standard folded output fields into GremlinFoldedContextField objects. | [
"Lower",
"standard",
"folded",
"output",
"fields",
"into",
"GremlinFoldedContextField",
"objects",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L319-L355 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py | GremlinFoldedContextField.validate | def validate(self):
"""Validate that the GremlinFoldedContextField is correctly representable."""
if not isinstance(self.fold_scope_location, FoldScopeLocation):
raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format(
type(self.fold_scope_locatio... | python | def validate(self):
"""Validate that the GremlinFoldedContextField is correctly representable."""
if not isinstance(self.fold_scope_location, FoldScopeLocation):
raise TypeError(u'Expected FoldScopeLocation fold_scope_location, got: {} {}'.format(
type(self.fold_scope_locatio... | [
"def",
"validate",
"(",
"self",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
".",
"fold_scope_location",
",",
"FoldScopeLocation",
")",
":",
"raise",
"TypeError",
"(",
"u'Expected FoldScopeLocation fold_scope_location, got: {} {}'",
".",
"format",
"(",
"type",
... | Validate that the GremlinFoldedContextField is correctly representable. | [
"Validate",
"that",
"the",
"GremlinFoldedContextField",
"is",
"correctly",
"representable",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L137-L159 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py | GremlinFoldedTraverse.from_traverse | def from_traverse(cls, traverse_block):
"""Create a GremlinFoldedTraverse block as a copy of the given Traverse block."""
if isinstance(traverse_block, Traverse):
return cls(traverse_block.direction, traverse_block.edge_name)
else:
raise AssertionError(u'Tried to initiali... | python | def from_traverse(cls, traverse_block):
"""Create a GremlinFoldedTraverse block as a copy of the given Traverse block."""
if isinstance(traverse_block, Traverse):
return cls(traverse_block.direction, traverse_block.edge_name)
else:
raise AssertionError(u'Tried to initiali... | [
"def",
"from_traverse",
"(",
"cls",
",",
"traverse_block",
")",
":",
"if",
"isinstance",
"(",
"traverse_block",
",",
"Traverse",
")",
":",
"return",
"cls",
"(",
"traverse_block",
".",
"direction",
",",
"traverse_block",
".",
"edge_name",
")",
"else",
":",
"r... | Create a GremlinFoldedTraverse block as a copy of the given Traverse block. | [
"Create",
"a",
"GremlinFoldedTraverse",
"block",
"as",
"a",
"copy",
"of",
"the",
"given",
"Traverse",
"block",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/ir_lowering_gremlin/ir_lowering.py#L258-L264 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _get_referenced_type_equivalences | def _get_referenced_type_equivalences(graphql_types, type_equivalence_hints):
"""Filter union types with no edges from the type equivalence hints dict."""
referenced_types = set()
for graphql_type in graphql_types.values():
if isinstance(graphql_type, (GraphQLObjectType, GraphQLInterfaceType)):
... | python | def _get_referenced_type_equivalences(graphql_types, type_equivalence_hints):
"""Filter union types with no edges from the type equivalence hints dict."""
referenced_types = set()
for graphql_type in graphql_types.values():
if isinstance(graphql_type, (GraphQLObjectType, GraphQLInterfaceType)):
... | [
"def",
"_get_referenced_type_equivalences",
"(",
"graphql_types",
",",
"type_equivalence_hints",
")",
":",
"referenced_types",
"=",
"set",
"(",
")",
"for",
"graphql_type",
"in",
"graphql_types",
".",
"values",
"(",
")",
":",
"if",
"isinstance",
"(",
"graphql_type",
... | Filter union types with no edges from the type equivalence hints dict. | [
"Filter",
"union",
"types",
"with",
"no",
"edges",
"from",
"the",
"type",
"equivalence",
"hints",
"dict",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L24-L36 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _get_inherited_field_types | def _get_inherited_field_types(class_to_field_type_overrides, schema_graph):
"""Return a dictionary describing the field type overrides in subclasses."""
inherited_field_type_overrides = dict()
for superclass_name, field_type_overrides in class_to_field_type_overrides.items():
for subclass_name in s... | python | def _get_inherited_field_types(class_to_field_type_overrides, schema_graph):
"""Return a dictionary describing the field type overrides in subclasses."""
inherited_field_type_overrides = dict()
for superclass_name, field_type_overrides in class_to_field_type_overrides.items():
for subclass_name in s... | [
"def",
"_get_inherited_field_types",
"(",
"class_to_field_type_overrides",
",",
"schema_graph",
")",
":",
"inherited_field_type_overrides",
"=",
"dict",
"(",
")",
"for",
"superclass_name",
",",
"field_type_overrides",
"in",
"class_to_field_type_overrides",
".",
"items",
"("... | Return a dictionary describing the field type overrides in subclasses. | [
"Return",
"a",
"dictionary",
"describing",
"the",
"field",
"type",
"overrides",
"in",
"subclasses",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L39-L46 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _validate_overriden_fields_are_not_defined_in_superclasses | def _validate_overriden_fields_are_not_defined_in_superclasses(class_to_field_type_overrides,
schema_graph):
"""Assert that the fields we want to override are not defined in superclasses."""
for class_name, field_type_overrides in six.iteritems(clas... | python | def _validate_overriden_fields_are_not_defined_in_superclasses(class_to_field_type_overrides,
schema_graph):
"""Assert that the fields we want to override are not defined in superclasses."""
for class_name, field_type_overrides in six.iteritems(clas... | [
"def",
"_validate_overriden_fields_are_not_defined_in_superclasses",
"(",
"class_to_field_type_overrides",
",",
"schema_graph",
")",
":",
"for",
"class_name",
",",
"field_type_overrides",
"in",
"six",
".",
"iteritems",
"(",
"class_to_field_type_overrides",
")",
":",
"for",
... | Assert that the fields we want to override are not defined in superclasses. | [
"Assert",
"that",
"the",
"fields",
"we",
"want",
"to",
"override",
"are",
"not",
"defined",
"in",
"superclasses",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L49-L61 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _property_descriptor_to_graphql_type | def _property_descriptor_to_graphql_type(property_obj):
"""Return the best GraphQL type representation for an OrientDB property descriptor."""
property_type = property_obj.type_id
scalar_types = {
PROPERTY_TYPE_BOOLEAN_ID: GraphQLBoolean,
PROPERTY_TYPE_DATE_ID: GraphQLDate,
PROPERTY_... | python | def _property_descriptor_to_graphql_type(property_obj):
"""Return the best GraphQL type representation for an OrientDB property descriptor."""
property_type = property_obj.type_id
scalar_types = {
PROPERTY_TYPE_BOOLEAN_ID: GraphQLBoolean,
PROPERTY_TYPE_DATE_ID: GraphQLDate,
PROPERTY_... | [
"def",
"_property_descriptor_to_graphql_type",
"(",
"property_obj",
")",
":",
"property_type",
"=",
"property_obj",
".",
"type_id",
"scalar_types",
"=",
"{",
"PROPERTY_TYPE_BOOLEAN_ID",
":",
"GraphQLBoolean",
",",
"PROPERTY_TYPE_DATE_ID",
":",
"GraphQLDate",
",",
"PROPERT... | Return the best GraphQL type representation for an OrientDB property descriptor. | [
"Return",
"the",
"best",
"GraphQL",
"type",
"representation",
"for",
"an",
"OrientDB",
"property",
"descriptor",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L64-L96 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _get_union_type_name | def _get_union_type_name(type_names_to_union):
"""Construct a unique union type name based on the type names being unioned."""
if not type_names_to_union:
raise AssertionError(u'Expected a non-empty list of type names to union, received: '
u'{}'.format(type_names_to_union))
... | python | def _get_union_type_name(type_names_to_union):
"""Construct a unique union type name based on the type names being unioned."""
if not type_names_to_union:
raise AssertionError(u'Expected a non-empty list of type names to union, received: '
u'{}'.format(type_names_to_union))
... | [
"def",
"_get_union_type_name",
"(",
"type_names_to_union",
")",
":",
"if",
"not",
"type_names_to_union",
":",
"raise",
"AssertionError",
"(",
"u'Expected a non-empty list of type names to union, received: '",
"u'{}'",
".",
"format",
"(",
"type_names_to_union",
")",
")",
"re... | Construct a unique union type name based on the type names being unioned. | [
"Construct",
"a",
"unique",
"union",
"type",
"name",
"based",
"on",
"the",
"type",
"names",
"being",
"unioned",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L99-L104 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _get_fields_for_class | def _get_fields_for_class(schema_graph, graphql_types, field_type_overrides, hidden_classes,
cls_name):
"""Return a dict from field name to GraphQL field type, for the specified graph class."""
properties = schema_graph.get_element_by_class_name(cls_name).properties
# Add leaf Gra... | python | def _get_fields_for_class(schema_graph, graphql_types, field_type_overrides, hidden_classes,
cls_name):
"""Return a dict from field name to GraphQL field type, for the specified graph class."""
properties = schema_graph.get_element_by_class_name(cls_name).properties
# Add leaf Gra... | [
"def",
"_get_fields_for_class",
"(",
"schema_graph",
",",
"graphql_types",
",",
"field_type_overrides",
",",
"hidden_classes",
",",
"cls_name",
")",
":",
"properties",
"=",
"schema_graph",
".",
"get_element_by_class_name",
"(",
"cls_name",
")",
".",
"properties",
"all... | Return a dict from field name to GraphQL field type, for the specified graph class. | [
"Return",
"a",
"dict",
"from",
"field",
"name",
"to",
"GraphQL",
"field",
"type",
"for",
"the",
"specified",
"graph",
"class",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L107-L172 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _create_field_specification | def _create_field_specification(schema_graph, graphql_types, field_type_overrides,
hidden_classes, cls_name):
"""Return a function that specifies the fields present on the given type."""
def field_maker_func():
"""Create and return the fields for the given GraphQL type.""... | python | def _create_field_specification(schema_graph, graphql_types, field_type_overrides,
hidden_classes, cls_name):
"""Return a function that specifies the fields present on the given type."""
def field_maker_func():
"""Create and return the fields for the given GraphQL type.""... | [
"def",
"_create_field_specification",
"(",
"schema_graph",
",",
"graphql_types",
",",
"field_type_overrides",
",",
"hidden_classes",
",",
"cls_name",
")",
":",
"def",
"field_maker_func",
"(",
")",
":",
"result",
"=",
"EXTENDED_META_FIELD_DEFINITIONS",
".",
"copy",
"("... | Return a function that specifies the fields present on the given type. | [
"Return",
"a",
"function",
"that",
"specifies",
"the",
"fields",
"present",
"on",
"the",
"given",
"type",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L175-L189 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _create_interface_specification | def _create_interface_specification(schema_graph, graphql_types, hidden_classes, cls_name):
"""Return a function that specifies the interfaces implemented by the given type."""
def interface_spec():
"""Return a list of GraphQL interface types implemented by the type named 'cls_name'."""
abstract... | python | def _create_interface_specification(schema_graph, graphql_types, hidden_classes, cls_name):
"""Return a function that specifies the interfaces implemented by the given type."""
def interface_spec():
"""Return a list of GraphQL interface types implemented by the type named 'cls_name'."""
abstract... | [
"def",
"_create_interface_specification",
"(",
"schema_graph",
",",
"graphql_types",
",",
"hidden_classes",
",",
"cls_name",
")",
":",
"def",
"interface_spec",
"(",
")",
":",
"abstract_inheritance_set",
"=",
"(",
"superclass_name",
"for",
"superclass_name",
"in",
"sor... | Return a function that specifies the interfaces implemented by the given type. | [
"Return",
"a",
"function",
"that",
"specifies",
"the",
"interfaces",
"implemented",
"by",
"the",
"given",
"type",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L192-L209 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | _create_union_types_specification | def _create_union_types_specification(schema_graph, graphql_types, hidden_classes, base_name):
"""Return a function that gives the types in the union type rooted at base_name."""
# When edges point to vertices of type base_name, and base_name is both non-abstract and
# has subclasses, we need to represent t... | python | def _create_union_types_specification(schema_graph, graphql_types, hidden_classes, base_name):
"""Return a function that gives the types in the union type rooted at base_name."""
# When edges point to vertices of type base_name, and base_name is both non-abstract and
# has subclasses, we need to represent t... | [
"def",
"_create_union_types_specification",
"(",
"schema_graph",
",",
"graphql_types",
",",
"hidden_classes",
",",
"base_name",
")",
":",
"def",
"types_spec",
"(",
")",
":",
"return",
"[",
"graphql_types",
"[",
"x",
"]",
"for",
"x",
"in",
"sorted",
"(",
"list"... | Return a function that gives the types in the union type rooted at base_name. | [
"Return",
"a",
"function",
"that",
"gives",
"the",
"types",
"in",
"the",
"union",
"type",
"rooted",
"at",
"base_name",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L212-L225 | train |
kensho-technologies/graphql-compiler | graphql_compiler/schema_generation/graphql_schema.py | get_graphql_schema_from_schema_graph | def get_graphql_schema_from_schema_graph(schema_graph, class_to_field_type_overrides,
hidden_classes):
"""Return a GraphQL schema object corresponding to the schema of the given schema graph.
Args:
schema_graph: SchemaGraph
class_to_field_type_overrides:... | python | def get_graphql_schema_from_schema_graph(schema_graph, class_to_field_type_overrides,
hidden_classes):
"""Return a GraphQL schema object corresponding to the schema of the given schema graph.
Args:
schema_graph: SchemaGraph
class_to_field_type_overrides:... | [
"def",
"get_graphql_schema_from_schema_graph",
"(",
"schema_graph",
",",
"class_to_field_type_overrides",
",",
"hidden_classes",
")",
":",
"_validate_overriden_fields_are_not_defined_in_superclasses",
"(",
"class_to_field_type_overrides",
",",
"schema_graph",
")",
"inherited_field_ty... | Return a GraphQL schema object corresponding to the schema of the given schema graph.
Args:
schema_graph: SchemaGraph
class_to_field_type_overrides: dict, class name -> {field name -> field type},
(string -> {string -> GraphQLType}). Used to override the
... | [
"Return",
"a",
"GraphQL",
"schema",
"object",
"corresponding",
"to",
"the",
"schema",
"of",
"the",
"given",
"schema",
"graph",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/schema_generation/graphql_schema.py#L228-L383 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py | workaround_lowering_pass | def workaround_lowering_pass(ir_blocks, query_metadata_table):
"""Extract locations from TernaryConditionals and rewrite their Filter blocks as necessary."""
new_ir_blocks = []
for block in ir_blocks:
if isinstance(block, Filter):
new_block = _process_filter_block(query_metadata_table, ... | python | def workaround_lowering_pass(ir_blocks, query_metadata_table):
"""Extract locations from TernaryConditionals and rewrite their Filter blocks as necessary."""
new_ir_blocks = []
for block in ir_blocks:
if isinstance(block, Filter):
new_block = _process_filter_block(query_metadata_table, ... | [
"def",
"workaround_lowering_pass",
"(",
"ir_blocks",
",",
"query_metadata_table",
")",
":",
"new_ir_blocks",
"=",
"[",
"]",
"for",
"block",
"in",
"ir_blocks",
":",
"if",
"isinstance",
"(",
"block",
",",
"Filter",
")",
":",
"new_block",
"=",
"_process_filter_bloc... | Extract locations from TernaryConditionals and rewrite their Filter blocks as necessary. | [
"Extract",
"locations",
"from",
"TernaryConditionals",
"and",
"rewrite",
"their",
"Filter",
"blocks",
"as",
"necessary",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py#L19-L30 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py | _process_filter_block | def _process_filter_block(query_metadata_table, block):
"""Rewrite the provided Filter block if necessary."""
# For a given Filter block with BinaryComposition predicate expression X,
# let L be the set of all Locations referenced in any TernaryConditional
# predicate expression enclosed in X.
# For... | python | def _process_filter_block(query_metadata_table, block):
"""Rewrite the provided Filter block if necessary."""
# For a given Filter block with BinaryComposition predicate expression X,
# let L be the set of all Locations referenced in any TernaryConditional
# predicate expression enclosed in X.
# For... | [
"def",
"_process_filter_block",
"(",
"query_metadata_table",
",",
"block",
")",
":",
"base_predicate",
"=",
"block",
".",
"predicate",
"ternary_conditionals",
"=",
"[",
"]",
"problematic_locations",
"=",
"[",
"]",
"def",
"find_ternary_conditionals",
"(",
"expression",... | Rewrite the provided Filter block if necessary. | [
"Rewrite",
"the",
"provided",
"Filter",
"block",
"if",
"necessary",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py#L33-L98 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py | _create_tautological_expression_for_location | def _create_tautological_expression_for_location(query_metadata_table, location):
"""For a given location, create a BinaryComposition that always evaluates to 'true'."""
location_type = query_metadata_table.get_location_info(location).type
location_exists = BinaryComposition(
u'!=', ContextField(lo... | python | def _create_tautological_expression_for_location(query_metadata_table, location):
"""For a given location, create a BinaryComposition that always evaluates to 'true'."""
location_type = query_metadata_table.get_location_info(location).type
location_exists = BinaryComposition(
u'!=', ContextField(lo... | [
"def",
"_create_tautological_expression_for_location",
"(",
"query_metadata_table",
",",
"location",
")",
":",
"location_type",
"=",
"query_metadata_table",
".",
"get_location_info",
"(",
"location",
")",
".",
"type",
"location_exists",
"=",
"BinaryComposition",
"(",
"u'!... | For a given location, create a BinaryComposition that always evaluates to 'true'. | [
"For",
"a",
"given",
"location",
"create",
"a",
"BinaryComposition",
"that",
"always",
"evaluates",
"to",
"true",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_eval_scheduling.py#L101-L109 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | get_only_element_from_collection | def get_only_element_from_collection(one_element_collection):
"""Assert that the collection has exactly one element, then return that element."""
if len(one_element_collection) != 1:
raise AssertionError(u'Expected a collection with exactly one element, but got: {}'
.format(... | python | def get_only_element_from_collection(one_element_collection):
"""Assert that the collection has exactly one element, then return that element."""
if len(one_element_collection) != 1:
raise AssertionError(u'Expected a collection with exactly one element, but got: {}'
.format(... | [
"def",
"get_only_element_from_collection",
"(",
"one_element_collection",
")",
":",
"if",
"len",
"(",
"one_element_collection",
")",
"!=",
"1",
":",
"raise",
"AssertionError",
"(",
"u'Expected a collection with exactly one element, but got: {}'",
".",
"format",
"(",
"one_el... | Assert that the collection has exactly one element, then return that element. | [
"Assert",
"that",
"the",
"collection",
"has",
"exactly",
"one",
"element",
"then",
"return",
"that",
"element",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L37-L42 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | get_ast_field_name | def get_ast_field_name(ast):
"""Return the normalized field name for the given AST node."""
replacements = {
# We always rewrite the following field names into their proper underlying counterparts.
TYPENAME_META_FIELD_NAME: '@class'
}
base_field_name = ast.name.value
normalized_name ... | python | def get_ast_field_name(ast):
"""Return the normalized field name for the given AST node."""
replacements = {
# We always rewrite the following field names into their proper underlying counterparts.
TYPENAME_META_FIELD_NAME: '@class'
}
base_field_name = ast.name.value
normalized_name ... | [
"def",
"get_ast_field_name",
"(",
"ast",
")",
":",
"replacements",
"=",
"{",
"TYPENAME_META_FIELD_NAME",
":",
"'@class'",
"}",
"base_field_name",
"=",
"ast",
".",
"name",
".",
"value",
"normalized_name",
"=",
"replacements",
".",
"get",
"(",
"base_field_name",
"... | Return the normalized field name for the given AST node. | [
"Return",
"the",
"normalized",
"field",
"name",
"for",
"the",
"given",
"AST",
"node",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L45-L53 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | get_field_type_from_schema | def get_field_type_from_schema(schema_type, field_name):
"""Return the type of the field in the given type, accounting for field name normalization."""
if field_name == '@class':
return GraphQLString
else:
if field_name not in schema_type.fields:
raise AssertionError(u'Field {} p... | python | def get_field_type_from_schema(schema_type, field_name):
"""Return the type of the field in the given type, accounting for field name normalization."""
if field_name == '@class':
return GraphQLString
else:
if field_name not in schema_type.fields:
raise AssertionError(u'Field {} p... | [
"def",
"get_field_type_from_schema",
"(",
"schema_type",
",",
"field_name",
")",
":",
"if",
"field_name",
"==",
"'@class'",
":",
"return",
"GraphQLString",
"else",
":",
"if",
"field_name",
"not",
"in",
"schema_type",
".",
"fields",
":",
"raise",
"AssertionError",
... | Return the type of the field in the given type, accounting for field name normalization. | [
"Return",
"the",
"type",
"of",
"the",
"field",
"in",
"the",
"given",
"type",
"accounting",
"for",
"field",
"name",
"normalization",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L63-L73 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | get_vertex_field_type | def get_vertex_field_type(current_schema_type, vertex_field_name):
"""Return the type of the vertex within the specified vertex field name of the given type."""
# According to the schema, the vertex field itself is of type GraphQLList, and this is
# what get_field_type_from_schema returns. We care about wha... | python | def get_vertex_field_type(current_schema_type, vertex_field_name):
"""Return the type of the vertex within the specified vertex field name of the given type."""
# According to the schema, the vertex field itself is of type GraphQLList, and this is
# what get_field_type_from_schema returns. We care about wha... | [
"def",
"get_vertex_field_type",
"(",
"current_schema_type",
",",
"vertex_field_name",
")",
":",
"if",
"not",
"is_vertex_field_name",
"(",
"vertex_field_name",
")",
":",
"raise",
"AssertionError",
"(",
"u'Trying to load the vertex field type of a non-vertex field: '",
"u'{} {}'"... | Return the type of the vertex within the specified vertex field name of the given type. | [
"Return",
"the",
"type",
"of",
"the",
"vertex",
"within",
"the",
"specified",
"vertex",
"field",
"name",
"of",
"the",
"given",
"type",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L76-L91 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | get_edge_direction_and_name | def get_edge_direction_and_name(vertex_field_name):
"""Get the edge direction and name from a non-root vertex field name."""
edge_direction = None
edge_name = None
if vertex_field_name.startswith(OUTBOUND_EDGE_FIELD_PREFIX):
edge_direction = OUTBOUND_EDGE_DIRECTION
edge_name = vertex_fie... | python | def get_edge_direction_and_name(vertex_field_name):
"""Get the edge direction and name from a non-root vertex field name."""
edge_direction = None
edge_name = None
if vertex_field_name.startswith(OUTBOUND_EDGE_FIELD_PREFIX):
edge_direction = OUTBOUND_EDGE_DIRECTION
edge_name = vertex_fie... | [
"def",
"get_edge_direction_and_name",
"(",
"vertex_field_name",
")",
":",
"edge_direction",
"=",
"None",
"edge_name",
"=",
"None",
"if",
"vertex_field_name",
".",
"startswith",
"(",
"OUTBOUND_EDGE_FIELD_PREFIX",
")",
":",
"edge_direction",
"=",
"OUTBOUND_EDGE_DIRECTION",
... | Get the edge direction and name from a non-root vertex field name. | [
"Get",
"the",
"edge",
"direction",
"and",
"name",
"from",
"a",
"non",
"-",
"root",
"vertex",
"field",
"name",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L101-L116 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | is_vertex_field_type | def is_vertex_field_type(graphql_type):
"""Return True if the argument is a vertex field type, and False otherwise."""
# This will need to change if we ever support complex embedded types or edge field types.
underlying_type = strip_non_null_from_type(graphql_type)
return isinstance(underlying_type, (Gr... | python | def is_vertex_field_type(graphql_type):
"""Return True if the argument is a vertex field type, and False otherwise."""
# This will need to change if we ever support complex embedded types or edge field types.
underlying_type = strip_non_null_from_type(graphql_type)
return isinstance(underlying_type, (Gr... | [
"def",
"is_vertex_field_type",
"(",
"graphql_type",
")",
":",
"underlying_type",
"=",
"strip_non_null_from_type",
"(",
"graphql_type",
")",
"return",
"isinstance",
"(",
"underlying_type",
",",
"(",
"GraphQLInterfaceType",
",",
"GraphQLObjectType",
",",
"GraphQLUnionType",... | Return True if the argument is a vertex field type, and False otherwise. | [
"Return",
"True",
"if",
"the",
"argument",
"is",
"a",
"vertex",
"field",
"type",
"and",
"False",
"otherwise",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L127-L131 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | ensure_unicode_string | def ensure_unicode_string(value):
"""Ensure the value is a string, and return it as unicode."""
if not isinstance(value, six.string_types):
raise TypeError(u'Expected string value, got: {}'.format(value))
return six.text_type(value) | python | def ensure_unicode_string(value):
"""Ensure the value is a string, and return it as unicode."""
if not isinstance(value, six.string_types):
raise TypeError(u'Expected string value, got: {}'.format(value))
return six.text_type(value) | [
"def",
"ensure_unicode_string",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"u'Expected string value, got: {}'",
".",
"format",
"(",
"value",
")",
")",
"return",
"six",
... | Ensure the value is a string, and return it as unicode. | [
"Ensure",
"the",
"value",
"is",
"a",
"string",
"and",
"return",
"it",
"as",
"unicode",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L140-L144 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | get_uniquely_named_objects_by_name | def get_uniquely_named_objects_by_name(object_list):
"""Return dict of name -> object pairs from a list of objects with unique names.
Args:
object_list: list of objects, each X of which has a unique name accessible as X.name.value
Returns:
dict, { X.name.value: X for x in object_list }
... | python | def get_uniquely_named_objects_by_name(object_list):
"""Return dict of name -> object pairs from a list of objects with unique names.
Args:
object_list: list of objects, each X of which has a unique name accessible as X.name.value
Returns:
dict, { X.name.value: X for x in object_list }
... | [
"def",
"get_uniquely_named_objects_by_name",
"(",
"object_list",
")",
":",
"if",
"not",
"object_list",
":",
"return",
"dict",
"(",
")",
"result",
"=",
"dict",
"(",
")",
"for",
"obj",
"in",
"object_list",
":",
"name",
"=",
"obj",
".",
"name",
".",
"value",
... | Return dict of name -> object pairs from a list of objects with unique names.
Args:
object_list: list of objects, each X of which has a unique name accessible as X.name.value
Returns:
dict, { X.name.value: X for x in object_list }
If the list is empty or None, returns an empty dict. | [
"Return",
"dict",
"of",
"name",
"-",
">",
"object",
"pairs",
"from",
"a",
"list",
"of",
"objects",
"with",
"unique",
"names",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L147-L168 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | validate_safe_string | def validate_safe_string(value):
"""Ensure the provided string does not have illegal characters."""
# The following strings are explicitly allowed, despite having otherwise-illegal chars.
legal_strings_with_special_chars = frozenset({'@rid', '@class', '@this', '%'})
if not isinstance(value, six.string_... | python | def validate_safe_string(value):
"""Ensure the provided string does not have illegal characters."""
# The following strings are explicitly allowed, despite having otherwise-illegal chars.
legal_strings_with_special_chars = frozenset({'@rid', '@class', '@this', '%'})
if not isinstance(value, six.string_... | [
"def",
"validate_safe_string",
"(",
"value",
")",
":",
"legal_strings_with_special_chars",
"=",
"frozenset",
"(",
"{",
"'@rid'",
",",
"'@class'",
",",
"'@this'",
",",
"'%'",
"}",
")",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
... | Ensure the provided string does not have illegal characters. | [
"Ensure",
"the",
"provided",
"string",
"does",
"not",
"have",
"illegal",
"characters",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L177-L194 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | validate_edge_direction | def validate_edge_direction(edge_direction):
"""Ensure the provided edge direction is either "in" or "out"."""
if not isinstance(edge_direction, six.string_types):
raise TypeError(u'Expected string edge_direction, got: {} {}'.format(
type(edge_direction), edge_direction))
if... | python | def validate_edge_direction(edge_direction):
"""Ensure the provided edge direction is either "in" or "out"."""
if not isinstance(edge_direction, six.string_types):
raise TypeError(u'Expected string edge_direction, got: {} {}'.format(
type(edge_direction), edge_direction))
if... | [
"def",
"validate_edge_direction",
"(",
"edge_direction",
")",
":",
"if",
"not",
"isinstance",
"(",
"edge_direction",
",",
"six",
".",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"u'Expected string edge_direction, got: {} {}'",
".",
"format",
"(",
"type",
"(... | Ensure the provided edge direction is either "in" or "out". | [
"Ensure",
"the",
"provided",
"edge",
"direction",
"is",
"either",
"in",
"or",
"out",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L205-L212 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | validate_marked_location | def validate_marked_location(location):
"""Validate that a Location object is safe for marking, and not at a field."""
if not isinstance(location, (Location, FoldScopeLocation)):
raise TypeError(u'Expected Location or FoldScopeLocation location, got: {} {}'.format(
type(location).__name__, l... | python | def validate_marked_location(location):
"""Validate that a Location object is safe for marking, and not at a field."""
if not isinstance(location, (Location, FoldScopeLocation)):
raise TypeError(u'Expected Location or FoldScopeLocation location, got: {} {}'.format(
type(location).__name__, l... | [
"def",
"validate_marked_location",
"(",
"location",
")",
":",
"if",
"not",
"isinstance",
"(",
"location",
",",
"(",
"Location",
",",
"FoldScopeLocation",
")",
")",
":",
"raise",
"TypeError",
"(",
"u'Expected Location or FoldScopeLocation location, got: {} {}'",
".",
"... | Validate that a Location object is safe for marking, and not at a field. | [
"Validate",
"that",
"a",
"Location",
"object",
"is",
"safe",
"for",
"marking",
"and",
"not",
"at",
"a",
"field",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L215-L222 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/helpers.py | invert_dict | def invert_dict(invertible_dict):
"""Invert a dict. A dict is invertible if values are unique and hashable."""
inverted = {}
for k, v in six.iteritems(invertible_dict):
if not isinstance(v, Hashable):
raise TypeError(u'Expected an invertible dict, but value at key {} has type {}'.format(... | python | def invert_dict(invertible_dict):
"""Invert a dict. A dict is invertible if values are unique and hashable."""
inverted = {}
for k, v in six.iteritems(invertible_dict):
if not isinstance(v, Hashable):
raise TypeError(u'Expected an invertible dict, but value at key {} has type {}'.format(... | [
"def",
"invert_dict",
"(",
"invertible_dict",
")",
":",
"inverted",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"six",
".",
"iteritems",
"(",
"invertible_dict",
")",
":",
"if",
"not",
"isinstance",
"(",
"v",
",",
"Hashable",
")",
":",
"raise",
"TypeErro... | Invert a dict. A dict is invertible if values are unique and hashable. | [
"Invert",
"a",
"dict",
".",
"A",
"dict",
"is",
"invertible",
"if",
"values",
"are",
"unique",
"and",
"hashable",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/helpers.py#L230-L242 | train |
kensho-technologies/graphql-compiler | setup.py | read_file | def read_file(filename):
"""Read package file as text to get name and version"""
# intentionally *not* adding an encoding option to open
# see here:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.joi... | python | def read_file(filename):
"""Read package file as text to get name and version"""
# intentionally *not* adding an encoding option to open
# see here:
# https://github.com/pypa/virtualenv/issues/201#issuecomment-3145690
here = os.path.abspath(os.path.dirname(__file__))
with codecs.open(os.path.joi... | [
"def",
"read_file",
"(",
"filename",
")",
":",
"here",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
")",
"with",
"codecs",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"here",
","... | Read package file as text to get name and version | [
"Read",
"package",
"file",
"as",
"text",
"to",
"get",
"name",
"and",
"version"
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/setup.py#L13-L20 | train |
kensho-technologies/graphql-compiler | setup.py | find_version | def find_version():
"""Only define version in one place"""
version_file = read_file('__init__.py')
version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']',
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError('Unable to ... | python | def find_version():
"""Only define version in one place"""
version_file = read_file('__init__.py')
version_match = re.search(r'^__version__ = ["\']([^"\']*)["\']',
version_file, re.M)
if version_match:
return version_match.group(1)
raise RuntimeError('Unable to ... | [
"def",
"find_version",
"(",
")",
":",
"version_file",
"=",
"read_file",
"(",
"'__init__.py'",
")",
"version_match",
"=",
"re",
".",
"search",
"(",
"r'^__version__ = [\"\\']([^\"\\']*)[\"\\']'",
",",
"version_file",
",",
"re",
".",
"M",
")",
"if",
"version_match",
... | Only define version in one place | [
"Only",
"define",
"version",
"in",
"one",
"place"
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/setup.py#L23-L30 | train |
kensho-technologies/graphql-compiler | setup.py | find_name | def find_name():
"""Only define name in one place"""
name_file = read_file('__init__.py')
name_match = re.search(r'^__package_name__ = ["\']([^"\']*)["\']',
name_file, re.M)
if name_match:
return name_match.group(1)
raise RuntimeError('Unable to find name string.') | python | def find_name():
"""Only define name in one place"""
name_file = read_file('__init__.py')
name_match = re.search(r'^__package_name__ = ["\']([^"\']*)["\']',
name_file, re.M)
if name_match:
return name_match.group(1)
raise RuntimeError('Unable to find name string.') | [
"def",
"find_name",
"(",
")",
":",
"name_file",
"=",
"read_file",
"(",
"'__init__.py'",
")",
"name_match",
"=",
"re",
".",
"search",
"(",
"r'^__package_name__ = [\"\\']([^\"\\']*)[\"\\']'",
",",
"name_file",
",",
"re",
".",
"M",
")",
"if",
"name_match",
":",
"... | Only define name in one place | [
"Only",
"define",
"name",
"in",
"one",
"place"
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/setup.py#L33-L40 | train |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/workarounds/orientdb_class_with_while.py | workaround_type_coercions_in_recursions | def workaround_type_coercions_in_recursions(match_query):
"""Lower CoerceType blocks into Filter blocks within Recurse steps."""
# This step is required to work around an OrientDB bug that causes queries with both
# "while:" and "class:" in the same query location to fail to parse correctly.
#
# Thi... | python | def workaround_type_coercions_in_recursions(match_query):
"""Lower CoerceType blocks into Filter blocks within Recurse steps."""
# This step is required to work around an OrientDB bug that causes queries with both
# "while:" and "class:" in the same query location to fail to parse correctly.
#
# Thi... | [
"def",
"workaround_type_coercions_in_recursions",
"(",
"match_query",
")",
":",
"new_match_traversals",
"=",
"[",
"]",
"for",
"current_traversal",
"in",
"match_query",
".",
"match_traversals",
":",
"new_traversal",
"=",
"[",
"]",
"for",
"match_step",
"in",
"current_tr... | Lower CoerceType blocks into Filter blocks within Recurse steps. | [
"Lower",
"CoerceType",
"blocks",
"into",
"Filter",
"blocks",
"within",
"Recurse",
"steps",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/workarounds/orientdb_class_with_while.py#L11-L42 | train |
kensho-technologies/graphql-compiler | graphql_compiler/tool.py | main | def main():
"""Read a GraphQL query from standard input, and output it pretty-printed to standard output."""
query = ' '.join(sys.stdin.readlines())
sys.stdout.write(pretty_print_graphql(query)) | python | def main():
"""Read a GraphQL query from standard input, and output it pretty-printed to standard output."""
query = ' '.join(sys.stdin.readlines())
sys.stdout.write(pretty_print_graphql(query)) | [
"def",
"main",
"(",
")",
":",
"query",
"=",
"' '",
".",
"join",
"(",
"sys",
".",
"stdin",
".",
"readlines",
"(",
")",
")",
"sys",
".",
"stdout",
".",
"write",
"(",
"pretty_print_graphql",
"(",
"query",
")",
")"
] | Read a GraphQL query from standard input, and output it pretty-printed to standard output. | [
"Read",
"a",
"GraphQL",
"query",
"from",
"standard",
"input",
"and",
"output",
"it",
"pretty",
"-",
"printed",
"to",
"standard",
"output",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/tool.py#L12-L16 | train |
kensho-technologies/graphql-compiler | graphql_compiler/query_formatting/gremlin_formatting.py | _safe_gremlin_string | def _safe_gremlin_string(value):
"""Sanitize and represent a string argument in Gremlin."""
if not isinstance(value, six.string_types):
if isinstance(value, bytes): # should only happen in py3
value = value.decode('utf-8')
else:
raise GraphQLInvalidArgumentError(u'Attemp... | python | def _safe_gremlin_string(value):
"""Sanitize and represent a string argument in Gremlin."""
if not isinstance(value, six.string_types):
if isinstance(value, bytes): # should only happen in py3
value = value.decode('utf-8')
else:
raise GraphQLInvalidArgumentError(u'Attemp... | [
"def",
"_safe_gremlin_string",
"(",
"value",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"six",
".",
"string_types",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"bytes",
")",
":",
"value",
"=",
"value",
".",
"decode",
"(",
"'utf-8'",
"... | Sanitize and represent a string argument in Gremlin. | [
"Sanitize",
"and",
"represent",
"a",
"string",
"argument",
"in",
"Gremlin",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/gremlin_formatting.py#L18-L48 | train |
kensho-technologies/graphql-compiler | graphql_compiler/query_formatting/gremlin_formatting.py | _safe_gremlin_list | def _safe_gremlin_list(inner_type, argument_value):
"""Represent the list of "inner_type" objects in Gremlin form."""
if not isinstance(argument_value, list):
raise GraphQLInvalidArgumentError(u'Attempting to represent a non-list as a list: '
u'{}'.format(argume... | python | def _safe_gremlin_list(inner_type, argument_value):
"""Represent the list of "inner_type" objects in Gremlin form."""
if not isinstance(argument_value, list):
raise GraphQLInvalidArgumentError(u'Attempting to represent a non-list as a list: '
u'{}'.format(argume... | [
"def",
"_safe_gremlin_list",
"(",
"inner_type",
",",
"argument_value",
")",
":",
"if",
"not",
"isinstance",
"(",
"argument_value",
",",
"list",
")",
":",
"raise",
"GraphQLInvalidArgumentError",
"(",
"u'Attempting to represent a non-list as a list: '",
"u'{}'",
".",
"for... | Represent the list of "inner_type" objects in Gremlin form. | [
"Represent",
"the",
"list",
"of",
"inner_type",
"objects",
"in",
"Gremlin",
"form",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/gremlin_formatting.py#L81-L92 | train |
kensho-technologies/graphql-compiler | graphql_compiler/query_formatting/gremlin_formatting.py | _safe_gremlin_argument | def _safe_gremlin_argument(expected_type, argument_value):
"""Return a Gremlin string representing the given argument value."""
if GraphQLString.is_same_type(expected_type):
return _safe_gremlin_string(argument_value)
elif GraphQLID.is_same_type(expected_type):
# IDs can be strings or number... | python | def _safe_gremlin_argument(expected_type, argument_value):
"""Return a Gremlin string representing the given argument value."""
if GraphQLString.is_same_type(expected_type):
return _safe_gremlin_string(argument_value)
elif GraphQLID.is_same_type(expected_type):
# IDs can be strings or number... | [
"def",
"_safe_gremlin_argument",
"(",
"expected_type",
",",
"argument_value",
")",
":",
"if",
"GraphQLString",
".",
"is_same_type",
"(",
"expected_type",
")",
":",
"return",
"_safe_gremlin_string",
"(",
"argument_value",
")",
"elif",
"GraphQLID",
".",
"is_same_type",
... | Return a Gremlin string representing the given argument value. | [
"Return",
"a",
"Gremlin",
"string",
"representing",
"the",
"given",
"argument",
"value",
"."
] | f6079c6d10f64932f6b3af309b79bcea2123ca8f | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/query_formatting/gremlin_formatting.py#L95-L131 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.