repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
helixyte/everest
everest/representers/base.py
MappingResourceRepresenter.with_updated_configuration
def with_updated_configuration(self, options=None, attribute_options=None): """ Returns a context in which this representer is updated with the given options and attribute options. """ return self._mapping.with_updated_configuration(options=opti...
python
def with_updated_configuration(self, options=None, attribute_options=None): """ Returns a context in which this representer is updated with the given options and attribute options. """ return self._mapping.with_updated_configuration(options=opti...
[ "def", "with_updated_configuration", "(", "self", ",", "options", "=", "None", ",", "attribute_options", "=", "None", ")", ":", "return", "self", ".", "_mapping", ".", "with_updated_configuration", "(", "options", "=", "options", ",", "attribute_options", "=", "...
Returns a context in which this representer is updated with the given options and attribute options.
[ "Returns", "a", "context", "in", "which", "this", "representer", "is", "updated", "with", "the", "given", "options", "and", "attribute", "options", "." ]
70c9b93c3061db5cb62428349d18b8fb8566411b
https://github.com/helixyte/everest/blob/70c9b93c3061db5cb62428349d18b8fb8566411b/everest/representers/base.py#L294-L302
train
58,300
brmscheiner/ideogram
ideogram/writer.py
jsPath
def jsPath(path): '''Returns a relative path without \, -, and . so that the string will play nicely with javascript.''' shortPath=path.replace( "C:\\Users\\scheinerbock\\Desktop\\"+ "ideogram\\scrapeSource\\test\\","") noDash = shortPath.replace("-","_dash_") jsPath=noDash....
python
def jsPath(path): '''Returns a relative path without \, -, and . so that the string will play nicely with javascript.''' shortPath=path.replace( "C:\\Users\\scheinerbock\\Desktop\\"+ "ideogram\\scrapeSource\\test\\","") noDash = shortPath.replace("-","_dash_") jsPath=noDash....
[ "def", "jsPath", "(", "path", ")", ":", "shortPath", "=", "path", ".", "replace", "(", "\"C:\\\\Users\\\\scheinerbock\\\\Desktop\\\\\"", "+", "\"ideogram\\\\scrapeSource\\\\test\\\\\"", ",", "\"\"", ")", "noDash", "=", "shortPath", ".", "replace", "(", "\"-\"", ",",...
Returns a relative path without \, -, and . so that the string will play nicely with javascript.
[ "Returns", "a", "relative", "path", "without", "\\", "-", "and", ".", "so", "that", "the", "string", "will", "play", "nicely", "with", "javascript", "." ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L3-L11
train
58,301
brmscheiner/ideogram
ideogram/writer.py
jsName
def jsName(path,name): '''Returns a name string without \, -, and . so that the string will play nicely with javascript.''' shortPath=path.replace( "C:\\Users\\scheinerbock\\Desktop\\"+ "ideogram\\scrapeSource\\test\\","") noDash = shortPath.replace("-","_dash_") jsPath=noDa...
python
def jsName(path,name): '''Returns a name string without \, -, and . so that the string will play nicely with javascript.''' shortPath=path.replace( "C:\\Users\\scheinerbock\\Desktop\\"+ "ideogram\\scrapeSource\\test\\","") noDash = shortPath.replace("-","_dash_") jsPath=noDa...
[ "def", "jsName", "(", "path", ",", "name", ")", ":", "shortPath", "=", "path", ".", "replace", "(", "\"C:\\\\Users\\\\scheinerbock\\\\Desktop\\\\\"", "+", "\"ideogram\\\\scrapeSource\\\\test\\\\\"", ",", "\"\"", ")", "noDash", "=", "shortPath", ".", "replace", "(", ...
Returns a name string without \, -, and . so that the string will play nicely with javascript.
[ "Returns", "a", "name", "string", "without", "\\", "-", "and", ".", "so", "that", "the", "string", "will", "play", "nicely", "with", "javascript", "." ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L13-L22
train
58,302
brmscheiner/ideogram
ideogram/writer.py
getStartNodes
def getStartNodes(fdefs,calls): '''Return a list of nodes in fdefs that have no inbound edges''' s=[] for source in fdefs: for fn in fdefs[source]: inboundEdges=False for call in calls: if call.target==fn: inboundEdges=True if n...
python
def getStartNodes(fdefs,calls): '''Return a list of nodes in fdefs that have no inbound edges''' s=[] for source in fdefs: for fn in fdefs[source]: inboundEdges=False for call in calls: if call.target==fn: inboundEdges=True if n...
[ "def", "getStartNodes", "(", "fdefs", ",", "calls", ")", ":", "s", "=", "[", "]", "for", "source", "in", "fdefs", ":", "for", "fn", "in", "fdefs", "[", "source", "]", ":", "inboundEdges", "=", "False", "for", "call", "in", "calls", ":", "if", "call...
Return a list of nodes in fdefs that have no inbound edges
[ "Return", "a", "list", "of", "nodes", "in", "fdefs", "that", "have", "no", "inbound", "edges" ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L55-L66
train
58,303
brmscheiner/ideogram
ideogram/writer.py
getChildren
def getChildren(current,calls,blacklist=[]): ''' Return a list of the children of current that are not in used. ''' return [c.target for c in calls if c.source==current and c.target not in blacklist]
python
def getChildren(current,calls,blacklist=[]): ''' Return a list of the children of current that are not in used. ''' return [c.target for c in calls if c.source==current and c.target not in blacklist]
[ "def", "getChildren", "(", "current", ",", "calls", ",", "blacklist", "=", "[", "]", ")", ":", "return", "[", "c", ".", "target", "for", "c", "in", "calls", "if", "c", ".", "source", "==", "current", "and", "c", ".", "target", "not", "in", "blackli...
Return a list of the children of current that are not in used.
[ "Return", "a", "list", "of", "the", "children", "of", "current", "that", "are", "not", "in", "used", "." ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L140-L142
train
58,304
brmscheiner/ideogram
ideogram/writer.py
tagAttributes
def tagAttributes(fdef_master_list,node,depth=0): '''recursively tag objects with sizes, depths and path names ''' if type(node)==list: for i in node: depth+=1 tagAttributes(fdef_master_list,i,depth) if type(node)==dict: for x in fdef_master_list: if jsNam...
python
def tagAttributes(fdef_master_list,node,depth=0): '''recursively tag objects with sizes, depths and path names ''' if type(node)==list: for i in node: depth+=1 tagAttributes(fdef_master_list,i,depth) if type(node)==dict: for x in fdef_master_list: if jsNam...
[ "def", "tagAttributes", "(", "fdef_master_list", ",", "node", ",", "depth", "=", "0", ")", ":", "if", "type", "(", "node", ")", "==", "list", ":", "for", "i", "in", "node", ":", "depth", "+=", "1", "tagAttributes", "(", "fdef_master_list", ",", "i", ...
recursively tag objects with sizes, depths and path names
[ "recursively", "tag", "objects", "with", "sizes", "depths", "and", "path", "names" ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L161-L177
train
58,305
brmscheiner/ideogram
ideogram/writer.py
tagAttributes_while
def tagAttributes_while(fdef_master_list,root): '''Tag each node under root with the appropriate depth. ''' depth = 0 current = root untagged_nodes = [root] while untagged_nodes: current = untagged_nodes.pop() for x in fdef_master_list: if jsName(x.path,x.name) == current...
python
def tagAttributes_while(fdef_master_list,root): '''Tag each node under root with the appropriate depth. ''' depth = 0 current = root untagged_nodes = [root] while untagged_nodes: current = untagged_nodes.pop() for x in fdef_master_list: if jsName(x.path,x.name) == current...
[ "def", "tagAttributes_while", "(", "fdef_master_list", ",", "root", ")", ":", "depth", "=", "0", "current", "=", "root", "untagged_nodes", "=", "[", "root", "]", "while", "untagged_nodes", ":", "current", "=", "untagged_nodes", ".", "pop", "(", ")", "for", ...
Tag each node under root with the appropriate depth.
[ "Tag", "each", "node", "under", "root", "with", "the", "appropriate", "depth", "." ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L179-L196
train
58,306
brmscheiner/ideogram
ideogram/writer.py
noEmptyNests
def noEmptyNests(node): '''recursively make sure that no dictionaries inside node contain empty children lists ''' if type(node)==list: for i in node: noEmptyNests(i) if type(node)==dict: for i in node.values(): noEmptyNests(i) if node["children"] == []: ...
python
def noEmptyNests(node): '''recursively make sure that no dictionaries inside node contain empty children lists ''' if type(node)==list: for i in node: noEmptyNests(i) if type(node)==dict: for i in node.values(): noEmptyNests(i) if node["children"] == []: ...
[ "def", "noEmptyNests", "(", "node", ")", ":", "if", "type", "(", "node", ")", "==", "list", ":", "for", "i", "in", "node", ":", "noEmptyNests", "(", "i", ")", "if", "type", "(", "node", ")", "==", "dict", ":", "for", "i", "in", "node", ".", "va...
recursively make sure that no dictionaries inside node contain empty children lists
[ "recursively", "make", "sure", "that", "no", "dictionaries", "inside", "node", "contain", "empty", "children", "lists" ]
422bf566c51fd56f7bbb6e75b16d18d52b4c7568
https://github.com/brmscheiner/ideogram/blob/422bf566c51fd56f7bbb6e75b16d18d52b4c7568/ideogram/writer.py#L199-L209
train
58,307
liminspace/dju-image
dju_image/maintenance.py
remove_old_tmp_files
def remove_old_tmp_files(profiles=None, max_lifetime=(7 * 24)): """ Removes old temp files that is older than expiration_hours. If profiles is None then will be use all profiles. """ assert isinstance(profiles, (list, tuple)) or profiles is None if profiles is None: profiles = dju_settin...
python
def remove_old_tmp_files(profiles=None, max_lifetime=(7 * 24)): """ Removes old temp files that is older than expiration_hours. If profiles is None then will be use all profiles. """ assert isinstance(profiles, (list, tuple)) or profiles is None if profiles is None: profiles = dju_settin...
[ "def", "remove_old_tmp_files", "(", "profiles", "=", "None", ",", "max_lifetime", "=", "(", "7", "*", "24", ")", ")", ":", "assert", "isinstance", "(", "profiles", ",", "(", "list", ",", "tuple", ")", ")", "or", "profiles", "is", "None", "if", "profile...
Removes old temp files that is older than expiration_hours. If profiles is None then will be use all profiles.
[ "Removes", "old", "temp", "files", "that", "is", "older", "than", "expiration_hours", ".", "If", "profiles", "is", "None", "then", "will", "be", "use", "all", "profiles", "." ]
b06eb3be2069cd6cb52cf1e26c2c761883142d4e
https://github.com/liminspace/dju-image/blob/b06eb3be2069cd6cb52cf1e26c2c761883142d4e/dju_image/maintenance.py#L23-L46
train
58,308
erikvw/django-collect-offline-files
django_collect_offline_files/file_queues/incoming_transactions_file_queue.py
IncomingTransactionsFileQueue.next_task
def next_task(self, item, **kwargs): """Calls import_batch for the next filename in the queue and "archives" the file. The archive folder is typically the folder for the deserializer queue. """ filename = os.path.basename(item) try: self.tx_importer.import_ba...
python
def next_task(self, item, **kwargs): """Calls import_batch for the next filename in the queue and "archives" the file. The archive folder is typically the folder for the deserializer queue. """ filename = os.path.basename(item) try: self.tx_importer.import_ba...
[ "def", "next_task", "(", "self", ",", "item", ",", "*", "*", "kwargs", ")", ":", "filename", "=", "os", ".", "path", ".", "basename", "(", "item", ")", "try", ":", "self", ".", "tx_importer", ".", "import_batch", "(", "filename", "=", "filename", ")"...
Calls import_batch for the next filename in the queue and "archives" the file. The archive folder is typically the folder for the deserializer queue.
[ "Calls", "import_batch", "for", "the", "next", "filename", "in", "the", "queue", "and", "archives", "the", "file", "." ]
78f61c823ea3926eb88206b019b5dca3c36017da
https://github.com/erikvw/django-collect-offline-files/blob/78f61c823ea3926eb88206b019b5dca3c36017da/django_collect_offline_files/file_queues/incoming_transactions_file_queue.py#L17-L29
train
58,309
django-fluent/django-fluent-utils
fluent_utils/softdeps/comments.py
get_public_comments_for_model
def get_public_comments_for_model(model): """ Get visible comments for the model. """ if not IS_INSTALLED: # No local comments, return empty queryset. # The project might be using DISQUS or Facebook comments instead. return CommentModelStub.objects.none() else: return...
python
def get_public_comments_for_model(model): """ Get visible comments for the model. """ if not IS_INSTALLED: # No local comments, return empty queryset. # The project might be using DISQUS or Facebook comments instead. return CommentModelStub.objects.none() else: return...
[ "def", "get_public_comments_for_model", "(", "model", ")", ":", "if", "not", "IS_INSTALLED", ":", "# No local comments, return empty queryset.", "# The project might be using DISQUS or Facebook comments instead.", "return", "CommentModelStub", ".", "objects", ".", "none", "(", ...
Get visible comments for the model.
[ "Get", "visible", "comments", "for", "the", "model", "." ]
5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b
https://github.com/django-fluent/django-fluent-utils/blob/5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b/fluent_utils/softdeps/comments.py#L67-L76
train
58,310
django-fluent/django-fluent-utils
fluent_utils/softdeps/comments.py
get_comments_are_open
def get_comments_are_open(instance): """ Check if comments are open for the instance """ if not IS_INSTALLED: return False try: # Get the moderator which is installed for this model. mod = moderator._registry[instance.__class__] except KeyError: # No moderator = ...
python
def get_comments_are_open(instance): """ Check if comments are open for the instance """ if not IS_INSTALLED: return False try: # Get the moderator which is installed for this model. mod = moderator._registry[instance.__class__] except KeyError: # No moderator = ...
[ "def", "get_comments_are_open", "(", "instance", ")", ":", "if", "not", "IS_INSTALLED", ":", "return", "False", "try", ":", "# Get the moderator which is installed for this model.", "mod", "=", "moderator", ".", "_registry", "[", "instance", ".", "__class__", "]", "...
Check if comments are open for the instance
[ "Check", "if", "comments", "are", "open", "for", "the", "instance" ]
5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b
https://github.com/django-fluent/django-fluent-utils/blob/5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b/fluent_utils/softdeps/comments.py#L79-L95
train
58,311
django-fluent/django-fluent-utils
fluent_utils/softdeps/comments.py
get_comments_are_moderated
def get_comments_are_moderated(instance): """ Check if comments are moderated for the instance """ if not IS_INSTALLED: return False try: # Get the moderator which is installed for this model. mod = moderator._registry[instance.__class__] except KeyError: # No mo...
python
def get_comments_are_moderated(instance): """ Check if comments are moderated for the instance """ if not IS_INSTALLED: return False try: # Get the moderator which is installed for this model. mod = moderator._registry[instance.__class__] except KeyError: # No mo...
[ "def", "get_comments_are_moderated", "(", "instance", ")", ":", "if", "not", "IS_INSTALLED", ":", "return", "False", "try", ":", "# Get the moderator which is installed for this model.", "mod", "=", "moderator", ".", "_registry", "[", "instance", ".", "__class__", "]"...
Check if comments are moderated for the instance
[ "Check", "if", "comments", "are", "moderated", "for", "the", "instance" ]
5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b
https://github.com/django-fluent/django-fluent-utils/blob/5f93e5aa20f33a44133ad49fde4df0bfe1bc9f0b/fluent_utils/softdeps/comments.py#L98-L114
train
58,312
cstatz/maui
maui/backend/helper.py
calc_local_indices
def calc_local_indices(shape, num_partitions, coordinate): """ calculate local indices, return start and stop index per dimension per process for local data field :param shape: global shape of data :param num_partitions: number of partition for each dimension (from MPI.Compute_dims()) :param coordinate...
python
def calc_local_indices(shape, num_partitions, coordinate): """ calculate local indices, return start and stop index per dimension per process for local data field :param shape: global shape of data :param num_partitions: number of partition for each dimension (from MPI.Compute_dims()) :param coordinate...
[ "def", "calc_local_indices", "(", "shape", ",", "num_partitions", ",", "coordinate", ")", ":", "dimension", "=", "len", "(", "shape", ")", "# check matching of cartesian communicator and shape", "assert", "dimension", "==", "len", "(", "num_partitions", ")", "decompos...
calculate local indices, return start and stop index per dimension per process for local data field :param shape: global shape of data :param num_partitions: number of partition for each dimension (from MPI.Compute_dims()) :param coordinate: cartesian coordinate descriptor (from CARTESIAN_COMMUNICATOR.Get_...
[ "calculate", "local", "indices", "return", "start", "and", "stop", "index", "per", "dimension", "per", "process", "for", "local", "data", "field" ]
db99986e93699ee20c5cffdd5b4ee446f8607c5d
https://github.com/cstatz/maui/blob/db99986e93699ee20c5cffdd5b4ee446f8607c5d/maui/backend/helper.py#L85-L146
train
58,313
Nekroze/partpy
partpy/sourcestring.py
SourceString.load_file
def load_file(self, filename): """Read in file contents and set the current string.""" with open(filename, 'r') as sourcefile: self.set_string(sourcefile.read())
python
def load_file(self, filename): """Read in file contents and set the current string.""" with open(filename, 'r') as sourcefile: self.set_string(sourcefile.read())
[ "def", "load_file", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "sourcefile", ":", "self", ".", "set_string", "(", "sourcefile", ".", "read", "(", ")", ")" ]
Read in file contents and set the current string.
[ "Read", "in", "file", "contents", "and", "set", "the", "current", "string", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L33-L36
train
58,314
Nekroze/partpy
partpy/sourcestring.py
SourceString.set_string
def set_string(self, string): """Set the working string and its length then reset positions.""" self.string = string self.length = len(string) self.reset_position()
python
def set_string(self, string): """Set the working string and its length then reset positions.""" self.string = string self.length = len(string) self.reset_position()
[ "def", "set_string", "(", "self", ",", "string", ")", ":", "self", ".", "string", "=", "string", "self", ".", "length", "=", "len", "(", "string", ")", "self", ".", "reset_position", "(", ")" ]
Set the working string and its length then reset positions.
[ "Set", "the", "working", "string", "and", "its", "length", "then", "reset", "positions", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L38-L42
train
58,315
Nekroze/partpy
partpy/sourcestring.py
SourceString.add_string
def add_string(self, string): """Add to the working string and its length and reset eos.""" self.string += string self.length += len(string) self.eos = 0
python
def add_string(self, string): """Add to the working string and its length and reset eos.""" self.string += string self.length += len(string) self.eos = 0
[ "def", "add_string", "(", "self", ",", "string", ")", ":", "self", ".", "string", "+=", "string", "self", ".", "length", "+=", "len", "(", "string", ")", "self", ".", "eos", "=", "0" ]
Add to the working string and its length and reset eos.
[ "Add", "to", "the", "working", "string", "and", "its", "length", "and", "reset", "eos", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L44-L48
train
58,316
Nekroze/partpy
partpy/sourcestring.py
SourceString.reset_position
def reset_position(self): """Reset all current positions.""" self.pos = 0 self.col = 0 self.row = 1 self.eos = 0
python
def reset_position(self): """Reset all current positions.""" self.pos = 0 self.col = 0 self.row = 1 self.eos = 0
[ "def", "reset_position", "(", "self", ")", ":", "self", ".", "pos", "=", "0", "self", ".", "col", "=", "0", "self", ".", "row", "=", "1", "self", ".", "eos", "=", "0" ]
Reset all current positions.
[ "Reset", "all", "current", "positions", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L50-L55
train
58,317
Nekroze/partpy
partpy/sourcestring.py
SourceString.has_space
def has_space(self, length=1, offset=0): """Returns boolean if self.pos + length < working string length.""" return self.pos + (length + offset) - 1 < self.length
python
def has_space(self, length=1, offset=0): """Returns boolean if self.pos + length < working string length.""" return self.pos + (length + offset) - 1 < self.length
[ "def", "has_space", "(", "self", ",", "length", "=", "1", ",", "offset", "=", "0", ")", ":", "return", "self", ".", "pos", "+", "(", "length", "+", "offset", ")", "-", "1", "<", "self", ".", "length" ]
Returns boolean if self.pos + length < working string length.
[ "Returns", "boolean", "if", "self", ".", "pos", "+", "length", "<", "working", "string", "length", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L57-L59
train
58,318
Nekroze/partpy
partpy/sourcestring.py
SourceString.eol_distance_next
def eol_distance_next(self, offset=0): """Return the amount of characters until the next newline.""" distance = 0 for char in self.string[self.pos + offset:]: if char == '\n': break else: distance += 1 return distance
python
def eol_distance_next(self, offset=0): """Return the amount of characters until the next newline.""" distance = 0 for char in self.string[self.pos + offset:]: if char == '\n': break else: distance += 1 return distance
[ "def", "eol_distance_next", "(", "self", ",", "offset", "=", "0", ")", ":", "distance", "=", "0", "for", "char", "in", "self", ".", "string", "[", "self", ".", "pos", "+", "offset", ":", "]", ":", "if", "char", "==", "'\\n'", ":", "break", "else", ...
Return the amount of characters until the next newline.
[ "Return", "the", "amount", "of", "characters", "until", "the", "next", "newline", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L61-L69
train
58,319
Nekroze/partpy
partpy/sourcestring.py
SourceString.eol_distance_last
def eol_distance_last(self, offset=0): """Return the ammount of characters until the last newline.""" distance = 0 for char in reversed(self.string[:self.pos + offset]): if char == '\n': break else: distance += 1 return distance
python
def eol_distance_last(self, offset=0): """Return the ammount of characters until the last newline.""" distance = 0 for char in reversed(self.string[:self.pos + offset]): if char == '\n': break else: distance += 1 return distance
[ "def", "eol_distance_last", "(", "self", ",", "offset", "=", "0", ")", ":", "distance", "=", "0", "for", "char", "in", "reversed", "(", "self", ".", "string", "[", ":", "self", ".", "pos", "+", "offset", "]", ")", ":", "if", "char", "==", "'\\n'", ...
Return the ammount of characters until the last newline.
[ "Return", "the", "ammount", "of", "characters", "until", "the", "last", "newline", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L71-L79
train
58,320
Nekroze/partpy
partpy/sourcestring.py
SourceString.spew_length
def spew_length(self, length): """Move current position backwards by length.""" pos = self.pos if not pos or length > pos: return None row = self.row for char in reversed(self.string[pos - length:pos]): pos -= 1 if char == '\n': # handle a ne...
python
def spew_length(self, length): """Move current position backwards by length.""" pos = self.pos if not pos or length > pos: return None row = self.row for char in reversed(self.string[pos - length:pos]): pos -= 1 if char == '\n': # handle a ne...
[ "def", "spew_length", "(", "self", ",", "length", ")", ":", "pos", "=", "self", ".", "pos", "if", "not", "pos", "or", "length", ">", "pos", ":", "return", "None", "row", "=", "self", ".", "row", "for", "char", "in", "reversed", "(", "self", ".", ...
Move current position backwards by length.
[ "Move", "current", "position", "backwards", "by", "length", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L81-L98
train
58,321
Nekroze/partpy
partpy/sourcestring.py
SourceString.eat_length
def eat_length(self, length): """Move current position forward by length and sets eos if needed.""" pos = self.pos if self.eos or pos + length > self.length: return None col = self.col row = self.row for char in self.string[pos:pos + length]: col ...
python
def eat_length(self, length): """Move current position forward by length and sets eos if needed.""" pos = self.pos if self.eos or pos + length > self.length: return None col = self.col row = self.row for char in self.string[pos:pos + length]: col ...
[ "def", "eat_length", "(", "self", ",", "length", ")", ":", "pos", "=", "self", ".", "pos", "if", "self", ".", "eos", "or", "pos", "+", "length", ">", "self", ".", "length", ":", "return", "None", "col", "=", "self", ".", "col", "row", "=", "self"...
Move current position forward by length and sets eos if needed.
[ "Move", "current", "position", "forward", "by", "length", "and", "sets", "eos", "if", "needed", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L100-L120
train
58,322
Nekroze/partpy
partpy/sourcestring.py
SourceString.eat_string
def eat_string(self, string): """Move current position by length of string and count lines by \n.""" pos = self.pos if self.eos or pos + len(string) > self.length: return None col = self.col row = self.row for char in string: col += 1 ...
python
def eat_string(self, string): """Move current position by length of string and count lines by \n.""" pos = self.pos if self.eos or pos + len(string) > self.length: return None col = self.col row = self.row for char in string: col += 1 ...
[ "def", "eat_string", "(", "self", ",", "string", ")", ":", "pos", "=", "self", ".", "pos", "if", "self", ".", "eos", "or", "pos", "+", "len", "(", "string", ")", ">", "self", ".", "length", ":", "return", "None", "col", "=", "self", ".", "col", ...
Move current position by length of string and count lines by \n.
[ "Move", "current", "position", "by", "length", "of", "string", "and", "count", "lines", "by", "\\", "n", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L122-L142
train
58,323
Nekroze/partpy
partpy/sourcestring.py
SourceString.eat_line
def eat_line(self): """Move current position forward until the next line.""" if self.eos: return None eat_length = self.eat_length get_char = self.get_char has_space = self.has_space while has_space() and get_char() != '\n': eat_length(1) e...
python
def eat_line(self): """Move current position forward until the next line.""" if self.eos: return None eat_length = self.eat_length get_char = self.get_char has_space = self.has_space while has_space() and get_char() != '\n': eat_length(1) e...
[ "def", "eat_line", "(", "self", ")", ":", "if", "self", ".", "eos", ":", "return", "None", "eat_length", "=", "self", ".", "eat_length", "get_char", "=", "self", ".", "get_char", "has_space", "=", "self", ".", "has_space", "while", "has_space", "(", ")",...
Move current position forward until the next line.
[ "Move", "current", "position", "forward", "until", "the", "next", "line", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L144-L153
train
58,324
Nekroze/partpy
partpy/sourcestring.py
SourceString.get_char
def get_char(self, offset=0): """Return the current character in the working string.""" if not self.has_space(offset=offset): return '' return self.string[self.pos + offset]
python
def get_char(self, offset=0): """Return the current character in the working string.""" if not self.has_space(offset=offset): return '' return self.string[self.pos + offset]
[ "def", "get_char", "(", "self", ",", "offset", "=", "0", ")", ":", "if", "not", "self", ".", "has_space", "(", "offset", "=", "offset", ")", ":", "return", "''", "return", "self", ".", "string", "[", "self", ".", "pos", "+", "offset", "]" ]
Return the current character in the working string.
[ "Return", "the", "current", "character", "in", "the", "working", "string", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L155-L160
train
58,325
Nekroze/partpy
partpy/sourcestring.py
SourceString.get_length
def get_length(self, length, trim=0, offset=0): """Return string at current position + length. If trim == true then get as much as possible before eos. """ if trim and not self.has_space(offset + length): return self.string[self.pos + offset:] elif self.has_space(offs...
python
def get_length(self, length, trim=0, offset=0): """Return string at current position + length. If trim == true then get as much as possible before eos. """ if trim and not self.has_space(offset + length): return self.string[self.pos + offset:] elif self.has_space(offs...
[ "def", "get_length", "(", "self", ",", "length", ",", "trim", "=", "0", ",", "offset", "=", "0", ")", ":", "if", "trim", "and", "not", "self", ".", "has_space", "(", "offset", "+", "length", ")", ":", "return", "self", ".", "string", "[", "self", ...
Return string at current position + length. If trim == true then get as much as possible before eos.
[ "Return", "string", "at", "current", "position", "+", "length", ".", "If", "trim", "==", "true", "then", "get", "as", "much", "as", "possible", "before", "eos", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L162-L171
train
58,326
Nekroze/partpy
partpy/sourcestring.py
SourceString.get_string
def get_string(self, offset=0): """Return non space chars from current position until a whitespace.""" if not self.has_space(offset=offset): return '' # Get a char for each char in the current string from pos onward # solong as the char is not whitespace. string = s...
python
def get_string(self, offset=0): """Return non space chars from current position until a whitespace.""" if not self.has_space(offset=offset): return '' # Get a char for each char in the current string from pos onward # solong as the char is not whitespace. string = s...
[ "def", "get_string", "(", "self", ",", "offset", "=", "0", ")", ":", "if", "not", "self", ".", "has_space", "(", "offset", "=", "offset", ")", ":", "return", "''", "# Get a char for each char in the current string from pos onward", "# solong as the char is not whites...
Return non space chars from current position until a whitespace.
[ "Return", "non", "space", "chars", "from", "current", "position", "until", "a", "whitespace", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L173-L186
train
58,327
Nekroze/partpy
partpy/sourcestring.py
SourceString.rest_of_string
def rest_of_string(self, offset=0): """A copy of the current position till the end of the source string.""" if self.has_space(offset=offset): return self.string[self.pos + offset:] else: return ''
python
def rest_of_string(self, offset=0): """A copy of the current position till the end of the source string.""" if self.has_space(offset=offset): return self.string[self.pos + offset:] else: return ''
[ "def", "rest_of_string", "(", "self", ",", "offset", "=", "0", ")", ":", "if", "self", ".", "has_space", "(", "offset", "=", "offset", ")", ":", "return", "self", ".", "string", "[", "self", ".", "pos", "+", "offset", ":", "]", "else", ":", "return...
A copy of the current position till the end of the source string.
[ "A", "copy", "of", "the", "current", "position", "till", "the", "end", "of", "the", "source", "string", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L188-L193
train
58,328
Nekroze/partpy
partpy/sourcestring.py
SourceString.get_current_line
def get_current_line(self): """Return a SourceLine of the current line.""" if not self.has_space(): return None pos = self.pos - self.col string = self.string end = self.length output = [] while pos < len(string) and string[pos] != '\n': ...
python
def get_current_line(self): """Return a SourceLine of the current line.""" if not self.has_space(): return None pos = self.pos - self.col string = self.string end = self.length output = [] while pos < len(string) and string[pos] != '\n': ...
[ "def", "get_current_line", "(", "self", ")", ":", "if", "not", "self", ".", "has_space", "(", ")", ":", "return", "None", "pos", "=", "self", ".", "pos", "-", "self", ".", "col", "string", "=", "self", ".", "string", "end", "=", "self", ".", "lengt...
Return a SourceLine of the current line.
[ "Return", "a", "SourceLine", "of", "the", "current", "line", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L212-L233
train
58,329
Nekroze/partpy
partpy/sourcestring.py
SourceString.get_lines
def get_lines(self, first, last): """Return SourceLines for lines between and including first & last.""" line = 1 linestring = [] linestrings = [] for char in self.string: if line >= first and line <= last: linestring.append(char) if ch...
python
def get_lines(self, first, last): """Return SourceLines for lines between and including first & last.""" line = 1 linestring = [] linestrings = [] for char in self.string: if line >= first and line <= last: linestring.append(char) if ch...
[ "def", "get_lines", "(", "self", ",", "first", ",", "last", ")", ":", "line", "=", "1", "linestring", "=", "[", "]", "linestrings", "=", "[", "]", "for", "char", "in", "self", ".", "string", ":", "if", "line", ">=", "first", "and", "line", "<=", ...
Return SourceLines for lines between and including first & last.
[ "Return", "SourceLines", "for", "lines", "between", "and", "including", "first", "&", "last", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L235-L256
train
58,330
Nekroze/partpy
partpy/sourcestring.py
SourceString.get_surrounding_lines
def get_surrounding_lines(self, past=1, future=1): """Return the current line and x,y previous and future lines. Returns a list of SourceLine's. """ string = self.string pos = self.pos - self.col end = self.length row = self.row linesback = 0 whil...
python
def get_surrounding_lines(self, past=1, future=1): """Return the current line and x,y previous and future lines. Returns a list of SourceLine's. """ string = self.string pos = self.pos - self.col end = self.length row = self.row linesback = 0 whil...
[ "def", "get_surrounding_lines", "(", "self", ",", "past", "=", "1", ",", "future", "=", "1", ")", ":", "string", "=", "self", ".", "string", "pos", "=", "self", ".", "pos", "-", "self", ".", "col", "end", "=", "self", ".", "length", "row", "=", "...
Return the current line and x,y previous and future lines. Returns a list of SourceLine's.
[ "Return", "the", "current", "line", "and", "x", "y", "previous", "and", "future", "lines", ".", "Returns", "a", "list", "of", "SourceLine", "s", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L258-L294
train
58,331
Nekroze/partpy
partpy/sourcestring.py
SourceString.get_all_lines
def get_all_lines(self): """Return all lines of the SourceString as a list of SourceLine's.""" output = [] line = [] lineno = 1 for char in self.string: line.append(char) if char == '\n': output.append(SourceLine(''.join(line), lineno)) ...
python
def get_all_lines(self): """Return all lines of the SourceString as a list of SourceLine's.""" output = [] line = [] lineno = 1 for char in self.string: line.append(char) if char == '\n': output.append(SourceLine(''.join(line), lineno)) ...
[ "def", "get_all_lines", "(", "self", ")", ":", "output", "=", "[", "]", "line", "=", "[", "]", "lineno", "=", "1", "for", "char", "in", "self", ".", "string", ":", "line", ".", "append", "(", "char", ")", "if", "char", "==", "'\\n'", ":", "output...
Return all lines of the SourceString as a list of SourceLine's.
[ "Return", "all", "lines", "of", "the", "SourceString", "as", "a", "list", "of", "SourceLine", "s", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L296-L310
train
58,332
Nekroze/partpy
partpy/sourcestring.py
SourceString.match_string
def match_string(self, string, word=0, offset=0): """Returns 1 if string can be matches against SourceString's current position. If word is >= 1 then it will only match string followed by whitepsace. """ if word: return self.get_string(offset) == string retur...
python
def match_string(self, string, word=0, offset=0): """Returns 1 if string can be matches against SourceString's current position. If word is >= 1 then it will only match string followed by whitepsace. """ if word: return self.get_string(offset) == string retur...
[ "def", "match_string", "(", "self", ",", "string", ",", "word", "=", "0", ",", "offset", "=", "0", ")", ":", "if", "word", ":", "return", "self", ".", "get_string", "(", "offset", ")", "==", "string", "return", "self", ".", "get_length", "(", "len", ...
Returns 1 if string can be matches against SourceString's current position. If word is >= 1 then it will only match string followed by whitepsace.
[ "Returns", "1", "if", "string", "can", "be", "matches", "against", "SourceString", "s", "current", "position", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L312-L320
train
58,333
Nekroze/partpy
partpy/sourcestring.py
SourceString.match_any_string
def match_any_string(self, strings, word=0, offset=0): """Attempts to match each string in strings in order. Will return the string that matches or an empty string if no match. If word arg >= 1 then only match if string is followed by a whitespace which is much higher performance. ...
python
def match_any_string(self, strings, word=0, offset=0): """Attempts to match each string in strings in order. Will return the string that matches or an empty string if no match. If word arg >= 1 then only match if string is followed by a whitespace which is much higher performance. ...
[ "def", "match_any_string", "(", "self", ",", "strings", ",", "word", "=", "0", ",", "offset", "=", "0", ")", ":", "if", "word", ":", "current", "=", "self", ".", "get_string", "(", "offset", ")", "return", "current", "if", "current", "in", "strings", ...
Attempts to match each string in strings in order. Will return the string that matches or an empty string if no match. If word arg >= 1 then only match if string is followed by a whitespace which is much higher performance. If word is 0 then you should sort the strings argument yoursel...
[ "Attempts", "to", "match", "each", "string", "in", "strings", "in", "order", ".", "Will", "return", "the", "string", "that", "matches", "or", "an", "empty", "string", "if", "no", "match", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L322-L345
train
58,334
Nekroze/partpy
partpy/sourcestring.py
SourceString.match_any_char
def match_any_char(self, chars, offset=0): """Match and return the current SourceString char if its in chars.""" if not self.has_space(offset=offset): return '' current = self.string[self.pos + offset] return current if current in chars else ''
python
def match_any_char(self, chars, offset=0): """Match and return the current SourceString char if its in chars.""" if not self.has_space(offset=offset): return '' current = self.string[self.pos + offset] return current if current in chars else ''
[ "def", "match_any_char", "(", "self", ",", "chars", ",", "offset", "=", "0", ")", ":", "if", "not", "self", ".", "has_space", "(", "offset", "=", "offset", ")", ":", "return", "''", "current", "=", "self", ".", "string", "[", "self", ".", "pos", "+...
Match and return the current SourceString char if its in chars.
[ "Match", "and", "return", "the", "current", "SourceString", "char", "if", "its", "in", "chars", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L347-L352
train
58,335
Nekroze/partpy
partpy/sourcestring.py
SourceString.match_function_pattern
def match_function_pattern(self, first, rest=None, least=1, offset=0): """Match each char sequentially from current SourceString position until the pattern doesnt match and return all maches. Integer argument least defines and minimum amount of chars that can be matched. This v...
python
def match_function_pattern(self, first, rest=None, least=1, offset=0): """Match each char sequentially from current SourceString position until the pattern doesnt match and return all maches. Integer argument least defines and minimum amount of chars that can be matched. This v...
[ "def", "match_function_pattern", "(", "self", ",", "first", ",", "rest", "=", "None", ",", "least", "=", "1", ",", "offset", "=", "0", ")", ":", "if", "not", "self", ".", "has_space", "(", "offset", "=", "offset", ")", ":", "return", "''", "firstchar...
Match each char sequentially from current SourceString position until the pattern doesnt match and return all maches. Integer argument least defines and minimum amount of chars that can be matched. This version takes functions instead of string patterns. Each function must take...
[ "Match", "each", "char", "sequentially", "from", "current", "SourceString", "position", "until", "the", "pattern", "doesnt", "match", "and", "return", "all", "maches", "." ]
dbb7d2fb285464fc43d85bc31f5af46192d301f6
https://github.com/Nekroze/partpy/blob/dbb7d2fb285464fc43d85bc31f5af46192d301f6/partpy/sourcestring.py#L384-L416
train
58,336
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
train
58,337
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
train
58,338
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
train
58,339
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
train
58,340
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
train
58,341
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
train
58,342
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
train
58,343
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
train
58,344
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
train
58,345
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
train
58,346
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
train
58,347
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
train
58,348
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
train
58,349
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
train
58,350
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
train
58,351
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
train
58,352
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
train
58,353
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
train
58,354
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
train
58,355
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
train
58,356
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
train
58,357
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
train
58,358
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
train
58,359
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
train
58,360
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
train
58,361
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
train
58,362
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
train
58,363
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
train
58,364
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
train
58,365
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
train
58,366
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
train
58,367
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
train
58,368
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
train
58,369
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
train
58,370
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
train
58,371
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
train
58,372
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
train
58,373
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
train
58,374
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
train
58,375
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
train
58,376
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
train
58,377
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
train
58,378
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
train
58,379
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
train
58,380
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
train
58,381
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
train
58,382
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
train
58,383
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
train
58,384
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
train
58,385
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
train
58,386
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
train
58,387
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
train
58,388
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
train
58,389
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
train
58,390
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
train
58,391
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
train
58,392
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
train
58,393
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
train
58,394
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
train
58,395
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
train
58,396
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
train
58,397
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
train
58,398
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
train
58,399