repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
googlefonts/glyphsLib
Lib/glyphsLib/parser.py
Parser._fail
def _fail(self, message, text, i): """Raise an exception with given message and text at i.""" raise ValueError("{}:\n{}".format(message, text[i : i + 79]))
python
def _fail(self, message, text, i): """Raise an exception with given message and text at i.""" raise ValueError("{}:\n{}".format(message, text[i : i + 79]))
[ "def", "_fail", "(", "self", ",", "message", ",", "text", ",", "i", ")", ":", "raise", "ValueError", "(", "\"{}:\\n{}\"", ".", "format", "(", "message", ",", "text", "[", "i", ":", "i", "+", "79", "]", ")", ")" ]
Raise an exception with given message and text at i.
[ "Raise", "an", "exception", "with", "given", "message", "and", "text", "at", "i", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/parser.py#L233-L236
googlefonts/glyphsLib
Lib/glyphsLib/builder/names.py
build_stylemap_names
def build_stylemap_names( family_name, style_name, is_bold=False, is_italic=False, linked_style=None ): """Build UFO `styleMapFamilyName` and `styleMapStyleName` based on the family and style names, and the entries in the "Style Linking" section of the "Instances" tab in the "Font Info". The value ...
python
def build_stylemap_names( family_name, style_name, is_bold=False, is_italic=False, linked_style=None ): """Build UFO `styleMapFamilyName` and `styleMapStyleName` based on the family and style names, and the entries in the "Style Linking" section of the "Instances" tab in the "Font Info". The value ...
[ "def", "build_stylemap_names", "(", "family_name", ",", "style_name", ",", "is_bold", "=", "False", ",", "is_italic", "=", "False", ",", "linked_style", "=", "None", ")", ":", "styleMapStyleName", "=", "(", "\" \"", ".", "join", "(", "s", "for", "s", "in",...
Build UFO `styleMapFamilyName` and `styleMapStyleName` based on the family and style names, and the entries in the "Style Linking" section of the "Instances" tab in the "Font Info". The value of `styleMapStyleName` can be either "regular", "bold", "italic" or "bold italic", depending on the values of `...
[ "Build", "UFO", "styleMapFamilyName", "and", "styleMapStyleName", "based", "on", "the", "family", "and", "style", "names", "and", "the", "entries", "in", "the", "Style", "Linking", "section", "of", "the", "Instances", "tab", "in", "the", "Font", "Info", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/names.py#L55-L85
googlefonts/glyphsLib
Lib/glyphsLib/builder/blue_values.py
to_ufo_blue_values
def to_ufo_blue_values(self, ufo, master): """Set postscript blue values from Glyphs alignment zones.""" alignment_zones = master.alignmentZones blue_values = [] other_blues = [] for zone in sorted(alignment_zones): pos = zone.position size = zone.size val_list = blue_values...
python
def to_ufo_blue_values(self, ufo, master): """Set postscript blue values from Glyphs alignment zones.""" alignment_zones = master.alignmentZones blue_values = [] other_blues = [] for zone in sorted(alignment_zones): pos = zone.position size = zone.size val_list = blue_values...
[ "def", "to_ufo_blue_values", "(", "self", ",", "ufo", ",", "master", ")", ":", "alignment_zones", "=", "master", ".", "alignmentZones", "blue_values", "=", "[", "]", "other_blues", "=", "[", "]", "for", "zone", "in", "sorted", "(", "alignment_zones", ")", ...
Set postscript blue values from Glyphs alignment zones.
[ "Set", "postscript", "blue", "values", "from", "Glyphs", "alignment", "zones", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/blue_values.py#L18-L31
googlefonts/glyphsLib
Lib/glyphsLib/builder/blue_values.py
to_glyphs_blue_values
def to_glyphs_blue_values(self, ufo, master): """Sets the GSFontMaster alignmentZones from the postscript blue values.""" zones = [] blue_values = _pairs(ufo.info.postscriptBlueValues) other_blues = _pairs(ufo.info.postscriptOtherBlues) for y1, y2 in blue_values: size = y2 - y1 if y...
python
def to_glyphs_blue_values(self, ufo, master): """Sets the GSFontMaster alignmentZones from the postscript blue values.""" zones = [] blue_values = _pairs(ufo.info.postscriptBlueValues) other_blues = _pairs(ufo.info.postscriptOtherBlues) for y1, y2 in blue_values: size = y2 - y1 if y...
[ "def", "to_glyphs_blue_values", "(", "self", ",", "ufo", ",", "master", ")", ":", "zones", "=", "[", "]", "blue_values", "=", "_pairs", "(", "ufo", ".", "info", ".", "postscriptBlueValues", ")", "other_blues", "=", "_pairs", "(", "ufo", ".", "info", ".",...
Sets the GSFontMaster alignmentZones from the postscript blue values.
[ "Sets", "the", "GSFontMaster", "alignmentZones", "from", "the", "postscript", "blue", "values", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/blue_values.py#L34-L53
googlefonts/glyphsLib
Lib/glyphsLib/builder/filters.py
parse_glyphs_filter
def parse_glyphs_filter(filter_str, is_pre=False): """Parses glyphs custom filter string into a dict object that ufo2ft can consume. Reference: ufo2ft: https://github.com/googlei18n/ufo2ft Glyphs 2.3 Handbook July 2016, p184 Args: filter_str - a string of...
python
def parse_glyphs_filter(filter_str, is_pre=False): """Parses glyphs custom filter string into a dict object that ufo2ft can consume. Reference: ufo2ft: https://github.com/googlei18n/ufo2ft Glyphs 2.3 Handbook July 2016, p184 Args: filter_str - a string of...
[ "def", "parse_glyphs_filter", "(", "filter_str", ",", "is_pre", "=", "False", ")", ":", "elements", "=", "filter_str", ".", "split", "(", "\";\"", ")", "if", "elements", "[", "0", "]", "==", "\"\"", ":", "logger", ".", "error", "(", "\"Failed to parse glyp...
Parses glyphs custom filter string into a dict object that ufo2ft can consume. Reference: ufo2ft: https://github.com/googlei18n/ufo2ft Glyphs 2.3 Handbook July 2016, p184 Args: filter_str - a string of glyphs app filter Return: A dictiona...
[ "Parses", "glyphs", "custom", "filter", "string", "into", "a", "dict", "object", "that", "ufo2ft", "can", "consume", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/filters.py#L25-L76
googlefonts/glyphsLib
Lib/glyphsLib/util.py
build_ufo_path
def build_ufo_path(out_dir, family_name, style_name): """Build string to use as a UFO path.""" return os.path.join( out_dir, "%s-%s.ufo" % ((family_name or "").replace(" ", ""), (style_name or "").replace(" ", "")), )
python
def build_ufo_path(out_dir, family_name, style_name): """Build string to use as a UFO path.""" return os.path.join( out_dir, "%s-%s.ufo" % ((family_name or "").replace(" ", ""), (style_name or "").replace(" ", "")), )
[ "def", "build_ufo_path", "(", "out_dir", ",", "family_name", ",", "style_name", ")", ":", "return", "os", ".", "path", ".", "join", "(", "out_dir", ",", "\"%s-%s.ufo\"", "%", "(", "(", "family_name", "or", "\"\"", ")", ".", "replace", "(", "\" \"", ",", ...
Build string to use as a UFO path.
[ "Build", "string", "to", "use", "as", "a", "UFO", "path", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L26-L33
googlefonts/glyphsLib
Lib/glyphsLib/util.py
write_ufo
def write_ufo(ufo, out_dir): """Write a UFO.""" out_path = build_ufo_path(out_dir, ufo.info.familyName, ufo.info.styleName) logger.info("Writing %s" % out_path) clean_ufo(out_path) ufo.save(out_path)
python
def write_ufo(ufo, out_dir): """Write a UFO.""" out_path = build_ufo_path(out_dir, ufo.info.familyName, ufo.info.styleName) logger.info("Writing %s" % out_path) clean_ufo(out_path) ufo.save(out_path)
[ "def", "write_ufo", "(", "ufo", ",", "out_dir", ")", ":", "out_path", "=", "build_ufo_path", "(", "out_dir", ",", "ufo", ".", "info", ".", "familyName", ",", "ufo", ".", "info", ".", "styleName", ")", "logger", ".", "info", "(", "\"Writing %s\"", "%", ...
Write a UFO.
[ "Write", "a", "UFO", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L36-L43
googlefonts/glyphsLib
Lib/glyphsLib/util.py
clean_ufo
def clean_ufo(path): """Make sure old UFO data is removed, as it may contain deleted glyphs.""" if path.endswith(".ufo") and os.path.exists(path): shutil.rmtree(path)
python
def clean_ufo(path): """Make sure old UFO data is removed, as it may contain deleted glyphs.""" if path.endswith(".ufo") and os.path.exists(path): shutil.rmtree(path)
[ "def", "clean_ufo", "(", "path", ")", ":", "if", "path", ".", "endswith", "(", "\".ufo\"", ")", "and", "os", ".", "path", ".", "exists", "(", "path", ")", ":", "shutil", ".", "rmtree", "(", "path", ")" ]
Make sure old UFO data is removed, as it may contain deleted glyphs.
[ "Make", "sure", "old", "UFO", "data", "is", "removed", "as", "it", "may", "contain", "deleted", "glyphs", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L46-L50
googlefonts/glyphsLib
Lib/glyphsLib/util.py
ufo_create_background_layer_for_all_glyphs
def ufo_create_background_layer_for_all_glyphs(ufo_font): # type: (defcon.Font) -> None """Create a background layer for all glyphs in ufo_font if not present to reduce roundtrip differences.""" if "public.background" in ufo_font.layers: background = ufo_font.layers["public.background"] els...
python
def ufo_create_background_layer_for_all_glyphs(ufo_font): # type: (defcon.Font) -> None """Create a background layer for all glyphs in ufo_font if not present to reduce roundtrip differences.""" if "public.background" in ufo_font.layers: background = ufo_font.layers["public.background"] els...
[ "def", "ufo_create_background_layer_for_all_glyphs", "(", "ufo_font", ")", ":", "# type: (defcon.Font) -> None", "if", "\"public.background\"", "in", "ufo_font", ".", "layers", ":", "background", "=", "ufo_font", ".", "layers", "[", "\"public.background\"", "]", "else", ...
Create a background layer for all glyphs in ufo_font if not present to reduce roundtrip differences.
[ "Create", "a", "background", "layer", "for", "all", "glyphs", "in", "ufo_font", "if", "not", "present", "to", "reduce", "roundtrip", "differences", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L53-L65
googlefonts/glyphsLib
Lib/glyphsLib/util.py
cast_to_number_or_bool
def cast_to_number_or_bool(inputstr): """Cast a string to int, float or bool. Return original string if it can't be converted. Scientific expression is converted into float. """ if inputstr.strip().lower() == "true": return True elif inputstr.strip().lower() == "false": return F...
python
def cast_to_number_or_bool(inputstr): """Cast a string to int, float or bool. Return original string if it can't be converted. Scientific expression is converted into float. """ if inputstr.strip().lower() == "true": return True elif inputstr.strip().lower() == "false": return F...
[ "def", "cast_to_number_or_bool", "(", "inputstr", ")", ":", "if", "inputstr", ".", "strip", "(", ")", ".", "lower", "(", ")", "==", "\"true\"", ":", "return", "True", "elif", "inputstr", ".", "strip", "(", ")", ".", "lower", "(", ")", "==", "\"false\""...
Cast a string to int, float or bool. Return original string if it can't be converted. Scientific expression is converted into float.
[ "Cast", "a", "string", "to", "int", "float", "or", "bool", ".", "Return", "original", "string", "if", "it", "can", "t", "be", "converted", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/util.py#L68-L84
googlefonts/glyphsLib
Lib/glyphsLib/builder/background_image.py
to_ufo_background_image
def to_ufo_background_image(self, ufo_glyph, layer): """Copy the backgound image from the GSLayer to the UFO Glyph.""" image = layer.backgroundImage if image is None: return ufo_image = ufo_glyph.image ufo_image.fileName = image.path ufo_image.transformation = image.transform ufo_gly...
python
def to_ufo_background_image(self, ufo_glyph, layer): """Copy the backgound image from the GSLayer to the UFO Glyph.""" image = layer.backgroundImage if image is None: return ufo_image = ufo_glyph.image ufo_image.fileName = image.path ufo_image.transformation = image.transform ufo_gly...
[ "def", "to_ufo_background_image", "(", "self", ",", "ufo_glyph", ",", "layer", ")", ":", "image", "=", "layer", ".", "backgroundImage", "if", "image", "is", "None", ":", "return", "ufo_image", "=", "ufo_glyph", ".", "image", "ufo_image", ".", "fileName", "="...
Copy the backgound image from the GSLayer to the UFO Glyph.
[ "Copy", "the", "backgound", "image", "from", "the", "GSLayer", "to", "the", "UFO", "Glyph", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/background_image.py#L26-L36
googlefonts/glyphsLib
Lib/glyphsLib/builder/background_image.py
to_glyphs_background_image
def to_glyphs_background_image(self, ufo_glyph, layer): """Copy the background image from the UFO Glyph to the GSLayer.""" ufo_image = ufo_glyph.image if ufo_image.fileName is None: return image = self.glyphs_module.GSBackgroundImage() image.path = ufo_image.fileName image.transform = Tr...
python
def to_glyphs_background_image(self, ufo_glyph, layer): """Copy the background image from the UFO Glyph to the GSLayer.""" ufo_image = ufo_glyph.image if ufo_image.fileName is None: return image = self.glyphs_module.GSBackgroundImage() image.path = ufo_image.fileName image.transform = Tr...
[ "def", "to_glyphs_background_image", "(", "self", ",", "ufo_glyph", ",", "layer", ")", ":", "ufo_image", "=", "ufo_glyph", ".", "image", "if", "ufo_image", ".", "fileName", "is", "None", ":", "return", "image", "=", "self", ".", "glyphs_module", ".", "GSBack...
Copy the background image from the UFO Glyph to the GSLayer.
[ "Copy", "the", "background", "image", "from", "the", "UFO", "Glyph", "to", "the", "GSLayer", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/background_image.py#L39-L54
googlefonts/glyphsLib
Lib/glyphsLib/builder/guidelines.py
to_ufo_guidelines
def to_ufo_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" guidelines = glyphs_obj.guides if not guidelines: return new_guidelines = [] for guideline in guidelines: new_guideline = {} x, y = guideline.position angle = guideline.angle % 360 if _is_...
python
def to_ufo_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" guidelines = glyphs_obj.guides if not guidelines: return new_guidelines = [] for guideline in guidelines: new_guideline = {} x, y = guideline.position angle = guideline.angle % 360 if _is_...
[ "def", "to_ufo_guidelines", "(", "self", ",", "ufo_obj", ",", "glyphs_obj", ")", ":", "guidelines", "=", "glyphs_obj", ".", "guides", "if", "not", "guidelines", ":", "return", "new_guidelines", "=", "[", "]", "for", "guideline", "in", "guidelines", ":", "new...
Set guidelines.
[ "Set", "guidelines", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/guidelines.py#L28-L63
googlefonts/glyphsLib
Lib/glyphsLib/builder/guidelines.py
to_glyphs_guidelines
def to_glyphs_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" if not ufo_obj.guidelines: return for guideline in ufo_obj.guidelines: new_guideline = self.glyphs_module.GSGuideLine() name = guideline.name # Locked if name is not None and name.endswith(LOCK...
python
def to_glyphs_guidelines(self, ufo_obj, glyphs_obj): """Set guidelines.""" if not ufo_obj.guidelines: return for guideline in ufo_obj.guidelines: new_guideline = self.glyphs_module.GSGuideLine() name = guideline.name # Locked if name is not None and name.endswith(LOCK...
[ "def", "to_glyphs_guidelines", "(", "self", ",", "ufo_obj", ",", "glyphs_obj", ")", ":", "if", "not", "ufo_obj", ".", "guidelines", ":", "return", "for", "guideline", "in", "ufo_obj", ".", "guidelines", ":", "new_guideline", "=", "self", ".", "glyphs_module", ...
Set guidelines.
[ "Set", "guidelines", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/guidelines.py#L66-L87
4Catalyzer/flask-resty
flask_resty/api.py
Api.add_resource
def add_resource( self, base_rule, base_view, alternate_view=None, alternate_rule=None, id_rule=None, app=None, ): """Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by...
python
def add_resource( self, base_rule, base_view, alternate_view=None, alternate_rule=None, id_rule=None, app=None, ): """Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by...
[ "def", "add_resource", "(", "self", ",", "base_rule", ",", "base_view", ",", "alternate_view", "=", "None", ",", "alternate_rule", "=", "None", ",", "id_rule", "=", "None", ",", "app", "=", "None", ",", ")", ":", "if", "alternate_view", ":", "if", "not",...
Add route or routes for a resource. :param str base_rule: The URL rule for the resource. This will be prefixed by the API prefix. :param base_view: Class-based view for the resource. :param alternate_view: If specified, an alternate class-based view for the resource. Usu...
[ "Add", "route", "or", "routes", "for", "a", "resource", "." ]
train
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/api.py#L61-L137
4Catalyzer/flask-resty
flask_resty/api.py
Api.add_ping
def add_ping(self, rule, status_code=200, app=None): """Add a ping route. :param str rule: The URL rule. This will not use the API prefix, as the ping endpoint is not really part of the API. :param int status_code: The ping response status code. The default is 200 rather...
python
def add_ping(self, rule, status_code=200, app=None): """Add a ping route. :param str rule: The URL rule. This will not use the API prefix, as the ping endpoint is not really part of the API. :param int status_code: The ping response status code. The default is 200 rather...
[ "def", "add_ping", "(", "self", ",", "rule", ",", "status_code", "=", "200", ",", "app", "=", "None", ")", ":", "app", "=", "self", ".", "_get_app", "(", "app", ")", "@", "app", ".", "route", "(", "rule", ")", "def", "ping", "(", ")", ":", "ret...
Add a ping route. :param str rule: The URL rule. This will not use the API prefix, as the ping endpoint is not really part of the API. :param int status_code: The ping response status code. The default is 200 rather than the more correct 204 because many health checks ...
[ "Add", "a", "ping", "route", "." ]
train
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/api.py#L150-L165
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
UFOBuilder.masters
def masters(self): """Get an iterator over master UFOs that match the given family_name. """ if self._sources: for source in self._sources.values(): yield source.font return # Store set of actually existing master (layer) ids. This helps with ...
python
def masters(self): """Get an iterator over master UFOs that match the given family_name. """ if self._sources: for source in self._sources.values(): yield source.font return # Store set of actually existing master (layer) ids. This helps with ...
[ "def", "masters", "(", "self", ")", ":", "if", "self", ".", "_sources", ":", "for", "source", "in", "self", ".", "_sources", ".", "values", "(", ")", ":", "yield", "source", ".", "font", "return", "# Store set of actually existing master (layer) ids. This helps ...
Get an iterator over master UFOs that match the given family_name.
[ "Get", "an", "iterator", "over", "master", "UFOs", "that", "match", "the", "given", "family_name", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L128-L227
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
UFOBuilder.designspace
def designspace(self): """Get a designspace Document instance that links the masters together and holds instance data. """ if self._designspace_is_complete: return self._designspace self._designspace_is_complete = True list(self.masters) # Make sure that the...
python
def designspace(self): """Get a designspace Document instance that links the masters together and holds instance data. """ if self._designspace_is_complete: return self._designspace self._designspace_is_complete = True list(self.masters) # Make sure that the...
[ "def", "designspace", "(", "self", ")", ":", "if", "self", ".", "_designspace_is_complete", ":", "return", "self", ".", "_designspace", "self", ".", "_designspace_is_complete", "=", "True", "list", "(", "self", ".", "masters", ")", "# Make sure that the UFOs are b...
Get a designspace Document instance that links the masters together and holds instance data.
[ "Get", "a", "designspace", "Document", "instance", "that", "links", "the", "masters", "together", "and", "holds", "instance", "data", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L230-L255
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
UFOBuilder._apply_bracket_layers
def _apply_bracket_layers(self): """Extract bracket layers in a GSGlyph into free-standing UFO glyphs with Designspace substitution rules. As of Glyphs.app 2.6, only single axis bracket layers are supported, we assume the axis to be the first axis in the Designspace. Bracket layer ...
python
def _apply_bracket_layers(self): """Extract bracket layers in a GSGlyph into free-standing UFO glyphs with Designspace substitution rules. As of Glyphs.app 2.6, only single axis bracket layers are supported, we assume the axis to be the first axis in the Designspace. Bracket layer ...
[ "def", "_apply_bracket_layers", "(", "self", ")", ":", "if", "not", "self", ".", "_designspace", ".", "axes", ":", "raise", "ValueError", "(", "\"Cannot apply bracket layers unless at least one axis is defined.\"", ")", "bracket_axis", "=", "self", ".", "_designspace", ...
Extract bracket layers in a GSGlyph into free-standing UFO glyphs with Designspace substitution rules. As of Glyphs.app 2.6, only single axis bracket layers are supported, we assume the axis to be the first axis in the Designspace. Bracket layer backgrounds are not round-tripped. ...
[ "Extract", "bracket", "layers", "in", "a", "GSGlyph", "into", "free", "-", "standing", "UFO", "glyphs", "with", "Designspace", "substitution", "rules", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L277-L419
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
GlyphsBuilder.font
def font(self): """Get the GSFont built from the UFOs + designspace.""" if self._font is not None: return self._font # Sort UFOS in the original order from the Glyphs file sorted_sources = self.to_glyphs_ordered_masters() # Convert all full source UFOs to Glyphs mas...
python
def font(self): """Get the GSFont built from the UFOs + designspace.""" if self._font is not None: return self._font # Sort UFOS in the original order from the Glyphs file sorted_sources = self.to_glyphs_ordered_masters() # Convert all full source UFOs to Glyphs mas...
[ "def", "font", "(", "self", ")", ":", "if", "self", ".", "_font", "is", "not", "None", ":", "return", "self", ".", "_font", "# Sort UFOS in the original order from the Glyphs file", "sorted_sources", "=", "self", ".", "to_glyphs_ordered_masters", "(", ")", "# Conv...
Get the GSFont built from the UFOs + designspace.
[ "Get", "the", "GSFont", "built", "from", "the", "UFOs", "+", "designspace", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L512-L597
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
GlyphsBuilder._valid_designspace
def _valid_designspace(self, designspace): """Make sure that the user-provided designspace has loaded fonts and that names are the same as those from the UFOs. """ # TODO: (jany) really make a copy to avoid modifying the original object copy = designspace # Load only full...
python
def _valid_designspace(self, designspace): """Make sure that the user-provided designspace has loaded fonts and that names are the same as those from the UFOs. """ # TODO: (jany) really make a copy to avoid modifying the original object copy = designspace # Load only full...
[ "def", "_valid_designspace", "(", "self", ",", "designspace", ")", ":", "# TODO: (jany) really make a copy to avoid modifying the original object", "copy", "=", "designspace", "# Load only full UFO masters, sparse or \"brace\" layer sources are assumed", "# to point to existing layers with...
Make sure that the user-provided designspace has loaded fonts and that names are the same as those from the UFOs.
[ "Make", "sure", "that", "the", "user", "-", "provided", "designspace", "has", "loaded", "fonts", "and", "that", "names", "are", "the", "same", "as", "those", "from", "the", "UFOs", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L599-L638
googlefonts/glyphsLib
Lib/glyphsLib/builder/builders.py
GlyphsBuilder._fake_designspace
def _fake_designspace(self, ufos): """Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace. """ designspace = designspaceLib.DesignSpaceDocument() ufo_to_location = defaultdict(dict) # Make weig...
python
def _fake_designspace(self, ufos): """Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace. """ designspace = designspaceLib.DesignSpaceDocument() ufo_to_location = defaultdict(dict) # Make weig...
[ "def", "_fake_designspace", "(", "self", ",", "ufos", ")", ":", "designspace", "=", "designspaceLib", ".", "DesignSpaceDocument", "(", ")", "ufo_to_location", "=", "defaultdict", "(", "dict", ")", "# Make weight and width axis if relevant", "for", "info_key", ",", "...
Build a fake designspace with the given UFOs as sources, so that all builder functions can rely on the presence of a designspace.
[ "Build", "a", "fake", "designspace", "with", "the", "given", "UFOs", "as", "sources", "so", "that", "all", "builder", "functions", "can", "rely", "on", "the", "presence", "of", "a", "designspace", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/builders.py#L640-L702
googlefonts/glyphsLib
Lib/glyphsLib/builder/kerning.py
_to_ufo_kerning
def _to_ufo_kerning(self, ufo, kerning_data): """Add .glyphs kerning to an UFO.""" warning_msg = "Non-existent glyph class %s found in kerning rules." for left, pairs in kerning_data.items(): match = re.match(r"@MMK_L_(.+)", left) left_is_class = bool(match) if left_is_class: ...
python
def _to_ufo_kerning(self, ufo, kerning_data): """Add .glyphs kerning to an UFO.""" warning_msg = "Non-existent glyph class %s found in kerning rules." for left, pairs in kerning_data.items(): match = re.match(r"@MMK_L_(.+)", left) left_is_class = bool(match) if left_is_class: ...
[ "def", "_to_ufo_kerning", "(", "self", ",", "ufo", ",", "kerning_data", ")", ":", "warning_msg", "=", "\"Non-existent glyph class %s found in kerning rules.\"", "for", "left", ",", "pairs", "in", "kerning_data", ".", "items", "(", ")", ":", "match", "=", "re", "...
Add .glyphs kerning to an UFO.
[ "Add", ".", "glyphs", "kerning", "to", "an", "UFO", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/kerning.py#L27-L46
googlefonts/glyphsLib
Lib/glyphsLib/builder/kerning.py
to_glyphs_kerning
def to_glyphs_kerning(self): """Add UFO kerning to GSFont.""" for master_id, source in self._sources.items(): for (left, right), value in source.font.kerning.items(): left_match = UFO_KERN_GROUP_PATTERN.match(left) right_match = UFO_KERN_GROUP_PATTERN.match(right) if ...
python
def to_glyphs_kerning(self): """Add UFO kerning to GSFont.""" for master_id, source in self._sources.items(): for (left, right), value in source.font.kerning.items(): left_match = UFO_KERN_GROUP_PATTERN.match(left) right_match = UFO_KERN_GROUP_PATTERN.match(right) if ...
[ "def", "to_glyphs_kerning", "(", "self", ")", ":", "for", "master_id", ",", "source", "in", "self", ".", "_sources", ".", "items", "(", ")", ":", "for", "(", "left", ",", "right", ")", ",", "value", "in", "source", ".", "font", ".", "kerning", ".", ...
Add UFO kerning to GSFont.
[ "Add", "UFO", "kerning", "to", "GSFont", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/kerning.py#L49-L59
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
_normalize_custom_param_name
def _normalize_custom_param_name(name): """Replace curved quotes with straight quotes in a custom parameter name. These should be the only keys with problematic (non-ascii) characters, since they can be user-generated. """ replacements = (("\u2018", "'"), ("\u2019", "'"), ("\u201C", '"'), ("\u201D"...
python
def _normalize_custom_param_name(name): """Replace curved quotes with straight quotes in a custom parameter name. These should be the only keys with problematic (non-ascii) characters, since they can be user-generated. """ replacements = (("\u2018", "'"), ("\u2019", "'"), ("\u201C", '"'), ("\u201D"...
[ "def", "_normalize_custom_param_name", "(", "name", ")", ":", "replacements", "=", "(", "(", "\"\\u2018\"", ",", "\"'\"", ")", ",", "(", "\"\\u2019\"", ",", "\"'\"", ")", ",", "(", "\"\\u201C\"", ",", "'\"'", ")", ",", "(", "\"\\u201D\"", ",", "'\"'", ")...
Replace curved quotes with straight quotes in a custom parameter name. These should be the only keys with problematic (non-ascii) characters, since they can be user-generated.
[ "Replace", "curved", "quotes", "with", "straight", "quotes", "in", "a", "custom", "parameter", "name", ".", "These", "should", "be", "the", "only", "keys", "with", "problematic", "(", "non", "-", "ascii", ")", "characters", "since", "they", "can", "be", "u...
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L757-L766
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
_set_default_params
def _set_default_params(ufo): """ Set Glyphs.app's default parameters when different from ufo2ft ones. """ for _, ufo_name, default_value in DEFAULT_PARAMETERS: if getattr(ufo.info, ufo_name) is None: if isinstance(default_value, list): # Prevent problem if the same defau...
python
def _set_default_params(ufo): """ Set Glyphs.app's default parameters when different from ufo2ft ones. """ for _, ufo_name, default_value in DEFAULT_PARAMETERS: if getattr(ufo.info, ufo_name) is None: if isinstance(default_value, list): # Prevent problem if the same defau...
[ "def", "_set_default_params", "(", "ufo", ")", ":", "for", "_", ",", "ufo_name", ",", "default_value", "in", "DEFAULT_PARAMETERS", ":", "if", "getattr", "(", "ufo", ".", "info", ",", "ufo_name", ")", "is", "None", ":", "if", "isinstance", "(", "default_val...
Set Glyphs.app's default parameters when different from ufo2ft ones.
[ "Set", "Glyphs", ".", "app", "s", "default", "parameters", "when", "different", "from", "ufo2ft", "ones", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L781-L790
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
_unset_default_params
def _unset_default_params(glyphs): """ Unset Glyphs.app's parameters that have default values. FIXME: (jany) maybe this should be taken care of in the writer? and/or classes should have better default values? """ for glyphs_name, _, default_value in DEFAULT_PARAMETERS: if ( g...
python
def _unset_default_params(glyphs): """ Unset Glyphs.app's parameters that have default values. FIXME: (jany) maybe this should be taken care of in the writer? and/or classes should have better default values? """ for glyphs_name, _, default_value in DEFAULT_PARAMETERS: if ( g...
[ "def", "_unset_default_params", "(", "glyphs", ")", ":", "for", "glyphs_name", ",", "_", ",", "default_value", "in", "DEFAULT_PARAMETERS", ":", "if", "(", "glyphs_name", "in", "glyphs", ".", "customParameters", "and", "glyphs", ".", "customParameters", "[", "gly...
Unset Glyphs.app's parameters that have default values. FIXME: (jany) maybe this should be taken care of in the writer? and/or classes should have better default values?
[ "Unset", "Glyphs", ".", "app", "s", "parameters", "that", "have", "default", "values", ".", "FIXME", ":", "(", "jany", ")", "maybe", "this", "should", "be", "taken", "care", "of", "in", "the", "writer?", "and", "/", "or", "classes", "should", "have", "...
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L793-L809
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
GlyphsObjectProxy.get_custom_value
def get_custom_value(self, key): """Return the first and only custom parameter matching the given name.""" self._handled.add(key) values = self._lookup[key] if len(values) > 1: raise RuntimeError( "More than one value for this customParameter: {}".format(key) ...
python
def get_custom_value(self, key): """Return the first and only custom parameter matching the given name.""" self._handled.add(key) values = self._lookup[key] if len(values) > 1: raise RuntimeError( "More than one value for this customParameter: {}".format(key) ...
[ "def", "get_custom_value", "(", "self", ",", "key", ")", ":", "self", ".", "_handled", ".", "add", "(", "key", ")", "values", "=", "self", ".", "_lookup", "[", "key", "]", "if", "len", "(", "values", ")", ">", "1", ":", "raise", "RuntimeError", "("...
Return the first and only custom parameter matching the given name.
[ "Return", "the", "first", "and", "only", "custom", "parameter", "matching", "the", "given", "name", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L101-L111
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
GlyphsObjectProxy.get_custom_values
def get_custom_values(self, key): """Return a set of values for the given customParameter name.""" self._handled.add(key) return self._lookup[key]
python
def get_custom_values(self, key): """Return a set of values for the given customParameter name.""" self._handled.add(key) return self._lookup[key]
[ "def", "get_custom_values", "(", "self", ",", "key", ")", ":", "self", ".", "_handled", ".", "add", "(", "key", ")", "return", "self", ".", "_lookup", "[", "key", "]" ]
Return a set of values for the given customParameter name.
[ "Return", "a", "set", "of", "values", "for", "the", "given", "customParameter", "name", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L113-L116
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
GlyphsObjectProxy.set_custom_value
def set_custom_value(self, key, value): """Set one custom parameter with the given value. We assume that the list of custom parameters does not already contain the given parameter so we only append. """ self._owner.customParameters.append( self._glyphs_module.GSCustom...
python
def set_custom_value(self, key, value): """Set one custom parameter with the given value. We assume that the list of custom parameters does not already contain the given parameter so we only append. """ self._owner.customParameters.append( self._glyphs_module.GSCustom...
[ "def", "set_custom_value", "(", "self", ",", "key", ",", "value", ")", ":", "self", ".", "_owner", ".", "customParameters", ".", "append", "(", "self", ".", "_glyphs_module", ".", "GSCustomParameter", "(", "name", "=", "key", ",", "value", "=", "value", ...
Set one custom parameter with the given value. We assume that the list of custom parameters does not already contain the given parameter so we only append.
[ "Set", "one", "custom", "parameter", "with", "the", "given", "value", ".", "We", "assume", "that", "the", "list", "of", "custom", "parameters", "does", "not", "already", "contain", "the", "given", "parameter", "so", "we", "only", "append", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L118-L125
googlefonts/glyphsLib
Lib/glyphsLib/builder/custom_params.py
GlyphsObjectProxy.set_custom_values
def set_custom_values(self, key, values): """Set several values for the customParameter with the given key. We append one GSCustomParameter per value. """ for value in values: self.set_custom_value(key, value)
python
def set_custom_values(self, key, values): """Set several values for the customParameter with the given key. We append one GSCustomParameter per value. """ for value in values: self.set_custom_value(key, value)
[ "def", "set_custom_values", "(", "self", ",", "key", ",", "values", ")", ":", "for", "value", "in", "values", ":", "self", ".", "set_custom_value", "(", "key", ",", "value", ")" ]
Set several values for the customParameter with the given key. We append one GSCustomParameter per value.
[ "Set", "several", "values", "for", "the", "customParameter", "with", "the", "given", "key", ".", "We", "append", "one", "GSCustomParameter", "per", "value", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/custom_params.py#L127-L132
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSCustomParameter.setValue
def setValue(self, value): """Cast some known data in custom parameters.""" if self.name in self._CUSTOM_INT_PARAMS: value = int(value) elif self.name in self._CUSTOM_FLOAT_PARAMS: value = float(value) elif self.name in self._CUSTOM_BOOL_PARAMS: value ...
python
def setValue(self, value): """Cast some known data in custom parameters.""" if self.name in self._CUSTOM_INT_PARAMS: value = int(value) elif self.name in self._CUSTOM_FLOAT_PARAMS: value = float(value) elif self.name in self._CUSTOM_BOOL_PARAMS: value ...
[ "def", "setValue", "(", "self", ",", "value", ")", ":", "if", "self", ".", "name", "in", "self", ".", "_CUSTOM_INT_PARAMS", ":", "value", "=", "int", "(", "value", ")", "elif", "self", ".", "name", "in", "self", ".", "_CUSTOM_FLOAT_PARAMS", ":", "value...
Cast some known data in custom parameters.
[ "Cast", "some", "known", "data", "in", "custom", "parameters", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1254-L1269
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSFontMaster.name
def name(self, name): """This function will take the given name and split it into components weight, width, customName, and possibly the full name. This is what Glyphs 1113 seems to be doing, approximately. """ weight, width, custom_name = self._splitName(name) self.set_a...
python
def name(self, name): """This function will take the given name and split it into components weight, width, customName, and possibly the full name. This is what Glyphs 1113 seems to be doing, approximately. """ weight, width, custom_name = self._splitName(name) self.set_a...
[ "def", "name", "(", "self", ",", "name", ")", ":", "weight", ",", "width", ",", "custom_name", "=", "self", ".", "_splitName", "(", "name", ")", "self", ".", "set_all_name_components", "(", "name", ",", "weight", ",", "width", ",", "custom_name", ")" ]
This function will take the given name and split it into components weight, width, customName, and possibly the full name. This is what Glyphs 1113 seems to be doing, approximately.
[ "This", "function", "will", "take", "the", "given", "name", "and", "split", "it", "into", "components", "weight", "width", "customName", "and", "possibly", "the", "full", "name", ".", "This", "is", "what", "Glyphs", "1113", "seems", "to", "be", "doing", "a...
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1446-L1452
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSFontMaster.set_all_name_components
def set_all_name_components(self, name, weight, width, custom_name): """This function ensures that after being called, the master.name, master.weight, master.width, and master.customName match the given values. """ self.weight = weight or "Regular" self.width = width or "...
python
def set_all_name_components(self, name, weight, width, custom_name): """This function ensures that after being called, the master.name, master.weight, master.width, and master.customName match the given values. """ self.weight = weight or "Regular" self.width = width or "...
[ "def", "set_all_name_components", "(", "self", ",", "name", ",", "weight", ",", "width", ",", "custom_name", ")", ":", "self", ".", "weight", "=", "weight", "or", "\"Regular\"", "self", ".", "width", "=", "width", "or", "\"Regular\"", "self", ".", "customN...
This function ensures that after being called, the master.name, master.weight, master.width, and master.customName match the given values.
[ "This", "function", "ensures", "that", "after", "being", "called", "the", "master", ".", "name", "master", ".", "weight", "master", ".", "width", "and", "master", ".", "customName", "match", "the", "given", "values", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1454-L1468
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSNode._encode_dict_as_string
def _encode_dict_as_string(value): """Takes the PLIST string of a dict, and returns the same string encoded such that it can be included in the string representation of a GSNode.""" # Strip the first and last newlines if value.startswith("{\n"): value = "{" + value[2:...
python
def _encode_dict_as_string(value): """Takes the PLIST string of a dict, and returns the same string encoded such that it can be included in the string representation of a GSNode.""" # Strip the first and last newlines if value.startswith("{\n"): value = "{" + value[2:...
[ "def", "_encode_dict_as_string", "(", "value", ")", ":", "# Strip the first and last newlines", "if", "value", ".", "startswith", "(", "\"{\\n\"", ")", ":", "value", "=", "\"{\"", "+", "value", "[", "2", ":", "]", "if", "value", ".", "endswith", "(", "\"\\n}...
Takes the PLIST string of a dict, and returns the same string encoded such that it can be included in the string representation of a GSNode.
[ "Takes", "the", "PLIST", "string", "of", "a", "dict", "and", "returns", "the", "same", "string", "encoded", "such", "that", "it", "can", "be", "included", "in", "the", "string", "representation", "of", "a", "GSNode", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1649-L1659
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSNode._indices
def _indices(self): """Find the path_index and node_index that identify the given node.""" path = self.parent layer = path.parent for path_index in range(len(layer.paths)): if path == layer.paths[path_index]: for node_index in range(len(path.nodes)): ...
python
def _indices(self): """Find the path_index and node_index that identify the given node.""" path = self.parent layer = path.parent for path_index in range(len(layer.paths)): if path == layer.paths[path_index]: for node_index in range(len(path.nodes)): ...
[ "def", "_indices", "(", "self", ")", ":", "path", "=", "self", ".", "parent", "layer", "=", "path", ".", "parent", "for", "path_index", "in", "range", "(", "len", "(", "layer", ".", "paths", ")", ")", ":", "if", "path", "==", "layer", ".", "paths",...
Find the path_index and node_index that identify the given node.
[ "Find", "the", "path_index", "and", "node_index", "that", "identify", "the", "given", "node", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L1677-L1686
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSLayer._find_node_by_indices
def _find_node_by_indices(self, point): """"Find the GSNode that is refered to by the given indices. See GSNode::_indices() """ path_index, node_index = point path = self.paths[int(path_index)] node = path.nodes[int(node_index)] return node
python
def _find_node_by_indices(self, point): """"Find the GSNode that is refered to by the given indices. See GSNode::_indices() """ path_index, node_index = point path = self.paths[int(path_index)] node = path.nodes[int(node_index)] return node
[ "def", "_find_node_by_indices", "(", "self", ",", "point", ")", ":", "path_index", ",", "node_index", "=", "point", "path", "=", "self", ".", "paths", "[", "int", "(", "path_index", ")", "]", "node", "=", "path", ".", "nodes", "[", "int", "(", "node_in...
Find the GSNode that is refered to by the given indices. See GSNode::_indices()
[ "Find", "the", "GSNode", "that", "is", "refered", "to", "by", "the", "given", "indices", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L2909-L2917
googlefonts/glyphsLib
Lib/glyphsLib/classes.py
GSLayer.background
def background(self): """Only a getter on purpose. See the tests.""" if self._background is None: self._background = GSBackgroundLayer() self._background._foreground = self return self._background
python
def background(self): """Only a getter on purpose. See the tests.""" if self._background is None: self._background = GSBackgroundLayer() self._background._foreground = self return self._background
[ "def", "background", "(", "self", ")", ":", "if", "self", ".", "_background", "is", "None", ":", "self", ".", "_background", "=", "GSBackgroundLayer", "(", ")", "self", ".", "_background", ".", "_foreground", "=", "self", "return", "self", ".", "_backgroun...
Only a getter on purpose. See the tests.
[ "Only", "a", "getter", "on", "purpose", ".", "See", "the", "tests", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/classes.py#L2920-L2925
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
to_ufo_propagate_font_anchors
def to_ufo_propagate_font_anchors(self, ufo): """Copy anchors from parent glyphs' components to the parent.""" processed = set() for glyph in ufo: _propagate_glyph_anchors(self, ufo, glyph, processed)
python
def to_ufo_propagate_font_anchors(self, ufo): """Copy anchors from parent glyphs' components to the parent.""" processed = set() for glyph in ufo: _propagate_glyph_anchors(self, ufo, glyph, processed)
[ "def", "to_ufo_propagate_font_anchors", "(", "self", ",", "ufo", ")", ":", "processed", "=", "set", "(", ")", "for", "glyph", "in", "ufo", ":", "_propagate_glyph_anchors", "(", "self", ",", "ufo", ",", "glyph", ",", "processed", ")" ]
Copy anchors from parent glyphs' components to the parent.
[ "Copy", "anchors", "from", "parent", "glyphs", "components", "to", "the", "parent", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L29-L34
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
_propagate_glyph_anchors
def _propagate_glyph_anchors(self, ufo, parent, processed): """Propagate anchors for a single parent glyph.""" if parent.name in processed: return processed.add(parent.name) base_components = [] mark_components = [] anchor_names = set() to_add = {} for component in parent.compo...
python
def _propagate_glyph_anchors(self, ufo, parent, processed): """Propagate anchors for a single parent glyph.""" if parent.name in processed: return processed.add(parent.name) base_components = [] mark_components = [] anchor_names = set() to_add = {} for component in parent.compo...
[ "def", "_propagate_glyph_anchors", "(", "self", ",", "ufo", ",", "parent", ",", "processed", ")", ":", "if", "parent", ".", "name", "in", "processed", ":", "return", "processed", ".", "add", "(", "parent", ".", "name", ")", "base_components", "=", "[", "...
Propagate anchors for a single parent glyph.
[ "Propagate", "anchors", "for", "a", "single", "parent", "glyph", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L37-L77
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
_adjust_anchors
def _adjust_anchors(anchor_data, ufo, component): """Adjust anchors to which a mark component may have been attached.""" glyph = ufo[component.baseGlyph] t = Transform(*component.transformation) for anchor in glyph.anchors: # only adjust if this anchor has data and the component also contains ...
python
def _adjust_anchors(anchor_data, ufo, component): """Adjust anchors to which a mark component may have been attached.""" glyph = ufo[component.baseGlyph] t = Transform(*component.transformation) for anchor in glyph.anchors: # only adjust if this anchor has data and the component also contains ...
[ "def", "_adjust_anchors", "(", "anchor_data", ",", "ufo", ",", "component", ")", ":", "glyph", "=", "ufo", "[", "component", ".", "baseGlyph", "]", "t", "=", "Transform", "(", "*", "component", ".", "transformation", ")", "for", "anchor", "in", "glyph", ...
Adjust anchors to which a mark component may have been attached.
[ "Adjust", "anchors", "to", "which", "a", "mark", "component", "may", "have", "been", "attached", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L100-L111
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
to_ufo_glyph_anchors
def to_ufo_glyph_anchors(self, glyph, anchors): """Add .glyphs anchors to a glyph.""" for anchor in anchors: x, y = anchor.position anchor_dict = {"name": anchor.name, "x": x, "y": y} glyph.appendAnchor(anchor_dict)
python
def to_ufo_glyph_anchors(self, glyph, anchors): """Add .glyphs anchors to a glyph.""" for anchor in anchors: x, y = anchor.position anchor_dict = {"name": anchor.name, "x": x, "y": y} glyph.appendAnchor(anchor_dict)
[ "def", "to_ufo_glyph_anchors", "(", "self", ",", "glyph", ",", "anchors", ")", ":", "for", "anchor", "in", "anchors", ":", "x", ",", "y", "=", "anchor", ".", "position", "anchor_dict", "=", "{", "\"name\"", ":", "anchor", ".", "name", ",", "\"x\"", ":"...
Add .glyphs anchors to a glyph.
[ "Add", ".", "glyphs", "anchors", "to", "a", "glyph", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L114-L120
googlefonts/glyphsLib
Lib/glyphsLib/builder/anchors.py
to_glyphs_glyph_anchors
def to_glyphs_glyph_anchors(self, ufo_glyph, layer): """Add UFO glif anchors to a GSLayer.""" for ufo_anchor in ufo_glyph.anchors: anchor = self.glyphs_module.GSAnchor() anchor.name = ufo_anchor.name anchor.position = Point(ufo_anchor.x, ufo_anchor.y) layer.anchors.append(anchor)
python
def to_glyphs_glyph_anchors(self, ufo_glyph, layer): """Add UFO glif anchors to a GSLayer.""" for ufo_anchor in ufo_glyph.anchors: anchor = self.glyphs_module.GSAnchor() anchor.name = ufo_anchor.name anchor.position = Point(ufo_anchor.x, ufo_anchor.y) layer.anchors.append(anchor)
[ "def", "to_glyphs_glyph_anchors", "(", "self", ",", "ufo_glyph", ",", "layer", ")", ":", "for", "ufo_anchor", "in", "ufo_glyph", ".", "anchors", ":", "anchor", "=", "self", ".", "glyphs_module", ".", "GSAnchor", "(", ")", "anchor", ".", "name", "=", "ufo_a...
Add UFO glif anchors to a GSLayer.
[ "Add", "UFO", "glif", "anchors", "to", "a", "GSLayer", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/anchors.py#L123-L129
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
cached_property
def cached_property(func): """Special property decorator that caches the computed property value in the object's instance dict the first time it is accessed. """ name = func.__name__ doc = func.__doc__ def getter(self, name=name): try: return self.__dict__[name] ...
python
def cached_property(func): """Special property decorator that caches the computed property value in the object's instance dict the first time it is accessed. """ name = func.__name__ doc = func.__doc__ def getter(self, name=name): try: return self.__dict__[name] ...
[ "def", "cached_property", "(", "func", ")", ":", "name", "=", "func", ".", "__name__", "doc", "=", "func", ".", "__doc__", "def", "getter", "(", "self", ",", "name", "=", "name", ")", ":", "try", ":", "return", "self", ".", "__dict__", "[", "name", ...
Special property decorator that caches the computed property value in the object's instance dict the first time it is accessed.
[ "Special", "property", "decorator", "that", "caches", "the", "computed", "property", "value", "in", "the", "object", "s", "instance", "dict", "the", "first", "time", "it", "is", "accessed", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L99-L115
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
cos_sin_deg
def cos_sin_deg(deg): """Return the cosine and sin for the given angle in degrees, with special-case handling of multiples of 90 for perfect right angles """ deg = deg % 360.0 if deg == 90.0: return 0.0, 1.0 elif deg == 180.0: return -1.0, 0 elif deg == 270.0: ret...
python
def cos_sin_deg(deg): """Return the cosine and sin for the given angle in degrees, with special-case handling of multiples of 90 for perfect right angles """ deg = deg % 360.0 if deg == 90.0: return 0.0, 1.0 elif deg == 180.0: return -1.0, 0 elif deg == 270.0: ret...
[ "def", "cos_sin_deg", "(", "deg", ")", ":", "deg", "=", "deg", "%", "360.0", "if", "deg", "==", "90.0", ":", "return", "0.0", ",", "1.0", "elif", "deg", "==", "180.0", ":", "return", "-", "1.0", ",", "0", "elif", "deg", "==", "270.0", ":", "retur...
Return the cosine and sin for the given angle in degrees, with special-case handling of multiples of 90 for perfect right angles
[ "Return", "the", "cosine", "and", "sin", "for", "the", "given", "angle", "in", "degrees", "with", "special", "-", "case", "handling", "of", "multiples", "of", "90", "for", "perfect", "right", "angles" ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L118-L131
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.scale
def scale(cls, *scaling): """Create a scaling transform from a scalar or vector. :param scaling: The scaling factor. A scalar value will scale in both dimensions equally. A vector scaling value scales the dimensions independently. :type scaling: float or sequence ...
python
def scale(cls, *scaling): """Create a scaling transform from a scalar or vector. :param scaling: The scaling factor. A scalar value will scale in both dimensions equally. A vector scaling value scales the dimensions independently. :type scaling: float or sequence ...
[ "def", "scale", "(", "cls", ",", "*", "scaling", ")", ":", "if", "len", "(", "scaling", ")", "==", "1", ":", "sx", "=", "sy", "=", "float", "(", "scaling", "[", "0", "]", ")", "else", ":", "sx", ",", "sy", "=", "scaling", "return", "tuple", "...
Create a scaling transform from a scalar or vector. :param scaling: The scaling factor. A scalar value will scale in both dimensions equally. A vector scaling value scales the dimensions independently. :type scaling: float or sequence :rtype: Affine
[ "Create", "a", "scaling", "transform", "from", "a", "scalar", "or", "vector", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L184-L197
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.shear
def shear(cls, x_angle=0, y_angle=0): """Create a shear transform along one or both axes. :param x_angle: Angle in degrees to shear along the x-axis. :type x_angle: float :param y_angle: Angle in degrees to shear along the y-axis. :type y_angle: float :rtype: Affine ...
python
def shear(cls, x_angle=0, y_angle=0): """Create a shear transform along one or both axes. :param x_angle: Angle in degrees to shear along the x-axis. :type x_angle: float :param y_angle: Angle in degrees to shear along the y-axis. :type y_angle: float :rtype: Affine ...
[ "def", "shear", "(", "cls", ",", "x_angle", "=", "0", ",", "y_angle", "=", "0", ")", ":", "sx", "=", "math", ".", "tan", "(", "math", ".", "radians", "(", "x_angle", ")", ")", "sy", "=", "math", ".", "tan", "(", "math", ".", "radians", "(", "...
Create a shear transform along one or both axes. :param x_angle: Angle in degrees to shear along the x-axis. :type x_angle: float :param y_angle: Angle in degrees to shear along the y-axis. :type y_angle: float :rtype: Affine
[ "Create", "a", "shear", "transform", "along", "one", "or", "both", "axes", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L200-L211
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.rotation
def rotation(cls, angle, pivot=None): """Create a rotation transform at the specified angle, optionally about the specified pivot point. :param angle: Rotation angle in degrees :type angle: float :param pivot: Point to rotate about, if omitted the rotation is about t...
python
def rotation(cls, angle, pivot=None): """Create a rotation transform at the specified angle, optionally about the specified pivot point. :param angle: Rotation angle in degrees :type angle: float :param pivot: Point to rotate about, if omitted the rotation is about t...
[ "def", "rotation", "(", "cls", ",", "angle", ",", "pivot", "=", "None", ")", ":", "ca", ",", "sa", "=", "cos_sin_deg", "(", "angle", ")", "if", "pivot", "is", "None", ":", "return", "tuple", ".", "__new__", "(", "cls", ",", "(", "ca", ",", "sa", ...
Create a rotation transform at the specified angle, optionally about the specified pivot point. :param angle: Rotation angle in degrees :type angle: float :param pivot: Point to rotate about, if omitted the rotation is about the origin. :type pivot: sequence ...
[ "Create", "a", "rotation", "transform", "at", "the", "specified", "angle", "optionally", "about", "the", "specified", "pivot", "point", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L214-L243
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.determinant
def determinant(self): """The determinant of the transform matrix. This value is equal to the area scaling factor when the transform is applied to a shape. """ a, b, c, d, e, f, g, h, i = self return a * e - b * d
python
def determinant(self): """The determinant of the transform matrix. This value is equal to the area scaling factor when the transform is applied to a shape. """ a, b, c, d, e, f, g, h, i = self return a * e - b * d
[ "def", "determinant", "(", "self", ")", ":", "a", ",", "b", ",", "c", ",", "d", ",", "e", ",", "f", ",", "g", ",", "h", ",", "i", "=", "self", "return", "a", "*", "e", "-", "b", "*", "d" ]
The determinant of the transform matrix. This value is equal to the area scaling factor when the transform is applied to a shape.
[ "The", "determinant", "of", "the", "transform", "matrix", ".", "This", "value", "is", "equal", "to", "the", "area", "scaling", "factor", "when", "the", "transform", "is", "applied", "to", "a", "shape", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L267-L273
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.is_rectilinear
def is_rectilinear(self): """True if the transform is rectilinear, i.e., whether a shape would remain axis-aligned, within rounding limits, after applying the transform. """ a, b, c, d, e, f, g, h, i = self return (abs(a) < EPSILON and abs(e) < EPSILON) or ( a...
python
def is_rectilinear(self): """True if the transform is rectilinear, i.e., whether a shape would remain axis-aligned, within rounding limits, after applying the transform. """ a, b, c, d, e, f, g, h, i = self return (abs(a) < EPSILON and abs(e) < EPSILON) or ( a...
[ "def", "is_rectilinear", "(", "self", ")", ":", "a", ",", "b", ",", "c", ",", "d", ",", "e", ",", "f", ",", "g", ",", "h", ",", "i", "=", "self", "return", "(", "abs", "(", "a", ")", "<", "EPSILON", "and", "abs", "(", "e", ")", "<", "EPSI...
True if the transform is rectilinear, i.e., whether a shape would remain axis-aligned, within rounding limits, after applying the transform.
[ "True", "if", "the", "transform", "is", "rectilinear", "i", ".", "e", ".", "whether", "a", "shape", "would", "remain", "axis", "-", "aligned", "within", "rounding", "limits", "after", "applying", "the", "transform", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L283-L291
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.is_conformal
def is_conformal(self): """True if the transform is conformal, i.e., if angles between points are preserved after applying the transform, within rounding limits. This implies that the transform has no effective shear. """ a, b, c, d, e, f, g, h, i = self return abs(a * b ...
python
def is_conformal(self): """True if the transform is conformal, i.e., if angles between points are preserved after applying the transform, within rounding limits. This implies that the transform has no effective shear. """ a, b, c, d, e, f, g, h, i = self return abs(a * b ...
[ "def", "is_conformal", "(", "self", ")", ":", "a", ",", "b", ",", "c", ",", "d", ",", "e", ",", "f", ",", "g", ",", "h", ",", "i", "=", "self", "return", "abs", "(", "a", "*", "b", "+", "d", "*", "e", ")", "<", "EPSILON" ]
True if the transform is conformal, i.e., if angles between points are preserved after applying the transform, within rounding limits. This implies that the transform has no effective shear.
[ "True", "if", "the", "transform", "is", "conformal", "i", ".", "e", ".", "if", "angles", "between", "points", "are", "preserved", "after", "applying", "the", "transform", "within", "rounding", "limits", ".", "This", "implies", "that", "the", "transform", "ha...
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L294-L300
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.is_orthonormal
def is_orthonormal(self): """True if the transform is orthonormal, which means that the transform represents a rigid motion, which has no effective scaling or shear. Mathematically, this means that the axis vectors of the transform matrix are perpendicular and unit-length. Applying an ...
python
def is_orthonormal(self): """True if the transform is orthonormal, which means that the transform represents a rigid motion, which has no effective scaling or shear. Mathematically, this means that the axis vectors of the transform matrix are perpendicular and unit-length. Applying an ...
[ "def", "is_orthonormal", "(", "self", ")", ":", "a", ",", "b", ",", "c", ",", "d", ",", "e", ",", "f", ",", "g", ",", "h", ",", "i", "=", "self", "return", "(", "self", ".", "is_conformal", "and", "abs", "(", "1.0", "-", "(", "a", "*", "a",...
True if the transform is orthonormal, which means that the transform represents a rigid motion, which has no effective scaling or shear. Mathematically, this means that the axis vectors of the transform matrix are perpendicular and unit-length. Applying an orthonormal transform to a sha...
[ "True", "if", "the", "transform", "is", "orthonormal", "which", "means", "that", "the", "transform", "represents", "a", "rigid", "motion", "which", "has", "no", "effective", "scaling", "or", "shear", ".", "Mathematically", "this", "means", "that", "the", "axis...
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L303-L315
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.column_vectors
def column_vectors(self): """The values of the transform as three 2D column vectors""" a, b, c, d, e, f, _, _, _ = self return (a, d), (b, e), (c, f)
python
def column_vectors(self): """The values of the transform as three 2D column vectors""" a, b, c, d, e, f, _, _, _ = self return (a, d), (b, e), (c, f)
[ "def", "column_vectors", "(", "self", ")", ":", "a", ",", "b", ",", "c", ",", "d", ",", "e", ",", "f", ",", "_", ",", "_", ",", "_", "=", "self", "return", "(", "a", ",", "d", ")", ",", "(", "b", ",", "e", ")", ",", "(", "c", ",", "f"...
The values of the transform as three 2D column vectors
[ "The", "values", "of", "the", "transform", "as", "three", "2D", "column", "vectors" ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L326-L329
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.almost_equals
def almost_equals(self, other): """Compare transforms for approximate equality. :param other: Transform being compared. :type other: Affine :return: True if absolute difference between each element of each respective tranform matrix < ``EPSILON``. """ for i i...
python
def almost_equals(self, other): """Compare transforms for approximate equality. :param other: Transform being compared. :type other: Affine :return: True if absolute difference between each element of each respective tranform matrix < ``EPSILON``. """ for i i...
[ "def", "almost_equals", "(", "self", ",", "other", ")", ":", "for", "i", "in", "(", "0", ",", "1", ",", "2", ",", "3", ",", "4", ",", "5", ")", ":", "if", "abs", "(", "self", "[", "i", "]", "-", "other", "[", "i", "]", ")", ">=", "EPSILON...
Compare transforms for approximate equality. :param other: Transform being compared. :type other: Affine :return: True if absolute difference between each element of each respective tranform matrix < ``EPSILON``.
[ "Compare", "transforms", "for", "approximate", "equality", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L331-L342
googlefonts/glyphsLib
Lib/glyphsLib/affine/__init__.py
Affine.itransform
def itransform(self, seq): """Transform a sequence of points or vectors in place. :param seq: Mutable sequence of :class:`~planar.Vec2` to be transformed. :returns: None, the input sequence is mutated in place. """ if self is not identity and self != identity: ...
python
def itransform(self, seq): """Transform a sequence of points or vectors in place. :param seq: Mutable sequence of :class:`~planar.Vec2` to be transformed. :returns: None, the input sequence is mutated in place. """ if self is not identity and self != identity: ...
[ "def", "itransform", "(", "self", ",", "seq", ")", ":", "if", "self", "is", "not", "identity", "and", "self", "!=", "identity", ":", "sa", ",", "sb", ",", "sc", ",", "sd", ",", "se", ",", "sf", ",", "_", ",", "_", ",", "_", "=", "self", "for"...
Transform a sequence of points or vectors in place. :param seq: Mutable sequence of :class:`~planar.Vec2` to be transformed. :returns: None, the input sequence is mutated in place.
[ "Transform", "a", "sequence", "of", "points", "or", "vectors", "in", "place", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/affine/__init__.py#L405-L415
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
get_glyph
def get_glyph(glyph_name, data=None): """Return a named tuple (Glyph) containing information derived from a glyph name akin to GSGlyphInfo. The information is derived from an included copy of GlyphData.xml and GlyphData_Ideographs.xml, going purely by the glyph name. """ # Read data on first u...
python
def get_glyph(glyph_name, data=None): """Return a named tuple (Glyph) containing information derived from a glyph name akin to GSGlyphInfo. The information is derived from an included copy of GlyphData.xml and GlyphData_Ideographs.xml, going purely by the glyph name. """ # Read data on first u...
[ "def", "get_glyph", "(", "glyph_name", ",", "data", "=", "None", ")", ":", "# Read data on first use.", "if", "data", "is", "None", ":", "global", "GLYPHDATA", "if", "GLYPHDATA", "is", "None", ":", "GLYPHDATA", "=", "GlyphData", ".", "from_files", "(", "os",...
Return a named tuple (Glyph) containing information derived from a glyph name akin to GSGlyphInfo. The information is derived from an included copy of GlyphData.xml and GlyphData_Ideographs.xml, going purely by the glyph name.
[ "Return", "a", "named", "tuple", "(", "Glyph", ")", "containing", "information", "derived", "from", "a", "glyph", "name", "akin", "to", "GSGlyphInfo", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L89-L139
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_lookup_attributes
def _lookup_attributes(glyph_name, data): """Look up glyph attributes in data by glyph name, alternative name or production name in order or return empty dictionary. Look up by alternative and production names for legacy projects and because of issue #232. """ attributes = ( data.names....
python
def _lookup_attributes(glyph_name, data): """Look up glyph attributes in data by glyph name, alternative name or production name in order or return empty dictionary. Look up by alternative and production names for legacy projects and because of issue #232. """ attributes = ( data.names....
[ "def", "_lookup_attributes", "(", "glyph_name", ",", "data", ")", ":", "attributes", "=", "(", "data", ".", "names", ".", "get", "(", "glyph_name", ")", "or", "data", ".", "alternative_names", ".", "get", "(", "glyph_name", ")", "or", "data", ".", "produ...
Look up glyph attributes in data by glyph name, alternative name or production name in order or return empty dictionary. Look up by alternative and production names for legacy projects and because of issue #232.
[ "Look", "up", "glyph", "attributes", "in", "data", "by", "glyph", "name", "alternative", "name", "or", "production", "name", "in", "order", "or", "return", "empty", "dictionary", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L142-L155
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_agl_compliant_name
def _agl_compliant_name(glyph_name): """Return an AGL-compliant name string or None if we can't make one.""" MAX_GLYPH_NAME_LENGTH = 63 clean_name = re.sub("[^0-9a-zA-Z_.]", "", glyph_name) if len(clean_name) > MAX_GLYPH_NAME_LENGTH: return None return clean_name
python
def _agl_compliant_name(glyph_name): """Return an AGL-compliant name string or None if we can't make one.""" MAX_GLYPH_NAME_LENGTH = 63 clean_name = re.sub("[^0-9a-zA-Z_.]", "", glyph_name) if len(clean_name) > MAX_GLYPH_NAME_LENGTH: return None return clean_name
[ "def", "_agl_compliant_name", "(", "glyph_name", ")", ":", "MAX_GLYPH_NAME_LENGTH", "=", "63", "clean_name", "=", "re", ".", "sub", "(", "\"[^0-9a-zA-Z_.]\"", ",", "\"\"", ",", "glyph_name", ")", "if", "len", "(", "clean_name", ")", ">", "MAX_GLYPH_NAME_LENGTH",...
Return an AGL-compliant name string or None if we can't make one.
[ "Return", "an", "AGL", "-", "compliant", "name", "string", "or", "None", "if", "we", "can", "t", "make", "one", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L158-L164
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_construct_category
def _construct_category(glyph_name, data): """Derive (sub)category of a glyph name.""" # Glyphs creates glyphs that start with an underscore as "non-exportable" glyphs or # construction helpers without a category. if glyph_name.startswith("_"): return None, None # Glyph variants (e.g. "fi.a...
python
def _construct_category(glyph_name, data): """Derive (sub)category of a glyph name.""" # Glyphs creates glyphs that start with an underscore as "non-exportable" glyphs or # construction helpers without a category. if glyph_name.startswith("_"): return None, None # Glyph variants (e.g. "fi.a...
[ "def", "_construct_category", "(", "glyph_name", ",", "data", ")", ":", "# Glyphs creates glyphs that start with an underscore as \"non-exportable\" glyphs or", "# construction helpers without a category.", "if", "glyph_name", ".", "startswith", "(", "\"_\"", ")", ":", "return", ...
Derive (sub)category of a glyph name.
[ "Derive", "(", "sub", ")", "category", "of", "a", "glyph", "name", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L174-L233
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_translate_category
def _translate_category(glyph_name, unicode_category): """Return a translation from Unicode category letters to Glyphs categories.""" DEFAULT_CATEGORIES = { None: ("Letter", None), "Cc": ("Separator", None), "Cf": ("Separator", "Format"), "Cn": ("Symbol", None), "Co":...
python
def _translate_category(glyph_name, unicode_category): """Return a translation from Unicode category letters to Glyphs categories.""" DEFAULT_CATEGORIES = { None: ("Letter", None), "Cc": ("Separator", None), "Cf": ("Separator", "Format"), "Cn": ("Symbol", None), "Co":...
[ "def", "_translate_category", "(", "glyph_name", ",", "unicode_category", ")", ":", "DEFAULT_CATEGORIES", "=", "{", "None", ":", "(", "\"Letter\"", ",", "None", ")", ",", "\"Cc\"", ":", "(", "\"Separator\"", ",", "None", ")", ",", "\"Cf\"", ":", "(", "\"Se...
Return a translation from Unicode category letters to Glyphs categories.
[ "Return", "a", "translation", "from", "Unicode", "category", "letters", "to", "Glyphs", "categories", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L236-L279
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
_construct_production_name
def _construct_production_name(glyph_name, data=None): """Return the production name for a glyph name from the GlyphData.xml database according to the AGL specification. This should be run only if there is no official entry with a production name in it. Handles single glyphs (e.g. "brevecomb") and...
python
def _construct_production_name(glyph_name, data=None): """Return the production name for a glyph name from the GlyphData.xml database according to the AGL specification. This should be run only if there is no official entry with a production name in it. Handles single glyphs (e.g. "brevecomb") and...
[ "def", "_construct_production_name", "(", "glyph_name", ",", "data", "=", "None", ")", ":", "# At this point, we have already checked the data for the full glyph name, so", "# directly go to the base name here (e.g. when looking at \"fi.alt\").", "base_name", ",", "dot", ",", "suffix...
Return the production name for a glyph name from the GlyphData.xml database according to the AGL specification. This should be run only if there is no official entry with a production name in it. Handles single glyphs (e.g. "brevecomb") and ligatures (e.g. "brevecomb_acutecomb"). Returns None when...
[ "Return", "the", "production", "name", "for", "a", "glyph", "name", "from", "the", "GlyphData", ".", "xml", "database", "according", "to", "the", "AGL", "specification", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L282-L384
googlefonts/glyphsLib
Lib/glyphsLib/glyphdata.py
GlyphData.from_files
def from_files(cls, *glyphdata_files): """Return GlyphData holding data from a list of XML file paths.""" name_mapping = {} alt_name_mapping = {} production_name_mapping = {} for glyphdata_file in glyphdata_files: glyph_data = xml.etree.ElementTree.parse(glyphdata_fi...
python
def from_files(cls, *glyphdata_files): """Return GlyphData holding data from a list of XML file paths.""" name_mapping = {} alt_name_mapping = {} production_name_mapping = {} for glyphdata_file in glyphdata_files: glyph_data = xml.etree.ElementTree.parse(glyphdata_fi...
[ "def", "from_files", "(", "cls", ",", "*", "glyphdata_files", ")", ":", "name_mapping", "=", "{", "}", "alt_name_mapping", "=", "{", "}", "production_name_mapping", "=", "{", "}", "for", "glyphdata_file", "in", "glyphdata_files", ":", "glyph_data", "=", "xml",...
Return GlyphData holding data from a list of XML file paths.
[ "Return", "GlyphData", "holding", "data", "from", "a", "list", "of", "XML", "file", "paths", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/glyphdata.py#L65-L86
googlefonts/glyphsLib
Lib/glyphsLib/__init__.py
load_to_ufos
def load_to_ufos( file_or_path, include_instances=False, family_name=None, propagate_anchors=True ): """Load an unpacked .glyphs object to UFO objects.""" if hasattr(file_or_path, "read"): font = load(file_or_path) else: with open(file_or_path, "r", encoding="utf-8") as ifile: ...
python
def load_to_ufos( file_or_path, include_instances=False, family_name=None, propagate_anchors=True ): """Load an unpacked .glyphs object to UFO objects.""" if hasattr(file_or_path, "read"): font = load(file_or_path) else: with open(file_or_path, "r", encoding="utf-8") as ifile: ...
[ "def", "load_to_ufos", "(", "file_or_path", ",", "include_instances", "=", "False", ",", "family_name", "=", "None", ",", "propagate_anchors", "=", "True", ")", ":", "if", "hasattr", "(", "file_or_path", ",", "\"read\"", ")", ":", "font", "=", "load", "(", ...
Load an unpacked .glyphs object to UFO objects.
[ "Load", "an", "unpacked", ".", "glyphs", "object", "to", "UFO", "objects", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/__init__.py#L62-L78
googlefonts/glyphsLib
Lib/glyphsLib/__init__.py
build_masters
def build_masters( filename, master_dir, designspace_instance_dir=None, designspace_path=None, family_name=None, propagate_anchors=True, minimize_glyphs_diffs=False, normalize_ufos=False, create_background_layers=False, generate_GDEF=True, store_editor_state=True, ): """W...
python
def build_masters( filename, master_dir, designspace_instance_dir=None, designspace_path=None, family_name=None, propagate_anchors=True, minimize_glyphs_diffs=False, normalize_ufos=False, create_background_layers=False, generate_GDEF=True, store_editor_state=True, ): """W...
[ "def", "build_masters", "(", "filename", ",", "master_dir", ",", "designspace_instance_dir", "=", "None", ",", "designspace_path", "=", "None", ",", "family_name", "=", "None", ",", "propagate_anchors", "=", "True", ",", "minimize_glyphs_diffs", "=", "False", ",",...
Write and return UFOs from the masters and the designspace defined in a .glyphs file. Args: master_dir: Directory where masters are written. designspace_instance_dir: If provided, a designspace document will be written alongside the master UFOs though no instances will be built. ...
[ "Write", "and", "return", "UFOs", "from", "the", "masters", "and", "the", "designspace", "defined", "in", "a", ".", "glyphs", "file", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/__init__.py#L81-L155
googlefonts/glyphsLib
Lib/glyphsLib/cli.py
glyphs2ufo
def glyphs2ufo(options): """Converts a Glyphs.app source file into UFO masters and a designspace file.""" if options.output_dir is None: options.output_dir = os.path.dirname(options.glyphs_file) or "." if options.designspace_path is None: options.designspace_path = os.path.join( ...
python
def glyphs2ufo(options): """Converts a Glyphs.app source file into UFO masters and a designspace file.""" if options.output_dir is None: options.output_dir = os.path.dirname(options.glyphs_file) or "." if options.designspace_path is None: options.designspace_path = os.path.join( ...
[ "def", "glyphs2ufo", "(", "options", ")", ":", "if", "options", ".", "output_dir", "is", "None", ":", "options", ".", "output_dir", "=", "os", ".", "path", ".", "dirname", "(", "options", ".", "glyphs_file", ")", "or", "\".\"", "if", "options", ".", "d...
Converts a Glyphs.app source file into UFO masters and a designspace file.
[ "Converts", "a", "Glyphs", ".", "app", "source", "file", "into", "UFO", "masters", "and", "a", "designspace", "file", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/cli.py#L166-L191
googlefonts/glyphsLib
Lib/glyphsLib/cli.py
ufo2glyphs
def ufo2glyphs(options): """Convert one designspace file or one or more UFOs to a Glyphs.app source file.""" import fontTools.designspaceLib import defcon sources = options.designspace_file_or_UFOs designspace_file = None if ( len(sources) == 1 and sources[0].endswith(".designsp...
python
def ufo2glyphs(options): """Convert one designspace file or one or more UFOs to a Glyphs.app source file.""" import fontTools.designspaceLib import defcon sources = options.designspace_file_or_UFOs designspace_file = None if ( len(sources) == 1 and sources[0].endswith(".designsp...
[ "def", "ufo2glyphs", "(", "options", ")", ":", "import", "fontTools", ".", "designspaceLib", "import", "defcon", "sources", "=", "options", ".", "designspace_file_or_UFOs", "designspace_file", "=", "None", "if", "(", "len", "(", "sources", ")", "==", "1", "and...
Convert one designspace file or one or more UFOs to a Glyphs.app source file.
[ "Convert", "one", "designspace", "file", "or", "one", "or", "more", "UFOs", "to", "a", "Glyphs", ".", "app", "source", "file", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/cli.py#L201-L252
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
_has_manual_kern_feature
def _has_manual_kern_feature(font): """Return true if the GSFont contains a manually written 'kern' feature.""" return any(f for f in font.features if f.name == "kern" and not f.automatic)
python
def _has_manual_kern_feature(font): """Return true if the GSFont contains a manually written 'kern' feature.""" return any(f for f in font.features if f.name == "kern" and not f.automatic)
[ "def", "_has_manual_kern_feature", "(", "font", ")", ":", "return", "any", "(", "f", "for", "f", "in", "font", ".", "features", "if", "f", ".", "name", "==", "\"kern\"", "and", "not", "f", ".", "automatic", ")" ]
Return true if the GSFont contains a manually written 'kern' feature.
[ "Return", "true", "if", "the", "GSFont", "contains", "a", "manually", "written", "kern", "feature", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L36-L38
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_ufo_family_user_data
def to_ufo_family_user_data(self, ufo): """Set family-wide user data as Glyphs does.""" if not self.use_designspace: ufo.lib[FONT_USER_DATA_KEY] = dict(self.font.userData)
python
def to_ufo_family_user_data(self, ufo): """Set family-wide user data as Glyphs does.""" if not self.use_designspace: ufo.lib[FONT_USER_DATA_KEY] = dict(self.font.userData)
[ "def", "to_ufo_family_user_data", "(", "self", ",", "ufo", ")", ":", "if", "not", "self", ".", "use_designspace", ":", "ufo", ".", "lib", "[", "FONT_USER_DATA_KEY", "]", "=", "dict", "(", "self", ".", "font", ".", "userData", ")" ]
Set family-wide user data as Glyphs does.
[ "Set", "family", "-", "wide", "user", "data", "as", "Glyphs", "does", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L58-L61
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_ufo_master_user_data
def to_ufo_master_user_data(self, ufo, master): """Set master-specific user data as Glyphs does.""" for key in master.userData.keys(): if _user_data_has_no_special_meaning(key): ufo.lib[key] = master.userData[key] # Restore UFO data files. This code assumes that all paths are POSIX path...
python
def to_ufo_master_user_data(self, ufo, master): """Set master-specific user data as Glyphs does.""" for key in master.userData.keys(): if _user_data_has_no_special_meaning(key): ufo.lib[key] = master.userData[key] # Restore UFO data files. This code assumes that all paths are POSIX path...
[ "def", "to_ufo_master_user_data", "(", "self", ",", "ufo", ",", "master", ")", ":", "for", "key", "in", "master", ".", "userData", ".", "keys", "(", ")", ":", "if", "_user_data_has_no_special_meaning", "(", "key", ")", ":", "ufo", ".", "lib", "[", "key",...
Set master-specific user data as Glyphs does.
[ "Set", "master", "-", "specific", "user", "data", "as", "Glyphs", "does", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L64-L73
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_glyphs_family_user_data_from_designspace
def to_glyphs_family_user_data_from_designspace(self): """Set the GSFont userData from the designspace family-wide lib data.""" target_user_data = self.font.userData for key, value in self.designspace.lib.items(): if key == UFO2FT_FEATURE_WRITERS_KEY and value == DEFAULT_FEATURE_WRITERS: ...
python
def to_glyphs_family_user_data_from_designspace(self): """Set the GSFont userData from the designspace family-wide lib data.""" target_user_data = self.font.userData for key, value in self.designspace.lib.items(): if key == UFO2FT_FEATURE_WRITERS_KEY and value == DEFAULT_FEATURE_WRITERS: ...
[ "def", "to_glyphs_family_user_data_from_designspace", "(", "self", ")", ":", "target_user_data", "=", "self", ".", "font", ".", "userData", "for", "key", ",", "value", "in", "self", ".", "designspace", ".", "lib", ".", "items", "(", ")", ":", "if", "key", ...
Set the GSFont userData from the designspace family-wide lib data.
[ "Set", "the", "GSFont", "userData", "from", "the", "designspace", "family", "-", "wide", "lib", "data", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L103-L112
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_glyphs_family_user_data_from_ufo
def to_glyphs_family_user_data_from_ufo(self, ufo): """Set the GSFont userData from the UFO family-wide lib data.""" target_user_data = self.font.userData try: for key, value in ufo.lib[FONT_USER_DATA_KEY].items(): # Existing values taken from the designspace lib take precedence ...
python
def to_glyphs_family_user_data_from_ufo(self, ufo): """Set the GSFont userData from the UFO family-wide lib data.""" target_user_data = self.font.userData try: for key, value in ufo.lib[FONT_USER_DATA_KEY].items(): # Existing values taken from the designspace lib take precedence ...
[ "def", "to_glyphs_family_user_data_from_ufo", "(", "self", ",", "ufo", ")", ":", "target_user_data", "=", "self", ".", "font", ".", "userData", "try", ":", "for", "key", ",", "value", "in", "ufo", ".", "lib", "[", "FONT_USER_DATA_KEY", "]", ".", "items", "...
Set the GSFont userData from the UFO family-wide lib data.
[ "Set", "the", "GSFont", "userData", "from", "the", "UFO", "family", "-", "wide", "lib", "data", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L115-L125
googlefonts/glyphsLib
Lib/glyphsLib/builder/user_data.py
to_glyphs_master_user_data
def to_glyphs_master_user_data(self, ufo, master): """Set the GSFontMaster userData from the UFO master-specific lib data.""" target_user_data = master.userData for key, value in ufo.lib.items(): if _user_data_has_no_special_meaning(key): target_user_data[key] = value # Save UFO dat...
python
def to_glyphs_master_user_data(self, ufo, master): """Set the GSFontMaster userData from the UFO master-specific lib data.""" target_user_data = master.userData for key, value in ufo.lib.items(): if _user_data_has_no_special_meaning(key): target_user_data[key] = value # Save UFO dat...
[ "def", "to_glyphs_master_user_data", "(", "self", ",", "ufo", ",", "master", ")", ":", "target_user_data", "=", "master", ".", "userData", "for", "key", ",", "value", "in", "ufo", ".", "lib", ".", "items", "(", ")", ":", "if", "_user_data_has_no_special_mean...
Set the GSFontMaster userData from the UFO master-specific lib data.
[ "Set", "the", "GSFontMaster", "userData", "from", "the", "UFO", "master", "-", "specific", "lib", "data", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/user_data.py#L128-L143
googlefonts/glyphsLib
Lib/glyphsLib/builder/__init__.py
to_ufos
def to_ufos( font, include_instances=False, family_name=None, propagate_anchors=True, ufo_module=defcon, minimize_glyphs_diffs=False, generate_GDEF=True, store_editor_state=True, ): """Take a GSFont object and convert it into one UFO per master. Takes in data as Glyphs.app-compa...
python
def to_ufos( font, include_instances=False, family_name=None, propagate_anchors=True, ufo_module=defcon, minimize_glyphs_diffs=False, generate_GDEF=True, store_editor_state=True, ): """Take a GSFont object and convert it into one UFO per master. Takes in data as Glyphs.app-compa...
[ "def", "to_ufos", "(", "font", ",", "include_instances", "=", "False", ",", "family_name", "=", "None", ",", "propagate_anchors", "=", "True", ",", "ufo_module", "=", "defcon", ",", "minimize_glyphs_diffs", "=", "False", ",", "generate_GDEF", "=", "True", ",",...
Take a GSFont object and convert it into one UFO per master. Takes in data as Glyphs.app-compatible classes, as documented at https://docu.glyphsapp.com/ If include_instances is True, also returns the parsed instance data. If family_name is provided, the master UFOs will be given this name and on...
[ "Take", "a", "GSFont", "object", "and", "convert", "it", "into", "one", "UFO", "per", "master", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/__init__.py#L25-L62
googlefonts/glyphsLib
Lib/glyphsLib/builder/__init__.py
to_designspace
def to_designspace( font, family_name=None, instance_dir=None, propagate_anchors=True, ufo_module=defcon, minimize_glyphs_diffs=False, generate_GDEF=True, store_editor_state=True, ): """Take a GSFont object and convert it into a Designspace Document + UFOS. The UFOs are available...
python
def to_designspace( font, family_name=None, instance_dir=None, propagate_anchors=True, ufo_module=defcon, minimize_glyphs_diffs=False, generate_GDEF=True, store_editor_state=True, ): """Take a GSFont object and convert it into a Designspace Document + UFOS. The UFOs are available...
[ "def", "to_designspace", "(", "font", ",", "family_name", "=", "None", ",", "instance_dir", "=", "None", ",", "propagate_anchors", "=", "True", ",", "ufo_module", "=", "defcon", ",", "minimize_glyphs_diffs", "=", "False", ",", "generate_GDEF", "=", "True", ","...
Take a GSFont object and convert it into a Designspace Document + UFOS. The UFOs are available as the attribute `font` of each SourceDescriptor of the DesignspaceDocument: ufos = [source.font for source in designspace.sources] The designspace and the UFOs are not written anywhere by default, they ...
[ "Take", "a", "GSFont", "object", "and", "convert", "it", "into", "a", "Designspace", "Document", "+", "UFOS", ".", "The", "UFOs", "are", "available", "as", "the", "attribute", "font", "of", "each", "SourceDescriptor", "of", "the", "DesignspaceDocument", ":" ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/__init__.py#L65-L108
googlefonts/glyphsLib
Lib/glyphsLib/builder/__init__.py
to_glyphs
def to_glyphs(ufos_or_designspace, glyphs_module=classes, minimize_ufo_diffs=False): """ Take a list of UFOs or a single DesignspaceDocument with attached UFOs and converts it into a GSFont object. The GSFont object is in-memory, it's up to the user to write it to the disk if needed. This shou...
python
def to_glyphs(ufos_or_designspace, glyphs_module=classes, minimize_ufo_diffs=False): """ Take a list of UFOs or a single DesignspaceDocument with attached UFOs and converts it into a GSFont object. The GSFont object is in-memory, it's up to the user to write it to the disk if needed. This shou...
[ "def", "to_glyphs", "(", "ufos_or_designspace", ",", "glyphs_module", "=", "classes", ",", "minimize_ufo_diffs", "=", "False", ")", ":", "if", "hasattr", "(", "ufos_or_designspace", ",", "\"sources\"", ")", ":", "builder", "=", "GlyphsBuilder", "(", "designspace",...
Take a list of UFOs or a single DesignspaceDocument with attached UFOs and converts it into a GSFont object. The GSFont object is in-memory, it's up to the user to write it to the disk if needed. This should be the inverse function of `to_ufos` and `to_designspace`, so we should have to_glyphs(to_...
[ "Take", "a", "list", "of", "UFOs", "or", "a", "single", "DesignspaceDocument", "with", "attached", "UFOs", "and", "converts", "it", "into", "a", "GSFont", "object", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/__init__.py#L111-L135
4Catalyzer/flask-resty
flask_resty/spec/plugin.py
FlaskRestyPlugin.path_helper
def path_helper(self, path, view, **kwargs): """Path helper for Flask-RESTy views. :param view: An `ApiView` object. """ super(FlaskRestyPlugin, self).path_helper( path=path, view=view, **kwargs ) resource = self.get_state().views[vie...
python
def path_helper(self, path, view, **kwargs): """Path helper for Flask-RESTy views. :param view: An `ApiView` object. """ super(FlaskRestyPlugin, self).path_helper( path=path, view=view, **kwargs ) resource = self.get_state().views[vie...
[ "def", "path_helper", "(", "self", ",", "path", ",", "view", ",", "*", "*", "kwargs", ")", ":", "super", "(", "FlaskRestyPlugin", ",", "self", ")", ".", "path_helper", "(", "path", "=", "path", ",", "view", "=", "view", ",", "*", "*", "kwargs", ")"...
Path helper for Flask-RESTy views. :param view: An `ApiView` object.
[ "Path", "helper", "for", "Flask", "-", "RESTy", "views", "." ]
train
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/plugin.py#L24-L55
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
class_to_value
def class_to_value(axis, ufo_class): """ >>> class_to_value('wdth', 7) 125 """ if axis == "wght": # 600.0 => 600, 250 => 250 return int(ufo_class) elif axis == "wdth": return WIDTH_CLASS_TO_VALUE[int(ufo_class)] raise NotImplementedError
python
def class_to_value(axis, ufo_class): """ >>> class_to_value('wdth', 7) 125 """ if axis == "wght": # 600.0 => 600, 250 => 250 return int(ufo_class) elif axis == "wdth": return WIDTH_CLASS_TO_VALUE[int(ufo_class)] raise NotImplementedError
[ "def", "class_to_value", "(", "axis", ",", "ufo_class", ")", ":", "if", "axis", "==", "\"wght\"", ":", "# 600.0 => 600, 250 => 250", "return", "int", "(", "ufo_class", ")", "elif", "axis", "==", "\"wdth\"", ":", "return", "WIDTH_CLASS_TO_VALUE", "[", "int", "(...
>>> class_to_value('wdth', 7) 125
[ ">>>", "class_to_value", "(", "wdth", "7", ")", "125" ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L43-L54
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
user_loc_string_to_value
def user_loc_string_to_value(axis_tag, user_loc): """Go from Glyphs UI strings to user space location. Returns None if the string is invalid. >>> user_loc_string_to_value('wght', 'ExtraLight') 200 >>> user_loc_string_to_value('wdth', 'SemiCondensed') 87.5 >>> user_loc_string_to_value('wdth'...
python
def user_loc_string_to_value(axis_tag, user_loc): """Go from Glyphs UI strings to user space location. Returns None if the string is invalid. >>> user_loc_string_to_value('wght', 'ExtraLight') 200 >>> user_loc_string_to_value('wdth', 'SemiCondensed') 87.5 >>> user_loc_string_to_value('wdth'...
[ "def", "user_loc_string_to_value", "(", "axis_tag", ",", "user_loc", ")", ":", "if", "axis_tag", "==", "\"wght\"", ":", "try", ":", "value", "=", "_nospace_lookup", "(", "WEIGHT_CODES", ",", "user_loc", ")", "except", "KeyError", ":", "return", "None", "return...
Go from Glyphs UI strings to user space location. Returns None if the string is invalid. >>> user_loc_string_to_value('wght', 'ExtraLight') 200 >>> user_loc_string_to_value('wdth', 'SemiCondensed') 87.5 >>> user_loc_string_to_value('wdth', 'Clearly Not From Glyphs UI')
[ "Go", "from", "Glyphs", "UI", "strings", "to", "user", "space", "location", ".", "Returns", "None", "if", "the", "string", "is", "invalid", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L67-L91
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
user_loc_value_to_class
def user_loc_value_to_class(axis_tag, user_loc): """Return the OS/2 weight or width class that is closest to the provided user location. For weight the user location is between 0 and 1000 and for width it is a percentage. >>> user_loc_value_to_class('wght', 310) 310 >>> user_loc_value_to_class(...
python
def user_loc_value_to_class(axis_tag, user_loc): """Return the OS/2 weight or width class that is closest to the provided user location. For weight the user location is between 0 and 1000 and for width it is a percentage. >>> user_loc_value_to_class('wght', 310) 310 >>> user_loc_value_to_class(...
[ "def", "user_loc_value_to_class", "(", "axis_tag", ",", "user_loc", ")", ":", "if", "axis_tag", "==", "\"wght\"", ":", "return", "int", "(", "user_loc", ")", "elif", "axis_tag", "==", "\"wdth\"", ":", "return", "min", "(", "sorted", "(", "WIDTH_CLASS_TO_VALUE"...
Return the OS/2 weight or width class that is closest to the provided user location. For weight the user location is between 0 and 1000 and for width it is a percentage. >>> user_loc_value_to_class('wght', 310) 310 >>> user_loc_value_to_class('wdth', 62) 2
[ "Return", "the", "OS", "/", "2", "weight", "or", "width", "class", "that", "is", "closest", "to", "the", "provided", "user", "location", ".", "For", "weight", "the", "user", "location", "is", "between", "0", "and", "1000", "and", "for", "width", "it", ...
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L94-L112
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
user_loc_value_to_instance_string
def user_loc_value_to_instance_string(axis_tag, user_loc): """Return the Glyphs UI string (from the instance dropdown) that is closest to the provided user location. >>> user_loc_value_to_instance_string('wght', 430) 'Normal' >>> user_loc_value_to_instance_string('wdth', 150) 'Extra Expanded' ...
python
def user_loc_value_to_instance_string(axis_tag, user_loc): """Return the Glyphs UI string (from the instance dropdown) that is closest to the provided user location. >>> user_loc_value_to_instance_string('wght', 430) 'Normal' >>> user_loc_value_to_instance_string('wdth', 150) 'Extra Expanded' ...
[ "def", "user_loc_value_to_instance_string", "(", "axis_tag", ",", "user_loc", ")", ":", "codes", "=", "{", "}", "if", "axis_tag", "==", "\"wght\"", ":", "codes", "=", "WEIGHT_CODES", "elif", "axis_tag", "==", "\"wdth\"", ":", "codes", "=", "WIDTH_CODES", "else...
Return the Glyphs UI string (from the instance dropdown) that is closest to the provided user location. >>> user_loc_value_to_instance_string('wght', 430) 'Normal' >>> user_loc_value_to_instance_string('wdth', 150) 'Extra Expanded'
[ "Return", "the", "Glyphs", "UI", "string", "(", "from", "the", "instance", "dropdown", ")", "that", "is", "closest", "to", "the", "provided", "user", "location", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L115-L135
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
get_regular_master
def get_regular_master(font): """Find the "regular" master among the GSFontMasters. Tries to find the master with the passed 'regularName'. If there is no such master or if regularName is None, tries to find a base style shared between all masters (defaulting to "Regular"), and then tries to find a...
python
def get_regular_master(font): """Find the "regular" master among the GSFontMasters. Tries to find the master with the passed 'regularName'. If there is no such master or if regularName is None, tries to find a base style shared between all masters (defaulting to "Regular"), and then tries to find a...
[ "def", "get_regular_master", "(", "font", ")", ":", "if", "not", "font", ".", "masters", ":", "return", "None", "regular_name", "=", "font", ".", "customParameters", "[", "\"Variation Font Origin\"", "]", "if", "regular_name", "is", "not", "None", ":", "for", ...
Find the "regular" master among the GSFontMasters. Tries to find the master with the passed 'regularName'. If there is no such master or if regularName is None, tries to find a base style shared between all masters (defaulting to "Regular"), and then tries to find a master with that style name. If ...
[ "Find", "the", "regular", "master", "among", "the", "GSFontMasters", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L512-L542
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
find_base_style
def find_base_style(masters): """Find a base style shared between all masters. Return empty string if none is found. """ if not masters: return "" base_style = (masters[0].name or "").split() for master in masters: style = master.name.split() base_style = [s for s in styl...
python
def find_base_style(masters): """Find a base style shared between all masters. Return empty string if none is found. """ if not masters: return "" base_style = (masters[0].name or "").split() for master in masters: style = master.name.split() base_style = [s for s in styl...
[ "def", "find_base_style", "(", "masters", ")", ":", "if", "not", "masters", ":", "return", "\"\"", "base_style", "=", "(", "masters", "[", "0", "]", ".", "name", "or", "\"\"", ")", ".", "split", "(", ")", "for", "master", "in", "masters", ":", "style...
Find a base style shared between all masters. Return empty string if none is found.
[ "Find", "a", "base", "style", "shared", "between", "all", "masters", ".", "Return", "empty", "string", "if", "none", "is", "found", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L545-L556
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
interp
def interp(mapping, x): """Compute the piecewise linear interpolation given by mapping for input x. >>> interp(((1, 1), (2, 4)), 1.5) 2.5 """ mapping = sorted(mapping) if len(mapping) == 1: xa, ya = mapping[0] if xa == x: return ya return x for (xa, ya), ...
python
def interp(mapping, x): """Compute the piecewise linear interpolation given by mapping for input x. >>> interp(((1, 1), (2, 4)), 1.5) 2.5 """ mapping = sorted(mapping) if len(mapping) == 1: xa, ya = mapping[0] if xa == x: return ya return x for (xa, ya), ...
[ "def", "interp", "(", "mapping", ",", "x", ")", ":", "mapping", "=", "sorted", "(", "mapping", ")", "if", "len", "(", "mapping", ")", "==", "1", ":", "xa", ",", "ya", "=", "mapping", "[", "0", "]", "if", "xa", "==", "x", ":", "return", "ya", ...
Compute the piecewise linear interpolation given by mapping for input x. >>> interp(((1, 1), (2, 4)), 1.5) 2.5
[ "Compute", "the", "piecewise", "linear", "interpolation", "given", "by", "mapping", "for", "input", "x", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L566-L581
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
AxisDefinition.get_user_loc
def get_user_loc(self, master_or_instance): """Get the user location of a Glyphs master or instance. Masters in Glyphs can have a user location in the "Axis Location" custom parameter. The user location is what the user sees on the slider in his variable-font-enabled UI. For wei...
python
def get_user_loc(self, master_or_instance): """Get the user location of a Glyphs master or instance. Masters in Glyphs can have a user location in the "Axis Location" custom parameter. The user location is what the user sees on the slider in his variable-font-enabled UI. For wei...
[ "def", "get_user_loc", "(", "self", ",", "master_or_instance", ")", ":", "user_loc", "=", "self", ".", "default_user_loc", "if", "self", ".", "tag", "!=", "\"wght\"", ":", "# The user location is by default the same as the design location.", "user_loc", "=", "self", "...
Get the user location of a Glyphs master or instance. Masters in Glyphs can have a user location in the "Axis Location" custom parameter. The user location is what the user sees on the slider in his variable-font-enabled UI. For weight it is a value between 0 and 1000, 400 being...
[ "Get", "the", "user", "location", "of", "a", "Glyphs", "master", "or", "instance", ".", "Masters", "in", "Glyphs", "can", "have", "a", "user", "location", "in", "the", "Axis", "Location", "custom", "parameter", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L310-L365
googlefonts/glyphsLib
Lib/glyphsLib/builder/axes.py
AxisDefinition.set_user_loc
def set_user_loc(self, master_or_instance, value): """Set the user location of a Glyphs master or instance.""" if hasattr(master_or_instance, "instanceInterpolations"): # The following code is only valid for instances. # Masters also the keys `weight` and `width` but they should ...
python
def set_user_loc(self, master_or_instance, value): """Set the user location of a Glyphs master or instance.""" if hasattr(master_or_instance, "instanceInterpolations"): # The following code is only valid for instances. # Masters also the keys `weight` and `width` but they should ...
[ "def", "set_user_loc", "(", "self", ",", "master_or_instance", ",", "value", ")", ":", "if", "hasattr", "(", "master_or_instance", ",", "\"instanceInterpolations\"", ")", ":", "# The following code is only valid for instances.", "# Masters also the keys `weight` and `width` but...
Set the user location of a Glyphs master or instance.
[ "Set", "the", "user", "location", "of", "a", "Glyphs", "master", "or", "instance", "." ]
train
https://github.com/googlefonts/glyphsLib/blob/9c12dc70c8d13f08d92b824e6710f6e3bb5037bb/Lib/glyphsLib/builder/axes.py#L367-L418
4Catalyzer/flask-resty
flask_resty/spec/operation.py
Operation.add_parameter
def add_parameter(self, location='query', **kwargs): """Adds a new parameter to the request :param location: the 'in' field of the parameter (e.g: 'query', 'body', 'path') """ kwargs.setdefault('in', location) if kwargs['in'] != 'body': kwargs.setdefault('...
python
def add_parameter(self, location='query', **kwargs): """Adds a new parameter to the request :param location: the 'in' field of the parameter (e.g: 'query', 'body', 'path') """ kwargs.setdefault('in', location) if kwargs['in'] != 'body': kwargs.setdefault('...
[ "def", "add_parameter", "(", "self", ",", "location", "=", "'query'", ",", "*", "*", "kwargs", ")", ":", "kwargs", ".", "setdefault", "(", "'in'", ",", "location", ")", "if", "kwargs", "[", "'in'", "]", "!=", "'body'", ":", "kwargs", ".", "setdefault",...
Adds a new parameter to the request :param location: the 'in' field of the parameter (e.g: 'query', 'body', 'path')
[ "Adds", "a", "new", "parameter", "to", "the", "request", ":", "param", "location", ":", "the", "in", "field", "of", "the", "parameter", "(", "e", ".", "g", ":", "query", "body", "path", ")" ]
train
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/operation.py#L12-L20
4Catalyzer/flask-resty
flask_resty/spec/operation.py
Operation.add_property_to_response
def add_property_to_response(self, code='200', prop_name='data', **kwargs): """Add a property (http://json-schema.org/latest/json-schema-validation.html#anchor64) # noqa: E501 to the schema of the response identified by the code""" self['responses'] \ .setdefault(str(code), self._ne...
python
def add_property_to_response(self, code='200', prop_name='data', **kwargs): """Add a property (http://json-schema.org/latest/json-schema-validation.html#anchor64) # noqa: E501 to the schema of the response identified by the code""" self['responses'] \ .setdefault(str(code), self._ne...
[ "def", "add_property_to_response", "(", "self", ",", "code", "=", "'200'", ",", "prop_name", "=", "'data'", ",", "*", "*", "kwargs", ")", ":", "self", "[", "'responses'", "]", ".", "setdefault", "(", "str", "(", "code", ")", ",", "self", ".", "_new_ope...
Add a property (http://json-schema.org/latest/json-schema-validation.html#anchor64) # noqa: E501 to the schema of the response identified by the code
[ "Add", "a", "property", "(", "http", ":", "//", "json", "-", "schema", ".", "org", "/", "latest", "/", "json", "-", "schema", "-", "validation", ".", "html#anchor64", ")", "#", "noqa", ":", "E501", "to", "the", "schema", "of", "the", "response", "ide...
train
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/operation.py#L22-L30
4Catalyzer/flask-resty
flask_resty/spec/operation.py
Operation.declare_response
def declare_response(self, code='200', **kwargs): """Declare a response for the specified code https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#responseObject""" # noqa: E501 self['responses'][str(code)] = self._new_operation(**kwargs)
python
def declare_response(self, code='200', **kwargs): """Declare a response for the specified code https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#responseObject""" # noqa: E501 self['responses'][str(code)] = self._new_operation(**kwargs)
[ "def", "declare_response", "(", "self", ",", "code", "=", "'200'", ",", "*", "*", "kwargs", ")", ":", "# noqa: E501", "self", "[", "'responses'", "]", "[", "str", "(", "code", ")", "]", "=", "self", ".", "_new_operation", "(", "*", "*", "kwargs", ")"...
Declare a response for the specified code https://github.com/swagger-api/swagger-spec/blob/master/versions/2.0.md#responseObject
[ "Declare", "a", "response", "for", "the", "specified", "code", "https", ":", "//", "github", ".", "com", "/", "swagger", "-", "api", "/", "swagger", "-", "spec", "/", "blob", "/", "master", "/", "versions", "/", "2", ".", "0", ".", "md#responseObject" ...
train
https://github.com/4Catalyzer/flask-resty/blob/a8b6502a799c270ca9ce41c6d8b7297713942097/flask_resty/spec/operation.py#L32-L35
inveniosoftware/invenio-records-rest
invenio_records_rest/schemas/fields/sanitizedhtml.py
SanitizedHTML._deserialize
def _deserialize(self, value, attr, data): """Deserialize string by sanitizing HTML.""" value = super(SanitizedHTML, self)._deserialize(value, attr, data) return bleach.clean( value, tags=self.tags, attributes=self.attrs, strip=True, ).stri...
python
def _deserialize(self, value, attr, data): """Deserialize string by sanitizing HTML.""" value = super(SanitizedHTML, self)._deserialize(value, attr, data) return bleach.clean( value, tags=self.tags, attributes=self.attrs, strip=True, ).stri...
[ "def", "_deserialize", "(", "self", ",", "value", ",", "attr", ",", "data", ")", ":", "value", "=", "super", "(", "SanitizedHTML", ",", "self", ")", ".", "_deserialize", "(", "value", ",", "attr", ",", "data", ")", "return", "bleach", ".", "clean", "...
Deserialize string by sanitizing HTML.
[ "Deserialize", "string", "by", "sanitizing", "HTML", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/schemas/fields/sanitizedhtml.py#L55-L63
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
build_default_endpoint_prefixes
def build_default_endpoint_prefixes(records_rest_endpoints): """Build the default_endpoint_prefixes map.""" pid_types = set() guessed = set() endpoint_prefixes = {} for key, endpoint in records_rest_endpoints.items(): pid_type = endpoint['pid_type'] pid_types.add(pid_type) i...
python
def build_default_endpoint_prefixes(records_rest_endpoints): """Build the default_endpoint_prefixes map.""" pid_types = set() guessed = set() endpoint_prefixes = {} for key, endpoint in records_rest_endpoints.items(): pid_type = endpoint['pid_type'] pid_types.add(pid_type) i...
[ "def", "build_default_endpoint_prefixes", "(", "records_rest_endpoints", ")", ":", "pid_types", "=", "set", "(", ")", "guessed", "=", "set", "(", ")", "endpoint_prefixes", "=", "{", "}", "for", "key", ",", "endpoint", "in", "records_rest_endpoints", ".", "items"...
Build the default_endpoint_prefixes map.
[ "Build", "the", "default_endpoint_prefixes", "map", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L28-L57
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
obj_or_import_string
def obj_or_import_string(value, default=None): """Import string or return object. :params value: Import path or class object to instantiate. :params default: Default object to return if the import fails. :returns: The imported object. """ if isinstance(value, six.string_types): return i...
python
def obj_or_import_string(value, default=None): """Import string or return object. :params value: Import path or class object to instantiate. :params default: Default object to return if the import fails. :returns: The imported object. """ if isinstance(value, six.string_types): return i...
[ "def", "obj_or_import_string", "(", "value", ",", "default", "=", "None", ")", ":", "if", "isinstance", "(", "value", ",", "six", ".", "string_types", ")", ":", "return", "import_string", "(", "value", ")", "elif", "value", ":", "return", "value", "return"...
Import string or return object. :params value: Import path or class object to instantiate. :params default: Default object to return if the import fails. :returns: The imported object.
[ "Import", "string", "or", "return", "object", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L60-L71
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
load_or_import_from_config
def load_or_import_from_config(key, app=None, default=None): """Load or import value from config. :returns: The loaded value. """ app = app or current_app imp = app.config.get(key) return obj_or_import_string(imp, default=default)
python
def load_or_import_from_config(key, app=None, default=None): """Load or import value from config. :returns: The loaded value. """ app = app or current_app imp = app.config.get(key) return obj_or_import_string(imp, default=default)
[ "def", "load_or_import_from_config", "(", "key", ",", "app", "=", "None", ",", "default", "=", "None", ")", ":", "app", "=", "app", "or", "current_app", "imp", "=", "app", ".", "config", ".", "get", "(", "key", ")", "return", "obj_or_import_string", "(",...
Load or import value from config. :returns: The loaded value.
[ "Load", "or", "import", "value", "from", "config", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L74-L81
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
check_elasticsearch
def check_elasticsearch(record, *args, **kwargs): """Return permission that check if the record exists in ES index. :params record: A record object. :returns: A object instance with a ``can()`` method. """ def can(self): """Try to search for given record.""" search = request._method...
python
def check_elasticsearch(record, *args, **kwargs): """Return permission that check if the record exists in ES index. :params record: A record object. :returns: A object instance with a ``can()`` method. """ def can(self): """Try to search for given record.""" search = request._method...
[ "def", "check_elasticsearch", "(", "record", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "def", "can", "(", "self", ")", ":", "\"\"\"Try to search for given record.\"\"\"", "search", "=", "request", ".", "_methodview", ".", "search_class", "(", ")", ...
Return permission that check if the record exists in ES index. :params record: A record object. :returns: A object instance with a ``can()`` method.
[ "Return", "permission", "that", "check", "if", "the", "record", "exists", "in", "ES", "index", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L100-L112
inveniosoftware/invenio-records-rest
invenio_records_rest/utils.py
LazyPIDValue.data
def data(self): """Resolve PID from a value and return a tuple with PID and the record. :returns: A tuple with the PID and the record resolved. """ try: return self.resolver.resolve(self.value) except PIDDoesNotExistError as pid_error: raise PIDDoesNotExi...
python
def data(self): """Resolve PID from a value and return a tuple with PID and the record. :returns: A tuple with the PID and the record resolved. """ try: return self.resolver.resolve(self.value) except PIDDoesNotExistError as pid_error: raise PIDDoesNotExi...
[ "def", "data", "(", "self", ")", ":", "try", ":", "return", "self", ".", "resolver", ".", "resolve", "(", "self", ".", "value", ")", "except", "PIDDoesNotExistError", "as", "pid_error", ":", "raise", "PIDDoesNotExistRESTError", "(", "pid_error", "=", "pid_er...
Resolve PID from a value and return a tuple with PID and the record. :returns: A tuple with the PID and the record resolved.
[ "Resolve", "PID", "from", "a", "value", "and", "return", "a", "tuple", "with", "PID", "and", "the", "record", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/utils.py#L133-L176
inveniosoftware/invenio-records-rest
invenio_records_rest/serializers/json.py
JSONSerializerMixin._format_args
def _format_args(): """Get JSON dump indentation and separates.""" if request and request.args.get('prettyprint'): return dict( indent=2, separators=(', ', ': '), ) else: return dict( indent=None, ...
python
def _format_args(): """Get JSON dump indentation and separates.""" if request and request.args.get('prettyprint'): return dict( indent=2, separators=(', ', ': '), ) else: return dict( indent=None, ...
[ "def", "_format_args", "(", ")", ":", "if", "request", "and", "request", ".", "args", ".", "get", "(", "'prettyprint'", ")", ":", "return", "dict", "(", "indent", "=", "2", ",", "separators", "=", "(", "', '", ",", "': '", ")", ",", ")", "else", ":...
Get JSON dump indentation and separates.
[ "Get", "JSON", "dump", "indentation", "and", "separates", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/serializers/json.py#L23-L34
inveniosoftware/invenio-records-rest
invenio_records_rest/serializers/json.py
JSONSerializerMixin.serialize
def serialize(self, pid, record, links_factory=None, **kwargs): """Serialize a single record and persistent identifier. :param pid: Persistent identifier instance. :param record: Record instance. :param links_factory: Factory function for record links. """ return json.du...
python
def serialize(self, pid, record, links_factory=None, **kwargs): """Serialize a single record and persistent identifier. :param pid: Persistent identifier instance. :param record: Record instance. :param links_factory: Factory function for record links. """ return json.du...
[ "def", "serialize", "(", "self", ",", "pid", ",", "record", ",", "links_factory", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "json", ".", "dumps", "(", "self", ".", "transform_record", "(", "pid", ",", "record", ",", "links_factory", ","...
Serialize a single record and persistent identifier. :param pid: Persistent identifier instance. :param record: Record instance. :param links_factory: Factory function for record links.
[ "Serialize", "a", "single", "record", "and", "persistent", "identifier", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/serializers/json.py#L36-L45
inveniosoftware/invenio-records-rest
invenio_records_rest/serializers/json.py
JSONSerializerMixin.serialize_search
def serialize_search(self, pid_fetcher, search_result, links=None, item_links_factory=None, **kwargs): """Serialize a search result. :param pid_fetcher: Persistent identifier fetcher. :param search_result: Elasticsearch search result. :param links: Dictionary of...
python
def serialize_search(self, pid_fetcher, search_result, links=None, item_links_factory=None, **kwargs): """Serialize a search result. :param pid_fetcher: Persistent identifier fetcher. :param search_result: Elasticsearch search result. :param links: Dictionary of...
[ "def", "serialize_search", "(", "self", ",", "pid_fetcher", ",", "search_result", ",", "links", "=", "None", ",", "item_links_factory", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "json", ".", "dumps", "(", "dict", "(", "hits", "=", "dict",...
Serialize a search result. :param pid_fetcher: Persistent identifier fetcher. :param search_result: Elasticsearch search result. :param links: Dictionary of links to add to response.
[ "Serialize", "a", "search", "result", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/serializers/json.py#L47-L67
inveniosoftware/invenio-records-rest
invenio_records_rest/views.py
create_error_handlers
def create_error_handlers(blueprint, error_handlers_registry=None): """Create error handlers on blueprint. :params blueprint: Records API blueprint. :params error_handlers_registry: Configuration of error handlers per exception or HTTP status code and view name. The dictionary has the foll...
python
def create_error_handlers(blueprint, error_handlers_registry=None): """Create error handlers on blueprint. :params blueprint: Records API blueprint. :params error_handlers_registry: Configuration of error handlers per exception or HTTP status code and view name. The dictionary has the foll...
[ "def", "create_error_handlers", "(", "blueprint", ",", "error_handlers_registry", "=", "None", ")", ":", "error_handlers_registry", "=", "error_handlers_registry", "or", "{", "}", "# Catch record validation errors", "@", "blueprint", ".", "errorhandler", "(", "ValidationE...
Create error handlers on blueprint. :params blueprint: Records API blueprint. :params error_handlers_registry: Configuration of error handlers per exception or HTTP status code and view name. The dictionary has the following structure: .. code-block:: python { ...
[ "Create", "error", "handlers", "on", "blueprint", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/views.py#L54-L116
inveniosoftware/invenio-records-rest
invenio_records_rest/views.py
create_blueprint
def create_blueprint(endpoints): """Create Invenio-Records-REST blueprint. :params endpoints: Dictionary representing the endpoints configuration. :returns: Configured blueprint. """ endpoints = endpoints or {} blueprint = Blueprint( 'invenio_records_rest', __name__, ur...
python
def create_blueprint(endpoints): """Create Invenio-Records-REST blueprint. :params endpoints: Dictionary representing the endpoints configuration. :returns: Configured blueprint. """ endpoints = endpoints or {} blueprint = Blueprint( 'invenio_records_rest', __name__, ur...
[ "def", "create_blueprint", "(", "endpoints", ")", ":", "endpoints", "=", "endpoints", "or", "{", "}", "blueprint", "=", "Blueprint", "(", "'invenio_records_rest'", ",", "__name__", ",", "url_prefix", "=", "''", ",", ")", "error_handlers_registry", "=", "defaultd...
Create Invenio-Records-REST blueprint. :params endpoints: Dictionary representing the endpoints configuration. :returns: Configured blueprint.
[ "Create", "Invenio", "-", "Records", "-", "REST", "blueprint", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/views.py#L134-L157
inveniosoftware/invenio-records-rest
invenio_records_rest/views.py
create_url_rules
def create_url_rules(endpoint, list_route=None, item_route=None, pid_type=None, pid_minter=None, pid_fetcher=None, read_permission_factory_imp=None, create_permission_factory_imp=None, update_permission_factory_imp=None, ...
python
def create_url_rules(endpoint, list_route=None, item_route=None, pid_type=None, pid_minter=None, pid_fetcher=None, read_permission_factory_imp=None, create_permission_factory_imp=None, update_permission_factory_imp=None, ...
[ "def", "create_url_rules", "(", "endpoint", ",", "list_route", "=", "None", ",", "item_route", "=", "None", ",", "pid_type", "=", "None", ",", "pid_minter", "=", "None", ",", "pid_fetcher", "=", "None", ",", "read_permission_factory_imp", "=", "None", ",", "...
Create Werkzeug URL rules. :param endpoint: Name of endpoint. :param list_route: Record listing URL route. Required. :param item_route: Record URL route (must include ``<pid_value>`` pattern). Required. :param pid_type: Persistent identifier type for endpoint. Required. :param pid_minter: I...
[ "Create", "Werkzeug", "URL", "rules", "." ]
train
https://github.com/inveniosoftware/invenio-records-rest/blob/e7b63c5f72cef03d06d3f1b4c12c0d37e3a628b9/invenio_records_rest/views.py#L160-L358