id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
41,400
Nekroze/partpy
partpy/sourcestring.py
SourceString.count_indents_last_line
def count_indents_last_line(self, spacecount, tabs=0, back=5): """Finds the last meaningful line and returns its indent level. Back specifies the amount of lines to look back for a none whitespace line. """ if not self.has_space(): return 0 lines = self.get_su...
python
def count_indents_last_line(self, spacecount, tabs=0, back=5): """Finds the last meaningful line and returns its indent level. Back specifies the amount of lines to look back for a none whitespace line. """ if not self.has_space(): return 0 lines = self.get_su...
[ "def", "count_indents_last_line", "(", "self", ",", "spacecount", ",", "tabs", "=", "0", ",", "back", "=", "5", ")", ":", "if", "not", "self", ".", "has_space", "(", ")", ":", "return", "0", "lines", "=", "self", ".", "get_surrounding_lines", "(", "bac...
Finds the last meaningful line and returns its indent level. Back specifies the amount of lines to look back for a none whitespace line.
[ "Finds", "the", "last", "meaningful", "line", "and", "returns", "its", "indent", "level", ".", "Back", "specifies", "the", "amount", "of", "lines", "to", "look", "back", "for", "a", "none", "whitespace", "line", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L464-L476
41,401
Nekroze/partpy
partpy/sourcestring.py
SourceString.count_indents_length_last_line
def count_indents_length_last_line(self, spacecount, tabs=0, back=5): """Finds the last meaningful line and returns its indent level and character length. Back specifies the amount of lines to look back for a none whitespace line. """ if not self.has_space(): ...
python
def count_indents_length_last_line(self, spacecount, tabs=0, back=5): """Finds the last meaningful line and returns its indent level and character length. Back specifies the amount of lines to look back for a none whitespace line. """ if not self.has_space(): ...
[ "def", "count_indents_length_last_line", "(", "self", ",", "spacecount", ",", "tabs", "=", "0", ",", "back", "=", "5", ")", ":", "if", "not", "self", ".", "has_space", "(", ")", ":", "return", "0", "lines", "=", "self", ".", "get_surrounding_lines", "(",...
Finds the last meaningful line and returns its indent level and character length. Back specifies the amount of lines to look back for a none whitespace line.
[ "Finds", "the", "last", "meaningful", "line", "and", "returns", "its", "indent", "level", "and", "character", "length", ".", "Back", "specifies", "the", "amount", "of", "lines", "to", "look", "back", "for", "a", "none", "whitespace", "line", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L478-L491
41,402
Nekroze/partpy
partpy/sourcestring.py
SourceString.skip_whitespace
def skip_whitespace(self, newlines=0): """Moves the position forwards to the next non newline space character. If newlines >= 1 include newlines as spaces. """ if newlines: while not self.eos: if self.get_char().isspace(): self.eat_length(1...
python
def skip_whitespace(self, newlines=0): """Moves the position forwards to the next non newline space character. If newlines >= 1 include newlines as spaces. """ if newlines: while not self.eos: if self.get_char().isspace(): self.eat_length(1...
[ "def", "skip_whitespace", "(", "self", ",", "newlines", "=", "0", ")", ":", "if", "newlines", ":", "while", "not", "self", ".", "eos", ":", "if", "self", ".", "get_char", "(", ")", ".", "isspace", "(", ")", ":", "self", ".", "eat_length", "(", "1",...
Moves the position forwards to the next non newline space character. If newlines >= 1 include newlines as spaces.
[ "Moves", "the", "position", "forwards", "to", "the", "next", "non", "newline", "space", "character", ".", "If", "newlines", ">", "=", "1", "include", "newlines", "as", "spaces", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L493-L510
41,403
Nekroze/partpy
partpy/sourcestring.py
SourceLine.pretty_print
def pretty_print(self, carrot=False): """Return a string of this line including linenumber. If carrot is True then a line is added under the string with a carrot under the current character position. """ lineno = self.lineno padding = 0 if lineno < 1000: ...
python
def pretty_print(self, carrot=False): """Return a string of this line including linenumber. If carrot is True then a line is added under the string with a carrot under the current character position. """ lineno = self.lineno padding = 0 if lineno < 1000: ...
[ "def", "pretty_print", "(", "self", ",", "carrot", "=", "False", ")", ":", "lineno", "=", "self", ".", "lineno", "padding", "=", "0", "if", "lineno", "<", "1000", ":", "padding", "=", "1", "if", "lineno", "<", "100", ":", "padding", "=", "2", "if",...
Return a string of this line including linenumber. If carrot is True then a line is added under the string with a carrot under the current character position.
[ "Return", "a", "string", "of", "this", "line", "including", "linenumber", ".", "If", "carrot", "is", "True", "then", "a", "line", "is", "added", "under", "the", "string", "with", "a", "carrot", "under", "the", "current", "character", "position", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L571-L588
41,404
siznax/frag2text
frag2text.py
safe_exit
def safe_exit(output): """exit without breaking pipes.""" try: sys.stdout.write(output) sys.stdout.flush() except IOError: pass
python
def safe_exit(output): """exit without breaking pipes.""" try: sys.stdout.write(output) sys.stdout.flush() except IOError: pass
[ "def", "safe_exit", "(", "output", ")", ":", "try", ":", "sys", ".", "stdout", ".", "write", "(", "output", ")", "sys", ".", "stdout", ".", "flush", "(", ")", "except", "IOError", ":", "pass" ]
exit without breaking pipes.
[ "exit", "without", "breaking", "pipes", "." ]
ccb5cb9007931cce25e39d598bd2e790123c12e6
https://github.com/siznax/frag2text/blob/ccb5cb9007931cce25e39d598bd2e790123c12e6/frag2text.py#L68-L74
41,405
siznax/frag2text
frag2text.py
frag2text
def frag2text(endpoint, stype, selector, clean=False, raw=False, verbose=False): """returns Markdown text of selected fragment. Args: endpoint: URL, file, or HTML string stype: { 'css' | 'xpath' } selector: CSS selector or XPath expression Returns: Markdown tex...
python
def frag2text(endpoint, stype, selector, clean=False, raw=False, verbose=False): """returns Markdown text of selected fragment. Args: endpoint: URL, file, or HTML string stype: { 'css' | 'xpath' } selector: CSS selector or XPath expression Returns: Markdown tex...
[ "def", "frag2text", "(", "endpoint", ",", "stype", ",", "selector", ",", "clean", "=", "False", ",", "raw", "=", "False", ",", "verbose", "=", "False", ")", ":", "try", ":", "return", "main", "(", "endpoint", ",", "stype", ",", "selector", ",", "clea...
returns Markdown text of selected fragment. Args: endpoint: URL, file, or HTML string stype: { 'css' | 'xpath' } selector: CSS selector or XPath expression Returns: Markdown text Options: clean: cleans fragment (lxml.html.clean defaults) raw: returns raw HTML...
[ "returns", "Markdown", "text", "of", "selected", "fragment", "." ]
ccb5cb9007931cce25e39d598bd2e790123c12e6
https://github.com/siznax/frag2text/blob/ccb5cb9007931cce25e39d598bd2e790123c12e6/frag2text.py#L77-L95
41,406
siznax/frag2text
frag2text.py
Frag2Text.read
def read(self, _file): """return local file contents as endpoint.""" with open(_file) as fh: data = fh.read() if self.verbose: sys.stdout.write("read %d bytes from %s\n" % (fh.tell(), _file)) return data
python
def read(self, _file): """return local file contents as endpoint.""" with open(_file) as fh: data = fh.read() if self.verbose: sys.stdout.write("read %d bytes from %s\n" % (fh.tell(), _file)) return data
[ "def", "read", "(", "self", ",", "_file", ")", ":", "with", "open", "(", "_file", ")", "as", "fh", ":", "data", "=", "fh", ".", "read", "(", ")", "if", "self", ".", "verbose", ":", "sys", ".", "stdout", ".", "write", "(", "\"read %d bytes from %s\\...
return local file contents as endpoint.
[ "return", "local", "file", "contents", "as", "endpoint", "." ]
ccb5cb9007931cce25e39d598bd2e790123c12e6
https://github.com/siznax/frag2text/blob/ccb5cb9007931cce25e39d598bd2e790123c12e6/frag2text.py#L31-L38
41,407
siznax/frag2text
frag2text.py
Frag2Text.GET
def GET(self, url): """returns text content of HTTP GET response.""" r = requests.get(url) if self.verbose: sys.stdout.write("%s %s\n" % (r.status_code, r.encoding)) sys.stdout.write(str(r.headers) + "\n") self.encoding = r.encoding return r.text
python
def GET(self, url): """returns text content of HTTP GET response.""" r = requests.get(url) if self.verbose: sys.stdout.write("%s %s\n" % (r.status_code, r.encoding)) sys.stdout.write(str(r.headers) + "\n") self.encoding = r.encoding return r.text
[ "def", "GET", "(", "self", ",", "url", ")", ":", "r", "=", "requests", ".", "get", "(", "url", ")", "if", "self", ".", "verbose", ":", "sys", ".", "stdout", ".", "write", "(", "\"%s %s\\n\"", "%", "(", "r", ".", "status_code", ",", "r", ".", "e...
returns text content of HTTP GET response.
[ "returns", "text", "content", "of", "HTTP", "GET", "response", "." ]
ccb5cb9007931cce25e39d598bd2e790123c12e6
https://github.com/siznax/frag2text/blob/ccb5cb9007931cce25e39d598bd2e790123c12e6/frag2text.py#L40-L47
41,408
siznax/frag2text
frag2text.py
Frag2Text.select
def select(self, html, stype, expression): """returns WHATWG spec HTML fragment from selector expression.""" etree = html5lib.parse(html, treebuilder='lxml', namespaceHTMLElements=False) if stype == 'css': selector = lxml....
python
def select(self, html, stype, expression): """returns WHATWG spec HTML fragment from selector expression.""" etree = html5lib.parse(html, treebuilder='lxml', namespaceHTMLElements=False) if stype == 'css': selector = lxml....
[ "def", "select", "(", "self", ",", "html", ",", "stype", ",", "expression", ")", ":", "etree", "=", "html5lib", ".", "parse", "(", "html", ",", "treebuilder", "=", "'lxml'", ",", "namespaceHTMLElements", "=", "False", ")", "if", "stype", "==", "'css'", ...
returns WHATWG spec HTML fragment from selector expression.
[ "returns", "WHATWG", "spec", "HTML", "fragment", "from", "selector", "expression", "." ]
ccb5cb9007931cce25e39d598bd2e790123c12e6
https://github.com/siznax/frag2text/blob/ccb5cb9007931cce25e39d598bd2e790123c12e6/frag2text.py#L49-L61
41,409
siznax/frag2text
frag2text.py
Frag2Text.clean
def clean(self, html): """removes evil HTML per lxml.html.clean defaults.""" return lxml.html.clean.clean_html(unicode(html, self.encoding))
python
def clean(self, html): """removes evil HTML per lxml.html.clean defaults.""" return lxml.html.clean.clean_html(unicode(html, self.encoding))
[ "def", "clean", "(", "self", ",", "html", ")", ":", "return", "lxml", ".", "html", ".", "clean", ".", "clean_html", "(", "unicode", "(", "html", ",", "self", ".", "encoding", ")", ")" ]
removes evil HTML per lxml.html.clean defaults.
[ "removes", "evil", "HTML", "per", "lxml", ".", "html", ".", "clean", "defaults", "." ]
ccb5cb9007931cce25e39d598bd2e790123c12e6
https://github.com/siznax/frag2text/blob/ccb5cb9007931cce25e39d598bd2e790123c12e6/frag2text.py#L63-L65
41,410
helixyte/everest
everest/directives.py
filesystem_repository
def filesystem_repository(_context, name=None, make_default=False, aggregate_class=None, repository_class=None, directory=None, content_type=None): """ Directive for registering a file-system based repository. """ cnf = {} if not directory is None:...
python
def filesystem_repository(_context, name=None, make_default=False, aggregate_class=None, repository_class=None, directory=None, content_type=None): """ Directive for registering a file-system based repository. """ cnf = {} if not directory is None:...
[ "def", "filesystem_repository", "(", "_context", ",", "name", "=", "None", ",", "make_default", "=", "False", ",", "aggregate_class", "=", "None", ",", "repository_class", "=", "None", ",", "directory", "=", "None", ",", "content_type", "=", "None", ")", ":"...
Directive for registering a file-system based repository.
[ "Directive", "for", "registering", "a", "file", "-", "system", "based", "repository", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/directives.py#L131-L145
41,411
helixyte/everest
everest/directives.py
rdb_repository
def rdb_repository(_context, name=None, make_default=False, aggregate_class=None, repository_class=None, db_string=None, metadata_factory=None): """ Directive for registering a RDBM based repository. """ cnf = {} if not db_string is None: cnf['db_string'...
python
def rdb_repository(_context, name=None, make_default=False, aggregate_class=None, repository_class=None, db_string=None, metadata_factory=None): """ Directive for registering a RDBM based repository. """ cnf = {} if not db_string is None: cnf['db_string'...
[ "def", "rdb_repository", "(", "_context", ",", "name", "=", "None", ",", "make_default", "=", "False", ",", "aggregate_class", "=", "None", ",", "repository_class", "=", "None", ",", "db_string", "=", "None", ",", "metadata_factory", "=", "None", ")", ":", ...
Directive for registering a RDBM based repository.
[ "Directive", "for", "registering", "a", "RDBM", "based", "repository", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/directives.py#L159-L172
41,412
helixyte/everest
everest/directives.py
messaging
def messaging(_context, repository, reset_on_start=False): """ Directive for setting up the user message resource in the appropriate repository. :param str repository: The repository to create the user messages resource in. """ discriminator = ('messaging', repository) reg = get_curre...
python
def messaging(_context, repository, reset_on_start=False): """ Directive for setting up the user message resource in the appropriate repository. :param str repository: The repository to create the user messages resource in. """ discriminator = ('messaging', repository) reg = get_curre...
[ "def", "messaging", "(", "_context", ",", "repository", ",", "reset_on_start", "=", "False", ")", ":", "discriminator", "=", "(", "'messaging'", ",", "repository", ")", "reg", "=", "get_current_registry", "(", ")", "config", "=", "Configurator", "(", "reg", ...
Directive for setting up the user message resource in the appropriate repository. :param str repository: The repository to create the user messages resource in.
[ "Directive", "for", "setting", "up", "the", "user", "message", "resource", "in", "the", "appropriate", "repository", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/directives.py#L186-L200
41,413
rackerlabs/python-lunrclient
lunrclient/displayable.py
Displayable._filter
def _filter(self, dict, keep): """ Remove any keys not in 'keep' """ if not keep: return dict result = {} for key, value in dict.iteritems(): if key in keep: result[key] = value return result
python
def _filter(self, dict, keep): """ Remove any keys not in 'keep' """ if not keep: return dict result = {} for key, value in dict.iteritems(): if key in keep: result[key] = value return result
[ "def", "_filter", "(", "self", ",", "dict", ",", "keep", ")", ":", "if", "not", "keep", ":", "return", "dict", "result", "=", "{", "}", "for", "key", ",", "value", "in", "dict", ".", "iteritems", "(", ")", ":", "if", "key", "in", "keep", ":", "...
Remove any keys not in 'keep'
[ "Remove", "any", "keys", "not", "in", "keep" ]
f26a450a422600f492480bfa42cbee50a5c7016f
https://github.com/rackerlabs/python-lunrclient/blob/f26a450a422600f492480bfa42cbee50a5c7016f/lunrclient/displayable.py#L66-L75
41,414
ponty/confduino
confduino/examples/custom_boards.py
main
def main( upload='usbasp', core='arduino', replace_existing=True, ): """install custom boards.""" def install(mcu, f_cpu, kbyte): board = AutoBunch() board.name = TEMPL_NAME.format(mcu=mcu, f_cpu=format_freq(f_cpu), ...
python
def main( upload='usbasp', core='arduino', replace_existing=True, ): """install custom boards.""" def install(mcu, f_cpu, kbyte): board = AutoBunch() board.name = TEMPL_NAME.format(mcu=mcu, f_cpu=format_freq(f_cpu), ...
[ "def", "main", "(", "upload", "=", "'usbasp'", ",", "core", "=", "'arduino'", ",", "replace_existing", "=", "True", ",", ")", ":", "def", "install", "(", "mcu", ",", "f_cpu", ",", "kbyte", ")", ":", "board", "=", "AutoBunch", "(", ")", "board", ".", ...
install custom boards.
[ "install", "custom", "boards", "." ]
f4c261e5e84997f145a8bdd001f471db74c9054b
https://github.com/ponty/confduino/blob/f4c261e5e84997f145a8bdd001f471db74c9054b/confduino/examples/custom_boards.py#L24-L62
41,415
The-Politico/politico-civic-demography
demography/management/commands/legacy_census.py
Command.write_county_estimate
def write_county_estimate(self, table, variable, code, datum): """ Creates new estimate from a census series. Data has following signature from API: { 'B00001_001E': '5373', 'NAME': 'Anderson County, Texas', 'county': '001', 'state': '4...
python
def write_county_estimate(self, table, variable, code, datum): """ Creates new estimate from a census series. Data has following signature from API: { 'B00001_001E': '5373', 'NAME': 'Anderson County, Texas', 'county': '001', 'state': '4...
[ "def", "write_county_estimate", "(", "self", ",", "table", ",", "variable", ",", "code", ",", "datum", ")", ":", "try", ":", "division", "=", "Division", ".", "objects", ".", "get", "(", "code", "=", "\"{}{}\"", ".", "format", "(", "datum", "[", "\"sta...
Creates new estimate from a census series. Data has following signature from API: { 'B00001_001E': '5373', 'NAME': 'Anderson County, Texas', 'county': '001', 'state': '48' }
[ "Creates", "new", "estimate", "from", "a", "census", "series", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/legacy_census.py#L72-L95
41,416
The-Politico/politico-civic-demography
demography/management/commands/legacy_census.py
Command.get_district_estimates_by_state
def get_district_estimates_by_state( self, api, table, variable, estimate, state ): """ Calls API for all districts in a state and a given estimate. """ state = Division.objects.get(level=self.STATE_LEVEL, code=state) district_data = api.get( ("NAME", esti...
python
def get_district_estimates_by_state( self, api, table, variable, estimate, state ): """ Calls API for all districts in a state and a given estimate. """ state = Division.objects.get(level=self.STATE_LEVEL, code=state) district_data = api.get( ("NAME", esti...
[ "def", "get_district_estimates_by_state", "(", "self", ",", "api", ",", "table", ",", "variable", ",", "estimate", ",", "state", ")", ":", "state", "=", "Division", ".", "objects", ".", "get", "(", "level", "=", "self", ".", "STATE_LEVEL", ",", "code", "...
Calls API for all districts in a state and a given estimate.
[ "Calls", "API", "for", "all", "districts", "in", "a", "state", "and", "a", "given", "estimate", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/legacy_census.py#L110-L126
41,417
The-Politico/politico-civic-demography
demography/management/commands/legacy_census.py
Command.get_county_estimates_by_state
def get_county_estimates_by_state( self, api, table, variable, estimate, state ): """ Calls API for all counties in a state and a given estimate. """ state = Division.objects.get(level=self.STATE_LEVEL, code=state) county_data = api.get( ("NAME", estimate)...
python
def get_county_estimates_by_state( self, api, table, variable, estimate, state ): """ Calls API for all counties in a state and a given estimate. """ state = Division.objects.get(level=self.STATE_LEVEL, code=state) county_data = api.get( ("NAME", estimate)...
[ "def", "get_county_estimates_by_state", "(", "self", ",", "api", ",", "table", ",", "variable", ",", "estimate", ",", "state", ")", ":", "state", "=", "Division", ".", "objects", ".", "get", "(", "level", "=", "self", ".", "STATE_LEVEL", ",", "code", "="...
Calls API for all counties in a state and a given estimate.
[ "Calls", "API", "for", "all", "counties", "in", "a", "state", "and", "a", "given", "estimate", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/legacy_census.py#L128-L141
41,418
The-Politico/politico-civic-demography
demography/management/commands/legacy_census.py
Command.get_state_estimates_by_state
def get_state_estimates_by_state( self, api, table, variable, estimate, state ): """ Calls API for a state and a given estimate. """ state = Division.objects.get(level=self.STATE_LEVEL, code=state) state_data = api.get( ("NAME", estimate), {"fo...
python
def get_state_estimates_by_state( self, api, table, variable, estimate, state ): """ Calls API for a state and a given estimate. """ state = Division.objects.get(level=self.STATE_LEVEL, code=state) state_data = api.get( ("NAME", estimate), {"fo...
[ "def", "get_state_estimates_by_state", "(", "self", ",", "api", ",", "table", ",", "variable", ",", "estimate", ",", "state", ")", ":", "state", "=", "Division", ".", "objects", ".", "get", "(", "level", "=", "self", ".", "STATE_LEVEL", ",", "code", "=",...
Calls API for a state and a given estimate.
[ "Calls", "API", "for", "a", "state", "and", "a", "given", "estimate", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/legacy_census.py#L143-L156
41,419
The-Politico/politico-civic-demography
demography/management/commands/legacy_census.py
Command.aggregate_variable
def aggregate_variable(estimate, id): """ Aggregate census table variables by a custom label. """ estimates = [ variable.estimates.get(division__id=id).estimate for variable in estimate.variable.label.variables.all() ] method = estimate.variable.la...
python
def aggregate_variable(estimate, id): """ Aggregate census table variables by a custom label. """ estimates = [ variable.estimates.get(division__id=id).estimate for variable in estimate.variable.label.variables.all() ] method = estimate.variable.la...
[ "def", "aggregate_variable", "(", "estimate", ",", "id", ")", ":", "estimates", "=", "[", "variable", ".", "estimates", ".", "get", "(", "division__id", "=", "id", ")", ".", "estimate", "for", "variable", "in", "estimate", ".", "variable", ".", "label", ...
Aggregate census table variables by a custom label.
[ "Aggregate", "census", "table", "variables", "by", "a", "custom", "label", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/legacy_census.py#L196-L213
41,420
The-Politico/politico-civic-demography
demography/management/commands/legacy_census.py
Command.aggregate_national_estimates_by_district
def aggregate_national_estimates_by_district(self): """ Aggregates district-level estimates for each table within the country. Creates data structure designed for an export in this format: ...{series}/{year}/{table}/districts.json """ data = {} fips = "00" ...
python
def aggregate_national_estimates_by_district(self): """ Aggregates district-level estimates for each table within the country. Creates data structure designed for an export in this format: ...{series}/{year}/{table}/districts.json """ data = {} fips = "00" ...
[ "def", "aggregate_national_estimates_by_district", "(", "self", ")", ":", "data", "=", "{", "}", "fips", "=", "\"00\"", "aggregated_labels", "=", "[", "]", "states", "=", "Division", ".", "objects", ".", "filter", "(", "level", "=", "self", ".", "DISTRICT_LE...
Aggregates district-level estimates for each table within the country. Creates data structure designed for an export in this format: ...{series}/{year}/{table}/districts.json
[ "Aggregates", "district", "-", "level", "estimates", "for", "each", "table", "within", "the", "country", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/legacy_census.py#L268-L320
41,421
The-Politico/politico-civic-demography
demography/management/commands/legacy_census.py
Command.aggregate_state_estimates_by_county
def aggregate_state_estimates_by_county(self, parent): """ Aggregates county-level estimates for each table within a given state. Creates data structure designed for an export in this format: ...{series}/{year}/{table}/{state_fips}/counties.json """ data = {} for...
python
def aggregate_state_estimates_by_county(self, parent): """ Aggregates county-level estimates for each table within a given state. Creates data structure designed for an export in this format: ...{series}/{year}/{table}/{state_fips}/counties.json """ data = {} for...
[ "def", "aggregate_state_estimates_by_county", "(", "self", ",", "parent", ")", ":", "data", "=", "{", "}", "for", "division", "in", "tqdm", "(", "Division", ".", "objects", ".", "filter", "(", "level", "=", "self", ".", "COUNTY_LEVEL", ",", "parent", "=", ...
Aggregates county-level estimates for each table within a given state. Creates data structure designed for an export in this format: ...{series}/{year}/{table}/{state_fips}/counties.json
[ "Aggregates", "county", "-", "level", "estimates", "for", "each", "table", "within", "a", "given", "state", "." ]
080bb964b64b06db7fd04386530e893ceed1cf98
https://github.com/The-Politico/politico-civic-demography/blob/080bb964b64b06db7fd04386530e893ceed1cf98/demography/management/commands/legacy_census.py#L322-L362
41,422
BlackEarth/bxml
bxml/docx.py
DOCX.xml
def xml(self, fn=None, src='word/document.xml', XMLClass=XML, **params): "return the src with the given transformation applied, if any." if src in self.xml_cache: return self.xml_cache[src] if src not in self.zipfile.namelist(): return x = XMLClass( fn=fn or (self.fn and ...
python
def xml(self, fn=None, src='word/document.xml', XMLClass=XML, **params): "return the src with the given transformation applied, if any." if src in self.xml_cache: return self.xml_cache[src] if src not in self.zipfile.namelist(): return x = XMLClass( fn=fn or (self.fn and ...
[ "def", "xml", "(", "self", ",", "fn", "=", "None", ",", "src", "=", "'word/document.xml'", ",", "XMLClass", "=", "XML", ",", "*", "*", "params", ")", ":", "if", "src", "in", "self", ".", "xml_cache", ":", "return", "self", ".", "xml_cache", "[", "s...
return the src with the given transformation applied, if any.
[ "return", "the", "src", "with", "the", "given", "transformation", "applied", "if", "any", "." ]
8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77
https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/docx.py#L63-L71
41,423
BlackEarth/bxml
bxml/docx.py
DOCX.endnotemap
def endnotemap(self, cache=True): """return the endnotes from the docx, keyed to string id.""" if self.__endnotemap is not None and cache==True: return self.__endnotemap else: x = self.xml(src='word/endnotes.xml') d = Dict() if x is None: return d ...
python
def endnotemap(self, cache=True): """return the endnotes from the docx, keyed to string id.""" if self.__endnotemap is not None and cache==True: return self.__endnotemap else: x = self.xml(src='word/endnotes.xml') d = Dict() if x is None: return d ...
[ "def", "endnotemap", "(", "self", ",", "cache", "=", "True", ")", ":", "if", "self", ".", "__endnotemap", "is", "not", "None", "and", "cache", "==", "True", ":", "return", "self", ".", "__endnotemap", "else", ":", "x", "=", "self", ".", "xml", "(", ...
return the endnotes from the docx, keyed to string id.
[ "return", "the", "endnotes", "from", "the", "docx", "keyed", "to", "string", "id", "." ]
8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77
https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/docx.py#L134-L147
41,424
BlackEarth/bxml
bxml/docx.py
DOCX.footnotemap
def footnotemap(self, cache=True): """return the footnotes from the docx, keyed to string id.""" if self.__footnotemap is not None and cache==True: return self.__footnotemap else: x = self.xml(src='word/footnotes.xml') d = Dict() if x is None: retu...
python
def footnotemap(self, cache=True): """return the footnotes from the docx, keyed to string id.""" if self.__footnotemap is not None and cache==True: return self.__footnotemap else: x = self.xml(src='word/footnotes.xml') d = Dict() if x is None: retu...
[ "def", "footnotemap", "(", "self", ",", "cache", "=", "True", ")", ":", "if", "self", ".", "__footnotemap", "is", "not", "None", "and", "cache", "==", "True", ":", "return", "self", ".", "__footnotemap", "else", ":", "x", "=", "self", ".", "xml", "("...
return the footnotes from the docx, keyed to string id.
[ "return", "the", "footnotes", "from", "the", "docx", "keyed", "to", "string", "id", "." ]
8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77
https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/docx.py#L149-L162
41,425
BlackEarth/bxml
bxml/docx.py
DOCX.commentmap
def commentmap(self, cache=True): """return the comments from the docx, keyed to string id.""" if self.__commentmap is not None and cache==True: return self.__commentmap else: x = self.xml(src='word/comments.xml') d = Dict() if x is None: return d ...
python
def commentmap(self, cache=True): """return the comments from the docx, keyed to string id.""" if self.__commentmap is not None and cache==True: return self.__commentmap else: x = self.xml(src='word/comments.xml') d = Dict() if x is None: return d ...
[ "def", "commentmap", "(", "self", ",", "cache", "=", "True", ")", ":", "if", "self", ".", "__commentmap", "is", "not", "None", "and", "cache", "==", "True", ":", "return", "self", ".", "__commentmap", "else", ":", "x", "=", "self", ".", "xml", "(", ...
return the comments from the docx, keyed to string id.
[ "return", "the", "comments", "from", "the", "docx", "keyed", "to", "string", "id", "." ]
8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77
https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/docx.py#L164-L177
41,426
BlackEarth/bxml
bxml/docx.py
DOCX.selector
def selector(C, style): """return the selector for the given stylemap style""" clas = C.classname(style.name) if style.type == 'paragraph': # heading outline levels are 0..7 internally, indicating h1..h8 outlineLvl = int((style.properties.get('outlineLvl') or {}).get('val...
python
def selector(C, style): """return the selector for the given stylemap style""" clas = C.classname(style.name) if style.type == 'paragraph': # heading outline levels are 0..7 internally, indicating h1..h8 outlineLvl = int((style.properties.get('outlineLvl') or {}).get('val...
[ "def", "selector", "(", "C", ",", "style", ")", ":", "clas", "=", "C", ".", "classname", "(", "style", ".", "name", ")", "if", "style", ".", "type", "==", "'paragraph'", ":", "# heading outline levels are 0..7 internally, indicating h1..h8", "outlineLvl", "=", ...
return the selector for the given stylemap style
[ "return", "the", "selector", "for", "the", "given", "stylemap", "style" ]
8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77
https://github.com/BlackEarth/bxml/blob/8fbea5dad7fadc7b854ddbeff6ecfb55aaceeb77/bxml/docx.py#L226-L242
41,427
helixyte/everest
everest/resources/storing.py
load_collection_from_stream
def load_collection_from_stream(resource, stream, content_type): """ Creates a new collection for the registered resource and calls `load_into_collection_from_stream` with it. """ coll = create_staging_collection(resource) load_into_collection_from_stream(coll, stream, content_type) return c...
python
def load_collection_from_stream(resource, stream, content_type): """ Creates a new collection for the registered resource and calls `load_into_collection_from_stream` with it. """ coll = create_staging_collection(resource) load_into_collection_from_stream(coll, stream, content_type) return c...
[ "def", "load_collection_from_stream", "(", "resource", ",", "stream", ",", "content_type", ")", ":", "coll", "=", "create_staging_collection", "(", "resource", ")", "load_into_collection_from_stream", "(", "coll", ",", "stream", ",", "content_type", ")", "return", "...
Creates a new collection for the registered resource and calls `load_into_collection_from_stream` with it.
[ "Creates", "a", "new", "collection", "for", "the", "registered", "resource", "and", "calls", "load_into_collection_from_stream", "with", "it", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L72-L79
41,428
helixyte/everest
everest/resources/storing.py
load_into_collection_from_file
def load_into_collection_from_file(collection, filename, content_type=None): """ Loads resources from the specified file into the given collection resource. If no content type is provided, an attempt is made to look up the extension of the given filename in the MI...
python
def load_into_collection_from_file(collection, filename, content_type=None): """ Loads resources from the specified file into the given collection resource. If no content type is provided, an attempt is made to look up the extension of the given filename in the MI...
[ "def", "load_into_collection_from_file", "(", "collection", ",", "filename", ",", "content_type", "=", "None", ")", ":", "if", "content_type", "is", "None", ":", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "1", "]", "try", ...
Loads resources from the specified file into the given collection resource. If no content type is provided, an attempt is made to look up the extension of the given filename in the MIME content type registry.
[ "Loads", "resources", "from", "the", "specified", "file", "into", "the", "given", "collection", "resource", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L82-L99
41,429
helixyte/everest
everest/resources/storing.py
load_collection_from_file
def load_collection_from_file(resource, filename, content_type=None): """ Creates a new collection for the registered resource and calls `load_into_collection_from_file` with it. """ coll = create_staging_collection(resource) load_into_collection_from_file(coll, filename, ...
python
def load_collection_from_file(resource, filename, content_type=None): """ Creates a new collection for the registered resource and calls `load_into_collection_from_file` with it. """ coll = create_staging_collection(resource) load_into_collection_from_file(coll, filename, ...
[ "def", "load_collection_from_file", "(", "resource", ",", "filename", ",", "content_type", "=", "None", ")", ":", "coll", "=", "create_staging_collection", "(", "resource", ")", "load_into_collection_from_file", "(", "coll", ",", "filename", ",", "content_type", "="...
Creates a new collection for the registered resource and calls `load_into_collection_from_file` with it.
[ "Creates", "a", "new", "collection", "for", "the", "registered", "resource", "and", "calls", "load_into_collection_from_file", "with", "it", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L102-L110
41,430
helixyte/everest
everest/resources/storing.py
load_into_collection_from_url
def load_into_collection_from_url(collection, url, content_type=None): """ Loads resources from the representation contained in the given URL into the given collection resource. :returns: collection resource """ parsed = urlparse.urlparse(url) scheme = parsed.scheme # pylint: disable=E1101 ...
python
def load_into_collection_from_url(collection, url, content_type=None): """ Loads resources from the representation contained in the given URL into the given collection resource. :returns: collection resource """ parsed = urlparse.urlparse(url) scheme = parsed.scheme # pylint: disable=E1101 ...
[ "def", "load_into_collection_from_url", "(", "collection", ",", "url", ",", "content_type", "=", "None", ")", ":", "parsed", "=", "urlparse", ".", "urlparse", "(", "url", ")", "scheme", "=", "parsed", ".", "scheme", "# pylint: disable=E1101", "if", "scheme", "...
Loads resources from the representation contained in the given URL into the given collection resource. :returns: collection resource
[ "Loads", "resources", "from", "the", "representation", "contained", "in", "the", "given", "URL", "into", "the", "given", "collection", "resource", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L113-L128
41,431
helixyte/everest
everest/resources/storing.py
load_collection_from_url
def load_collection_from_url(resource, url, content_type=None): """ Creates a new collection for the registered resource and calls `load_into_collection_from_url` with it. """ coll = create_staging_collection(resource) load_into_collection_from_url(coll, url, content_type=content_type) retur...
python
def load_collection_from_url(resource, url, content_type=None): """ Creates a new collection for the registered resource and calls `load_into_collection_from_url` with it. """ coll = create_staging_collection(resource) load_into_collection_from_url(coll, url, content_type=content_type) retur...
[ "def", "load_collection_from_url", "(", "resource", ",", "url", ",", "content_type", "=", "None", ")", ":", "coll", "=", "create_staging_collection", "(", "resource", ")", "load_into_collection_from_url", "(", "coll", ",", "url", ",", "content_type", "=", "content...
Creates a new collection for the registered resource and calls `load_into_collection_from_url` with it.
[ "Creates", "a", "new", "collection", "for", "the", "registered", "resource", "and", "calls", "load_into_collection_from_url", "with", "it", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L131-L138
41,432
helixyte/everest
everest/resources/storing.py
load_into_collections_from_zipfile
def load_into_collections_from_zipfile(collections, zipfile): """ Loads resources contained in the given ZIP archive into each of the given collections. The ZIP file is expected to contain a list of file names obtained with the :func:`get_collection_filename` function, each pointing to a file o...
python
def load_into_collections_from_zipfile(collections, zipfile): """ Loads resources contained in the given ZIP archive into each of the given collections. The ZIP file is expected to contain a list of file names obtained with the :func:`get_collection_filename` function, each pointing to a file o...
[ "def", "load_into_collections_from_zipfile", "(", "collections", ",", "zipfile", ")", ":", "with", "ZipFile", "(", "zipfile", ")", "as", "zipf", ":", "names", "=", "zipf", ".", "namelist", "(", ")", "name_map", "=", "dict", "(", "[", "(", "os", ".", "pat...
Loads resources contained in the given ZIP archive into each of the given collections. The ZIP file is expected to contain a list of file names obtained with the :func:`get_collection_filename` function, each pointing to a file of zipped collection resource data. :param collections: sequence of co...
[ "Loads", "resources", "contained", "in", "the", "given", "ZIP", "archive", "into", "each", "of", "the", "given", "collections", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L160-L195
41,433
helixyte/everest
everest/resources/storing.py
build_resource_dependency_graph
def build_resource_dependency_graph(resource_classes, include_backrefs=False): """ Builds a graph of dependencies among the given resource classes. The dependency graph is a directed graph with member resource classes as nodes. An edge between two nodes represents a ...
python
def build_resource_dependency_graph(resource_classes, include_backrefs=False): """ Builds a graph of dependencies among the given resource classes. The dependency graph is a directed graph with member resource classes as nodes. An edge between two nodes represents a ...
[ "def", "build_resource_dependency_graph", "(", "resource_classes", ",", "include_backrefs", "=", "False", ")", ":", "def", "visit", "(", "mb_cls", ",", "grph", ",", "path", ",", "incl_backrefs", ")", ":", "for", "attr_name", "in", "get_resource_class_attribute_names...
Builds a graph of dependencies among the given resource classes. The dependency graph is a directed graph with member resource classes as nodes. An edge between two nodes represents a member or collection attribute. :param resource_classes: resource classes to determine interdependencies of. ...
[ "Builds", "a", "graph", "of", "dependencies", "among", "the", "given", "resource", "classes", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L209-L249
41,434
helixyte/everest
everest/resources/storing.py
build_resource_graph
def build_resource_graph(resource, dependency_graph=None): """ Traverses the graph of resources that is reachable from the given resource. If a resource dependency graph is given, links to other resources are only followed if the dependency graph has an edge connecting the two corresponding res...
python
def build_resource_graph(resource, dependency_graph=None): """ Traverses the graph of resources that is reachable from the given resource. If a resource dependency graph is given, links to other resources are only followed if the dependency graph has an edge connecting the two corresponding res...
[ "def", "build_resource_graph", "(", "resource", ",", "dependency_graph", "=", "None", ")", ":", "def", "visit", "(", "rc", ",", "grph", ",", "dep_grph", ")", ":", "mb_cls", "=", "type", "(", "rc", ")", "attr_map", "=", "get_resource_class_attributes", "(", ...
Traverses the graph of resources that is reachable from the given resource. If a resource dependency graph is given, links to other resources are only followed if the dependency graph has an edge connecting the two corresponding resource classes; otherwise, a default graph is built which ignores al...
[ "Traverses", "the", "graph", "of", "resources", "that", "is", "reachable", "from", "the", "given", "resource", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L252-L300
41,435
helixyte/everest
everest/resources/storing.py
find_connected_resources
def find_connected_resources(resource, dependency_graph=None): """ Collects all resources connected to the given resource and returns a dictionary mapping member resource classes to new collections containing the members found. """ # Build a resource_graph. resource_graph = \ ...
python
def find_connected_resources(resource, dependency_graph=None): """ Collects all resources connected to the given resource and returns a dictionary mapping member resource classes to new collections containing the members found. """ # Build a resource_graph. resource_graph = \ ...
[ "def", "find_connected_resources", "(", "resource", ",", "dependency_graph", "=", "None", ")", ":", "# Build a resource_graph.", "resource_graph", "=", "build_resource_graph", "(", "resource", ",", "dependency_graph", "=", "dependency_graph", ")", "entity_map", "=", "Or...
Collects all resources connected to the given resource and returns a dictionary mapping member resource classes to new collections containing the members found.
[ "Collects", "all", "resources", "connected", "to", "the", "given", "resource", "and", "returns", "a", "dictionary", "mapping", "member", "resource", "classes", "to", "new", "collections", "containing", "the", "members", "found", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L303-L321
41,436
helixyte/everest
everest/resources/storing.py
ConnectedResourcesSerializer.to_files
def to_files(self, resource, directory): """ Dumps the given resource and all resources linked to it into a set of representation files in the given directory. """ collections = self.__collect(resource) for (mb_cls, coll) in iteritems_(collections): fn = get_w...
python
def to_files(self, resource, directory): """ Dumps the given resource and all resources linked to it into a set of representation files in the given directory. """ collections = self.__collect(resource) for (mb_cls, coll) in iteritems_(collections): fn = get_w...
[ "def", "to_files", "(", "self", ",", "resource", ",", "directory", ")", ":", "collections", "=", "self", ".", "__collect", "(", "resource", ")", "for", "(", "mb_cls", ",", "coll", ")", "in", "iteritems_", "(", "collections", ")", ":", "fn", "=", "get_w...
Dumps the given resource and all resources linked to it into a set of representation files in the given directory.
[ "Dumps", "the", "given", "resource", "and", "all", "resources", "linked", "to", "it", "into", "a", "set", "of", "representation", "files", "in", "the", "given", "directory", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L400-L411
41,437
helixyte/everest
everest/resources/storing.py
ConnectedResourcesSerializer.to_zipfile
def to_zipfile(self, resource, zipfile): """ Dumps the given resource and all resources linked to it into the given ZIP file. """ rpr_map = self.to_strings(resource) with ZipFile(zipfile, 'w') as zipf: for (mb_cls, rpr_string) in iteritems_(rpr_map): ...
python
def to_zipfile(self, resource, zipfile): """ Dumps the given resource and all resources linked to it into the given ZIP file. """ rpr_map = self.to_strings(resource) with ZipFile(zipfile, 'w') as zipf: for (mb_cls, rpr_string) in iteritems_(rpr_map): ...
[ "def", "to_zipfile", "(", "self", ",", "resource", ",", "zipfile", ")", ":", "rpr_map", "=", "self", ".", "to_strings", "(", "resource", ")", "with", "ZipFile", "(", "zipfile", ",", "'w'", ")", "as", "zipf", ":", "for", "(", "mb_cls", ",", "rpr_string"...
Dumps the given resource and all resources linked to it into the given ZIP file.
[ "Dumps", "the", "given", "resource", "and", "all", "resources", "linked", "to", "it", "into", "the", "given", "ZIP", "file", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/resources/storing.py#L413-L422
41,438
erikvw/django-collect-offline-files
django_collect_offline_files/transaction/transaction_importer.py
JSONLoadFile.read
def read(self): """Returns the file contents as validated JSON text. """ p = os.path.join(self.path, self.name) try: with open(p) as f: json_text = f.read() except FileNotFoundError as e: raise JSONFileError(e) from e try: ...
python
def read(self): """Returns the file contents as validated JSON text. """ p = os.path.join(self.path, self.name) try: with open(p) as f: json_text = f.read() except FileNotFoundError as e: raise JSONFileError(e) from e try: ...
[ "def", "read", "(", "self", ")", ":", "p", "=", "os", ".", "path", ".", "join", "(", "self", ".", "path", ",", "self", ".", "name", ")", "try", ":", "with", "open", "(", "p", ")", "as", "f", ":", "json_text", "=", "f", ".", "read", "(", ")"...
Returns the file contents as validated JSON text.
[ "Returns", "the", "file", "contents", "as", "validated", "JSON", "text", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_importer.py#L62-L75
41,439
erikvw/django-collect-offline-files
django_collect_offline_files/transaction/transaction_importer.py
BatchHistory.exists
def exists(self, batch_id=None): """Returns True if batch_id exists in the history. """ try: self.model.objects.get(batch_id=batch_id) except self.model.DoesNotExist: return False return True
python
def exists(self, batch_id=None): """Returns True if batch_id exists in the history. """ try: self.model.objects.get(batch_id=batch_id) except self.model.DoesNotExist: return False return True
[ "def", "exists", "(", "self", ",", "batch_id", "=", "None", ")", ":", "try", ":", "self", ".", "model", ".", "objects", ".", "get", "(", "batch_id", "=", "batch_id", ")", "except", "self", ".", "model", ".", "DoesNotExist", ":", "return", "False", "r...
Returns True if batch_id exists in the history.
[ "Returns", "True", "if", "batch_id", "exists", "in", "the", "history", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_importer.py#L91-L98
41,440
erikvw/django-collect-offline-files
django_collect_offline_files/transaction/transaction_importer.py
BatchHistory.update
def update( self, filename=None, batch_id=None, prev_batch_id=None, producer=None, count=None, ): """Creates an history model instance. """ # TODO: refactor model enforce unique batch_id # TODO: refactor model to not allow NULLs ...
python
def update( self, filename=None, batch_id=None, prev_batch_id=None, producer=None, count=None, ): """Creates an history model instance. """ # TODO: refactor model enforce unique batch_id # TODO: refactor model to not allow NULLs ...
[ "def", "update", "(", "self", ",", "filename", "=", "None", ",", "batch_id", "=", "None", ",", "prev_batch_id", "=", "None", ",", "producer", "=", "None", ",", "count", "=", "None", ",", ")", ":", "# TODO: refactor model enforce unique batch_id", "# TODO: refa...
Creates an history model instance.
[ "Creates", "an", "history", "model", "instance", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_importer.py#L106-L140
41,441
erikvw/django-collect-offline-files
django_collect_offline_files/transaction/transaction_importer.py
ImportBatch.populate
def populate(self, deserialized_txs=None, filename=None, retry=None): """Populates the batch with unsaved model instances from a generator of deserialized objects. """ if not deserialized_txs: raise BatchError("Failed to populate batch. There are no objects to add.") ...
python
def populate(self, deserialized_txs=None, filename=None, retry=None): """Populates the batch with unsaved model instances from a generator of deserialized objects. """ if not deserialized_txs: raise BatchError("Failed to populate batch. There are no objects to add.") ...
[ "def", "populate", "(", "self", ",", "deserialized_txs", "=", "None", ",", "filename", "=", "None", ",", "retry", "=", "None", ")", ":", "if", "not", "deserialized_txs", ":", "raise", "BatchError", "(", "\"Failed to populate batch. There are no objects to add.\"", ...
Populates the batch with unsaved model instances from a generator of deserialized objects.
[ "Populates", "the", "batch", "with", "unsaved", "model", "instances", "from", "a", "generator", "of", "deserialized", "objects", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_importer.py#L160-L179
41,442
erikvw/django-collect-offline-files
django_collect_offline_files/transaction/transaction_importer.py
ImportBatch.peek
def peek(self, deserialized_tx): """Peeks into first tx and sets self attrs or raise. """ self.batch_id = deserialized_tx.object.batch_id self.prev_batch_id = deserialized_tx.object.prev_batch_id self.producer = deserialized_tx.object.producer if self.batch_history.exists...
python
def peek(self, deserialized_tx): """Peeks into first tx and sets self attrs or raise. """ self.batch_id = deserialized_tx.object.batch_id self.prev_batch_id = deserialized_tx.object.prev_batch_id self.producer = deserialized_tx.object.producer if self.batch_history.exists...
[ "def", "peek", "(", "self", ",", "deserialized_tx", ")", ":", "self", ".", "batch_id", "=", "deserialized_tx", ".", "object", ".", "batch_id", "self", ".", "prev_batch_id", "=", "deserialized_tx", ".", "object", ".", "prev_batch_id", "self", ".", "producer", ...
Peeks into first tx and sets self attrs or raise.
[ "Peeks", "into", "first", "tx", "and", "sets", "self", "attrs", "or", "raise", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_importer.py#L181-L197
41,443
erikvw/django-collect-offline-files
django_collect_offline_files/transaction/transaction_importer.py
ImportBatch.save
def save(self): """Saves all model instances in the batch as model. """ saved = 0 if not self.objects: raise BatchError("Save failed. Batch is empty") for deserialized_tx in self.objects: try: self.model.objects.get(pk=deserialized_tx.pk) ...
python
def save(self): """Saves all model instances in the batch as model. """ saved = 0 if not self.objects: raise BatchError("Save failed. Batch is empty") for deserialized_tx in self.objects: try: self.model.objects.get(pk=deserialized_tx.pk) ...
[ "def", "save", "(", "self", ")", ":", "saved", "=", "0", "if", "not", "self", ".", "objects", ":", "raise", "BatchError", "(", "\"Save failed. Batch is empty\"", ")", "for", "deserialized_tx", "in", "self", ".", "objects", ":", "try", ":", "self", ".", "...
Saves all model instances in the batch as model.
[ "Saves", "all", "model", "instances", "in", "the", "batch", "as", "model", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_importer.py#L199-L217
41,444
erikvw/django-collect-offline-files
django_collect_offline_files/transaction/transaction_importer.py
TransactionImporter.import_batch
def import_batch(self, filename): """Imports the batch of outgoing transactions into model IncomingTransaction. """ batch = self.batch_cls() json_file = self.json_file_cls(name=filename, path=self.path) try: deserialized_txs = json_file.deserialized_objects ...
python
def import_batch(self, filename): """Imports the batch of outgoing transactions into model IncomingTransaction. """ batch = self.batch_cls() json_file = self.json_file_cls(name=filename, path=self.path) try: deserialized_txs = json_file.deserialized_objects ...
[ "def", "import_batch", "(", "self", ",", "filename", ")", ":", "batch", "=", "self", ".", "batch_cls", "(", ")", "json_file", "=", "self", ".", "json_file_cls", "(", "name", "=", "filename", ",", "path", "=", "self", ".", "path", ")", "try", ":", "de...
Imports the batch of outgoing transactions into model IncomingTransaction.
[ "Imports", "the", "batch", "of", "outgoing", "transactions", "into", "model", "IncomingTransaction", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/transaction/transaction_importer.py#L264-L284
41,445
dfm/ugly
ugly/feedfinder.py
timelimit
def timelimit(timeout): """borrowed from web.py""" def _1(function): def _2(*args, **kw): class Dispatch(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.result = None self.error = None ...
python
def timelimit(timeout): """borrowed from web.py""" def _1(function): def _2(*args, **kw): class Dispatch(threading.Thread): def __init__(self): threading.Thread.__init__(self) self.result = None self.error = None ...
[ "def", "timelimit", "(", "timeout", ")", ":", "def", "_1", "(", "function", ")", ":", "def", "_2", "(", "*", "args", ",", "*", "*", "kw", ")", ":", "class", "Dispatch", "(", "threading", ".", "Thread", ")", ":", "def", "__init__", "(", "self", ")...
borrowed from web.py
[ "borrowed", "from", "web", ".", "py" ]
bc09834849184552619ee926d7563ed37630accb
https://github.com/dfm/ugly/blob/bc09834849184552619ee926d7563ed37630accb/ugly/feedfinder.py#L53-L80
41,446
steder/txtemplate
txtemplate/templates.py
GenshiTemplateAdapter._populateBuffer
def _populateBuffer(self, stream, n): """ Iterator that returns N steps of the genshi stream. Found that performance really sucks for n = 1 (0.5 requests/second for the root resources versus 80 requests/second for a blocking algorithm). Hopefully increasing the ...
python
def _populateBuffer(self, stream, n): """ Iterator that returns N steps of the genshi stream. Found that performance really sucks for n = 1 (0.5 requests/second for the root resources versus 80 requests/second for a blocking algorithm). Hopefully increasing the ...
[ "def", "_populateBuffer", "(", "self", ",", "stream", ",", "n", ")", ":", "try", ":", "for", "x", "in", "xrange", "(", "n", ")", ":", "output", "=", "stream", ".", "next", "(", ")", "self", ".", "_buffer", ".", "write", "(", "output", ")", "excep...
Iterator that returns N steps of the genshi stream. Found that performance really sucks for n = 1 (0.5 requests/second for the root resources versus 80 requests/second for a blocking algorithm). Hopefully increasing the number of steps per timeslice will significantly i...
[ "Iterator", "that", "returns", "N", "steps", "of", "the", "genshi", "stream", "." ]
0177bafca7c3b43c1b8e919174f280da917e6767
https://github.com/steder/txtemplate/blob/0177bafca7c3b43c1b8e919174f280da917e6767/txtemplate/templates.py#L143-L164
41,447
kapot65/python-df-parser
dfparser/envelope_parser.py
create_message
def create_message( json_meta, data, data_type=0, version=b'\x00\x01@\x00'): """Create message, containing meta and data in df-envelope format. @json_meta - metadata @data - binary data @data_type - data type code for binary data @version - version of machine header @return - message as...
python
def create_message( json_meta, data, data_type=0, version=b'\x00\x01@\x00'): """Create message, containing meta and data in df-envelope format. @json_meta - metadata @data - binary data @data_type - data type code for binary data @version - version of machine header @return - message as...
[ "def", "create_message", "(", "json_meta", ",", "data", ",", "data_type", "=", "0", ",", "version", "=", "b'\\x00\\x01@\\x00'", ")", ":", "__check_data", "(", "data", ")", "meta", "=", "__prepare_meta", "(", "json_meta", ")", "data", "=", "__compress", "(", ...
Create message, containing meta and data in df-envelope format. @json_meta - metadata @data - binary data @data_type - data type code for binary data @version - version of machine header @return - message as bytearray
[ "Create", "message", "containing", "meta", "and", "data", "in", "df", "-", "envelope", "format", "." ]
bb3eec0fb7ca85d72cb1d9ed7415efe074594f26
https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/envelope_parser.py#L15-L32
41,448
kapot65/python-df-parser
dfparser/envelope_parser.py
parse_from_file
def parse_from_file(filename, nodata=False): """Parse df message from file. @filename - path to file @nodata - do not load data @return - [binary header, metadata, binary data] """ header = None with open(filename, "rb") as file: header = read_machine_header(file) meta_raw ...
python
def parse_from_file(filename, nodata=False): """Parse df message from file. @filename - path to file @nodata - do not load data @return - [binary header, metadata, binary data] """ header = None with open(filename, "rb") as file: header = read_machine_header(file) meta_raw ...
[ "def", "parse_from_file", "(", "filename", ",", "nodata", "=", "False", ")", ":", "header", "=", "None", "with", "open", "(", "filename", ",", "\"rb\"", ")", "as", "file", ":", "header", "=", "read_machine_header", "(", "file", ")", "meta_raw", "=", "fil...
Parse df message from file. @filename - path to file @nodata - do not load data @return - [binary header, metadata, binary data]
[ "Parse", "df", "message", "from", "file", "." ]
bb3eec0fb7ca85d72cb1d9ed7415efe074594f26
https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/envelope_parser.py#L35-L52
41,449
kapot65/python-df-parser
dfparser/envelope_parser.py
parse_message
def parse_message(message, nodata=False): """Parse df message from bytearray. @message - message data @nodata - do not load data @return - [binary header, metadata, binary data] """ header = read_machine_header(message) h_len = __get_machine_header_length(header) meta_raw = message[h_l...
python
def parse_message(message, nodata=False): """Parse df message from bytearray. @message - message data @nodata - do not load data @return - [binary header, metadata, binary data] """ header = read_machine_header(message) h_len = __get_machine_header_length(header) meta_raw = message[h_l...
[ "def", "parse_message", "(", "message", ",", "nodata", "=", "False", ")", ":", "header", "=", "read_machine_header", "(", "message", ")", "h_len", "=", "__get_machine_header_length", "(", "header", ")", "meta_raw", "=", "message", "[", "h_len", ":", "h_len", ...
Parse df message from bytearray. @message - message data @nodata - do not load data @return - [binary header, metadata, binary data]
[ "Parse", "df", "message", "from", "bytearray", "." ]
bb3eec0fb7ca85d72cb1d9ed7415efe074594f26
https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/envelope_parser.py#L55-L74
41,450
kapot65/python-df-parser
dfparser/envelope_parser.py
read_machine_header
def read_machine_header(data): """Parse binary header. @data - bytearray, contains binary header of file opened in 'rb' mode @return - parsed binary header """ if isinstance(data, (bytes, bytearray)): stream = io.BytesIO(data) elif isinstance(data, io.BufferedReader): stream = ...
python
def read_machine_header(data): """Parse binary header. @data - bytearray, contains binary header of file opened in 'rb' mode @return - parsed binary header """ if isinstance(data, (bytes, bytearray)): stream = io.BytesIO(data) elif isinstance(data, io.BufferedReader): stream = ...
[ "def", "read_machine_header", "(", "data", ")", ":", "if", "isinstance", "(", "data", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "stream", "=", "io", ".", "BytesIO", "(", "data", ")", "elif", "isinstance", "(", "data", ",", "io", ".", "Buffe...
Parse binary header. @data - bytearray, contains binary header of file opened in 'rb' mode @return - parsed binary header
[ "Parse", "binary", "header", "." ]
bb3eec0fb7ca85d72cb1d9ed7415efe074594f26
https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/envelope_parser.py#L77-L112
41,451
kapot65/python-df-parser
dfparser/envelope_parser.py
get_messages_from_stream
def get_messages_from_stream(data): """Extract complete messages from stream and cut out them from stream. @data - stream binary data @return - [list of messages, choped stream data] """ messages = [] iterator = HEADER_RE.finditer(data) last_pos = 0 for match in iterator: pos =...
python
def get_messages_from_stream(data): """Extract complete messages from stream and cut out them from stream. @data - stream binary data @return - [list of messages, choped stream data] """ messages = [] iterator = HEADER_RE.finditer(data) last_pos = 0 for match in iterator: pos =...
[ "def", "get_messages_from_stream", "(", "data", ")", ":", "messages", "=", "[", "]", "iterator", "=", "HEADER_RE", ".", "finditer", "(", "data", ")", "last_pos", "=", "0", "for", "match", "in", "iterator", ":", "pos", "=", "match", ".", "span", "(", ")...
Extract complete messages from stream and cut out them from stream. @data - stream binary data @return - [list of messages, choped stream data]
[ "Extract", "complete", "messages", "from", "stream", "and", "cut", "out", "them", "from", "stream", "." ]
bb3eec0fb7ca85d72cb1d9ed7415efe074594f26
https://github.com/kapot65/python-df-parser/blob/bb3eec0fb7ca85d72cb1d9ed7415efe074594f26/dfparser/envelope_parser.py#L115-L140
41,452
helixyte/everest
everest/representers/mapping.py
Mapping.clone
def clone(self, options=None, attribute_options=None): """ Returns a clone of this mapping that is configured with the given option and attribute option dictionaries. :param dict options: Maps representer options to their values. :param dict attribute_options: Maps attribute nam...
python
def clone(self, options=None, attribute_options=None): """ Returns a clone of this mapping that is configured with the given option and attribute option dictionaries. :param dict options: Maps representer options to their values. :param dict attribute_options: Maps attribute nam...
[ "def", "clone", "(", "self", ",", "options", "=", "None", ",", "attribute_options", "=", "None", ")", ":", "copied_cfg", "=", "self", ".", "__configurations", "[", "-", "1", "]", ".", "copy", "(", ")", "upd_cfg", "=", "type", "(", "copied_cfg", ")", ...
Returns a clone of this mapping that is configured with the given option and attribute option dictionaries. :param dict options: Maps representer options to their values. :param dict attribute_options: Maps attribute names to dictionaries mapping attribute options to their values.
[ "Returns", "a", "clone", "of", "this", "mapping", "that", "is", "configured", "with", "the", "given", "option", "and", "attribute", "option", "dictionaries", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L72-L86
41,453
helixyte/everest
everest/representers/mapping.py
Mapping.update
def update(self, options=None, attribute_options=None): """ Updates this mapping with the given option and attribute option maps. :param dict options: Maps representer options to their values. :param dict attribute_options: Maps attribute names to dictionaries mapping attribut...
python
def update(self, options=None, attribute_options=None): """ Updates this mapping with the given option and attribute option maps. :param dict options: Maps representer options to their values. :param dict attribute_options: Maps attribute names to dictionaries mapping attribut...
[ "def", "update", "(", "self", ",", "options", "=", "None", ",", "attribute_options", "=", "None", ")", ":", "attr_map", "=", "self", ".", "__get_attribute_map", "(", "self", ".", "__mapped_cls", ",", "None", ",", "0", ")", "for", "attributes", "in", "att...
Updates this mapping with the given option and attribute option maps. :param dict options: Maps representer options to their values. :param dict attribute_options: Maps attribute names to dictionaries mapping attribute options to their values.
[ "Updates", "this", "mapping", "with", "the", "given", "option", "and", "attribute", "option", "maps", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L88-L105
41,454
helixyte/everest
everest/representers/mapping.py
Mapping.get_attribute_map
def get_attribute_map(self, mapped_class=None, key=None): """ Returns an ordered map of the mapped attributes for the given mapped class and attribute key. :param key: Tuple of attribute names specifying a path to a nested attribute in a resource tree. If this is not given, al...
python
def get_attribute_map(self, mapped_class=None, key=None): """ Returns an ordered map of the mapped attributes for the given mapped class and attribute key. :param key: Tuple of attribute names specifying a path to a nested attribute in a resource tree. If this is not given, al...
[ "def", "get_attribute_map", "(", "self", ",", "mapped_class", "=", "None", ",", "key", "=", "None", ")", ":", "if", "mapped_class", "is", "None", ":", "mapped_class", "=", "self", ".", "__mapped_cls", "if", "key", "is", "None", ":", "key", "=", "MappedAt...
Returns an ordered map of the mapped attributes for the given mapped class and attribute key. :param key: Tuple of attribute names specifying a path to a nested attribute in a resource tree. If this is not given, all attributes in this mapping will be returned.
[ "Returns", "an", "ordered", "map", "of", "the", "mapped", "attributes", "for", "the", "given", "mapped", "class", "and", "attribute", "key", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L117-L132
41,455
helixyte/everest
everest/representers/mapping.py
Mapping.create_data_element
def create_data_element(self, mapped_class=None): """ Returns a new data element for the given mapped class. :returns: object implementing :class:`IResourceDataElement`. """ if not mapped_class is None and mapped_class != self.__mapped_cls: mp = self.__mp_reg.find_or...
python
def create_data_element(self, mapped_class=None): """ Returns a new data element for the given mapped class. :returns: object implementing :class:`IResourceDataElement`. """ if not mapped_class is None and mapped_class != self.__mapped_cls: mp = self.__mp_reg.find_or...
[ "def", "create_data_element", "(", "self", ",", "mapped_class", "=", "None", ")", ":", "if", "not", "mapped_class", "is", "None", "and", "mapped_class", "!=", "self", ".", "__mapped_cls", ":", "mp", "=", "self", ".", "__mp_reg", ".", "find_or_create_mapping", ...
Returns a new data element for the given mapped class. :returns: object implementing :class:`IResourceDataElement`.
[ "Returns", "a", "new", "data", "element", "for", "the", "given", "mapped", "class", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L204-L215
41,456
helixyte/everest
everest/representers/mapping.py
Mapping.create_linked_data_element
def create_linked_data_element(self, url, kind, id=None, # pylint: disable=W0622 relation=None, title=None): """ Returns a new linked data element for the given url and kind. :param str url: URL to assign to the linked data element. :param str kind: ki...
python
def create_linked_data_element(self, url, kind, id=None, # pylint: disable=W0622 relation=None, title=None): """ Returns a new linked data element for the given url and kind. :param str url: URL to assign to the linked data element. :param str kind: ki...
[ "def", "create_linked_data_element", "(", "self", ",", "url", ",", "kind", ",", "id", "=", "None", ",", "# pylint: disable=W0622", "relation", "=", "None", ",", "title", "=", "None", ")", ":", "mp", "=", "self", ".", "__mp_reg", ".", "find_or_create_mapping"...
Returns a new linked data element for the given url and kind. :param str url: URL to assign to the linked data element. :param str kind: kind of the resource that is linked. One of the constantes defined by :class:`everest.constants.RESOURCE_KINDS`. :returns: object implementing :clas...
[ "Returns", "a", "new", "linked", "data", "element", "for", "the", "given", "url", "and", "kind", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L217-L229
41,457
helixyte/everest
everest/representers/mapping.py
Mapping.create_data_element_from_resource
def create_data_element_from_resource(self, resource): """ Returns a new data element for the given resource object. :returns: object implementing :class:`IResourceDataElement`. """ mp = self.__mp_reg.find_or_create_mapping(type(resource)) return mp.data_element_class.cr...
python
def create_data_element_from_resource(self, resource): """ Returns a new data element for the given resource object. :returns: object implementing :class:`IResourceDataElement`. """ mp = self.__mp_reg.find_or_create_mapping(type(resource)) return mp.data_element_class.cr...
[ "def", "create_data_element_from_resource", "(", "self", ",", "resource", ")", ":", "mp", "=", "self", ".", "__mp_reg", ".", "find_or_create_mapping", "(", "type", "(", "resource", ")", ")", "return", "mp", ".", "data_element_class", ".", "create_from_resource", ...
Returns a new data element for the given resource object. :returns: object implementing :class:`IResourceDataElement`.
[ "Returns", "a", "new", "data", "element", "for", "the", "given", "resource", "object", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L231-L238
41,458
helixyte/everest
everest/representers/mapping.py
Mapping.create_linked_data_element_from_resource
def create_linked_data_element_from_resource(self, resource): """ Returns a new linked data element for the given resource object. :returns: object implementing :class:`ILinkedDataElement`. """ mp = self.__mp_reg.find_or_create_mapping(Link) return mp.data_element_class....
python
def create_linked_data_element_from_resource(self, resource): """ Returns a new linked data element for the given resource object. :returns: object implementing :class:`ILinkedDataElement`. """ mp = self.__mp_reg.find_or_create_mapping(Link) return mp.data_element_class....
[ "def", "create_linked_data_element_from_resource", "(", "self", ",", "resource", ")", ":", "mp", "=", "self", ".", "__mp_reg", ".", "find_or_create_mapping", "(", "Link", ")", "return", "mp", ".", "data_element_class", ".", "create_from_resource", "(", "resource", ...
Returns a new linked data element for the given resource object. :returns: object implementing :class:`ILinkedDataElement`.
[ "Returns", "a", "new", "linked", "data", "element", "for", "the", "given", "resource", "object", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L240-L247
41,459
helixyte/everest
everest/representers/mapping.py
Mapping.map_to_resource
def map_to_resource(self, data_element, resource=None): """ Maps the given data element to a new resource or updates the given resource. :raises ValueError: If :param:`data_element` does not provide :class:`everest.representers.interfaces.IDataElement`. """ if ...
python
def map_to_resource(self, data_element, resource=None): """ Maps the given data element to a new resource or updates the given resource. :raises ValueError: If :param:`data_element` does not provide :class:`everest.representers.interfaces.IDataElement`. """ if ...
[ "def", "map_to_resource", "(", "self", ",", "data_element", ",", "resource", "=", "None", ")", ":", "if", "not", "IDataElement", ".", "providedBy", "(", "data_element", ")", ":", "# pylint:disable=E1101", "raise", "ValueError", "(", "'Expected data element, got %s.'...
Maps the given data element to a new resource or updates the given resource. :raises ValueError: If :param:`data_element` does not provide :class:`everest.representers.interfaces.IDataElement`.
[ "Maps", "the", "given", "data", "element", "to", "a", "new", "resource", "or", "updates", "the", "given", "resource", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L249-L272
41,460
helixyte/everest
everest/representers/mapping.py
Mapping.map_to_data_element
def map_to_data_element(self, resource): """ Maps the given resource to a data element tree. """ trv = ResourceTreeTraverser(resource, self.as_pruning()) visitor = DataElementBuilderResourceTreeVisitor(self) trv.run(visitor) return visitor.data_element
python
def map_to_data_element(self, resource): """ Maps the given resource to a data element tree. """ trv = ResourceTreeTraverser(resource, self.as_pruning()) visitor = DataElementBuilderResourceTreeVisitor(self) trv.run(visitor) return visitor.data_element
[ "def", "map_to_data_element", "(", "self", ",", "resource", ")", ":", "trv", "=", "ResourceTreeTraverser", "(", "resource", ",", "self", ".", "as_pruning", "(", ")", ")", "visitor", "=", "DataElementBuilderResourceTreeVisitor", "(", "self", ")", "trv", ".", "r...
Maps the given resource to a data element tree.
[ "Maps", "the", "given", "resource", "to", "a", "data", "element", "tree", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L274-L281
41,461
helixyte/everest
everest/representers/mapping.py
Mapping.push_configuration
def push_configuration(self, configuration): """ Pushes the given configuration object on the stack of configurations managed by this mapping and makes it the active configuration. """ self.__mapped_attr_cache.clear() self.__configurations.append(configuration)
python
def push_configuration(self, configuration): """ Pushes the given configuration object on the stack of configurations managed by this mapping and makes it the active configuration. """ self.__mapped_attr_cache.clear() self.__configurations.append(configuration)
[ "def", "push_configuration", "(", "self", ",", "configuration", ")", ":", "self", ".", "__mapped_attr_cache", ".", "clear", "(", ")", "self", ".", "__configurations", ".", "append", "(", "configuration", ")" ]
Pushes the given configuration object on the stack of configurations managed by this mapping and makes it the active configuration.
[ "Pushes", "the", "given", "configuration", "object", "on", "the", "stack", "of", "configurations", "managed", "by", "this", "mapping", "and", "makes", "it", "the", "active", "configuration", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L291-L297
41,462
helixyte/everest
everest/representers/mapping.py
Mapping.pop_configuration
def pop_configuration(self): """ Pushes the currently active configuration from the stack of configurations managed by this mapping. :raises IndexError: If there is only one configuration in the stack. """ if len(self.__configurations) == 1: raise IndexError(...
python
def pop_configuration(self): """ Pushes the currently active configuration from the stack of configurations managed by this mapping. :raises IndexError: If there is only one configuration in the stack. """ if len(self.__configurations) == 1: raise IndexError(...
[ "def", "pop_configuration", "(", "self", ")", ":", "if", "len", "(", "self", ".", "__configurations", ")", "==", "1", ":", "raise", "IndexError", "(", "'Can not pop the last configuration from the '", "'stack of configurations.'", ")", "self", ".", "__configurations",...
Pushes the currently active configuration from the stack of configurations managed by this mapping. :raises IndexError: If there is only one configuration in the stack.
[ "Pushes", "the", "currently", "active", "configuration", "from", "the", "stack", "of", "configurations", "managed", "by", "this", "mapping", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L299-L310
41,463
helixyte/everest
everest/representers/mapping.py
Mapping.with_updated_configuration
def with_updated_configuration(self, options=None, attribute_options=None): """ Returns a context in which this mapping is updated with the given options and attribute options. """ new_cfg = self.__configurations[-1].copy() if not option...
python
def with_updated_configuration(self, options=None, attribute_options=None): """ Returns a context in which this mapping is updated with the given options and attribute options. """ new_cfg = self.__configurations[-1].copy() if not option...
[ "def", "with_updated_configuration", "(", "self", ",", "options", "=", "None", ",", "attribute_options", "=", "None", ")", ":", "new_cfg", "=", "self", ".", "__configurations", "[", "-", "1", "]", ".", "copy", "(", ")", "if", "not", "options", "is", "Non...
Returns a context in which this mapping is updated with the given options and attribute options.
[ "Returns", "a", "context", "in", "which", "this", "mapping", "is", "updated", "with", "the", "given", "options", "and", "attribute", "options", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L312-L329
41,464
helixyte/everest
everest/representers/mapping.py
Mapping._attribute_iterator
def _attribute_iterator(self, mapped_class, key): """ Returns an iterator over the attributes in this mapping for the given mapped class and attribute key. If this is a pruning mapping, attributes that are ignored because of a custom configuration or because of the default ignor...
python
def _attribute_iterator(self, mapped_class, key): """ Returns an iterator over the attributes in this mapping for the given mapped class and attribute key. If this is a pruning mapping, attributes that are ignored because of a custom configuration or because of the default ignor...
[ "def", "_attribute_iterator", "(", "self", ",", "mapped_class", ",", "key", ")", ":", "for", "attr", "in", "itervalues_", "(", "self", ".", "__get_attribute_map", "(", "mapped_class", ",", "key", ",", "0", ")", ")", ":", "if", "self", ".", "is_pruning", ...
Returns an iterator over the attributes in this mapping for the given mapped class and attribute key. If this is a pruning mapping, attributes that are ignored because of a custom configuration or because of the default ignore rules are skipped.
[ "Returns", "an", "iterator", "over", "the", "attributes", "in", "this", "mapping", "for", "the", "given", "mapped", "class", "and", "attribute", "key", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L343-L359
41,465
helixyte/everest
everest/representers/mapping.py
MappingRegistry.create_mapping
def create_mapping(self, mapped_class, configuration=None): """ Creates a new mapping for the given mapped class and representer configuration. :param configuration: configuration for the new data element class. :type configuration: :class:`RepresenterConfiguration` :ret...
python
def create_mapping(self, mapped_class, configuration=None): """ Creates a new mapping for the given mapped class and representer configuration. :param configuration: configuration for the new data element class. :type configuration: :class:`RepresenterConfiguration` :ret...
[ "def", "create_mapping", "(", "self", ",", "mapped_class", ",", "configuration", "=", "None", ")", ":", "cfg", "=", "self", ".", "__configuration", ".", "copy", "(", ")", "if", "not", "configuration", "is", "None", ":", "cfg", ".", "update", "(", "config...
Creates a new mapping for the given mapped class and representer configuration. :param configuration: configuration for the new data element class. :type configuration: :class:`RepresenterConfiguration` :returns: newly created instance of :class:`Mapping`
[ "Creates", "a", "new", "mapping", "for", "the", "given", "mapped", "class", "and", "representer", "configuration", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L474-L503
41,466
helixyte/everest
everest/representers/mapping.py
MappingRegistry.find_mapping
def find_mapping(self, mapped_class): """ Returns the mapping registered for the given mapped class or any of its base classes. Returns `None` if no mapping can be found. :param mapped_class: mapped type :type mapped_class: type :returns: instance of :class:`Mapping` or ...
python
def find_mapping(self, mapped_class): """ Returns the mapping registered for the given mapped class or any of its base classes. Returns `None` if no mapping can be found. :param mapped_class: mapped type :type mapped_class: type :returns: instance of :class:`Mapping` or ...
[ "def", "find_mapping", "(", "self", ",", "mapped_class", ")", ":", "if", "not", "self", ".", "__is_initialized", ":", "self", ".", "__is_initialized", "=", "True", "self", ".", "_initialize", "(", ")", "mapping", "=", "None", "for", "base_cls", "in", "mapp...
Returns the mapping registered for the given mapped class or any of its base classes. Returns `None` if no mapping can be found. :param mapped_class: mapped type :type mapped_class: type :returns: instance of :class:`Mapping` or `None`
[ "Returns", "the", "mapping", "registered", "for", "the", "given", "mapped", "class", "or", "any", "of", "its", "base", "classes", ".", "Returns", "None", "if", "no", "mapping", "can", "be", "found", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/mapping.py#L514-L534
41,467
corydodt/Codado
codado/py.py
eachMethod
def eachMethod(decorator, methodFilter=lambda fName: True): """ Class decorator that wraps every single method in its own method decorator methodFilter: a function which accepts a function name and should return True if the method is one which we want to decorate, False if we want to leave this met...
python
def eachMethod(decorator, methodFilter=lambda fName: True): """ Class decorator that wraps every single method in its own method decorator methodFilter: a function which accepts a function name and should return True if the method is one which we want to decorate, False if we want to leave this met...
[ "def", "eachMethod", "(", "decorator", ",", "methodFilter", "=", "lambda", "fName", ":", "True", ")", ":", "if", "isinstance", "(", "methodFilter", ",", "basestring", ")", ":", "# Is it a string? If it is, change it into a function that takes a string.", "prefix", "=", ...
Class decorator that wraps every single method in its own method decorator methodFilter: a function which accepts a function name and should return True if the method is one which we want to decorate, False if we want to leave this method alone. methodFilter can also be simply a string prefix. If it i...
[ "Class", "decorator", "that", "wraps", "every", "single", "method", "in", "its", "own", "method", "decorator" ]
487d51ec6132c05aa88e2f128012c95ccbf6928e
https://github.com/corydodt/Codado/blob/487d51ec6132c05aa88e2f128012c95ccbf6928e/codado/py.py#L42-L74
41,468
corydodt/Codado
codado/py.py
_sibpath
def _sibpath(path, sibling): """ Return the path to a sibling of a file in the filesystem. This is useful in conjunction with the special C{__file__} attribute that Python provides for modules, so modules can load associated resource files. (Stolen from twisted.python.util) """ return ...
python
def _sibpath(path, sibling): """ Return the path to a sibling of a file in the filesystem. This is useful in conjunction with the special C{__file__} attribute that Python provides for modules, so modules can load associated resource files. (Stolen from twisted.python.util) """ return ...
[ "def", "_sibpath", "(", "path", ",", "sibling", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "path", ")", ")", ",", "sibling", ")" ]
Return the path to a sibling of a file in the filesystem. This is useful in conjunction with the special C{__file__} attribute that Python provides for modules, so modules can load associated resource files. (Stolen from twisted.python.util)
[ "Return", "the", "path", "to", "a", "sibling", "of", "a", "file", "in", "the", "filesystem", "." ]
487d51ec6132c05aa88e2f128012c95ccbf6928e
https://github.com/corydodt/Codado/blob/487d51ec6132c05aa88e2f128012c95ccbf6928e/codado/py.py#L97-L107
41,469
jealous/cachez
cachez.py
Cache.cache
def cache(cls, func): """ Global cache decorator :param func: the function to be decorated :return: the decorator """ @functools.wraps(func) def func_wrapper(*args, **kwargs): func_key = cls.get_key(func) val_cache = cls.get_cache(func_key) ...
python
def cache(cls, func): """ Global cache decorator :param func: the function to be decorated :return: the decorator """ @functools.wraps(func) def func_wrapper(*args, **kwargs): func_key = cls.get_key(func) val_cache = cls.get_cache(func_key) ...
[ "def", "cache", "(", "cls", ",", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "func_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "func_key", "=", "cls", ".", "get_key", "(", "func", ")", "val_cache", ...
Global cache decorator :param func: the function to be decorated :return: the decorator
[ "Global", "cache", "decorator" ]
4e928b0d796be47073290e631463a63f0d1e66b8
https://github.com/jealous/cachez/blob/4e928b0d796be47073290e631463a63f0d1e66b8/cachez.py#L113-L129
41,470
jealous/cachez
cachez.py
Cache.instance_cache
def instance_cache(cls, func): """ Save the cache to `self` This decorator take it for granted that the decorated function is a method. The first argument of the function is `self`. :param func: function to decorate :return: the decorator """ @functools.wraps(...
python
def instance_cache(cls, func): """ Save the cache to `self` This decorator take it for granted that the decorated function is a method. The first argument of the function is `self`. :param func: function to decorate :return: the decorator """ @functools.wraps(...
[ "def", "instance_cache", "(", "cls", ",", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "func_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "args", ":", "raise", "ValueError", "(", "'`self` i...
Save the cache to `self` This decorator take it for granted that the decorated function is a method. The first argument of the function is `self`. :param func: function to decorate :return: the decorator
[ "Save", "the", "cache", "to", "self" ]
4e928b0d796be47073290e631463a63f0d1e66b8
https://github.com/jealous/cachez/blob/4e928b0d796be47073290e631463a63f0d1e66b8/cachez.py#L163-L186
41,471
jealous/cachez
cachez.py
Cache.clear_instance_cache
def clear_instance_cache(cls, func): """ clear the instance cache Decorate a method of a class, the first parameter is supposed to be `self`. It clear all items cached by the `instance_cache` decorator. :param func: function to decorate """ @functools.wraps(func...
python
def clear_instance_cache(cls, func): """ clear the instance cache Decorate a method of a class, the first parameter is supposed to be `self`. It clear all items cached by the `instance_cache` decorator. :param func: function to decorate """ @functools.wraps(func...
[ "def", "clear_instance_cache", "(", "cls", ",", "func", ")", ":", "@", "functools", ".", "wraps", "(", "func", ")", "def", "func_wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "not", "args", ":", "raise", "ValueError", "(", "'`s...
clear the instance cache Decorate a method of a class, the first parameter is supposed to be `self`. It clear all items cached by the `instance_cache` decorator. :param func: function to decorate
[ "clear", "the", "instance", "cache" ]
4e928b0d796be47073290e631463a63f0d1e66b8
https://github.com/jealous/cachez/blob/4e928b0d796be47073290e631463a63f0d1e66b8/cachez.py#L189-L208
41,472
jealous/cachez
cachez.py
Persisted.persisted
def persisted(cls, seconds=0, minutes=0, hours=0, days=0, weeks=0): """ Cache the return of the function for given time. Default to 1 day. :param weeks: as name :param seconds: as name :param minutes: as name :param hours: as name :param days: as name :re...
python
def persisted(cls, seconds=0, minutes=0, hours=0, days=0, weeks=0): """ Cache the return of the function for given time. Default to 1 day. :param weeks: as name :param seconds: as name :param minutes: as name :param hours: as name :param days: as name :re...
[ "def", "persisted", "(", "cls", ",", "seconds", "=", "0", ",", "minutes", "=", "0", ",", "hours", "=", "0", ",", "days", "=", "0", ",", "weeks", "=", "0", ")", ":", "days", "+=", "weeks", "*", "7", "hours", "+=", "days", "*", "24", "minutes", ...
Cache the return of the function for given time. Default to 1 day. :param weeks: as name :param seconds: as name :param minutes: as name :param hours: as name :param days: as name :return: return of the function decorated
[ "Cache", "the", "return", "of", "the", "function", "for", "given", "time", "." ]
4e928b0d796be47073290e631463a63f0d1e66b8
https://github.com/jealous/cachez/blob/4e928b0d796be47073290e631463a63f0d1e66b8/cachez.py#L234-L297
41,473
tomprince/txgithub
txgithub/api.py
ReposEndpoint.getEvents
def getEvents(self, repo_user, repo_name, until_id=None): """Get all repository events, following paging, until the end or until UNTIL_ID is seen. Returns a Deferred.""" done = False page = 0 events = [] while not done: new_events = yield self.api.makeRequest...
python
def getEvents(self, repo_user, repo_name, until_id=None): """Get all repository events, following paging, until the end or until UNTIL_ID is seen. Returns a Deferred.""" done = False page = 0 events = [] while not done: new_events = yield self.api.makeRequest...
[ "def", "getEvents", "(", "self", ",", "repo_user", ",", "repo_name", ",", "until_id", "=", "None", ")", ":", "done", "=", "False", "page", "=", "0", "events", "=", "[", "]", "while", "not", "done", ":", "new_events", "=", "yield", "self", ".", "api",...
Get all repository events, following paging, until the end or until UNTIL_ID is seen. Returns a Deferred.
[ "Get", "all", "repository", "events", "following", "paging", "until", "the", "end", "or", "until", "UNTIL_ID", "is", "seen", ".", "Returns", "a", "Deferred", "." ]
3bd5eebb25db013e2193e6a102a91049f356710d
https://github.com/tomprince/txgithub/blob/3bd5eebb25db013e2193e6a102a91049f356710d/txgithub/api.py#L157-L179
41,474
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.from_project_path
def from_project_path(cls, path): """Utility for finding a virtualenv location based on a project path""" path = vistir.compat.Path(path) if path.name == 'Pipfile': pipfile_path = path path = path.parent else: pipfile_path = path / 'Pipfile' pi...
python
def from_project_path(cls, path): """Utility for finding a virtualenv location based on a project path""" path = vistir.compat.Path(path) if path.name == 'Pipfile': pipfile_path = path path = path.parent else: pipfile_path = path / 'Pipfile' pi...
[ "def", "from_project_path", "(", "cls", ",", "path", ")", ":", "path", "=", "vistir", ".", "compat", ".", "Path", "(", "path", ")", "if", "path", ".", "name", "==", "'Pipfile'", ":", "pipfile_path", "=", "path", "path", "=", "path", ".", "parent", "e...
Utility for finding a virtualenv location based on a project path
[ "Utility", "for", "finding", "a", "virtualenv", "location", "based", "on", "a", "project", "path" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L46-L69
41,475
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.get_setup_install_args
def get_setup_install_args(self, pkgname, setup_py, develop=False): """Get setup.py install args for installing the supplied package in the virtualenv :param str pkgname: The name of the package to install :param str setup_py: The path to the setup file of the package :param bool develo...
python
def get_setup_install_args(self, pkgname, setup_py, develop=False): """Get setup.py install args for installing the supplied package in the virtualenv :param str pkgname: The name of the package to install :param str setup_py: The path to the setup file of the package :param bool develo...
[ "def", "get_setup_install_args", "(", "self", ",", "pkgname", ",", "setup_py", ",", "develop", "=", "False", ")", ":", "headers", "=", "self", ".", "base_paths", "[", "\"headers\"", "]", "headers", "=", "headers", "/", "\"python{0}\"", ".", "format", "(", ...
Get setup.py install args for installing the supplied package in the virtualenv :param str pkgname: The name of the package to install :param str setup_py: The path to the setup file of the package :param bool develop: Whether the package is in development mode :return: The installation...
[ "Get", "setup", ".", "py", "install", "args", "for", "installing", "the", "supplied", "package", "in", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L453-L474
41,476
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.setuptools_install
def setuptools_install(self, chdir_to, pkg_name, setup_py_path=None, editable=False): """Install an sdist or an editable package into the virtualenv :param str chdir_to: The location to change to :param str setup_py_path: The path to the setup.py, if applicable defaults to None :param ...
python
def setuptools_install(self, chdir_to, pkg_name, setup_py_path=None, editable=False): """Install an sdist or an editable package into the virtualenv :param str chdir_to: The location to change to :param str setup_py_path: The path to the setup.py, if applicable defaults to None :param ...
[ "def", "setuptools_install", "(", "self", ",", "chdir_to", ",", "pkg_name", ",", "setup_py_path", "=", "None", ",", "editable", "=", "False", ")", ":", "install_options", "=", "[", "\"--prefix={0}\"", ".", "format", "(", "self", ".", "prefix", ".", "as_posix...
Install an sdist or an editable package into the virtualenv :param str chdir_to: The location to change to :param str setup_py_path: The path to the setup.py, if applicable defaults to None :param bool editable: Whether the package is editable, defaults to False
[ "Install", "an", "sdist", "or", "an", "editable", "package", "into", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L476-L490
41,477
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.install
def install(self, req, editable=False, sources=[]): """Install a package into the virtualenv :param req: A requirement to install :type req: :class:`requirementslib.models.requirement.Requirement` :param bool editable: Whether the requirement is editable, defaults to False :para...
python
def install(self, req, editable=False, sources=[]): """Install a package into the virtualenv :param req: A requirement to install :type req: :class:`requirementslib.models.requirement.Requirement` :param bool editable: Whether the requirement is editable, defaults to False :para...
[ "def", "install", "(", "self", ",", "req", ",", "editable", "=", "False", ",", "sources", "=", "[", "]", ")", ":", "try", ":", "packagebuilder", "=", "self", ".", "safe_import", "(", "\"packagebuilder\"", ")", "except", "ImportError", ":", "packagebuilder"...
Install a package into the virtualenv :param req: A requirement to install :type req: :class:`requirementslib.models.requirement.Requirement` :param bool editable: Whether the requirement is editable, defaults to False :param list sources: A list of pip sources to consult, defaults to [...
[ "Install", "a", "package", "into", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L492-L530
41,478
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.activated
def activated(self, include_extras=True, extra_dists=[]): """A context manager which activates the virtualenv. :param list extra_dists: Paths added to the context after the virtualenv is activated. This context manager sets the following environment variables: * `PYTHONUSERBASE` ...
python
def activated(self, include_extras=True, extra_dists=[]): """A context manager which activates the virtualenv. :param list extra_dists: Paths added to the context after the virtualenv is activated. This context manager sets the following environment variables: * `PYTHONUSERBASE` ...
[ "def", "activated", "(", "self", ",", "include_extras", "=", "True", ",", "extra_dists", "=", "[", "]", ")", ":", "original_path", "=", "sys", ".", "path", "original_prefix", "=", "sys", ".", "prefix", "original_user_base", "=", "os", ".", "environ", ".", ...
A context manager which activates the virtualenv. :param list extra_dists: Paths added to the context after the virtualenv is activated. This context manager sets the following environment variables: * `PYTHONUSERBASE` * `VIRTUAL_ENV` * `PYTHONIOENCODING` ...
[ "A", "context", "manager", "which", "activates", "the", "virtualenv", "." ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L533-L585
41,479
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.get_monkeypatched_pathset
def get_monkeypatched_pathset(self): """Returns a monkeypatched `UninstallPathset` for using to uninstall packages from the virtualenv :return: A patched `UninstallPathset` which enables uninstallation of venv packages :rtype: :class:`pip._internal.req.req_uninstall.UninstallPathset` ""...
python
def get_monkeypatched_pathset(self): """Returns a monkeypatched `UninstallPathset` for using to uninstall packages from the virtualenv :return: A patched `UninstallPathset` which enables uninstallation of venv packages :rtype: :class:`pip._internal.req.req_uninstall.UninstallPathset` ""...
[ "def", "get_monkeypatched_pathset", "(", "self", ")", ":", "from", "pip_shims", ".", "shims", "import", "InstallRequirement", "# Determine the path to the uninstall module name based on the install module name", "uninstall_path", "=", "InstallRequirement", ".", "__module__", ".",...
Returns a monkeypatched `UninstallPathset` for using to uninstall packages from the virtualenv :return: A patched `UninstallPathset` which enables uninstallation of venv packages :rtype: :class:`pip._internal.req.req_uninstall.UninstallPathset`
[ "Returns", "a", "monkeypatched", "UninstallPathset", "for", "using", "to", "uninstall", "packages", "from", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L632-L648
41,480
sarugaku/mork
src/mork/virtualenv.py
VirtualEnv.uninstall
def uninstall(self, pkgname, *args, **kwargs): """A context manager which allows uninstallation of packages from the virtualenv :param str pkgname: The name of a package to uninstall >>> venv = VirtualEnv("/path/to/venv/root") >>> with venv.uninstall("pytz", auto_confirm=True, verbose=...
python
def uninstall(self, pkgname, *args, **kwargs): """A context manager which allows uninstallation of packages from the virtualenv :param str pkgname: The name of a package to uninstall >>> venv = VirtualEnv("/path/to/venv/root") >>> with venv.uninstall("pytz", auto_confirm=True, verbose=...
[ "def", "uninstall", "(", "self", ",", "pkgname", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "auto_confirm", "=", "kwargs", ".", "pop", "(", "\"auto_confirm\"", ",", "True", ")", "verbose", "=", "kwargs", ".", "pop", "(", "\"verbose\"", ",", ...
A context manager which allows uninstallation of packages from the virtualenv :param str pkgname: The name of a package to uninstall >>> venv = VirtualEnv("/path/to/venv/root") >>> with venv.uninstall("pytz", auto_confirm=True, verbose=False) as uninstaller: cleaned = uninstall...
[ "A", "context", "manager", "which", "allows", "uninstallation", "of", "packages", "from", "the", "virtualenv" ]
c1a7cd63c490ed7fbecb7714fd5590d2609366de
https://github.com/sarugaku/mork/blob/c1a7cd63c490ed7fbecb7714fd5590d2609366de/src/mork/virtualenv.py#L651-L683
41,481
brmscheiner/ideogram
ideogram/polarfract/polarfract.py
getRootNode
def getRootNode(nodes): '''Return the node with the most children''' max = 0 root = None for i in nodes: if len(i.children) > max: max = len(i.children) root = i return root
python
def getRootNode(nodes): '''Return the node with the most children''' max = 0 root = None for i in nodes: if len(i.children) > max: max = len(i.children) root = i return root
[ "def", "getRootNode", "(", "nodes", ")", ":", "max", "=", "0", "root", "=", "None", "for", "i", "in", "nodes", ":", "if", "len", "(", "i", ".", "children", ")", ">", "max", ":", "max", "=", "len", "(", "i", ".", "children", ")", "root", "=", ...
Return the node with the most children
[ "Return", "the", "node", "with", "the", "most", "children" ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/polarfract/polarfract.py#L34-L42
41,482
brmscheiner/ideogram
ideogram/polarfract/polarfract.py
getNextNode
def getNextNode(nodes,usednodes,parent): '''Get next node in a breadth-first traversal of nodes that have not been used yet''' for e in edges: if e.source==parent: if e.target in usednodes: x = e.target break elif e.target==parent: if e.sou...
python
def getNextNode(nodes,usednodes,parent): '''Get next node in a breadth-first traversal of nodes that have not been used yet''' for e in edges: if e.source==parent: if e.target in usednodes: x = e.target break elif e.target==parent: if e.sou...
[ "def", "getNextNode", "(", "nodes", ",", "usednodes", ",", "parent", ")", ":", "for", "e", "in", "edges", ":", "if", "e", ".", "source", "==", "parent", ":", "if", "e", ".", "target", "in", "usednodes", ":", "x", "=", "e", ".", "target", "break", ...
Get next node in a breadth-first traversal of nodes that have not been used yet
[ "Get", "next", "node", "in", "a", "breadth", "-", "first", "traversal", "of", "nodes", "that", "have", "not", "been", "used", "yet" ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/polarfract/polarfract.py#L44-L55
41,483
brmscheiner/ideogram
ideogram/polarfract/polarfract.py
Circle.calcPosition
def calcPosition(self,parent_circle): ''' Position the circle tangent to the parent circle with the line connecting the centers of the two circles meeting the x axis at angle theta. ''' if r not in self: raise AttributeError("radius must be calculated before position.") if theta not ...
python
def calcPosition(self,parent_circle): ''' Position the circle tangent to the parent circle with the line connecting the centers of the two circles meeting the x axis at angle theta. ''' if r not in self: raise AttributeError("radius must be calculated before position.") if theta not ...
[ "def", "calcPosition", "(", "self", ",", "parent_circle", ")", ":", "if", "r", "not", "in", "self", ":", "raise", "AttributeError", "(", "\"radius must be calculated before position.\"", ")", "if", "theta", "not", "in", "self", ":", "raise", "AttributeError", "(...
Position the circle tangent to the parent circle with the line connecting the centers of the two circles meeting the x axis at angle theta.
[ "Position", "the", "circle", "tangent", "to", "the", "parent", "circle", "with", "the", "line", "connecting", "the", "centers", "of", "the", "two", "circles", "meeting", "the", "x", "axis", "at", "angle", "theta", "." ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/polarfract/polarfract.py#L23-L32
41,484
foobarbecue/afterflight
afterflight/progressbarupload/views.py
upload_progress
def upload_progress(request): """ Used by Ajax calls Return the upload progress and total length values """ if 'X-Progress-ID' in request.GET: progress_id = request.GET['X-Progress-ID'] elif 'X-Progress-ID' in request.META: progress_id = request.META['X-Progress-ID'] if prog...
python
def upload_progress(request): """ Used by Ajax calls Return the upload progress and total length values """ if 'X-Progress-ID' in request.GET: progress_id = request.GET['X-Progress-ID'] elif 'X-Progress-ID' in request.META: progress_id = request.META['X-Progress-ID'] if prog...
[ "def", "upload_progress", "(", "request", ")", ":", "if", "'X-Progress-ID'", "in", "request", ".", "GET", ":", "progress_id", "=", "request", ".", "GET", "[", "'X-Progress-ID'", "]", "elif", "'X-Progress-ID'", "in", "request", ".", "META", ":", "progress_id", ...
Used by Ajax calls Return the upload progress and total length values
[ "Used", "by", "Ajax", "calls" ]
7085f719593f88999dce93f35caec5f15d2991b6
https://github.com/foobarbecue/afterflight/blob/7085f719593f88999dce93f35caec5f15d2991b6/afterflight/progressbarupload/views.py#L8-L21
41,485
clinicedc/edc-model-fields
edc_model_fields/fields/userfield.py
UserField.pre_save
def pre_save(self, model_instance, add): """Updates username created on ADD only.""" value = super(UserField, self).pre_save(model_instance, add) if not value and not add: # fall back to OS user if not accessing through browser # better than nothing ... value ...
python
def pre_save(self, model_instance, add): """Updates username created on ADD only.""" value = super(UserField, self).pre_save(model_instance, add) if not value and not add: # fall back to OS user if not accessing through browser # better than nothing ... value ...
[ "def", "pre_save", "(", "self", ",", "model_instance", ",", "add", ")", ":", "value", "=", "super", "(", "UserField", ",", "self", ")", ".", "pre_save", "(", "model_instance", ",", "add", ")", "if", "not", "value", "and", "not", "add", ":", "# fall bac...
Updates username created on ADD only.
[ "Updates", "username", "created", "on", "ADD", "only", "." ]
fac30a71163760edd57329f26b48095eb0a0dd5b
https://github.com/clinicedc/edc-model-fields/blob/fac30a71163760edd57329f26b48095eb0a0dd5b/edc_model_fields/fields/userfield.py#L19-L28
41,486
envi-idl/envipyarclib
envipyarclib/system.py
sys_toolbox_dir
def sys_toolbox_dir(): """ Returns this site-package esri toolbox directory. """ return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'esri', 'toolboxes')
python
def sys_toolbox_dir(): """ Returns this site-package esri toolbox directory. """ return os.path.join(os.path.dirname(os.path.abspath(__file__)), 'esri', 'toolboxes')
[ "def", "sys_toolbox_dir", "(", ")", ":", "return", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "'esri'", ",", "'toolboxes'", ")" ]
Returns this site-package esri toolbox directory.
[ "Returns", "this", "site", "-", "package", "esri", "toolbox", "directory", "." ]
90135652510c3d53c5f51177252c1fea2639bf22
https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/system.py#L10-L14
41,487
envi-idl/envipyarclib
envipyarclib/system.py
appdata_roaming_dir
def appdata_roaming_dir(): """Returns the roaming AppData directory for the installed ArcGIS Desktop.""" install = arcpy.GetInstallInfo('desktop') app_data = arcpy.GetSystemEnvironment("APPDATA") product_dir = ''.join((install['ProductName'], major_version())) return os.path.join(app_data, 'ESRI', p...
python
def appdata_roaming_dir(): """Returns the roaming AppData directory for the installed ArcGIS Desktop.""" install = arcpy.GetInstallInfo('desktop') app_data = arcpy.GetSystemEnvironment("APPDATA") product_dir = ''.join((install['ProductName'], major_version())) return os.path.join(app_data, 'ESRI', p...
[ "def", "appdata_roaming_dir", "(", ")", ":", "install", "=", "arcpy", ".", "GetInstallInfo", "(", "'desktop'", ")", "app_data", "=", "arcpy", ".", "GetSystemEnvironment", "(", "\"APPDATA\"", ")", "product_dir", "=", "''", ".", "join", "(", "(", "install", "[...
Returns the roaming AppData directory for the installed ArcGIS Desktop.
[ "Returns", "the", "roaming", "AppData", "directory", "for", "the", "installed", "ArcGIS", "Desktop", "." ]
90135652510c3d53c5f51177252c1fea2639bf22
https://github.com/envi-idl/envipyarclib/blob/90135652510c3d53c5f51177252c1fea2639bf22/envipyarclib/system.py#L20-L25
41,488
silver-castle/mach9
mach9/app.py
Mach9.add_route
def add_route(self, handler, uri, methods=frozenset({'GET'}), host=None, strict_slashes=False): '''A helper method to register class instance or functions as a handler to the application url routes. :param handler: function or class instance :param uri: path of...
python
def add_route(self, handler, uri, methods=frozenset({'GET'}), host=None, strict_slashes=False): '''A helper method to register class instance or functions as a handler to the application url routes. :param handler: function or class instance :param uri: path of...
[ "def", "add_route", "(", "self", ",", "handler", ",", "uri", ",", "methods", "=", "frozenset", "(", "{", "'GET'", "}", ")", ",", "host", "=", "None", ",", "strict_slashes", "=", "False", ")", ":", "stream", "=", "False", "# Handle HTTPMethodView differentl...
A helper method to register class instance or functions as a handler to the application url routes. :param handler: function or class instance :param uri: path of the URL :param methods: list or tuple of methods allowed, these are overridden if using a HT...
[ "A", "helper", "method", "to", "register", "class", "instance", "or", "functions", "as", "a", "handler", "to", "the", "application", "url", "routes", "." ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L159-L195
41,489
silver-castle/mach9
mach9/app.py
Mach9.middleware
def middleware(self, middleware_or_request): '''Decorate and register middleware to be called before a request. Can either be called as @app.middleware or @app.middleware('request') ''' def register_middleware(middleware, attach_to='request'): if attach_to == 'request': ...
python
def middleware(self, middleware_or_request): '''Decorate and register middleware to be called before a request. Can either be called as @app.middleware or @app.middleware('request') ''' def register_middleware(middleware, attach_to='request'): if attach_to == 'request': ...
[ "def", "middleware", "(", "self", ",", "middleware_or_request", ")", ":", "def", "register_middleware", "(", "middleware", ",", "attach_to", "=", "'request'", ")", ":", "if", "attach_to", "==", "'request'", ":", "self", ".", "request_middleware", ".", "append", ...
Decorate and register middleware to be called before a request. Can either be called as @app.middleware or @app.middleware('request')
[ "Decorate", "and", "register", "middleware", "to", "be", "called", "before", "a", "request", ".", "Can", "either", "be", "called", "as" ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L220-L237
41,490
silver-castle/mach9
mach9/app.py
Mach9.static
def static(self, uri, file_or_directory, pattern=r'/?.+', use_modified_since=True, use_content_range=False): '''Register a root to serve files from. The input can either be a file or a directory. See ''' static_register(self, uri, file_or_directory, pattern, ...
python
def static(self, uri, file_or_directory, pattern=r'/?.+', use_modified_since=True, use_content_range=False): '''Register a root to serve files from. The input can either be a file or a directory. See ''' static_register(self, uri, file_or_directory, pattern, ...
[ "def", "static", "(", "self", ",", "uri", ",", "file_or_directory", ",", "pattern", "=", "r'/?.+'", ",", "use_modified_since", "=", "True", ",", "use_content_range", "=", "False", ")", ":", "static_register", "(", "self", ",", "uri", ",", "file_or_directory", ...
Register a root to serve files from. The input can either be a file or a directory. See
[ "Register", "a", "root", "to", "serve", "files", "from", ".", "The", "input", "can", "either", "be", "a", "file", "or", "a", "directory", ".", "See" ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L240-L246
41,491
silver-castle/mach9
mach9/app.py
Mach9.url_for
def url_for(self, view_name: str, **kwargs): '''Build a URL based on a view name and the values provided. In order to build a URL, all request parameters must be supplied as keyword arguments, and each parameter must pass the test for the specified parameter type. If these conditions ar...
python
def url_for(self, view_name: str, **kwargs): '''Build a URL based on a view name and the values provided. In order to build a URL, all request parameters must be supplied as keyword arguments, and each parameter must pass the test for the specified parameter type. If these conditions ar...
[ "def", "url_for", "(", "self", ",", "view_name", ":", "str", ",", "*", "*", "kwargs", ")", ":", "# find the route by the supplied view name", "uri", ",", "route", "=", "self", ".", "router", ".", "find_route_by_view_name", "(", "view_name", ")", "if", "not", ...
Build a URL based on a view name and the values provided. In order to build a URL, all request parameters must be supplied as keyword arguments, and each parameter must pass the test for the specified parameter type. If these conditions are not met, a `URLBuildError` will be thrown. ...
[ "Build", "a", "URL", "based", "on", "a", "view", "name", "and", "the", "values", "provided", "." ]
7a623aab3c70d89d36ade6901b6307e115400c5e
https://github.com/silver-castle/mach9/blob/7a623aab3c70d89d36ade6901b6307e115400c5e/mach9/app.py#L265-L359
41,492
rajeevs1992/pyhealthvault
src/healthvaultlib/hvcrypto.py
HVCrypto.i2osp
def i2osp(self, long_integer, block_size): 'Convert a long integer into an octet string.' hex_string = '%X' % long_integer if len(hex_string) > 2 * block_size: raise ValueError('integer %i too large to encode in %i octets' % (long_integer, block_size)) return a2b_hex(hex_stri...
python
def i2osp(self, long_integer, block_size): 'Convert a long integer into an octet string.' hex_string = '%X' % long_integer if len(hex_string) > 2 * block_size: raise ValueError('integer %i too large to encode in %i octets' % (long_integer, block_size)) return a2b_hex(hex_stri...
[ "def", "i2osp", "(", "self", ",", "long_integer", ",", "block_size", ")", ":", "hex_string", "=", "'%X'", "%", "long_integer", "if", "len", "(", "hex_string", ")", ">", "2", "*", "block_size", ":", "raise", "ValueError", "(", "'integer %i too large to encode i...
Convert a long integer into an octet string.
[ "Convert", "a", "long", "integer", "into", "an", "octet", "string", "." ]
2b6fa7c1687300bcc2e501368883fbb13dc80495
https://github.com/rajeevs1992/pyhealthvault/blob/2b6fa7c1687300bcc2e501368883fbb13dc80495/src/healthvaultlib/hvcrypto.py#L44-L49
41,493
callowayproject/Calloway
calloway/apps/django_ext/markov.py
MarkovChain.random_output
def random_output(self, max=100): """ Generate a list of elements from the markov chain. The `max` value is in place in order to prevent excessive iteration. """ output = [] item1 = item2 = MarkovChain.START for i in range(max-3): item3 = self[(item1, item...
python
def random_output(self, max=100): """ Generate a list of elements from the markov chain. The `max` value is in place in order to prevent excessive iteration. """ output = [] item1 = item2 = MarkovChain.START for i in range(max-3): item3 = self[(item1, item...
[ "def", "random_output", "(", "self", ",", "max", "=", "100", ")", ":", "output", "=", "[", "]", "item1", "=", "item2", "=", "MarkovChain", ".", "START", "for", "i", "in", "range", "(", "max", "-", "3", ")", ":", "item3", "=", "self", "[", "(", ...
Generate a list of elements from the markov chain. The `max` value is in place in order to prevent excessive iteration.
[ "Generate", "a", "list", "of", "elements", "from", "the", "markov", "chain", ".", "The", "max", "value", "is", "in", "place", "in", "order", "to", "prevent", "excessive", "iteration", "." ]
d22e98d41fbd298ab6393ba7bd84a75528be9f81
https://github.com/callowayproject/Calloway/blob/d22e98d41fbd298ab6393ba7bd84a75528be9f81/calloway/apps/django_ext/markov.py#L51-L64
41,494
fredericklussier/TinyPeriodicTask
tinyPeriodicTask/TinyPeriodicTask.py
TinyPeriodicTask.start
def start(self): """ Start the periodic runner """ if self._isRunning: return if self._cease.is_set(): self._cease.clear() # restart class Runner(threading.Thread): @classmethod def run(cls): nextRunAt = c...
python
def start(self): """ Start the periodic runner """ if self._isRunning: return if self._cease.is_set(): self._cease.clear() # restart class Runner(threading.Thread): @classmethod def run(cls): nextRunAt = c...
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "_isRunning", ":", "return", "if", "self", ".", "_cease", ".", "is_set", "(", ")", ":", "self", ".", "_cease", ".", "clear", "(", ")", "# restart", "class", "Runner", "(", "threading", ".", ...
Start the periodic runner
[ "Start", "the", "periodic", "runner" ]
be79e349bf6f73c1ba7576eb5acc6e812ffcfe36
https://github.com/fredericklussier/TinyPeriodicTask/blob/be79e349bf6f73c1ba7576eb5acc6e812ffcfe36/tinyPeriodicTask/TinyPeriodicTask.py#L139-L167
41,495
fredericklussier/TinyPeriodicTask
tinyPeriodicTask/TinyPeriodicTask.py
TinyPeriodicTask.useThis
def useThis(self, *args, **kwargs): """ Change parameter of the callback function. :param *args, **kwargs: parameter(s) to use when executing the callback function. """ self._callback = functools.partial(self._callback, *args, **kwargs)
python
def useThis(self, *args, **kwargs): """ Change parameter of the callback function. :param *args, **kwargs: parameter(s) to use when executing the callback function. """ self._callback = functools.partial(self._callback, *args, **kwargs)
[ "def", "useThis", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "_callback", "=", "functools", ".", "partial", "(", "self", ".", "_callback", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Change parameter of the callback function. :param *args, **kwargs: parameter(s) to use when executing the callback function.
[ "Change", "parameter", "of", "the", "callback", "function", "." ]
be79e349bf6f73c1ba7576eb5acc6e812ffcfe36
https://github.com/fredericklussier/TinyPeriodicTask/blob/be79e349bf6f73c1ba7576eb5acc6e812ffcfe36/tinyPeriodicTask/TinyPeriodicTask.py#L172-L179
41,496
fredericklussier/TinyPeriodicTask
tinyPeriodicTask/TinyPeriodicTask.py
TinyPeriodicTask.stop
def stop(self): """ Stop the periodic runner """ self._cease.set() time.sleep(0.1) # let the thread closing correctly. self._isRunning = False
python
def stop(self): """ Stop the periodic runner """ self._cease.set() time.sleep(0.1) # let the thread closing correctly. self._isRunning = False
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_cease", ".", "set", "(", ")", "time", ".", "sleep", "(", "0.1", ")", "# let the thread closing correctly.", "self", ".", "_isRunning", "=", "False" ]
Stop the periodic runner
[ "Stop", "the", "periodic", "runner" ]
be79e349bf6f73c1ba7576eb5acc6e812ffcfe36
https://github.com/fredericklussier/TinyPeriodicTask/blob/be79e349bf6f73c1ba7576eb5acc6e812ffcfe36/tinyPeriodicTask/TinyPeriodicTask.py#L181-L187
41,497
AtomHash/evernode
evernode/middleware/session_middleware.py
SessionMiddleware.condition
def condition(self) -> bool: """ check JWT, then check session for validity """ jwt = JWT() if jwt.verify_http_auth_token(): if not current_app.config['AUTH']['FAST_SESSIONS']: session = SessionModel.where_session_id( jwt.data['session_id']) ...
python
def condition(self) -> bool: """ check JWT, then check session for validity """ jwt = JWT() if jwt.verify_http_auth_token(): if not current_app.config['AUTH']['FAST_SESSIONS']: session = SessionModel.where_session_id( jwt.data['session_id']) ...
[ "def", "condition", "(", "self", ")", "->", "bool", ":", "jwt", "=", "JWT", "(", ")", "if", "jwt", ".", "verify_http_auth_token", "(", ")", ":", "if", "not", "current_app", ".", "config", "[", "'AUTH'", "]", "[", "'FAST_SESSIONS'", "]", ":", "session",...
check JWT, then check session for validity
[ "check", "JWT", "then", "check", "session", "for", "validity" ]
b2fb91555fb937a3f3eba41db56dee26f9b034be
https://github.com/AtomHash/evernode/blob/b2fb91555fb937a3f3eba41db56dee26f9b034be/evernode/middleware/session_middleware.py#L13-L24
41,498
vicalloy/lbutils
lbutils/widgets.py
render_hidden
def render_hidden(name, value): """ render as hidden widget """ if isinstance(value, list): return MultipleHiddenInput().render(name, value) return HiddenInput().render(name, value)
python
def render_hidden(name, value): """ render as hidden widget """ if isinstance(value, list): return MultipleHiddenInput().render(name, value) return HiddenInput().render(name, value)
[ "def", "render_hidden", "(", "name", ",", "value", ")", ":", "if", "isinstance", "(", "value", ",", "list", ")", ":", "return", "MultipleHiddenInput", "(", ")", ".", "render", "(", "name", ",", "value", ")", "return", "HiddenInput", "(", ")", ".", "ren...
render as hidden widget
[ "render", "as", "hidden", "widget" ]
66ae7e73bc939f073cdc1b91602a95e67caf4ba6
https://github.com/vicalloy/lbutils/blob/66ae7e73bc939f073cdc1b91602a95e67caf4ba6/lbutils/widgets.py#L71-L75
41,499
erikvw/django-collect-offline-files
django_collect_offline_files/file_queues/deserialize_transactions_file_queue.py
DeserializeTransactionsFileQueue.next_task
def next_task(self, item, raise_exceptions=None, **kwargs): """Deserializes all transactions for this batch and archives the file. """ filename = os.path.basename(item) batch = self.get_batch(filename) tx_deserializer = self.tx_deserializer_cls( allow_self=sel...
python
def next_task(self, item, raise_exceptions=None, **kwargs): """Deserializes all transactions for this batch and archives the file. """ filename = os.path.basename(item) batch = self.get_batch(filename) tx_deserializer = self.tx_deserializer_cls( allow_self=sel...
[ "def", "next_task", "(", "self", ",", "item", ",", "raise_exceptions", "=", "None", ",", "*", "*", "kwargs", ")", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "item", ")", "batch", "=", "self", ".", "get_batch", "(", "filename", ")"...
Deserializes all transactions for this batch and archives the file.
[ "Deserializes", "all", "transactions", "for", "this", "batch", "and", "archives", "the", "file", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/file_queues/deserialize_transactions_file_queue.py#L25-L42