repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
xflr6/concepts
concepts/__init__.py
load_csv
def load_csv(filename, dialect='excel', encoding='utf-8'): """Load and return formal context from CSV file. Args: filename: Path to the CSV file to load the context from. dialect: Syntax variant of the CSV file (``'excel'``, ``'excel-tab'``). encoding (str): Encoding of the file (``'utf...
python
def load_csv(filename, dialect='excel', encoding='utf-8'): """Load and return formal context from CSV file. Args: filename: Path to the CSV file to load the context from. dialect: Syntax variant of the CSV file (``'excel'``, ``'excel-tab'``). encoding (str): Encoding of the file (``'utf...
[ "def", "load_csv", "(", "filename", ",", "dialect", "=", "'excel'", ",", "encoding", "=", "'utf-8'", ")", ":", "return", "Context", ".", "fromfile", "(", "filename", ",", "'csv'", ",", "encoding", ",", "dialect", "=", "dialect", ")" ]
Load and return formal context from CSV file. Args: filename: Path to the CSV file to load the context from. dialect: Syntax variant of the CSV file (``'excel'``, ``'excel-tab'``). encoding (str): Encoding of the file (``'utf-8'``, ``'latin1'``, ``'ascii'``, ...). Example: >>> ...
[ "Load", "and", "return", "formal", "context", "from", "CSV", "file", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/__init__.py#L61-L73
train
xflr6/concepts
concepts/definitions.py
ensure_compatible
def ensure_compatible(left, right): """Raise an informative ``ValueError`` if the two definitions disagree.""" conflicts = list(conflicting_pairs(left, right)) if conflicts: raise ValueError('conflicting values for object/property pairs: %r' % conflicts)
python
def ensure_compatible(left, right): """Raise an informative ``ValueError`` if the two definitions disagree.""" conflicts = list(conflicting_pairs(left, right)) if conflicts: raise ValueError('conflicting values for object/property pairs: %r' % conflicts)
[ "def", "ensure_compatible", "(", "left", ",", "right", ")", ":", "conflicts", "=", "list", "(", "conflicting_pairs", "(", "left", ",", "right", ")", ")", "if", "conflicts", ":", "raise", "ValueError", "(", "'conflicting values for object/property pairs: %r'", "%",...
Raise an informative ``ValueError`` if the two definitions disagree.
[ "Raise", "an", "informative", "ValueError", "if", "the", "two", "definitions", "disagree", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L211-L215
train
xflr6/concepts
concepts/definitions.py
Definition.rename_object
def rename_object(self, old, new): """Replace the name of an object by a new one.""" self._objects.replace(old, new) pairs = self._pairs pairs |= {(new, p) for p in self._properties if (old, p) in pairs and not pairs.remove((old, p))}
python
def rename_object(self, old, new): """Replace the name of an object by a new one.""" self._objects.replace(old, new) pairs = self._pairs pairs |= {(new, p) for p in self._properties if (old, p) in pairs and not pairs.remove((old, p))}
[ "def", "rename_object", "(", "self", ",", "old", ",", "new", ")", ":", "self", ".", "_objects", ".", "replace", "(", "old", ",", "new", ")", "pairs", "=", "self", ".", "_pairs", "pairs", "|=", "{", "(", "new", ",", "p", ")", "for", "p", "in", "...
Replace the name of an object by a new one.
[ "Replace", "the", "name", "of", "an", "object", "by", "a", "new", "one", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L317-L322
train
xflr6/concepts
concepts/definitions.py
Definition.rename_property
def rename_property(self, old, new): """Replace the name of a property by a new one.""" self._properties.replace(old, new) pairs = self._pairs pairs |= {(o, new) for o in self._objects if (o, old) in pairs and not pairs.remove((o, old))}
python
def rename_property(self, old, new): """Replace the name of a property by a new one.""" self._properties.replace(old, new) pairs = self._pairs pairs |= {(o, new) for o in self._objects if (o, old) in pairs and not pairs.remove((o, old))}
[ "def", "rename_property", "(", "self", ",", "old", ",", "new", ")", ":", "self", ".", "_properties", ".", "replace", "(", "old", ",", "new", ")", "pairs", "=", "self", ".", "_pairs", "pairs", "|=", "{", "(", "o", ",", "new", ")", "for", "o", "in"...
Replace the name of a property by a new one.
[ "Replace", "the", "name", "of", "a", "property", "by", "a", "new", "one", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L324-L329
train
xflr6/concepts
concepts/definitions.py
Definition.add_object
def add_object(self, obj, properties=()): """Add an object to the definition and add ``properties`` as related.""" self._objects.add(obj) self._properties |= properties self._pairs.update((obj, p) for p in properties)
python
def add_object(self, obj, properties=()): """Add an object to the definition and add ``properties`` as related.""" self._objects.add(obj) self._properties |= properties self._pairs.update((obj, p) for p in properties)
[ "def", "add_object", "(", "self", ",", "obj", ",", "properties", "=", "(", ")", ")", ":", "self", ".", "_objects", ".", "add", "(", "obj", ")", "self", ".", "_properties", "|=", "properties", "self", ".", "_pairs", ".", "update", "(", "(", "obj", "...
Add an object to the definition and add ``properties`` as related.
[ "Add", "an", "object", "to", "the", "definition", "and", "add", "properties", "as", "related", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L350-L354
train
xflr6/concepts
concepts/definitions.py
Definition.add_property
def add_property(self, prop, objects=()): """Add a property to the definition and add ``objects`` as related.""" self._properties.add(prop) self._objects |= objects self._pairs.update((o, prop) for o in objects)
python
def add_property(self, prop, objects=()): """Add a property to the definition and add ``objects`` as related.""" self._properties.add(prop) self._objects |= objects self._pairs.update((o, prop) for o in objects)
[ "def", "add_property", "(", "self", ",", "prop", ",", "objects", "=", "(", ")", ")", ":", "self", ".", "_properties", ".", "add", "(", "prop", ")", "self", ".", "_objects", "|=", "objects", "self", ".", "_pairs", ".", "update", "(", "(", "o", ",", ...
Add a property to the definition and add ``objects`` as related.
[ "Add", "a", "property", "to", "the", "definition", "and", "add", "objects", "as", "related", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L356-L360
train
xflr6/concepts
concepts/definitions.py
Definition.remove_object
def remove_object(self, obj): """Remove an object from the definition.""" self._objects.remove(obj) self._pairs.difference_update((obj, p) for p in self._properties)
python
def remove_object(self, obj): """Remove an object from the definition.""" self._objects.remove(obj) self._pairs.difference_update((obj, p) for p in self._properties)
[ "def", "remove_object", "(", "self", ",", "obj", ")", ":", "self", ".", "_objects", ".", "remove", "(", "obj", ")", "self", ".", "_pairs", ".", "difference_update", "(", "(", "obj", ",", "p", ")", "for", "p", "in", "self", ".", "_properties", ")" ]
Remove an object from the definition.
[ "Remove", "an", "object", "from", "the", "definition", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L362-L365
train
xflr6/concepts
concepts/definitions.py
Definition.remove_property
def remove_property(self, prop): """Remove a property from the definition.""" self._properties.remove(prop) self._pairs.difference_update((o, prop) for o in self._objects)
python
def remove_property(self, prop): """Remove a property from the definition.""" self._properties.remove(prop) self._pairs.difference_update((o, prop) for o in self._objects)
[ "def", "remove_property", "(", "self", ",", "prop", ")", ":", "self", ".", "_properties", ".", "remove", "(", "prop", ")", "self", ".", "_pairs", ".", "difference_update", "(", "(", "o", ",", "prop", ")", "for", "o", "in", "self", ".", "_objects", ")...
Remove a property from the definition.
[ "Remove", "a", "property", "from", "the", "definition", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L367-L370
train
xflr6/concepts
concepts/definitions.py
Definition.set_object
def set_object(self, obj, properties): """Add an object to the definition and set its ``properties``.""" self._objects.add(obj) properties = set(properties) self._properties |= properties pairs = self._pairs for p in self._properties: if p in properties: ...
python
def set_object(self, obj, properties): """Add an object to the definition and set its ``properties``.""" self._objects.add(obj) properties = set(properties) self._properties |= properties pairs = self._pairs for p in self._properties: if p in properties: ...
[ "def", "set_object", "(", "self", ",", "obj", ",", "properties", ")", ":", "self", ".", "_objects", ".", "add", "(", "obj", ")", "properties", "=", "set", "(", "properties", ")", "self", ".", "_properties", "|=", "properties", "pairs", "=", "self", "."...
Add an object to the definition and set its ``properties``.
[ "Add", "an", "object", "to", "the", "definition", "and", "set", "its", "properties", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L372-L382
train
xflr6/concepts
concepts/definitions.py
Definition.set_property
def set_property(self, prop, objects): """Add a property to the definition and set its ``objects``.""" self._properties.add(prop) objects = set(objects) self._objects |= objects pairs = self._pairs for o in self._objects: if o in objects: pairs...
python
def set_property(self, prop, objects): """Add a property to the definition and set its ``objects``.""" self._properties.add(prop) objects = set(objects) self._objects |= objects pairs = self._pairs for o in self._objects: if o in objects: pairs...
[ "def", "set_property", "(", "self", ",", "prop", ",", "objects", ")", ":", "self", ".", "_properties", ".", "add", "(", "prop", ")", "objects", "=", "set", "(", "objects", ")", "self", ".", "_objects", "|=", "objects", "pairs", "=", "self", ".", "_pa...
Add a property to the definition and set its ``objects``.
[ "Add", "a", "property", "to", "the", "definition", "and", "set", "its", "objects", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L384-L394
train
xflr6/concepts
concepts/definitions.py
Definition.union_update
def union_update(self, other, ignore_conflicts=False): """Update the definition with the union of the ``other``.""" if not ignore_conflicts: ensure_compatible(self, other) self._objects |= other._objects self._properties |= other._properties self._pairs |= other._pair...
python
def union_update(self, other, ignore_conflicts=False): """Update the definition with the union of the ``other``.""" if not ignore_conflicts: ensure_compatible(self, other) self._objects |= other._objects self._properties |= other._properties self._pairs |= other._pair...
[ "def", "union_update", "(", "self", ",", "other", ",", "ignore_conflicts", "=", "False", ")", ":", "if", "not", "ignore_conflicts", ":", "ensure_compatible", "(", "self", ",", "other", ")", "self", ".", "_objects", "|=", "other", ".", "_objects", "self", "...
Update the definition with the union of the ``other``.
[ "Update", "the", "definition", "with", "the", "union", "of", "the", "other", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L396-L402
train
xflr6/concepts
concepts/definitions.py
Definition.union
def union(self, other, ignore_conflicts=False): """Return a new definition from the union of the definitions.""" result = self.copy() result.union_update(other, ignore_conflicts) return result
python
def union(self, other, ignore_conflicts=False): """Return a new definition from the union of the definitions.""" result = self.copy() result.union_update(other, ignore_conflicts) return result
[ "def", "union", "(", "self", ",", "other", ",", "ignore_conflicts", "=", "False", ")", ":", "result", "=", "self", ".", "copy", "(", ")", "result", ".", "union_update", "(", "other", ",", "ignore_conflicts", ")", "return", "result" ]
Return a new definition from the union of the definitions.
[ "Return", "a", "new", "definition", "from", "the", "union", "of", "the", "definitions", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L420-L424
train
xflr6/concepts
concepts/definitions.py
Definition.intersection
def intersection(self, other, ignore_conflicts=False): """Return a new definition from the intersection of the definitions.""" result = self.copy() result.intersection_update(other, ignore_conflicts) return result
python
def intersection(self, other, ignore_conflicts=False): """Return a new definition from the intersection of the definitions.""" result = self.copy() result.intersection_update(other, ignore_conflicts) return result
[ "def", "intersection", "(", "self", ",", "other", ",", "ignore_conflicts", "=", "False", ")", ":", "result", "=", "self", ".", "copy", "(", ")", "result", ".", "intersection_update", "(", "other", ",", "ignore_conflicts", ")", "return", "result" ]
Return a new definition from the intersection of the definitions.
[ "Return", "a", "new", "definition", "from", "the", "intersection", "of", "the", "definitions", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/definitions.py#L426-L430
train
xflr6/concepts
concepts/tools.py
maximal
def maximal(iterable, comparison=operator.lt, _groupkey=operator.itemgetter(0)): """Yield the unique maximal elements from ``iterable`` using ``comparison``. >>> list(maximal([1, 2, 3, 3])) [3] >>> list(maximal([1])) [1] """ iterable = set(iterable) if len(iterable) < 2: return...
python
def maximal(iterable, comparison=operator.lt, _groupkey=operator.itemgetter(0)): """Yield the unique maximal elements from ``iterable`` using ``comparison``. >>> list(maximal([1, 2, 3, 3])) [3] >>> list(maximal([1])) [1] """ iterable = set(iterable) if len(iterable) < 2: return...
[ "def", "maximal", "(", "iterable", ",", "comparison", "=", "operator", ".", "lt", ",", "_groupkey", "=", "operator", ".", "itemgetter", "(", "0", ")", ")", ":", "iterable", "=", "set", "(", "iterable", ")", "if", "len", "(", "iterable", ")", "<", "2"...
Yield the unique maximal elements from ``iterable`` using ``comparison``. >>> list(maximal([1, 2, 3, 3])) [3] >>> list(maximal([1])) [1]
[ "Yield", "the", "unique", "maximal", "elements", "from", "iterable", "using", "comparison", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/tools.py#L142-L156
train
xflr6/concepts
concepts/tools.py
Unique.replace
def replace(self, item, new_item): """Replace an item preserving order. >>> u = Unique([0, 1, 2]) >>> u.replace(1, 'spam') >>> u Unique([0, 'spam', 2]) >>> u.replace('eggs', 1) Traceback (most recent call last): ... ValueError: 'eggs' is not ...
python
def replace(self, item, new_item): """Replace an item preserving order. >>> u = Unique([0, 1, 2]) >>> u.replace(1, 'spam') >>> u Unique([0, 'spam', 2]) >>> u.replace('eggs', 1) Traceback (most recent call last): ... ValueError: 'eggs' is not ...
[ "def", "replace", "(", "self", ",", "item", ",", "new_item", ")", ":", "if", "new_item", "in", "self", ".", "_seen", ":", "raise", "ValueError", "(", "'%r already in list'", "%", "new_item", ")", "idx", "=", "self", ".", "_items", ".", "index", "(", "i...
Replace an item preserving order. >>> u = Unique([0, 1, 2]) >>> u.replace(1, 'spam') >>> u Unique([0, 'spam', 2]) >>> u.replace('eggs', 1) Traceback (most recent call last): ... ValueError: 'eggs' is not in list >>> u.replace('spam', 0) ...
[ "Replace", "an", "item", "preserving", "order", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/tools.py#L58-L81
train
xflr6/concepts
concepts/tools.py
Unique.move
def move(self, item, new_index): """Move an item to the given position. >>> u = Unique(['spam', 'eggs']) >>> u.move('spam', 1) >>> u Unique(['eggs', 'spam']) >>> u.move('ham', 0) Traceback (most recent call last): ... ValueError: 'ham' is not...
python
def move(self, item, new_index): """Move an item to the given position. >>> u = Unique(['spam', 'eggs']) >>> u.move('spam', 1) >>> u Unique(['eggs', 'spam']) >>> u.move('ham', 0) Traceback (most recent call last): ... ValueError: 'ham' is not...
[ "def", "move", "(", "self", ",", "item", ",", "new_index", ")", ":", "idx", "=", "self", ".", "_items", ".", "index", "(", "item", ")", "if", "idx", "!=", "new_index", ":", "item", "=", "self", ".", "_items", ".", "pop", "(", "idx", ")", "self", ...
Move an item to the given position. >>> u = Unique(['spam', 'eggs']) >>> u.move('spam', 1) >>> u Unique(['eggs', 'spam']) >>> u.move('ham', 0) Traceback (most recent call last): ... ValueError: 'ham' is not in list
[ "Move", "an", "item", "to", "the", "given", "position", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/tools.py#L83-L99
train
xflr6/concepts
concepts/tools.py
Unique.issuperset
def issuperset(self, items): """Return whether this collection contains all items. >>> Unique(['spam', 'eggs']).issuperset(['spam', 'spam', 'spam']) True """ return all(_compat.map(self._seen.__contains__, items))
python
def issuperset(self, items): """Return whether this collection contains all items. >>> Unique(['spam', 'eggs']).issuperset(['spam', 'spam', 'spam']) True """ return all(_compat.map(self._seen.__contains__, items))
[ "def", "issuperset", "(", "self", ",", "items", ")", ":", "return", "all", "(", "_compat", ".", "map", "(", "self", ".", "_seen", ".", "__contains__", ",", "items", ")", ")" ]
Return whether this collection contains all items. >>> Unique(['spam', 'eggs']).issuperset(['spam', 'spam', 'spam']) True
[ "Return", "whether", "this", "collection", "contains", "all", "items", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/tools.py#L101-L107
train
xflr6/concepts
concepts/tools.py
Unique.rsub
def rsub(self, items): """Return order preserving unique items not in this collection. >>> Unique(['spam']).rsub(['ham', 'spam', 'eggs']) Unique(['ham', 'eggs']) """ ignore = self._seen seen = set() add = seen.add items = [i for i in items ...
python
def rsub(self, items): """Return order preserving unique items not in this collection. >>> Unique(['spam']).rsub(['ham', 'spam', 'eggs']) Unique(['ham', 'eggs']) """ ignore = self._seen seen = set() add = seen.add items = [i for i in items ...
[ "def", "rsub", "(", "self", ",", "items", ")", ":", "ignore", "=", "self", ".", "_seen", "seen", "=", "set", "(", ")", "add", "=", "seen", ".", "add", "items", "=", "[", "i", "for", "i", "in", "items", "if", "i", "not", "in", "ignore", "and", ...
Return order preserving unique items not in this collection. >>> Unique(['spam']).rsub(['ham', 'spam', 'eggs']) Unique(['ham', 'eggs'])
[ "Return", "order", "preserving", "unique", "items", "not", "in", "this", "collection", "." ]
2801b27b05fa02cccee7d549451810ffcbf5c942
https://github.com/xflr6/concepts/blob/2801b27b05fa02cccee7d549451810ffcbf5c942/concepts/tools.py#L109-L120
train
scrapinghub/skinfer
skinfer/json_schema_merger.py
merge_schema
def merge_schema(first, second): """Returns the result of merging the two given schemas. """ if not (type(first) == type(second) == dict): raise ValueError("Argument is not a schema") if not (first.get('type') == second.get('type') == 'object'): raise NotImplementedError("Unsupported ro...
python
def merge_schema(first, second): """Returns the result of merging the two given schemas. """ if not (type(first) == type(second) == dict): raise ValueError("Argument is not a schema") if not (first.get('type') == second.get('type') == 'object'): raise NotImplementedError("Unsupported ro...
[ "def", "merge_schema", "(", "first", ",", "second", ")", ":", "if", "not", "(", "type", "(", "first", ")", "==", "type", "(", "second", ")", "==", "dict", ")", ":", "raise", "ValueError", "(", "\"Argument is not a schema\"", ")", "if", "not", "(", "fir...
Returns the result of merging the two given schemas.
[ "Returns", "the", "result", "of", "merging", "the", "two", "given", "schemas", "." ]
7db5bc8b27229f20b718a8f5a1d219b1b0396316
https://github.com/scrapinghub/skinfer/blob/7db5bc8b27229f20b718a8f5a1d219b1b0396316/skinfer/json_schema_merger.py#L176-L185
train
scrapinghub/skinfer
skinfer/schema_inferer.py
generate_and_merge_schemas
def generate_and_merge_schemas(samples): """Iterates through the given samples, generating schemas and merging them, returning the resulting merged schema. """ merged = generate_schema_for_sample(next(iter(samples))) for sample in samples: merged = merge_schema(merged, generate_schema_for_...
python
def generate_and_merge_schemas(samples): """Iterates through the given samples, generating schemas and merging them, returning the resulting merged schema. """ merged = generate_schema_for_sample(next(iter(samples))) for sample in samples: merged = merge_schema(merged, generate_schema_for_...
[ "def", "generate_and_merge_schemas", "(", "samples", ")", ":", "merged", "=", "generate_schema_for_sample", "(", "next", "(", "iter", "(", "samples", ")", ")", ")", "for", "sample", "in", "samples", ":", "merged", "=", "merge_schema", "(", "merged", ",", "ge...
Iterates through the given samples, generating schemas and merging them, returning the resulting merged schema.
[ "Iterates", "through", "the", "given", "samples", "generating", "schemas", "and", "merging", "them", "returning", "the", "resulting", "merged", "schema", "." ]
7db5bc8b27229f20b718a8f5a1d219b1b0396316
https://github.com/scrapinghub/skinfer/blob/7db5bc8b27229f20b718a8f5a1d219b1b0396316/skinfer/schema_inferer.py#L42-L52
train
krischer/mtspec
mtspec/multitaper.py
sine_psd
def sine_psd(data, delta, number_of_tapers=None, number_of_iterations=2, degree_of_smoothing=1.0, statistics=False, verbose=False): """ Wrapper method for the sine_psd subroutine in the library by German A. Prieto. The subroutine is in charge of estimating the adaptive sine multitaper as ...
python
def sine_psd(data, delta, number_of_tapers=None, number_of_iterations=2, degree_of_smoothing=1.0, statistics=False, verbose=False): """ Wrapper method for the sine_psd subroutine in the library by German A. Prieto. The subroutine is in charge of estimating the adaptive sine multitaper as ...
[ "def", "sine_psd", "(", "data", ",", "delta", ",", "number_of_tapers", "=", "None", ",", "number_of_iterations", "=", "2", ",", "degree_of_smoothing", "=", "1.0", ",", "statistics", "=", "False", ",", "verbose", "=", "False", ")", ":", "# Verbose mode on or of...
Wrapper method for the sine_psd subroutine in the library by German A. Prieto. The subroutine is in charge of estimating the adaptive sine multitaper as in Riedel and Sidorenko (1995). It outputs the power spectral density (PSD). This is done by performing a MSE adaptive estimation. First a pilot ...
[ "Wrapper", "method", "for", "the", "sine_psd", "subroutine", "in", "the", "library", "by", "German", "A", ".", "Prieto", "." ]
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/multitaper.py#L183-L298
train
krischer/mtspec
mtspec/multitaper.py
dpss
def dpss(npts, fw, number_of_tapers, auto_spline=True, npts_max=None): """ Calculates DPSS also known as Slepian sequences or Slepian tapers. Calculation of the DPSS (Discrete Prolate Spheroidal Sequences) and the correspondent eigenvalues. The (1 - eigenvalue) terms are also calculated. Wraps the...
python
def dpss(npts, fw, number_of_tapers, auto_spline=True, npts_max=None): """ Calculates DPSS also known as Slepian sequences or Slepian tapers. Calculation of the DPSS (Discrete Prolate Spheroidal Sequences) and the correspondent eigenvalues. The (1 - eigenvalue) terms are also calculated. Wraps the...
[ "def", "dpss", "(", "npts", ",", "fw", ",", "number_of_tapers", ",", "auto_spline", "=", "True", ",", "npts_max", "=", "None", ")", ":", "mt", "=", "_MtspecType", "(", "\"float64\"", ")", "v", "=", "mt", ".", "empty", "(", "(", "npts", ",", "number_o...
Calculates DPSS also known as Slepian sequences or Slepian tapers. Calculation of the DPSS (Discrete Prolate Spheroidal Sequences) and the correspondent eigenvalues. The (1 - eigenvalue) terms are also calculated. Wraps the ``dpss()`` subroutine from the Fortran library. By default this routine will ...
[ "Calculates", "DPSS", "also", "known", "as", "Slepian", "sequences", "or", "Slepian", "tapers", "." ]
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/multitaper.py#L301-L384
train
krischer/mtspec
mtspec/multitaper.py
wigner_ville_spectrum
def wigner_ville_spectrum(data, delta, time_bandwidth=3.5, number_of_tapers=None, smoothing_filter=None, filter_width=100, frequency_divider=1, verbose=False): """ Function to calculate the Wigner-Ville Distribution or Wigner-Ville ...
python
def wigner_ville_spectrum(data, delta, time_bandwidth=3.5, number_of_tapers=None, smoothing_filter=None, filter_width=100, frequency_divider=1, verbose=False): """ Function to calculate the Wigner-Ville Distribution or Wigner-Ville ...
[ "def", "wigner_ville_spectrum", "(", "data", ",", "delta", ",", "time_bandwidth", "=", "3.5", ",", "number_of_tapers", "=", "None", ",", "smoothing_filter", "=", "None", ",", "filter_width", "=", "100", ",", "frequency_divider", "=", "1", ",", "verbose", "=", ...
Function to calculate the Wigner-Ville Distribution or Wigner-Ville Spectrum of a signal using multitaper spectral estimates. In general it gives better temporal and frequency resolution than a spectrogram but introduces many artifacts and possibly negative values which are not physical. This can be al...
[ "Function", "to", "calculate", "the", "Wigner", "-", "Ville", "Distribution", "or", "Wigner", "-", "Ville", "Spectrum", "of", "a", "signal", "using", "multitaper", "spectral", "estimates", "." ]
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/multitaper.py#L387-L546
train
krischer/mtspec
mtspec/multitaper.py
mt_deconvolve
def mt_deconvolve(data_a, data_b, delta, nfft=None, time_bandwidth=None, number_of_tapers=None, weights="adaptive", demean=True, fmax=0.0): """ Deconvolve two time series using multitapers. This uses the eigencoefficients and the weights from the multitaper spectral ...
python
def mt_deconvolve(data_a, data_b, delta, nfft=None, time_bandwidth=None, number_of_tapers=None, weights="adaptive", demean=True, fmax=0.0): """ Deconvolve two time series using multitapers. This uses the eigencoefficients and the weights from the multitaper spectral ...
[ "def", "mt_deconvolve", "(", "data_a", ",", "data_b", ",", "delta", ",", "nfft", "=", "None", ",", "time_bandwidth", "=", "None", ",", "number_of_tapers", "=", "None", ",", "weights", "=", "\"adaptive\"", ",", "demean", "=", "True", ",", "fmax", "=", "0....
Deconvolve two time series using multitapers. This uses the eigencoefficients and the weights from the multitaper spectral estimations and more or less follows this paper: .. |br| raw:: html <br /> **Receiver Functions from Multiple-Taper Spectral Correlation Estimates** *Jeffrey Park, V...
[ "Deconvolve", "two", "time", "series", "using", "multitapers", "." ]
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/multitaper.py#L623-L749
train
krischer/mtspec
mtspec/multitaper.py
_MtspecType.empty
def empty(self, shape, complex=False): """ A wrapper around np.empty which automatically sets the correct type and returns an empty array. :param shape: The shape of the array in np.empty format """ if complex: return np.empty(shape, dtype=self.complex, order...
python
def empty(self, shape, complex=False): """ A wrapper around np.empty which automatically sets the correct type and returns an empty array. :param shape: The shape of the array in np.empty format """ if complex: return np.empty(shape, dtype=self.complex, order...
[ "def", "empty", "(", "self", ",", "shape", ",", "complex", "=", "False", ")", ":", "if", "complex", ":", "return", "np", ".", "empty", "(", "shape", ",", "dtype", "=", "self", ".", "complex", ",", "order", "=", "self", ".", "order", ")", "return", ...
A wrapper around np.empty which automatically sets the correct type and returns an empty array. :param shape: The shape of the array in np.empty format
[ "A", "wrapper", "around", "np", ".", "empty", "which", "automatically", "sets", "the", "correct", "type", "and", "returns", "an", "empty", "array", "." ]
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/multitaper.py#L775-L784
train
krischer/mtspec
mtspec/util.py
signal_bursts
def signal_bursts(): """ Generates a signal with two bursts inside. Useful for testing time frequency distributions. :returns: Generated signal :rtype: numpy.ndarray """ np.random.seed(815) length = 5 * 512 # Baseline low frequency plus noise. data = np.sin(np.linspace(0, 80 * ...
python
def signal_bursts(): """ Generates a signal with two bursts inside. Useful for testing time frequency distributions. :returns: Generated signal :rtype: numpy.ndarray """ np.random.seed(815) length = 5 * 512 # Baseline low frequency plus noise. data = np.sin(np.linspace(0, 80 * ...
[ "def", "signal_bursts", "(", ")", ":", "np", ".", "random", ".", "seed", "(", "815", ")", "length", "=", "5", "*", "512", "# Baseline low frequency plus noise.", "data", "=", "np", ".", "sin", "(", "np", ".", "linspace", "(", "0", ",", "80", "*", "np...
Generates a signal with two bursts inside. Useful for testing time frequency distributions. :returns: Generated signal :rtype: numpy.ndarray
[ "Generates", "a", "signal", "with", "two", "bursts", "inside", ".", "Useful", "for", "testing", "time", "frequency", "distributions", "." ]
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/util.py#L57-L86
train
krischer/mtspec
mtspec/util.py
linear_chirp
def linear_chirp(npts=2000): """ Generates a simple linear chirp. :param npts: Number of samples. :type npts: int :returns: Generated signal :rtype: numpy.ndarray """ time = np.linspace(0, 20, npts) chirp = np.sin(0.2 * np.pi * (0.1 + 24.0 / 2.0 * time) * time) return chirp
python
def linear_chirp(npts=2000): """ Generates a simple linear chirp. :param npts: Number of samples. :type npts: int :returns: Generated signal :rtype: numpy.ndarray """ time = np.linspace(0, 20, npts) chirp = np.sin(0.2 * np.pi * (0.1 + 24.0 / 2.0 * time) * time) return chirp
[ "def", "linear_chirp", "(", "npts", "=", "2000", ")", ":", "time", "=", "np", ".", "linspace", "(", "0", ",", "20", ",", "npts", ")", "chirp", "=", "np", ".", "sin", "(", "0.2", "*", "np", ".", "pi", "*", "(", "0.1", "+", "24.0", "/", "2.0", ...
Generates a simple linear chirp. :param npts: Number of samples. :type npts: int :returns: Generated signal :rtype: numpy.ndarray
[ "Generates", "a", "simple", "linear", "chirp", "." ]
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/util.py#L89-L100
train
krischer/mtspec
mtspec/util.py
exponential_chirp
def exponential_chirp(npts=2000): """ Generates an exponential chirp. :param npts: Number of samples. :type npts: int :returns: Generated signal :rtype: numpy.ndarray """ time = np.linspace(0, 20, npts) chirp = np.sin(2 * np.pi * 0.2 * (1.3 ** time - 1) / np.log(1.3)) return chi...
python
def exponential_chirp(npts=2000): """ Generates an exponential chirp. :param npts: Number of samples. :type npts: int :returns: Generated signal :rtype: numpy.ndarray """ time = np.linspace(0, 20, npts) chirp = np.sin(2 * np.pi * 0.2 * (1.3 ** time - 1) / np.log(1.3)) return chi...
[ "def", "exponential_chirp", "(", "npts", "=", "2000", ")", ":", "time", "=", "np", ".", "linspace", "(", "0", ",", "20", ",", "npts", ")", "chirp", "=", "np", ".", "sin", "(", "2", "*", "np", ".", "pi", "*", "0.2", "*", "(", "1.3", "**", "tim...
Generates an exponential chirp. :param npts: Number of samples. :type npts: int :returns: Generated signal :rtype: numpy.ndarray
[ "Generates", "an", "exponential", "chirp", "." ]
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/mtspec/util.py#L103-L114
train
krischer/mtspec
setup.py
get_libgfortran_dir
def get_libgfortran_dir(): """ Helper function returning the library directory of libgfortran. Useful on OSX where the C compiler oftentimes has no knowledge of the library directories of the Fortran compiler. I don't think it can do any harm on Linux. """ for ending in [".3.dylib", ".dylib"...
python
def get_libgfortran_dir(): """ Helper function returning the library directory of libgfortran. Useful on OSX where the C compiler oftentimes has no knowledge of the library directories of the Fortran compiler. I don't think it can do any harm on Linux. """ for ending in [".3.dylib", ".dylib"...
[ "def", "get_libgfortran_dir", "(", ")", ":", "for", "ending", "in", "[", "\".3.dylib\"", ",", "\".dylib\"", ",", "\".3.so\"", ",", "\".so\"", "]", ":", "try", ":", "p", "=", "Popen", "(", "[", "'gfortran'", ",", "\"-print-file-name=libgfortran\"", "+", "endi...
Helper function returning the library directory of libgfortran. Useful on OSX where the C compiler oftentimes has no knowledge of the library directories of the Fortran compiler. I don't think it can do any harm on Linux.
[ "Helper", "function", "returning", "the", "library", "directory", "of", "libgfortran", ".", "Useful", "on", "OSX", "where", "the", "C", "compiler", "oftentimes", "has", "no", "knowledge", "of", "the", "library", "directories", "of", "the", "Fortran", "compiler",...
06561b6370f13fcb2e731470ba0f7314f4b2362d
https://github.com/krischer/mtspec/blob/06561b6370f13fcb2e731470ba0f7314f4b2362d/setup.py#L116-L134
train
pyGrowler/Growler
growler/utils/proto.py
PrototypeObject.create
def create(cls, obj): """ Create a new prototype object with the argument as the source prototype. .. Note: This does not `initialize` the newly created object any more than setting its prototype. Calling the __init__ method is usually unnecessary as...
python
def create(cls, obj): """ Create a new prototype object with the argument as the source prototype. .. Note: This does not `initialize` the newly created object any more than setting its prototype. Calling the __init__ method is usually unnecessary as...
[ "def", "create", "(", "cls", ",", "obj", ")", ":", "self", "=", "cls", ".", "__new__", "(", "cls", ")", "self", ".", "__proto__", "=", "obj", "return", "self" ]
Create a new prototype object with the argument as the source prototype. .. Note: This does not `initialize` the newly created object any more than setting its prototype. Calling the __init__ method is usually unnecessary as all initialization data shoul...
[ "Create", "a", "new", "prototype", "object", "with", "the", "argument", "as", "the", "source", "prototype", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/utils/proto.py#L41-L63
train
pyGrowler/Growler
growler/utils/proto.py
PrototypeObject.bind
def bind(self, func): """ Take a function and create a bound method """ if self.__methods__ is None: self.__methods__ = {} self.__methods__[func.__name__] = BoundFunction(func)
python
def bind(self, func): """ Take a function and create a bound method """ if self.__methods__ is None: self.__methods__ = {} self.__methods__[func.__name__] = BoundFunction(func)
[ "def", "bind", "(", "self", ",", "func", ")", ":", "if", "self", ".", "__methods__", "is", "None", ":", "self", ".", "__methods__", "=", "{", "}", "self", ".", "__methods__", "[", "func", ".", "__name__", "]", "=", "BoundFunction", "(", "func", ")" ]
Take a function and create a bound method
[ "Take", "a", "function", "and", "create", "a", "bound", "method" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/utils/proto.py#L65-L71
train
pyGrowler/Growler
growler/utils/proto.py
PrototypeObject.has_own_property
def has_own_property(self, attr): """ Returns if the property """ try: object.__getattribute__(self, attr) except AttributeError: return False else: return True
python
def has_own_property(self, attr): """ Returns if the property """ try: object.__getattribute__(self, attr) except AttributeError: return False else: return True
[ "def", "has_own_property", "(", "self", ",", "attr", ")", ":", "try", ":", "object", ".", "__getattribute__", "(", "self", ",", "attr", ")", "except", "AttributeError", ":", "return", "False", "else", ":", "return", "True" ]
Returns if the property
[ "Returns", "if", "the", "property" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/utils/proto.py#L73-L82
train
pyGrowler/Growler
growler/core/application.py
Application.add_router
def add_router(self, path, router): """ Adds a router to the list of routers Args: path (str or regex): The path on which the router binds router (growler.Router): The router which will respond to requests Raises: TypeError: If `stric...
python
def add_router(self, path, router): """ Adds a router to the list of routers Args: path (str or regex): The path on which the router binds router (growler.Router): The router which will respond to requests Raises: TypeError: If `stric...
[ "def", "add_router", "(", "self", ",", "path", ",", "router", ")", ":", "if", "self", ".", "strict_router_check", "and", "not", "isinstance", "(", "router", ",", "Router", ")", ":", "raise", "TypeError", "(", "\"Expected object of type Router, found %r\"", "%", ...
Adds a router to the list of routers Args: path (str or regex): The path on which the router binds router (growler.Router): The router which will respond to requests Raises: TypeError: If `strict_router_check` attribute is True and th...
[ "Adds", "a", "router", "to", "the", "list", "of", "routers" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/application.py#L296-L315
train
pyGrowler/Growler
growler/core/application.py
Application.create_server
def create_server(self, loop=None, as_coroutine=False, protocol_factory=None, **server_config): """ Helper function which constructs a listening server, using the default growler.http.protocol.Protocol which ...
python
def create_server(self, loop=None, as_coroutine=False, protocol_factory=None, **server_config): """ Helper function which constructs a listening server, using the default growler.http.protocol.Protocol which ...
[ "def", "create_server", "(", "self", ",", "loop", "=", "None", ",", "as_coroutine", "=", "False", ",", "protocol_factory", "=", "None", ",", "*", "*", "server_config", ")", ":", "if", "loop", "is", "None", ":", "import", "asyncio", "loop", "=", "asyncio"...
Helper function which constructs a listening server, using the default growler.http.protocol.Protocol which responds to this app. This function exists only to remove boilerplate code for starting up a growler app when using asyncio. Args: as_coroutine (bool): If Tru...
[ "Helper", "function", "which", "constructs", "a", "listening", "server", "using", "the", "default", "growler", ".", "http", ".", "protocol", ".", "Protocol", "which", "responds", "to", "this", "app", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/application.py#L616-L683
train
pyGrowler/Growler
growler/core/application.py
Application.create_server_and_run_forever
def create_server_and_run_forever(self, loop=None, **server_config): """ Helper function which constructs an HTTP server and listens the loop forever. This function exists only to remove boilerplate code for starting up a growler app. Args: **server_config: ...
python
def create_server_and_run_forever(self, loop=None, **server_config): """ Helper function which constructs an HTTP server and listens the loop forever. This function exists only to remove boilerplate code for starting up a growler app. Args: **server_config: ...
[ "def", "create_server_and_run_forever", "(", "self", ",", "loop", "=", "None", ",", "*", "*", "server_config", ")", ":", "if", "loop", "is", "None", ":", "import", "asyncio", "loop", "=", "asyncio", ".", "get_event_loop", "(", ")", "self", ".", "create_ser...
Helper function which constructs an HTTP server and listens the loop forever. This function exists only to remove boilerplate code for starting up a growler app. Args: **server_config: These keyword arguments are forwarded directly to the BaseEventLoop.creat...
[ "Helper", "function", "which", "constructs", "an", "HTTP", "server", "and", "listens", "the", "loop", "forever", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/application.py#L685-L712
train
pyGrowler/Growler
growler/middleware/renderer.py
RenderEngine.find_template_filename
def find_template_filename(self, template_name): """ Searches for a file matching the given template name. If found, this method returns the pathlib.Path object of the found template file. Args: template_name (str): Name of the template, with or without a file ...
python
def find_template_filename(self, template_name): """ Searches for a file matching the given template name. If found, this method returns the pathlib.Path object of the found template file. Args: template_name (str): Name of the template, with or without a file ...
[ "def", "find_template_filename", "(", "self", ",", "template_name", ")", ":", "def", "next_file", "(", ")", ":", "filename", "=", "self", ".", "path", "/", "template_name", "yield", "filename", "try", ":", "exts", "=", "self", ".", "default_file_extensions", ...
Searches for a file matching the given template name. If found, this method returns the pathlib.Path object of the found template file. Args: template_name (str): Name of the template, with or without a file extension. Returns: pathlib.Path: Pat...
[ "Searches", "for", "a", "file", "matching", "the", "given", "template", "name", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/middleware/renderer.py#L141-L170
train
pyGrowler/Growler
growler/http/responder.py
GrowlerHTTPResponder.set_request_line
def set_request_line(self, method, url, version): """ Sets the request line on the responder. """ self.parsed_request = (method, url, version) self.request = { 'method': method, 'url': url, 'version': version }
python
def set_request_line(self, method, url, version): """ Sets the request line on the responder. """ self.parsed_request = (method, url, version) self.request = { 'method': method, 'url': url, 'version': version }
[ "def", "set_request_line", "(", "self", ",", "method", ",", "url", ",", "version", ")", ":", "self", ".", "parsed_request", "=", "(", "method", ",", "url", ",", "version", ")", "self", ".", "request", "=", "{", "'method'", ":", "method", ",", "'url'", ...
Sets the request line on the responder.
[ "Sets", "the", "request", "line", "on", "the", "responder", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/responder.py#L186-L195
train
pyGrowler/Growler
growler/http/responder.py
GrowlerHTTPResponder.init_body_buffer
def init_body_buffer(self, method, headers): """ Sets up the body_buffer and content_length attributes based on method and headers. """ content_length = headers.get("CONTENT-LENGTH", None) if method in (HTTPMethod.POST, HTTPMethod.PUT): if content_length is N...
python
def init_body_buffer(self, method, headers): """ Sets up the body_buffer and content_length attributes based on method and headers. """ content_length = headers.get("CONTENT-LENGTH", None) if method in (HTTPMethod.POST, HTTPMethod.PUT): if content_length is N...
[ "def", "init_body_buffer", "(", "self", ",", "method", ",", "headers", ")", ":", "content_length", "=", "headers", ".", "get", "(", "\"CONTENT-LENGTH\"", ",", "None", ")", "if", "method", "in", "(", "HTTPMethod", ".", "POST", ",", "HTTPMethod", ".", "PUT",...
Sets up the body_buffer and content_length attributes based on method and headers.
[ "Sets", "up", "the", "body_buffer", "and", "content_length", "attributes", "based", "on", "method", "and", "headers", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/responder.py#L197-L213
train
pyGrowler/Growler
growler/http/responder.py
GrowlerHTTPResponder.build_req_and_res
def build_req_and_res(self): """ Simple method which calls the request and response factories the responder was given, and returns the pair. """ req = self.build_req(self, self.headers) res = self.build_res(self._handler) return req, res
python
def build_req_and_res(self): """ Simple method which calls the request and response factories the responder was given, and returns the pair. """ req = self.build_req(self, self.headers) res = self.build_res(self._handler) return req, res
[ "def", "build_req_and_res", "(", "self", ")", ":", "req", "=", "self", ".", "build_req", "(", "self", ",", "self", ".", "headers", ")", "res", "=", "self", ".", "build_res", "(", "self", ".", "_handler", ")", "return", "req", ",", "res" ]
Simple method which calls the request and response factories the responder was given, and returns the pair.
[ "Simple", "method", "which", "calls", "the", "request", "and", "response", "factories", "the", "responder", "was", "given", "and", "returns", "the", "pair", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/responder.py#L215-L222
train
pyGrowler/Growler
growler/http/responder.py
GrowlerHTTPResponder.validate_and_store_body_data
def validate_and_store_body_data(self, data): """ Attempts simple body data validation by comparining incoming data to the content length header. If passes store the data into self._buffer. Parameters: data (bytes): Incoming client data to be added to the body ...
python
def validate_and_store_body_data(self, data): """ Attempts simple body data validation by comparining incoming data to the content length header. If passes store the data into self._buffer. Parameters: data (bytes): Incoming client data to be added to the body ...
[ "def", "validate_and_store_body_data", "(", "self", ",", "data", ")", ":", "# add data to end of buffer", "self", ".", "body_buffer", "[", "-", "1", ":", "]", "=", "data", "#", "if", "len", "(", "self", ".", "body_buffer", ")", ">", "self", ".", "content_l...
Attempts simple body data validation by comparining incoming data to the content length header. If passes store the data into self._buffer. Parameters: data (bytes): Incoming client data to be added to the body Raises: HTTPErrorBadRequest: Raised if data is sent...
[ "Attempts", "simple", "body", "data", "validation", "by", "comparining", "incoming", "data", "to", "the", "content", "length", "header", ".", "If", "passes", "store", "the", "data", "into", "self", ".", "_buffer", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/responder.py#L224-L246
train
pyGrowler/Growler
growler/aio/http_protocol.py
GrowlerHTTPProtocol.begin_application
def begin_application(self, req, res): """ Entry point for the application middleware chain for an asyncio event loop. """ # Add the middleware processing to the event loop - this *should* # change the call stack so any server errors do not link back to this # fun...
python
def begin_application(self, req, res): """ Entry point for the application middleware chain for an asyncio event loop. """ # Add the middleware processing to the event loop - this *should* # change the call stack so any server errors do not link back to this # fun...
[ "def", "begin_application", "(", "self", ",", "req", ",", "res", ")", ":", "# Add the middleware processing to the event loop - this *should*", "# change the call stack so any server errors do not link back to this", "# function", "self", ".", "loop", ".", "create_task", "(", "...
Entry point for the application middleware chain for an asyncio event loop.
[ "Entry", "point", "for", "the", "application", "middleware", "chain", "for", "an", "asyncio", "event", "loop", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/aio/http_protocol.py#L137-L145
train
pyGrowler/Growler
growler/middleware/static.py
Static.calculate_etag
def calculate_etag(file_path): """ Calculate an etag value Args: a_file (pathlib.Path): The filepath to the Returns: String of the etag value to be sent back in header """ stat = file_path.stat() etag = "%x-%x" % (stat.st_mtime_ns, stat.s...
python
def calculate_etag(file_path): """ Calculate an etag value Args: a_file (pathlib.Path): The filepath to the Returns: String of the etag value to be sent back in header """ stat = file_path.stat() etag = "%x-%x" % (stat.st_mtime_ns, stat.s...
[ "def", "calculate_etag", "(", "file_path", ")", ":", "stat", "=", "file_path", ".", "stat", "(", ")", "etag", "=", "\"%x-%x\"", "%", "(", "stat", ".", "st_mtime_ns", ",", "stat", ".", "st_size", ")", "return", "etag" ]
Calculate an etag value Args: a_file (pathlib.Path): The filepath to the Returns: String of the etag value to be sent back in header
[ "Calculate", "an", "etag", "value" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/middleware/static.py#L81-L93
train
pyGrowler/Growler
growler/http/response.py
HTTPResponse._set_default_headers
def _set_default_headers(self): """ Create some default headers that should be sent along with every HTTP response """ self.headers.setdefault('Date', self.get_current_time) self.headers.setdefault('Server', self.SERVER_INFO) self.headers.setdefault('Content-Lengt...
python
def _set_default_headers(self): """ Create some default headers that should be sent along with every HTTP response """ self.headers.setdefault('Date', self.get_current_time) self.headers.setdefault('Server', self.SERVER_INFO) self.headers.setdefault('Content-Lengt...
[ "def", "_set_default_headers", "(", "self", ")", ":", "self", ".", "headers", ".", "setdefault", "(", "'Date'", ",", "self", ".", "get_current_time", ")", "self", ".", "headers", ".", "setdefault", "(", "'Server'", ",", "self", ".", "SERVER_INFO", ")", "se...
Create some default headers that should be sent along with every HTTP response
[ "Create", "some", "default", "headers", "that", "should", "be", "sent", "along", "with", "every", "HTTP", "response" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L65-L74
train
pyGrowler/Growler
growler/http/response.py
HTTPResponse.send_headers
def send_headers(self): """ Sends the headers to the client """ self.events.sync_emit('headers') self._set_default_headers() header_str = self.status_line + self.EOL + str(self.headers) self.stream.write(header_str.encode()) self.events.sync_emit('after_he...
python
def send_headers(self): """ Sends the headers to the client """ self.events.sync_emit('headers') self._set_default_headers() header_str = self.status_line + self.EOL + str(self.headers) self.stream.write(header_str.encode()) self.events.sync_emit('after_he...
[ "def", "send_headers", "(", "self", ")", ":", "self", ".", "events", ".", "sync_emit", "(", "'headers'", ")", "self", ".", "_set_default_headers", "(", ")", "header_str", "=", "self", ".", "status_line", "+", "self", ".", "EOL", "+", "str", "(", "self", ...
Sends the headers to the client
[ "Sends", "the", "headers", "to", "the", "client" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L76-L84
train
pyGrowler/Growler
growler/http/response.py
HTTPResponse.end
def end(self): """ Ends the response. Useful for quickly ending connection with no data sent """ self.send_headers() self.write() self.write_eof() self.has_ended = True
python
def end(self): """ Ends the response. Useful for quickly ending connection with no data sent """ self.send_headers() self.write() self.write_eof() self.has_ended = True
[ "def", "end", "(", "self", ")", ":", "self", ".", "send_headers", "(", ")", "self", ".", "write", "(", ")", "self", ".", "write_eof", "(", ")", "self", ".", "has_ended", "=", "True" ]
Ends the response. Useful for quickly ending connection with no data sent
[ "Ends", "the", "response", ".", "Useful", "for", "quickly", "ending", "connection", "with", "no", "data", "sent" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L110-L118
train
pyGrowler/Growler
growler/http/response.py
HTTPResponse.redirect
def redirect(self, url, status=None): """ Redirect to the specified url, optional status code defaults to 302. """ self.status_code = 302 if status is None else status self.headers = Headers([('location', url)]) self.message = '' self.end()
python
def redirect(self, url, status=None): """ Redirect to the specified url, optional status code defaults to 302. """ self.status_code = 302 if status is None else status self.headers = Headers([('location', url)]) self.message = '' self.end()
[ "def", "redirect", "(", "self", ",", "url", ",", "status", "=", "None", ")", ":", "self", ".", "status_code", "=", "302", "if", "status", "is", "None", "else", "status", "self", ".", "headers", "=", "Headers", "(", "[", "(", "'location'", ",", "url",...
Redirect to the specified url, optional status code defaults to 302.
[ "Redirect", "to", "the", "specified", "url", "optional", "status", "code", "defaults", "to", "302", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L120-L127
train
pyGrowler/Growler
growler/http/response.py
HTTPResponse.set
def set(self, header, value=None): """Set header to the value""" if value is None: for k, v in header.items(): self.headers[k] = v else: self.headers[header] = value
python
def set(self, header, value=None): """Set header to the value""" if value is None: for k, v in header.items(): self.headers[k] = v else: self.headers[header] = value
[ "def", "set", "(", "self", ",", "header", ",", "value", "=", "None", ")", ":", "if", "value", "is", "None", ":", "for", "k", ",", "v", "in", "header", ".", "items", "(", ")", ":", "self", ".", "headers", "[", "k", "]", "=", "v", "else", ":", ...
Set header to the value
[ "Set", "header", "to", "the", "value" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L129-L135
train
pyGrowler/Growler
growler/http/response.py
HTTPResponse.links
def links(self, links): """Sets the Link """ s = ['<{}>; rel="{}"'.format(link, rel) for link, rel in links.items()] self.headers['Link'] = ','.join(s)
python
def links(self, links): """Sets the Link """ s = ['<{}>; rel="{}"'.format(link, rel) for link, rel in links.items()] self.headers['Link'] = ','.join(s)
[ "def", "links", "(", "self", ",", "links", ")", ":", "s", "=", "[", "'<{}>; rel=\"{}\"'", ".", "format", "(", "link", ",", "rel", ")", "for", "link", ",", "rel", "in", "links", ".", "items", "(", ")", "]", "self", ".", "headers", "[", "'Link'", "...
Sets the Link
[ "Sets", "the", "Link" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L161-L165
train
pyGrowler/Growler
growler/http/response.py
HTTPResponse.send_file
def send_file(self, filename, status=200): """ Reads in the file 'filename' and sends bytes to client Parameters ---------- filename : str Filename of the file to read status : int, optional The HTTP status code, defaults to 200 (OK) """ ...
python
def send_file(self, filename, status=200): """ Reads in the file 'filename' and sends bytes to client Parameters ---------- filename : str Filename of the file to read status : int, optional The HTTP status code, defaults to 200 (OK) """ ...
[ "def", "send_file", "(", "self", ",", "filename", ",", "status", "=", "200", ")", ":", "if", "isinstance", "(", "filename", ",", "Path", ")", "and", "sys", ".", "version_info", ">=", "(", "3", ",", "5", ")", ":", "self", ".", "message", "=", "filen...
Reads in the file 'filename' and sends bytes to client Parameters ---------- filename : str Filename of the file to read status : int, optional The HTTP status code, defaults to 200 (OK)
[ "Reads", "in", "the", "file", "filename", "and", "sends", "bytes", "to", "client" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L228-L247
train
pyGrowler/Growler
growler/http/response.py
Headers.update
def update(self, *args, **kwargs): """ Equivalent to the python dict update method. Update the dictionary with the key/value pairs from other, overwriting existing keys. Args: other (dict): The source of key value pairs to add to headers Keyword Args: ...
python
def update(self, *args, **kwargs): """ Equivalent to the python dict update method. Update the dictionary with the key/value pairs from other, overwriting existing keys. Args: other (dict): The source of key value pairs to add to headers Keyword Args: ...
[ "def", "update", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "next_dict", "in", "chain", "(", "args", ",", "(", "kwargs", ",", ")", ")", ":", "for", "k", ",", "v", "in", "next_dict", ".", "items", "(", ")", ":", "...
Equivalent to the python dict update method. Update the dictionary with the key/value pairs from other, overwriting existing keys. Args: other (dict): The source of key value pairs to add to headers Keyword Args: All keyword arguments are stored in header direct...
[ "Equivalent", "to", "the", "python", "dict", "update", "method", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L328-L345
train
pyGrowler/Growler
growler/http/response.py
Headers.add_header
def add_header(self, key, value, **params): """ Add a header to the collection, including potential parameters. Args: key (str): The name of the header value (str): The value to store under that key params: Option parameters to be appended to the value, ...
python
def add_header(self, key, value, **params): """ Add a header to the collection, including potential parameters. Args: key (str): The name of the header value (str): The value to store under that key params: Option parameters to be appended to the value, ...
[ "def", "add_header", "(", "self", ",", "key", ",", "value", ",", "*", "*", "params", ")", ":", "key", "=", "self", ".", "escape", "(", "key", ")", "ci_key", "=", "key", ".", "casefold", "(", ")", "def", "quoted_params", "(", "items", ")", ":", "f...
Add a header to the collection, including potential parameters. Args: key (str): The name of the header value (str): The value to store under that key params: Option parameters to be appended to the value, automatically formatting them in a standard way
[ "Add", "a", "header", "to", "the", "collection", "including", "potential", "parameters", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/response.py#L347-L375
train
pyGrowler/Growler
examples/sessions.py
index
def index(req, res): """ Return root page of website. """ number = req.session.get('counter', -1) req.session['counter'] = int(number) + 1 print(" -- Session '{id}' returned {counter} times".format(**req.session)) msg = "Hello!! You've been here [[%s]] times" % (req.session['counter']) r...
python
def index(req, res): """ Return root page of website. """ number = req.session.get('counter', -1) req.session['counter'] = int(number) + 1 print(" -- Session '{id}' returned {counter} times".format(**req.session)) msg = "Hello!! You've been here [[%s]] times" % (req.session['counter']) r...
[ "def", "index", "(", "req", ",", "res", ")", ":", "number", "=", "req", ".", "session", ".", "get", "(", "'counter'", ",", "-", "1", ")", "req", ".", "session", "[", "'counter'", "]", "=", "int", "(", "number", ")", "+", "1", "print", "(", "\" ...
Return root page of website.
[ "Return", "root", "page", "of", "website", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/examples/sessions.py#L21-L30
train
pyGrowler/Growler
growler/http/request.py
HTTPRequest.body
async def body(self): """ A helper function which blocks until the body has been read completely. Returns the bytes of the body which the user should decode. If the request does not have a body part (i.e. it is a GET request) this function returns None. """ ...
python
async def body(self): """ A helper function which blocks until the body has been read completely. Returns the bytes of the body which the user should decode. If the request does not have a body part (i.e. it is a GET request) this function returns None. """ ...
[ "async", "def", "body", "(", "self", ")", ":", "if", "not", "isinstance", "(", "self", ".", "_body", ",", "bytes", ")", ":", "self", ".", "_body", "=", "await", "self", ".", "_body", "return", "self", ".", "_body" ]
A helper function which blocks until the body has been read completely. Returns the bytes of the body which the user should decode. If the request does not have a body part (i.e. it is a GET request) this function returns None.
[ "A", "helper", "function", "which", "blocks", "until", "the", "body", "has", "been", "read", "completely", ".", "Returns", "the", "bytes", "of", "the", "body", "which", "the", "user", "should", "decode", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/request.py#L63-L74
train
pyGrowler/Growler
growler/utils/event_manager.py
event_emitter
def event_emitter(cls_=None, *, events=('*', )): """ A class-decorator which will add the specified events and the methods 'on' and 'emit' to the class. """ # create a dictionary from items in the 'events' parameter and with empty # lists as values event_dict = dict.fromkeys(events, []) ...
python
def event_emitter(cls_=None, *, events=('*', )): """ A class-decorator which will add the specified events and the methods 'on' and 'emit' to the class. """ # create a dictionary from items in the 'events' parameter and with empty # lists as values event_dict = dict.fromkeys(events, []) ...
[ "def", "event_emitter", "(", "cls_", "=", "None", ",", "*", ",", "events", "=", "(", "'*'", ",", ")", ")", ":", "# create a dictionary from items in the 'events' parameter and with empty", "# lists as values", "event_dict", "=", "dict", ".", "fromkeys", "(", "events...
A class-decorator which will add the specified events and the methods 'on' and 'emit' to the class.
[ "A", "class", "-", "decorator", "which", "will", "add", "the", "specified", "events", "and", "the", "methods", "on", "and", "emit", "to", "the", "class", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/utils/event_manager.py#L9-L64
train
pyGrowler/Growler
growler/utils/event_manager.py
Events.on
def on(self, name, _callback=None): """ Add a callback to the event named 'name'. Returns callback object for decorationable calls. """ # this is being used as a decorator if _callback is None: return lambda cb: self.on(name, cb) if not (callable(_ca...
python
def on(self, name, _callback=None): """ Add a callback to the event named 'name'. Returns callback object for decorationable calls. """ # this is being used as a decorator if _callback is None: return lambda cb: self.on(name, cb) if not (callable(_ca...
[ "def", "on", "(", "self", ",", "name", ",", "_callback", "=", "None", ")", ":", "# this is being used as a decorator", "if", "_callback", "is", "None", ":", "return", "lambda", "cb", ":", "self", ".", "on", "(", "name", ",", "cb", ")", "if", "not", "("...
Add a callback to the event named 'name'. Returns callback object for decorationable calls.
[ "Add", "a", "callback", "to", "the", "event", "named", "name", ".", "Returns", "callback", "object", "for", "decorationable", "calls", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/utils/event_manager.py#L109-L124
train
pyGrowler/Growler
growler/utils/event_manager.py
Events.emit
async def emit(self, name): """ Add a callback to the event named 'name'. Returns this object for chained 'on' calls. """ for cb in self._event_list[name]: if isawaitable(cb): await cb else: cb()
python
async def emit(self, name): """ Add a callback to the event named 'name'. Returns this object for chained 'on' calls. """ for cb in self._event_list[name]: if isawaitable(cb): await cb else: cb()
[ "async", "def", "emit", "(", "self", ",", "name", ")", ":", "for", "cb", "in", "self", ".", "_event_list", "[", "name", "]", ":", "if", "isawaitable", "(", "cb", ")", ":", "await", "cb", "else", ":", "cb", "(", ")" ]
Add a callback to the event named 'name'. Returns this object for chained 'on' calls.
[ "Add", "a", "callback", "to", "the", "event", "named", "name", ".", "Returns", "this", "object", "for", "chained", "on", "calls", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/utils/event_manager.py#L126-L135
train
pyGrowler/Growler
growler/core/router.py
routerify
def routerify(obj): """ Scan through attributes of object parameter looking for any which match a route signature. A router will be created and added to the object with parameter. Args: obj (object): The object (with attributes) from which to setup a router Returns: ...
python
def routerify(obj): """ Scan through attributes of object parameter looking for any which match a route signature. A router will be created and added to the object with parameter. Args: obj (object): The object (with attributes) from which to setup a router Returns: ...
[ "def", "routerify", "(", "obj", ")", ":", "router", "=", "Router", "(", ")", "for", "info", "in", "get_routing_attributes", "(", "obj", ")", ":", "router", ".", "add_route", "(", "*", "info", ")", "obj", ".", "__growler_router", "=", "router", "return", ...
Scan through attributes of object parameter looking for any which match a route signature. A router will be created and added to the object with parameter. Args: obj (object): The object (with attributes) from which to setup a router Returns: Router: The router created from...
[ "Scan", "through", "attributes", "of", "object", "parameter", "looking", "for", "any", "which", "match", "a", "route", "signature", ".", "A", "router", "will", "be", "created", "and", "added", "to", "the", "object", "with", "parameter", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/router.py#L281-L298
train
pyGrowler/Growler
growler/core/router.py
Router._add_route
def _add_route(self, method, path, middleware=None): """The implementation of adding a route""" if middleware is not None: self.add(method, path, middleware) return self else: # return a lambda that will return the 'func' argument return lambda fun...
python
def _add_route(self, method, path, middleware=None): """The implementation of adding a route""" if middleware is not None: self.add(method, path, middleware) return self else: # return a lambda that will return the 'func' argument return lambda fun...
[ "def", "_add_route", "(", "self", ",", "method", ",", "path", ",", "middleware", "=", "None", ")", ":", "if", "middleware", "is", "not", "None", ":", "self", ".", "add", "(", "method", ",", "path", ",", "middleware", ")", "return", "self", "else", ":...
The implementation of adding a route
[ "The", "implementation", "of", "adding", "a", "route" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/router.py#L68-L78
train
pyGrowler/Growler
growler/core/router.py
Router.use
def use(self, middleware, path=None): """ Call the provided middleware upon requests matching the path. If path is not provided or None, all requests will match. Args: middleware (callable): Callable with the signature ``(res, req) -> None`` path ...
python
def use(self, middleware, path=None): """ Call the provided middleware upon requests matching the path. If path is not provided or None, all requests will match. Args: middleware (callable): Callable with the signature ``(res, req) -> None`` path ...
[ "def", "use", "(", "self", ",", "middleware", ",", "path", "=", "None", ")", ":", "self", ".", "log", ".", "info", "(", "\" Using middleware {}\"", ",", "middleware", ")", "if", "path", "is", "None", ":", "path", "=", "MiddlewareChain", ".", "ROOT_PATTER...
Call the provided middleware upon requests matching the path. If path is not provided or None, all requests will match. Args: middleware (callable): Callable with the signature ``(res, req) -> None`` path (Optional[str or regex]): a specific path the ...
[ "Call", "the", "provided", "middleware", "upon", "requests", "matching", "the", "path", ".", "If", "path", "is", "not", "provided", "or", "None", "all", "requests", "will", "match", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/router.py#L86-L103
train
pyGrowler/Growler
growler/core/router.py
Router.sinatra_path_to_regex
def sinatra_path_to_regex(cls, path): """ Converts a sinatra-style path to a regex with named parameters. """ # Return the path if already a (compiled) regex if type(path) is cls.regex_type: return path # Build a regular expression string which is spl...
python
def sinatra_path_to_regex(cls, path): """ Converts a sinatra-style path to a regex with named parameters. """ # Return the path if already a (compiled) regex if type(path) is cls.regex_type: return path # Build a regular expression string which is spl...
[ "def", "sinatra_path_to_regex", "(", "cls", ",", "path", ")", ":", "# Return the path if already a (compiled) regex", "if", "type", "(", "path", ")", "is", "cls", ".", "regex_type", ":", "return", "path", "# Build a regular expression string which is split on the '/' charac...
Converts a sinatra-style path to a regex with named parameters.
[ "Converts", "a", "sinatra", "-", "style", "path", "to", "a", "regex", "with", "named", "parameters", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/router.py#L137-L153
train
pyGrowler/Growler
growler/http/parser.py
Parser._parse_and_store_headers
def _parse_and_store_headers(self): """ Coroutine used retrieve header data and parse each header until the body is found. """ header_storage = self._store_header() header_storage.send(None) for header_line in self._next_header_line(): if header_line...
python
def _parse_and_store_headers(self): """ Coroutine used retrieve header data and parse each header until the body is found. """ header_storage = self._store_header() header_storage.send(None) for header_line in self._next_header_line(): if header_line...
[ "def", "_parse_and_store_headers", "(", "self", ")", ":", "header_storage", "=", "self", ".", "_store_header", "(", ")", "header_storage", ".", "send", "(", "None", ")", "for", "header_line", "in", "self", ".", "_next_header_line", "(", ")", ":", "if", "head...
Coroutine used retrieve header data and parse each header until the body is found.
[ "Coroutine", "used", "retrieve", "header", "data", "and", "parse", "each", "header", "until", "the", "body", "is", "found", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/parser.py#L140-L156
train
pyGrowler/Growler
growler/http/parser.py
Parser._store_header
def _store_header(self): """ Logic & state behind storing headers. This is a coroutine that should be sent header lines in the usual fashion. Sending it None will indicate there are no more lines, and the dictionary of headers will be returned. """ key, value = No...
python
def _store_header(self): """ Logic & state behind storing headers. This is a coroutine that should be sent header lines in the usual fashion. Sending it None will indicate there are no more lines, and the dictionary of headers will be returned. """ key, value = No...
[ "def", "_store_header", "(", "self", ")", ":", "key", ",", "value", "=", "None", ",", "None", "headers", "=", "[", "]", "header_line", "=", "yield", "while", "header_line", "is", "not", "None", ":", "if", "not", "header_line", ".", "startswith", "(", "...
Logic & state behind storing headers. This is a coroutine that should be sent header lines in the usual fashion. Sending it None will indicate there are no more lines, and the dictionary of headers will be returned.
[ "Logic", "&", "state", "behind", "storing", "headers", ".", "This", "is", "a", "coroutine", "that", "should", "be", "sent", "header", "lines", "in", "the", "usual", "fashion", ".", "Sending", "it", "None", "will", "indicate", "there", "are", "no", "more", ...
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/parser.py#L158-L185
train
pyGrowler/Growler
growler/http/parser.py
Parser._store_request_line
def _store_request_line(self, req_line): """ Splits the request line given into three components. Ensures that the version and method are valid for this server, and uses the urllib.parse function to parse the request URI. Note: This method has the additional side eff...
python
def _store_request_line(self, req_line): """ Splits the request line given into three components. Ensures that the version and method are valid for this server, and uses the urllib.parse function to parse the request URI. Note: This method has the additional side eff...
[ "def", "_store_request_line", "(", "self", ",", "req_line", ")", ":", "if", "not", "isinstance", "(", "req_line", ",", "str", ")", ":", "try", ":", "req_line", "=", "self", ".", "raw_request_line", "=", "req_line", ".", "decode", "(", ")", "except", "Uni...
Splits the request line given into three components. Ensures that the version and method are valid for this server, and uses the urllib.parse function to parse the request URI. Note: This method has the additional side effect of updating all request line related attribut...
[ "Splits", "the", "request", "line", "given", "into", "three", "components", ".", "Ensures", "that", "the", "version", "and", "method", "are", "valid", "for", "this", "server", "and", "uses", "the", "urllib", ".", "parse", "function", "to", "parse", "the", ...
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/parser.py#L219-L277
train
pyGrowler/Growler
growler/http/parser.py
Parser.determine_newline
def determine_newline(data): """ Looks for a newline character in bytestring parameter 'data'. Currently only looks for strings '\r\n', '\n'. If '\n' is found at the first position of the string, this raises an exception. Parameters: data (bytes): The data to...
python
def determine_newline(data): """ Looks for a newline character in bytestring parameter 'data'. Currently only looks for strings '\r\n', '\n'. If '\n' is found at the first position of the string, this raises an exception. Parameters: data (bytes): The data to...
[ "def", "determine_newline", "(", "data", ")", ":", "line_end_pos", "=", "data", ".", "find", "(", "b'\\n'", ")", "if", "line_end_pos", "==", "-", "1", ":", "return", "None", "elif", "line_end_pos", "==", "0", ":", "return", "b'\\n'", "prev_char", "=", "d...
Looks for a newline character in bytestring parameter 'data'. Currently only looks for strings '\r\n', '\n'. If '\n' is found at the first position of the string, this raises an exception. Parameters: data (bytes): The data to be searched Returns: None: ...
[ "Looks", "for", "a", "newline", "character", "in", "bytestring", "parameter", "data", ".", "Currently", "only", "looks", "for", "strings", "\\", "r", "\\", "n", "\\", "n", ".", "If", "\\", "n", "is", "found", "at", "the", "first", "position", "of", "th...
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/http/parser.py#L280-L303
train
pyGrowler/Growler
growler/core/middleware_chain.py
MiddlewareNode.path_split
def path_split(self, path): """ Splits a path into the part matching this middleware and the part remaining. If path does not exist, it returns a pair of None values. If the regex matches the entire pair, the second item in returned tuple is None. Args: path (str): T...
python
def path_split(self, path): """ Splits a path into the part matching this middleware and the part remaining. If path does not exist, it returns a pair of None values. If the regex matches the entire pair, the second item in returned tuple is None. Args: path (str): T...
[ "def", "path_split", "(", "self", ",", "path", ")", ":", "match", "=", "self", ".", "path", ".", "match", "(", "path", ")", "if", "match", "is", "None", ":", "return", "None", ",", "None", "# split string at position", "the_rest", "=", "path", "[", "ma...
Splits a path into the part matching this middleware and the part remaining. If path does not exist, it returns a pair of None values. If the regex matches the entire pair, the second item in returned tuple is None. Args: path (str): The url to split Returns: Tu...
[ "Splits", "a", "path", "into", "the", "part", "matching", "this", "middleware", "and", "the", "part", "remaining", ".", "If", "path", "does", "not", "exist", "it", "returns", "a", "pair", "of", "None", "values", ".", "If", "the", "regex", "matches", "the...
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/middleware_chain.py#L66-L101
train
pyGrowler/Growler
growler/core/middleware_chain.py
MiddlewareChain.find_matching_middleware
def find_matching_middleware(self, method, path): """ Iterator handling the matching of middleware against a method+path pair. Yields the middleware, and the """ for mw in self.mw_list: if not mw.matches_method(method): continue # get the ...
python
def find_matching_middleware(self, method, path): """ Iterator handling the matching of middleware against a method+path pair. Yields the middleware, and the """ for mw in self.mw_list: if not mw.matches_method(method): continue # get the ...
[ "def", "find_matching_middleware", "(", "self", ",", "method", ",", "path", ")", ":", "for", "mw", "in", "self", ".", "mw_list", ":", "if", "not", "mw", ".", "matches_method", "(", "method", ")", ":", "continue", "# get the path matching this middleware and the ...
Iterator handling the matching of middleware against a method+path pair. Yields the middleware, and the
[ "Iterator", "handling", "the", "matching", "of", "middleware", "against", "a", "method", "+", "path", "pair", ".", "Yields", "the", "middleware", "and", "the" ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/middleware_chain.py#L183-L199
train
pyGrowler/Growler
growler/core/middleware_chain.py
MiddlewareChain.add
def add(self, method_mask, path, func): """ Add a function to the middleware chain. This function is returned when iterating over the chain with matching method and path. Args: method_mask (growler.http.HTTPMethod): A bitwise mask intended to match specific r...
python
def add(self, method_mask, path, func): """ Add a function to the middleware chain. This function is returned when iterating over the chain with matching method and path. Args: method_mask (growler.http.HTTPMethod): A bitwise mask intended to match specific r...
[ "def", "add", "(", "self", ",", "method_mask", ",", "path", ",", "func", ")", ":", "is_err", "=", "len", "(", "signature", "(", "func", ")", ".", "parameters", ")", "==", "3", "is_subchain", "=", "isinstance", "(", "func", ",", "MiddlewareChain", ")", ...
Add a function to the middleware chain. This function is returned when iterating over the chain with matching method and path. Args: method_mask (growler.http.HTTPMethod): A bitwise mask intended to match specific request methods. path (str or regex): An object w...
[ "Add", "a", "function", "to", "the", "middleware", "chain", ".", "This", "function", "is", "returned", "when", "iterating", "over", "the", "chain", "with", "matching", "method", "and", "path", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/middleware_chain.py#L232-L251
train
pyGrowler/Growler
growler/core/middleware_chain.py
MiddlewareChain.count_all
def count_all(self): """ Returns the total number of middleware in this chain and subchains. """ return sum(x.func.count_all() if x.is_subchain else 1 for x in self)
python
def count_all(self): """ Returns the total number of middleware in this chain and subchains. """ return sum(x.func.count_all() if x.is_subchain else 1 for x in self)
[ "def", "count_all", "(", "self", ")", ":", "return", "sum", "(", "x", ".", "func", ".", "count_all", "(", ")", "if", "x", ".", "is_subchain", "else", "1", "for", "x", "in", "self", ")" ]
Returns the total number of middleware in this chain and subchains.
[ "Returns", "the", "total", "number", "of", "middleware", "in", "this", "chain", "and", "subchains", "." ]
90c923ff204f28b86a01d741224987a22f69540f
https://github.com/pyGrowler/Growler/blob/90c923ff204f28b86a01d741224987a22f69540f/growler/core/middleware_chain.py#L268-L272
train
coleifer/django-relationships
relationships/templatetags/relationship_tags.py
if_relationship
def if_relationship(parser, token): """ Determine if a certain type of relationship exists between two users. The ``status`` parameter must be a slug matching either the from_slug, to_slug or symmetrical_slug of a RelationshipStatus. Example:: {% if_relationship from_user to_user "friends"...
python
def if_relationship(parser, token): """ Determine if a certain type of relationship exists between two users. The ``status`` parameter must be a slug matching either the from_slug, to_slug or symmetrical_slug of a RelationshipStatus. Example:: {% if_relationship from_user to_user "friends"...
[ "def", "if_relationship", "(", "parser", ",", "token", ")", ":", "bits", "=", "list", "(", "token", ".", "split_contents", "(", ")", ")", "if", "len", "(", "bits", ")", "!=", "4", ":", "raise", "TemplateSyntaxError", "(", "\"%r takes 3 arguments:\\n%s\"", ...
Determine if a certain type of relationship exists between two users. The ``status`` parameter must be a slug matching either the from_slug, to_slug or symmetrical_slug of a RelationshipStatus. Example:: {% if_relationship from_user to_user "friends" %} Here are pictures of me drinking...
[ "Determine", "if", "a", "certain", "type", "of", "relationship", "exists", "between", "two", "users", ".", "The", "status", "parameter", "must", "be", "a", "slug", "matching", "either", "the", "from_slug", "to_slug", "or", "symmetrical_slug", "of", "a", "Relat...
f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805
https://github.com/coleifer/django-relationships/blob/f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805/relationships/templatetags/relationship_tags.py#L45-L74
train
coleifer/django-relationships
relationships/templatetags/relationship_tags.py
add_relationship_url
def add_relationship_url(user, status): """ Generate a url for adding a relationship on a given user. ``user`` is a User object, and ``status`` is either a relationship_status object or a string denoting a RelationshipStatus Usage:: href="{{ user|add_relationship_url:"following" }}" "...
python
def add_relationship_url(user, status): """ Generate a url for adding a relationship on a given user. ``user`` is a User object, and ``status`` is either a relationship_status object or a string denoting a RelationshipStatus Usage:: href="{{ user|add_relationship_url:"following" }}" "...
[ "def", "add_relationship_url", "(", "user", ",", "status", ")", ":", "if", "isinstance", "(", "status", ",", "RelationshipStatus", ")", ":", "status", "=", "status", ".", "from_slug", "return", "reverse", "(", "'relationship_add'", ",", "args", "=", "[", "us...
Generate a url for adding a relationship on a given user. ``user`` is a User object, and ``status`` is either a relationship_status object or a string denoting a RelationshipStatus Usage:: href="{{ user|add_relationship_url:"following" }}"
[ "Generate", "a", "url", "for", "adding", "a", "relationship", "on", "a", "given", "user", ".", "user", "is", "a", "User", "object", "and", "status", "is", "either", "a", "relationship_status", "object", "or", "a", "string", "denoting", "a", "RelationshipStat...
f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805
https://github.com/coleifer/django-relationships/blob/f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805/relationships/templatetags/relationship_tags.py#L78-L90
train
googlefonts/ufo2ft
Lib/ufo2ft/postProcessor.py
PostProcessor._rename_glyphs_from_ufo
def _rename_glyphs_from_ufo(self): """Rename glyphs using ufo.lib.public.postscriptNames in UFO.""" rename_map = self._build_production_names() otf = self.otf otf.setGlyphOrder([rename_map.get(n, n) for n in otf.getGlyphOrder()]) # we need to compile format 2 'post' table so th...
python
def _rename_glyphs_from_ufo(self): """Rename glyphs using ufo.lib.public.postscriptNames in UFO.""" rename_map = self._build_production_names() otf = self.otf otf.setGlyphOrder([rename_map.get(n, n) for n in otf.getGlyphOrder()]) # we need to compile format 2 'post' table so th...
[ "def", "_rename_glyphs_from_ufo", "(", "self", ")", ":", "rename_map", "=", "self", ".", "_build_production_names", "(", ")", "otf", "=", "self", ".", "otf", "otf", ".", "setGlyphOrder", "(", "[", "rename_map", ".", "get", "(", "n", ",", "n", ")", "for",...
Rename glyphs using ufo.lib.public.postscriptNames in UFO.
[ "Rename", "glyphs", "using", "ufo", ".", "lib", ".", "public", ".", "postscriptNames", "in", "UFO", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/postProcessor.py#L73-L93
train
googlefonts/ufo2ft
Lib/ufo2ft/postProcessor.py
PostProcessor._unique_name
def _unique_name(name, seen): """Append incremental '.N' suffix if glyph is a duplicate.""" if name in seen: n = seen[name] while (name + ".%d" % n) in seen: n += 1 seen[name] = n + 1 name += ".%d" % n seen[name] = 1 return ...
python
def _unique_name(name, seen): """Append incremental '.N' suffix if glyph is a duplicate.""" if name in seen: n = seen[name] while (name + ".%d" % n) in seen: n += 1 seen[name] = n + 1 name += ".%d" % n seen[name] = 1 return ...
[ "def", "_unique_name", "(", "name", ",", "seen", ")", ":", "if", "name", "in", "seen", ":", "n", "=", "seen", "[", "name", "]", "while", "(", "name", "+", "\".%d\"", "%", "n", ")", "in", "seen", ":", "n", "+=", "1", "seen", "[", "name", "]", ...
Append incremental '.N' suffix if glyph is a duplicate.
[ "Append", "incremental", ".", "N", "suffix", "if", "glyph", "is", "a", "duplicate", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/postProcessor.py#L124-L133
train
googlefonts/ufo2ft
Lib/ufo2ft/postProcessor.py
PostProcessor._build_production_name
def _build_production_name(self, glyph): """Build a production name for a single glyph.""" # use PostScript names from UFO lib if available if self._postscriptNames: production_name = self._postscriptNames.get(glyph.name) return production_name if production_name else gl...
python
def _build_production_name(self, glyph): """Build a production name for a single glyph.""" # use PostScript names from UFO lib if available if self._postscriptNames: production_name = self._postscriptNames.get(glyph.name) return production_name if production_name else gl...
[ "def", "_build_production_name", "(", "self", ",", "glyph", ")", ":", "# use PostScript names from UFO lib if available", "if", "self", ".", "_postscriptNames", ":", "production_name", "=", "self", ".", "_postscriptNames", ".", "get", "(", "glyph", ".", "name", ")",...
Build a production name for a single glyph.
[ "Build", "a", "production", "name", "for", "a", "single", "glyph", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/postProcessor.py#L135-L168
train
googlefonts/ufo2ft
Lib/ufo2ft/featureWriters/ast.py
makeFeaClassName
def makeFeaClassName(name, existingClassNames=None): """Make a glyph class name which is legal to use in feature text. Ensures the name only includes characters in "A-Za-z0-9._", and isn't already defined. """ name = re.sub(r"[^A-Za-z0-9._]", r"", name) if existingClassNames is None: re...
python
def makeFeaClassName(name, existingClassNames=None): """Make a glyph class name which is legal to use in feature text. Ensures the name only includes characters in "A-Za-z0-9._", and isn't already defined. """ name = re.sub(r"[^A-Za-z0-9._]", r"", name) if existingClassNames is None: re...
[ "def", "makeFeaClassName", "(", "name", ",", "existingClassNames", "=", "None", ")", ":", "name", "=", "re", ".", "sub", "(", "r\"[^A-Za-z0-9._]\"", ",", "r\"\"", ",", "name", ")", "if", "existingClassNames", "is", "None", ":", "return", "name", "i", "=", ...
Make a glyph class name which is legal to use in feature text. Ensures the name only includes characters in "A-Za-z0-9._", and isn't already defined.
[ "Make", "a", "glyph", "class", "name", "which", "is", "legal", "to", "use", "in", "feature", "text", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureWriters/ast.py#L128-L142
train
googlefonts/ufo2ft
Lib/ufo2ft/featureWriters/ast.py
addLookupReference
def addLookupReference( feature, lookup, script=None, languages=None, exclude_dflt=False ): """Shortcut for addLookupReferences, but for a single lookup. """ return addLookupReferences( feature, (lookup,), script=script, languages=languages, exclude_dflt=exclude_d...
python
def addLookupReference( feature, lookup, script=None, languages=None, exclude_dflt=False ): """Shortcut for addLookupReferences, but for a single lookup. """ return addLookupReferences( feature, (lookup,), script=script, languages=languages, exclude_dflt=exclude_d...
[ "def", "addLookupReference", "(", "feature", ",", "lookup", ",", "script", "=", "None", ",", "languages", "=", "None", ",", "exclude_dflt", "=", "False", ")", ":", "return", "addLookupReferences", "(", "feature", ",", "(", "lookup", ",", ")", ",", "script"...
Shortcut for addLookupReferences, but for a single lookup.
[ "Shortcut", "for", "addLookupReferences", "but", "for", "a", "single", "lookup", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureWriters/ast.py#L184-L195
train
googlefonts/ufo2ft
Lib/ufo2ft/fontInfoData.py
openTypeHeadCreatedFallback
def openTypeHeadCreatedFallback(info): """ Fallback to the environment variable SOURCE_DATE_EPOCH if set, otherwise now. """ if "SOURCE_DATE_EPOCH" in os.environ: t = datetime.utcfromtimestamp(int(os.environ["SOURCE_DATE_EPOCH"])) return t.strftime(_date_format) else: ret...
python
def openTypeHeadCreatedFallback(info): """ Fallback to the environment variable SOURCE_DATE_EPOCH if set, otherwise now. """ if "SOURCE_DATE_EPOCH" in os.environ: t = datetime.utcfromtimestamp(int(os.environ["SOURCE_DATE_EPOCH"])) return t.strftime(_date_format) else: ret...
[ "def", "openTypeHeadCreatedFallback", "(", "info", ")", ":", "if", "\"SOURCE_DATE_EPOCH\"", "in", "os", ".", "environ", ":", "t", "=", "datetime", ".", "utcfromtimestamp", "(", "int", "(", "os", ".", "environ", "[", "\"SOURCE_DATE_EPOCH\"", "]", ")", ")", "r...
Fallback to the environment variable SOURCE_DATE_EPOCH if set, otherwise now.
[ "Fallback", "to", "the", "environment", "variable", "SOURCE_DATE_EPOCH", "if", "set", "otherwise", "now", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/fontInfoData.py#L79-L88
train
googlefonts/ufo2ft
Lib/ufo2ft/fontInfoData.py
preflightInfo
def preflightInfo(info): """ Returns a dict containing two items. The value for each item will be a list of info attribute names. ================== === missingRequired Required data that is missing. missingRecommended Recommended data that is missing. ================== === """ ...
python
def preflightInfo(info): """ Returns a dict containing two items. The value for each item will be a list of info attribute names. ================== === missingRequired Required data that is missing. missingRecommended Recommended data that is missing. ================== === """ ...
[ "def", "preflightInfo", "(", "info", ")", ":", "missingRequired", "=", "set", "(", ")", "missingRecommended", "=", "set", "(", ")", "for", "attr", "in", "requiredAttributes", ":", "if", "not", "hasattr", "(", "info", ",", "attr", ")", "or", "getattr", "(...
Returns a dict containing two items. The value for each item will be a list of info attribute names. ================== === missingRequired Required data that is missing. missingRecommended Recommended data that is missing. ================== ===
[ "Returns", "a", "dict", "containing", "two", "items", ".", "The", "value", "for", "each", "item", "will", "be", "a", "list", "of", "info", "attribute", "names", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/fontInfoData.py#L466-L484
train
coleifer/django-relationships
relationships/models.py
RelationshipManager.add
def add(self, user, status=None, symmetrical=False): """ Add a relationship from one user to another with the given status, which defaults to "following". Adding a relationship is by default asymmetrical (akin to following someone on twitter). Specify a symmetrical relationship...
python
def add(self, user, status=None, symmetrical=False): """ Add a relationship from one user to another with the given status, which defaults to "following". Adding a relationship is by default asymmetrical (akin to following someone on twitter). Specify a symmetrical relationship...
[ "def", "add", "(", "self", ",", "user", ",", "status", "=", "None", ",", "symmetrical", "=", "False", ")", ":", "if", "not", "status", ":", "status", "=", "RelationshipStatus", ".", "objects", ".", "following", "(", ")", "relationship", ",", "created", ...
Add a relationship from one user to another with the given status, which defaults to "following". Adding a relationship is by default asymmetrical (akin to following someone on twitter). Specify a symmetrical relationship (akin to being friends on facebook) by passing in :param:`symmet...
[ "Add", "a", "relationship", "from", "one", "user", "to", "another", "with", "the", "given", "status", "which", "defaults", "to", "following", "." ]
f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805
https://github.com/coleifer/django-relationships/blob/f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805/relationships/models.py#L83-L110
train
coleifer/django-relationships
relationships/models.py
RelationshipManager.remove
def remove(self, user, status=None, symmetrical=False): """ Remove a relationship from one user to another, with the same caveats and behavior as adding a relationship. """ if not status: status = RelationshipStatus.objects.following() res = Relationship.obje...
python
def remove(self, user, status=None, symmetrical=False): """ Remove a relationship from one user to another, with the same caveats and behavior as adding a relationship. """ if not status: status = RelationshipStatus.objects.following() res = Relationship.obje...
[ "def", "remove", "(", "self", ",", "user", ",", "status", "=", "None", ",", "symmetrical", "=", "False", ")", ":", "if", "not", "status", ":", "status", "=", "RelationshipStatus", ".", "objects", ".", "following", "(", ")", "res", "=", "Relationship", ...
Remove a relationship from one user to another, with the same caveats and behavior as adding a relationship.
[ "Remove", "a", "relationship", "from", "one", "user", "to", "another", "with", "the", "same", "caveats", "and", "behavior", "as", "adding", "a", "relationship", "." ]
f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805
https://github.com/coleifer/django-relationships/blob/f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805/relationships/models.py#L112-L130
train
coleifer/django-relationships
relationships/models.py
RelationshipManager.get_relationships
def get_relationships(self, status, symmetrical=False): """ Returns a QuerySet of user objects with which the given user has established a relationship. """ query = self._get_from_query(status) if symmetrical: query.update(self._get_to_query(status)) ...
python
def get_relationships(self, status, symmetrical=False): """ Returns a QuerySet of user objects with which the given user has established a relationship. """ query = self._get_from_query(status) if symmetrical: query.update(self._get_to_query(status)) ...
[ "def", "get_relationships", "(", "self", ",", "status", ",", "symmetrical", "=", "False", ")", ":", "query", "=", "self", ".", "_get_from_query", "(", "status", ")", "if", "symmetrical", ":", "query", ".", "update", "(", "self", ".", "_get_to_query", "(", ...
Returns a QuerySet of user objects with which the given user has established a relationship.
[ "Returns", "a", "QuerySet", "of", "user", "objects", "with", "which", "the", "given", "user", "has", "established", "a", "relationship", "." ]
f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805
https://github.com/coleifer/django-relationships/blob/f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805/relationships/models.py#L146-L156
train
coleifer/django-relationships
relationships/models.py
RelationshipManager.only_to
def only_to(self, status): """ Returns a QuerySet of user objects who have created a relationship to the given user, but which the given user has not reciprocated """ from_relationships = self.get_relationships(status) to_relationships = self.get_related_to(status) ...
python
def only_to(self, status): """ Returns a QuerySet of user objects who have created a relationship to the given user, but which the given user has not reciprocated """ from_relationships = self.get_relationships(status) to_relationships = self.get_related_to(status) ...
[ "def", "only_to", "(", "self", ",", "status", ")", ":", "from_relationships", "=", "self", ".", "get_relationships", "(", "status", ")", "to_relationships", "=", "self", ".", "get_related_to", "(", "status", ")", "return", "to_relationships", ".", "exclude", "...
Returns a QuerySet of user objects who have created a relationship to the given user, but which the given user has not reciprocated
[ "Returns", "a", "QuerySet", "of", "user", "objects", "who", "have", "created", "a", "relationship", "to", "the", "given", "user", "but", "which", "the", "given", "user", "has", "not", "reciprocated" ]
f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805
https://github.com/coleifer/django-relationships/blob/f15d0a186d9cc5cc2ca3fb2b6ec4b498df951805/relationships/models.py#L165-L172
train
googlefonts/ufo2ft
Lib/ufo2ft/util.py
makeOfficialGlyphOrder
def makeOfficialGlyphOrder(font, glyphOrder=None): """ Make the final glyph order for 'font'. If glyphOrder is None, try getting the font.glyphOrder list. If not explicit glyphOrder is defined, sort glyphs alphabetically. If ".notdef" glyph is present in the font, force this to always be the first...
python
def makeOfficialGlyphOrder(font, glyphOrder=None): """ Make the final glyph order for 'font'. If glyphOrder is None, try getting the font.glyphOrder list. If not explicit glyphOrder is defined, sort glyphs alphabetically. If ".notdef" glyph is present in the font, force this to always be the first...
[ "def", "makeOfficialGlyphOrder", "(", "font", ",", "glyphOrder", "=", "None", ")", ":", "if", "glyphOrder", "is", "None", ":", "glyphOrder", "=", "getattr", "(", "font", ",", "\"glyphOrder\"", ",", "(", ")", ")", "names", "=", "set", "(", "font", ".", ...
Make the final glyph order for 'font'. If glyphOrder is None, try getting the font.glyphOrder list. If not explicit glyphOrder is defined, sort glyphs alphabetically. If ".notdef" glyph is present in the font, force this to always be the first glyph (at index 0).
[ "Make", "the", "final", "glyph", "order", "for", "font", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/util.py#L27-L49
train
googlefonts/ufo2ft
Lib/ufo2ft/util.py
_GlyphSet.from_layer
def from_layer(cls, font, layerName=None, copy=False, skipExportGlyphs=None): """Return a mapping of glyph names to glyph objects from `font`.""" if layerName is not None: layer = font.layers[layerName] else: layer = font.layers.defaultLayer if copy: ...
python
def from_layer(cls, font, layerName=None, copy=False, skipExportGlyphs=None): """Return a mapping of glyph names to glyph objects from `font`.""" if layerName is not None: layer = font.layers[layerName] else: layer = font.layers.defaultLayer if copy: ...
[ "def", "from_layer", "(", "cls", ",", "font", ",", "layerName", "=", "None", ",", "copy", "=", "False", ",", "skipExportGlyphs", "=", "None", ")", ":", "if", "layerName", "is", "not", "None", ":", "layer", "=", "font", ".", "layers", "[", "layerName", ...
Return a mapping of glyph names to glyph objects from `font`.
[ "Return", "a", "mapping", "of", "glyph", "names", "to", "glyph", "objects", "from", "font", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/util.py#L54-L93
train
googlefonts/ufo2ft
Lib/ufo2ft/featureCompiler.py
parseLayoutFeatures
def parseLayoutFeatures(font): """ Parse OpenType layout features in the UFO and return a feaLib.ast.FeatureFile instance. """ featxt = tounicode(font.features.text or "", "utf-8") if not featxt: return ast.FeatureFile() buf = UnicodeIO(featxt) # the path is used by the lexer to reso...
python
def parseLayoutFeatures(font): """ Parse OpenType layout features in the UFO and return a feaLib.ast.FeatureFile instance. """ featxt = tounicode(font.features.text or "", "utf-8") if not featxt: return ast.FeatureFile() buf = UnicodeIO(featxt) # the path is used by the lexer to reso...
[ "def", "parseLayoutFeatures", "(", "font", ")", ":", "featxt", "=", "tounicode", "(", "font", ".", "features", ".", "text", "or", "\"\"", ",", "\"utf-8\"", ")", "if", "not", "featxt", ":", "return", "ast", ".", "FeatureFile", "(", ")", "buf", "=", "Uni...
Parse OpenType layout features in the UFO and return a feaLib.ast.FeatureFile instance.
[ "Parse", "OpenType", "layout", "features", "in", "the", "UFO", "and", "return", "a", "feaLib", ".", "ast", ".", "FeatureFile", "instance", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureCompiler.py#L30-L58
train
googlefonts/ufo2ft
Lib/ufo2ft/featureCompiler.py
FeatureCompiler.setupFeatures
def setupFeatures(self): """ Make the features source. **This should not be called externally.** Subclasses may override this method to handle the file creation in a different way if desired. """ if self.featureWriters: featureFile = parseLayoutFeatur...
python
def setupFeatures(self): """ Make the features source. **This should not be called externally.** Subclasses may override this method to handle the file creation in a different way if desired. """ if self.featureWriters: featureFile = parseLayoutFeatur...
[ "def", "setupFeatures", "(", "self", ")", ":", "if", "self", ".", "featureWriters", ":", "featureFile", "=", "parseLayoutFeatures", "(", "self", ".", "ufo", ")", "for", "writer", "in", "self", ".", "featureWriters", ":", "writer", ".", "write", "(", "self"...
Make the features source. **This should not be called externally.** Subclasses may override this method to handle the file creation in a different way if desired.
[ "Make", "the", "features", "source", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureCompiler.py#L213-L231
train
googlefonts/ufo2ft
Lib/ufo2ft/featureCompiler.py
FeatureCompiler.buildTables
def buildTables(self): """ Compile OpenType feature tables from the source. Raises a FeaLibError if the feature compilation was unsuccessful. **This should not be called externally.** Subclasses may override this method to handle the table compilation in a different way ...
python
def buildTables(self): """ Compile OpenType feature tables from the source. Raises a FeaLibError if the feature compilation was unsuccessful. **This should not be called externally.** Subclasses may override this method to handle the table compilation in a different way ...
[ "def", "buildTables", "(", "self", ")", ":", "if", "not", "self", ".", "features", ":", "return", "# the path is used by the lexer to follow 'include' statements;", "# if we generated some automatic features, includes have already been", "# resolved, and we work from a string which doe...
Compile OpenType feature tables from the source. Raises a FeaLibError if the feature compilation was unsuccessful. **This should not be called externally.** Subclasses may override this method to handle the table compilation in a different way if desired.
[ "Compile", "OpenType", "feature", "tables", "from", "the", "source", ".", "Raises", "a", "FeaLibError", "if", "the", "feature", "compilation", "was", "unsuccessful", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureCompiler.py#L233-L263
train
googlefonts/ufo2ft
Lib/ufo2ft/maxContextCalc.py
maxCtxFont
def maxCtxFont(font): """Calculate the usMaxContext value for an entire font.""" maxCtx = 0 for tag in ('GSUB', 'GPOS'): if tag not in font: continue table = font[tag].table if table.LookupList is None: continue for lookup in table.LookupList.Lookup: ...
python
def maxCtxFont(font): """Calculate the usMaxContext value for an entire font.""" maxCtx = 0 for tag in ('GSUB', 'GPOS'): if tag not in font: continue table = font[tag].table if table.LookupList is None: continue for lookup in table.LookupList.Lookup: ...
[ "def", "maxCtxFont", "(", "font", ")", ":", "maxCtx", "=", "0", "for", "tag", "in", "(", "'GSUB'", ",", "'GPOS'", ")", ":", "if", "tag", "not", "in", "font", ":", "continue", "table", "=", "font", "[", "tag", "]", ".", "table", "if", "table", "."...
Calculate the usMaxContext value for an entire font.
[ "Calculate", "the", "usMaxContext", "value", "for", "an", "entire", "font", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/maxContextCalc.py#L6-L19
train
googlefonts/ufo2ft
Lib/ufo2ft/maxContextCalc.py
maxCtxContextualSubtable
def maxCtxContextualSubtable(maxCtx, st, ruleType, chain=''): """Calculate usMaxContext based on a contextual feature subtable.""" if st.Format == 1: for ruleset in getattr(st, '%s%sRuleSet' % (chain, ruleType)): if ruleset is None: continue for rule in getattr(r...
python
def maxCtxContextualSubtable(maxCtx, st, ruleType, chain=''): """Calculate usMaxContext based on a contextual feature subtable.""" if st.Format == 1: for ruleset in getattr(st, '%s%sRuleSet' % (chain, ruleType)): if ruleset is None: continue for rule in getattr(r...
[ "def", "maxCtxContextualSubtable", "(", "maxCtx", ",", "st", ",", "ruleType", ",", "chain", "=", "''", ")", ":", "if", "st", ".", "Format", "==", "1", ":", "for", "ruleset", "in", "getattr", "(", "st", ",", "'%s%sRuleSet'", "%", "(", "chain", ",", "r...
Calculate usMaxContext based on a contextual feature subtable.
[ "Calculate", "usMaxContext", "based", "on", "a", "contextual", "feature", "subtable", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/maxContextCalc.py#L67-L91
train
googlefonts/ufo2ft
Lib/ufo2ft/maxContextCalc.py
maxCtxContextualRule
def maxCtxContextualRule(maxCtx, st, chain): """Calculate usMaxContext based on a contextual feature rule.""" if not chain: return max(maxCtx, st.GlyphCount) elif chain == 'Reverse': return max(maxCtx, st.GlyphCount + st.LookAheadGlyphCount) return max(maxCtx, st.InputGlyphCount + st.Lo...
python
def maxCtxContextualRule(maxCtx, st, chain): """Calculate usMaxContext based on a contextual feature rule.""" if not chain: return max(maxCtx, st.GlyphCount) elif chain == 'Reverse': return max(maxCtx, st.GlyphCount + st.LookAheadGlyphCount) return max(maxCtx, st.InputGlyphCount + st.Lo...
[ "def", "maxCtxContextualRule", "(", "maxCtx", ",", "st", ",", "chain", ")", ":", "if", "not", "chain", ":", "return", "max", "(", "maxCtx", ",", "st", ".", "GlyphCount", ")", "elif", "chain", "==", "'Reverse'", ":", "return", "max", "(", "maxCtx", ",",...
Calculate usMaxContext based on a contextual feature rule.
[ "Calculate", "usMaxContext", "based", "on", "a", "contextual", "feature", "rule", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/maxContextCalc.py#L94-L101
train
googlefonts/ufo2ft
Lib/ufo2ft/__init__.py
compileOTF
def compileOTF( ufo, preProcessorClass=OTFPreProcessor, outlineCompilerClass=OutlineOTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, optimizeCFF=CFFOptimization.SUBROUTINIZE, roundTolerance=None, removeOverlaps=False, over...
python
def compileOTF( ufo, preProcessorClass=OTFPreProcessor, outlineCompilerClass=OutlineOTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, optimizeCFF=CFFOptimization.SUBROUTINIZE, roundTolerance=None, removeOverlaps=False, over...
[ "def", "compileOTF", "(", "ufo", ",", "preProcessorClass", "=", "OTFPreProcessor", ",", "outlineCompilerClass", "=", "OutlineOTFCompiler", ",", "featureCompilerClass", "=", "None", ",", "featureWriters", "=", "None", ",", "glyphOrder", "=", "None", ",", "useProducti...
Create FontTools CFF font from a UFO. *removeOverlaps* performs a union operation on all the glyphs' contours. *optimizeCFF* (int) defines whether the CFF charstrings should be specialized and subroutinized. By default both optimization are enabled. A value of 0 disables both; 1 only enables the s...
[ "Create", "FontTools", "CFF", "font", "from", "a", "UFO", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/__init__.py#L38-L140
train
googlefonts/ufo2ft
Lib/ufo2ft/__init__.py
compileTTF
def compileTTF( ufo, preProcessorClass=TTFPreProcessor, outlineCompilerClass=OutlineTTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, convertCubics=True, cubicConversionError=None, reverseDirection=True, rememberCurveType=T...
python
def compileTTF( ufo, preProcessorClass=TTFPreProcessor, outlineCompilerClass=OutlineTTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, convertCubics=True, cubicConversionError=None, reverseDirection=True, rememberCurveType=T...
[ "def", "compileTTF", "(", "ufo", ",", "preProcessorClass", "=", "TTFPreProcessor", ",", "outlineCompilerClass", "=", "OutlineTTFCompiler", ",", "featureCompilerClass", "=", "None", ",", "featureWriters", "=", "None", ",", "glyphOrder", "=", "None", ",", "useProducti...
Create FontTools TrueType font from a UFO. *removeOverlaps* performs a union operation on all the glyphs' contours. *convertCubics* and *cubicConversionError* specify how the conversion from cubic to quadratic curves should be handled. *layerName* specifies which layer should be compiled. When compil...
[ "Create", "FontTools", "TrueType", "font", "from", "a", "UFO", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/__init__.py#L143-L216
train
googlefonts/ufo2ft
Lib/ufo2ft/__init__.py
compileInterpolatableTTFs
def compileInterpolatableTTFs( ufos, preProcessorClass=TTFInterpolatablePreProcessor, outlineCompilerClass=OutlineTTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, cubicConversionError=None, reverseDirection=True, inplace=False...
python
def compileInterpolatableTTFs( ufos, preProcessorClass=TTFInterpolatablePreProcessor, outlineCompilerClass=OutlineTTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, cubicConversionError=None, reverseDirection=True, inplace=False...
[ "def", "compileInterpolatableTTFs", "(", "ufos", ",", "preProcessorClass", "=", "TTFInterpolatablePreProcessor", ",", "outlineCompilerClass", "=", "OutlineTTFCompiler", ",", "featureCompilerClass", "=", "None", ",", "featureWriters", "=", "None", ",", "glyphOrder", "=", ...
Create FontTools TrueType fonts from a list of UFOs with interpolatable outlines. Cubic curves are converted compatibly to quadratic curves using the Cu2Qu conversion algorithm. Return an iterator object that yields a TTFont instance for each UFO. *layerNames* refers to the layer names to use glyphs f...
[ "Create", "FontTools", "TrueType", "fonts", "from", "a", "list", "of", "UFOs", "with", "interpolatable", "outlines", ".", "Cubic", "curves", "are", "converted", "compatibly", "to", "quadratic", "curves", "using", "the", "Cu2Qu", "conversion", "algorithm", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/__init__.py#L219-L316
train
googlefonts/ufo2ft
Lib/ufo2ft/__init__.py
compileInterpolatableTTFsFromDS
def compileInterpolatableTTFsFromDS( designSpaceDoc, preProcessorClass=TTFInterpolatablePreProcessor, outlineCompilerClass=OutlineTTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, cubicConversionError=None, reverseDirection=True, ...
python
def compileInterpolatableTTFsFromDS( designSpaceDoc, preProcessorClass=TTFInterpolatablePreProcessor, outlineCompilerClass=OutlineTTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, cubicConversionError=None, reverseDirection=True, ...
[ "def", "compileInterpolatableTTFsFromDS", "(", "designSpaceDoc", ",", "preProcessorClass", "=", "TTFInterpolatablePreProcessor", ",", "outlineCompilerClass", "=", "OutlineTTFCompiler", ",", "featureCompilerClass", "=", "None", ",", "featureWriters", "=", "None", ",", "glyph...
Create FontTools TrueType fonts from the DesignSpaceDocument UFO sources with interpolatable outlines. Cubic curves are converted compatibly to quadratic curves using the Cu2Qu conversion algorithm. If the Designspace contains a "public.skipExportGlyphs" lib key, these glyphs will not be exported to th...
[ "Create", "FontTools", "TrueType", "fonts", "from", "the", "DesignSpaceDocument", "UFO", "sources", "with", "interpolatable", "outlines", ".", "Cubic", "curves", "are", "converted", "compatibly", "to", "quadratic", "curves", "using", "the", "Cu2Qu", "conversion", "a...
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/__init__.py#L319-L390
train
googlefonts/ufo2ft
Lib/ufo2ft/__init__.py
compileInterpolatableOTFsFromDS
def compileInterpolatableOTFsFromDS( designSpaceDoc, preProcessorClass=OTFPreProcessor, outlineCompilerClass=OutlineOTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, roundTolerance=None, inplace=False, ): """Create FontTools CF...
python
def compileInterpolatableOTFsFromDS( designSpaceDoc, preProcessorClass=OTFPreProcessor, outlineCompilerClass=OutlineOTFCompiler, featureCompilerClass=None, featureWriters=None, glyphOrder=None, useProductionNames=None, roundTolerance=None, inplace=False, ): """Create FontTools CF...
[ "def", "compileInterpolatableOTFsFromDS", "(", "designSpaceDoc", ",", "preProcessorClass", "=", "OTFPreProcessor", ",", "outlineCompilerClass", "=", "OutlineOTFCompiler", ",", "featureCompilerClass", "=", "None", ",", "featureWriters", "=", "None", ",", "glyphOrder", "=",...
Create FontTools CFF fonts from the DesignSpaceDocument UFO sources with interpolatable outlines. Interpolatable means without subroutinization and specializer optimizations and no removal of overlaps. If the Designspace contains a "public.skipExportGlyphs" lib key, these glyphs will not be export...
[ "Create", "FontTools", "CFF", "fonts", "from", "the", "DesignSpaceDocument", "UFO", "sources", "with", "interpolatable", "outlines", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/__init__.py#L393-L470
train
googlefonts/ufo2ft
Lib/ufo2ft/__init__.py
compileFeatures
def compileFeatures( ufo, ttFont=None, glyphSet=None, featureWriters=None, featureCompilerClass=None, ): """ Compile OpenType Layout features from `ufo` into FontTools OTL tables. If `ttFont` is None, a new TTFont object is created containing the new tables, else the provided `ttFont` is...
python
def compileFeatures( ufo, ttFont=None, glyphSet=None, featureWriters=None, featureCompilerClass=None, ): """ Compile OpenType Layout features from `ufo` into FontTools OTL tables. If `ttFont` is None, a new TTFont object is created containing the new tables, else the provided `ttFont` is...
[ "def", "compileFeatures", "(", "ufo", ",", "ttFont", "=", "None", ",", "glyphSet", "=", "None", ",", "featureWriters", "=", "None", ",", "featureCompilerClass", "=", "None", ",", ")", ":", "if", "featureCompilerClass", "is", "None", ":", "if", "any", "(", ...
Compile OpenType Layout features from `ufo` into FontTools OTL tables. If `ttFont` is None, a new TTFont object is created containing the new tables, else the provided `ttFont` is updated with the new tables. If no explicit `featureCompilerClass` is provided, the one used will depend on whether the ufo...
[ "Compile", "OpenType", "Layout", "features", "from", "ufo", "into", "FontTools", "OTL", "tables", ".", "If", "ttFont", "is", "None", "a", "new", "TTFont", "object", "is", "created", "containing", "the", "new", "tables", "else", "the", "provided", "ttFont", "...
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/__init__.py#L473-L504
train
googlefonts/ufo2ft
Lib/ufo2ft/filters/propagateAnchors.py
_propagate_glyph_anchors
def _propagate_glyph_anchors(glyphSet, composite, processed): """ Propagate anchors from base glyphs to a given composite glyph, and to all composite glyphs used in between. """ if composite.name in processed: return processed.add(composite.name) if not composite.components: ...
python
def _propagate_glyph_anchors(glyphSet, composite, processed): """ Propagate anchors from base glyphs to a given composite glyph, and to all composite glyphs used in between. """ if composite.name in processed: return processed.add(composite.name) if not composite.components: ...
[ "def", "_propagate_glyph_anchors", "(", "glyphSet", ",", "composite", ",", "processed", ")", ":", "if", "composite", ".", "name", "in", "processed", ":", "return", "processed", ".", "add", "(", "composite", ".", "name", ")", "if", "not", "composite", ".", ...
Propagate anchors from base glyphs to a given composite glyph, and to all composite glyphs used in between.
[ "Propagate", "anchors", "from", "base", "glyphs", "to", "a", "given", "composite", "glyph", "and", "to", "all", "composite", "glyphs", "used", "in", "between", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/filters/propagateAnchors.py#L51-L115
train
googlefonts/ufo2ft
Lib/ufo2ft/filters/propagateAnchors.py
_get_anchor_data
def _get_anchor_data(anchor_data, glyphSet, components, anchor_name): """Get data for an anchor from a list of components.""" anchors = [] for component in components: for anchor in glyphSet[component.baseGlyph].anchors: if anchor.name == anchor_name: anchors.append((anc...
python
def _get_anchor_data(anchor_data, glyphSet, components, anchor_name): """Get data for an anchor from a list of components.""" anchors = [] for component in components: for anchor in glyphSet[component.baseGlyph].anchors: if anchor.name == anchor_name: anchors.append((anc...
[ "def", "_get_anchor_data", "(", "anchor_data", ",", "glyphSet", ",", "components", ",", "anchor_name", ")", ":", "anchors", "=", "[", "]", "for", "component", "in", "components", ":", "for", "anchor", "in", "glyphSet", "[", "component", ".", "baseGlyph", "]"...
Get data for an anchor from a list of components.
[ "Get", "data", "for", "an", "anchor", "from", "a", "list", "of", "components", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/filters/propagateAnchors.py#L118-L135
train
googlefonts/ufo2ft
Lib/ufo2ft/featureWriters/baseFeatureWriter.py
BaseFeatureWriter.setContext
def setContext(self, font, feaFile, compiler=None): """ Populate a temporary `self.context` namespace, which is reset after each new call to `_write` method. Subclasses can override this to provide contextual information which depends on other data, or set any temporary attributes. ...
python
def setContext(self, font, feaFile, compiler=None): """ Populate a temporary `self.context` namespace, which is reset after each new call to `_write` method. Subclasses can override this to provide contextual information which depends on other data, or set any temporary attributes. ...
[ "def", "setContext", "(", "self", ",", "font", ",", "feaFile", ",", "compiler", "=", "None", ")", ":", "todo", "=", "set", "(", "self", ".", "features", ")", "if", "self", ".", "mode", "==", "\"skip\"", ":", "existing", "=", "ast", ".", "findFeatureT...
Populate a temporary `self.context` namespace, which is reset after each new call to `_write` method. Subclasses can override this to provide contextual information which depends on other data, or set any temporary attributes. The default implementation sets: - the current font;...
[ "Populate", "a", "temporary", "self", ".", "context", "namespace", "which", "is", "reset", "after", "each", "new", "call", "to", "_write", "method", ".", "Subclasses", "can", "override", "this", "to", "provide", "contextual", "information", "which", "depends", ...
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureWriters/baseFeatureWriter.py#L70-L95
train
googlefonts/ufo2ft
Lib/ufo2ft/featureWriters/baseFeatureWriter.py
BaseFeatureWriter.write
def write(self, font, feaFile, compiler=None): """Write features and class definitions for this font to a feaLib FeatureFile object. Returns True if feature file was modified, False if no new features were generated. """ self.setContext(font, feaFile, compiler=compiler) ...
python
def write(self, font, feaFile, compiler=None): """Write features and class definitions for this font to a feaLib FeatureFile object. Returns True if feature file was modified, False if no new features were generated. """ self.setContext(font, feaFile, compiler=compiler) ...
[ "def", "write", "(", "self", ",", "font", ",", "feaFile", ",", "compiler", "=", "None", ")", ":", "self", ".", "setContext", "(", "font", ",", "feaFile", ",", "compiler", "=", "compiler", ")", "try", ":", "if", "self", ".", "shouldContinue", "(", ")"...
Write features and class definitions for this font to a feaLib FeatureFile object. Returns True if feature file was modified, False if no new features were generated.
[ "Write", "features", "and", "class", "definitions", "for", "this", "font", "to", "a", "feaLib", "FeatureFile", "object", ".", "Returns", "True", "if", "feature", "file", "was", "modified", "False", "if", "no", "new", "features", "were", "generated", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureWriters/baseFeatureWriter.py#L109-L122
train
googlefonts/ufo2ft
Lib/ufo2ft/featureWriters/baseFeatureWriter.py
BaseFeatureWriter.makeUnicodeToGlyphNameMapping
def makeUnicodeToGlyphNameMapping(self): """Return the Unicode to glyph name mapping for the current font. """ # Try to get the "best" Unicode cmap subtable if this writer is running # in the context of a FeatureCompiler, else create a new mapping from # the UFO glyphs co...
python
def makeUnicodeToGlyphNameMapping(self): """Return the Unicode to glyph name mapping for the current font. """ # Try to get the "best" Unicode cmap subtable if this writer is running # in the context of a FeatureCompiler, else create a new mapping from # the UFO glyphs co...
[ "def", "makeUnicodeToGlyphNameMapping", "(", "self", ")", ":", "# Try to get the \"best\" Unicode cmap subtable if this writer is running", "# in the context of a FeatureCompiler, else create a new mapping from", "# the UFO glyphs", "compiler", "=", "self", ".", "context", ".", "compil...
Return the Unicode to glyph name mapping for the current font.
[ "Return", "the", "Unicode", "to", "glyph", "name", "mapping", "for", "the", "current", "font", "." ]
915b986558e87bee288765d9218cc1cd4ebf7f4c
https://github.com/googlefonts/ufo2ft/blob/915b986558e87bee288765d9218cc1cd4ebf7f4c/Lib/ufo2ft/featureWriters/baseFeatureWriter.py#L128-L148
train