repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
frasertweedale/ledgertools
ltlib/config.py
Config.rulefiles
def rulefiles(self, acc=None): """Return a list of rulefiles for the given account. Returns an empty list if none specified. """ rulesdir = self.rulesdir(acc) rules = [os.path.join(rulesdir, x) for x in self.get('rules', acc, [])] if acc is not None: rules +=...
python
def rulefiles(self, acc=None): """Return a list of rulefiles for the given account. Returns an empty list if none specified. """ rulesdir = self.rulesdir(acc) rules = [os.path.join(rulesdir, x) for x in self.get('rules', acc, [])] if acc is not None: rules +=...
[ "def", "rulefiles", "(", "self", ",", "acc", "=", "None", ")", ":", "rulesdir", "=", "self", ".", "rulesdir", "(", "acc", ")", "rules", "=", "[", "os", ".", "path", ".", "join", "(", "rulesdir", ",", "x", ")", "for", "x", "in", "self", ".", "ge...
Return a list of rulefiles for the given account. Returns an empty list if none specified.
[ "Return", "a", "list", "of", "rulefiles", "for", "the", "given", "account", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/config.py#L138-L147
train
Return a list of rulefiles for the given account.
geophysics-ubonn/reda
lib/reda/utils/data.py
download_data
def download_data(identifier, outdir): """Download data from a separate data repository for testing. Parameters ---------- identifier: string The identifier used to find the data set outdir: string unzip the data in this directory """ # determine target if use_local_data...
python
def download_data(identifier, outdir): """Download data from a separate data repository for testing. Parameters ---------- identifier: string The identifier used to find the data set outdir: string unzip the data in this directory """ # determine target if use_local_data...
[ "def", "download_data", "(", "identifier", ",", "outdir", ")", ":", "# determine target", "if", "use_local_data_repository", "is", "not", "None", ":", "url_base", "=", "'file:'", "+", "request", ".", "pathname2url", "(", "use_local_data_repository", "+", "os", "."...
Download data from a separate data repository for testing. Parameters ---------- identifier: string The identifier used to find the data set outdir: string unzip the data in this directory
[ "Download", "data", "from", "a", "separate", "data", "repository", "for", "testing", "." ]
46a939729e40c7c4723315c03679c40761152e9e
https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/data.py#L21-L66
train
Download data from a separate data repository for testing.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_annotations_and_semacts_parser.py
ShexAnnotationAndSemactsParser.visitAnnotation
def visitAnnotation(self, ctx: ShExDocParser.AnnotationContext): """ annotation: '//' predicate (iri | literal) """ # Annotations apply to the expression, NOT the shape (!) annot = Annotation(self.context.predicate_to_IRI(ctx.predicate())) if ctx.iri(): annot.object = self.co...
python
def visitAnnotation(self, ctx: ShExDocParser.AnnotationContext): """ annotation: '//' predicate (iri | literal) """ # Annotations apply to the expression, NOT the shape (!) annot = Annotation(self.context.predicate_to_IRI(ctx.predicate())) if ctx.iri(): annot.object = self.co...
[ "def", "visitAnnotation", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "AnnotationContext", ")", ":", "# Annotations apply to the expression, NOT the shape (!)", "annot", "=", "Annotation", "(", "self", ".", "context", ".", "predicate_to_IRI", "(", "ctx", ".", ...
annotation: '//' predicate (iri | literal)
[ "annotation", ":", "//", "predicate", "(", "iri", "|", "literal", ")" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_annotations_and_semacts_parser.py#L42-L50
train
Annotation is an annotation that is a predicate iri | literal
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_annotations_and_semacts_parser.py
ShexAnnotationAndSemactsParser.visitCodeDecl
def visitCodeDecl(self, ctx: ShExDocParser.CodeDeclContext): """ codeDecl: '%' iri (CODE | '%') CODE: : '{' (~[%\\] | '\\' [%\\] | UCHAR)* '%' '}' """ semact = SemAct() semact.name = self.context.iri_to_iriref(ctx.iri()) if ctx.CODE(): semact.code = ctx.CODE().ge...
python
def visitCodeDecl(self, ctx: ShExDocParser.CodeDeclContext): """ codeDecl: '%' iri (CODE | '%') CODE: : '{' (~[%\\] | '\\' [%\\] | UCHAR)* '%' '}' """ semact = SemAct() semact.name = self.context.iri_to_iriref(ctx.iri()) if ctx.CODE(): semact.code = ctx.CODE().ge...
[ "def", "visitCodeDecl", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "CodeDeclContext", ")", ":", "semact", "=", "SemAct", "(", ")", "semact", ".", "name", "=", "self", ".", "context", ".", "iri_to_iriref", "(", "ctx", ".", "iri", "(", ")", ")",...
codeDecl: '%' iri (CODE | '%') CODE: : '{' (~[%\\] | '\\' [%\\] | UCHAR)* '%' '}'
[ "codeDecl", ":", "%", "iri", "(", "CODE", "|", "%", ")", "CODE", ":", ":", "{", "(", "~", "[", "%", "\\\\", "]", "|", "\\\\", "[", "%", "\\\\", "]", "|", "UCHAR", ")", "*", "%", "}" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_annotations_and_semacts_parser.py#L52-L59
train
visit CodeDeclContext - > add semact to self. semacts
frasertweedale/ledgertools
ltlib/score.py
ScoreSet.append
def append(self, item): """Append an item to the score set. item is a pair tuple, the first element of which is a valid dict key and the second of which is a numeric value. """ if item in self: self.items[item[0]].append(item[1]) else: self.items[...
python
def append(self, item): """Append an item to the score set. item is a pair tuple, the first element of which is a valid dict key and the second of which is a numeric value. """ if item in self: self.items[item[0]].append(item[1]) else: self.items[...
[ "def", "append", "(", "self", ",", "item", ")", ":", "if", "item", "in", "self", ":", "self", ".", "items", "[", "item", "[", "0", "]", "]", ".", "append", "(", "item", "[", "1", "]", ")", "else", ":", "self", ".", "items", "[", "item", "[", ...
Append an item to the score set. item is a pair tuple, the first element of which is a valid dict key and the second of which is a numeric value.
[ "Append", "an", "item", "to", "the", "score", "set", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/score.py#L34-L43
train
Append an item to the score set.
frasertweedale/ledgertools
ltlib/score.py
ScoreSet.scores
def scores(self): """Return a list of the items with their final scores. The final score of each item is its average score multiplied by the square root of its length. This reduces to sum * len^(-1/2). """ return map( lambda x: (x[0], sum(x[1]) * len(x[1]) ** -.5), ...
python
def scores(self): """Return a list of the items with their final scores. The final score of each item is its average score multiplied by the square root of its length. This reduces to sum * len^(-1/2). """ return map( lambda x: (x[0], sum(x[1]) * len(x[1]) ** -.5), ...
[ "def", "scores", "(", "self", ")", ":", "return", "map", "(", "lambda", "x", ":", "(", "x", "[", "0", "]", ",", "sum", "(", "x", "[", "1", "]", ")", "*", "len", "(", "x", "[", "1", "]", ")", "**", "-", ".5", ")", ",", "iter", "(", "self...
Return a list of the items with their final scores. The final score of each item is its average score multiplied by the square root of its length. This reduces to sum * len^(-1/2).
[ "Return", "a", "list", "of", "the", "items", "with", "their", "final", "scores", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/score.py#L45-L54
train
Return a list of the items with their final scores.
frasertweedale/ledgertools
ltlib/score.py
ScoreSet.highest
def highest(self): """Return the items with the higest score. If this ScoreSet is empty, returns None. """ scores = self.scores() if not scores: return None maxscore = max(map(score, scores)) return filter(lambda x: score(x) == maxscore, scores)
python
def highest(self): """Return the items with the higest score. If this ScoreSet is empty, returns None. """ scores = self.scores() if not scores: return None maxscore = max(map(score, scores)) return filter(lambda x: score(x) == maxscore, scores)
[ "def", "highest", "(", "self", ")", ":", "scores", "=", "self", ".", "scores", "(", ")", "if", "not", "scores", ":", "return", "None", "maxscore", "=", "max", "(", "map", "(", "score", ",", "scores", ")", ")", "return", "filter", "(", "lambda", "x"...
Return the items with the higest score. If this ScoreSet is empty, returns None.
[ "Return", "the", "items", "with", "the", "higest", "score", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/score.py#L56-L65
train
Return the items with the higest score.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.iriref_to_str
def iriref_to_str(self, ref: ShExDocParser.IRIREF) -> str: """ IRIREF: '<' (~[\u0000-\u0020=<>\"{}|^`\\] | UCHAR)* '>' """ rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape') return rval if ':' in rval or not self.base else self.base.val + rval
python
def iriref_to_str(self, ref: ShExDocParser.IRIREF) -> str: """ IRIREF: '<' (~[\u0000-\u0020=<>\"{}|^`\\] | UCHAR)* '>' """ rval = ref.getText()[1:-1].encode('utf-8').decode('unicode-escape') return rval if ':' in rval or not self.base else self.base.val + rval
[ "def", "iriref_to_str", "(", "self", ",", "ref", ":", "ShExDocParser", ".", "IRIREF", ")", "->", "str", ":", "rval", "=", "ref", ".", "getText", "(", ")", "[", "1", ":", "-", "1", "]", ".", "encode", "(", "'utf-8'", ")", ".", "decode", "(", "'uni...
IRIREF: '<' (~[\u0000-\u0020=<>\"{}|^`\\] | UCHAR)* '>'
[ "IRIREF", ":", "<", "(", "~", "[", "\\", "u0000", "-", "\\", "u0020", "=", "<", ">", "\\", "{}", "|^", "\\\\", "]", "|", "UCHAR", ")", "*", ">" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L65-L68
train
Converts an IRIREF to a string.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.iriref_to_shexj_iriref
def iriref_to_shexj_iriref(self, ref: ShExDocParser.IRIREF) -> ShExJ.IRIREF: """ IRIREF: '<' (~[\u0000-\u0020=<>\"{}|^`\\] | UCHAR)* '>' IRI: (PN_CHARS | '!' | ''.' | ':' | '/' | '\\' | '#' | '@' | '%' | '&' | UCHAR)* """ return ShExJ.IRIREF(self.iriref_to_str(ref))
python
def iriref_to_shexj_iriref(self, ref: ShExDocParser.IRIREF) -> ShExJ.IRIREF: """ IRIREF: '<' (~[\u0000-\u0020=<>\"{}|^`\\] | UCHAR)* '>' IRI: (PN_CHARS | '!' | ''.' | ':' | '/' | '\\' | '#' | '@' | '%' | '&' | UCHAR)* """ return ShExJ.IRIREF(self.iriref_to_str(ref))
[ "def", "iriref_to_shexj_iriref", "(", "self", ",", "ref", ":", "ShExDocParser", ".", "IRIREF", ")", "->", "ShExJ", ".", "IRIREF", ":", "return", "ShExJ", ".", "IRIREF", "(", "self", ".", "iriref_to_str", "(", "ref", ")", ")" ]
IRIREF: '<' (~[\u0000-\u0020=<>\"{}|^`\\] | UCHAR)* '>' IRI: (PN_CHARS | '!' | ''.' | ':' | '/' | '\\' | '#' | '@' | '%' | '&' | UCHAR)*
[ "IRIREF", ":", "<", "(", "~", "[", "\\", "u0000", "-", "\\", "u0020", "=", "<", ">", "\\", "{}", "|^", "\\\\", "]", "|", "UCHAR", ")", "*", ">", "IRI", ":", "(", "PN_CHARS", "|", "!", "|", ".", "|", ":", "|", "/", "|", "\\\\", "|", "#", ...
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L70-L73
train
Converts a ShExDocParser. IRIREF to a ShExJ. IRIREF
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.prefixedname_to_str
def prefixedname_to_str(self, prefix: ShExDocParser.PrefixedNameContext) -> str: """ prefixedName: PNAME_LN | PNAME_NS PNAME_NS: PN_PREFIX? ':' ; PNAME_LN: PNAME_NS PN_LOCAL ; """ if prefix.PNAME_NS(): return self._lookup_prefix(prefix.PNAME_NS().getText()) ...
python
def prefixedname_to_str(self, prefix: ShExDocParser.PrefixedNameContext) -> str: """ prefixedName: PNAME_LN | PNAME_NS PNAME_NS: PN_PREFIX? ':' ; PNAME_LN: PNAME_NS PN_LOCAL ; """ if prefix.PNAME_NS(): return self._lookup_prefix(prefix.PNAME_NS().getText()) ...
[ "def", "prefixedname_to_str", "(", "self", ",", "prefix", ":", "ShExDocParser", ".", "PrefixedNameContext", ")", "->", "str", ":", "if", "prefix", ".", "PNAME_NS", "(", ")", ":", "return", "self", ".", "_lookup_prefix", "(", "prefix", ".", "PNAME_NS", "(", ...
prefixedName: PNAME_LN | PNAME_NS PNAME_NS: PN_PREFIX? ':' ; PNAME_LN: PNAME_NS PN_LOCAL ;
[ "prefixedName", ":", "PNAME_LN", "|", "PNAME_NS", "PNAME_NS", ":", "PN_PREFIX?", ":", ";", "PNAME_LN", ":", "PNAME_NS", "PN_LOCAL", ";" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L75-L84
train
Returns the string representation of a prefixed name.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.prefixedname_to_iriref
def prefixedname_to_iriref(self, prefix: ShExDocParser.PrefixedNameContext) -> ShExJ.IRIREF: """ prefixedName: PNAME_LN | PNAME_NS PNAME_NS: PN_PREFIX? ':' ; PNAME_LN: PNAME_NS PN_LOCAL ; """ return ShExJ.IRIREF(self.prefixedname_to_str(prefix))
python
def prefixedname_to_iriref(self, prefix: ShExDocParser.PrefixedNameContext) -> ShExJ.IRIREF: """ prefixedName: PNAME_LN | PNAME_NS PNAME_NS: PN_PREFIX? ':' ; PNAME_LN: PNAME_NS PN_LOCAL ; """ return ShExJ.IRIREF(self.prefixedname_to_str(prefix))
[ "def", "prefixedname_to_iriref", "(", "self", ",", "prefix", ":", "ShExDocParser", ".", "PrefixedNameContext", ")", "->", "ShExJ", ".", "IRIREF", ":", "return", "ShExJ", ".", "IRIREF", "(", "self", ".", "prefixedname_to_str", "(", "prefix", ")", ")" ]
prefixedName: PNAME_LN | PNAME_NS PNAME_NS: PN_PREFIX? ':' ; PNAME_LN: PNAME_NS PN_LOCAL ;
[ "prefixedName", ":", "PNAME_LN", "|", "PNAME_NS", "PNAME_NS", ":", "PN_PREFIX?", ":", ";", "PNAME_LN", ":", "PNAME_NS", "PN_LOCAL", ";" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L86-L91
train
Converts a prefixed name to an IRIREF.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.shapeRef_to_iriref
def shapeRef_to_iriref(self, ref: ShExDocParser.ShapeRefContext) -> ShExJ.IRIREF: """ shapeRef: ATPNAME_NS | ATPNAME_LN | '@' shapeExprLabel """ if ref.ATPNAME_NS(): return ShExJ.IRIREF(self._lookup_prefix(ref.ATPNAME_NS().getText()[1:])) elif ref.ATPNAME_LN(): prefix, lo...
python
def shapeRef_to_iriref(self, ref: ShExDocParser.ShapeRefContext) -> ShExJ.IRIREF: """ shapeRef: ATPNAME_NS | ATPNAME_LN | '@' shapeExprLabel """ if ref.ATPNAME_NS(): return ShExJ.IRIREF(self._lookup_prefix(ref.ATPNAME_NS().getText()[1:])) elif ref.ATPNAME_LN(): prefix, lo...
[ "def", "shapeRef_to_iriref", "(", "self", ",", "ref", ":", "ShExDocParser", ".", "ShapeRefContext", ")", "->", "ShExJ", ".", "IRIREF", ":", "if", "ref", ".", "ATPNAME_NS", "(", ")", ":", "return", "ShExJ", ".", "IRIREF", "(", "self", ".", "_lookup_prefix",...
shapeRef: ATPNAME_NS | ATPNAME_LN | '@' shapeExprLabel
[ "shapeRef", ":", "ATPNAME_NS", "|", "ATPNAME_LN", "|" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L93-L101
train
Convert a ShExShapeRefContext to an IRIREF.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.iri_to_str
def iri_to_str(self, iri_: ShExDocParser.IriContext) -> str: """ iri: IRIREF | prefixedName """ if iri_.IRIREF(): return self.iriref_to_str(iri_.IRIREF()) else: return self.prefixedname_to_str(iri_.prefixedName())
python
def iri_to_str(self, iri_: ShExDocParser.IriContext) -> str: """ iri: IRIREF | prefixedName """ if iri_.IRIREF(): return self.iriref_to_str(iri_.IRIREF()) else: return self.prefixedname_to_str(iri_.prefixedName())
[ "def", "iri_to_str", "(", "self", ",", "iri_", ":", "ShExDocParser", ".", "IriContext", ")", "->", "str", ":", "if", "iri_", ".", "IRIREF", "(", ")", ":", "return", "self", ".", "iriref_to_str", "(", "iri_", ".", "IRIREF", "(", ")", ")", "else", ":",...
iri: IRIREF | prefixedName
[ "iri", ":", "IRIREF", "|", "prefixedName" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L103-L109
train
Converts an IRI to a string.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.iri_to_iriref
def iri_to_iriref(self, iri_: ShExDocParser.IriContext) -> ShExJ.IRIREF: """ iri: IRIREF | prefixedName prefixedName: PNAME_LN | PNAME_NS """ return ShExJ.IRIREF(self.iri_to_str(iri_))
python
def iri_to_iriref(self, iri_: ShExDocParser.IriContext) -> ShExJ.IRIREF: """ iri: IRIREF | prefixedName prefixedName: PNAME_LN | PNAME_NS """ return ShExJ.IRIREF(self.iri_to_str(iri_))
[ "def", "iri_to_iriref", "(", "self", ",", "iri_", ":", "ShExDocParser", ".", "IriContext", ")", "->", "ShExJ", ".", "IRIREF", ":", "return", "ShExJ", ".", "IRIREF", "(", "self", ".", "iri_to_str", "(", "iri_", ")", ")" ]
iri: IRIREF | prefixedName prefixedName: PNAME_LN | PNAME_NS
[ "iri", ":", "IRIREF", "|", "prefixedName", "prefixedName", ":", "PNAME_LN", "|", "PNAME_NS" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L111-L115
train
Converts an IRI to an IRIREF.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.tripleexprlabel_to_iriref
def tripleexprlabel_to_iriref(self, tripleExprLabel: ShExDocParser.TripleExprLabelContext) \ -> Union[ShExJ.BNODE, ShExJ.IRIREF]: """ tripleExprLabel: iri | blankNode """ if tripleExprLabel.iri(): return self.iri_to_iriref(tripleExprLabel.iri()) else: return S...
python
def tripleexprlabel_to_iriref(self, tripleExprLabel: ShExDocParser.TripleExprLabelContext) \ -> Union[ShExJ.BNODE, ShExJ.IRIREF]: """ tripleExprLabel: iri | blankNode """ if tripleExprLabel.iri(): return self.iri_to_iriref(tripleExprLabel.iri()) else: return S...
[ "def", "tripleexprlabel_to_iriref", "(", "self", ",", "tripleExprLabel", ":", "ShExDocParser", ".", "TripleExprLabelContext", ")", "->", "Union", "[", "ShExJ", ".", "BNODE", ",", "ShExJ", ".", "IRIREF", "]", ":", "if", "tripleExprLabel", ".", "iri", "(", ")", ...
tripleExprLabel: iri | blankNode
[ "tripleExprLabel", ":", "iri", "|", "blankNode" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L117-L123
train
Converts a triple expression label to an IRIREF.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.shapeexprlabel_to_IRI
def shapeexprlabel_to_IRI(self, shapeExprLabel: ShExDocParser.ShapeExprLabelContext) \ -> Union[ShExJ.BNODE, ShExJ.IRIREF]: """ shapeExprLabel: iri | blankNode """ if shapeExprLabel.iri(): return self.iri_to_iriref(shapeExprLabel.iri()) else: return ShExJ.BNOD...
python
def shapeexprlabel_to_IRI(self, shapeExprLabel: ShExDocParser.ShapeExprLabelContext) \ -> Union[ShExJ.BNODE, ShExJ.IRIREF]: """ shapeExprLabel: iri | blankNode """ if shapeExprLabel.iri(): return self.iri_to_iriref(shapeExprLabel.iri()) else: return ShExJ.BNOD...
[ "def", "shapeexprlabel_to_IRI", "(", "self", ",", "shapeExprLabel", ":", "ShExDocParser", ".", "ShapeExprLabelContext", ")", "->", "Union", "[", "ShExJ", ".", "BNODE", ",", "ShExJ", ".", "IRIREF", "]", ":", "if", "shapeExprLabel", ".", "iri", "(", ")", ":", ...
shapeExprLabel: iri | blankNode
[ "shapeExprLabel", ":", "iri", "|", "blankNode" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L125-L131
train
\ Returns the IRI for the given shapeExprLabel.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.predicate_to_IRI
def predicate_to_IRI(self, predicate: ShExDocParser.PredicateContext) -> ShExJ.IRIREF: """ predicate: iri | rdfType """ if predicate.iri(): return self.iri_to_iriref(predicate.iri()) else: return RDF_TYPE
python
def predicate_to_IRI(self, predicate: ShExDocParser.PredicateContext) -> ShExJ.IRIREF: """ predicate: iri | rdfType """ if predicate.iri(): return self.iri_to_iriref(predicate.iri()) else: return RDF_TYPE
[ "def", "predicate_to_IRI", "(", "self", ",", "predicate", ":", "ShExDocParser", ".", "PredicateContext", ")", "->", "ShExJ", ".", "IRIREF", ":", "if", "predicate", ".", "iri", "(", ")", ":", "return", "self", ".", "iri_to_iriref", "(", "predicate", ".", "i...
predicate: iri | rdfType
[ "predicate", ":", "iri", "|", "rdfType" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L133-L138
train
Converts predicate to IRIREF
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.numeric_literal_to_type
def numeric_literal_to_type(numlit: ShExDocParser.NumericLiteralContext) -> Union[jsg.Integer, jsg.Number]: """ numericLiteral: INTEGER | DECIMAL | DOUBLE """ if numlit.INTEGER(): rval = jsg.Integer(str(int(numlit.INTEGER().getText()))) elif numlit.DECIMAL(): rval = jsg.N...
python
def numeric_literal_to_type(numlit: ShExDocParser.NumericLiteralContext) -> Union[jsg.Integer, jsg.Number]: """ numericLiteral: INTEGER | DECIMAL | DOUBLE """ if numlit.INTEGER(): rval = jsg.Integer(str(int(numlit.INTEGER().getText()))) elif numlit.DECIMAL(): rval = jsg.N...
[ "def", "numeric_literal_to_type", "(", "numlit", ":", "ShExDocParser", ".", "NumericLiteralContext", ")", "->", "Union", "[", "jsg", ".", "Integer", ",", "jsg", ".", "Number", "]", ":", "if", "numlit", ".", "INTEGER", "(", ")", ":", "rval", "=", "jsg", "...
numericLiteral: INTEGER | DECIMAL | DOUBLE
[ "numericLiteral", ":", "INTEGER", "|", "DECIMAL", "|", "DOUBLE" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L141-L149
train
Converts a numeric literal to a type in the format of Int Decimal or Double.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.literal_to_ObjectLiteral
def literal_to_ObjectLiteral(self, literal: ShExDocParser.LiteralContext) -> ShExJ.ObjectLiteral: """ literal: rdfLiteral | numericLiteral | booleanLiteral """ rval = ShExJ.ObjectLiteral() if literal.rdfLiteral(): rdflit = literal.rdfLiteral() txt = rdflit.string().getTex...
python
def literal_to_ObjectLiteral(self, literal: ShExDocParser.LiteralContext) -> ShExJ.ObjectLiteral: """ literal: rdfLiteral | numericLiteral | booleanLiteral """ rval = ShExJ.ObjectLiteral() if literal.rdfLiteral(): rdflit = literal.rdfLiteral() txt = rdflit.string().getTex...
[ "def", "literal_to_ObjectLiteral", "(", "self", ",", "literal", ":", "ShExDocParser", ".", "LiteralContext", ")", "->", "ShExJ", ".", "ObjectLiteral", ":", "rval", "=", "ShExJ", ".", "ObjectLiteral", "(", ")", "if", "literal", ".", "rdfLiteral", "(", ")", ":...
literal: rdfLiteral | numericLiteral | booleanLiteral
[ "literal", ":", "rdfLiteral", "|", "numericLiteral", "|", "booleanLiteral" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L151-L185
train
Converts a literal to an object literal.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.is_empty_shape
def is_empty_shape(sh: ShExJ.Shape) -> bool: """ Determine whether sh has any value """ return sh.closed is None and sh.expression is None and sh.extra is None and \ sh.semActs is None
python
def is_empty_shape(sh: ShExJ.Shape) -> bool: """ Determine whether sh has any value """ return sh.closed is None and sh.expression is None and sh.extra is None and \ sh.semActs is None
[ "def", "is_empty_shape", "(", "sh", ":", "ShExJ", ".", "Shape", ")", "->", "bool", ":", "return", "sh", ".", "closed", "is", "None", "and", "sh", ".", "expression", "is", "None", "and", "sh", ".", "extra", "is", "None", "and", "sh", ".", "semActs", ...
Determine whether sh has any value
[ "Determine", "whether", "sh", "has", "any", "value" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L188-L191
train
Determines whether the shape is empty.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.fix_text_escapes
def fix_text_escapes(self, txt: str, quote_char: str) -> str: """ Fix the various text escapes """ def _subf(matchobj): return matchobj.group(0).translate(self.re_trans_table) if quote_char: txt = re.sub(r'\\'+quote_char, quote_char, txt) return re.sub(r'\\.', _su...
python
def fix_text_escapes(self, txt: str, quote_char: str) -> str: """ Fix the various text escapes """ def _subf(matchobj): return matchobj.group(0).translate(self.re_trans_table) if quote_char: txt = re.sub(r'\\'+quote_char, quote_char, txt) return re.sub(r'\\.', _su...
[ "def", "fix_text_escapes", "(", "self", ",", "txt", ":", "str", ",", "quote_char", ":", "str", ")", "->", "str", ":", "def", "_subf", "(", "matchobj", ")", ":", "return", "matchobj", ".", "group", "(", "0", ")", ".", "translate", "(", "self", ".", ...
Fix the various text escapes
[ "Fix", "the", "various", "text", "escapes" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L195-L201
train
Fix the various text escapes
shexSpec/grammar
parsers/python/pyshexc/parser_impl/parser_context.py
ParserContext.fix_re_escapes
def fix_re_escapes(self, txt: str) -> str: """ The ShEx RE engine allows escaping any character. We have to remove that escape for everything except those that CAN be legitimately escaped :param txt: text to be escaped """ def _subf(matchobj): # o = self.fix_text_es...
python
def fix_re_escapes(self, txt: str) -> str: """ The ShEx RE engine allows escaping any character. We have to remove that escape for everything except those that CAN be legitimately escaped :param txt: text to be escaped """ def _subf(matchobj): # o = self.fix_text_es...
[ "def", "fix_re_escapes", "(", "self", ",", "txt", ":", "str", ")", "->", "str", ":", "def", "_subf", "(", "matchobj", ")", ":", "# o = self.fix_text_escapes(matchobj.group(0))", "o", "=", "matchobj", ".", "group", "(", "0", ")", ".", "translate", "(", "sel...
The ShEx RE engine allows escaping any character. We have to remove that escape for everything except those that CAN be legitimately escaped :param txt: text to be escaped
[ "The", "ShEx", "RE", "engine", "allows", "escaping", "any", "character", ".", "We", "have", "to", "remove", "that", "escape", "for", "everything", "except", "those", "that", "CAN", "be", "legitimately", "escaped" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/parser_context.py#L203-L217
train
Fixes the escape sequences in the text.
moonso/query_phenomizer
query_phenomizer/cli.py
cli
def cli(ctx, hpo_term, check_terms, output, p_value_limit, verbose, username, password, to_json): "Give hpo terms either on the form 'HP:0001623', or '0001623'" loglevel = LEVELS.get(min(verbose, 3)) configure_stream(level=loglevel) if not hpo_term: logger.info("Please specify ...
python
def cli(ctx, hpo_term, check_terms, output, p_value_limit, verbose, username, password, to_json): "Give hpo terms either on the form 'HP:0001623', or '0001623'" loglevel = LEVELS.get(min(verbose, 3)) configure_stream(level=loglevel) if not hpo_term: logger.info("Please specify ...
[ "def", "cli", "(", "ctx", ",", "hpo_term", ",", "check_terms", ",", "output", ",", "p_value_limit", ",", "verbose", ",", "username", ",", "password", ",", "to_json", ")", ":", "loglevel", "=", "LEVELS", ".", "get", "(", "min", "(", "verbose", ",", "3",...
Give hpo terms either on the form 'HP:0001623', or '0001623
[ "Give", "hpo", "terms", "either", "on", "the", "form", "HP", ":", "0001623", "or", "0001623" ]
19883ed125e224fc17cbb71240428fd60082e017
https://github.com/moonso/query_phenomizer/blob/19883ed125e224fc17cbb71240428fd60082e017/query_phenomizer/cli.py#L62-L115
train
Give hpo terms either on the form HP :0001623 or HP :0001623
pennlabs/penn-sdk-python
penn/registrar.py
Registrar._iter_response
def _iter_response(self, url, params=None): """Return an enumerable that iterates through a multi-page API request""" if params is None: params = {} params['page_number'] = 1 # Last page lists itself as next page while True: response = self._request(url, ...
python
def _iter_response(self, url, params=None): """Return an enumerable that iterates through a multi-page API request""" if params is None: params = {} params['page_number'] = 1 # Last page lists itself as next page while True: response = self._request(url, ...
[ "def", "_iter_response", "(", "self", ",", "url", ",", "params", "=", "None", ")", ":", "if", "params", "is", "None", ":", "params", "=", "{", "}", "params", "[", "'page_number'", "]", "=", "1", "# Last page lists itself as next page", "while", "True", ":"...
Return an enumerable that iterates through a multi-page API request
[ "Return", "an", "enumerable", "that", "iterates", "through", "a", "multi", "-", "page", "API", "request" ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/registrar.py#L28-L45
train
Return an enumerable that iterates through a multi - page API request
pennlabs/penn-sdk-python
penn/registrar.py
Registrar.search
def search(self, params, validate=False): """Return a generator of section objects for the given search params. :param params: Dictionary of course search parameters. :param validate: Optional. Set to true to enable request validation. >>> cis100s = r.search({'course_id': 'cis', 'cours...
python
def search(self, params, validate=False): """Return a generator of section objects for the given search params. :param params: Dictionary of course search parameters. :param validate: Optional. Set to true to enable request validation. >>> cis100s = r.search({'course_id': 'cis', 'cours...
[ "def", "search", "(", "self", ",", "params", ",", "validate", "=", "False", ")", ":", "if", "self", ".", "val_info", "is", "None", ":", "self", ".", "val_info", "=", "self", ".", "search_params", "(", ")", "if", "validate", ":", "errors", "=", "self"...
Return a generator of section objects for the given search params. :param params: Dictionary of course search parameters. :param validate: Optional. Set to true to enable request validation. >>> cis100s = r.search({'course_id': 'cis', 'course_level_at_or_below': '200'})
[ "Return", "a", "generator", "of", "section", "objects", "for", "the", "given", "search", "params", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/registrar.py#L47-L63
train
Search for a set of course entries.
pennlabs/penn-sdk-python
penn/registrar.py
Registrar.course
def course(self, dept, course_number): """Return an object of semester-independent course info. All arguments should be strings. >>> cis120 = r.course('cis', '120') """ response = self._request(path.join(ENDPOINTS['CATALOG'], dept, course_number)) return response['result...
python
def course(self, dept, course_number): """Return an object of semester-independent course info. All arguments should be strings. >>> cis120 = r.course('cis', '120') """ response = self._request(path.join(ENDPOINTS['CATALOG'], dept, course_number)) return response['result...
[ "def", "course", "(", "self", ",", "dept", ",", "course_number", ")", ":", "response", "=", "self", ".", "_request", "(", "path", ".", "join", "(", "ENDPOINTS", "[", "'CATALOG'", "]", ",", "dept", ",", "course_number", ")", ")", "return", "response", "...
Return an object of semester-independent course info. All arguments should be strings. >>> cis120 = r.course('cis', '120')
[ "Return", "an", "object", "of", "semester", "-", "independent", "course", "info", ".", "All", "arguments", "should", "be", "strings", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/registrar.py#L65-L72
train
Return an object of semester - independent course info. All arguments are strings.
pennlabs/penn-sdk-python
penn/registrar.py
Registrar.section
def section(self, dept, course_number, sect_number): """Return a single section object for the given section. All arguments should be strings. Throws a `ValueError` if the section is not found. >>> lgst101_bfs = r.course('lgst', '101', '301') """ section_id = dept + course_numbe...
python
def section(self, dept, course_number, sect_number): """Return a single section object for the given section. All arguments should be strings. Throws a `ValueError` if the section is not found. >>> lgst101_bfs = r.course('lgst', '101', '301') """ section_id = dept + course_numbe...
[ "def", "section", "(", "self", ",", "dept", ",", "course_number", ",", "sect_number", ")", ":", "section_id", "=", "dept", "+", "course_number", "+", "sect_number", "sections", "=", "self", ".", "search", "(", "{", "'course_id'", ":", "section_id", "}", ")...
Return a single section object for the given section. All arguments should be strings. Throws a `ValueError` if the section is not found. >>> lgst101_bfs = r.course('lgst', '101', '301')
[ "Return", "a", "single", "section", "object", "for", "the", "given", "section", ".", "All", "arguments", "should", "be", "strings", ".", "Throws", "a", "ValueError", "if", "the", "section", "is", "not", "found", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/registrar.py#L80-L91
train
Return a single section object for the given section. All arguments should be strings. Throws a ValueError if the section is not found.
ikegami-yukino/asa-python
asa/asa.py
ASA.parse
def parse(self, sentence): """Parse the sentence Param: sentence (str) Return: result (list of dict) """ self.asa.stdin.write(sentence.encode(self.encoding) + b'\n') self.asa.stdin.flush() result = [] while not result: w...
python
def parse(self, sentence): """Parse the sentence Param: sentence (str) Return: result (list of dict) """ self.asa.stdin.write(sentence.encode(self.encoding) + b'\n') self.asa.stdin.flush() result = [] while not result: w...
[ "def", "parse", "(", "self", ",", "sentence", ")", ":", "self", ".", "asa", ".", "stdin", ".", "write", "(", "sentence", ".", "encode", "(", "self", ".", "encoding", ")", "+", "b'\\n'", ")", "self", ".", "asa", ".", "stdin", ".", "flush", "(", ")...
Parse the sentence Param: sentence (str) Return: result (list of dict)
[ "Parse", "the", "sentence", "Param", ":", "sentence", "(", "str", ")", "Return", ":", "result", "(", "list", "of", "dict", ")" ]
54bbdded06a9dbe79b6d2cdd30f98c1d0519f74a
https://github.com/ikegami-yukino/asa-python/blob/54bbdded06a9dbe79b6d2cdd30f98c1d0519f74a/asa/asa.py#L86-L103
train
Parse the sentence into a list of dict.
Metatab/geoid
geoid/core.py
parse_to_gvid
def parse_to_gvid(v): """Parse an ACS Geoid or a GVID to a GVID""" from geoid.civick import GVid from geoid.acs import AcsGeoid m1 = '' try: return GVid.parse(v) except ValueError as e: m1 = str(e) try: return AcsGeoid.parse(v).convert(GVid) except ValueError a...
python
def parse_to_gvid(v): """Parse an ACS Geoid or a GVID to a GVID""" from geoid.civick import GVid from geoid.acs import AcsGeoid m1 = '' try: return GVid.parse(v) except ValueError as e: m1 = str(e) try: return AcsGeoid.parse(v).convert(GVid) except ValueError a...
[ "def", "parse_to_gvid", "(", "v", ")", ":", "from", "geoid", ".", "civick", "import", "GVid", "from", "geoid", ".", "acs", "import", "AcsGeoid", "m1", "=", "''", "try", ":", "return", "GVid", ".", "parse", "(", "v", ")", "except", "ValueError", "as", ...
Parse an ACS Geoid or a GVID to a GVID
[ "Parse", "an", "ACS", "Geoid", "or", "a", "GVID", "to", "a", "GVID" ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L342-L357
train
Parse an ACS Geoid or a GVID to a GVID
Metatab/geoid
geoid/core.py
base62_decode
def base62_decode(string): """Decode a Base X encoded string into the number Arguments: - `string`: The encoded string - `alphabet`: The alphabet to use for encoding Stolen from: http://stackoverflow.com/a/1119769/1144479 """ alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP...
python
def base62_decode(string): """Decode a Base X encoded string into the number Arguments: - `string`: The encoded string - `alphabet`: The alphabet to use for encoding Stolen from: http://stackoverflow.com/a/1119769/1144479 """ alphabet = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP...
[ "def", "base62_decode", "(", "string", ")", ":", "alphabet", "=", "'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'", "base", "=", "len", "(", "alphabet", ")", "strlen", "=", "len", "(", "string", ")", "num", "=", "0", "idx", "=", "0", "for", "...
Decode a Base X encoded string into the number Arguments: - `string`: The encoded string - `alphabet`: The alphabet to use for encoding Stolen from: http://stackoverflow.com/a/1119769/1144479
[ "Decode", "a", "Base", "X", "encoded", "string", "into", "the", "number" ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L384-L405
train
Decode a Base X encoded string into a number of base X words.
Metatab/geoid
geoid/core.py
augment
def augment(module_name, base_class): """Call the augment() method for all of the derived classes in the module """ for name, cls in inspect.getmembers(sys.modules[module_name], lambda x : inspect.isclass(x) and issubclass(x, base_class) ): if cls == base_class:...
python
def augment(module_name, base_class): """Call the augment() method for all of the derived classes in the module """ for name, cls in inspect.getmembers(sys.modules[module_name], lambda x : inspect.isclass(x) and issubclass(x, base_class) ): if cls == base_class:...
[ "def", "augment", "(", "module_name", ",", "base_class", ")", ":", "for", "name", ",", "cls", "in", "inspect", ".", "getmembers", "(", "sys", ".", "modules", "[", "module_name", "]", ",", "lambda", "x", ":", "inspect", ".", "isclass", "(", "x", ")", ...
Call the augment() method for all of the derived classes in the module
[ "Call", "the", "augment", "()", "method", "for", "all", "of", "the", "derived", "classes", "in", "the", "module" ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L408-L416
train
Call the augment method for all derived classes in the module with the given name.
Metatab/geoid
geoid/core.py
make_classes
def make_classes(base_class, module): """Create derived classes and put them into the same module as the base class. This function is called at the end of each of the derived class modules, acs, census, civik and tiger. It will create a set of new derived class in the module, one for each of the enries in...
python
def make_classes(base_class, module): """Create derived classes and put them into the same module as the base class. This function is called at the end of each of the derived class modules, acs, census, civik and tiger. It will create a set of new derived class in the module, one for each of the enries in...
[ "def", "make_classes", "(", "base_class", ",", "module", ")", ":", "from", "functools", "import", "partial", "for", "k", "in", "names", ":", "cls", "=", "base_class", ".", "class_factory", "(", "k", ".", "capitalize", "(", ")", ")", "cls", ".", "augment"...
Create derived classes and put them into the same module as the base class. This function is called at the end of each of the derived class modules, acs, census, civik and tiger. It will create a set of new derived class in the module, one for each of the enries in the `summary_levels` dict.
[ "Create", "derived", "classes", "and", "put", "them", "into", "the", "same", "module", "as", "the", "base", "class", "." ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L428-L446
train
Create derived classes and put them into the same module as the base class.
Metatab/geoid
geoid/core.py
generate_all
def generate_all(sumlevel, d): """Generate a dict that includes all of the available geoid values, with keys for the most common names for those values. """ from geoid.civick import GVid from geoid.tiger import TigerGeoid from geoid.acs import AcsGeoid sumlevel = int(sumlevel) d = dict(d....
python
def generate_all(sumlevel, d): """Generate a dict that includes all of the available geoid values, with keys for the most common names for those values. """ from geoid.civick import GVid from geoid.tiger import TigerGeoid from geoid.acs import AcsGeoid sumlevel = int(sumlevel) d = dict(d....
[ "def", "generate_all", "(", "sumlevel", ",", "d", ")", ":", "from", "geoid", ".", "civick", "import", "GVid", "from", "geoid", ".", "tiger", "import", "TigerGeoid", "from", "geoid", ".", "acs", "import", "AcsGeoid", "sumlevel", "=", "int", "(", "sumlevel",...
Generate a dict that includes all of the available geoid values, with keys for the most common names for those values.
[ "Generate", "a", "dict", "that", "includes", "all", "of", "the", "available", "geoid", "values", "with", "keys", "for", "the", "most", "common", "names", "for", "those", "values", "." ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L887-L927
train
Generate a dict that includes all of the available geoid values with keys for the most common names for those values.
Metatab/geoid
geoid/core.py
_generate_names
def _generate_names(): """ Code to generate the state and county names >>> python -c 'import geoid; geoid._generate_names()' """ from ambry import get_library l = get_library() counties = l.partition('census.gov-acs-geofile-2009-geofile50-20095-50') states = l.partition('census.gov-acs-...
python
def _generate_names(): """ Code to generate the state and county names >>> python -c 'import geoid; geoid._generate_names()' """ from ambry import get_library l = get_library() counties = l.partition('census.gov-acs-geofile-2009-geofile50-20095-50') states = l.partition('census.gov-acs-...
[ "def", "_generate_names", "(", ")", ":", "from", "ambry", "import", "get_library", "l", "=", "get_library", "(", ")", "counties", "=", "l", ".", "partition", "(", "'census.gov-acs-geofile-2009-geofile50-20095-50'", ")", "states", "=", "l", ".", "partition", "(",...
Code to generate the state and county names >>> python -c 'import geoid; geoid._generate_names()'
[ "Code", "to", "generate", "the", "state", "and", "county", "names" ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L930-L952
train
Code to generate the state and county names for the county and county
Metatab/geoid
geoid/core.py
CountyName.division_name
def division_name(self): """The type designation for the county or county equivalent, such as 'County','Parish' or 'Borough'""" try: return next(e for e in self.type_names_re.search(self.name).groups() if e is not None) except AttributeError: # The search will fail for 'D...
python
def division_name(self): """The type designation for the county or county equivalent, such as 'County','Parish' or 'Borough'""" try: return next(e for e in self.type_names_re.search(self.name).groups() if e is not None) except AttributeError: # The search will fail for 'D...
[ "def", "division_name", "(", "self", ")", ":", "try", ":", "return", "next", "(", "e", "for", "e", "in", "self", ".", "type_names_re", ".", "search", "(", "self", ".", "name", ")", ".", "groups", "(", ")", "if", "e", "is", "not", "None", ")", "ex...
The type designation for the county or county equivalent, such as 'County','Parish' or 'Borough
[ "The", "type", "designation", "for", "the", "county", "or", "county", "equivalent", "such", "as", "County", "Parish", "or", "Borough" ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L489-L495
train
The type designation for the county or county equivalent such as Parish Borough or District of Columbia
Metatab/geoid
geoid/core.py
Geoid.augment
def augment(cls): """Augment the class with computed formats, regexes, and other things. This caches these values so they don't have to be created for every instance. """ import re level_name = cls.__name__.lower() cls.sl = names[level_name] cls.class_map[cls.__name__...
python
def augment(cls): """Augment the class with computed formats, regexes, and other things. This caches these values so they don't have to be created for every instance. """ import re level_name = cls.__name__.lower() cls.sl = names[level_name] cls.class_map[cls.__name__...
[ "def", "augment", "(", "cls", ")", ":", "import", "re", "level_name", "=", "cls", ".", "__name__", ".", "lower", "(", ")", "cls", ".", "sl", "=", "names", "[", "level_name", "]", "cls", ".", "class_map", "[", "cls", ".", "__name__", ".", "lower", "...
Augment the class with computed formats, regexes, and other things. This caches these values so they don't have to be created for every instance.
[ "Augment", "the", "class", "with", "computed", "formats", "regexes", "and", "other", "things", ".", "This", "caches", "these", "values", "so", "they", "don", "t", "have", "to", "be", "created", "for", "every", "instance", "." ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L562-L583
train
Augment the class with computed formats regexes and other things. This is a utility function that is used to augment the class with computed formats and regexes and other things.
Metatab/geoid
geoid/core.py
Geoid.get_class
def get_class(cls, name_or_sl): """Return a derived class based on the class name or the summary_level""" try: return cls.sl_map[int(name_or_sl)] except TypeError as e: raise TypeError("Bad name or sl: {} : {}".format(name_or_sl, e)) except ValueError: ...
python
def get_class(cls, name_or_sl): """Return a derived class based on the class name or the summary_level""" try: return cls.sl_map[int(name_or_sl)] except TypeError as e: raise TypeError("Bad name or sl: {} : {}".format(name_or_sl, e)) except ValueError: ...
[ "def", "get_class", "(", "cls", ",", "name_or_sl", ")", ":", "try", ":", "return", "cls", ".", "sl_map", "[", "int", "(", "name_or_sl", ")", "]", "except", "TypeError", "as", "e", ":", "raise", "TypeError", "(", "\"Bad name or sl: {} : {}\"", ".", "format"...
Return a derived class based on the class name or the summary_level
[ "Return", "a", "derived", "class", "based", "on", "the", "class", "name", "or", "the", "summary_level" ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L587-L598
train
Return a derived class based on the class name or the summary level
Metatab/geoid
geoid/core.py
Geoid.geo_name
def geo_name(self): """ Return a name of the state or county, or, for other lowever levels, the name of the level type in the county. :return: """ if self.level == 'county': return str(self.county_name) elif self.level == 'state': return ...
python
def geo_name(self): """ Return a name of the state or county, or, for other lowever levels, the name of the level type in the county. :return: """ if self.level == 'county': return str(self.county_name) elif self.level == 'state': return ...
[ "def", "geo_name", "(", "self", ")", ":", "if", "self", ".", "level", "==", "'county'", ":", "return", "str", "(", "self", ".", "county_name", ")", "elif", "self", ".", "level", "==", "'state'", ":", "return", "self", ".", "state_name", "else", ":", ...
Return a name of the state or county, or, for other lowever levels, the name of the level type in the county. :return:
[ "Return", "a", "name", "of", "the", "state", "or", "county", "or", "for", "other", "lowever", "levels", "the", "name", "of", "the", "level", "type", "in", "the", "county", "." ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L668-L689
train
Return a name of the state or county or the other lowever levels.
Metatab/geoid
geoid/core.py
Geoid.parse
def parse(cls, gvid, exception=True): """ Parse a string value into the geoid of this class. :param gvid: String value to parse. :param exception: If true ( default) raise an eception on parse erorrs. If False, return a 'null' geoid. :return: """ if gvid...
python
def parse(cls, gvid, exception=True): """ Parse a string value into the geoid of this class. :param gvid: String value to parse. :param exception: If true ( default) raise an eception on parse erorrs. If False, return a 'null' geoid. :return: """ if gvid...
[ "def", "parse", "(", "cls", ",", "gvid", ",", "exception", "=", "True", ")", ":", "if", "gvid", "==", "'invalid'", ":", "return", "cls", ".", "get_class", "(", "'null'", ")", "(", "0", ")", "if", "not", "bool", "(", "gvid", ")", ":", "return", "N...
Parse a string value into the geoid of this class. :param gvid: String value to parse. :param exception: If true ( default) raise an eception on parse erorrs. If False, return a 'null' geoid. :return:
[ "Parse", "a", "string", "value", "into", "the", "geoid", "of", "this", "class", "." ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L714-L781
train
Parse a string value into the geoid of this class.
Metatab/geoid
geoid/core.py
Geoid.convert
def convert(self, root_cls): """Convert to another derived class. cls is the base class for the derived type, ie AcsGeoid, TigerGeoid, etc. """ d = self.__dict__ d['sl'] = self.sl try: cls = root_cls.get_class(root_cls.sl) except (AttributeError, TypeError):...
python
def convert(self, root_cls): """Convert to another derived class. cls is the base class for the derived type, ie AcsGeoid, TigerGeoid, etc. """ d = self.__dict__ d['sl'] = self.sl try: cls = root_cls.get_class(root_cls.sl) except (AttributeError, TypeError):...
[ "def", "convert", "(", "self", ",", "root_cls", ")", ":", "d", "=", "self", ".", "__dict__", "d", "[", "'sl'", "]", "=", "self", ".", "sl", "try", ":", "cls", "=", "root_cls", ".", "get_class", "(", "root_cls", ".", "sl", ")", "except", "(", "Att...
Convert to another derived class. cls is the base class for the derived type, ie AcsGeoid, TigerGeoid, etc.
[ "Convert", "to", "another", "derived", "class", ".", "cls", "is", "the", "base", "class", "for", "the", "derived", "type", "ie", "AcsGeoid", "TigerGeoid", "etc", "." ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L783-L796
train
Convert to another derived class.
Metatab/geoid
geoid/core.py
Geoid.promote
def promote(self, level=None): """Convert to the next higher level summary level""" if level is None: if len(self.fields) < 2: if self.level in ('region', 'division', 'state', 'ua'): cls = self.get_class('us') else: re...
python
def promote(self, level=None): """Convert to the next higher level summary level""" if level is None: if len(self.fields) < 2: if self.level in ('region', 'division', 'state', 'ua'): cls = self.get_class('us') else: re...
[ "def", "promote", "(", "self", ",", "level", "=", "None", ")", ":", "if", "level", "is", "None", ":", "if", "len", "(", "self", ".", "fields", ")", "<", "2", ":", "if", "self", ".", "level", "in", "(", "'region'", ",", "'division'", ",", "'state'...
Convert to the next higher level summary level
[ "Convert", "to", "the", "next", "higher", "level", "summary", "level" ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L810-L828
train
Convert to the next higher level summary level
Metatab/geoid
geoid/core.py
Geoid.allval
def allval(self): """Convert the last value to zero. This form represents the entire higher summary level at the granularity of the lower summary level. For example, for a county, it means 'All counties in the state' """ d = dict(self.__dict__.items()) d['sl'] = self.sl d[self...
python
def allval(self): """Convert the last value to zero. This form represents the entire higher summary level at the granularity of the lower summary level. For example, for a county, it means 'All counties in the state' """ d = dict(self.__dict__.items()) d['sl'] = self.sl d[self...
[ "def", "allval", "(", "self", ")", ":", "d", "=", "dict", "(", "self", ".", "__dict__", ".", "items", "(", ")", ")", "d", "[", "'sl'", "]", "=", "self", ".", "sl", "d", "[", "self", ".", "level", "]", "=", "0", "cls", "=", "self", ".", "get...
Convert the last value to zero. This form represents the entire higher summary level at the granularity of the lower summary level. For example, for a county, it means 'All counties in the state'
[ "Convert", "the", "last", "value", "to", "zero", ".", "This", "form", "represents", "the", "entire", "higher", "summary", "level", "at", "the", "granularity", "of", "the", "lower", "summary", "level", ".", "For", "example", "for", "a", "county", "it", "mea...
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L835-L846
train
Convert the last value to zero. This form represents the entire higher summary level at the granularity
Metatab/geoid
geoid/core.py
Geoid.nullval
def nullval(cls): """Create a new instance where all of the values are 0""" d = dict(cls.__dict__.items()) for k in d: d[k] = 0 d['sl'] = cls.sl d[cls.level] = 0 return cls(**d)
python
def nullval(cls): """Create a new instance where all of the values are 0""" d = dict(cls.__dict__.items()) for k in d: d[k] = 0 d['sl'] = cls.sl d[cls.level] = 0 return cls(**d)
[ "def", "nullval", "(", "cls", ")", ":", "d", "=", "dict", "(", "cls", ".", "__dict__", ".", "items", "(", ")", ")", "for", "k", "in", "d", ":", "d", "[", "k", "]", "=", "0", "d", "[", "'sl'", "]", "=", "cls", ".", "sl", "d", "[", "cls", ...
Create a new instance where all of the values are 0
[ "Create", "a", "new", "instance", "where", "all", "of", "the", "values", "are", "0" ]
4b7769406b00e59376fb6046b42a2f8ed706b33b
https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/core.py#L849-L860
train
Create a new instance where all of the values are 0
andy-z/ged4py
ged4py/detail/name.py
split_name
def split_name(name): """Extracts pieces of name from full name string. Full name can have one of these formats: <NAME_TEXT> | /<NAME_TEXT>/ | <NAME_TEXT> /<NAME_TEXT>/ | /<NAME_TEXT>/ <NAME_TEXT> | <NAME_TEXT> /<NAME_TEXT>/ <NAME_TEXT> <NAME_TEXT> can include almos...
python
def split_name(name): """Extracts pieces of name from full name string. Full name can have one of these formats: <NAME_TEXT> | /<NAME_TEXT>/ | <NAME_TEXT> /<NAME_TEXT>/ | /<NAME_TEXT>/ <NAME_TEXT> | <NAME_TEXT> /<NAME_TEXT>/ <NAME_TEXT> <NAME_TEXT> can include almos...
[ "def", "split_name", "(", "name", ")", ":", "given1", ",", "_", ",", "rem", "=", "name", ".", "partition", "(", "\"/\"", ")", "surname", ",", "_", ",", "given2", "=", "rem", ".", "partition", "(", "\"/\"", ")", "return", "given1", ".", "strip", "("...
Extracts pieces of name from full name string. Full name can have one of these formats: <NAME_TEXT> | /<NAME_TEXT>/ | <NAME_TEXT> /<NAME_TEXT>/ | /<NAME_TEXT>/ <NAME_TEXT> | <NAME_TEXT> /<NAME_TEXT>/ <NAME_TEXT> <NAME_TEXT> can include almost anything excluding commas, ...
[ "Extracts", "pieces", "of", "name", "from", "full", "name", "string", "." ]
d0e0cceaadf0a84cbf052705e3c27303b12e1757
https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/detail/name.py#L7-L35
train
Splits a full name into pieces of name.
andy-z/ged4py
ged4py/detail/name.py
parse_name_altree
def parse_name_altree(record): """Parse NAME structure assuming ALTREE dialect. In ALTREE dialect maiden name (if present) is saved as SURN sub-record and is also appended to family name in parens. Given name is saved in GIVN sub-record. Few examples: No maiden name: 1 NAME John /Smith/ ...
python
def parse_name_altree(record): """Parse NAME structure assuming ALTREE dialect. In ALTREE dialect maiden name (if present) is saved as SURN sub-record and is also appended to family name in parens. Given name is saved in GIVN sub-record. Few examples: No maiden name: 1 NAME John /Smith/ ...
[ "def", "parse_name_altree", "(", "record", ")", ":", "name_tuple", "=", "split_name", "(", "record", ".", "value", ")", "if", "name_tuple", "[", "1", "]", "==", "'?'", ":", "name_tuple", "=", "(", "name_tuple", "[", "0", "]", ",", "''", ",", "name_tupl...
Parse NAME structure assuming ALTREE dialect. In ALTREE dialect maiden name (if present) is saved as SURN sub-record and is also appended to family name in parens. Given name is saved in GIVN sub-record. Few examples: No maiden name: 1 NAME John /Smith/ 2 GIVN John With maiden na...
[ "Parse", "NAME", "structure", "assuming", "ALTREE", "dialect", "." ]
d0e0cceaadf0a84cbf052705e3c27303b12e1757
https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/detail/name.py#L38-L85
train
Parse NAME record assuming ALTREE dialect.
andy-z/ged4py
ged4py/detail/name.py
parse_name_myher
def parse_name_myher(record): """Parse NAME structure assuming MYHERITAGE dialect. In MYHERITAGE dialect married name (if present) is saved as _MARNM sub-record. Maiden name is stored in SURN record. Few examples: No maiden name: 1 NAME John /Smith/ 2 GIVN John 2 SURN Smith ...
python
def parse_name_myher(record): """Parse NAME structure assuming MYHERITAGE dialect. In MYHERITAGE dialect married name (if present) is saved as _MARNM sub-record. Maiden name is stored in SURN record. Few examples: No maiden name: 1 NAME John /Smith/ 2 GIVN John 2 SURN Smith ...
[ "def", "parse_name_myher", "(", "record", ")", ":", "name_tuple", "=", "split_name", "(", "record", ".", "value", ")", "married", "=", "record", ".", "sub_tag_value", "(", "\"_MARNM\"", ")", "if", "married", ":", "maiden", "=", "name_tuple", "[", "1", "]",...
Parse NAME structure assuming MYHERITAGE dialect. In MYHERITAGE dialect married name (if present) is saved as _MARNM sub-record. Maiden name is stored in SURN record. Few examples: No maiden name: 1 NAME John /Smith/ 2 GIVN John 2 SURN Smith With maiden name: 1 NAME ...
[ "Parse", "NAME", "structure", "assuming", "MYHERITAGE", "dialect", "." ]
d0e0cceaadf0a84cbf052705e3c27303b12e1757
https://github.com/andy-z/ged4py/blob/d0e0cceaadf0a84cbf052705e3c27303b12e1757/ged4py/detail/name.py#L88-L127
train
Parse NAME structure assuming MYHERITAGE dialect.
gtaylor/django-athumb
athumb/pial/helpers.py
toint
def toint(number): """ Helper to return rounded int for a float or just the int it self. """ if isinstance(number, float): number = round(number, 0) return int(number)
python
def toint(number): """ Helper to return rounded int for a float or just the int it self. """ if isinstance(number, float): number = round(number, 0) return int(number)
[ "def", "toint", "(", "number", ")", ":", "if", "isinstance", "(", "number", ",", "float", ")", ":", "number", "=", "round", "(", "number", ",", "0", ")", "return", "int", "(", "number", ")" ]
Helper to return rounded int for a float or just the int it self.
[ "Helper", "to", "return", "rounded", "int", "for", "a", "float", "or", "just", "the", "int", "it", "self", "." ]
69261ace0dff81e33156a54440874456a7b38dfb
https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/pial/helpers.py#L6-L12
train
Helper to return rounded int for a float or just the int it self.
frasertweedale/ledgertools
ltlib/ui.py
number
def number(items): """Maps numbering onto given values""" n = len(items) if n == 0: return items places = str(int(math.log10(n) // 1 + 1)) format = '[{0[0]:' + str(int(places)) + 'd}] {0[1]}' return map( lambda x: format.format(x), enumerate(items) )
python
def number(items): """Maps numbering onto given values""" n = len(items) if n == 0: return items places = str(int(math.log10(n) // 1 + 1)) format = '[{0[0]:' + str(int(places)) + 'd}] {0[1]}' return map( lambda x: format.format(x), enumerate(items) )
[ "def", "number", "(", "items", ")", ":", "n", "=", "len", "(", "items", ")", "if", "n", "==", "0", ":", "return", "items", "places", "=", "str", "(", "int", "(", "math", ".", "log10", "(", "n", ")", "//", "1", "+", "1", ")", ")", "format", ...
Maps numbering onto given values
[ "Maps", "numbering", "onto", "given", "values" ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L35-L45
train
Maps numbering onto given values
frasertweedale/ledgertools
ltlib/ui.py
filter_yn
def filter_yn(string, default=None): """Return True if yes, False if no, or the default.""" if string.startswith(('Y', 'y')): return True elif string.startswith(('N', 'n')): return False elif not string and default is not None: return True if default else False raise InvalidI...
python
def filter_yn(string, default=None): """Return True if yes, False if no, or the default.""" if string.startswith(('Y', 'y')): return True elif string.startswith(('N', 'n')): return False elif not string and default is not None: return True if default else False raise InvalidI...
[ "def", "filter_yn", "(", "string", ",", "default", "=", "None", ")", ":", "if", "string", ".", "startswith", "(", "(", "'Y'", ",", "'y'", ")", ")", ":", "return", "True", "elif", "string", ".", "startswith", "(", "(", "'N'", ",", "'n'", ")", ")", ...
Return True if yes, False if no, or the default.
[ "Return", "True", "if", "yes", "False", "if", "no", "or", "the", "default", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L48-L56
train
Return True if yes False if no or the default.
frasertweedale/ledgertools
ltlib/ui.py
filter_int
def filter_int(string, default=None, start=None, stop=None): """Return the input integer, or the default.""" try: i = int(string) if start is not None and i < start: raise InvalidInputError("value too small") if stop is not None and i >= stop: raise InvalidInputEr...
python
def filter_int(string, default=None, start=None, stop=None): """Return the input integer, or the default.""" try: i = int(string) if start is not None and i < start: raise InvalidInputError("value too small") if stop is not None and i >= stop: raise InvalidInputEr...
[ "def", "filter_int", "(", "string", ",", "default", "=", "None", ",", "start", "=", "None", ",", "stop", "=", "None", ")", ":", "try", ":", "i", "=", "int", "(", "string", ")", "if", "start", "is", "not", "None", "and", "i", "<", "start", ":", ...
Return the input integer, or the default.
[ "Return", "the", "input", "integer", "or", "the", "default", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L59-L73
train
Return the input integer or the default.
frasertweedale/ledgertools
ltlib/ui.py
filter_decimal
def filter_decimal(string, default=None, lower=None, upper=None): """Return the input decimal number, or the default.""" try: d = decimal.Decimal(string) if lower is not None and d < lower: raise InvalidInputError("value too small") if upper is not None and d >= upper: ...
python
def filter_decimal(string, default=None, lower=None, upper=None): """Return the input decimal number, or the default.""" try: d = decimal.Decimal(string) if lower is not None and d < lower: raise InvalidInputError("value too small") if upper is not None and d >= upper: ...
[ "def", "filter_decimal", "(", "string", ",", "default", "=", "None", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "try", ":", "d", "=", "decimal", ".", "Decimal", "(", "string", ")", "if", "lower", "is", "not", "None", "and", "d"...
Return the input decimal number, or the default.
[ "Return", "the", "input", "decimal", "number", "or", "the", "default", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L76-L90
train
Return the input decimal number or the default.
frasertweedale/ledgertools
ltlib/ui.py
filter_pastdate
def filter_pastdate(string, default=None): """Coerce to a date not beyond the current date If only a day is given, assumes the current month if that day has passed or is the current day, otherwise assumes the previous month. If a day and month are given, but no year, assumes the current year if the...
python
def filter_pastdate(string, default=None): """Coerce to a date not beyond the current date If only a day is given, assumes the current month if that day has passed or is the current day, otherwise assumes the previous month. If a day and month are given, but no year, assumes the current year if the...
[ "def", "filter_pastdate", "(", "string", ",", "default", "=", "None", ")", ":", "if", "not", "string", "and", "default", "is", "not", "None", ":", "return", "default", "today", "=", "datetime", ".", "date", ".", "today", "(", ")", "# split the string", "...
Coerce to a date not beyond the current date If only a day is given, assumes the current month if that day has passed or is the current day, otherwise assumes the previous month. If a day and month are given, but no year, assumes the current year if the given date has passed (or is today), otherwise th...
[ "Coerce", "to", "a", "date", "not", "beyond", "the", "current", "date" ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L102-L148
train
Coerce to a date not beyond the current date
frasertweedale/ledgertools
ltlib/ui.py
UI.input
def input(self, filter_fn, prompt): """Prompt user until valid input is received. RejectWarning is raised if a KeyboardInterrupt is caught. """ while True: try: return filter_fn(raw_input(prompt)) except InvalidInputError as e: if ...
python
def input(self, filter_fn, prompt): """Prompt user until valid input is received. RejectWarning is raised if a KeyboardInterrupt is caught. """ while True: try: return filter_fn(raw_input(prompt)) except InvalidInputError as e: if ...
[ "def", "input", "(", "self", ",", "filter_fn", ",", "prompt", ")", ":", "while", "True", ":", "try", ":", "return", "filter_fn", "(", "raw_input", "(", "prompt", ")", ")", "except", "InvalidInputError", "as", "e", ":", "if", "e", ".", "message", ":", ...
Prompt user until valid input is received. RejectWarning is raised if a KeyboardInterrupt is caught.
[ "Prompt", "user", "until", "valid", "input", "is", "received", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L161-L173
train
Prompt user until valid input is received.
frasertweedale/ledgertools
ltlib/ui.py
UI.text
def text(self, prompt, default=None): """Prompts the user for some text, with optional default""" prompt = prompt if prompt is not None else 'Enter some text' prompt += " [{0}]: ".format(default) if default is not None else ': ' return self.input(curry(filter_text, default=default), prom...
python
def text(self, prompt, default=None): """Prompts the user for some text, with optional default""" prompt = prompt if prompt is not None else 'Enter some text' prompt += " [{0}]: ".format(default) if default is not None else ': ' return self.input(curry(filter_text, default=default), prom...
[ "def", "text", "(", "self", ",", "prompt", ",", "default", "=", "None", ")", ":", "prompt", "=", "prompt", "if", "prompt", "is", "not", "None", "else", "'Enter some text'", "prompt", "+=", "\" [{0}]: \"", ".", "format", "(", "default", ")", "if", "defaul...
Prompts the user for some text, with optional default
[ "Prompts", "the", "user", "for", "some", "text", "with", "optional", "default" ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L175-L179
train
Prompts the user for some text with optional default
frasertweedale/ledgertools
ltlib/ui.py
UI.decimal
def decimal(self, prompt, default=None, lower=None, upper=None): """Prompts user to input decimal, with optional default and bounds.""" prompt = prompt if prompt is not None else "Enter a decimal number" prompt += " [{0}]: ".format(default) if default is not None else ': ' return self.in...
python
def decimal(self, prompt, default=None, lower=None, upper=None): """Prompts user to input decimal, with optional default and bounds.""" prompt = prompt if prompt is not None else "Enter a decimal number" prompt += " [{0}]: ".format(default) if default is not None else ': ' return self.in...
[ "def", "decimal", "(", "self", ",", "prompt", ",", "default", "=", "None", ",", "lower", "=", "None", ",", "upper", "=", "None", ")", ":", "prompt", "=", "prompt", "if", "prompt", "is", "not", "None", "else", "\"Enter a decimal number\"", "prompt", "+=",...
Prompts user to input decimal, with optional default and bounds.
[ "Prompts", "user", "to", "input", "decimal", "with", "optional", "default", "and", "bounds", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L189-L196
train
Prompts user to input a decimal number with optional default and bounds.
frasertweedale/ledgertools
ltlib/ui.py
UI.pastdate
def pastdate(self, prompt, default=None): """Prompts user to input a date in the past.""" prompt = prompt if prompt is not None else "Enter a past date" if default is not None: prompt += " [" + default.strftime('%d %m %Y') + "]" prompt += ': ' return self.input(curry(...
python
def pastdate(self, prompt, default=None): """Prompts user to input a date in the past.""" prompt = prompt if prompt is not None else "Enter a past date" if default is not None: prompt += " [" + default.strftime('%d %m %Y') + "]" prompt += ': ' return self.input(curry(...
[ "def", "pastdate", "(", "self", ",", "prompt", ",", "default", "=", "None", ")", ":", "prompt", "=", "prompt", "if", "prompt", "is", "not", "None", "else", "\"Enter a past date\"", "if", "default", "is", "not", "None", ":", "prompt", "+=", "\" [\"", "+",...
Prompts user to input a date in the past.
[ "Prompts", "user", "to", "input", "a", "date", "in", "the", "past", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L198-L204
train
Prompts user to input a date in the past.
frasertweedale/ledgertools
ltlib/ui.py
UI.yn
def yn(self, prompt, default=None): """Prompts the user for yes/no confirmation, with optional default""" if default is True: opts = " [Y/n]: " elif default is False: opts = " [y/N]: " else: opts = " [y/n]: " prompt += opts return self....
python
def yn(self, prompt, default=None): """Prompts the user for yes/no confirmation, with optional default""" if default is True: opts = " [Y/n]: " elif default is False: opts = " [y/N]: " else: opts = " [y/n]: " prompt += opts return self....
[ "def", "yn", "(", "self", ",", "prompt", ",", "default", "=", "None", ")", ":", "if", "default", "is", "True", ":", "opts", "=", "\" [Y/n]: \"", "elif", "default", "is", "False", ":", "opts", "=", "\" [y/N]: \"", "else", ":", "opts", "=", "\" [y/n]: \"...
Prompts the user for yes/no confirmation, with optional default
[ "Prompts", "the", "user", "for", "yes", "/", "no", "confirmation", "with", "optional", "default" ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L206-L215
train
Prompts the user for yes or no confirmation with optional default
frasertweedale/ledgertools
ltlib/ui.py
UI.choose
def choose(self, prompt, items, default=None): """Prompts the user to choose one item from a list. The default, if provided, is an index; the item of that index will be returned. """ if default is not None and (default >= len(items) or default < 0): raise IndexError ...
python
def choose(self, prompt, items, default=None): """Prompts the user to choose one item from a list. The default, if provided, is an index; the item of that index will be returned. """ if default is not None and (default >= len(items) or default < 0): raise IndexError ...
[ "def", "choose", "(", "self", ",", "prompt", ",", "items", ",", "default", "=", "None", ")", ":", "if", "default", "is", "not", "None", "and", "(", "default", ">=", "len", "(", "items", ")", "or", "default", "<", "0", ")", ":", "raise", "IndexError...
Prompts the user to choose one item from a list. The default, if provided, is an index; the item of that index will be returned.
[ "Prompts", "the", "user", "to", "choose", "one", "item", "from", "a", "list", "." ]
a695f8667d72253e5448693c12f0282d09902aaa
https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/ui.py#L217-L233
train
Prompts the user to choose one item from a list.
lekhakpadmanabh/Summarizer
smrzr/core.py
goose_extractor
def goose_extractor(url): '''webpage extraction using Goose Library''' article = Goose().extract(url=url) return article.title, article.meta_description,\ article.cleaned_text
python
def goose_extractor(url): '''webpage extraction using Goose Library''' article = Goose().extract(url=url) return article.title, article.meta_description,\ article.cleaned_text
[ "def", "goose_extractor", "(", "url", ")", ":", "article", "=", "Goose", "(", ")", ".", "extract", "(", "url", "=", "url", ")", "return", "article", ".", "title", ",", "article", ".", "meta_description", ",", "article", ".", "cleaned_text" ]
webpage extraction using Goose Library
[ "webpage", "extraction", "using", "Goose", "Library" ]
143456a48217905c720d87331f410e5c8b4e24aa
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L24-L30
train
webpage extraction using Goose Library
lekhakpadmanabh/Summarizer
smrzr/core.py
_tokenize
def _tokenize(sentence): '''Tokenizer and Stemmer''' _tokens = nltk.word_tokenize(sentence) tokens = [stemmer.stem(tk) for tk in _tokens] return tokens
python
def _tokenize(sentence): '''Tokenizer and Stemmer''' _tokens = nltk.word_tokenize(sentence) tokens = [stemmer.stem(tk) for tk in _tokens] return tokens
[ "def", "_tokenize", "(", "sentence", ")", ":", "_tokens", "=", "nltk", ".", "word_tokenize", "(", "sentence", ")", "tokens", "=", "[", "stemmer", ".", "stem", "(", "tk", ")", "for", "tk", "in", "_tokens", "]", "return", "tokens" ]
Tokenizer and Stemmer
[ "Tokenizer", "and", "Stemmer" ]
143456a48217905c720d87331f410e5c8b4e24aa
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L32-L37
train
Tokenize a string and return a list of tokens.
lekhakpadmanabh/Summarizer
smrzr/core.py
_normalize
def _normalize(sentences): '''returns tf-idf matrix (unigrams+bigrams)''' tfidf = TfidfVectorizer(tokenizer=_tokenize, stop_words='english', decode_error='ignore', ngram_range=(1,2)) return tfidf.fit_transform(senten...
python
def _normalize(sentences): '''returns tf-idf matrix (unigrams+bigrams)''' tfidf = TfidfVectorizer(tokenizer=_tokenize, stop_words='english', decode_error='ignore', ngram_range=(1,2)) return tfidf.fit_transform(senten...
[ "def", "_normalize", "(", "sentences", ")", ":", "tfidf", "=", "TfidfVectorizer", "(", "tokenizer", "=", "_tokenize", ",", "stop_words", "=", "'english'", ",", "decode_error", "=", "'ignore'", ",", "ngram_range", "=", "(", "1", ",", "2", ")", ")", "return"...
returns tf-idf matrix (unigrams+bigrams)
[ "returns", "tf", "-", "idf", "matrix", "(", "unigrams", "+", "bigrams", ")" ]
143456a48217905c720d87331f410e5c8b4e24aa
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L39-L47
train
returns tf - idf matrix
lekhakpadmanabh/Summarizer
smrzr/core.py
_intertext_score
def _intertext_score(full_text): '''returns tuple of scored sentences in order of appearance Note: Doing an A/B test to compare results, reverting to original algorithm.''' sentences = sentence_tokenizer(full_text) norm = _normalize(sentences) similarity_matrix = pairwise_k...
python
def _intertext_score(full_text): '''returns tuple of scored sentences in order of appearance Note: Doing an A/B test to compare results, reverting to original algorithm.''' sentences = sentence_tokenizer(full_text) norm = _normalize(sentences) similarity_matrix = pairwise_k...
[ "def", "_intertext_score", "(", "full_text", ")", ":", "sentences", "=", "sentence_tokenizer", "(", "full_text", ")", "norm", "=", "_normalize", "(", "sentences", ")", "similarity_matrix", "=", "pairwise_kernels", "(", "norm", ",", "metric", "=", "'cosine'", ")"...
returns tuple of scored sentences in order of appearance Note: Doing an A/B test to compare results, reverting to original algorithm.
[ "returns", "tuple", "of", "scored", "sentences", "in", "order", "of", "appearance", "Note", ":", "Doing", "an", "A", "/", "B", "test", "to", "compare", "results", "reverting", "to", "original", "algorithm", "." ]
143456a48217905c720d87331f410e5c8b4e24aa
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L57-L74
train
returns tuple of scored sentences in order of appearance
lekhakpadmanabh/Summarizer
smrzr/core.py
_title_similarity_score
def _title_similarity_score(full_text, title): """Similarity scores for sentences with title in descending order""" sentences = sentence_tokenizer(full_text) norm = _normalize([title]+sentences) similarity_matrix = pairwise_kernels(norm, metric='cosine') return sorted(zip( ...
python
def _title_similarity_score(full_text, title): """Similarity scores for sentences with title in descending order""" sentences = sentence_tokenizer(full_text) norm = _normalize([title]+sentences) similarity_matrix = pairwise_kernels(norm, metric='cosine') return sorted(zip( ...
[ "def", "_title_similarity_score", "(", "full_text", ",", "title", ")", ":", "sentences", "=", "sentence_tokenizer", "(", "full_text", ")", "norm", "=", "_normalize", "(", "[", "title", "]", "+", "sentences", ")", "similarity_matrix", "=", "pairwise_kernels", "("...
Similarity scores for sentences with title in descending order
[ "Similarity", "scores", "for", "sentences", "with", "title", "in", "descending", "order" ]
143456a48217905c720d87331f410e5c8b4e24aa
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L77-L91
train
Similarity scores for sentences with title in descending order
lekhakpadmanabh/Summarizer
smrzr/core.py
_aggregrate_scores
def _aggregrate_scores(its,tss,num_sentences): """rerank the two vectors by min aggregrate rank, reorder""" final = [] for i,el in enumerate(its): for j, le in enumerate(tss): if el[2] == le[2]: assert el[1] == le[1] final.append((el[1],i+j,el[2])) ...
python
def _aggregrate_scores(its,tss,num_sentences): """rerank the two vectors by min aggregrate rank, reorder""" final = [] for i,el in enumerate(its): for j, le in enumerate(tss): if el[2] == le[2]: assert el[1] == le[1] final.append((el[1],i+j,el[2])) ...
[ "def", "_aggregrate_scores", "(", "its", ",", "tss", ",", "num_sentences", ")", ":", "final", "=", "[", "]", "for", "i", ",", "el", "in", "enumerate", "(", "its", ")", ":", "for", "j", ",", "le", "in", "enumerate", "(", "tss", ")", ":", "if", "el...
rerank the two vectors by min aggregrate rank, reorder
[ "rerank", "the", "two", "vectors", "by", "min", "aggregrate", "rank", "reorder" ]
143456a48217905c720d87331f410e5c8b4e24aa
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L102-L112
train
rerank the two vectors by aggregrate rank reorder
lekhakpadmanabh/Summarizer
smrzr/core.py
_eval_meta_as_summary
def _eval_meta_as_summary(meta): """some crude heuristics for now most are implemented on bot-side with domain whitelists""" if meta == '': return False if len(meta)>500: return False if 'login' in meta.lower(): return False return True
python
def _eval_meta_as_summary(meta): """some crude heuristics for now most are implemented on bot-side with domain whitelists""" if meta == '': return False if len(meta)>500: return False if 'login' in meta.lower(): return False return True
[ "def", "_eval_meta_as_summary", "(", "meta", ")", ":", "if", "meta", "==", "''", ":", "return", "False", "if", "len", "(", "meta", ")", ">", "500", ":", "return", "False", "if", "'login'", "in", "meta", ".", "lower", "(", ")", ":", "return", "False",...
some crude heuristics for now most are implemented on bot-side with domain whitelists
[ "some", "crude", "heuristics", "for", "now", "most", "are", "implemented", "on", "bot", "-", "side", "with", "domain", "whitelists" ]
143456a48217905c720d87331f410e5c8b4e24aa
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L115-L126
train
Check if meta is a summary of what is in the base64 encoded alphabet.
lekhakpadmanabh/Summarizer
smrzr/core.py
summarize_url
def summarize_url(url, num_sentences=4, fmt='default'): '''returns: tuple containing * single-line summary candidate * key points in the format specified. ''' title, meta, full_text = goose_extractor(url) if not full_text: raise ArticleExtractionFail("Couldn't extract: {}...
python
def summarize_url(url, num_sentences=4, fmt='default'): '''returns: tuple containing * single-line summary candidate * key points in the format specified. ''' title, meta, full_text = goose_extractor(url) if not full_text: raise ArticleExtractionFail("Couldn't extract: {}...
[ "def", "summarize_url", "(", "url", ",", "num_sentences", "=", "4", ",", "fmt", "=", "'default'", ")", ":", "title", ",", "meta", ",", "full_text", "=", "goose_extractor", "(", "url", ")", "if", "not", "full_text", ":", "raise", "ArticleExtractionFail", "(...
returns: tuple containing * single-line summary candidate * key points in the format specified.
[ "returns", ":", "tuple", "containing", "*", "single", "-", "line", "summary", "candidate", "*", "key", "points", "in", "the", "format", "specified", "." ]
143456a48217905c720d87331f410e5c8b4e24aa
https://github.com/lekhakpadmanabh/Summarizer/blob/143456a48217905c720d87331f410e5c8b4e24aa/smrzr/core.py#L128-L156
train
returns tuple containing the summary candidate title meta score and text of the candidate object.
digidotcom/python-wvalib
wva/core.py
WVA.get_vehicle_data_elements
def get_vehicle_data_elements(self): """Get a dictionary mapping names to :class:`VehicleData` instances This result is based on the results of `GET /ws/vehicle/data` that returns a list of URIs to each vehicle data element. The value is a handle for accessing additional information ab...
python
def get_vehicle_data_elements(self): """Get a dictionary mapping names to :class:`VehicleData` instances This result is based on the results of `GET /ws/vehicle/data` that returns a list of URIs to each vehicle data element. The value is a handle for accessing additional information ab...
[ "def", "get_vehicle_data_elements", "(", "self", ")", ":", "# Response looks like: { \"data\": ['vehicle/data/ParkingBrake', ...] }", "elements", "=", "{", "}", "for", "uri", "in", "self", ".", "get_http_client", "(", ")", ".", "get", "(", "\"vehicle/data\"", ")", "."...
Get a dictionary mapping names to :class:`VehicleData` instances This result is based on the results of `GET /ws/vehicle/data` that returns a list of URIs to each vehicle data element. The value is a handle for accessing additional information about a particular data element. :raises ...
[ "Get", "a", "dictionary", "mapping", "names", "to", ":", "class", ":", "VehicleData", "instances" ]
4252735e2775f80ebaffd813fbe84046d26906b3
https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/core.py#L66-L81
train
Get a dictionary mapping names to VehicleData instances
digidotcom/python-wvalib
wva/core.py
WVA.get_subscriptions
def get_subscriptions(self): """Return a list of subscriptions currently active for this WVA device :raises WVAError: if there is a problem getting the subscription list from the WVA :returns: A list of :class:`WVASubscription` instances """ # Example: {'subscriptions': ['subscr...
python
def get_subscriptions(self): """Return a list of subscriptions currently active for this WVA device :raises WVAError: if there is a problem getting the subscription list from the WVA :returns: A list of :class:`WVASubscription` instances """ # Example: {'subscriptions': ['subscr...
[ "def", "get_subscriptions", "(", "self", ")", ":", "# Example: {'subscriptions': ['subscriptions/TripDistance~sub', 'subscriptions/FuelRate~sub', ]}", "subscriptions", "=", "[", "]", "for", "uri", "in", "self", ".", "get_http_client", "(", ")", ".", "get", "(", "\"subscri...
Return a list of subscriptions currently active for this WVA device :raises WVAError: if there is a problem getting the subscription list from the WVA :returns: A list of :class:`WVASubscription` instances
[ "Return", "a", "list", "of", "subscriptions", "currently", "active", "for", "this", "WVA", "device" ]
4252735e2775f80ebaffd813fbe84046d26906b3
https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/core.py#L90-L100
train
Returns a list of all subscriptions currently active for this WVA device
digidotcom/python-wvalib
wva/core.py
WVA.get_event_stream
def get_event_stream(self): """Get the event stream associated with this WVA Note that this event stream is shared across all users of this WVA device as the WVA only supports a single event stream. :return: a new :class:`WVAEventStream` instance """ if self._event_stre...
python
def get_event_stream(self): """Get the event stream associated with this WVA Note that this event stream is shared across all users of this WVA device as the WVA only supports a single event stream. :return: a new :class:`WVAEventStream` instance """ if self._event_stre...
[ "def", "get_event_stream", "(", "self", ")", ":", "if", "self", ".", "_event_stream", "is", "None", ":", "self", ".", "_event_stream", "=", "WVAEventStream", "(", "self", ".", "_http_client", ")", "return", "self", ".", "_event_stream" ]
Get the event stream associated with this WVA Note that this event stream is shared across all users of this WVA device as the WVA only supports a single event stream. :return: a new :class:`WVAEventStream` instance
[ "Get", "the", "event", "stream", "associated", "with", "this", "WVA" ]
4252735e2775f80ebaffd813fbe84046d26906b3
https://github.com/digidotcom/python-wvalib/blob/4252735e2775f80ebaffd813fbe84046d26906b3/wva/core.py#L102-L112
train
Get the event stream associated with this WVA.
spacetelescope/stsci.imagestats
stsci/imagestats/histogram1d.py
histogram1d._populateHistogram
def _populateHistogram(self): """Call the C-code that actually populates the histogram""" try : buildHistogram.populate1DHist(self._data, self.histogram, self.minValue, self.maxValue, self.binWidth) except: if ((self._data.max() - self._data.min()) < self....
python
def _populateHistogram(self): """Call the C-code that actually populates the histogram""" try : buildHistogram.populate1DHist(self._data, self.histogram, self.minValue, self.maxValue, self.binWidth) except: if ((self._data.max() - self._data.min()) < self....
[ "def", "_populateHistogram", "(", "self", ")", ":", "try", ":", "buildHistogram", ".", "populate1DHist", "(", "self", ".", "_data", ",", "self", ".", "histogram", ",", "self", ".", "minValue", ",", "self", ".", "maxValue", ",", "self", ".", "binWidth", "...
Call the C-code that actually populates the histogram
[ "Call", "the", "C", "-", "code", "that", "actually", "populates", "the", "histogram" ]
d7fc9fe9783f7ed3dc9e4af47acd357a5ccd68e3
https://github.com/spacetelescope/stsci.imagestats/blob/d7fc9fe9783f7ed3dc9e4af47acd357a5ccd68e3/stsci/imagestats/histogram1d.py#L55-L68
train
Call the C - code that actually populates the histogram
spacetelescope/stsci.imagestats
stsci/imagestats/histogram1d.py
histogram1d.getCenters
def getCenters(self): """ Returns histogram's centers. """ return np.arange(self.histogram.size) * self.binWidth + self.minValue
python
def getCenters(self): """ Returns histogram's centers. """ return np.arange(self.histogram.size) * self.binWidth + self.minValue
[ "def", "getCenters", "(", "self", ")", ":", "return", "np", ".", "arange", "(", "self", ".", "histogram", ".", "size", ")", "*", "self", ".", "binWidth", "+", "self", ".", "minValue" ]
Returns histogram's centers.
[ "Returns", "histogram", "s", "centers", "." ]
d7fc9fe9783f7ed3dc9e4af47acd357a5ccd68e3
https://github.com/spacetelescope/stsci.imagestats/blob/d7fc9fe9783f7ed3dc9e4af47acd357a5ccd68e3/stsci/imagestats/histogram1d.py#L70-L72
train
Returns a list of the centers of the histogram.
pennlabs/penn-sdk-python
penn/wharton.py
Wharton.get_reservations
def get_reservations(self, sessionid, timeout=None): """Returns a list of location IDs and names.""" url = "{}{}".format(BASE_URL, "/reservations/") cookies = dict(sessionid=sessionid) try: resp = requests.get(url, timeout=timeout, cookies=cookies) except resp.except...
python
def get_reservations(self, sessionid, timeout=None): """Returns a list of location IDs and names.""" url = "{}{}".format(BASE_URL, "/reservations/") cookies = dict(sessionid=sessionid) try: resp = requests.get(url, timeout=timeout, cookies=cookies) except resp.except...
[ "def", "get_reservations", "(", "self", ",", "sessionid", ",", "timeout", "=", "None", ")", ":", "url", "=", "\"{}{}\"", ".", "format", "(", "BASE_URL", ",", "\"/reservations/\"", ")", "cookies", "=", "dict", "(", "sessionid", "=", "sessionid", ")", "try",...
Returns a list of location IDs and names.
[ "Returns", "a", "list", "of", "location", "IDs", "and", "names", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/wharton.py#L21-L51
train
Returns a list of location IDs and names.
pennlabs/penn-sdk-python
penn/wharton.py
Wharton.book_reservation
def book_reservation(self, sessionid, roomid, start, end): """ Book a reservation given the session id, the room id as an integer, and the start and end time as datetimes. """ duration = int((end - start).seconds / 60) format = "%Y-%m-%dT%H:%M:%S-{}".format(self.get_dst_gmt_timezone()) b...
python
def book_reservation(self, sessionid, roomid, start, end): """ Book a reservation given the session id, the room id as an integer, and the start and end time as datetimes. """ duration = int((end - start).seconds / 60) format = "%Y-%m-%dT%H:%M:%S-{}".format(self.get_dst_gmt_timezone()) b...
[ "def", "book_reservation", "(", "self", ",", "sessionid", ",", "roomid", ",", "start", ",", "end", ")", ":", "duration", "=", "int", "(", "(", "end", "-", "start", ")", ".", "seconds", "/", "60", ")", "format", "=", "\"%Y-%m-%dT%H:%M:%S-{}\"", ".", "fo...
Book a reservation given the session id, the room id as an integer, and the start and end time as datetimes.
[ "Book", "a", "reservation", "given", "the", "session", "id", "the", "room", "id", "as", "an", "integer", "and", "the", "start", "and", "end", "time", "as", "datetimes", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/wharton.py#L53-L90
train
Book a reservation given the session id the room id and the start and end time as datetimes.
pennlabs/penn-sdk-python
penn/wharton.py
Wharton.delete_booking
def delete_booking(self, sessionid, booking_id): """ Deletes a Wharton GSR Booking for a given booking and session id. """ url = "{}{}{}/".format(BASE_URL, "/delete/", booking_id) cookies = dict(sessionid=sessionid) try: resp = requests.get(url, cookies=cookies, headers={'Re...
python
def delete_booking(self, sessionid, booking_id): """ Deletes a Wharton GSR Booking for a given booking and session id. """ url = "{}{}{}/".format(BASE_URL, "/delete/", booking_id) cookies = dict(sessionid=sessionid) try: resp = requests.get(url, cookies=cookies, headers={'Re...
[ "def", "delete_booking", "(", "self", ",", "sessionid", ",", "booking_id", ")", ":", "url", "=", "\"{}{}{}/\"", ".", "format", "(", "BASE_URL", ",", "\"/delete/\"", ",", "booking_id", ")", "cookies", "=", "dict", "(", "sessionid", "=", "sessionid", ")", "t...
Deletes a Wharton GSR Booking for a given booking and session id.
[ "Deletes", "a", "Wharton", "GSR", "Booking", "for", "a", "given", "booking", "and", "session", "id", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/wharton.py#L92-L124
train
Delete a Wharton GSR Booking for a given session id.
pennlabs/penn-sdk-python
penn/wharton.py
Wharton.get_wharton_gsrs
def get_wharton_gsrs(self, sessionid, date=None): """ Make a request to retrieve Wharton GSR listings. """ if date: date += " {}".format(self.get_dst_gmt_timezone()) else: date = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%S") resp = requests.get('https://ap...
python
def get_wharton_gsrs(self, sessionid, date=None): """ Make a request to retrieve Wharton GSR listings. """ if date: date += " {}".format(self.get_dst_gmt_timezone()) else: date = datetime.datetime.utcnow().strftime("%Y-%m-%d %H:%S") resp = requests.get('https://ap...
[ "def", "get_wharton_gsrs", "(", "self", ",", "sessionid", ",", "date", "=", "None", ")", ":", "if", "date", ":", "date", "+=", "\" {}\"", ".", "format", "(", "self", ".", "get_dst_gmt_timezone", "(", ")", ")", "else", ":", "date", "=", "datetime", ".",...
Make a request to retrieve Wharton GSR listings.
[ "Make", "a", "request", "to", "retrieve", "Wharton", "GSR", "listings", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/wharton.py#L126-L140
train
Get Wharton GSR listings.
pennlabs/penn-sdk-python
penn/wharton.py
Wharton.switch_format
def switch_format(self, gsr): """ Convert the Wharton GSR format into the studyspaces API format. """ if "error" in gsr: return gsr categories = { "cid": 1, "name": "Huntsman Hall", "rooms": [] } for time in gsr["times"]: ...
python
def switch_format(self, gsr): """ Convert the Wharton GSR format into the studyspaces API format. """ if "error" in gsr: return gsr categories = { "cid": 1, "name": "Huntsman Hall", "rooms": [] } for time in gsr["times"]: ...
[ "def", "switch_format", "(", "self", ",", "gsr", ")", ":", "if", "\"error\"", "in", "gsr", ":", "return", "gsr", "categories", "=", "{", "\"cid\"", ":", "1", ",", "\"name\"", ":", "\"Huntsman Hall\"", ",", "\"rooms\"", ":", "[", "]", "}", "for", "time"...
Convert the Wharton GSR format into the studyspaces API format.
[ "Convert", "the", "Wharton", "GSR", "format", "into", "the", "studyspaces", "API", "format", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/wharton.py#L142-L184
train
Convert the Wharton GSR format into the studyspaces API format.
pennlabs/penn-sdk-python
penn/wharton.py
Wharton.get_wharton_gsrs_formatted
def get_wharton_gsrs_formatted(self, sessionid, date=None): """ Return the wharton GSR listing formatted in studyspaces format. """ gsrs = self.get_wharton_gsrs(sessionid, date) return self.switch_format(gsrs)
python
def get_wharton_gsrs_formatted(self, sessionid, date=None): """ Return the wharton GSR listing formatted in studyspaces format. """ gsrs = self.get_wharton_gsrs(sessionid, date) return self.switch_format(gsrs)
[ "def", "get_wharton_gsrs_formatted", "(", "self", ",", "sessionid", ",", "date", "=", "None", ")", ":", "gsrs", "=", "self", ".", "get_wharton_gsrs", "(", "sessionid", ",", "date", ")", "return", "self", ".", "switch_format", "(", "gsrs", ")" ]
Return the wharton GSR listing formatted in studyspaces format.
[ "Return", "the", "wharton", "GSR", "listing", "formatted", "in", "studyspaces", "format", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/wharton.py#L186-L189
train
Return the wharton GSR listing formatted in studyspaces format.
cloudbase/python-hnvclient
hnv/config/options.py
get_options
def get_options(): """Collect all the options info from the other modules.""" options = collections.defaultdict(list) for opt_class in config_factory.get_options(): if not issubclass(opt_class, config_base.Options): continue config_options = opt_class(None) options[config...
python
def get_options(): """Collect all the options info from the other modules.""" options = collections.defaultdict(list) for opt_class in config_factory.get_options(): if not issubclass(opt_class, config_base.Options): continue config_options = opt_class(None) options[config...
[ "def", "get_options", "(", ")", ":", "options", "=", "collections", ".", "defaultdict", "(", "list", ")", "for", "opt_class", "in", "config_factory", ".", "get_options", "(", ")", ":", "if", "not", "issubclass", "(", "opt_class", ",", "config_base", ".", "...
Collect all the options info from the other modules.
[ "Collect", "all", "the", "options", "info", "from", "the", "other", "modules", "." ]
b019452af01db22629809b8930357a2ebf6494be
https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/config/options.py#L26-L34
train
Collect all the options info from the other modules.
pennlabs/penn-sdk-python
penn/laundry.py
Laundry.create_hall_to_link_mapping
def create_hall_to_link_mapping(self): """ :return: Mapping from hall name to associated link in SUDS. Creates inverted index from id to hall. """ laundry_path = pkg_resources.resource_filename("penn", "data/laundry.csv") with open(laundry_path, "r") as f: reader = cs...
python
def create_hall_to_link_mapping(self): """ :return: Mapping from hall name to associated link in SUDS. Creates inverted index from id to hall. """ laundry_path = pkg_resources.resource_filename("penn", "data/laundry.csv") with open(laundry_path, "r") as f: reader = cs...
[ "def", "create_hall_to_link_mapping", "(", "self", ")", ":", "laundry_path", "=", "pkg_resources", ".", "resource_filename", "(", "\"penn\"", ",", "\"data/laundry.csv\"", ")", "with", "open", "(", "laundry_path", ",", "\"r\"", ")", "as", "f", ":", "reader", "=",...
:return: Mapping from hall name to associated link in SUDS. Creates inverted index from id to hall.
[ ":", "return", ":", "Mapping", "from", "hall", "name", "to", "associated", "link", "in", "SUDS", ".", "Creates", "inverted", "index", "from", "id", "to", "hall", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/laundry.py#L38-L51
train
Creates mapping from hall name to associated link in SUDS. Creates inverted index from id to hall name.
pennlabs/penn-sdk-python
penn/laundry.py
Laundry.parse_a_hall
def parse_a_hall(self, hall): """Return names, hall numbers, and the washers/dryers available for a certain hall. :param hall: The ID of the hall to retrieve data for. :type hall: int """ if hall not in self.hall_to_link: return None # change to to empty...
python
def parse_a_hall(self, hall): """Return names, hall numbers, and the washers/dryers available for a certain hall. :param hall: The ID of the hall to retrieve data for. :type hall: int """ if hall not in self.hall_to_link: return None # change to to empty...
[ "def", "parse_a_hall", "(", "self", ",", "hall", ")", ":", "if", "hall", "not", "in", "self", ".", "hall_to_link", ":", "return", "None", "# change to to empty json idk", "page", "=", "requests", ".", "get", "(", "self", ".", "hall_to_link", "[", "hall", "...
Return names, hall numbers, and the washers/dryers available for a certain hall. :param hall: The ID of the hall to retrieve data for. :type hall: int
[ "Return", "names", "hall", "numbers", "and", "the", "washers", "/", "dryers", "available", "for", "a", "certain", "hall", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/laundry.py#L77-L116
train
Returns a list of names hall numbers washers and dryers available for a certain hall.
pennlabs/penn-sdk-python
penn/laundry.py
Laundry.all_status
def all_status(self): """Return names, hall numbers, and the washers/dryers available for all rooms in the system >>> all_laundry = l.all_status() """ laundry_rooms = {} for room in self.hall_to_link: laundry_rooms[room] = self.parse_a_hall(room) ret...
python
def all_status(self): """Return names, hall numbers, and the washers/dryers available for all rooms in the system >>> all_laundry = l.all_status() """ laundry_rooms = {} for room in self.hall_to_link: laundry_rooms[room] = self.parse_a_hall(room) ret...
[ "def", "all_status", "(", "self", ")", ":", "laundry_rooms", "=", "{", "}", "for", "room", "in", "self", ".", "hall_to_link", ":", "laundry_rooms", "[", "room", "]", "=", "self", ".", "parse_a_hall", "(", "room", ")", "return", "laundry_rooms" ]
Return names, hall numbers, and the washers/dryers available for all rooms in the system >>> all_laundry = l.all_status()
[ "Return", "names", "hall", "numbers", "and", "the", "washers", "/", "dryers", "available", "for", "all", "rooms", "in", "the", "system" ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/laundry.py#L118-L128
train
Return the names hall numbers and washers and dryers available for all available system entries.
pennlabs/penn-sdk-python
penn/laundry.py
Laundry.hall_status
def hall_status(self, hall_id): """Return the status of each specific washer/dryer in a particular laundry room. :param hall_id: Integer corresponding to the id of the hall. This id is returned as part of the all_status call. >>> english_house = l.hall_status(...
python
def hall_status(self, hall_id): """Return the status of each specific washer/dryer in a particular laundry room. :param hall_id: Integer corresponding to the id of the hall. This id is returned as part of the all_status call. >>> english_house = l.hall_status(...
[ "def", "hall_status", "(", "self", ",", "hall_id", ")", ":", "if", "hall_id", "not", "in", "self", ".", "id_to_hall", ":", "raise", "ValueError", "(", "\"No hall with id %s exists.\"", "%", "hall_id", ")", "hall_name", "=", "self", ".", "id_to_hall", "[", "h...
Return the status of each specific washer/dryer in a particular laundry room. :param hall_id: Integer corresponding to the id of the hall. This id is returned as part of the all_status call. >>> english_house = l.hall_status("English%20House")
[ "Return", "the", "status", "of", "each", "specific", "washer", "/", "dryer", "in", "a", "particular", "laundry", "room", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/laundry.py#L130-L151
train
Return the status of each specific washer or dryer in a particular hall.
pennlabs/penn-sdk-python
penn/laundry.py
Laundry.check_is_working
def check_is_working(self): """ Returns True if the wash alert web interface seems to be working properly, or False otherwise. >>> l.check_is_working() """ try: r = requests.post("http://{}/".format(LAUNDRY_DOMAIN), timeout=60, data={ "locationid": "5...
python
def check_is_working(self): """ Returns True if the wash alert web interface seems to be working properly, or False otherwise. >>> l.check_is_working() """ try: r = requests.post("http://{}/".format(LAUNDRY_DOMAIN), timeout=60, data={ "locationid": "5...
[ "def", "check_is_working", "(", "self", ")", ":", "try", ":", "r", "=", "requests", ".", "post", "(", "\"http://{}/\"", ".", "format", "(", "LAUNDRY_DOMAIN", ")", ",", "timeout", "=", "60", ",", "data", "=", "{", "\"locationid\"", ":", "\"5faec7e9-a4aa-47c...
Returns True if the wash alert web interface seems to be working properly, or False otherwise. >>> l.check_is_working()
[ "Returns", "True", "if", "the", "wash", "alert", "web", "interface", "seems", "to", "be", "working", "properly", "or", "False", "otherwise", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/laundry.py#L153-L170
train
Returns True if the wash alert web interface seems to be working properly or False otherwise.
pennlabs/penn-sdk-python
penn/laundry.py
Laundry.machine_usage
def machine_usage(self, hall_no): """Returns the average usage of laundry machines every hour for a given hall. The usages are returned in a dictionary, with the key being the day of the week, and the value being an array listing the usages per hour. :param hall_no: ...
python
def machine_usage(self, hall_no): """Returns the average usage of laundry machines every hour for a given hall. The usages are returned in a dictionary, with the key being the day of the week, and the value being an array listing the usages per hour. :param hall_no: ...
[ "def", "machine_usage", "(", "self", ",", "hall_no", ")", ":", "try", ":", "num", "=", "int", "(", "hall_no", ")", "except", "ValueError", ":", "raise", "ValueError", "(", "\"Room Number must be integer\"", ")", "r", "=", "requests", ".", "get", "(", "USAG...
Returns the average usage of laundry machines every hour for a given hall. The usages are returned in a dictionary, with the key being the day of the week, and the value being an array listing the usages per hour. :param hall_no: integer corresponding to the id num...
[ "Returns", "the", "average", "usage", "of", "laundry", "machines", "every", "hour", "for", "a", "given", "hall", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/laundry.py#L172-L202
train
Returns the average usage of laundry machines every hour for a given hall.
lambdalisue/notify
src/notify/mailer.py
create_message
def create_message(from_addr, to_addr, subject, body, encoding=None): """ Create message object for sending email Parameters ---------- from_addr : string An email address used for 'From' attribute to_addr : string An email address used for 'To' attribute subject : string ...
python
def create_message(from_addr, to_addr, subject, body, encoding=None): """ Create message object for sending email Parameters ---------- from_addr : string An email address used for 'From' attribute to_addr : string An email address used for 'To' attribute subject : string ...
[ "def", "create_message", "(", "from_addr", ",", "to_addr", ",", "subject", ",", "body", ",", "encoding", "=", "None", ")", ":", "if", "encoding", "==", "\"None\"", ":", "encoding", "=", "None", "if", "not", "encoding", ":", "encoding", "=", "'utf-8'", "m...
Create message object for sending email Parameters ---------- from_addr : string An email address used for 'From' attribute to_addr : string An email address used for 'To' attribute subject : string An email subject string body : string An email body string e...
[ "Create", "message", "object", "for", "sending", "email" ]
1b6d7d1faa2cea13bfaa1f35130f279a0115e686
https://github.com/lambdalisue/notify/blob/1b6d7d1faa2cea13bfaa1f35130f279a0115e686/src/notify/mailer.py#L11-L42
train
Create a message object for sending email
lambdalisue/notify
src/notify/mailer.py
send_email
def send_email(msg, host='localhost', port=25, username=None, password=None): """ Send an email (via TLS when username and password are specified) Parameters ---------- msg : object An instance of MIMEText. Create this with :func:`create_message` function. host : string...
python
def send_email(msg, host='localhost', port=25, username=None, password=None): """ Send an email (via TLS when username and password are specified) Parameters ---------- msg : object An instance of MIMEText. Create this with :func:`create_message` function. host : string...
[ "def", "send_email", "(", "msg", ",", "host", "=", "'localhost'", ",", "port", "=", "25", ",", "username", "=", "None", ",", "password", "=", "None", ")", ":", "s", "=", "smtplib", ".", "SMTP", "(", "host", ",", "port", ")", "if", "username", "and"...
Send an email (via TLS when username and password are specified) Parameters ---------- msg : object An instance of MIMEText. Create this with :func:`create_message` function. host : string A mail user agent host name (Default: localhost) port : int A mail user agent ...
[ "Send", "an", "email", "(", "via", "TLS", "when", "username", "and", "password", "are", "specified", ")" ]
1b6d7d1faa2cea13bfaa1f35130f279a0115e686
https://github.com/lambdalisue/notify/blob/1b6d7d1faa2cea13bfaa1f35130f279a0115e686/src/notify/mailer.py#L44-L72
train
Send an email via TLS
pennlabs/penn-sdk-python
penn/calendar3year.py
Calendar.pull_3year
def pull_3year(self): """Returns a list (in JSON format) containing all the events from the Penn iCal Calendar. List contains events in chronological order. Each element of the list is a dictionary, containing: - Name of the event 'name' - Start date 'start' ...
python
def pull_3year(self): """Returns a list (in JSON format) containing all the events from the Penn iCal Calendar. List contains events in chronological order. Each element of the list is a dictionary, containing: - Name of the event 'name' - Start date 'start' ...
[ "def", "pull_3year", "(", "self", ")", ":", "events", "=", "[", "]", "for", "term", "in", "[", "\"fall\"", ",", "\"summer\"", ",", "\"spring\"", "]", ":", "url", "=", "\"{}{}{}term.ics\"", ".", "format", "(", "BASE_URL", ",", "datetime", ".", "datetime",...
Returns a list (in JSON format) containing all the events from the Penn iCal Calendar. List contains events in chronological order. Each element of the list is a dictionary, containing: - Name of the event 'name' - Start date 'start' - End date 'end'
[ "Returns", "a", "list", "(", "in", "JSON", "format", ")", "containing", "all", "the", "events", "from", "the", "Penn", "iCal", "Calendar", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/calendar3year.py#L12-L48
train
Pulls all the events from the Penn iCal Calendar and returns a list of dictionaries containing all the events in chronological order.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces._obtain_token
def _obtain_token(self): """Obtain an auth token from client id and client secret.""" # don't renew token if hasn't expired yet if self.expiration and self.expiration > datetime.datetime.now(): return resp = requests.post("{}/1.1/oauth/token".format(API_URL), data={ ...
python
def _obtain_token(self): """Obtain an auth token from client id and client secret.""" # don't renew token if hasn't expired yet if self.expiration and self.expiration > datetime.datetime.now(): return resp = requests.post("{}/1.1/oauth/token".format(API_URL), data={ ...
[ "def", "_obtain_token", "(", "self", ")", ":", "# don't renew token if hasn't expired yet", "if", "self", ".", "expiration", "and", "self", ".", "expiration", ">", "datetime", ".", "datetime", ".", "now", "(", ")", ":", "return", "resp", "=", "requests", ".", ...
Obtain an auth token from client id and client secret.
[ "Obtain", "an", "auth", "token", "from", "client", "id", "and", "client", "secret", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L30-L48
train
Obtain an auth token from client id and client secret.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces._request
def _request(self, *args, **kwargs): """Make a signed request to the libcal API.""" if not self.token: self._obtain_token() headers = { "Authorization": "Bearer {}".format(self.token) } # add authorization headers if "headers" in kwargs: ...
python
def _request(self, *args, **kwargs): """Make a signed request to the libcal API.""" if not self.token: self._obtain_token() headers = { "Authorization": "Bearer {}".format(self.token) } # add authorization headers if "headers" in kwargs: ...
[ "def", "_request", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "token", ":", "self", ".", "_obtain_token", "(", ")", "headers", "=", "{", "\"Authorization\"", ":", "\"Bearer {}\"", ".", "format", "(", "...
Make a signed request to the libcal API.
[ "Make", "a", "signed", "request", "to", "the", "libcal", "API", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L50-L78
train
Make a signed request to the libcal API.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces.get_buildings
def get_buildings(self): """Returns a list of location IDs and names.""" resp = self._request("GET", "/1.1/space/locations").json() out = [] for x in resp: if x["lid"] in LOCATION_BLACKLIST: continue if x["public"] == 1: del x["publ...
python
def get_buildings(self): """Returns a list of location IDs and names.""" resp = self._request("GET", "/1.1/space/locations").json() out = [] for x in resp: if x["lid"] in LOCATION_BLACKLIST: continue if x["public"] == 1: del x["publ...
[ "def", "get_buildings", "(", "self", ")", ":", "resp", "=", "self", ".", "_request", "(", "\"GET\"", ",", "\"/1.1/space/locations\"", ")", ".", "json", "(", ")", "out", "=", "[", "]", "for", "x", "in", "resp", ":", "if", "x", "[", "\"lid\"", "]", "...
Returns a list of location IDs and names.
[ "Returns", "a", "list", "of", "location", "IDs", "and", "names", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L80-L91
train
Returns a list of location IDs and names.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces.get_rooms
def get_rooms(self, lid, start=None, end=None): """Returns a list of rooms and their availabilities, grouped by category. :param lid: The ID of the location to retrieve rooms for. :type lid: int :param start: The start range for the availabilities to retrieve, in YYYY-MM-DD format. ...
python
def get_rooms(self, lid, start=None, end=None): """Returns a list of rooms and their availabilities, grouped by category. :param lid: The ID of the location to retrieve rooms for. :type lid: int :param start: The start range for the availabilities to retrieve, in YYYY-MM-DD format. ...
[ "def", "get_rooms", "(", "self", ",", "lid", ",", "start", "=", "None", ",", "end", "=", "None", ")", ":", "range_str", "=", "\"availability\"", "if", "start", ":", "start_datetime", "=", "datetime", ".", "datetime", ".", "combine", "(", "datetime", ".",...
Returns a list of rooms and their availabilities, grouped by category. :param lid: The ID of the location to retrieve rooms for. :type lid: int :param start: The start range for the availabilities to retrieve, in YYYY-MM-DD format. :type start: str :param end: The end range for ...
[ "Returns", "a", "list", "of", "rooms", "and", "their", "availabilities", "grouped", "by", "category", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L93-L167
train
Returns a list of rooms and their availabilities grouped by category.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces.book_room
def book_room(self, item, start, end, fname, lname, email, nickname, custom={}, test=False): """Books a room given the required information. :param item: The ID of the room to book. :type item: int :param start: The start time range of when to book the room, in t...
python
def book_room(self, item, start, end, fname, lname, email, nickname, custom={}, test=False): """Books a room given the required information. :param item: The ID of the room to book. :type item: int :param start: The start time range of when to book the room, in t...
[ "def", "book_room", "(", "self", ",", "item", ",", "start", ",", "end", ",", "fname", ",", "lname", ",", "email", ",", "nickname", ",", "custom", "=", "{", "}", ",", "test", "=", "False", ")", ":", "data", "=", "{", "\"start\"", ":", "start", ","...
Books a room given the required information. :param item: The ID of the room to book. :type item: int :param start: The start time range of when to book the room, in the format returned by the LibCal API. :type start: str :param end: The end t...
[ "Books", "a", "room", "given", "the", "required", "information", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L169-L231
train
Books a room given the required information.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces.cancel_room
def cancel_room(self, booking_id): """Cancel a room given a booking id. :param booking_id: A booking id or a list of booking ids (separated by commas) to cancel. :type booking_id: str """ resp = self._request("POST", "/1.1/space/cancel/{}".format(booking_id)) return resp...
python
def cancel_room(self, booking_id): """Cancel a room given a booking id. :param booking_id: A booking id or a list of booking ids (separated by commas) to cancel. :type booking_id: str """ resp = self._request("POST", "/1.1/space/cancel/{}".format(booking_id)) return resp...
[ "def", "cancel_room", "(", "self", ",", "booking_id", ")", ":", "resp", "=", "self", ".", "_request", "(", "\"POST\"", ",", "\"/1.1/space/cancel/{}\"", ".", "format", "(", "booking_id", ")", ")", "return", "resp", ".", "json", "(", ")" ]
Cancel a room given a booking id. :param booking_id: A booking id or a list of booking ids (separated by commas) to cancel. :type booking_id: str
[ "Cancel", "a", "room", "given", "a", "booking", "id", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L233-L240
train
Cancel a room given a booking id.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces.get_reservations
def get_reservations(self, email, date, timeout=None): """Gets reservations for a given email. :param email: the email of the user who's reservations are to be fetched :type email: str """ try: resp = self._request("GET", "/1.1/space/bookings?email={}&date={}&limit=1...
python
def get_reservations(self, email, date, timeout=None): """Gets reservations for a given email. :param email: the email of the user who's reservations are to be fetched :type email: str """ try: resp = self._request("GET", "/1.1/space/bookings?email={}&date={}&limit=1...
[ "def", "get_reservations", "(", "self", ",", "email", ",", "date", ",", "timeout", "=", "None", ")", ":", "try", ":", "resp", "=", "self", ".", "_request", "(", "\"GET\"", ",", "\"/1.1/space/bookings?email={}&date={}&limit=100\"", ".", "format", "(", "email", ...
Gets reservations for a given email. :param email: the email of the user who's reservations are to be fetched :type email: str
[ "Gets", "reservations", "for", "a", "given", "email", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L242-L254
train
Gets the reservations for a given email.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces.get_reservations_for_booking_ids
def get_reservations_for_booking_ids(self, booking_ids): """Gets booking information for a given list of booking ids. :param booking_ids: a booking id or a list of room ids (comma separated). :type booking_ids: string """ try: resp = self._request("GET", "/1.1/space/...
python
def get_reservations_for_booking_ids(self, booking_ids): """Gets booking information for a given list of booking ids. :param booking_ids: a booking id or a list of room ids (comma separated). :type booking_ids: string """ try: resp = self._request("GET", "/1.1/space/...
[ "def", "get_reservations_for_booking_ids", "(", "self", ",", "booking_ids", ")", ":", "try", ":", "resp", "=", "self", ".", "_request", "(", "\"GET\"", ",", "\"/1.1/space/booking/{}\"", ".", "format", "(", "booking_ids", ")", ")", "except", "resp", ".", "excep...
Gets booking information for a given list of booking ids. :param booking_ids: a booking id or a list of room ids (comma separated). :type booking_ids: string
[ "Gets", "booking", "information", "for", "a", "given", "list", "of", "booking", "ids", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L256-L266
train
Gets the booking information for a given list of booking ids.
pennlabs/penn-sdk-python
penn/studyspaces.py
StudySpaces.get_room_info
def get_room_info(self, room_ids): """Gets room information for a given list of ids. :param room_ids: a room id or a list of room ids (comma separated). :type room_ids: string """ try: resp = self._request("GET", "/1.1/space/item/{}".format(room_ids)) roo...
python
def get_room_info(self, room_ids): """Gets room information for a given list of ids. :param room_ids: a room id or a list of room ids (comma separated). :type room_ids: string """ try: resp = self._request("GET", "/1.1/space/item/{}".format(room_ids)) roo...
[ "def", "get_room_info", "(", "self", ",", "room_ids", ")", ":", "try", ":", "resp", "=", "self", ".", "_request", "(", "\"GET\"", ",", "\"/1.1/space/item/{}\"", ".", "format", "(", "room_ids", ")", ")", "rooms", "=", "resp", ".", "json", "(", ")", "for...
Gets room information for a given list of ids. :param room_ids: a room id or a list of room ids (comma separated). :type room_ids: string
[ "Gets", "room", "information", "for", "a", "given", "list", "of", "ids", "." ]
31ff12c20d69438d63bc7a796f83ce4f4c828396
https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/studyspaces.py#L268-L286
train
Gets the room information for a given list of ids.
south-coast-science/scs_core
src/scs_core/position/nmea/gptime.py
GPTime.as_iso8601
def as_iso8601(self): """ example: 00:38:05.210Z """ if self.__time is None: return None return "%s:%s:%s0Z" % (self.__time[:2], self.__time[2:4], self.__time[4:])
python
def as_iso8601(self): """ example: 00:38:05.210Z """ if self.__time is None: return None return "%s:%s:%s0Z" % (self.__time[:2], self.__time[2:4], self.__time[4:])
[ "def", "as_iso8601", "(", "self", ")", ":", "if", "self", ".", "__time", "is", "None", ":", "return", "None", "return", "\"%s:%s:%s0Z\"", "%", "(", "self", ".", "__time", "[", ":", "2", "]", ",", "self", ".", "__time", "[", "2", ":", "4", "]", ",...
example: 00:38:05.210Z
[ "example", ":", "00", ":", "38", ":", "05", ".", "210Z" ]
a4152b0bbed6acbbf257e1bba6a912f6ebe578e5
https://github.com/south-coast-science/scs_core/blob/a4152b0bbed6acbbf257e1bba6a912f6ebe578e5/src/scs_core/position/nmea/gptime.py#L29-L36
train
returns ISO 8601 time string
marazmiki/django-ulogin
django_ulogin/models.py
create_user
def create_user(request, ulogin_response): """ Creates user """ # Custom behaviour if s.CREATE_USER_CALLBACK is not None: callback = import_by_path(s.CREATE_USER_CALLBACK) if callable(callback): return callback(request=request, ulogin_response...
python
def create_user(request, ulogin_response): """ Creates user """ # Custom behaviour if s.CREATE_USER_CALLBACK is not None: callback = import_by_path(s.CREATE_USER_CALLBACK) if callable(callback): return callback(request=request, ulogin_response...
[ "def", "create_user", "(", "request", ",", "ulogin_response", ")", ":", "# Custom behaviour", "if", "s", ".", "CREATE_USER_CALLBACK", "is", "not", "None", ":", "callback", "=", "import_by_path", "(", "s", ".", "CREATE_USER_CALLBACK", ")", "if", "callable", "(", ...
Creates user
[ "Creates", "user" ]
f41ad4b4ca130ad8af25be72ad882c8cf94a80dc
https://github.com/marazmiki/django-ulogin/blob/f41ad4b4ca130ad8af25be72ad882c8cf94a80dc/django_ulogin/models.py#L56-L79
train
Creates user in the current language
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_shape_definition_parser.py
ShexShapeDefinitionParser.visitShapeDefinition
def visitShapeDefinition(self, ctx: ShExDocParser.ShapeDefinitionContext): """ shapeDefinition: qualifier* '{' oneOfShape? '}' annotation* semanticActions """ if ctx.qualifier(): for q in ctx.qualifier(): self.visit(q) if ctx.oneOfShape(): oneof_parser = S...
python
def visitShapeDefinition(self, ctx: ShExDocParser.ShapeDefinitionContext): """ shapeDefinition: qualifier* '{' oneOfShape? '}' annotation* semanticActions """ if ctx.qualifier(): for q in ctx.qualifier(): self.visit(q) if ctx.oneOfShape(): oneof_parser = S...
[ "def", "visitShapeDefinition", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "ShapeDefinitionContext", ")", ":", "if", "ctx", ".", "qualifier", "(", ")", ":", "for", "q", "in", "ctx", ".", "qualifier", "(", ")", ":", "self", ".", "visit", "(", "q...
shapeDefinition: qualifier* '{' oneOfShape? '}' annotation* semanticActions
[ "shapeDefinition", ":", "qualifier", "*", "{", "oneOfShape?", "}", "annotation", "*", "semanticActions" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_definition_parser.py#L45-L62
train
visit a ShapeDefinition node by traversing all of its children and adding the shape definition information to the instance variables.
shexSpec/grammar
parsers/python/pyshexc/parser_impl/shex_shape_definition_parser.py
ShexShapeDefinitionParser.visitInlineShapeDefinition
def visitInlineShapeDefinition(self, ctx: ShExDocParser.InlineShapeDefinitionContext): """ shapeDefinition: qualifier* '{' oneOfShape? '}' """ if ctx.qualifier(): for q in ctx.qualifier(): self.visit(q) if ctx.oneOfShape(): oneof_parser = ShexOneOfShapePar...
python
def visitInlineShapeDefinition(self, ctx: ShExDocParser.InlineShapeDefinitionContext): """ shapeDefinition: qualifier* '{' oneOfShape? '}' """ if ctx.qualifier(): for q in ctx.qualifier(): self.visit(q) if ctx.oneOfShape(): oneof_parser = ShexOneOfShapePar...
[ "def", "visitInlineShapeDefinition", "(", "self", ",", "ctx", ":", "ShExDocParser", ".", "InlineShapeDefinitionContext", ")", ":", "if", "ctx", ".", "qualifier", "(", ")", ":", "for", "q", "in", "ctx", ".", "qualifier", "(", ")", ":", "self", ".", "visit",...
shapeDefinition: qualifier* '{' oneOfShape? '}'
[ "shapeDefinition", ":", "qualifier", "*", "{", "oneOfShape?", "}" ]
4497cd1f73fa6703bca6e2cb53ba9c120f22e48c
https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_definition_parser.py#L64-L72
train
Visit inline shape definition.