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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
serkanyersen/underscore.py
src/underscore.py
underscore.include
def include(self, target): """ Determine if a given value is included in the array or object using `is`. """ if self._clean.isDict(): return self._wrap(target in self.obj.values()) else: return self._wrap(target in self.obj)
python
def include(self, target): """ Determine if a given value is included in the array or object using `is`. """ if self._clean.isDict(): return self._wrap(target in self.obj.values()) else: return self._wrap(target in self.obj)
[ "def", "include", "(", "self", ",", "target", ")", ":", "if", "self", ".", "_clean", ".", "isDict", "(", ")", ":", "return", "self", ".", "_wrap", "(", "target", "in", "self", ".", "obj", ".", "values", "(", ")", ")", "else", ":", "return", "self...
Determine if a given value is included in the array or object using `is`.
[ "Determine", "if", "a", "given", "value", "is", "included", "in", "the", "array", "or", "object", "using", "is", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L289-L297
train
61,300
serkanyersen/underscore.py
src/underscore.py
underscore.shuffle
def shuffle(self): """ Shuffle an array. """ if(self._clean.isDict()): return self._wrap(list()) cloned = self.obj[:] random.shuffle(cloned) return self._wrap(cloned)
python
def shuffle(self): """ Shuffle an array. """ if(self._clean.isDict()): return self._wrap(list()) cloned = self.obj[:] random.shuffle(cloned) return self._wrap(cloned)
[ "def", "shuffle", "(", "self", ")", ":", "if", "(", "self", ".", "_clean", ".", "isDict", "(", ")", ")", ":", "return", "self", ".", "_wrap", "(", "list", "(", ")", ")", "cloned", "=", "self", ".", "obj", "[", ":", "]", "random", ".", "shuffle"...
Shuffle an array.
[ "Shuffle", "an", "array", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L365-L374
train
61,301
serkanyersen/underscore.py
src/underscore.py
underscore.sortBy
def sortBy(self, val=None): """ Sort the object's values by a criterion produced by an iterator. """ if val is not None: if _(val).isString(): return self._wrap(sorted(self.obj, key=lambda x, *args: x.get(val))) else: ...
python
def sortBy(self, val=None): """ Sort the object's values by a criterion produced by an iterator. """ if val is not None: if _(val).isString(): return self._wrap(sorted(self.obj, key=lambda x, *args: x.get(val))) else: ...
[ "def", "sortBy", "(", "self", ",", "val", "=", "None", ")", ":", "if", "val", "is", "not", "None", ":", "if", "_", "(", "val", ")", ".", "isString", "(", ")", ":", "return", "self", ".", "_wrap", "(", "sorted", "(", "self", ".", "obj", ",", "...
Sort the object's values by a criterion produced by an iterator.
[ "Sort", "the", "object", "s", "values", "by", "a", "criterion", "produced", "by", "an", "iterator", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L376-L386
train
61,302
serkanyersen/underscore.py
src/underscore.py
underscore._lookupIterator
def _lookupIterator(self, val): """ An internal function to generate lookup iterators. """ if val is None: return lambda el, *args: el return val if _.isCallable(val) else lambda obj, *args: obj[val]
python
def _lookupIterator(self, val): """ An internal function to generate lookup iterators. """ if val is None: return lambda el, *args: el return val if _.isCallable(val) else lambda obj, *args: obj[val]
[ "def", "_lookupIterator", "(", "self", ",", "val", ")", ":", "if", "val", "is", "None", ":", "return", "lambda", "el", ",", "*", "args", ":", "el", "return", "val", "if", "_", ".", "isCallable", "(", "val", ")", "else", "lambda", "obj", ",", "*", ...
An internal function to generate lookup iterators.
[ "An", "internal", "function", "to", "generate", "lookup", "iterators", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L388-L393
train
61,303
serkanyersen/underscore.py
src/underscore.py
underscore._group
def _group(self, obj, val, behavior): """ An internal function used for aggregate "group by" operations. """ ns = self.Namespace() ns.result = {} iterator = self._lookupIterator(val) def e(value, index, *args): key = iterator(value, index) behavio...
python
def _group(self, obj, val, behavior): """ An internal function used for aggregate "group by" operations. """ ns = self.Namespace() ns.result = {} iterator = self._lookupIterator(val) def e(value, index, *args): key = iterator(value, index) behavio...
[ "def", "_group", "(", "self", ",", "obj", ",", "val", ",", "behavior", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "result", "=", "{", "}", "iterator", "=", "self", ".", "_lookupIterator", "(", "val", ")", "def", "e", "(",...
An internal function used for aggregate "group by" operations.
[ "An", "internal", "function", "used", "for", "aggregate", "group", "by", "operations", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L395-L413
train
61,304
serkanyersen/underscore.py
src/underscore.py
underscore.groupBy
def groupBy(self, val): """ Groups the object's values by a criterion. Pass either a string attribute to group by, or a function that returns the criterion. """ def by(result, key, value): if key not in result: result[key] = [] result[key]...
python
def groupBy(self, val): """ Groups the object's values by a criterion. Pass either a string attribute to group by, or a function that returns the criterion. """ def by(result, key, value): if key not in result: result[key] = [] result[key]...
[ "def", "groupBy", "(", "self", ",", "val", ")", ":", "def", "by", "(", "result", ",", "key", ",", "value", ")", ":", "if", "key", "not", "in", "result", ":", "result", "[", "key", "]", "=", "[", "]", "result", "[", "key", "]", ".", "append", ...
Groups the object's values by a criterion. Pass either a string attribute to group by, or a function that returns the criterion.
[ "Groups", "the", "object", "s", "values", "by", "a", "criterion", ".", "Pass", "either", "a", "string", "attribute", "to", "group", "by", "or", "a", "function", "that", "returns", "the", "criterion", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L415-L428
train
61,305
serkanyersen/underscore.py
src/underscore.py
underscore.indexBy
def indexBy(self, val=None): """ Indexes the object's values by a criterion, similar to `groupBy`, but for when you know that your index values will be unique. """ if val is None: val = lambda *args: args[0] def by(result, key, value): result[key]...
python
def indexBy(self, val=None): """ Indexes the object's values by a criterion, similar to `groupBy`, but for when you know that your index values will be unique. """ if val is None: val = lambda *args: args[0] def by(result, key, value): result[key]...
[ "def", "indexBy", "(", "self", ",", "val", "=", "None", ")", ":", "if", "val", "is", "None", ":", "val", "=", "lambda", "*", "args", ":", "args", "[", "0", "]", "def", "by", "(", "result", ",", "key", ",", "value", ")", ":", "result", "[", "k...
Indexes the object's values by a criterion, similar to `groupBy`, but for when you know that your index values will be unique.
[ "Indexes", "the", "object", "s", "values", "by", "a", "criterion", "similar", "to", "groupBy", "but", "for", "when", "you", "know", "that", "your", "index", "values", "will", "be", "unique", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L430-L443
train
61,306
serkanyersen/underscore.py
src/underscore.py
underscore.countBy
def countBy(self, val): """ Counts instances of an object that group by a certain criterion. Pass either a string attribute to count by, or a function that returns the criterion. """ def by(result, key, value): if key not in result: result[key...
python
def countBy(self, val): """ Counts instances of an object that group by a certain criterion. Pass either a string attribute to count by, or a function that returns the criterion. """ def by(result, key, value): if key not in result: result[key...
[ "def", "countBy", "(", "self", ",", "val", ")", ":", "def", "by", "(", "result", ",", "key", ",", "value", ")", ":", "if", "key", "not", "in", "result", ":", "result", "[", "key", "]", "=", "0", "result", "[", "key", "]", "+=", "1", "res", "=...
Counts instances of an object that group by a certain criterion. Pass either a string attribute to count by, or a function that returns the criterion.
[ "Counts", "instances", "of", "an", "object", "that", "group", "by", "a", "certain", "criterion", ".", "Pass", "either", "a", "string", "attribute", "to", "count", "by", "or", "a", "function", "that", "returns", "the", "criterion", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L445-L459
train
61,307
serkanyersen/underscore.py
src/underscore.py
underscore.sortedIndex
def sortedIndex(self, obj, iterator=lambda x: x): """ Use a comparator function to figure out the smallest index at which an object should be inserted so as to maintain order. Uses binary search. """ array = self.obj value = iterator(obj) low = 0 h...
python
def sortedIndex(self, obj, iterator=lambda x: x): """ Use a comparator function to figure out the smallest index at which an object should be inserted so as to maintain order. Uses binary search. """ array = self.obj value = iterator(obj) low = 0 h...
[ "def", "sortedIndex", "(", "self", ",", "obj", ",", "iterator", "=", "lambda", "x", ":", "x", ")", ":", "array", "=", "self", ".", "obj", "value", "=", "iterator", "(", "obj", ")", "low", "=", "0", "high", "=", "len", "(", "array", ")", "while", ...
Use a comparator function to figure out the smallest index at which an object should be inserted so as to maintain order. Uses binary search.
[ "Use", "a", "comparator", "function", "to", "figure", "out", "the", "smallest", "index", "at", "which", "an", "object", "should", "be", "inserted", "so", "as", "to", "maintain", "order", ".", "Uses", "binary", "search", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L461-L477
train
61,308
serkanyersen/underscore.py
src/underscore.py
underscore.flatten
def flatten(self, shallow=None): """ Return a completely flattened version of an array. """ return self._wrap(self._flatten(self.obj, shallow))
python
def flatten(self, shallow=None): """ Return a completely flattened version of an array. """ return self._wrap(self._flatten(self.obj, shallow))
[ "def", "flatten", "(", "self", ",", "shallow", "=", "None", ")", ":", "return", "self", ".", "_wrap", "(", "self", ".", "_flatten", "(", "self", ".", "obj", ",", "shallow", ")", ")" ]
Return a completely flattened version of an array.
[ "Return", "a", "completely", "flattened", "version", "of", "an", "array", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L556-L559
train
61,309
serkanyersen/underscore.py
src/underscore.py
underscore.uniq
def uniq(self, isSorted=False, iterator=None): """ Produce a duplicate-free version of the array. If the array has already been sorted, you have the option of using a faster algorithm. Aliased as `unique`. """ ns = self.Namespace() ns.results = [] ns.array...
python
def uniq(self, isSorted=False, iterator=None): """ Produce a duplicate-free version of the array. If the array has already been sorted, you have the option of using a faster algorithm. Aliased as `unique`. """ ns = self.Namespace() ns.results = [] ns.array...
[ "def", "uniq", "(", "self", ",", "isSorted", "=", "False", ",", "iterator", "=", "None", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "results", "=", "[", "]", "ns", ".", "array", "=", "self", ".", "obj", "initial", "=", ...
Produce a duplicate-free version of the array. If the array has already been sorted, you have the option of using a faster algorithm. Aliased as `unique`.
[ "Produce", "a", "duplicate", "-", "free", "version", "of", "the", "array", ".", "If", "the", "array", "has", "already", "been", "sorted", "you", "have", "the", "option", "of", "using", "a", "faster", "algorithm", ".", "Aliased", "as", "unique", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L597-L619
train
61,310
serkanyersen/underscore.py
src/underscore.py
underscore.intersection
def intersection(self, *args): """ Produce an array that contains every item shared between all the passed-in arrays. """ if type(self.obj[0]) is int: a = self.obj else: a = tuple(self.obj[0]) setobj = set(a) for i, v in enumerate(a...
python
def intersection(self, *args): """ Produce an array that contains every item shared between all the passed-in arrays. """ if type(self.obj[0]) is int: a = self.obj else: a = tuple(self.obj[0]) setobj = set(a) for i, v in enumerate(a...
[ "def", "intersection", "(", "self", ",", "*", "args", ")", ":", "if", "type", "(", "self", ".", "obj", "[", "0", "]", ")", "is", "int", ":", "a", "=", "self", ".", "obj", "else", ":", "a", "=", "tuple", "(", "self", ".", "obj", "[", "0", "]...
Produce an array that contains every item shared between all the passed-in arrays.
[ "Produce", "an", "array", "that", "contains", "every", "item", "shared", "between", "all", "the", "passed", "-", "in", "arrays", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L639-L651
train
61,311
serkanyersen/underscore.py
src/underscore.py
underscore.difference
def difference(self, *args): """ Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain. """ setobj = set(self.obj) for i, v in enumerate(args): setobj = setobj - set(args[i]) r...
python
def difference(self, *args): """ Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain. """ setobj = set(self.obj) for i, v in enumerate(args): setobj = setobj - set(args[i]) r...
[ "def", "difference", "(", "self", ",", "*", "args", ")", ":", "setobj", "=", "set", "(", "self", ".", "obj", ")", "for", "i", ",", "v", "in", "enumerate", "(", "args", ")", ":", "setobj", "=", "setobj", "-", "set", "(", "args", "[", "i", "]", ...
Take the difference between one array and a number of other arrays. Only the elements present in just the first array will remain.
[ "Take", "the", "difference", "between", "one", "array", "and", "a", "number", "of", "other", "arrays", ".", "Only", "the", "elements", "present", "in", "just", "the", "first", "array", "will", "remain", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L653-L661
train
61,312
serkanyersen/underscore.py
src/underscore.py
underscore.indexOf
def indexOf(self, item, isSorted=False): """ Return the position of the first occurrence of an item in an array, or -1 if the item is not included in the array. """ array = self.obj ret = -1 if not (self._clean.isList() or self._clean.isTuple()): retu...
python
def indexOf(self, item, isSorted=False): """ Return the position of the first occurrence of an item in an array, or -1 if the item is not included in the array. """ array = self.obj ret = -1 if not (self._clean.isList() or self._clean.isTuple()): retu...
[ "def", "indexOf", "(", "self", ",", "item", ",", "isSorted", "=", "False", ")", ":", "array", "=", "self", ".", "obj", "ret", "=", "-", "1", "if", "not", "(", "self", ".", "_clean", ".", "isList", "(", ")", "or", "self", ".", "_clean", ".", "is...
Return the position of the first occurrence of an item in an array, or -1 if the item is not included in the array.
[ "Return", "the", "position", "of", "the", "first", "occurrence", "of", "an", "item", "in", "an", "array", "or", "-", "1", "if", "the", "item", "is", "not", "included", "in", "the", "array", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L695-L716
train
61,313
serkanyersen/underscore.py
src/underscore.py
underscore.lastIndexOf
def lastIndexOf(self, item): """ Return the position of the last occurrence of an item in an array, or -1 if the item is not included in the array. """ array = self.obj i = len(array) - 1 if not (self._clean.isList() or self._clean.isTuple()): return s...
python
def lastIndexOf(self, item): """ Return the position of the last occurrence of an item in an array, or -1 if the item is not included in the array. """ array = self.obj i = len(array) - 1 if not (self._clean.isList() or self._clean.isTuple()): return s...
[ "def", "lastIndexOf", "(", "self", ",", "item", ")", ":", "array", "=", "self", ".", "obj", "i", "=", "len", "(", "array", ")", "-", "1", "if", "not", "(", "self", ".", "_clean", ".", "isList", "(", ")", "or", "self", ".", "_clean", ".", "isTup...
Return the position of the last occurrence of an item in an array, or -1 if the item is not included in the array.
[ "Return", "the", "position", "of", "the", "last", "occurrence", "of", "an", "item", "in", "an", "array", "or", "-", "1", "if", "the", "item", "is", "not", "included", "in", "the", "array", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L718-L732
train
61,314
serkanyersen/underscore.py
src/underscore.py
underscore.range
def range(self, *args): """ Generate an integer Array containing an arithmetic progression. """ args = list(args) args.insert(0, self.obj) return self._wrap(range(*args))
python
def range(self, *args): """ Generate an integer Array containing an arithmetic progression. """ args = list(args) args.insert(0, self.obj) return self._wrap(range(*args))
[ "def", "range", "(", "self", ",", "*", "args", ")", ":", "args", "=", "list", "(", "args", ")", "args", ".", "insert", "(", "0", ",", "self", ".", "obj", ")", "return", "self", ".", "_wrap", "(", "range", "(", "*", "args", ")", ")" ]
Generate an integer Array containing an arithmetic progression.
[ "Generate", "an", "integer", "Array", "containing", "an", "arithmetic", "progression", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L734-L739
train
61,315
serkanyersen/underscore.py
src/underscore.py
underscore.partial
def partial(self, *args): """ Partially apply a function by creating a version that has had some of its arguments pre-filled, without changing its dynamic `this` context. """ def part(*args2): args3 = args + args2 return self.obj(*args3) return se...
python
def partial(self, *args): """ Partially apply a function by creating a version that has had some of its arguments pre-filled, without changing its dynamic `this` context. """ def part(*args2): args3 = args + args2 return self.obj(*args3) return se...
[ "def", "partial", "(", "self", ",", "*", "args", ")", ":", "def", "part", "(", "*", "args2", ")", ":", "args3", "=", "args", "+", "args2", "return", "self", ".", "obj", "(", "*", "args3", ")", "return", "self", ".", "_wrap", "(", "part", ")" ]
Partially apply a function by creating a version that has had some of its arguments pre-filled, without changing its dynamic `this` context.
[ "Partially", "apply", "a", "function", "by", "creating", "a", "version", "that", "has", "had", "some", "of", "its", "arguments", "pre", "-", "filled", "without", "changing", "its", "dynamic", "this", "context", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L754-L763
train
61,316
serkanyersen/underscore.py
src/underscore.py
underscore.memoize
def memoize(self, hasher=None): """ Memoize an expensive function by storing its results. """ ns = self.Namespace() ns.memo = {} if hasher is None: hasher = lambda x: x def memoized(*args, **kwargs): key = hasher(*args) if key not in n...
python
def memoize(self, hasher=None): """ Memoize an expensive function by storing its results. """ ns = self.Namespace() ns.memo = {} if hasher is None: hasher = lambda x: x def memoized(*args, **kwargs): key = hasher(*args) if key not in n...
[ "def", "memoize", "(", "self", ",", "hasher", "=", "None", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "memo", "=", "{", "}", "if", "hasher", "is", "None", ":", "hasher", "=", "lambda", "x", ":", "x", "def", "memoized", ...
Memoize an expensive function by storing its results.
[ "Memoize", "an", "expensive", "function", "by", "storing", "its", "results", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L773-L787
train
61,317
serkanyersen/underscore.py
src/underscore.py
underscore.delay
def delay(self, wait, *args): """ Delays a function for the given number of milliseconds, and then calls it with the arguments supplied. """ def call_it(): self.obj(*args) t = Timer((float(wait) / float(1000)), call_it) t.start() return self....
python
def delay(self, wait, *args): """ Delays a function for the given number of milliseconds, and then calls it with the arguments supplied. """ def call_it(): self.obj(*args) t = Timer((float(wait) / float(1000)), call_it) t.start() return self....
[ "def", "delay", "(", "self", ",", "wait", ",", "*", "args", ")", ":", "def", "call_it", "(", ")", ":", "self", ".", "obj", "(", "*", "args", ")", "t", "=", "Timer", "(", "(", "float", "(", "wait", ")", "/", "float", "(", "1000", ")", ")", "...
Delays a function for the given number of milliseconds, and then calls it with the arguments supplied.
[ "Delays", "a", "function", "for", "the", "given", "number", "of", "milliseconds", "and", "then", "calls", "it", "with", "the", "arguments", "supplied", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L789-L800
train
61,318
serkanyersen/underscore.py
src/underscore.py
underscore.throttle
def throttle(self, wait): """ Returns a function, that, when invoked, will only be triggered at most once during a given window of time. """ ns = self.Namespace() ns.timeout = None ns.throttling = None ns.more = None ns.result = None def d...
python
def throttle(self, wait): """ Returns a function, that, when invoked, will only be triggered at most once during a given window of time. """ ns = self.Namespace() ns.timeout = None ns.throttling = None ns.more = None ns.result = None def d...
[ "def", "throttle", "(", "self", ",", "wait", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "timeout", "=", "None", "ns", ".", "throttling", "=", "None", "ns", ".", "more", "=", "None", "ns", ".", "result", "=", "None", "def"...
Returns a function, that, when invoked, will only be triggered at most once during a given window of time.
[ "Returns", "a", "function", "that", "when", "invoked", "will", "only", "be", "triggered", "at", "most", "once", "during", "a", "given", "window", "of", "time", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L810-L845
train
61,319
serkanyersen/underscore.py
src/underscore.py
underscore.debounce
def debounce(self, wait, immediate=None): """ Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. If `immediate` is passed, trigger the function on the leading edge, in...
python
def debounce(self, wait, immediate=None): """ Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. If `immediate` is passed, trigger the function on the leading edge, in...
[ "def", "debounce", "(", "self", ",", "wait", ",", "immediate", "=", "None", ")", ":", "wait", "=", "(", "float", "(", "wait", ")", "/", "float", "(", "1000", ")", ")", "def", "debounced", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "de...
Returns a function, that, as long as it continues to be invoked, will not be triggered. The function will be called after it stops being called for N milliseconds. If `immediate` is passed, trigger the function on the leading edge, instead of the trailing.
[ "Returns", "a", "function", "that", "as", "long", "as", "it", "continues", "to", "be", "invoked", "will", "not", "be", "triggered", ".", "The", "function", "will", "be", "called", "after", "it", "stops", "being", "called", "for", "N", "milliseconds", ".", ...
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L848-L866
train
61,320
serkanyersen/underscore.py
src/underscore.py
underscore.once
def once(self): """ Returns a function that will be executed at most one time, no matter how often you call it. Useful for lazy initialization. """ ns = self.Namespace() ns.memo = None ns.run = False def work_once(*args, **kwargs): if ns.run i...
python
def once(self): """ Returns a function that will be executed at most one time, no matter how often you call it. Useful for lazy initialization. """ ns = self.Namespace() ns.memo = None ns.run = False def work_once(*args, **kwargs): if ns.run i...
[ "def", "once", "(", "self", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "memo", "=", "None", "ns", ".", "run", "=", "False", "def", "work_once", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "ns", ".", "ru...
Returns a function that will be executed at most one time, no matter how often you call it. Useful for lazy initialization.
[ "Returns", "a", "function", "that", "will", "be", "executed", "at", "most", "one", "time", "no", "matter", "how", "often", "you", "call", "it", ".", "Useful", "for", "lazy", "initialization", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L868-L883
train
61,321
serkanyersen/underscore.py
src/underscore.py
underscore.wrap
def wrap(self, wrapper): """ Returns the first function passed as an argument to the second, allowing you to adjust arguments, run code before and after, and conditionally execute the original function. """ def wrapped(*args, **kwargs): if kwargs: ...
python
def wrap(self, wrapper): """ Returns the first function passed as an argument to the second, allowing you to adjust arguments, run code before and after, and conditionally execute the original function. """ def wrapped(*args, **kwargs): if kwargs: ...
[ "def", "wrap", "(", "self", ",", "wrapper", ")", ":", "def", "wrapped", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "kwargs", "[", "\"object\"", "]", "=", "self", ".", "obj", "else", ":", "args", "=", "list", "(", ...
Returns the first function passed as an argument to the second, allowing you to adjust arguments, run code before and after, and conditionally execute the original function.
[ "Returns", "the", "first", "function", "passed", "as", "an", "argument", "to", "the", "second", "allowing", "you", "to", "adjust", "arguments", "run", "code", "before", "and", "after", "and", "conditionally", "execute", "the", "original", "function", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L885-L901
train
61,322
serkanyersen/underscore.py
src/underscore.py
underscore.compose
def compose(self, *args): """ Returns a function that is the composition of a list of functions, each consuming the return value of the function that follows. """ args = list(args) def composed(*ar, **kwargs): lastRet = self.obj(*ar, **kwargs) for...
python
def compose(self, *args): """ Returns a function that is the composition of a list of functions, each consuming the return value of the function that follows. """ args = list(args) def composed(*ar, **kwargs): lastRet = self.obj(*ar, **kwargs) for...
[ "def", "compose", "(", "self", ",", "*", "args", ")", ":", "args", "=", "list", "(", "args", ")", "def", "composed", "(", "*", "ar", ",", "*", "*", "kwargs", ")", ":", "lastRet", "=", "self", ".", "obj", "(", "*", "ar", ",", "*", "*", "kwargs...
Returns a function that is the composition of a list of functions, each consuming the return value of the function that follows.
[ "Returns", "a", "function", "that", "is", "the", "composition", "of", "a", "list", "of", "functions", "each", "consuming", "the", "return", "value", "of", "the", "function", "that", "follows", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L903-L917
train
61,323
serkanyersen/underscore.py
src/underscore.py
underscore.after
def after(self, func): """ Returns a function that will only be executed after being called N times. """ ns = self.Namespace() ns.times = self.obj if ns.times <= 0: return func() def work_after(*args): if ns.times <= 1: ...
python
def after(self, func): """ Returns a function that will only be executed after being called N times. """ ns = self.Namespace() ns.times = self.obj if ns.times <= 0: return func() def work_after(*args): if ns.times <= 1: ...
[ "def", "after", "(", "self", ",", "func", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "times", "=", "self", ".", "obj", "if", "ns", ".", "times", "<=", "0", ":", "return", "func", "(", ")", "def", "work_after", "(", "*",...
Returns a function that will only be executed after being called N times.
[ "Returns", "a", "function", "that", "will", "only", "be", "executed", "after", "being", "called", "N", "times", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L919-L935
train
61,324
serkanyersen/underscore.py
src/underscore.py
underscore.invert
def invert(self): """ Invert the keys and values of an object. The values must be serializable. """ keys = self._clean.keys() inverted = {} for key in keys: inverted[self.obj[key]] = key return self._wrap(inverted)
python
def invert(self): """ Invert the keys and values of an object. The values must be serializable. """ keys = self._clean.keys() inverted = {} for key in keys: inverted[self.obj[key]] = key return self._wrap(inverted)
[ "def", "invert", "(", "self", ")", ":", "keys", "=", "self", ".", "_clean", ".", "keys", "(", ")", "inverted", "=", "{", "}", "for", "key", "in", "keys", ":", "inverted", "[", "self", ".", "obj", "[", "key", "]", "]", "=", "key", "return", "sel...
Invert the keys and values of an object. The values must be serializable.
[ "Invert", "the", "keys", "and", "values", "of", "an", "object", ".", "The", "values", "must", "be", "serializable", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L961-L971
train
61,325
serkanyersen/underscore.py
src/underscore.py
underscore.functions
def functions(self): """ Return a sorted list of the function names available on the object. """ names = [] for i, k in enumerate(self.obj): if _(self.obj[k]).isCallable(): names.append(k) return self._wrap(sorted(names))
python
def functions(self): """ Return a sorted list of the function names available on the object. """ names = [] for i, k in enumerate(self.obj): if _(self.obj[k]).isCallable(): names.append(k) return self._wrap(sorted(names))
[ "def", "functions", "(", "self", ")", ":", "names", "=", "[", "]", "for", "i", ",", "k", "in", "enumerate", "(", "self", ".", "obj", ")", ":", "if", "_", "(", "self", ".", "obj", "[", "k", "]", ")", ".", "isCallable", "(", ")", ":", "names", ...
Return a sorted list of the function names available on the object.
[ "Return", "a", "sorted", "list", "of", "the", "function", "names", "available", "on", "the", "object", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L973-L982
train
61,326
serkanyersen/underscore.py
src/underscore.py
underscore.pick
def pick(self, *args): """ Return a copy of the object only containing the whitelisted properties. """ ns = self.Namespace() ns.result = {} def by(key, *args): if key in self.obj: ns.result[key] = self.obj[key] _.each(self._fl...
python
def pick(self, *args): """ Return a copy of the object only containing the whitelisted properties. """ ns = self.Namespace() ns.result = {} def by(key, *args): if key in self.obj: ns.result[key] = self.obj[key] _.each(self._fl...
[ "def", "pick", "(", "self", ",", "*", "args", ")", ":", "ns", "=", "self", ".", "Namespace", "(", ")", "ns", ".", "result", "=", "{", "}", "def", "by", "(", "key", ",", "*", "args", ")", ":", "if", "key", "in", "self", ".", "obj", ":", "ns"...
Return a copy of the object only containing the whitelisted properties.
[ "Return", "a", "copy", "of", "the", "object", "only", "containing", "the", "whitelisted", "properties", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L996-L1009
train
61,327
serkanyersen/underscore.py
src/underscore.py
underscore.defaults
def defaults(self, *args): """ Fill in a given object with default properties. """ ns = self.Namespace ns.obj = self.obj def by(source, *ar): for i, prop in enumerate(source): if prop not in ns.obj: ns.obj[prop] = source[prop] ...
python
def defaults(self, *args): """ Fill in a given object with default properties. """ ns = self.Namespace ns.obj = self.obj def by(source, *ar): for i, prop in enumerate(source): if prop not in ns.obj: ns.obj[prop] = source[prop] ...
[ "def", "defaults", "(", "self", ",", "*", "args", ")", ":", "ns", "=", "self", ".", "Namespace", "ns", ".", "obj", "=", "self", ".", "obj", "def", "by", "(", "source", ",", "*", "ar", ")", ":", "for", "i", ",", "prop", "in", "enumerate", "(", ...
Fill in a given object with default properties.
[ "Fill", "in", "a", "given", "object", "with", "default", "properties", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1020-L1033
train
61,328
serkanyersen/underscore.py
src/underscore.py
underscore.tap
def tap(self, interceptor): """ Invokes interceptor with the obj, and then returns obj. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. """ interceptor(self.obj) return se...
python
def tap(self, interceptor): """ Invokes interceptor with the obj, and then returns obj. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain. """ interceptor(self.obj) return se...
[ "def", "tap", "(", "self", ",", "interceptor", ")", ":", "interceptor", "(", "self", ".", "obj", ")", "return", "self", ".", "_wrap", "(", "self", ".", "obj", ")" ]
Invokes interceptor with the obj, and then returns obj. The primary purpose of this method is to "tap into" a method chain, in order to perform operations on intermediate results within the chain.
[ "Invokes", "interceptor", "with", "the", "obj", "and", "then", "returns", "obj", ".", "The", "primary", "purpose", "of", "this", "method", "is", "to", "tap", "into", "a", "method", "chain", "in", "order", "to", "perform", "operations", "on", "intermediate", ...
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1041-L1048
train
61,329
serkanyersen/underscore.py
src/underscore.py
underscore.isEmpty
def isEmpty(self): """ Is a given array, string, or object empty? An "empty" object has no enumerable own-properties. """ if self.obj is None: return True if self._clean.isString(): ret = self.obj.strip() is "" elif self._clean.isDict(): ...
python
def isEmpty(self): """ Is a given array, string, or object empty? An "empty" object has no enumerable own-properties. """ if self.obj is None: return True if self._clean.isString(): ret = self.obj.strip() is "" elif self._clean.isDict(): ...
[ "def", "isEmpty", "(", "self", ")", ":", "if", "self", ".", "obj", "is", "None", ":", "return", "True", "if", "self", ".", "_clean", ".", "isString", "(", ")", ":", "ret", "=", "self", ".", "obj", ".", "strip", "(", ")", "is", "\"\"", "elif", "...
Is a given array, string, or object empty? An "empty" object has no enumerable own-properties.
[ "Is", "a", "given", "array", "string", "or", "object", "empty?", "An", "empty", "object", "has", "no", "enumerable", "own", "-", "properties", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1055-L1068
train
61,330
serkanyersen/underscore.py
src/underscore.py
underscore.isFile
def isFile(self): """ Check if the given object is a file """ try: filetype = file except NameError: filetype = io.IOBase return self._wrap(type(self.obj) is filetype)
python
def isFile(self): """ Check if the given object is a file """ try: filetype = file except NameError: filetype = io.IOBase return self._wrap(type(self.obj) is filetype)
[ "def", "isFile", "(", "self", ")", ":", "try", ":", "filetype", "=", "file", "except", "NameError", ":", "filetype", "=", "io", ".", "IOBase", "return", "self", ".", "_wrap", "(", "type", "(", "self", ".", "obj", ")", "is", "filetype", ")" ]
Check if the given object is a file
[ "Check", "if", "the", "given", "object", "is", "a", "file" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1202-L1210
train
61,331
serkanyersen/underscore.py
src/underscore.py
underscore.join
def join(self, glue=" "): """ Javascript's join implementation """ j = glue.join([str(x) for x in self.obj]) return self._wrap(j)
python
def join(self, glue=" "): """ Javascript's join implementation """ j = glue.join([str(x) for x in self.obj]) return self._wrap(j)
[ "def", "join", "(", "self", ",", "glue", "=", "\" \"", ")", ":", "j", "=", "glue", ".", "join", "(", "[", "str", "(", "x", ")", "for", "x", "in", "self", ".", "obj", "]", ")", "return", "self", ".", "_wrap", "(", "j", ")" ]
Javascript's join implementation
[ "Javascript", "s", "join", "implementation" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1275-L1279
train
61,332
serkanyersen/underscore.py
src/underscore.py
underscore.result
def result(self, property, *args): """ If the value of the named property is a function then invoke it; otherwise, return it. """ if self.obj is None: return self._wrap(self.obj) if(hasattr(self.obj, property)): value = getattr(self.obj, property)...
python
def result(self, property, *args): """ If the value of the named property is a function then invoke it; otherwise, return it. """ if self.obj is None: return self._wrap(self.obj) if(hasattr(self.obj, property)): value = getattr(self.obj, property)...
[ "def", "result", "(", "self", ",", "property", ",", "*", "args", ")", ":", "if", "self", ".", "obj", "is", "None", ":", "return", "self", ".", "_wrap", "(", "self", ".", "obj", ")", "if", "(", "hasattr", "(", "self", ".", "obj", ",", "property", ...
If the value of the named property is a function then invoke it; otherwise, return it.
[ "If", "the", "value", "of", "the", "named", "property", "is", "a", "function", "then", "invoke", "it", ";", "otherwise", "return", "it", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1339-L1353
train
61,333
serkanyersen/underscore.py
src/underscore.py
underscore.mixin
def mixin(self): """ Add your own custom functions to the Underscore object, ensuring that they're correctly added to the OOP wrapper as well. """ methods = self.obj for i, k in enumerate(methods): setattr(underscore, k, methods[k]) self.makeStatic() ...
python
def mixin(self): """ Add your own custom functions to the Underscore object, ensuring that they're correctly added to the OOP wrapper as well. """ methods = self.obj for i, k in enumerate(methods): setattr(underscore, k, methods[k]) self.makeStatic() ...
[ "def", "mixin", "(", "self", ")", ":", "methods", "=", "self", ".", "obj", "for", "i", ",", "k", "in", "enumerate", "(", "methods", ")", ":", "setattr", "(", "underscore", ",", "k", ",", "methods", "[", "k", "]", ")", "self", ".", "makeStatic", "...
Add your own custom functions to the Underscore object, ensuring that they're correctly added to the OOP wrapper as well.
[ "Add", "your", "own", "custom", "functions", "to", "the", "Underscore", "object", "ensuring", "that", "they", "re", "correctly", "added", "to", "the", "OOP", "wrapper", "as", "well", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1355-L1365
train
61,334
serkanyersen/underscore.py
src/underscore.py
underscore.escape
def escape(self): """ Escape a string for HTML interpolation. """ # & must be handled first self.obj = self.obj.replace("&", self._html_escape_table["&"]) for i, k in enumerate(self._html_escape_table): v = self._html_escape_table[k] if k is not "&": ...
python
def escape(self): """ Escape a string for HTML interpolation. """ # & must be handled first self.obj = self.obj.replace("&", self._html_escape_table["&"]) for i, k in enumerate(self._html_escape_table): v = self._html_escape_table[k] if k is not "&": ...
[ "def", "escape", "(", "self", ")", ":", "# & must be handled first", "self", ".", "obj", "=", "self", ".", "obj", ".", "replace", "(", "\"&\"", ",", "self", ".", "_html_escape_table", "[", "\"&\"", "]", ")", "for", "i", ",", "k", "in", "enumerate", "("...
Escape a string for HTML interpolation.
[ "Escape", "a", "string", "for", "HTML", "interpolation", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1387-L1398
train
61,335
serkanyersen/underscore.py
src/underscore.py
underscore.unescape
def unescape(self): """ Within an interpolation, evaluation, or escaping, remove HTML escaping that had been previously added. """ for i, k in enumerate(self._html_escape_table): v = self._html_escape_table[k] self.obj = self.obj.replace(v, k) ret...
python
def unescape(self): """ Within an interpolation, evaluation, or escaping, remove HTML escaping that had been previously added. """ for i, k in enumerate(self._html_escape_table): v = self._html_escape_table[k] self.obj = self.obj.replace(v, k) ret...
[ "def", "unescape", "(", "self", ")", ":", "for", "i", ",", "k", "in", "enumerate", "(", "self", ".", "_html_escape_table", ")", ":", "v", "=", "self", ".", "_html_escape_table", "[", "k", "]", "self", ".", "obj", "=", "self", ".", "obj", ".", "repl...
Within an interpolation, evaluation, or escaping, remove HTML escaping that had been previously added.
[ "Within", "an", "interpolation", "evaluation", "or", "escaping", "remove", "HTML", "escaping", "that", "had", "been", "previously", "added", "." ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1400-L1409
train
61,336
serkanyersen/underscore.py
src/underscore.py
underscore.value
def value(self): """ returns the object instead of instance """ if self._wrapped is not self.Null: return self._wrapped else: return self.obj
python
def value(self): """ returns the object instead of instance """ if self._wrapped is not self.Null: return self._wrapped else: return self.obj
[ "def", "value", "(", "self", ")", ":", "if", "self", ".", "_wrapped", "is", "not", "self", ".", "Null", ":", "return", "self", ".", "_wrapped", "else", ":", "return", "self", ".", "obj" ]
returns the object instead of instance
[ "returns", "the", "object", "instead", "of", "instance" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1583-L1589
train
61,337
serkanyersen/underscore.py
src/underscore.py
underscore.makeStatic
def makeStatic(): """ Provide static access to underscore class """ p = lambda value: inspect.ismethod(value) or inspect.isfunction(value) for eachMethod in inspect.getmembers(underscore, predicate=p): m = eachMethod[0] ...
python
def makeStatic(): """ Provide static access to underscore class """ p = lambda value: inspect.ismethod(value) or inspect.isfunction(value) for eachMethod in inspect.getmembers(underscore, predicate=p): m = eachMethod[0] ...
[ "def", "makeStatic", "(", ")", ":", "p", "=", "lambda", "value", ":", "inspect", ".", "ismethod", "(", "value", ")", "or", "inspect", ".", "isfunction", "(", "value", ")", "for", "eachMethod", "in", "inspect", ".", "getmembers", "(", "underscore", ",", ...
Provide static access to underscore class
[ "Provide", "static", "access", "to", "underscore", "class" ]
07c25c3f0f789536e4ad47aa315faccc0da9602f
https://github.com/serkanyersen/underscore.py/blob/07c25c3f0f789536e4ad47aa315faccc0da9602f/src/underscore.py#L1592-L1614
train
61,338
ckan/ckan-service-provider
ckanserviceprovider/web.py
init
def init(): """Initialise and configure the app, database, scheduler, etc. This should be called once at application startup or at tests startup (and not e.g. called once for each test case). """ global _users, _names _configure_app(app) _users, _names = _init_login_manager(app) _confi...
python
def init(): """Initialise and configure the app, database, scheduler, etc. This should be called once at application startup or at tests startup (and not e.g. called once for each test case). """ global _users, _names _configure_app(app) _users, _names = _init_login_manager(app) _confi...
[ "def", "init", "(", ")", ":", "global", "_users", ",", "_names", "_configure_app", "(", "app", ")", "_users", ",", "_names", "=", "_init_login_manager", "(", "app", ")", "_configure_logger", "(", ")", "init_scheduler", "(", "app", ".", "config", ".", "get"...
Initialise and configure the app, database, scheduler, etc. This should be called once at application startup or at tests startup (and not e.g. called once for each test case).
[ "Initialise", "and", "configure", "the", "app", "database", "scheduler", "etc", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L40-L52
train
61,339
ckan/ckan-service-provider
ckanserviceprovider/web.py
_configure_app
def _configure_app(app_): """Configure the Flask WSGI app.""" app_.url_map.strict_slashes = False app_.config.from_object(default_settings) app_.config.from_envvar('JOB_CONFIG', silent=True) db_url = app_.config.get('SQLALCHEMY_DATABASE_URI') if not db_url: raise Exception('No db_url in ...
python
def _configure_app(app_): """Configure the Flask WSGI app.""" app_.url_map.strict_slashes = False app_.config.from_object(default_settings) app_.config.from_envvar('JOB_CONFIG', silent=True) db_url = app_.config.get('SQLALCHEMY_DATABASE_URI') if not db_url: raise Exception('No db_url in ...
[ "def", "_configure_app", "(", "app_", ")", ":", "app_", ".", "url_map", ".", "strict_slashes", "=", "False", "app_", ".", "config", ".", "from_object", "(", "default_settings", ")", "app_", ".", "config", ".", "from_envvar", "(", "'JOB_CONFIG'", ",", "silent...
Configure the Flask WSGI app.
[ "Configure", "the", "Flask", "WSGI", "app", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L55-L71
train
61,340
ckan/ckan-service-provider
ckanserviceprovider/web.py
_init_login_manager
def _init_login_manager(app_): """Initialise and configure the login manager.""" login_manager = flogin.LoginManager() login_manager.setup_app(app_) login_manager.anonymous_user = Anonymous login_manager.login_view = "login" users = {app_.config['USERNAME']: User('Admin', 0)} names = dict((...
python
def _init_login_manager(app_): """Initialise and configure the login manager.""" login_manager = flogin.LoginManager() login_manager.setup_app(app_) login_manager.anonymous_user = Anonymous login_manager.login_view = "login" users = {app_.config['USERNAME']: User('Admin', 0)} names = dict((...
[ "def", "_init_login_manager", "(", "app_", ")", ":", "login_manager", "=", "flogin", ".", "LoginManager", "(", ")", "login_manager", ".", "setup_app", "(", "app_", ")", "login_manager", ".", "anonymous_user", "=", "Anonymous", "login_manager", ".", "login_view", ...
Initialise and configure the login manager.
[ "Initialise", "and", "configure", "the", "login", "manager", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L74-L90
train
61,341
ckan/ckan-service-provider
ckanserviceprovider/web.py
_configure_logger_for_production
def _configure_logger_for_production(logger): """Configure the given logger for production deployment. Logs to stderr and file, and emails errors to admins. """ stderr_handler = logging.StreamHandler(sys.stderr) stderr_handler.setLevel(logging.INFO) if 'STDERR' in app.config: logger.ad...
python
def _configure_logger_for_production(logger): """Configure the given logger for production deployment. Logs to stderr and file, and emails errors to admins. """ stderr_handler = logging.StreamHandler(sys.stderr) stderr_handler.setLevel(logging.INFO) if 'STDERR' in app.config: logger.ad...
[ "def", "_configure_logger_for_production", "(", "logger", ")", ":", "stderr_handler", "=", "logging", ".", "StreamHandler", "(", "sys", ".", "stderr", ")", "stderr_handler", ".", "setLevel", "(", "logging", ".", "INFO", ")", "if", "'STDERR'", "in", "app", ".",...
Configure the given logger for production deployment. Logs to stderr and file, and emails errors to admins.
[ "Configure", "the", "given", "logger", "for", "production", "deployment", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L93-L117
train
61,342
ckan/ckan-service-provider
ckanserviceprovider/web.py
_configure_logger
def _configure_logger(): """Configure the logging module.""" if not app.debug: _configure_logger_for_production(logging.getLogger()) elif not app.testing: _configure_logger_for_debugging(logging.getLogger())
python
def _configure_logger(): """Configure the logging module.""" if not app.debug: _configure_logger_for_production(logging.getLogger()) elif not app.testing: _configure_logger_for_debugging(logging.getLogger())
[ "def", "_configure_logger", "(", ")", ":", "if", "not", "app", ".", "debug", ":", "_configure_logger_for_production", "(", "logging", ".", "getLogger", "(", ")", ")", "elif", "not", "app", ".", "testing", ":", "_configure_logger_for_debugging", "(", "logging", ...
Configure the logging module.
[ "Configure", "the", "logging", "module", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L125-L130
train
61,343
ckan/ckan-service-provider
ckanserviceprovider/web.py
init_scheduler
def init_scheduler(db_uri): """Initialise and configure the scheduler.""" global scheduler scheduler = apscheduler.Scheduler() scheduler.misfire_grace_time = 3600 scheduler.add_jobstore( sqlalchemy_store.SQLAlchemyJobStore(url=db_uri), 'default') scheduler.add_listener( job_liste...
python
def init_scheduler(db_uri): """Initialise and configure the scheduler.""" global scheduler scheduler = apscheduler.Scheduler() scheduler.misfire_grace_time = 3600 scheduler.add_jobstore( sqlalchemy_store.SQLAlchemyJobStore(url=db_uri), 'default') scheduler.add_listener( job_liste...
[ "def", "init_scheduler", "(", "db_uri", ")", ":", "global", "scheduler", "scheduler", "=", "apscheduler", ".", "Scheduler", "(", ")", "scheduler", ".", "misfire_grace_time", "=", "3600", "scheduler", ".", "add_jobstore", "(", "sqlalchemy_store", ".", "SQLAlchemyJo...
Initialise and configure the scheduler.
[ "Initialise", "and", "configure", "the", "scheduler", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L133-L144
train
61,344
ckan/ckan-service-provider
ckanserviceprovider/web.py
job_listener
def job_listener(event): '''Listens to completed job''' job_id = event.job.args[0] if event.code == events.EVENT_JOB_MISSED: db.mark_job_as_missed(job_id) elif event.exception: if isinstance(event.exception, util.JobError): error_object = event.exception.as_dict() el...
python
def job_listener(event): '''Listens to completed job''' job_id = event.job.args[0] if event.code == events.EVENT_JOB_MISSED: db.mark_job_as_missed(job_id) elif event.exception: if isinstance(event.exception, util.JobError): error_object = event.exception.as_dict() el...
[ "def", "job_listener", "(", "event", ")", ":", "job_id", "=", "event", ".", "job", ".", "args", "[", "0", "]", "if", "event", ".", "code", "==", "events", ".", "EVENT_JOB_MISSED", ":", "db", ".", "mark_job_as_missed", "(", "job_id", ")", "elif", "event...
Listens to completed job
[ "Listens", "to", "completed", "job" ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L179-L203
train
61,345
ckan/ckan-service-provider
ckanserviceprovider/web.py
status
def status(): '''Show version, available job types and name of service. **Results:** :rtype: A dictionary with the following keys :param version: Version of the service provider :type version: float :param job_types: Available job types :type job_types: list of strings :param name: Nam...
python
def status(): '''Show version, available job types and name of service. **Results:** :rtype: A dictionary with the following keys :param version: Version of the service provider :type version: float :param job_types: Available job types :type job_types: list of strings :param name: Nam...
[ "def", "status", "(", ")", ":", "job_types", "=", "async_types", ".", "keys", "(", ")", "+", "sync_types", ".", "keys", "(", ")", "counts", "=", "{", "}", "for", "job_status", "in", "job_statuses", ":", "counts", "[", "job_status", "]", "=", "db", "....
Show version, available job types and name of service. **Results:** :rtype: A dictionary with the following keys :param version: Version of the service provider :type version: float :param job_types: Available job types :type job_types: list of strings :param name: Name of the service ...
[ "Show", "version", "available", "job", "types", "and", "name", "of", "service", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L224-L253
train
61,346
ckan/ckan-service-provider
ckanserviceprovider/web.py
login
def login(): '''Log in as administrator You can use wither basic auth or form based login (via POST). :param username: The administrator's username :type username: string :param password: The administrator's password :type password: string ''' username = None password = None ne...
python
def login(): '''Log in as administrator You can use wither basic auth or form based login (via POST). :param username: The administrator's username :type username: string :param password: The administrator's password :type password: string ''' username = None password = None ne...
[ "def", "login", "(", ")", ":", "username", "=", "None", "password", "=", "None", "next", "=", "flask", ".", "request", ".", "args", ".", "get", "(", "'next'", ")", "auth", "=", "flask", ".", "request", ".", "authorization", "if", "flask", ".", "reque...
Log in as administrator You can use wither basic auth or form based login (via POST). :param username: The administrator's username :type username: string :param password: The administrator's password :type password: string
[ "Log", "in", "as", "administrator" ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L265-L307
train
61,347
ckan/ckan-service-provider
ckanserviceprovider/web.py
user
def user(): '''Show information about the current user :rtype: A dictionary with the following keys :param id: User id :type id: int :param name: User name :type name: string :param is_active: Whether the user is currently active :type is_active: bool :param is_anonymous: The anonym...
python
def user(): '''Show information about the current user :rtype: A dictionary with the following keys :param id: User id :type id: int :param name: User name :type name: string :param is_active: Whether the user is currently active :type is_active: bool :param is_anonymous: The anonym...
[ "def", "user", "(", ")", ":", "user", "=", "flogin", ".", "current_user", "return", "flask", ".", "jsonify", "(", "{", "'id'", ":", "user", ".", "get_id", "(", ")", ",", "'name'", ":", "user", ".", "name", ",", "'is_active'", ":", "user", ".", "is_...
Show information about the current user :rtype: A dictionary with the following keys :param id: User id :type id: int :param name: User name :type name: string :param is_active: Whether the user is currently active :type is_active: bool :param is_anonymous: The anonymous user is the def...
[ "Show", "information", "about", "the", "current", "user" ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L311-L331
train
61,348
ckan/ckan-service-provider
ckanserviceprovider/web.py
logout
def logout(): """ Log out the active user """ flogin.logout_user() next = flask.request.args.get('next') return flask.redirect(next or flask.url_for("user"))
python
def logout(): """ Log out the active user """ flogin.logout_user() next = flask.request.args.get('next') return flask.redirect(next or flask.url_for("user"))
[ "def", "logout", "(", ")", ":", "flogin", ".", "logout_user", "(", ")", "next", "=", "flask", ".", "request", ".", "args", ".", "get", "(", "'next'", ")", "return", "flask", ".", "redirect", "(", "next", "or", "flask", ".", "url_for", "(", "\"user\""...
Log out the active user
[ "Log", "out", "the", "active", "user" ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L335-L340
train
61,349
ckan/ckan-service-provider
ckanserviceprovider/web.py
job_list
def job_list(): '''List all jobs. :param _limit: maximum number of jobs to show (default 100) :type _limit: int :param _offset: how many jobs to skip before showin the first one (default 0) :type _offset: int :param _status: filter jobs by status (complete, error) :type _status: string ...
python
def job_list(): '''List all jobs. :param _limit: maximum number of jobs to show (default 100) :type _limit: int :param _offset: how many jobs to skip before showin the first one (default 0) :type _offset: int :param _status: filter jobs by status (complete, error) :type _status: string ...
[ "def", "job_list", "(", ")", ":", "args", "=", "dict", "(", "(", "key", ",", "value", ")", "for", "key", ",", "value", "in", "flask", ".", "request", ".", "args", ".", "items", "(", ")", ")", "limit", "=", "args", ".", "pop", "(", "'_limit'", "...
List all jobs. :param _limit: maximum number of jobs to show (default 100) :type _limit: int :param _offset: how many jobs to skip before showin the first one (default 0) :type _offset: int :param _status: filter jobs by status (complete, error) :type _status: string Also, you can filter t...
[ "List", "all", "jobs", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L344-L397
train
61,350
ckan/ckan-service-provider
ckanserviceprovider/web.py
job_status
def job_status(job_id, show_job_key=False, ignore_auth=False): '''Show a specific job. **Results:** :rtype: A dictionary with the following keys :param status: Status of job (complete, error) :type status: string :param sent_data: Input data for job :type sent_data: json encodable data ...
python
def job_status(job_id, show_job_key=False, ignore_auth=False): '''Show a specific job. **Results:** :rtype: A dictionary with the following keys :param status: Status of job (complete, error) :type status: string :param sent_data: Input data for job :type sent_data: json encodable data ...
[ "def", "job_status", "(", "job_id", ",", "show_job_key", "=", "False", ",", "ignore_auth", "=", "False", ")", ":", "job_dict", "=", "db", ".", "get_job", "(", "job_id", ")", "if", "not", "job_dict", ":", "return", "json", ".", "dumps", "(", "{", "'erro...
Show a specific job. **Results:** :rtype: A dictionary with the following keys :param status: Status of job (complete, error) :type status: string :param sent_data: Input data for job :type sent_data: json encodable data :param job_id: An identifier for the job :type job_id: string ...
[ "Show", "a", "specific", "job", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L410-L449
train
61,351
ckan/ckan-service-provider
ckanserviceprovider/web.py
job_delete
def job_delete(job_id): '''Deletes the job together with its logs and metadata. :param job_id: An identifier for the job :type job_id: string :statuscode 200: no error :statuscode 403: not authorized to delete the job :statuscode 404: the job could not be found :statuscode 409: an error oc...
python
def job_delete(job_id): '''Deletes the job together with its logs and metadata. :param job_id: An identifier for the job :type job_id: string :statuscode 200: no error :statuscode 403: not authorized to delete the job :statuscode 404: the job could not be found :statuscode 409: an error oc...
[ "def", "job_delete", "(", "job_id", ")", ":", "conn", "=", "db", ".", "ENGINE", ".", "connect", "(", ")", "job", "=", "db", ".", "get_job", "(", "job_id", ")", "if", "not", "job", ":", "return", "json", ".", "dumps", "(", "{", "'error'", ":", "'j...
Deletes the job together with its logs and metadata. :param job_id: An identifier for the job :type job_id: string :statuscode 200: no error :statuscode 403: not authorized to delete the job :statuscode 404: the job could not be found :statuscode 409: an error occurred
[ "Deletes", "the", "job", "together", "with", "its", "logs", "and", "metadata", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L453-L480
train
61,352
ckan/ckan-service-provider
ckanserviceprovider/web.py
clear_jobs
def clear_jobs(): '''Clear old jobs :param days: Jobs for how many days should be kept (default: 10) :type days: integer :statuscode 200: no error :statuscode 403: not authorized to delete jobs :statuscode 409: an error occurred ''' if not is_authorized(): return json.dumps({'e...
python
def clear_jobs(): '''Clear old jobs :param days: Jobs for how many days should be kept (default: 10) :type days: integer :statuscode 200: no error :statuscode 403: not authorized to delete jobs :statuscode 409: an error occurred ''' if not is_authorized(): return json.dumps({'e...
[ "def", "clear_jobs", "(", ")", ":", "if", "not", "is_authorized", "(", ")", ":", "return", "json", ".", "dumps", "(", "{", "'error'", ":", "'not authorized'", "}", ")", ",", "403", ",", "headers", "days", "=", "flask", ".", "request", ".", "args", "....
Clear old jobs :param days: Jobs for how many days should be kept (default: 10) :type days: integer :statuscode 200: no error :statuscode 403: not authorized to delete jobs :statuscode 409: an error occurred
[ "Clear", "old", "jobs" ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L484-L498
train
61,353
ckan/ckan-service-provider
ckanserviceprovider/web.py
job_data
def job_data(job_id): '''Get the raw data that the job returned. The mimetype will be the value provided in the metdata for the key ``mimetype``. **Results:** :rtype: string :statuscode 200: no error :statuscode 403: not authorized to view the job's data :statuscode 404: job id not found ...
python
def job_data(job_id): '''Get the raw data that the job returned. The mimetype will be the value provided in the metdata for the key ``mimetype``. **Results:** :rtype: string :statuscode 200: no error :statuscode 403: not authorized to view the job's data :statuscode 404: job id not found ...
[ "def", "job_data", "(", "job_id", ")", ":", "job_dict", "=", "db", ".", "get_job", "(", "job_id", ")", "if", "not", "job_dict", ":", "return", "json", ".", "dumps", "(", "{", "'error'", ":", "'job_id not found'", "}", ")", ",", "404", ",", "headers", ...
Get the raw data that the job returned. The mimetype will be the value provided in the metdata for the key ``mimetype``. **Results:** :rtype: string :statuscode 200: no error :statuscode 403: not authorized to view the job's data :statuscode 404: job id not found :statuscode 409: an error...
[ "Get", "the", "raw", "data", "that", "the", "job", "returned", ".", "The", "mimetype", "will", "be", "the", "value", "provided", "in", "the", "metdata", "for", "the", "key", "mimetype", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L525-L546
train
61,354
ckan/ckan-service-provider
ckanserviceprovider/web.py
job
def job(job_id=None): '''Submit a job. If no id is provided, a random id will be generated. :param job_type: Which kind of job should be run. Has to be one of the available job types. :type job_type: string :param api_key: An API key that is needed to execute the job. This could be a CK...
python
def job(job_id=None): '''Submit a job. If no id is provided, a random id will be generated. :param job_type: Which kind of job should be run. Has to be one of the available job types. :type job_type: string :param api_key: An API key that is needed to execute the job. This could be a CK...
[ "def", "job", "(", "job_id", "=", "None", ")", ":", "if", "not", "job_id", ":", "job_id", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", "# key required for job administration", "job_key", "=", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", ...
Submit a job. If no id is provided, a random id will be generated. :param job_type: Which kind of job should be run. Has to be one of the available job types. :type job_type: string :param api_key: An API key that is needed to execute the job. This could be a CKAN API key that is needed to ...
[ "Submit", "a", "job", ".", "If", "no", "id", "is", "provided", "a", "random", "id", "will", "be", "generated", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L551-L649
train
61,355
ckan/ckan-service-provider
ckanserviceprovider/web.py
is_authorized
def is_authorized(job=None): '''Returns true if the request is authorized for the job if provided. If no job is provided, the user has to be admin to be authorized. ''' if flogin.current_user.is_authenticated: return True if job: job_key = flask.request.headers.get('Authorization...
python
def is_authorized(job=None): '''Returns true if the request is authorized for the job if provided. If no job is provided, the user has to be admin to be authorized. ''' if flogin.current_user.is_authenticated: return True if job: job_key = flask.request.headers.get('Authorization...
[ "def", "is_authorized", "(", "job", "=", "None", ")", ":", "if", "flogin", ".", "current_user", ".", "is_authenticated", ":", "return", "True", "if", "job", ":", "job_key", "=", "flask", ".", "request", ".", "headers", ".", "get", "(", "'Authorization'", ...
Returns true if the request is authorized for the job if provided. If no job is provided, the user has to be admin to be authorized.
[ "Returns", "true", "if", "the", "request", "is", "authorized", "for", "the", "job", "if", "provided", ".", "If", "no", "job", "is", "provided", "the", "user", "has", "to", "be", "admin", "to", "be", "authorized", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L697-L709
train
61,356
ckan/ckan-service-provider
ckanserviceprovider/web.py
send_result
def send_result(job_id, api_key=None): ''' Send results to where requested. If api_key is provided, it is used, otherwiese the key from the job will be used. ''' job_dict = db.get_job(job_id) result_url = job_dict.get('result_url') if not result_url: # A job with an API key (for u...
python
def send_result(job_id, api_key=None): ''' Send results to where requested. If api_key is provided, it is used, otherwiese the key from the job will be used. ''' job_dict = db.get_job(job_id) result_url = job_dict.get('result_url') if not result_url: # A job with an API key (for u...
[ "def", "send_result", "(", "job_id", ",", "api_key", "=", "None", ")", ":", "job_dict", "=", "db", ".", "get_job", "(", "job_id", ")", "result_url", "=", "job_dict", ".", "get", "(", "'result_url'", ")", "if", "not", "result_url", ":", "# A job with an API...
Send results to where requested. If api_key is provided, it is used, otherwiese the key from the job will be used.
[ "Send", "results", "to", "where", "requested", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/web.py#L712-L751
train
61,357
ckan/ckan-service-provider
ckanserviceprovider/db.py
init
def init(uri, echo=False): """Initialise the database. Initialise the sqlalchemy engine, metadata and table objects that we use to connect to the database. Create the database and the database tables themselves if they don't already exist. :param uri: the sqlalchemy database URI :type uri...
python
def init(uri, echo=False): """Initialise the database. Initialise the sqlalchemy engine, metadata and table objects that we use to connect to the database. Create the database and the database tables themselves if they don't already exist. :param uri: the sqlalchemy database URI :type uri...
[ "def", "init", "(", "uri", ",", "echo", "=", "False", ")", ":", "global", "ENGINE", ",", "_METADATA", ",", "JOBS_TABLE", ",", "METADATA_TABLE", ",", "LOGS_TABLE", "ENGINE", "=", "sqlalchemy", ".", "create_engine", "(", "uri", ",", "echo", "=", "echo", ",...
Initialise the database. Initialise the sqlalchemy engine, metadata and table objects that we use to connect to the database. Create the database and the database tables themselves if they don't already exist. :param uri: the sqlalchemy database URI :type uri: string :param echo: whether...
[ "Initialise", "the", "database", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L60-L83
train
61,358
ckan/ckan-service-provider
ckanserviceprovider/db.py
get_job
def get_job(job_id): """Return the job with the given job_id as a dict. The dict also includes any metadata or logs associated with the job. Returns None instead of a dict if there's no job with the given job_id. The keys of a job dict are: "job_id": The unique identifier for the job (unicode) ...
python
def get_job(job_id): """Return the job with the given job_id as a dict. The dict also includes any metadata or logs associated with the job. Returns None instead of a dict if there's no job with the given job_id. The keys of a job dict are: "job_id": The unique identifier for the job (unicode) ...
[ "def", "get_job", "(", "job_id", ")", ":", "# Avoid SQLAlchemy \"Unicode type received non-unicode bind param value\"", "# warnings.", "if", "job_id", ":", "job_id", "=", "unicode", "(", "job_id", ")", "result", "=", "ENGINE", ".", "execute", "(", "JOBS_TABLE", ".", ...
Return the job with the given job_id as a dict. The dict also includes any metadata or logs associated with the job. Returns None instead of a dict if there's no job with the given job_id. The keys of a job dict are: "job_id": The unique identifier for the job (unicode) "job_type": The name of ...
[ "Return", "the", "job", "with", "the", "given", "job_id", "as", "a", "dict", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L98-L179
train
61,359
ckan/ckan-service-provider
ckanserviceprovider/db.py
add_pending_job
def add_pending_job(job_id, job_key, job_type, api_key, data=None, metadata=None, result_url=None): """Add a new job with status "pending" to the jobs table. All code that adds jobs to the jobs table should go through this function. Code that adds to the jobs table manually should be re...
python
def add_pending_job(job_id, job_key, job_type, api_key, data=None, metadata=None, result_url=None): """Add a new job with status "pending" to the jobs table. All code that adds jobs to the jobs table should go through this function. Code that adds to the jobs table manually should be re...
[ "def", "add_pending_job", "(", "job_id", ",", "job_key", ",", "job_type", ",", "api_key", ",", "data", "=", "None", ",", "metadata", "=", "None", ",", "result_url", "=", "None", ")", ":", "if", "not", "data", ":", "data", "=", "{", "}", "data", "=", ...
Add a new job with status "pending" to the jobs table. All code that adds jobs to the jobs table should go through this function. Code that adds to the jobs table manually should be refactored to use this function. May raise unspecified exceptions from Python core, SQLAlchemy or JSON! TODO: Docume...
[ "Add", "a", "new", "job", "with", "status", "pending", "to", "the", "jobs", "table", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L182-L282
train
61,360
ckan/ckan-service-provider
ckanserviceprovider/db.py
_validate_error
def _validate_error(error): """Validate and return the given error object. Based on the given error object, return either None or a dict with a "message" key whose value is a string (the dict may also have any other keys that it wants). The given "error" object can be: - None, in which case N...
python
def _validate_error(error): """Validate and return the given error object. Based on the given error object, return either None or a dict with a "message" key whose value is a string (the dict may also have any other keys that it wants). The given "error" object can be: - None, in which case N...
[ "def", "_validate_error", "(", "error", ")", ":", "if", "error", "is", "None", ":", "return", "None", "elif", "isinstance", "(", "error", ",", "basestring", ")", ":", "return", "{", "\"message\"", ":", "error", "}", "else", ":", "try", ":", "message", ...
Validate and return the given error object. Based on the given error object, return either None or a dict with a "message" key whose value is a string (the dict may also have any other keys that it wants). The given "error" object can be: - None, in which case None is returned - A string, in...
[ "Validate", "and", "return", "the", "given", "error", "object", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L289-L326
train
61,361
ckan/ckan-service-provider
ckanserviceprovider/db.py
_update_job
def _update_job(job_id, job_dict): """Update the database row for the given job_id with the given job_dict. All functions that update rows in the jobs table do it by calling this helper function. job_dict is a dict with values corresponding to the database columns that should be updated, e.g.: ...
python
def _update_job(job_id, job_dict): """Update the database row for the given job_id with the given job_dict. All functions that update rows in the jobs table do it by calling this helper function. job_dict is a dict with values corresponding to the database columns that should be updated, e.g.: ...
[ "def", "_update_job", "(", "job_id", ",", "job_dict", ")", ":", "# Avoid SQLAlchemy \"Unicode type received non-unicode bind param value\"", "# warnings.", "if", "job_id", ":", "job_id", "=", "unicode", "(", "job_id", ")", "if", "\"error\"", "in", "job_dict", ":", "jo...
Update the database row for the given job_id with the given job_dict. All functions that update rows in the jobs table do it by calling this helper function. job_dict is a dict with values corresponding to the database columns that should be updated, e.g.: {"status": "complete", "data": ...}
[ "Update", "the", "database", "row", "for", "the", "given", "job_id", "with", "the", "given", "job_dict", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L329-L361
train
61,362
ckan/ckan-service-provider
ckanserviceprovider/db.py
mark_job_as_completed
def mark_job_as_completed(job_id, data=None): """Mark a job as completed successfully. :param job_id: the job_id of the job to be updated :type job_id: unicode :param data: the output data returned by the job :type data: any JSON-serializable type (including None) """ update_dict = { ...
python
def mark_job_as_completed(job_id, data=None): """Mark a job as completed successfully. :param job_id: the job_id of the job to be updated :type job_id: unicode :param data: the output data returned by the job :type data: any JSON-serializable type (including None) """ update_dict = { ...
[ "def", "mark_job_as_completed", "(", "job_id", ",", "data", "=", "None", ")", ":", "update_dict", "=", "{", "\"status\"", ":", "\"complete\"", ",", "\"data\"", ":", "json", ".", "dumps", "(", "data", ")", ",", "\"finished_timestamp\"", ":", "datetime", ".", ...
Mark a job as completed successfully. :param job_id: the job_id of the job to be updated :type job_id: unicode :param data: the output data returned by the job :type data: any JSON-serializable type (including None)
[ "Mark", "a", "job", "as", "completed", "successfully", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L364-L379
train
61,363
ckan/ckan-service-provider
ckanserviceprovider/db.py
mark_job_as_errored
def mark_job_as_errored(job_id, error_object): """Mark a job as failed with an error. :param job_id: the job_id of the job to be updated :type job_id: unicode :param error_object: the error returned by the job :type error_object: either a string or a dict with a "message" key whose value i...
python
def mark_job_as_errored(job_id, error_object): """Mark a job as failed with an error. :param job_id: the job_id of the job to be updated :type job_id: unicode :param error_object: the error returned by the job :type error_object: either a string or a dict with a "message" key whose value i...
[ "def", "mark_job_as_errored", "(", "job_id", ",", "error_object", ")", ":", "update_dict", "=", "{", "\"status\"", ":", "\"error\"", ",", "\"error\"", ":", "error_object", ",", "\"finished_timestamp\"", ":", "datetime", ".", "datetime", ".", "now", "(", ")", "...
Mark a job as failed with an error. :param job_id: the job_id of the job to be updated :type job_id: unicode :param error_object: the error returned by the job :type error_object: either a string or a dict with a "message" key whose value is a string
[ "Mark", "a", "job", "as", "failed", "with", "an", "error", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L397-L413
train
61,364
ckan/ckan-service-provider
ckanserviceprovider/db.py
_init_jobs_table
def _init_jobs_table(): """Initialise the "jobs" table in the db.""" _jobs_table = sqlalchemy.Table( 'jobs', _METADATA, sqlalchemy.Column('job_id', sqlalchemy.UnicodeText, primary_key=True), sqlalchemy.Column('job_type', sqlalchemy.UnicodeText), sqlalchemy.Column('status', sqlalc...
python
def _init_jobs_table(): """Initialise the "jobs" table in the db.""" _jobs_table = sqlalchemy.Table( 'jobs', _METADATA, sqlalchemy.Column('job_id', sqlalchemy.UnicodeText, primary_key=True), sqlalchemy.Column('job_type', sqlalchemy.UnicodeText), sqlalchemy.Column('status', sqlalc...
[ "def", "_init_jobs_table", "(", ")", ":", "_jobs_table", "=", "sqlalchemy", ".", "Table", "(", "'jobs'", ",", "_METADATA", ",", "sqlalchemy", ".", "Column", "(", "'job_id'", ",", "sqlalchemy", ".", "UnicodeText", ",", "primary_key", "=", "True", ")", ",", ...
Initialise the "jobs" table in the db.
[ "Initialise", "the", "jobs", "table", "in", "the", "db", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L446-L465
train
61,365
ckan/ckan-service-provider
ckanserviceprovider/db.py
_init_metadata_table
def _init_metadata_table(): """Initialise the "metadata" table in the db.""" _metadata_table = sqlalchemy.Table( 'metadata', _METADATA, sqlalchemy.Column( 'job_id', sqlalchemy.ForeignKey("jobs.job_id", ondelete="CASCADE"), nullable=False, primary_key=True), sqlalc...
python
def _init_metadata_table(): """Initialise the "metadata" table in the db.""" _metadata_table = sqlalchemy.Table( 'metadata', _METADATA, sqlalchemy.Column( 'job_id', sqlalchemy.ForeignKey("jobs.job_id", ondelete="CASCADE"), nullable=False, primary_key=True), sqlalc...
[ "def", "_init_metadata_table", "(", ")", ":", "_metadata_table", "=", "sqlalchemy", ".", "Table", "(", "'metadata'", ",", "_METADATA", ",", "sqlalchemy", ".", "Column", "(", "'job_id'", ",", "sqlalchemy", ".", "ForeignKey", "(", "\"jobs.job_id\"", ",", "ondelete...
Initialise the "metadata" table in the db.
[ "Initialise", "the", "metadata", "table", "in", "the", "db", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L468-L479
train
61,366
ckan/ckan-service-provider
ckanserviceprovider/db.py
_init_logs_table
def _init_logs_table(): """Initialise the "logs" table in the db.""" _logs_table = sqlalchemy.Table( 'logs', _METADATA, sqlalchemy.Column( 'job_id', sqlalchemy.ForeignKey("jobs.job_id", ondelete="CASCADE"), nullable=False), sqlalchemy.Column('timestamp', sqlalchem...
python
def _init_logs_table(): """Initialise the "logs" table in the db.""" _logs_table = sqlalchemy.Table( 'logs', _METADATA, sqlalchemy.Column( 'job_id', sqlalchemy.ForeignKey("jobs.job_id", ondelete="CASCADE"), nullable=False), sqlalchemy.Column('timestamp', sqlalchem...
[ "def", "_init_logs_table", "(", ")", ":", "_logs_table", "=", "sqlalchemy", ".", "Table", "(", "'logs'", ",", "_METADATA", ",", "sqlalchemy", ".", "Column", "(", "'job_id'", ",", "sqlalchemy", ".", "ForeignKey", "(", "\"jobs.job_id\"", ",", "ondelete", "=", ...
Initialise the "logs" table in the db.
[ "Initialise", "the", "logs", "table", "in", "the", "db", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L482-L496
train
61,367
ckan/ckan-service-provider
ckanserviceprovider/db.py
_get_metadata
def _get_metadata(job_id): """Return any metadata for the given job_id from the metadata table.""" # Avoid SQLAlchemy "Unicode type received non-unicode bind param value" # warnings. job_id = unicode(job_id) results = ENGINE.execute( METADATA_TABLE.select().where( METADATA_TABLE...
python
def _get_metadata(job_id): """Return any metadata for the given job_id from the metadata table.""" # Avoid SQLAlchemy "Unicode type received non-unicode bind param value" # warnings. job_id = unicode(job_id) results = ENGINE.execute( METADATA_TABLE.select().where( METADATA_TABLE...
[ "def", "_get_metadata", "(", "job_id", ")", ":", "# Avoid SQLAlchemy \"Unicode type received non-unicode bind param value\"", "# warnings.", "job_id", "=", "unicode", "(", "job_id", ")", "results", "=", "ENGINE", ".", "execute", "(", "METADATA_TABLE", ".", "select", "("...
Return any metadata for the given job_id from the metadata table.
[ "Return", "any", "metadata", "for", "the", "given", "job_id", "from", "the", "metadata", "table", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L499-L514
train
61,368
ckan/ckan-service-provider
ckanserviceprovider/db.py
_get_logs
def _get_logs(job_id): """Return any logs for the given job_id from the logs table.""" # Avoid SQLAlchemy "Unicode type received non-unicode bind param value" # warnings. job_id = unicode(job_id) results = ENGINE.execute( LOGS_TABLE.select().where(LOGS_TABLE.c.job_id == job_id)).fetchall() ...
python
def _get_logs(job_id): """Return any logs for the given job_id from the logs table.""" # Avoid SQLAlchemy "Unicode type received non-unicode bind param value" # warnings. job_id = unicode(job_id) results = ENGINE.execute( LOGS_TABLE.select().where(LOGS_TABLE.c.job_id == job_id)).fetchall() ...
[ "def", "_get_logs", "(", "job_id", ")", ":", "# Avoid SQLAlchemy \"Unicode type received non-unicode bind param value\"", "# warnings.", "job_id", "=", "unicode", "(", "job_id", ")", "results", "=", "ENGINE", ".", "execute", "(", "LOGS_TABLE", ".", "select", "(", ")",...
Return any logs for the given job_id from the logs table.
[ "Return", "any", "logs", "for", "the", "given", "job_id", "from", "the", "logs", "table", "." ]
83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa
https://github.com/ckan/ckan-service-provider/blob/83a42b027dba8a0b3ca7e5f689f990b7bc2cd7fa/ckanserviceprovider/db.py#L517-L531
train
61,369
bookieio/breadability
breadability/scoring.py
check_node_attributes
def check_node_attributes(pattern, node, *attributes): """ Searches match in attributes against given pattern and if finds the match against any of them returns True. """ for attribute_name in attributes: attribute = node.get(attribute_name) if attribute is not None and pattern.searc...
python
def check_node_attributes(pattern, node, *attributes): """ Searches match in attributes against given pattern and if finds the match against any of them returns True. """ for attribute_name in attributes: attribute = node.get(attribute_name) if attribute is not None and pattern.searc...
[ "def", "check_node_attributes", "(", "pattern", ",", "node", ",", "*", "attributes", ")", ":", "for", "attribute_name", "in", "attributes", ":", "attribute", "=", "node", ".", "get", "(", "attribute_name", ")", "if", "attribute", "is", "not", "None", "and", ...
Searches match in attributes against given pattern and if finds the match against any of them returns True.
[ "Searches", "match", "in", "attributes", "against", "given", "pattern", "and", "if", "finds", "the", "match", "against", "any", "of", "them", "returns", "True", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/scoring.py#L43-L53
train
61,370
bookieio/breadability
breadability/scoring.py
generate_hash_id
def generate_hash_id(node): """ Generates a hash_id for the node in question. :param node: lxml etree node """ try: content = tostring(node) except Exception: logger.exception("Generating of hash failed") content = to_bytes(repr(node)) hash_id = md5(content).hexdige...
python
def generate_hash_id(node): """ Generates a hash_id for the node in question. :param node: lxml etree node """ try: content = tostring(node) except Exception: logger.exception("Generating of hash failed") content = to_bytes(repr(node)) hash_id = md5(content).hexdige...
[ "def", "generate_hash_id", "(", "node", ")", ":", "try", ":", "content", "=", "tostring", "(", "node", ")", "except", "Exception", ":", "logger", ".", "exception", "(", "\"Generating of hash failed\"", ")", "content", "=", "to_bytes", "(", "repr", "(", "node...
Generates a hash_id for the node in question. :param node: lxml etree node
[ "Generates", "a", "hash_id", "for", "the", "node", "in", "question", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/scoring.py#L56-L69
train
61,371
bookieio/breadability
breadability/scoring.py
get_link_density
def get_link_density(node, node_text=None): """ Computes the ratio for text in given node and text in links contained in the node. It is computed from number of characters in the texts. :parameter Element node: HTML element in which links density is computed. :parameter string node_text...
python
def get_link_density(node, node_text=None): """ Computes the ratio for text in given node and text in links contained in the node. It is computed from number of characters in the texts. :parameter Element node: HTML element in which links density is computed. :parameter string node_text...
[ "def", "get_link_density", "(", "node", ",", "node_text", "=", "None", ")", ":", "if", "node_text", "is", "None", ":", "node_text", "=", "node", ".", "text_content", "(", ")", "node_text", "=", "normalize_whitespace", "(", "node_text", ".", "strip", "(", "...
Computes the ratio for text in given node and text in links contained in the node. It is computed from number of characters in the texts. :parameter Element node: HTML element in which links density is computed. :parameter string node_text: Text content of given node if it was obtained ...
[ "Computes", "the", "ratio", "for", "text", "in", "given", "node", "and", "text", "in", "links", "contained", "in", "the", "node", ".", "It", "is", "computed", "from", "number", "of", "characters", "in", "the", "texts", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/scoring.py#L72-L100
train
61,372
bookieio/breadability
breadability/scoring.py
is_unlikely_node
def is_unlikely_node(node): """ Short helper for checking unlikely status. If the class or id are in the unlikely list, and there's not also a class/id in the likely list then it might need to be removed. """ unlikely = check_node_attributes(CLS_UNLIKELY, node, "class", "id") maybe = check_...
python
def is_unlikely_node(node): """ Short helper for checking unlikely status. If the class or id are in the unlikely list, and there's not also a class/id in the likely list then it might need to be removed. """ unlikely = check_node_attributes(CLS_UNLIKELY, node, "class", "id") maybe = check_...
[ "def", "is_unlikely_node", "(", "node", ")", ":", "unlikely", "=", "check_node_attributes", "(", "CLS_UNLIKELY", ",", "node", ",", "\"class\"", ",", "\"id\"", ")", "maybe", "=", "check_node_attributes", "(", "CLS_MAYBE", ",", "node", ",", "\"class\"", ",", "\"...
Short helper for checking unlikely status. If the class or id are in the unlikely list, and there's not also a class/id in the likely list then it might need to be removed.
[ "Short", "helper", "for", "checking", "unlikely", "status", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/scoring.py#L128-L138
train
61,373
bookieio/breadability
breadability/scoring.py
score_candidates
def score_candidates(nodes): """Given a list of potential nodes, find some initial scores to start""" MIN_HIT_LENTH = 25 candidates = {} for node in nodes: logger.debug("* Scoring candidate %s %r", node.tag, node.attrib) # if the node has no parent it knows of then it ends up creating ...
python
def score_candidates(nodes): """Given a list of potential nodes, find some initial scores to start""" MIN_HIT_LENTH = 25 candidates = {} for node in nodes: logger.debug("* Scoring candidate %s %r", node.tag, node.attrib) # if the node has no parent it knows of then it ends up creating ...
[ "def", "score_candidates", "(", "nodes", ")", ":", "MIN_HIT_LENTH", "=", "25", "candidates", "=", "{", "}", "for", "node", "in", "nodes", ":", "logger", ".", "debug", "(", "\"* Scoring candidate %s %r\"", ",", "node", ".", "tag", ",", "node", ".", "attrib"...
Given a list of potential nodes, find some initial scores to start
[ "Given", "a", "list", "of", "potential", "nodes", "find", "some", "initial", "scores", "to", "start" ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/scoring.py#L141-L222
train
61,374
miguelmoreto/pycomtrade
src/pyComtrade.py
ComtradeRecord.getTime
def getTime(self): """ Actually, this function creates a time stamp vector based on the number of samples and sample rate. """ T = 1/float(self.samp[self.nrates-1]) endtime = self.endsamp[self.nrates-1] * T t = numpy.linspace(0,endtime,self.endsamp[self.nrates-1...
python
def getTime(self): """ Actually, this function creates a time stamp vector based on the number of samples and sample rate. """ T = 1/float(self.samp[self.nrates-1]) endtime = self.endsamp[self.nrates-1] * T t = numpy.linspace(0,endtime,self.endsamp[self.nrates-1...
[ "def", "getTime", "(", "self", ")", ":", "T", "=", "1", "/", "float", "(", "self", ".", "samp", "[", "self", ".", "nrates", "-", "1", "]", ")", "endtime", "=", "self", ".", "endsamp", "[", "self", ".", "nrates", "-", "1", "]", "*", "T", "t", ...
Actually, this function creates a time stamp vector based on the number of samples and sample rate.
[ "Actually", "this", "function", "creates", "a", "time", "stamp", "vector", "based", "on", "the", "number", "of", "samples", "and", "sample", "rate", "." ]
1785ebbc96c01a60e58fb11f0aa4848be855aa0d
https://github.com/miguelmoreto/pycomtrade/blob/1785ebbc96c01a60e58fb11f0aa4848be855aa0d/src/pyComtrade.py#L288-L298
train
61,375
miguelmoreto/pycomtrade
src/pyComtrade.py
ComtradeRecord.getAnalogID
def getAnalogID(self,num): """ Returns the COMTRADE ID of a given channel number. The number to be given is the same of the COMTRADE header. """ listidx = self.An.index(num) # Get the position of the channel number. return self.Ach_id[listidx]
python
def getAnalogID(self,num): """ Returns the COMTRADE ID of a given channel number. The number to be given is the same of the COMTRADE header. """ listidx = self.An.index(num) # Get the position of the channel number. return self.Ach_id[listidx]
[ "def", "getAnalogID", "(", "self", ",", "num", ")", ":", "listidx", "=", "self", ".", "An", ".", "index", "(", "num", ")", "# Get the position of the channel number.", "return", "self", ".", "Ach_id", "[", "listidx", "]" ]
Returns the COMTRADE ID of a given channel number. The number to be given is the same of the COMTRADE header.
[ "Returns", "the", "COMTRADE", "ID", "of", "a", "given", "channel", "number", ".", "The", "number", "to", "be", "given", "is", "the", "same", "of", "the", "COMTRADE", "header", "." ]
1785ebbc96c01a60e58fb11f0aa4848be855aa0d
https://github.com/miguelmoreto/pycomtrade/blob/1785ebbc96c01a60e58fb11f0aa4848be855aa0d/src/pyComtrade.py#L300-L306
train
61,376
miguelmoreto/pycomtrade
src/pyComtrade.py
ComtradeRecord.getDigitalID
def getDigitalID(self,num): """ Reads the COMTRADE ID of a given channel number. The number to be given is the same of the COMTRADE header. """ listidx = self.Dn.index(num) # Get the position of the channel number. return self.Dch_id[listidx]
python
def getDigitalID(self,num): """ Reads the COMTRADE ID of a given channel number. The number to be given is the same of the COMTRADE header. """ listidx = self.Dn.index(num) # Get the position of the channel number. return self.Dch_id[listidx]
[ "def", "getDigitalID", "(", "self", ",", "num", ")", ":", "listidx", "=", "self", ".", "Dn", ".", "index", "(", "num", ")", "# Get the position of the channel number.", "return", "self", ".", "Dch_id", "[", "listidx", "]" ]
Reads the COMTRADE ID of a given channel number. The number to be given is the same of the COMTRADE header.
[ "Reads", "the", "COMTRADE", "ID", "of", "a", "given", "channel", "number", ".", "The", "number", "to", "be", "given", "is", "the", "same", "of", "the", "COMTRADE", "header", "." ]
1785ebbc96c01a60e58fb11f0aa4848be855aa0d
https://github.com/miguelmoreto/pycomtrade/blob/1785ebbc96c01a60e58fb11f0aa4848be855aa0d/src/pyComtrade.py#L308-L314
train
61,377
miguelmoreto/pycomtrade
src/pyComtrade.py
ComtradeRecord.getAnalogType
def getAnalogType(self,num): """ Returns the type of the channel 'num' based on its unit stored in the Comtrade header file. Returns 'V' for a voltage channel and 'I' for a current channel. """ listidx = self.An.index(num) unit = self.uu[listidx] ...
python
def getAnalogType(self,num): """ Returns the type of the channel 'num' based on its unit stored in the Comtrade header file. Returns 'V' for a voltage channel and 'I' for a current channel. """ listidx = self.An.index(num) unit = self.uu[listidx] ...
[ "def", "getAnalogType", "(", "self", ",", "num", ")", ":", "listidx", "=", "self", ".", "An", ".", "index", "(", "num", ")", "unit", "=", "self", ".", "uu", "[", "listidx", "]", "if", "unit", "==", "'kV'", "or", "unit", "==", "'V'", ":", "return"...
Returns the type of the channel 'num' based on its unit stored in the Comtrade header file. Returns 'V' for a voltage channel and 'I' for a current channel.
[ "Returns", "the", "type", "of", "the", "channel", "num", "based", "on", "its", "unit", "stored", "in", "the", "Comtrade", "header", "file", ".", "Returns", "V", "for", "a", "voltage", "channel", "and", "I", "for", "a", "current", "channel", "." ]
1785ebbc96c01a60e58fb11f0aa4848be855aa0d
https://github.com/miguelmoreto/pycomtrade/blob/1785ebbc96c01a60e58fb11f0aa4848be855aa0d/src/pyComtrade.py#L316-L332
train
61,378
miguelmoreto/pycomtrade
src/pyComtrade.py
ComtradeRecord.ReadDataFile
def ReadDataFile(self): """ Reads the contents of the Comtrade .dat file and store them in a private variable. For accessing a specific channel data, see methods getAnalogData and getDigitalData. """ if os.path.isfile(self.filename[0:-4] + '.dat'): ...
python
def ReadDataFile(self): """ Reads the contents of the Comtrade .dat file and store them in a private variable. For accessing a specific channel data, see methods getAnalogData and getDigitalData. """ if os.path.isfile(self.filename[0:-4] + '.dat'): ...
[ "def", "ReadDataFile", "(", "self", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "self", ".", "filename", "[", "0", ":", "-", "4", "]", "+", "'.dat'", ")", ":", "filename", "=", "self", ".", "filename", "[", "0", ":", "-", "4", "]", ...
Reads the contents of the Comtrade .dat file and store them in a private variable. For accessing a specific channel data, see methods getAnalogData and getDigitalData.
[ "Reads", "the", "contents", "of", "the", "Comtrade", ".", "dat", "file", "and", "store", "them", "in", "a", "private", "variable", ".", "For", "accessing", "a", "specific", "channel", "data", "see", "methods", "getAnalogData", "and", "getDigitalData", "." ]
1785ebbc96c01a60e58fb11f0aa4848be855aa0d
https://github.com/miguelmoreto/pycomtrade/blob/1785ebbc96c01a60e58fb11f0aa4848be855aa0d/src/pyComtrade.py#L343-L367
train
61,379
miguelmoreto/pycomtrade
src/pyComtrade.py
ComtradeRecord.getAnalogChannelData
def getAnalogChannelData(self,ChNumber): """ Returns an array of numbers containing the data values of the channel number "ChNumber". ChNumber is the number of the channal as in .cfg file. """ if not self.DatFileContent: print "No data file content. ...
python
def getAnalogChannelData(self,ChNumber): """ Returns an array of numbers containing the data values of the channel number "ChNumber". ChNumber is the number of the channal as in .cfg file. """ if not self.DatFileContent: print "No data file content. ...
[ "def", "getAnalogChannelData", "(", "self", ",", "ChNumber", ")", ":", "if", "not", "self", ".", "DatFileContent", ":", "print", "\"No data file content. Use the method ReadDataFile first\"", "return", "0", "if", "(", "ChNumber", ">", "self", ".", "A", ")", ":", ...
Returns an array of numbers containing the data values of the channel number "ChNumber". ChNumber is the number of the channal as in .cfg file.
[ "Returns", "an", "array", "of", "numbers", "containing", "the", "data", "values", "of", "the", "channel", "number", "ChNumber", ".", "ChNumber", "is", "the", "number", "of", "the", "channal", "as", "in", ".", "cfg", "file", "." ]
1785ebbc96c01a60e58fb11f0aa4848be855aa0d
https://github.com/miguelmoreto/pycomtrade/blob/1785ebbc96c01a60e58fb11f0aa4848be855aa0d/src/pyComtrade.py#L369-L405
train
61,380
holtjma/msbwt
MUS/CommandLineInterface.py
initLogger
def initLogger(): ''' This code taken from Matt's Suspenders for initializing a logger ''' global logger logger = logging.getLogger('root') logger.setLevel(logging.DEBUG) ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.INFO) formatter = logging.Formatter("[%(asctime)s] %(l...
python
def initLogger(): ''' This code taken from Matt's Suspenders for initializing a logger ''' global logger logger = logging.getLogger('root') logger.setLevel(logging.DEBUG) ch = logging.StreamHandler(sys.stdout) ch.setLevel(logging.INFO) formatter = logging.Formatter("[%(asctime)s] %(l...
[ "def", "initLogger", "(", ")", ":", "global", "logger", "logger", "=", "logging", ".", "getLogger", "(", "'root'", ")", "logger", ".", "setLevel", "(", "logging", ".", "DEBUG", ")", "ch", "=", "logging", ".", "StreamHandler", "(", "sys", ".", "stdout", ...
This code taken from Matt's Suspenders for initializing a logger
[ "This", "code", "taken", "from", "Matt", "s", "Suspenders", "for", "initializing", "a", "logger" ]
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/CommandLineInterface.py#L22-L33
train
61,381
holtjma/msbwt
MUS/MSBWTGen.py
writeSeqsToFiles
def writeSeqsToFiles(seqArray, seqFNPrefix, offsetFN, uniformLength): ''' This function takes a seqArray and saves the values to a memmap file that can be accessed for multi-processing. Additionally, it saves some offset indices in a numpy file for quicker string access. @param seqArray - the list o...
python
def writeSeqsToFiles(seqArray, seqFNPrefix, offsetFN, uniformLength): ''' This function takes a seqArray and saves the values to a memmap file that can be accessed for multi-processing. Additionally, it saves some offset indices in a numpy file for quicker string access. @param seqArray - the list o...
[ "def", "writeSeqsToFiles", "(", "seqArray", ",", "seqFNPrefix", ",", "offsetFN", ",", "uniformLength", ")", ":", "if", "uniformLength", ":", "#first, store the uniform size in our offsets file", "offsets", "=", "np", ".", "lib", ".", "format", ".", "open_memmap", "(...
This function takes a seqArray and saves the values to a memmap file that can be accessed for multi-processing. Additionally, it saves some offset indices in a numpy file for quicker string access. @param seqArray - the list of '$'-terminated strings to be saved @param fnPrefix - the prefix for the temporar...
[ "This", "function", "takes", "a", "seqArray", "and", "saves", "the", "values", "to", "a", "memmap", "file", "that", "can", "be", "accessed", "for", "multi", "-", "processing", ".", "Additionally", "it", "saves", "some", "offset", "indices", "in", "a", "num...
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/MSBWTGen.py#L618-L681
train
61,382
holtjma/msbwt
MUS/MSBWTGen.py
decompressBWT
def decompressBWT(inputDir, outputDir, numProcs, logger): ''' This is called for taking a BWT and decompressing it back out to it's original form. While unusual to do, it's included in this package for completion purposes. @param inputDir - the directory of the compressed BWT we plan on decompressing ...
python
def decompressBWT(inputDir, outputDir, numProcs, logger): ''' This is called for taking a BWT and decompressing it back out to it's original form. While unusual to do, it's included in this package for completion purposes. @param inputDir - the directory of the compressed BWT we plan on decompressing ...
[ "def", "decompressBWT", "(", "inputDir", ",", "outputDir", ",", "numProcs", ",", "logger", ")", ":", "#load it, force it to be a compressed bwt also", "msbwt", "=", "MultiStringBWT", ".", "CompressedMSBWT", "(", ")", "msbwt", ".", "loadMsbwt", "(", "inputDir", ",", ...
This is called for taking a BWT and decompressing it back out to it's original form. While unusual to do, it's included in this package for completion purposes. @param inputDir - the directory of the compressed BWT we plan on decompressing @param outputFN - the directory for the output decompressed BWT, it...
[ "This", "is", "called", "for", "taking", "a", "BWT", "and", "decompressing", "it", "back", "out", "to", "it", "s", "original", "form", ".", "While", "unusual", "to", "do", "it", "s", "included", "in", "this", "package", "for", "completion", "purposes", "...
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/MSBWTGen.py#L1169-L1203
train
61,383
holtjma/msbwt
MUS/MSBWTGen.py
decompressBWTPoolProcess
def decompressBWTPoolProcess(tup): ''' Individual process for decompression ''' (inputDir, outputDir, startIndex, endIndex) = tup if startIndex == endIndex: return True #load the thing we'll be extracting from msbwt = MultiStringBWT.CompressedMSBWT() msbwt.loadMsbwt(inp...
python
def decompressBWTPoolProcess(tup): ''' Individual process for decompression ''' (inputDir, outputDir, startIndex, endIndex) = tup if startIndex == endIndex: return True #load the thing we'll be extracting from msbwt = MultiStringBWT.CompressedMSBWT() msbwt.loadMsbwt(inp...
[ "def", "decompressBWTPoolProcess", "(", "tup", ")", ":", "(", "inputDir", ",", "outputDir", ",", "startIndex", ",", "endIndex", ")", "=", "tup", "if", "startIndex", "==", "endIndex", ":", "return", "True", "#load the thing we'll be extracting from", "msbwt", "=", ...
Individual process for decompression
[ "Individual", "process", "for", "decompression" ]
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/MSBWTGen.py#L1207-L1224
train
61,384
holtjma/msbwt
MUS/MSBWTGen.py
clearAuxiliaryData
def clearAuxiliaryData(dirName): ''' This function removes auxiliary files associated with a given filename ''' if dirName != None: if os.path.exists(dirName+'/auxiliary.npy'): os.remove(dirName+'/auxiliary.npy') if os.path.exists(dirName+'/totalCounts.p'): ...
python
def clearAuxiliaryData(dirName): ''' This function removes auxiliary files associated with a given filename ''' if dirName != None: if os.path.exists(dirName+'/auxiliary.npy'): os.remove(dirName+'/auxiliary.npy') if os.path.exists(dirName+'/totalCounts.p'): ...
[ "def", "clearAuxiliaryData", "(", "dirName", ")", ":", "if", "dirName", "!=", "None", ":", "if", "os", ".", "path", ".", "exists", "(", "dirName", "+", "'/auxiliary.npy'", ")", ":", "os", ".", "remove", "(", "dirName", "+", "'/auxiliary.npy'", ")", "if",...
This function removes auxiliary files associated with a given filename
[ "This", "function", "removes", "auxiliary", "files", "associated", "with", "a", "given", "filename" ]
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/MSBWTGen.py#L1226-L1250
train
61,385
bookieio/breadability
breadability/readable.py
build_base_document
def build_base_document(dom, return_fragment=True): """ Builds a base document with the body as root. :param dom: Parsed lxml tree (Document Object Model). :param bool return_fragment: If True only <div> fragment is returned. Otherwise full HTML document is returned. """ body_element = ...
python
def build_base_document(dom, return_fragment=True): """ Builds a base document with the body as root. :param dom: Parsed lxml tree (Document Object Model). :param bool return_fragment: If True only <div> fragment is returned. Otherwise full HTML document is returned. """ body_element = ...
[ "def", "build_base_document", "(", "dom", ",", "return_fragment", "=", "True", ")", ":", "body_element", "=", "dom", ".", "find", "(", "\".//body\"", ")", "if", "body_element", "is", "None", ":", "fragment", "=", "fragment_fromstring", "(", "'<div id=\"readabili...
Builds a base document with the body as root. :param dom: Parsed lxml tree (Document Object Model). :param bool return_fragment: If True only <div> fragment is returned. Otherwise full HTML document is returned.
[ "Builds", "a", "base", "document", "with", "the", "body", "as", "root", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L67-L85
train
61,386
bookieio/breadability
breadability/readable.py
check_siblings
def check_siblings(candidate_node, candidate_list): """ Looks through siblings for content that might also be related. Things like preambles, content split by ads that we removed, etc. """ candidate_css = candidate_node.node.get("class") potential_target = candidate_node.content_score * 0.2 ...
python
def check_siblings(candidate_node, candidate_list): """ Looks through siblings for content that might also be related. Things like preambles, content split by ads that we removed, etc. """ candidate_css = candidate_node.node.get("class") potential_target = candidate_node.content_score * 0.2 ...
[ "def", "check_siblings", "(", "candidate_node", ",", "candidate_list", ")", ":", "candidate_css", "=", "candidate_node", ".", "node", ".", "get", "(", "\"class\"", ")", "potential_target", "=", "candidate_node", ".", "content_score", "*", "0.2", "sibling_target_scor...
Looks through siblings for content that might also be related. Things like preambles, content split by ads that we removed, etc.
[ "Looks", "through", "siblings", "for", "content", "that", "might", "also", "be", "related", ".", "Things", "like", "preambles", "content", "split", "by", "ads", "that", "we", "removed", "etc", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L113-L166
train
61,387
bookieio/breadability
breadability/readable.py
clean_document
def clean_document(node): """Cleans up the final document we return as the readable article.""" if node is None or len(node) == 0: return None logger.debug("\n\n-------------- CLEANING DOCUMENT -----------------") to_drop = [] for n in node.iter(): # clean out any in-line style pro...
python
def clean_document(node): """Cleans up the final document we return as the readable article.""" if node is None or len(node) == 0: return None logger.debug("\n\n-------------- CLEANING DOCUMENT -----------------") to_drop = [] for n in node.iter(): # clean out any in-line style pro...
[ "def", "clean_document", "(", "node", ")", ":", "if", "node", "is", "None", "or", "len", "(", "node", ")", "==", "0", ":", "return", "None", "logger", ".", "debug", "(", "\"\\n\\n-------------- CLEANING DOCUMENT -----------------\"", ")", "to_drop", "=", "[", ...
Cleans up the final document we return as the readable article.
[ "Cleans", "up", "the", "final", "document", "we", "return", "as", "the", "readable", "article", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L169-L210
train
61,388
bookieio/breadability
breadability/readable.py
clean_conditionally
def clean_conditionally(node): """Remove the clean_el if it looks like bad content based on rules.""" if node.tag not in ('form', 'table', 'ul', 'div', 'p'): return # this is not the tag we are looking for weight = get_class_weight(node) # content_score = LOOK up the content score for this nod...
python
def clean_conditionally(node): """Remove the clean_el if it looks like bad content based on rules.""" if node.tag not in ('form', 'table', 'ul', 'div', 'p'): return # this is not the tag we are looking for weight = get_class_weight(node) # content_score = LOOK up the content score for this nod...
[ "def", "clean_conditionally", "(", "node", ")", ":", "if", "node", ".", "tag", "not", "in", "(", "'form'", ",", "'table'", ",", "'ul'", ",", "'div'", ",", "'p'", ")", ":", "return", "# this is not the tag we are looking for", "weight", "=", "get_class_weight",...
Remove the clean_el if it looks like bad content based on rules.
[ "Remove", "the", "clean_el", "if", "it", "looks", "like", "bad", "content", "based", "on", "rules", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L227-L290
train
61,389
bookieio/breadability
breadability/readable.py
find_candidates
def find_candidates(document): """ Finds cadidate nodes for the readable version of the article. Here's we're going to remove unlikely nodes, find scores on the rest, clean up and return the final best match. """ nodes_to_score = set() should_remove = set() for node in document.iter():...
python
def find_candidates(document): """ Finds cadidate nodes for the readable version of the article. Here's we're going to remove unlikely nodes, find scores on the rest, clean up and return the final best match. """ nodes_to_score = set() should_remove = set() for node in document.iter():...
[ "def", "find_candidates", "(", "document", ")", ":", "nodes_to_score", "=", "set", "(", ")", "should_remove", "=", "set", "(", ")", "for", "node", "in", "document", ".", "iter", "(", ")", ":", "if", "is_unlikely_node", "(", "node", ")", ":", "logger", ...
Finds cadidate nodes for the readable version of the article. Here's we're going to remove unlikely nodes, find scores on the rest, clean up and return the final best match.
[ "Finds", "cadidate", "nodes", "for", "the", "readable", "version", "of", "the", "article", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L305-L327
train
61,390
bookieio/breadability
breadability/readable.py
is_bad_link
def is_bad_link(node): """ Helper to determine if the node is link that is useless. We've hit articles with many multiple links that should be cleaned out because they're just there to pollute the space. See tests for examples. """ if node.tag != "a": return False name = node.get("...
python
def is_bad_link(node): """ Helper to determine if the node is link that is useless. We've hit articles with many multiple links that should be cleaned out because they're just there to pollute the space. See tests for examples. """ if node.tag != "a": return False name = node.get("...
[ "def", "is_bad_link", "(", "node", ")", ":", "if", "node", ".", "tag", "!=", "\"a\"", ":", "return", "False", "name", "=", "node", ".", "get", "(", "\"name\"", ")", "href", "=", "node", ".", "get", "(", "\"href\"", ")", "if", "name", "and", "not", ...
Helper to determine if the node is link that is useless. We've hit articles with many multiple links that should be cleaned out because they're just there to pollute the space. See tests for examples.
[ "Helper", "to", "determine", "if", "the", "node", "is", "link", "that", "is", "useless", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L330-L350
train
61,391
bookieio/breadability
breadability/readable.py
Article.candidates
def candidates(self): """Generates list of candidates from the DOM.""" dom = self.dom if dom is None or len(dom) == 0: return None candidates, unlikely_candidates = find_candidates(dom) drop_nodes_with_parents(unlikely_candidates) return candidates
python
def candidates(self): """Generates list of candidates from the DOM.""" dom = self.dom if dom is None or len(dom) == 0: return None candidates, unlikely_candidates = find_candidates(dom) drop_nodes_with_parents(unlikely_candidates) return candidates
[ "def", "candidates", "(", "self", ")", ":", "dom", "=", "self", ".", "dom", "if", "dom", "is", "None", "or", "len", "(", "dom", ")", "==", "0", ":", "return", "None", "candidates", ",", "unlikely_candidates", "=", "find_candidates", "(", "dom", ")", ...
Generates list of candidates from the DOM.
[ "Generates", "list", "of", "candidates", "from", "the", "DOM", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L386-L395
train
61,392
bookieio/breadability
breadability/readable.py
Article._readable
def _readable(self): """The readable parsed article""" if not self.candidates: logger.info("No candidates found in document.") return self._handle_no_candidates() # right now we return the highest scoring candidate content best_candidates = sorted( (c...
python
def _readable(self): """The readable parsed article""" if not self.candidates: logger.info("No candidates found in document.") return self._handle_no_candidates() # right now we return the highest scoring candidate content best_candidates = sorted( (c...
[ "def", "_readable", "(", "self", ")", ":", "if", "not", "self", ".", "candidates", ":", "logger", ".", "info", "(", "\"No candidates found in document.\"", ")", "return", "self", ".", "_handle_no_candidates", "(", ")", "# right now we return the highest scoring candid...
The readable parsed article
[ "The", "readable", "parsed", "article" ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L410-L437
train
61,393
bookieio/breadability
breadability/readable.py
Article._handle_no_candidates
def _handle_no_candidates(self): """ If we fail to find a good candidate we need to find something else. """ # since we've not found a good candidate we're should help this if self.dom is not None and len(self.dom): dom = prep_article(self.dom) dom = build...
python
def _handle_no_candidates(self): """ If we fail to find a good candidate we need to find something else. """ # since we've not found a good candidate we're should help this if self.dom is not None and len(self.dom): dom = prep_article(self.dom) dom = build...
[ "def", "_handle_no_candidates", "(", "self", ")", ":", "# since we've not found a good candidate we're should help this", "if", "self", ".", "dom", "is", "not", "None", "and", "len", "(", "self", ".", "dom", ")", ":", "dom", "=", "prep_article", "(", "self", "."...
If we fail to find a good candidate we need to find something else.
[ "If", "we", "fail", "to", "find", "a", "good", "candidate", "we", "need", "to", "find", "something", "else", "." ]
95a364c43b00baf6664bea1997a7310827fb1ee9
https://github.com/bookieio/breadability/blob/95a364c43b00baf6664bea1997a7310827fb1ee9/breadability/readable.py#L446-L458
train
61,394
holtjma/msbwt
MUS/util.py
fastaIterator
def fastaIterator(fastaFN): ''' Iterator that yields tuples containing a sequence label and the sequence itself @param fastaFN - the FASTA filename to open and parse @return - an iterator yielding tuples of the form (label, sequence) from the FASTA file ''' if fastaFN[len(fastaFN)-3:] == '.gz': ...
python
def fastaIterator(fastaFN): ''' Iterator that yields tuples containing a sequence label and the sequence itself @param fastaFN - the FASTA filename to open and parse @return - an iterator yielding tuples of the form (label, sequence) from the FASTA file ''' if fastaFN[len(fastaFN)-3:] == '.gz': ...
[ "def", "fastaIterator", "(", "fastaFN", ")", ":", "if", "fastaFN", "[", "len", "(", "fastaFN", ")", "-", "3", ":", "]", "==", "'.gz'", ":", "fp", "=", "gzip", ".", "open", "(", "fastaFN", ",", "'r'", ")", "else", ":", "fp", "=", "open", "(", "f...
Iterator that yields tuples containing a sequence label and the sequence itself @param fastaFN - the FASTA filename to open and parse @return - an iterator yielding tuples of the form (label, sequence) from the FASTA file
[ "Iterator", "that", "yields", "tuples", "containing", "a", "sequence", "label", "and", "the", "sequence", "itself" ]
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/util.py#L110-L137
train
61,395
holtjma/msbwt
MUS/MultiStringBWT.py
loadBWT
def loadBWT(bwtDir, logger=None): ''' Generic load function, this is recommended for anyone wishing to use this code as it will automatically detect compression and assign the appropriate class preferring the decompressed version if both exist. @return - a MultiStringBWT, CompressedBWT, or none if neith...
python
def loadBWT(bwtDir, logger=None): ''' Generic load function, this is recommended for anyone wishing to use this code as it will automatically detect compression and assign the appropriate class preferring the decompressed version if both exist. @return - a MultiStringBWT, CompressedBWT, or none if neith...
[ "def", "loadBWT", "(", "bwtDir", ",", "logger", "=", "None", ")", ":", "if", "os", ".", "path", ".", "exists", "(", "bwtDir", "+", "'/msbwt.npy'", ")", ":", "msbwt", "=", "MultiStringBWT", "(", ")", "msbwt", ".", "loadMsbwt", "(", "bwtDir", ",", "log...
Generic load function, this is recommended for anyone wishing to use this code as it will automatically detect compression and assign the appropriate class preferring the decompressed version if both exist. @return - a MultiStringBWT, CompressedBWT, or none if neither can be instantiated
[ "Generic", "load", "function", "this", "is", "recommended", "for", "anyone", "wishing", "to", "use", "this", "code", "as", "it", "will", "automatically", "detect", "compression", "and", "assign", "the", "appropriate", "class", "preferring", "the", "decompressed", ...
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/MultiStringBWT.py#L730-L746
train
61,396
holtjma/msbwt
MUS/MultiStringBWT.py
createMSBWTFromSeqs
def createMSBWTFromSeqs(seqArray, mergedDir, numProcs, areUniform, logger): ''' This function takes a series of sequences and creates the BWT using the technique from Cox and Bauer @param seqArray - a list of '$'-terminated sequences to be in the MSBWT @param mergedFN - the final destination filename fo...
python
def createMSBWTFromSeqs(seqArray, mergedDir, numProcs, areUniform, logger): ''' This function takes a series of sequences and creates the BWT using the technique from Cox and Bauer @param seqArray - a list of '$'-terminated sequences to be in the MSBWT @param mergedFN - the final destination filename fo...
[ "def", "createMSBWTFromSeqs", "(", "seqArray", ",", "mergedDir", ",", "numProcs", ",", "areUniform", ",", "logger", ")", ":", "#wipe the auxiliary data stored here", "MSBWTGen", ".", "clearAuxiliaryData", "(", "mergedDir", ")", "#TODO: do we want a special case for N=1? the...
This function takes a series of sequences and creates the BWT using the technique from Cox and Bauer @param seqArray - a list of '$'-terminated sequences to be in the MSBWT @param mergedFN - the final destination filename for the BWT @param numProcs - the number of processes it's allowed to use
[ "This", "function", "takes", "a", "series", "of", "sequences", "and", "creates", "the", "BWT", "using", "the", "technique", "from", "Cox", "and", "Bauer" ]
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/MultiStringBWT.py#L748-L776
train
61,397
holtjma/msbwt
MUS/MultiStringBWT.py
createMSBWTFromFastq
def createMSBWTFromFastq(fastqFNs, outputDir, numProcs, areUniform, logger): ''' This function takes fasta filenames and creates the BWT using the technique from Cox and Bauer by simply loading all string prior to computation @param fastqFNs - a list of fastq filenames to extract sequences from @par...
python
def createMSBWTFromFastq(fastqFNs, outputDir, numProcs, areUniform, logger): ''' This function takes fasta filenames and creates the BWT using the technique from Cox and Bauer by simply loading all string prior to computation @param fastqFNs - a list of fastq filenames to extract sequences from @par...
[ "def", "createMSBWTFromFastq", "(", "fastqFNs", ",", "outputDir", ",", "numProcs", ",", "areUniform", ",", "logger", ")", ":", "#generate the files we will reference and clear out the in memory array before making the BWT", "logger", ".", "info", "(", "'Saving sorted sequences....
This function takes fasta filenames and creates the BWT using the technique from Cox and Bauer by simply loading all string prior to computation @param fastqFNs - a list of fastq filenames to extract sequences from @param outputDir - the directory for all of the bwt related data @param numProcs - the nu...
[ "This", "function", "takes", "fasta", "filenames", "and", "creates", "the", "BWT", "using", "the", "technique", "from", "Cox", "and", "Bauer", "by", "simply", "loading", "all", "string", "prior", "to", "computation" ]
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/MultiStringBWT.py#L778-L796
train
61,398
holtjma/msbwt
MUS/MultiStringBWT.py
createMSBWTFromBam
def createMSBWTFromBam(bamFNs, outputDir, numProcs, areUniform, logger): ''' This function takes a fasta filename and creates the BWT using the technique from Cox and Bauer @param bamFNs - a list of BAM filenames to extract sequences from, READS MUST BE SORTED BY NAME @param outputDir - the directory fo...
python
def createMSBWTFromBam(bamFNs, outputDir, numProcs, areUniform, logger): ''' This function takes a fasta filename and creates the BWT using the technique from Cox and Bauer @param bamFNs - a list of BAM filenames to extract sequences from, READS MUST BE SORTED BY NAME @param outputDir - the directory fo...
[ "def", "createMSBWTFromBam", "(", "bamFNs", ",", "outputDir", ",", "numProcs", ",", "areUniform", ",", "logger", ")", ":", "#generate the files we will reference and clear out the in memory array before making the BWT", "logger", ".", "info", "(", "'Saving sorted sequences...'"...
This function takes a fasta filename and creates the BWT using the technique from Cox and Bauer @param bamFNs - a list of BAM filenames to extract sequences from, READS MUST BE SORTED BY NAME @param outputDir - the directory for all of the bwt related data @param numProcs - the number of processes it's allo...
[ "This", "function", "takes", "a", "fasta", "filename", "and", "creates", "the", "BWT", "using", "the", "technique", "from", "Cox", "and", "Bauer" ]
7503346ec072ddb89520db86fef85569a9ba093a
https://github.com/holtjma/msbwt/blob/7503346ec072ddb89520db86fef85569a9ba093a/MUS/MultiStringBWT.py#L798-L815
train
61,399