repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
markfinger/assembla
assembla/api.py
WikiPage.write
def write(self): """ Create or update a Wiki Page on Assembla """ if not hasattr(self, 'space'): raise AttributeError("A WikiPage must have a 'space' attribute before you can write it to Assembla.") self.api = self.space.api if self.get('id'): # We are modi...
python
def write(self): """ Create or update a Wiki Page on Assembla """ if not hasattr(self, 'space'): raise AttributeError("A WikiPage must have a 'space' attribute before you can write it to Assembla.") self.api = self.space.api if self.get('id'): # We are modi...
[ "def", "write", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'space'", ")", ":", "raise", "AttributeError", "(", "\"A WikiPage must have a 'space' attribute before you can write it to Assembla.\"", ")", "self", ".", "api", "=", "self", ".", "s...
Create or update a Wiki Page on Assembla
[ "Create", "or", "update", "a", "Wiki", "Page", "on", "Assembla" ]
967a77a5ba718df94f60e832b6e0cf14c72426aa
https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/api.py#L573-L594
train
Genida/dependenpy
src/dependenpy/finder.py
PackageSpec.add
def add(self, spec): """ Add limitations of given spec to self's. Args: spec (PackageSpec): another spec. """ for limit in spec.limit_to: if limit not in self.limit_to: self.limit_to.append(limit)
python
def add(self, spec): """ Add limitations of given spec to self's. Args: spec (PackageSpec): another spec. """ for limit in spec.limit_to: if limit not in self.limit_to: self.limit_to.append(limit)
[ "def", "add", "(", "self", ",", "spec", ")", ":", "for", "limit", "in", "spec", ".", "limit_to", ":", "if", "limit", "not", "in", "self", ".", "limit_to", ":", "self", ".", "limit_to", ".", "append", "(", "limit", ")" ]
Add limitations of given spec to self's. Args: spec (PackageSpec): another spec.
[ "Add", "limitations", "of", "given", "spec", "to", "self", "s", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L33-L42
train
Genida/dependenpy
src/dependenpy/finder.py
PackageSpec.combine
def combine(specs): """ Combine package specifications' limitations. Args: specs (list of PackageSpec): the package specifications. Returns: list of PackageSpec: the new, merged list of PackageSpec. """ new_specs = {} for spec in specs: ...
python
def combine(specs): """ Combine package specifications' limitations. Args: specs (list of PackageSpec): the package specifications. Returns: list of PackageSpec: the new, merged list of PackageSpec. """ new_specs = {} for spec in specs: ...
[ "def", "combine", "(", "specs", ")", ":", "new_specs", "=", "{", "}", "for", "spec", "in", "specs", ":", "if", "new_specs", ".", "get", "(", "spec", ",", "None", ")", "is", "None", ":", "new_specs", "[", "spec", "]", "=", "spec", "else", ":", "ne...
Combine package specifications' limitations. Args: specs (list of PackageSpec): the package specifications. Returns: list of PackageSpec: the new, merged list of PackageSpec.
[ "Combine", "package", "specifications", "limitations", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L45-L61
train
Genida/dependenpy
src/dependenpy/finder.py
Finder.find
def find(self, package, **kwargs): """ Find a package using package finders. Return the first package found. Args: package (str): package to find. **kwargs (): additional keyword arguments used by finders. Returns: PackageSpec: if package fo...
python
def find(self, package, **kwargs): """ Find a package using package finders. Return the first package found. Args: package (str): package to find. **kwargs (): additional keyword arguments used by finders. Returns: PackageSpec: if package fo...
[ "def", "find", "(", "self", ",", "package", ",", "**", "kwargs", ")", ":", "for", "finder", "in", "self", ".", "finders", ":", "package_spec", "=", "finder", ".", "find", "(", "package", ",", "**", "kwargs", ")", "if", "package_spec", ":", "return", ...
Find a package using package finders. Return the first package found. Args: package (str): package to find. **kwargs (): additional keyword arguments used by finders. Returns: PackageSpec: if package found, else None
[ "Find", "a", "package", "using", "package", "finders", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/finder.py#L163-L180
train
noahbenson/pimms
pimms/util.py
_lazy_turbo_mapping
def _lazy_turbo_mapping(initial, pre_size): ''' _lazy_turbo_mapping is a blatant copy of the pyrsistent._pmap._turbo_mapping function, except it works for lazy maps; this seems like the only way to fully overload PMap. ''' size = pre_size or (2 * len(initial)) or 8 buckets = size * [None] if...
python
def _lazy_turbo_mapping(initial, pre_size): ''' _lazy_turbo_mapping is a blatant copy of the pyrsistent._pmap._turbo_mapping function, except it works for lazy maps; this seems like the only way to fully overload PMap. ''' size = pre_size or (2 * len(initial)) or 8 buckets = size * [None] if...
[ "def", "_lazy_turbo_mapping", "(", "initial", ",", "pre_size", ")", ":", "size", "=", "pre_size", "or", "(", "2", "*", "len", "(", "initial", ")", ")", "or", "8", "buckets", "=", "size", "*", "[", "None", "]", "if", "not", "isinstance", "(", "initial...
_lazy_turbo_mapping is a blatant copy of the pyrsistent._pmap._turbo_mapping function, except it works for lazy maps; this seems like the only way to fully overload PMap.
[ "_lazy_turbo_mapping", "is", "a", "blatant", "copy", "of", "the", "pyrsistent", ".", "_pmap", ".", "_turbo_mapping", "function", "except", "it", "works", "for", "lazy", "maps", ";", "this", "seems", "like", "the", "only", "way", "to", "fully", "overload", "P...
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L686-L700
train
noahbenson/pimms
pimms/util.py
lazy_map
def lazy_map(initial={}, pre_size=0): ''' lazy_map is a blatant copy of the pyrsistent.pmap function, and is used to create lazy maps. ''' if is_lazy_map(initial): return initial if not initial: return _EMPTY_LMAP return _lazy_turbo_mapping(initial, pre_size)
python
def lazy_map(initial={}, pre_size=0): ''' lazy_map is a blatant copy of the pyrsistent.pmap function, and is used to create lazy maps. ''' if is_lazy_map(initial): return initial if not initial: return _EMPTY_LMAP return _lazy_turbo_mapping(initial, pre_size)
[ "def", "lazy_map", "(", "initial", "=", "{", "}", ",", "pre_size", "=", "0", ")", ":", "if", "is_lazy_map", "(", "initial", ")", ":", "return", "initial", "if", "not", "initial", ":", "return", "_EMPTY_LMAP", "return", "_lazy_turbo_mapping", "(", "initial"...
lazy_map is a blatant copy of the pyrsistent.pmap function, and is used to create lazy maps.
[ "lazy_map", "is", "a", "blatant", "copy", "of", "the", "pyrsistent", ".", "pmap", "function", "and", "is", "used", "to", "create", "lazy", "maps", "." ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L702-L708
train
noahbenson/pimms
pimms/util.py
LazyPMap._examine_val
def _examine_val(self, k, val): 'should only be called internally' if not isinstance(val, (types.FunctionType, partial)): return val vid = id(val) if vid in self._memoized: return self._memoized[vid] elif [] != getargspec_py27like(val)[0]: return val ...
python
def _examine_val(self, k, val): 'should only be called internally' if not isinstance(val, (types.FunctionType, partial)): return val vid = id(val) if vid in self._memoized: return self._memoized[vid] elif [] != getargspec_py27like(val)[0]: return val ...
[ "def", "_examine_val", "(", "self", ",", "k", ",", "val", ")", ":", "'should only be called internally'", "if", "not", "isinstance", "(", "val", ",", "(", "types", ".", "FunctionType", ",", "partial", ")", ")", ":", "return", "val", "vid", "=", "id", "("...
should only be called internally
[ "should", "only", "be", "called", "internally" ]
9051b86d6b858a7a13511b72c48dc21bc903dab2
https://github.com/noahbenson/pimms/blob/9051b86d6b858a7a13511b72c48dc21bc903dab2/pimms/util.py#L582-L593
train
praekeltfoundation/seed-message-sender
message_sender/signals.py
psh_fire_msg_action_if_new
def psh_fire_msg_action_if_new(sender, instance, created, **kwargs): """ Post save hook to fire message send task """ if created: from message_sender.tasks import send_message send_message.apply_async(kwargs={"message_id": str(instance.id)})
python
def psh_fire_msg_action_if_new(sender, instance, created, **kwargs): """ Post save hook to fire message send task """ if created: from message_sender.tasks import send_message send_message.apply_async(kwargs={"message_id": str(instance.id)})
[ "def", "psh_fire_msg_action_if_new", "(", "sender", ",", "instance", ",", "created", ",", "**", "kwargs", ")", ":", "if", "created", ":", "from", "message_sender", ".", "tasks", "import", "send_message", "send_message", ".", "apply_async", "(", "kwargs", "=", ...
Post save hook to fire message send task
[ "Post", "save", "hook", "to", "fire", "message", "send", "task" ]
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/signals.py#L4-L10
train
praekeltfoundation/seed-message-sender
message_sender/signals.py
update_default_channels
def update_default_channels(sender, instance, created, **kwargs): """ Post save hook to ensure that there is only one default """ if instance.default: Channel.objects.filter(default=True).exclude( channel_id=instance.channel_id ).update(default=False)
python
def update_default_channels(sender, instance, created, **kwargs): """ Post save hook to ensure that there is only one default """ if instance.default: Channel.objects.filter(default=True).exclude( channel_id=instance.channel_id ).update(default=False)
[ "def", "update_default_channels", "(", "sender", ",", "instance", ",", "created", ",", "**", "kwargs", ")", ":", "if", "instance", ".", "default", ":", "Channel", ".", "objects", ".", "filter", "(", "default", "=", "True", ")", ".", "exclude", "(", "chan...
Post save hook to ensure that there is only one default
[ "Post", "save", "hook", "to", "ensure", "that", "there", "is", "only", "one", "default" ]
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/signals.py#L13-L19
train
romanorac/discomll
discomll/classification/linear_svm.py
map_fit
def map_fit(interface, state, label, inp): """ Function calculates matrices ete and etde for every sample, aggregates and output them. """ import numpy as np ete, etde = 0, 0 out = interface.output(0) for row in inp: row = row.strip().split(state["delimiter"]) # split row i...
python
def map_fit(interface, state, label, inp): """ Function calculates matrices ete and etde for every sample, aggregates and output them. """ import numpy as np ete, etde = 0, 0 out = interface.output(0) for row in inp: row = row.strip().split(state["delimiter"]) # split row i...
[ "def", "map_fit", "(", "interface", ",", "state", ",", "label", ",", "inp", ")", ":", "import", "numpy", "as", "np", "ete", ",", "etde", "=", "0", ",", "0", "out", "=", "interface", ".", "output", "(", "0", ")", "for", "row", "in", "inp", ":", ...
Function calculates matrices ete and etde for every sample, aggregates and output them.
[ "Function", "calculates", "matrices", "ete", "and", "etde", "for", "every", "sample", "aggregates", "and", "output", "them", "." ]
a4703daffb2ba3c9f614bc3dbe45ae55884aea00
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/classification/linear_svm.py#L15-L36
train
romanorac/discomll
discomll/classification/linear_svm.py
reduce_fit
def reduce_fit(interface, state, label, inp): """ Function joins all partially calculated matrices ETE and ETDe, aggregates them and it calculates final parameters. """ import numpy as np out = interface.output(0) sum_etde = 0 sum_ete = [0 for _ in range(len(state["X_indices"]) + 1)] fo...
python
def reduce_fit(interface, state, label, inp): """ Function joins all partially calculated matrices ETE and ETDe, aggregates them and it calculates final parameters. """ import numpy as np out = interface.output(0) sum_etde = 0 sum_ete = [0 for _ in range(len(state["X_indices"]) + 1)] fo...
[ "def", "reduce_fit", "(", "interface", ",", "state", ",", "label", ",", "inp", ")", ":", "import", "numpy", "as", "np", "out", "=", "interface", ".", "output", "(", "0", ")", "sum_etde", "=", "0", "sum_ete", "=", "[", "0", "for", "_", "in", "range"...
Function joins all partially calculated matrices ETE and ETDe, aggregates them and it calculates final parameters.
[ "Function", "joins", "all", "partially", "calculated", "matrices", "ETE", "and", "ETDe", "aggregates", "them", "and", "it", "calculates", "final", "parameters", "." ]
a4703daffb2ba3c9f614bc3dbe45ae55884aea00
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/classification/linear_svm.py#L39-L55
train
romanorac/discomll
discomll/classification/linear_svm.py
fit
def fit(dataset, nu=0.1, save_results=True, show=False): """ Function starts a job for calculation of model parameters Parameters ---------- input - dataset object with input urls and other parameters nu - parameter to adjust the classifier save_results - save results to ddfs show - sho...
python
def fit(dataset, nu=0.1, save_results=True, show=False): """ Function starts a job for calculation of model parameters Parameters ---------- input - dataset object with input urls and other parameters nu - parameter to adjust the classifier save_results - save results to ddfs show - sho...
[ "def", "fit", "(", "dataset", ",", "nu", "=", "0.1", ",", "save_results", "=", "True", ",", "show", "=", "False", ")", ":", "from", "disco", ".", "worker", ".", "pipeline", ".", "worker", "import", "Worker", ",", "Stage", "from", "disco", ".", "core"...
Function starts a job for calculation of model parameters Parameters ---------- input - dataset object with input urls and other parameters nu - parameter to adjust the classifier save_results - save results to ddfs show - show info about job execution Returns ------- Urls of fit m...
[ "Function", "starts", "a", "job", "for", "calculation", "of", "model", "parameters" ]
a4703daffb2ba3c9f614bc3dbe45ae55884aea00
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/classification/linear_svm.py#L77-L115
train
romanorac/discomll
discomll/classification/linear_svm.py
predict
def predict(dataset, fitmodel_url, save_results=True, show=False): """ Function starts a job that makes predictions to input data with a given model. Parameters ---------- input - dataset object with input urls and other parameters fitmodel_url - model created in fit phase save_results - sa...
python
def predict(dataset, fitmodel_url, save_results=True, show=False): """ Function starts a job that makes predictions to input data with a given model. Parameters ---------- input - dataset object with input urls and other parameters fitmodel_url - model created in fit phase save_results - sa...
[ "def", "predict", "(", "dataset", ",", "fitmodel_url", ",", "save_results", "=", "True", ",", "show", "=", "False", ")", ":", "from", "disco", ".", "worker", ".", "pipeline", ".", "worker", "import", "Worker", ",", "Stage", "from", "disco", ".", "core", ...
Function starts a job that makes predictions to input data with a given model. Parameters ---------- input - dataset object with input urls and other parameters fitmodel_url - model created in fit phase save_results - save results to ddfs show - show info about job execution Returns --...
[ "Function", "starts", "a", "job", "that", "makes", "predictions", "to", "input", "data", "with", "a", "given", "model", "." ]
a4703daffb2ba3c9f614bc3dbe45ae55884aea00
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/classification/linear_svm.py#L118-L148
train
djaodjin/djaodjin-deployutils
deployutils/apps/django/mockup/views.py
RedirectFormMixin.validate_redirect_url
def validate_redirect_url(next_url): """ Returns the next_url path if next_url matches allowed hosts. """ if not next_url: return None parts = urlparse(next_url) if parts.netloc: domain, _ = split_domain_port(parts.netloc) allowed_hosts...
python
def validate_redirect_url(next_url): """ Returns the next_url path if next_url matches allowed hosts. """ if not next_url: return None parts = urlparse(next_url) if parts.netloc: domain, _ = split_domain_port(parts.netloc) allowed_hosts...
[ "def", "validate_redirect_url", "(", "next_url", ")", ":", "if", "not", "next_url", ":", "return", "None", "parts", "=", "urlparse", "(", "next_url", ")", "if", "parts", ".", "netloc", ":", "domain", ",", "_", "=", "split_domain_port", "(", "parts", ".", ...
Returns the next_url path if next_url matches allowed hosts.
[ "Returns", "the", "next_url", "path", "if", "next_url", "matches", "allowed", "hosts", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/mockup/views.py#L51-L65
train
bitlabstudio/django-currency-history
currency_history/templatetags/currency_history_tags.py
convert_currency
def convert_currency(amount, from_currency, to_currency): ''' Converts currencies. Example: {% convert_currency 2 'EUR' 'SGD' as amount %} ''' try: rate = CurrencyRate.objects.get( from_currency__iso_code=from_currency, to_currency__iso_code=to_currency) exc...
python
def convert_currency(amount, from_currency, to_currency): ''' Converts currencies. Example: {% convert_currency 2 'EUR' 'SGD' as amount %} ''' try: rate = CurrencyRate.objects.get( from_currency__iso_code=from_currency, to_currency__iso_code=to_currency) exc...
[ "def", "convert_currency", "(", "amount", ",", "from_currency", ",", "to_currency", ")", ":", "try", ":", "rate", "=", "CurrencyRate", ".", "objects", ".", "get", "(", "from_currency__iso_code", "=", "from_currency", ",", "to_currency__iso_code", "=", "to_currency...
Converts currencies. Example: {% convert_currency 2 'EUR' 'SGD' as amount %}
[ "Converts", "currencies", "." ]
65fd0fd79c925cd2e87db59762a4ee7066e47c9f
https://github.com/bitlabstudio/django-currency-history/blob/65fd0fd79c925cd2e87db59762a4ee7066e47c9f/currency_history/templatetags/currency_history_tags.py#L11-L29
train
djaodjin/djaodjin-deployutils
deployutils/apps/django/urlbuilders.py
url_prefixed
def url_prefixed(regex, view, name=None): """ Returns a urlpattern prefixed with the APP_NAME in debug mode. """ return url(r'^%(app_prefix)s%(regex)s' % { 'app_prefix': APP_PREFIX, 'regex': regex}, view, name=name)
python
def url_prefixed(regex, view, name=None): """ Returns a urlpattern prefixed with the APP_NAME in debug mode. """ return url(r'^%(app_prefix)s%(regex)s' % { 'app_prefix': APP_PREFIX, 'regex': regex}, view, name=name)
[ "def", "url_prefixed", "(", "regex", ",", "view", ",", "name", "=", "None", ")", ":", "return", "url", "(", "r'^%(app_prefix)s%(regex)s'", "%", "{", "'app_prefix'", ":", "APP_PREFIX", ",", "'regex'", ":", "regex", "}", ",", "view", ",", "name", "=", "nam...
Returns a urlpattern prefixed with the APP_NAME in debug mode.
[ "Returns", "a", "urlpattern", "prefixed", "with", "the", "APP_NAME", "in", "debug", "mode", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/urlbuilders.py#L37-L42
train
mgoral/subconvert
src/subconvert/gui/DataModel.py
DataController.createDataFromFile
def createDataFromFile(self, filePath, inputEncoding = None, defaultFps = None): """Fetch a given filePath and parse its contents. May raise the following exceptions: * RuntimeError - generic exception telling that parsing was unsuccessfull * IOError - failed to open a file at given fil...
python
def createDataFromFile(self, filePath, inputEncoding = None, defaultFps = None): """Fetch a given filePath and parse its contents. May raise the following exceptions: * RuntimeError - generic exception telling that parsing was unsuccessfull * IOError - failed to open a file at given fil...
[ "def", "createDataFromFile", "(", "self", ",", "filePath", ",", "inputEncoding", "=", "None", ",", "defaultFps", "=", "None", ")", ":", "file_", "=", "File", "(", "filePath", ")", "if", "inputEncoding", "is", "None", ":", "inputEncoding", "=", "file_", "."...
Fetch a given filePath and parse its contents. May raise the following exceptions: * RuntimeError - generic exception telling that parsing was unsuccessfull * IOError - failed to open a file at given filePath @return SubtitleData filled with non-empty, default datafields. Client should...
[ "Fetch", "a", "given", "filePath", "and", "parse", "its", "contents", "." ]
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/gui/DataModel.py#L62-L88
train
mkoura/dump2polarion
dump2polarion/properties.py
_set_property
def _set_property(xml_root, name, value, properties=None): """Sets property to specified value.""" if properties is None: properties = xml_root.find("properties") for prop in properties: if prop.get("name") == name: prop.set("value", utils.get_unicode_str(value)) bre...
python
def _set_property(xml_root, name, value, properties=None): """Sets property to specified value.""" if properties is None: properties = xml_root.find("properties") for prop in properties: if prop.get("name") == name: prop.set("value", utils.get_unicode_str(value)) bre...
[ "def", "_set_property", "(", "xml_root", ",", "name", ",", "value", ",", "properties", "=", "None", ")", ":", "if", "properties", "is", "None", ":", "properties", "=", "xml_root", ".", "find", "(", "\"properties\"", ")", "for", "prop", "in", "properties", ...
Sets property to specified value.
[ "Sets", "property", "to", "specified", "value", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/properties.py#L19-L31
train
mkoura/dump2polarion
dump2polarion/properties.py
generate_response_property
def generate_response_property(name=None, value=None): """Generates response property.""" name = name or "dump2polarion" value = value or "".join(random.sample(string.ascii_lowercase, 12)) return (name, value)
python
def generate_response_property(name=None, value=None): """Generates response property.""" name = name or "dump2polarion" value = value or "".join(random.sample(string.ascii_lowercase, 12)) return (name, value)
[ "def", "generate_response_property", "(", "name", "=", "None", ",", "value", "=", "None", ")", ":", "name", "=", "name", "or", "\"dump2polarion\"", "value", "=", "value", "or", "\"\"", ".", "join", "(", "random", ".", "sample", "(", "string", ".", "ascii...
Generates response property.
[ "Generates", "response", "property", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/properties.py#L75-L79
train
mkoura/dump2polarion
dump2polarion/properties.py
fill_response_property
def fill_response_property(xml_root, name=None, value=None): """Returns response property and fills it if missing.""" name, value = generate_response_property(name, value) response_property = None if xml_root.tag == "testsuites": response_property = _fill_testsuites_response_property(xml_root, ...
python
def fill_response_property(xml_root, name=None, value=None): """Returns response property and fills it if missing.""" name, value = generate_response_property(name, value) response_property = None if xml_root.tag == "testsuites": response_property = _fill_testsuites_response_property(xml_root, ...
[ "def", "fill_response_property", "(", "xml_root", ",", "name", "=", "None", ",", "value", "=", "None", ")", ":", "name", ",", "value", "=", "generate_response_property", "(", "name", ",", "value", ")", "response_property", "=", "None", "if", "xml_root", ".",...
Returns response property and fills it if missing.
[ "Returns", "response", "property", "and", "fills", "it", "if", "missing", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/properties.py#L122-L134
train
mkoura/dump2polarion
dump2polarion/properties.py
remove_response_property
def remove_response_property(xml_root): """Removes response properties if exist.""" if xml_root.tag == "testsuites": properties = xml_root.find("properties") resp_properties = [] for prop in properties: prop_name = prop.get("name", "") if "polarion-response-" in p...
python
def remove_response_property(xml_root): """Removes response properties if exist.""" if xml_root.tag == "testsuites": properties = xml_root.find("properties") resp_properties = [] for prop in properties: prop_name = prop.get("name", "") if "polarion-response-" in p...
[ "def", "remove_response_property", "(", "xml_root", ")", ":", "if", "xml_root", ".", "tag", "==", "\"testsuites\"", ":", "properties", "=", "xml_root", ".", "find", "(", "\"properties\"", ")", "resp_properties", "=", "[", "]", "for", "prop", "in", "properties"...
Removes response properties if exist.
[ "Removes", "response", "properties", "if", "exist", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/properties.py#L137-L153
train
mkoura/dump2polarion
dump2polarion/properties.py
remove_property
def remove_property(xml_root, partial_name): """Removes properties if exist.""" if xml_root.tag in ("testsuites", "testcases", "requirements"): properties = xml_root.find("properties") remove_properties = [] for prop in properties: prop_name = prop.get("name", "") ...
python
def remove_property(xml_root, partial_name): """Removes properties if exist.""" if xml_root.tag in ("testsuites", "testcases", "requirements"): properties = xml_root.find("properties") remove_properties = [] for prop in properties: prop_name = prop.get("name", "") ...
[ "def", "remove_property", "(", "xml_root", ",", "partial_name", ")", ":", "if", "xml_root", ".", "tag", "in", "(", "\"testsuites\"", ",", "\"testcases\"", ",", "\"requirements\"", ")", ":", "properties", "=", "xml_root", ".", "find", "(", "\"properties\"", ")"...
Removes properties if exist.
[ "Removes", "properties", "if", "exist", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/properties.py#L156-L168
train
mkoura/dump2polarion
dump2polarion/properties.py
set_lookup_method
def set_lookup_method(xml_root, value): """Changes lookup method.""" if xml_root.tag == "testsuites": _set_property(xml_root, "polarion-lookup-method", value) elif xml_root.tag in ("testcases", "requirements"): _set_property(xml_root, "lookup-method", value) else: raise Dump2Pola...
python
def set_lookup_method(xml_root, value): """Changes lookup method.""" if xml_root.tag == "testsuites": _set_property(xml_root, "polarion-lookup-method", value) elif xml_root.tag in ("testcases", "requirements"): _set_property(xml_root, "lookup-method", value) else: raise Dump2Pola...
[ "def", "set_lookup_method", "(", "xml_root", ",", "value", ")", ":", "if", "xml_root", ".", "tag", "==", "\"testsuites\"", ":", "_set_property", "(", "xml_root", ",", "\"polarion-lookup-method\"", ",", "value", ")", "elif", "xml_root", ".", "tag", "in", "(", ...
Changes lookup method.
[ "Changes", "lookup", "method", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/properties.py#L171-L178
train
mkoura/dump2polarion
dump2polarion/properties.py
set_dry_run
def set_dry_run(xml_root, value=True): """Sets dry-run so records are not updated, only log file is produced.""" value_str = str(value).lower() assert value_str in ("true", "false") if xml_root.tag == "testsuites": _set_property(xml_root, "polarion-dry-run", value_str) elif xml_root.tag in (...
python
def set_dry_run(xml_root, value=True): """Sets dry-run so records are not updated, only log file is produced.""" value_str = str(value).lower() assert value_str in ("true", "false") if xml_root.tag == "testsuites": _set_property(xml_root, "polarion-dry-run", value_str) elif xml_root.tag in (...
[ "def", "set_dry_run", "(", "xml_root", ",", "value", "=", "True", ")", ":", "value_str", "=", "str", "(", "value", ")", ".", "lower", "(", ")", "assert", "value_str", "in", "(", "\"true\"", ",", "\"false\"", ")", "if", "xml_root", ".", "tag", "==", "...
Sets dry-run so records are not updated, only log file is produced.
[ "Sets", "dry", "-", "run", "so", "records", "are", "not", "updated", "only", "log", "file", "is", "produced", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/properties.py#L181-L190
train
darvid/biome
src/biome/__init__.py
Habitat.get_environ
def get_environ(cls, prefix): """Retrieves environment variables from a namespace. Args: prefix (str): The prefix, without a trailing underscore. Returns: list: A list of environment variable keys and values. """ return ((key[len(prefix) + 1:], value) ...
python
def get_environ(cls, prefix): """Retrieves environment variables from a namespace. Args: prefix (str): The prefix, without a trailing underscore. Returns: list: A list of environment variable keys and values. """ return ((key[len(prefix) + 1:], value) ...
[ "def", "get_environ", "(", "cls", ",", "prefix", ")", ":", "return", "(", "(", "key", "[", "len", "(", "prefix", ")", "+", "1", ":", "]", ",", "value", ")", "for", "key", ",", "value", "in", "os", ".", "environ", ".", "items", "(", ")", "if", ...
Retrieves environment variables from a namespace. Args: prefix (str): The prefix, without a trailing underscore. Returns: list: A list of environment variable keys and values.
[ "Retrieves", "environment", "variables", "from", "a", "namespace", "." ]
e1f1945165df9def31af42e5e13b623e1de97f01
https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/src/biome/__init__.py#L63-L75
train
darvid/biome
src/biome/__init__.py
Habitat.get_bool
def get_bool(self, name, default=None): """Retrieves an environment variable value as ``bool``. Integer values are converted as expected: zero evaluates to ``False``, and non-zero to ``True``. String values of ``'true'`` and ``'false'`` are evaluated case insensitive. Args: ...
python
def get_bool(self, name, default=None): """Retrieves an environment variable value as ``bool``. Integer values are converted as expected: zero evaluates to ``False``, and non-zero to ``True``. String values of ``'true'`` and ``'false'`` are evaluated case insensitive. Args: ...
[ "def", "get_bool", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "if", "name", "not", "in", "self", ":", "if", "default", "is", "not", "None", ":", "return", "default", "raise", "EnvironmentError", ".", "not_found", "(", "self", ".",...
Retrieves an environment variable value as ``bool``. Integer values are converted as expected: zero evaluates to ``False``, and non-zero to ``True``. String values of ``'true'`` and ``'false'`` are evaluated case insensitive. Args: name (str): The case-insensitive, unprefix...
[ "Retrieves", "an", "environment", "variable", "value", "as", "bool", "." ]
e1f1945165df9def31af42e5e13b623e1de97f01
https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/src/biome/__init__.py#L102-L128
train
darvid/biome
src/biome/__init__.py
Habitat.get_dict
def get_dict(self, name, default=None): """Retrieves an environment variable value as a dictionary. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be returned instead of throwing ``EnvironmentError``. ...
python
def get_dict(self, name, default=None): """Retrieves an environment variable value as a dictionary. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be returned instead of throwing ``EnvironmentError``. ...
[ "def", "get_dict", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "if", "name", "not", "in", "self", ":", "if", "default", "is", "not", "None", ":", "return", "default", "raise", "EnvironmentError", ".", "not_found", "(", "self", ".",...
Retrieves an environment variable value as a dictionary. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be returned instead of throwing ``EnvironmentError``. Returns: dict: The environment...
[ "Retrieves", "an", "environment", "variable", "value", "as", "a", "dictionary", "." ]
e1f1945165df9def31af42e5e13b623e1de97f01
https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/src/biome/__init__.py#L130-L150
train
darvid/biome
src/biome/__init__.py
Habitat.get_int
def get_int(self, name, default=None): """Retrieves an environment variable as an integer. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be returned instead of throwing ``EnvironmentError``. ...
python
def get_int(self, name, default=None): """Retrieves an environment variable as an integer. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be returned instead of throwing ``EnvironmentError``. ...
[ "def", "get_int", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "if", "name", "not", "in", "self", ":", "if", "default", "is", "not", "None", ":", "return", "default", "raise", "EnvironmentError", ".", "not_found", "(", "self", ".", ...
Retrieves an environment variable as an integer. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be returned instead of throwing ``EnvironmentError``. Returns: int: The environment variable...
[ "Retrieves", "an", "environment", "variable", "as", "an", "integer", "." ]
e1f1945165df9def31af42e5e13b623e1de97f01
https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/src/biome/__init__.py#L152-L174
train
darvid/biome
src/biome/__init__.py
Habitat.get_list
def get_list(self, name, default=None): """Retrieves an environment variable as a list. Note that while implicit access of environment variables containing tuples will return tuples, using this method will coerce tuples to lists. Args: name (str): The case-insensiti...
python
def get_list(self, name, default=None): """Retrieves an environment variable as a list. Note that while implicit access of environment variables containing tuples will return tuples, using this method will coerce tuples to lists. Args: name (str): The case-insensiti...
[ "def", "get_list", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "if", "name", "not", "in", "self", ":", "if", "default", "is", "not", "None", ":", "return", "default", "raise", "EnvironmentError", ".", "not_found", "(", "self", ".",...
Retrieves an environment variable as a list. Note that while implicit access of environment variables containing tuples will return tuples, using this method will coerce tuples to lists. Args: name (str): The case-insensitive, unprefixed variable name. default: ...
[ "Retrieves", "an", "environment", "variable", "as", "a", "list", "." ]
e1f1945165df9def31af42e5e13b623e1de97f01
https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/src/biome/__init__.py#L176-L202
train
darvid/biome
src/biome/__init__.py
Habitat.get_path
def get_path(self, name, default=None): """Retrieves an environment variable as a filesystem path. Requires the `pathlib`_ library if using Python <= 3.4. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be ret...
python
def get_path(self, name, default=None): """Retrieves an environment variable as a filesystem path. Requires the `pathlib`_ library if using Python <= 3.4. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be ret...
[ "def", "get_path", "(", "self", ",", "name", ",", "default", "=", "None", ")", ":", "if", "name", "not", "in", "self", ":", "if", "default", "is", "not", "None", ":", "return", "default", "raise", "EnvironmentError", ".", "not_found", "(", "self", ".",...
Retrieves an environment variable as a filesystem path. Requires the `pathlib`_ library if using Python <= 3.4. Args: name (str): The case-insensitive, unprefixed variable name. default: If provided, a default value will be returned instead of throwing ``Environ...
[ "Retrieves", "an", "environment", "variable", "as", "a", "filesystem", "path", "." ]
e1f1945165df9def31af42e5e13b623e1de97f01
https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/src/biome/__init__.py#L204-L230
train
darvid/biome
src/biome/__init__.py
Habitat.refresh
def refresh(self): """Update all environment variables from ``os.environ``. Use if ``os.environ`` was modified dynamically *after* you accessed an environment namespace with ``biome``. """ super(Habitat, self).update(self.get_environ(self._prefix))
python
def refresh(self): """Update all environment variables from ``os.environ``. Use if ``os.environ`` was modified dynamically *after* you accessed an environment namespace with ``biome``. """ super(Habitat, self).update(self.get_environ(self._prefix))
[ "def", "refresh", "(", "self", ")", ":", "super", "(", "Habitat", ",", "self", ")", ".", "update", "(", "self", ".", "get_environ", "(", "self", ".", "_prefix", ")", ")" ]
Update all environment variables from ``os.environ``. Use if ``os.environ`` was modified dynamically *after* you accessed an environment namespace with ``biome``.
[ "Update", "all", "environment", "variables", "from", "os", ".", "environ", "." ]
e1f1945165df9def31af42e5e13b623e1de97f01
https://github.com/darvid/biome/blob/e1f1945165df9def31af42e5e13b623e1de97f01/src/biome/__init__.py#L232-L239
train
mkoura/dump2polarion
dump2polarion/exporters/xunit_exporter.py
XunitExport._transform_result
def _transform_result(self, result): """Calls transform function on result.""" if self._transform_func: result = self._transform_func(result) return result or None
python
def _transform_result(self, result): """Calls transform function on result.""" if self._transform_func: result = self._transform_func(result) return result or None
[ "def", "_transform_result", "(", "self", ",", "result", ")", ":", "if", "self", ".", "_transform_func", ":", "result", "=", "self", ".", "_transform_func", "(", "result", ")", "return", "result", "or", "None" ]
Calls transform function on result.
[ "Calls", "transform", "function", "on", "result", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/xunit_exporter.py#L144-L148
train
mkoura/dump2polarion
dump2polarion/exporters/xunit_exporter.py
XunitExport._get_verdict
def _get_verdict(result): """Gets verdict of the testcase.""" verdict = result.get("verdict") if not verdict: return None verdict = verdict.strip().lower() if verdict not in Verdicts.PASS + Verdicts.FAIL + Verdicts.SKIP + Verdicts.WAIT: return None ...
python
def _get_verdict(result): """Gets verdict of the testcase.""" verdict = result.get("verdict") if not verdict: return None verdict = verdict.strip().lower() if verdict not in Verdicts.PASS + Verdicts.FAIL + Verdicts.SKIP + Verdicts.WAIT: return None ...
[ "def", "_get_verdict", "(", "result", ")", ":", "verdict", "=", "result", ".", "get", "(", "\"verdict\"", ")", "if", "not", "verdict", ":", "return", "None", "verdict", "=", "verdict", ".", "strip", "(", ")", ".", "lower", "(", ")", "if", "verdict", ...
Gets verdict of the testcase.
[ "Gets", "verdict", "of", "the", "testcase", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/xunit_exporter.py#L151-L159
train
mkoura/dump2polarion
dump2polarion/exporters/xunit_exporter.py
XunitExport._set_lookup_prop
def _set_lookup_prop(self, result_data): """Set lookup property based on processed testcases if not configured.""" if self._lookup_prop: return if result_data.get("id"): self._lookup_prop = "id" elif result_data.get("title"): self._lookup_prop = "name...
python
def _set_lookup_prop(self, result_data): """Set lookup property based on processed testcases if not configured.""" if self._lookup_prop: return if result_data.get("id"): self._lookup_prop = "id" elif result_data.get("title"): self._lookup_prop = "name...
[ "def", "_set_lookup_prop", "(", "self", ",", "result_data", ")", ":", "if", "self", ".", "_lookup_prop", ":", "return", "if", "result_data", ".", "get", "(", "\"id\"", ")", ":", "self", ".", "_lookup_prop", "=", "\"id\"", "elif", "result_data", ".", "get",...
Set lookup property based on processed testcases if not configured.
[ "Set", "lookup", "property", "based", "on", "processed", "testcases", "if", "not", "configured", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/xunit_exporter.py#L161-L173
train
mkoura/dump2polarion
dump2polarion/exporters/xunit_exporter.py
XunitExport._fill_out_err
def _fill_out_err(result, testcase): """Adds stdout and stderr if present.""" if result.get("stdout"): system_out = etree.SubElement(testcase, "system-out") system_out.text = utils.get_unicode_str(result["stdout"]) if result.get("stderr"): system_err = etree....
python
def _fill_out_err(result, testcase): """Adds stdout and stderr if present.""" if result.get("stdout"): system_out = etree.SubElement(testcase, "system-out") system_out.text = utils.get_unicode_str(result["stdout"]) if result.get("stderr"): system_err = etree....
[ "def", "_fill_out_err", "(", "result", ",", "testcase", ")", ":", "if", "result", ".", "get", "(", "\"stdout\"", ")", ":", "system_out", "=", "etree", ".", "SubElement", "(", "testcase", ",", "\"system-out\"", ")", "system_out", ".", "text", "=", "utils", ...
Adds stdout and stderr if present.
[ "Adds", "stdout", "and", "stderr", "if", "present", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/xunit_exporter.py#L199-L207
train
mkoura/dump2polarion
dump2polarion/exporters/xunit_exporter.py
XunitExport._fill_properties
def _fill_properties(verdict, result, testcase, testcase_id, testcase_title): """Adds properties into testcase element.""" properties = etree.SubElement(testcase, "properties") etree.SubElement( properties, "property", {"name": "polarion-testcase-id", "value":...
python
def _fill_properties(verdict, result, testcase, testcase_id, testcase_title): """Adds properties into testcase element.""" properties = etree.SubElement(testcase, "properties") etree.SubElement( properties, "property", {"name": "polarion-testcase-id", "value":...
[ "def", "_fill_properties", "(", "verdict", ",", "result", ",", "testcase", ",", "testcase_id", ",", "testcase_title", ")", ":", "properties", "=", "etree", ".", "SubElement", "(", "testcase", ",", "\"properties\"", ")", "etree", ".", "SubElement", "(", "proper...
Adds properties into testcase element.
[ "Adds", "properties", "into", "testcase", "element", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/xunit_exporter.py#L210-L236
train
mkoura/dump2polarion
dump2polarion/exporters/xunit_exporter.py
XunitExport.export
def export(self): """Returns XUnit XML.""" top = self._top_element() properties = self._properties_element(top) testsuite = self._testsuite_element(top) self._fill_tests_results(testsuite) self._fill_lookup_prop(properties) return utils.prettify_xml(top)
python
def export(self): """Returns XUnit XML.""" top = self._top_element() properties = self._properties_element(top) testsuite = self._testsuite_element(top) self._fill_tests_results(testsuite) self._fill_lookup_prop(properties) return utils.prettify_xml(top)
[ "def", "export", "(", "self", ")", ":", "top", "=", "self", ".", "_top_element", "(", ")", "properties", "=", "self", ".", "_properties_element", "(", "top", ")", "testsuite", "=", "self", ".", "_testsuite_element", "(", "top", ")", "self", ".", "_fill_t...
Returns XUnit XML.
[ "Returns", "XUnit", "XML", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/exporters/xunit_exporter.py#L290-L297
train
mkoura/dump2polarion
dump2polarion/parselogs.py
parse
def parse(log_file): """Parse log file.""" with io.open(os.path.expanduser(log_file), encoding="utf-8") as input_file: for line in input_file: if "Starting import of XUnit results" in line: obj = XUnitParser break elif "Starting import of test case...
python
def parse(log_file): """Parse log file.""" with io.open(os.path.expanduser(log_file), encoding="utf-8") as input_file: for line in input_file: if "Starting import of XUnit results" in line: obj = XUnitParser break elif "Starting import of test case...
[ "def", "parse", "(", "log_file", ")", ":", "with", "io", ".", "open", "(", "os", ".", "path", ".", "expanduser", "(", "log_file", ")", ",", "encoding", "=", "\"utf-8\"", ")", "as", "input_file", ":", "for", "line", "in", "input_file", ":", "if", "\"S...
Parse log file.
[ "Parse", "log", "file", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/parselogs.py#L246-L264
train
mkoura/dump2polarion
dump2polarion/parselogs.py
XUnitParser.get_result
def get_result(self, line): """Gets work item name and id.""" res = self.RESULT_SEARCH.search(line) try: name, ids = res.group(1), res.group(2) except (AttributeError, IndexError): return None ids = ids.split("/") tc_id = ids[0] try: ...
python
def get_result(self, line): """Gets work item name and id.""" res = self.RESULT_SEARCH.search(line) try: name, ids = res.group(1), res.group(2) except (AttributeError, IndexError): return None ids = ids.split("/") tc_id = ids[0] try: ...
[ "def", "get_result", "(", "self", ",", "line", ")", ":", "res", "=", "self", ".", "RESULT_SEARCH", ".", "search", "(", "line", ")", "try", ":", "name", ",", "ids", "=", "res", ".", "group", "(", "1", ")", ",", "res", ".", "group", "(", "2", ")"...
Gets work item name and id.
[ "Gets", "work", "item", "name", "and", "id", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/parselogs.py#L63-L77
train
mkoura/dump2polarion
dump2polarion/parselogs.py
XUnitParser.get_result_warn
def get_result_warn(self, line): """Gets work item name of item that was not successfully imported.""" res = self.RESULT_WARN_SEARCH.search(line) try: return LogItem(res.group(1), None, None) except (AttributeError, IndexError): pass # try again with cust...
python
def get_result_warn(self, line): """Gets work item name of item that was not successfully imported.""" res = self.RESULT_WARN_SEARCH.search(line) try: return LogItem(res.group(1), None, None) except (AttributeError, IndexError): pass # try again with cust...
[ "def", "get_result_warn", "(", "self", ",", "line", ")", ":", "res", "=", "self", ".", "RESULT_WARN_SEARCH", ".", "search", "(", "line", ")", "try", ":", "return", "LogItem", "(", "res", ".", "group", "(", "1", ")", ",", "None", ",", "None", ")", "...
Gets work item name of item that was not successfully imported.
[ "Gets", "work", "item", "name", "of", "item", "that", "was", "not", "successfully", "imported", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/parselogs.py#L79-L92
train
mkoura/dump2polarion
dump2polarion/parselogs.py
RequirementsParser.get_requirement
def get_requirement(self, line): """Gets requirement name and id.""" res = self.REQ_SEARCH.search(line) try: name, tc_id = res.group(1), res.group(2) except (AttributeError, IndexError): return None return LogItem(name, tc_id, None)
python
def get_requirement(self, line): """Gets requirement name and id.""" res = self.REQ_SEARCH.search(line) try: name, tc_id = res.group(1), res.group(2) except (AttributeError, IndexError): return None return LogItem(name, tc_id, None)
[ "def", "get_requirement", "(", "self", ",", "line", ")", ":", "res", "=", "self", ".", "REQ_SEARCH", ".", "search", "(", "line", ")", "try", ":", "name", ",", "tc_id", "=", "res", ".", "group", "(", "1", ")", ",", "res", ".", "group", "(", "2", ...
Gets requirement name and id.
[ "Gets", "requirement", "name", "and", "id", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/parselogs.py#L198-L206
train
mkoura/dump2polarion
dump2polarion/parselogs.py
RequirementsParser.get_requirement_warn
def get_requirement_warn(self, line): """Gets name of test case that was not successfully imported.""" res = self.REQ_WARN_SEARCH.search(line) try: return LogItem(res.group(1), None, None) except (AttributeError, IndexError): return None
python
def get_requirement_warn(self, line): """Gets name of test case that was not successfully imported.""" res = self.REQ_WARN_SEARCH.search(line) try: return LogItem(res.group(1), None, None) except (AttributeError, IndexError): return None
[ "def", "get_requirement_warn", "(", "self", ",", "line", ")", ":", "res", "=", "self", ".", "REQ_WARN_SEARCH", ".", "search", "(", "line", ")", "try", ":", "return", "LogItem", "(", "res", ".", "group", "(", "1", ")", ",", "None", ",", "None", ")", ...
Gets name of test case that was not successfully imported.
[ "Gets", "name", "of", "test", "case", "that", "was", "not", "successfully", "imported", "." ]
f4bd24e9d5070e282aad15f1e8bb514c0525cd37
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/parselogs.py#L208-L214
train
djaodjin/djaodjin-deployutils
deployutils/configs.py
load_config
def load_config(app_name, *args, **kwargs): """ Given a path to a file, parse its lines in ini-like format, and then set them in the current namespace. Quiet by default. Set verbose to True to see the absolute path to the config files printed on stderr. """ configure_logging() # compat...
python
def load_config(app_name, *args, **kwargs): """ Given a path to a file, parse its lines in ini-like format, and then set them in the current namespace. Quiet by default. Set verbose to True to see the absolute path to the config files printed on stderr. """ configure_logging() # compat...
[ "def", "load_config", "(", "app_name", ",", "*", "args", ",", "**", "kwargs", ")", ":", "configure_logging", "(", ")", "prefix", "=", "kwargs", ".", "get", "(", "'prefix'", ",", "'etc'", ")", "verbose", "=", "kwargs", ".", "get", "(", "'verbose'", ",",...
Given a path to a file, parse its lines in ini-like format, and then set them in the current namespace. Quiet by default. Set verbose to True to see the absolute path to the config files printed on stderr.
[ "Given", "a", "path", "to", "a", "file", "parse", "its", "lines", "in", "ini", "-", "like", "format", "and", "then", "set", "them", "in", "the", "current", "namespace", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/configs.py#L82-L166
train
skioo/django-customer-billing
billing/actions/accounts.py
close
def close(account_id: str) -> None: """ Closes the account. :param account_id: the account to close :return: Nothing """ logger.info('closing-account', account_id=account_id) with transaction.atomic(): account = Account.objects.get(pk=account_id) account.close() acco...
python
def close(account_id: str) -> None: """ Closes the account. :param account_id: the account to close :return: Nothing """ logger.info('closing-account', account_id=account_id) with transaction.atomic(): account = Account.objects.get(pk=account_id) account.close() acco...
[ "def", "close", "(", "account_id", ":", "str", ")", "->", "None", ":", "logger", ".", "info", "(", "'closing-account'", ",", "account_id", "=", "account_id", ")", "with", "transaction", ".", "atomic", "(", ")", ":", "account", "=", "Account", ".", "objec...
Closes the account. :param account_id: the account to close :return: Nothing
[ "Closes", "the", "account", "." ]
6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d
https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/actions/accounts.py#L22-L33
train
skioo/django-customer-billing
billing/actions/accounts.py
create_invoices
def create_invoices(account_id: str, due_date: date) -> Sequence[Invoice]: """ Creates the invoices for any due positive charges in the account. If there are due positive charges in different currencies, one invoice is created for each currency. :param account_id: The account to invoice. :param due...
python
def create_invoices(account_id: str, due_date: date) -> Sequence[Invoice]: """ Creates the invoices for any due positive charges in the account. If there are due positive charges in different currencies, one invoice is created for each currency. :param account_id: The account to invoice. :param due...
[ "def", "create_invoices", "(", "account_id", ":", "str", ",", "due_date", ":", "date", ")", "->", "Sequence", "[", "Invoice", "]", ":", "invoices", "=", "[", "]", "with", "transaction", ".", "atomic", "(", ")", ":", "due_charges", "=", "Charge", ".", "...
Creates the invoices for any due positive charges in the account. If there are due positive charges in different currencies, one invoice is created for each currency. :param account_id: The account to invoice. :param due_date: The due date for any invoice that gets created. :return: A possibly-empty li...
[ "Creates", "the", "invoices", "for", "any", "due", "positive", "charges", "in", "the", "account", ".", "If", "there", "are", "due", "positive", "charges", "in", "different", "currencies", "one", "invoice", "is", "created", "for", "each", "currency", "." ]
6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d
https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/actions/accounts.py#L50-L77
train
skioo/django-customer-billing
billing/actions/accounts.py
add_charge
def add_charge(account_id: str, amount: Money, reverses_id: Optional[str] = None, product_code: Optional[str] = None, product_properties: Optional[Dict[str, str]] = None) -> Charge: """ Add a charge to the account. :param account_id: The account o...
python
def add_charge(account_id: str, amount: Money, reverses_id: Optional[str] = None, product_code: Optional[str] = None, product_properties: Optional[Dict[str, str]] = None) -> Charge: """ Add a charge to the account. :param account_id: The account o...
[ "def", "add_charge", "(", "account_id", ":", "str", ",", "amount", ":", "Money", ",", "reverses_id", ":", "Optional", "[", "str", "]", "=", "None", ",", "product_code", ":", "Optional", "[", "str", "]", "=", "None", ",", "product_properties", ":", "Optio...
Add a charge to the account. :param account_id: The account on which to add the charge :param amount: The amount of the charge :param reverses_id: Set this if this charge reverses another one :param product_code: A code identifying the type of product cnarged :param product_properties: A dict of h...
[ "Add", "a", "charge", "to", "the", "account", "." ]
6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d
https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/actions/accounts.py#L80-L114
train
Genida/dependenpy
src/dependenpy/dsm.py
DSM.build_tree
def build_tree(self): """Build the Python packages tree.""" for spec in self.specs: if spec.ismodule: self.modules.append(Module(spec.name, spec.path, dsm=self)) else: self.packages.append(Package( spec.name, spec.path, ...
python
def build_tree(self): """Build the Python packages tree.""" for spec in self.specs: if spec.ismodule: self.modules.append(Module(spec.name, spec.path, dsm=self)) else: self.packages.append(Package( spec.name, spec.path, ...
[ "def", "build_tree", "(", "self", ")", ":", "for", "spec", "in", "self", ".", "specs", ":", "if", "spec", ".", "ismodule", ":", "self", ".", "modules", ".", "append", "(", "Module", "(", "spec", ".", "name", ",", "spec", ".", "path", ",", "dsm", ...
Build the Python packages tree.
[ "Build", "the", "Python", "packages", "tree", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/dsm.py#L86-L97
train
Genida/dependenpy
src/dependenpy/dsm.py
Package.split_limits_heads
def split_limits_heads(self): """ Return first parts of dot-separated strings, and rest of strings. Returns: (list of str, list of str): the heads and rest of the strings. """ heads = [] new_limit_to = [] for limit in self.limit_to: if '.'...
python
def split_limits_heads(self): """ Return first parts of dot-separated strings, and rest of strings. Returns: (list of str, list of str): the heads and rest of the strings. """ heads = [] new_limit_to = [] for limit in self.limit_to: if '.'...
[ "def", "split_limits_heads", "(", "self", ")", ":", "heads", "=", "[", "]", "new_limit_to", "=", "[", "]", "for", "limit", "in", "self", ".", "limit_to", ":", "if", "'.'", "in", "limit", ":", "name", ",", "limit", "=", "limit", ".", "split", "(", "...
Return first parts of dot-separated strings, and rest of strings. Returns: (list of str, list of str): the heads and rest of the strings.
[ "Return", "first", "parts", "of", "dot", "-", "separated", "strings", "and", "rest", "of", "strings", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/dsm.py#L171-L187
train
Genida/dependenpy
src/dependenpy/dsm.py
Package.build_tree
def build_tree(self): """Build the tree for this package.""" for m in listdir(self.path): abs_m = join(self.path, m) if isfile(abs_m) and m.endswith('.py'): name = splitext(m)[0] if not self.limit_to or name in self.limit_to: se...
python
def build_tree(self): """Build the tree for this package.""" for m in listdir(self.path): abs_m = join(self.path, m) if isfile(abs_m) and m.endswith('.py'): name = splitext(m)[0] if not self.limit_to or name in self.limit_to: se...
[ "def", "build_tree", "(", "self", ")", ":", "for", "m", "in", "listdir", "(", "self", ".", "path", ")", ":", "abs_m", "=", "join", "(", "self", ".", "path", ",", "m", ")", "if", "isfile", "(", "abs_m", ")", "and", "m", ".", "endswith", "(", "'....
Build the tree for this package.
[ "Build", "the", "tree", "for", "this", "package", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/dsm.py#L189-L205
train
Genida/dependenpy
src/dependenpy/dsm.py
Package.cardinal
def cardinal(self, to): """ Return the number of dependencies of this package to the given node. Args: to (Package/Module): target node. Returns: int: number of dependencies. """ return sum(m.cardinal(to) for m in self.submodules)
python
def cardinal(self, to): """ Return the number of dependencies of this package to the given node. Args: to (Package/Module): target node. Returns: int: number of dependencies. """ return sum(m.cardinal(to) for m in self.submodules)
[ "def", "cardinal", "(", "self", ",", "to", ")", ":", "return", "sum", "(", "m", ".", "cardinal", "(", "to", ")", "for", "m", "in", "self", ".", "submodules", ")" ]
Return the number of dependencies of this package to the given node. Args: to (Package/Module): target node. Returns: int: number of dependencies.
[ "Return", "the", "number", "of", "dependencies", "of", "this", "package", "to", "the", "given", "node", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/dsm.py#L207-L217
train
Genida/dependenpy
src/dependenpy/dsm.py
Module.build_dependencies
def build_dependencies(self): """ Build the dependencies for this module. Parse the code with ast, find all the import statements, convert them into Dependency objects. """ highest = self.dsm or self.root if self is highest: highest = LeafNode() ...
python
def build_dependencies(self): """ Build the dependencies for this module. Parse the code with ast, find all the import statements, convert them into Dependency objects. """ highest = self.dsm or self.root if self is highest: highest = LeafNode() ...
[ "def", "build_dependencies", "(", "self", ")", ":", "highest", "=", "self", ".", "dsm", "or", "self", ".", "root", "if", "self", "is", "highest", ":", "highest", "=", "LeafNode", "(", ")", "for", "_import", "in", "self", ".", "parse_code", "(", ")", ...
Build the dependencies for this module. Parse the code with ast, find all the import statements, convert them into Dependency objects.
[ "Build", "the", "dependencies", "for", "this", "module", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/dsm.py#L319-L336
train
Genida/dependenpy
src/dependenpy/dsm.py
Module.parse_code
def parse_code(self): """ Read the source code and return all the import statements. Returns: list of dict: the import statements. """ code = open(self.path, encoding='utf-8').read() try: body = ast.parse(code).body except SyntaxError: ...
python
def parse_code(self): """ Read the source code and return all the import statements. Returns: list of dict: the import statements. """ code = open(self.path, encoding='utf-8').read() try: body = ast.parse(code).body except SyntaxError: ...
[ "def", "parse_code", "(", "self", ")", ":", "code", "=", "open", "(", "self", ".", "path", ",", "encoding", "=", "'utf-8'", ")", ".", "read", "(", ")", "try", ":", "body", "=", "ast", ".", "parse", "(", "code", ")", ".", "body", "except", "Syntax...
Read the source code and return all the import statements. Returns: list of dict: the import statements.
[ "Read", "the", "source", "code", "and", "return", "all", "the", "import", "statements", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/dsm.py#L338-L354
train
Genida/dependenpy
src/dependenpy/dsm.py
Module.cardinal
def cardinal(self, to): """ Return the number of dependencies of this module to the given node. Args: to (Package/Module): the target node. Returns: int: number of dependencies. """ return sum(1 for _ in filter( lambda d: not d.extern...
python
def cardinal(self, to): """ Return the number of dependencies of this module to the given node. Args: to (Package/Module): the target node. Returns: int: number of dependencies. """ return sum(1 for _ in filter( lambda d: not d.extern...
[ "def", "cardinal", "(", "self", ",", "to", ")", ":", "return", "sum", "(", "1", "for", "_", "in", "filter", "(", "lambda", "d", ":", "not", "d", ".", "external", "and", "d", ".", "target", "in", "to", ",", "self", ".", "dependencies", ")", ")" ]
Return the number of dependencies of this module to the given node. Args: to (Package/Module): the target node. Returns: int: number of dependencies.
[ "Return", "the", "number", "of", "dependencies", "of", "this", "module", "to", "the", "given", "node", "." ]
df099c17cbe735c990eca9197e39cfc5eb8a4c8e
https://github.com/Genida/dependenpy/blob/df099c17cbe735c990eca9197e39cfc5eb8a4c8e/src/dependenpy/dsm.py#L386-L397
train
romanorac/discomll
discomll/dataset.py
Data.generate_urls
def generate_urls(self, first_url, last_url): """ Function generates URLs in split command fashion. If first_url is xaaaaa and last_url is xaaaac, it will automatically generate xaaaab. """ first_url = first_url.split("/") last_url = last_url.split("/") if first_url[0].lo...
python
def generate_urls(self, first_url, last_url): """ Function generates URLs in split command fashion. If first_url is xaaaaa and last_url is xaaaac, it will automatically generate xaaaab. """ first_url = first_url.split("/") last_url = last_url.split("/") if first_url[0].lo...
[ "def", "generate_urls", "(", "self", ",", "first_url", ",", "last_url", ")", ":", "first_url", "=", "first_url", ".", "split", "(", "\"/\"", ")", "last_url", "=", "last_url", ".", "split", "(", "\"/\"", ")", "if", "first_url", "[", "0", "]", ".", "lowe...
Function generates URLs in split command fashion. If first_url is xaaaaa and last_url is xaaaac, it will automatically generate xaaaab.
[ "Function", "generates", "URLs", "in", "split", "command", "fashion", ".", "If", "first_url", "is", "xaaaaa", "and", "last_url", "is", "xaaaac", "it", "will", "automatically", "generate", "xaaaab", "." ]
a4703daffb2ba3c9f614bc3dbe45ae55884aea00
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/dataset.py#L160-L194
train
oemof/oemof.db
oemof/db/coastdat.py
fetch_raw_data
def fetch_raw_data(sql, connection, geometry): """ Fetch the coastdat2 from the database, adapt it to the local time zone and create a time index. """ tmp_dc = {} weather_df = pd.DataFrame( connection.execute(sql).fetchall(), columns=[ 'gid', 'geom_point', 'geom_polygon', 'da...
python
def fetch_raw_data(sql, connection, geometry): """ Fetch the coastdat2 from the database, adapt it to the local time zone and create a time index. """ tmp_dc = {} weather_df = pd.DataFrame( connection.execute(sql).fetchall(), columns=[ 'gid', 'geom_point', 'geom_polygon', 'da...
[ "def", "fetch_raw_data", "(", "sql", ",", "connection", ",", "geometry", ")", ":", "tmp_dc", "=", "{", "}", "weather_df", "=", "pd", ".", "DataFrame", "(", "connection", ".", "execute", "(", "sql", ")", ".", "fetchall", "(", ")", ",", "columns", "=", ...
Fetch the coastdat2 from the database, adapt it to the local time zone and create a time index.
[ "Fetch", "the", "coastdat2", "from", "the", "database", "adapt", "it", "to", "the", "local", "time", "zone", "and", "create", "a", "time", "index", "." ]
d51ac50187f03a875bd7ce5991ed4772e8b77b93
https://github.com/oemof/oemof.db/blob/d51ac50187f03a875bd7ce5991ed4772e8b77b93/oemof/db/coastdat.py#L92-L128
train
oemof/oemof.db
oemof/db/coastdat.py
create_single_weather
def create_single_weather(df, rename_dc): """Create an oemof weather object for the given geometry""" my_weather = weather.FeedinWeather() data_height = {} name = None # Create a pandas.DataFrame with the time series of the weather data set weather_df = pd.DataFrame(index=df.time_series.iloc[0]....
python
def create_single_weather(df, rename_dc): """Create an oemof weather object for the given geometry""" my_weather = weather.FeedinWeather() data_height = {} name = None # Create a pandas.DataFrame with the time series of the weather data set weather_df = pd.DataFrame(index=df.time_series.iloc[0]....
[ "def", "create_single_weather", "(", "df", ",", "rename_dc", ")", ":", "my_weather", "=", "weather", ".", "FeedinWeather", "(", ")", "data_height", "=", "{", "}", "name", "=", "None", "weather_df", "=", "pd", ".", "DataFrame", "(", "index", "=", "df", "....
Create an oemof weather object for the given geometry
[ "Create", "an", "oemof", "weather", "object", "for", "the", "given", "geometry" ]
d51ac50187f03a875bd7ce5991ed4772e8b77b93
https://github.com/oemof/oemof.db/blob/d51ac50187f03a875bd7ce5991ed4772e8b77b93/oemof/db/coastdat.py#L131-L150
train
oemof/oemof.db
oemof/db/coastdat.py
create_multi_weather
def create_multi_weather(df, rename_dc): """Create a list of oemof weather objects if the given geometry is a polygon """ weather_list = [] # Create a pandas.DataFrame with the time series of the weather data set # for each data set and append them to a list. for gid in df.gid.unique(): ...
python
def create_multi_weather(df, rename_dc): """Create a list of oemof weather objects if the given geometry is a polygon """ weather_list = [] # Create a pandas.DataFrame with the time series of the weather data set # for each data set and append them to a list. for gid in df.gid.unique(): ...
[ "def", "create_multi_weather", "(", "df", ",", "rename_dc", ")", ":", "weather_list", "=", "[", "]", "for", "gid", "in", "df", ".", "gid", ".", "unique", "(", ")", ":", "gid_df", "=", "df", "[", "df", ".", "gid", "==", "gid", "]", "obj", "=", "cr...
Create a list of oemof weather objects if the given geometry is a polygon
[ "Create", "a", "list", "of", "oemof", "weather", "objects", "if", "the", "given", "geometry", "is", "a", "polygon" ]
d51ac50187f03a875bd7ce5991ed4772e8b77b93
https://github.com/oemof/oemof.db/blob/d51ac50187f03a875bd7ce5991ed4772e8b77b93/oemof/db/coastdat.py#L153-L163
train
romanorac/discomll
discomll/ensemble/core/decision_tree.py
predict
def predict(tree, x, y=[], dist=False): """ Function makes a prediction of one sample with a tree model. If y label is defined it returns node identifier and margin. tree: dictionary - tree model x: numpy array - one sample from the dataset y: string, integer or float - sample label """ # ...
python
def predict(tree, x, y=[], dist=False): """ Function makes a prediction of one sample with a tree model. If y label is defined it returns node identifier and margin. tree: dictionary - tree model x: numpy array - one sample from the dataset y: string, integer or float - sample label """ # ...
[ "def", "predict", "(", "tree", ",", "x", ",", "y", "=", "[", "]", ",", "dist", "=", "False", ")", ":", "node_id", "=", "1", "while", "1", ":", "nodes", "=", "tree", "[", "node_id", "]", "if", "nodes", "[", "0", "]", "[", "5", "]", "==", "\"...
Function makes a prediction of one sample with a tree model. If y label is defined it returns node identifier and margin. tree: dictionary - tree model x: numpy array - one sample from the dataset y: string, integer or float - sample label
[ "Function", "makes", "a", "prediction", "of", "one", "sample", "with", "a", "tree", "model", ".", "If", "y", "label", "is", "defined", "it", "returns", "node", "identifier", "and", "margin", "." ]
a4703daffb2ba3c9f614bc3dbe45ae55884aea00
https://github.com/romanorac/discomll/blob/a4703daffb2ba3c9f614bc3dbe45ae55884aea00/discomll/ensemble/core/decision_tree.py#L142-L193
train
mgoral/subconvert
src/subconvert/gui/SubtitleWindow.py
SubTabWidget.__addTab
def __addTab(self, filePath): """Returns existing tab index. Creates a new one if it isn't opened and returns its index otherwise.""" for i in range(self.tabBar.count()): widget = self.pages.widget(i) if not widget.isStatic and filePath == widget.filePath: ...
python
def __addTab(self, filePath): """Returns existing tab index. Creates a new one if it isn't opened and returns its index otherwise.""" for i in range(self.tabBar.count()): widget = self.pages.widget(i) if not widget.isStatic and filePath == widget.filePath: ...
[ "def", "__addTab", "(", "self", ",", "filePath", ")", ":", "for", "i", "in", "range", "(", "self", ".", "tabBar", ".", "count", "(", ")", ")", ":", "widget", "=", "self", ".", "pages", ".", "widget", "(", "i", ")", "if", "not", "widget", ".", "...
Returns existing tab index. Creates a new one if it isn't opened and returns its index otherwise.
[ "Returns", "existing", "tab", "index", ".", "Creates", "a", "new", "one", "if", "it", "isn", "t", "opened", "and", "returns", "its", "index", "otherwise", "." ]
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/gui/SubtitleWindow.py#L119-L131
train
iLampard/x-utils
xutils/config_utils.py
find_and_parse_config
def find_and_parse_config(config, default_config='default.yaml'): """Finds the service configuration file and parses it. Checks also a directory called default, to check for default configuration values, that will be overwritten by the actual configuration found on given path. """ def load_config(p...
python
def find_and_parse_config(config, default_config='default.yaml'): """Finds the service configuration file and parses it. Checks also a directory called default, to check for default configuration values, that will be overwritten by the actual configuration found on given path. """ def load_config(p...
[ "def", "find_and_parse_config", "(", "config", ",", "default_config", "=", "'default.yaml'", ")", ":", "def", "load_config", "(", "path", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "path", ")", ":", "with", "open", "(", "path", ",", "'r'", ...
Finds the service configuration file and parses it. Checks also a directory called default, to check for default configuration values, that will be overwritten by the actual configuration found on given path.
[ "Finds", "the", "service", "configuration", "file", "and", "parses", "it", ".", "Checks", "also", "a", "directory", "called", "default", "to", "check", "for", "default", "configuration", "values", "that", "will", "be", "overwritten", "by", "the", "actual", "co...
291d92832ee0e0c89bc22e10ecf2f44445e0d300
https://github.com/iLampard/x-utils/blob/291d92832ee0e0c89bc22e10ecf2f44445e0d300/xutils/config_utils.py#L76-L101
train
mgoral/subconvert
src/subconvert/cli/syncparse.py
parse
def parse(s, subs): """Parses a given string and creates a list of SyncPoints.""" if len(subs) == 0: return [] points = [] requests = _tokenize_request(s) if len(requests) == 1 and requests[0].type_ == _Request.Type.OFFSET: return _offset_subtitles(requests[0], subs) return _sy...
python
def parse(s, subs): """Parses a given string and creates a list of SyncPoints.""" if len(subs) == 0: return [] points = [] requests = _tokenize_request(s) if len(requests) == 1 and requests[0].type_ == _Request.Type.OFFSET: return _offset_subtitles(requests[0], subs) return _sy...
[ "def", "parse", "(", "s", ",", "subs", ")", ":", "if", "len", "(", "subs", ")", "==", "0", ":", "return", "[", "]", "points", "=", "[", "]", "requests", "=", "_tokenize_request", "(", "s", ")", "if", "len", "(", "requests", ")", "==", "1", "and...
Parses a given string and creates a list of SyncPoints.
[ "Parses", "a", "given", "string", "and", "creates", "a", "list", "of", "SyncPoints", "." ]
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/cli/syncparse.py#L172-L182
train
djaodjin/djaodjin-deployutils
deployutils/helpers.py
full_name_natural_split
def full_name_natural_split(full_name): """ This function splits a full name into a natural first name, last name and middle initials. """ parts = full_name.strip().split(' ') first_name = "" if parts: first_name = parts.pop(0) if first_name.lower() == "el" and parts: fir...
python
def full_name_natural_split(full_name): """ This function splits a full name into a natural first name, last name and middle initials. """ parts = full_name.strip().split(' ') first_name = "" if parts: first_name = parts.pop(0) if first_name.lower() == "el" and parts: fir...
[ "def", "full_name_natural_split", "(", "full_name", ")", ":", "parts", "=", "full_name", ".", "strip", "(", ")", ".", "split", "(", "' '", ")", "first_name", "=", "\"\"", "if", "parts", ":", "first_name", "=", "parts", ".", "pop", "(", "0", ")", "if", ...
This function splits a full name into a natural first name, last name and middle initials.
[ "This", "function", "splits", "a", "full", "name", "into", "a", "natural", "first", "name", "last", "name", "and", "middle", "initials", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/helpers.py#L45-L66
train
pneff/wsgiservice
wsgiservice/xmlserializer.py
_get_xml_value
def _get_xml_value(value): """Convert an individual value to an XML string. Calls itself recursively for dictionaries and lists. Uses some heuristics to convert the data to XML: - In dictionaries, the keys become the tag name. - In lists the tag name is 'child' with an order-attribute givin...
python
def _get_xml_value(value): """Convert an individual value to an XML string. Calls itself recursively for dictionaries and lists. Uses some heuristics to convert the data to XML: - In dictionaries, the keys become the tag name. - In lists the tag name is 'child' with an order-attribute givin...
[ "def", "_get_xml_value", "(", "value", ")", ":", "retval", "=", "[", "]", "if", "isinstance", "(", "value", ",", "dict", ")", ":", "for", "key", ",", "value", "in", "value", ".", "iteritems", "(", ")", ":", "retval", ".", "append", "(", "'<'", "+",...
Convert an individual value to an XML string. Calls itself recursively for dictionaries and lists. Uses some heuristics to convert the data to XML: - In dictionaries, the keys become the tag name. - In lists the tag name is 'child' with an order-attribute giving the list index. ...
[ "Convert", "an", "individual", "value", "to", "an", "XML", "string", ".", "Calls", "itself", "recursively", "for", "dictionaries", "and", "lists", "." ]
03c064ac2e8c53a1aac9c7b99970f23cf79e20f4
https://github.com/pneff/wsgiservice/blob/03c064ac2e8c53a1aac9c7b99970f23cf79e20f4/wsgiservice/xmlserializer.py#L30-L63
train
djaodjin/djaodjin-deployutils
deployutils/apps/django/management/commands/pullapp.py
fetch_changes
def fetch_changes(repo_path, up_commit='master'): """ Fetch latest changes from stage and touch .timestamp if any python sources have been modified. """ last_up_commit = None prevcwd = os.getcwd() try: gitexe = 'git' os.chdir(repo_path) old_sources_timestamp = sources...
python
def fetch_changes(repo_path, up_commit='master'): """ Fetch latest changes from stage and touch .timestamp if any python sources have been modified. """ last_up_commit = None prevcwd = os.getcwd() try: gitexe = 'git' os.chdir(repo_path) old_sources_timestamp = sources...
[ "def", "fetch_changes", "(", "repo_path", ",", "up_commit", "=", "'master'", ")", ":", "last_up_commit", "=", "None", "prevcwd", "=", "os", ".", "getcwd", "(", ")", "try", ":", "gitexe", "=", "'git'", "os", ".", "chdir", "(", "repo_path", ")", "old_sourc...
Fetch latest changes from stage and touch .timestamp if any python sources have been modified.
[ "Fetch", "latest", "changes", "from", "stage", "and", "touch", ".", "timestamp", "if", "any", "python", "sources", "have", "been", "modified", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/management/commands/pullapp.py#L114-L135
train
djaodjin/djaodjin-deployutils
deployutils/apps/django/management/commands/pullapp.py
migrate_all
def migrate_all(): """ Create schema migrations for all apps specified in INSTALLED_APPS, then run a migrate command. """ if 'south' in settings.INSTALLED_APPS: return _south_migrate_all() from django.core.management.commands import makemigrations, migrate schema_args = [sys.executab...
python
def migrate_all(): """ Create schema migrations for all apps specified in INSTALLED_APPS, then run a migrate command. """ if 'south' in settings.INSTALLED_APPS: return _south_migrate_all() from django.core.management.commands import makemigrations, migrate schema_args = [sys.executab...
[ "def", "migrate_all", "(", ")", ":", "if", "'south'", "in", "settings", ".", "INSTALLED_APPS", ":", "return", "_south_migrate_all", "(", ")", "from", "django", ".", "core", ".", "management", ".", "commands", "import", "makemigrations", ",", "migrate", "schema...
Create schema migrations for all apps specified in INSTALLED_APPS, then run a migrate command.
[ "Create", "schema", "migrations", "for", "all", "apps", "specified", "in", "INSTALLED_APPS", "then", "run", "a", "migrate", "command", "." ]
a0fe3cf3030dbbf09025c69ce75a69b326565dd8
https://github.com/djaodjin/djaodjin-deployutils/blob/a0fe3cf3030dbbf09025c69ce75a69b326565dd8/deployutils/apps/django/management/commands/pullapp.py#L200-L217
train
carta/ldap_tools
src/ldap_tools/key.py
API.add
def add(self, username, user_api, filename=None): """ Add SSH public key to a user's profile. Args: username: Username to attach SSH public key to filename: Filename containing keys to add (optional) Raises: ldap3.core.exceptions.LDAPNoSuchAttributeR...
python
def add(self, username, user_api, filename=None): """ Add SSH public key to a user's profile. Args: username: Username to attach SSH public key to filename: Filename containing keys to add (optional) Raises: ldap3.core.exceptions.LDAPNoSuchAttributeR...
[ "def", "add", "(", "self", ",", "username", ",", "user_api", ",", "filename", "=", "None", ")", ":", "keys", "=", "API", ".", "__get_keys", "(", "filename", ")", "user", "=", "user_api", ".", "find", "(", "username", ")", "[", "0", "]", "distinguishe...
Add SSH public key to a user's profile. Args: username: Username to attach SSH public key to filename: Filename containing keys to add (optional) Raises: ldap3.core.exceptions.LDAPNoSuchAttributeResult: ldapPublicKey isn't attached to objectClass
[ "Add", "SSH", "public", "key", "to", "a", "user", "s", "profile", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/key.py#L22-L51
train
carta/ldap_tools
src/ldap_tools/key.py
API.remove
def remove(self, username, user_api, filename=None, force=False): """Remove specified SSH public key from specified user.""" self.keys = API.__get_keys(filename) self.username = username user = user_api.find(username)[0] if not force: # pragma: no cover self.__confi...
python
def remove(self, username, user_api, filename=None, force=False): """Remove specified SSH public key from specified user.""" self.keys = API.__get_keys(filename) self.username = username user = user_api.find(username)[0] if not force: # pragma: no cover self.__confi...
[ "def", "remove", "(", "self", ",", "username", ",", "user_api", ",", "filename", "=", "None", ",", "force", "=", "False", ")", ":", "self", ".", "keys", "=", "API", ".", "__get_keys", "(", "filename", ")", "self", ".", "username", "=", "username", "u...
Remove specified SSH public key from specified user.
[ "Remove", "specified", "SSH", "public", "key", "from", "specified", "user", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/key.py#L53-L64
train
carta/ldap_tools
src/ldap_tools/key.py
API.get_keys_from_ldap
def get_keys_from_ldap(self, username=None): """ Fetch keys from ldap. Args: username Username associated with keys to fetch (optional) Returns: Array of dictionaries in '{username: [public keys]}' format """ result_dict = {} filter = ['...
python
def get_keys_from_ldap(self, username=None): """ Fetch keys from ldap. Args: username Username associated with keys to fetch (optional) Returns: Array of dictionaries in '{username: [public keys]}' format """ result_dict = {} filter = ['...
[ "def", "get_keys_from_ldap", "(", "self", ",", "username", "=", "None", ")", ":", "result_dict", "=", "{", "}", "filter", "=", "[", "'(sshPublicKey=*)'", "]", "if", "username", "is", "not", "None", ":", "filter", ".", "append", "(", "'(uid={})'", ".", "f...
Fetch keys from ldap. Args: username Username associated with keys to fetch (optional) Returns: Array of dictionaries in '{username: [public keys]}' format
[ "Fetch", "keys", "from", "ldap", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/key.py#L77-L96
train
carta/ldap_tools
src/ldap_tools/key.py
CLI.add
def add(config, username, filename): """Add user's SSH public key to their LDAP entry.""" try: client = Client() client.prepare_connection() user_api = UserApi(client) key_api = API(client) key_api.add(username, user_api, filename) exce...
python
def add(config, username, filename): """Add user's SSH public key to their LDAP entry.""" try: client = Client() client.prepare_connection() user_api = UserApi(client) key_api = API(client) key_api.add(username, user_api, filename) exce...
[ "def", "add", "(", "config", ",", "username", ",", "filename", ")", ":", "try", ":", "client", "=", "Client", "(", ")", "client", ".", "prepare_connection", "(", ")", "user_api", "=", "UserApi", "(", "client", ")", "key_api", "=", "API", "(", "client",...
Add user's SSH public key to their LDAP entry.
[ "Add", "user", "s", "SSH", "public", "key", "to", "their", "LDAP", "entry", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/key.py#L170-L184
train
carta/ldap_tools
src/ldap_tools/key.py
CLI.remove
def remove(config, username, filename, force): """Remove user's SSH public key from their LDAP entry.""" client = Client() client.prepare_connection() user_api = UserApi(client) key_api = API(client) key_api.remove(username, user_api, filename, force)
python
def remove(config, username, filename, force): """Remove user's SSH public key from their LDAP entry.""" client = Client() client.prepare_connection() user_api = UserApi(client) key_api = API(client) key_api.remove(username, user_api, filename, force)
[ "def", "remove", "(", "config", ",", "username", ",", "filename", ",", "force", ")", ":", "client", "=", "Client", "(", ")", "client", ".", "prepare_connection", "(", ")", "user_api", "=", "UserApi", "(", "client", ")", "key_api", "=", "API", "(", "cli...
Remove user's SSH public key from their LDAP entry.
[ "Remove", "user", "s", "SSH", "public", "key", "from", "their", "LDAP", "entry", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/key.py#L195-L201
train
carta/ldap_tools
src/ldap_tools/key.py
CLI.install
def install(config): # pragma: no cover """Install user's SSH public key to the local system.""" client = Client() client.prepare_connection() key_api = API(client) key_api.install()
python
def install(config): # pragma: no cover """Install user's SSH public key to the local system.""" client = Client() client.prepare_connection() key_api = API(client) key_api.install()
[ "def", "install", "(", "config", ")", ":", "client", "=", "Client", "(", ")", "client", ".", "prepare_connection", "(", ")", "key_api", "=", "API", "(", "client", ")", "key_api", ".", "install", "(", ")" ]
Install user's SSH public key to the local system.
[ "Install", "user", "s", "SSH", "public", "key", "to", "the", "local", "system", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/key.py#L205-L210
train
carta/ldap_tools
src/ldap_tools/key.py
CLI.show
def show(config, username): # pragma: no cover """Show a user's SSH public key from their LDAP entry.""" client = Client() client.prepare_connection() key_api = API(client) for key, value in key_api.get_keys_from_ldap(username).items(): print(value)
python
def show(config, username): # pragma: no cover """Show a user's SSH public key from their LDAP entry.""" client = Client() client.prepare_connection() key_api = API(client) for key, value in key_api.get_keys_from_ldap(username).items(): print(value)
[ "def", "show", "(", "config", ",", "username", ")", ":", "client", "=", "Client", "(", ")", "client", ".", "prepare_connection", "(", ")", "key_api", "=", "API", "(", "client", ")", "for", "key", ",", "value", "in", "key_api", ".", "get_keys_from_ldap", ...
Show a user's SSH public key from their LDAP entry.
[ "Show", "a", "user", "s", "SSH", "public", "key", "from", "their", "LDAP", "entry", "." ]
7c039304a5abaf836c7afc35cf068b4471306264
https://github.com/carta/ldap_tools/blob/7c039304a5abaf836c7afc35cf068b4471306264/src/ldap_tools/key.py#L232-L238
train
openearth/mmi-python
mmi/runner_legacy.py
main
def main(): """run mmi runner""" logging.basicConfig() logger.info("mmi-runner") warnings.warn( "You are using the mmi-runner script, please switch to `mmi runner`", DeprecationWarning ) arguments = docopt.docopt(__doc__) kwargs = parse_args(arguments) runner = mmi.runner...
python
def main(): """run mmi runner""" logging.basicConfig() logger.info("mmi-runner") warnings.warn( "You are using the mmi-runner script, please switch to `mmi runner`", DeprecationWarning ) arguments = docopt.docopt(__doc__) kwargs = parse_args(arguments) runner = mmi.runner...
[ "def", "main", "(", ")", ":", "logging", ".", "basicConfig", "(", ")", "logger", ".", "info", "(", "\"mmi-runner\"", ")", "warnings", ".", "warn", "(", "\"You are using the mmi-runner script, please switch to `mmi runner`\"", ",", "DeprecationWarning", ")", "arguments...
run mmi runner
[ "run", "mmi", "runner" ]
a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d
https://github.com/openearth/mmi-python/blob/a2f4ac96b1e7f2fa903f668b3e05c4e86ad42e8d/mmi/runner_legacy.py#L34-L47
train
rgmining/common
setup.py
load_requires_from_file
def load_requires_from_file(filepath): """Read a package list from a given file path. Args: filepath: file path of the package list. Returns: a list of package names. """ with open(filepath) as fp: return [pkg_name.strip() for pkg_name in fp.readlines()]
python
def load_requires_from_file(filepath): """Read a package list from a given file path. Args: filepath: file path of the package list. Returns: a list of package names. """ with open(filepath) as fp: return [pkg_name.strip() for pkg_name in fp.readlines()]
[ "def", "load_requires_from_file", "(", "filepath", ")", ":", "with", "open", "(", "filepath", ")", "as", "fp", ":", "return", "[", "pkg_name", ".", "strip", "(", ")", "for", "pkg_name", "in", "fp", ".", "readlines", "(", ")", "]" ]
Read a package list from a given file path. Args: filepath: file path of the package list. Returns: a list of package names.
[ "Read", "a", "package", "list", "from", "a", "given", "file", "path", "." ]
2462a4d54f32a82eadd7b1e28675b3c8bcd172b2
https://github.com/rgmining/common/blob/2462a4d54f32a82eadd7b1e28675b3c8bcd172b2/setup.py#L34-L44
train
JoMingyu/TourAPI
tourapi/api.py
TourAPI.get_tour_list
def get_tour_list(self): """ Inquire all tour list :rtype: list """ resp = json.loads(urlopen(self.tour_list_url.format(1)).read().decode('utf-8')) total_count = resp['response']['body']['totalCount'] # Get total count resp = json.loads(urlopen(self.tour...
python
def get_tour_list(self): """ Inquire all tour list :rtype: list """ resp = json.loads(urlopen(self.tour_list_url.format(1)).read().decode('utf-8')) total_count = resp['response']['body']['totalCount'] # Get total count resp = json.loads(urlopen(self.tour...
[ "def", "get_tour_list", "(", "self", ")", ":", "resp", "=", "json", ".", "loads", "(", "urlopen", "(", "self", ".", "tour_list_url", ".", "format", "(", "1", ")", ")", ".", "read", "(", ")", ".", "decode", "(", "'utf-8'", ")", ")", "total_count", "...
Inquire all tour list :rtype: list
[ "Inquire", "all", "tour", "list" ]
d4b2a6415e01efaa0ddddd55126e2f4ae9d19d33
https://github.com/JoMingyu/TourAPI/blob/d4b2a6415e01efaa0ddddd55126e2f4ae9d19d33/tourapi/api.py#L61-L103
train
JoMingyu/TourAPI
tourapi/api.py
TourAPI.get_detail_common
def get_detail_common(self, content_id): """ Inquire common detail data :param content_id: Content ID to inquire :type content_id: str :rtype: dict """ resp = json.loads(urlopen(self.detail_common_url.format(str(content_id))).read().decode('utf-8')) data...
python
def get_detail_common(self, content_id): """ Inquire common detail data :param content_id: Content ID to inquire :type content_id: str :rtype: dict """ resp = json.loads(urlopen(self.detail_common_url.format(str(content_id))).read().decode('utf-8')) data...
[ "def", "get_detail_common", "(", "self", ",", "content_id", ")", ":", "resp", "=", "json", ".", "loads", "(", "urlopen", "(", "self", ".", "detail_common_url", ".", "format", "(", "str", "(", "content_id", ")", ")", ")", ".", "read", "(", ")", ".", "...
Inquire common detail data :param content_id: Content ID to inquire :type content_id: str :rtype: dict
[ "Inquire", "common", "detail", "data" ]
d4b2a6415e01efaa0ddddd55126e2f4ae9d19d33
https://github.com/JoMingyu/TourAPI/blob/d4b2a6415e01efaa0ddddd55126e2f4ae9d19d33/tourapi/api.py#L105-L138
train
JoMingyu/TourAPI
tourapi/api.py
TourAPI.get_detail_images
def get_detail_images(self, content_id): """ Inquire detail images :param content_id: Content ID to inquire :type content_id: str :rtype: list """ resp = json.loads(urlopen(self.additional_images_url.format(content_id, 1)).read().decode('utf-8')) total_c...
python
def get_detail_images(self, content_id): """ Inquire detail images :param content_id: Content ID to inquire :type content_id: str :rtype: list """ resp = json.loads(urlopen(self.additional_images_url.format(content_id, 1)).read().decode('utf-8')) total_c...
[ "def", "get_detail_images", "(", "self", ",", "content_id", ")", ":", "resp", "=", "json", ".", "loads", "(", "urlopen", "(", "self", ".", "additional_images_url", ".", "format", "(", "content_id", ",", "1", ")", ")", ".", "read", "(", ")", ".", "decod...
Inquire detail images :param content_id: Content ID to inquire :type content_id: str :rtype: list
[ "Inquire", "detail", "images" ]
d4b2a6415e01efaa0ddddd55126e2f4ae9d19d33
https://github.com/JoMingyu/TourAPI/blob/d4b2a6415e01efaa0ddddd55126e2f4ae9d19d33/tourapi/api.py#L325-L361
train
mgoral/subconvert
src/subconvert/utils/SubFile.py
File._writeFile
def _writeFile(cls, filePath, content, encoding = None): """Safe file writing. Most common mistakes are checked against and reported before write operation. After that, if anything unexpected happens, user won't be left without data or with corrupted one as this method writes to a temporary file...
python
def _writeFile(cls, filePath, content, encoding = None): """Safe file writing. Most common mistakes are checked against and reported before write operation. After that, if anything unexpected happens, user won't be left without data or with corrupted one as this method writes to a temporary file...
[ "def", "_writeFile", "(", "cls", ",", "filePath", ",", "content", ",", "encoding", "=", "None", ")", ":", "filePath", "=", "os", ".", "path", ".", "realpath", "(", "filePath", ")", "log", ".", "debug", "(", "_", "(", "\"Real file path to write: %s\"", "%...
Safe file writing. Most common mistakes are checked against and reported before write operation. After that, if anything unexpected happens, user won't be left without data or with corrupted one as this method writes to a temporary file and then simply renames it (which should be atomic operatio...
[ "Safe", "file", "writing", ".", "Most", "common", "mistakes", "are", "checked", "against", "and", "reported", "before", "write", "operation", ".", "After", "that", "if", "anything", "unexpected", "happens", "user", "won", "t", "be", "left", "without", "data", ...
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/utils/SubFile.py#L117-L159
train
skioo/django-customer-billing
billing/actions/invoices.py
pay_with_account_credit_cards
def pay_with_account_credit_cards(invoice_id) -> Optional[Transaction]: """ Get paid for the invoice, trying the valid credit cards on record for the account. If successful attaches the payment to the invoice and marks the invoice as paid. :param invoice_id: the id of the invoice to pay. :return: ...
python
def pay_with_account_credit_cards(invoice_id) -> Optional[Transaction]: """ Get paid for the invoice, trying the valid credit cards on record for the account. If successful attaches the payment to the invoice and marks the invoice as paid. :param invoice_id: the id of the invoice to pay. :return: ...
[ "def", "pay_with_account_credit_cards", "(", "invoice_id", ")", "->", "Optional", "[", "Transaction", "]", ":", "logger", ".", "debug", "(", "'invoice-payment-started'", ",", "invoice_id", "=", "invoice_id", ")", "with", "transaction", ".", "atomic", "(", ")", "...
Get paid for the invoice, trying the valid credit cards on record for the account. If successful attaches the payment to the invoice and marks the invoice as paid. :param invoice_id: the id of the invoice to pay. :return: A successful transaction, or None if we weren't able to pay the invoice.
[ "Get", "paid", "for", "the", "invoice", "trying", "the", "valid", "credit", "cards", "on", "record", "for", "the", "account", "." ]
6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d
https://github.com/skioo/django-customer-billing/blob/6ac1ed9ef9d1d7eee0379de7f0c4b76919ae1f2d/billing/actions/invoices.py#L16-L77
train
mgoral/subconvert
src/subconvert/gui/ToolBox.py
ToolBox.setContentFor
def setContentFor(self, widget): """Updates toolbox contents with a data corresponding to a given tab.""" for i in range(self.count()): item = self.widget(i) if widget.isStatic: item.setStaticContent(widget) else: item.setContent(widget...
python
def setContentFor(self, widget): """Updates toolbox contents with a data corresponding to a given tab.""" for i in range(self.count()): item = self.widget(i) if widget.isStatic: item.setStaticContent(widget) else: item.setContent(widget...
[ "def", "setContentFor", "(", "self", ",", "widget", ")", ":", "for", "i", "in", "range", "(", "self", ".", "count", "(", ")", ")", ":", "item", "=", "self", ".", "widget", "(", "i", ")", "if", "widget", ".", "isStatic", ":", "item", ".", "setStat...
Updates toolbox contents with a data corresponding to a given tab.
[ "Updates", "toolbox", "contents", "with", "a", "data", "corresponding", "to", "a", "given", "tab", "." ]
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/gui/ToolBox.py#L37-L44
train
mgoral/subconvert
src/subconvert/gui/ToolBox.py
Tool.clear
def clear(self): """Removes all child widgets.""" layout = self.layout() for index in reversed(range(layout.count())): item = layout.takeAt(index) try: item.widget().deleteLater() except AttributeError: item = None
python
def clear(self): """Removes all child widgets.""" layout = self.layout() for index in reversed(range(layout.count())): item = layout.takeAt(index) try: item.widget().deleteLater() except AttributeError: item = None
[ "def", "clear", "(", "self", ")", ":", "layout", "=", "self", ".", "layout", "(", ")", "for", "index", "in", "reversed", "(", "range", "(", "layout", ".", "count", "(", ")", ")", ")", ":", "item", "=", "layout", ".", "takeAt", "(", "index", ")", ...
Removes all child widgets.
[ "Removes", "all", "child", "widgets", "." ]
59701e5e69ef1ca26ce7d1d766c936664aa2cb32
https://github.com/mgoral/subconvert/blob/59701e5e69ef1ca26ce7d1d766c936664aa2cb32/src/subconvert/gui/ToolBox.py#L79-L87
train
stylight/python-fastbill
fastbill/wrapper.py
FastbillWrapper._request
def _request(self, service, **kw): """Do the actual request to Fastbill's API server. If successful returns the RESPONSE section the of response, in case of an error raises a subclass of FastbillError. """ fb_request = { 'service': service, } for key ...
python
def _request(self, service, **kw): """Do the actual request to Fastbill's API server. If successful returns the RESPONSE section the of response, in case of an error raises a subclass of FastbillError. """ fb_request = { 'service': service, } for key ...
[ "def", "_request", "(", "self", ",", "service", ",", "**", "kw", ")", ":", "fb_request", "=", "{", "'service'", ":", "service", ",", "}", "for", "key", "in", "[", "'limit'", ",", "'offset'", ",", "'filter'", ",", "'data'", "]", ":", "fb_request", "["...
Do the actual request to Fastbill's API server. If successful returns the RESPONSE section the of response, in case of an error raises a subclass of FastbillError.
[ "Do", "the", "actual", "request", "to", "Fastbill", "s", "API", "server", "." ]
e0cea5cc931df4a7b64c2f877ff3b9a4cf56e5bc
https://github.com/stylight/python-fastbill/blob/e0cea5cc931df4a7b64c2f877ff3b9a4cf56e5bc/fastbill/wrapper.py#L117-L164
train
PythonOptimizers/cygenja
cygenja/treemap/treemap_node.py
TreeMapNode.set_parent
def set_parent(self, node): """ Attach node to its parent. Args: node: Parent node. Note: ``node`` can be ``None``. In that case, the node is detached from its previous parent. """ self._parent = node if node is None: # deta...
python
def set_parent(self, node): """ Attach node to its parent. Args: node: Parent node. Note: ``node`` can be ``None``. In that case, the node is detached from its previous parent. """ self._parent = node if node is None: # deta...
[ "def", "set_parent", "(", "self", ",", "node", ")", ":", "self", ".", "_parent", "=", "node", "if", "node", "is", "None", ":", "self", ".", "_depth", "=", "0", "else", ":", "self", ".", "_depth", "=", "node", ".", "get_depth", "(", ")", "+", "1" ...
Attach node to its parent. Args: node: Parent node. Note: ``node`` can be ``None``. In that case, the node is detached from its previous parent.
[ "Attach", "node", "to", "its", "parent", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap_node.py#L35-L52
train
PythonOptimizers/cygenja
cygenja/treemap/treemap_node.py
TreeMapNode.generate_child_leaf_nodes
def generate_child_leaf_nodes(self): """ Generate leaf nodes of this node. """ def _yield_child_leaf_nodes(node): """ Args: node: Yields: """ if not node.has_children(): yield node ...
python
def generate_child_leaf_nodes(self): """ Generate leaf nodes of this node. """ def _yield_child_leaf_nodes(node): """ Args: node: Yields: """ if not node.has_children(): yield node ...
[ "def", "generate_child_leaf_nodes", "(", "self", ")", ":", "def", "_yield_child_leaf_nodes", "(", "node", ")", ":", "if", "not", "node", ".", "has_children", "(", ")", ":", "yield", "node", "else", ":", "for", "child_node", "in", "node", ".", "generate_child...
Generate leaf nodes of this node.
[ "Generate", "leaf", "nodes", "of", "this", "node", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap_node.py#L149-L171
train
PythonOptimizers/cygenja
cygenja/treemap/treemap_node.py
TreeMapNode.detach_children
def detach_children(self): """ Erase references to children without deleting them. These children might be used somewhere else, otherwise they will be taken care by ``Python``'s garbage collector. """ for node in self.get_child_nodes(): node.set_parent(None) ...
python
def detach_children(self): """ Erase references to children without deleting them. These children might be used somewhere else, otherwise they will be taken care by ``Python``'s garbage collector. """ for node in self.get_child_nodes(): node.set_parent(None) ...
[ "def", "detach_children", "(", "self", ")", ":", "for", "node", "in", "self", ".", "get_child_nodes", "(", ")", ":", "node", ".", "set_parent", "(", "None", ")", "self", ".", "_nodes", "=", "dict", "(", ")" ]
Erase references to children without deleting them. These children might be used somewhere else, otherwise they will be taken care by ``Python``'s garbage collector.
[ "Erase", "references", "to", "children", "without", "deleting", "them", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/treemap/treemap_node.py#L173-L181
train
ngmarchant/oasis
oasis/experiments.py
process_expt
def process_expt(h5_path, inmemory = True, ignorenan = False): """ Assumes h5 file has table called `F_measure` Parameters ---------- h5_path : string path to HDF file containing the experimental data. The file is expected to have been generated from the `repeat_expt` function. ...
python
def process_expt(h5_path, inmemory = True, ignorenan = False): """ Assumes h5 file has table called `F_measure` Parameters ---------- h5_path : string path to HDF file containing the experimental data. The file is expected to have been generated from the `repeat_expt` function. ...
[ "def", "process_expt", "(", "h5_path", ",", "inmemory", "=", "True", ",", "ignorenan", "=", "False", ")", ":", "logging", ".", "info", "(", "\"Reading file at {}\"", ".", "format", "(", "h5_path", ")", ")", "h5_file", "=", "tables", ".", "open_file", "(", ...
Assumes h5 file has table called `F_measure` Parameters ---------- h5_path : string path to HDF file containing the experimental data. The file is expected to have been generated from the `repeat_expt` function. inmemory : bool whether to process the experiments in memory ...
[ "Assumes", "h5", "file", "has", "table", "called", "F_measure" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/experiments.py#L61-L138
train
ngmarchant/oasis
oasis/experiments.py
Data.calc_confusion_matrix
def calc_confusion_matrix(self, printout = False): """ Calculates number of TP, FP, TN, FN """ if self.labels is None: raise DataError("Cannot calculate confusion matrix before data " "has been read.") if self.preds is None: ra...
python
def calc_confusion_matrix(self, printout = False): """ Calculates number of TP, FP, TN, FN """ if self.labels is None: raise DataError("Cannot calculate confusion matrix before data " "has been read.") if self.preds is None: ra...
[ "def", "calc_confusion_matrix", "(", "self", ",", "printout", "=", "False", ")", ":", "if", "self", ".", "labels", "is", "None", ":", "raise", "DataError", "(", "\"Cannot calculate confusion matrix before data \"", "\"has been read.\"", ")", "if", "self", ".", "pr...
Calculates number of TP, FP, TN, FN
[ "Calculates", "number", "of", "TP", "FP", "TN", "FN" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/experiments.py#L216-L239
train
ngmarchant/oasis
oasis/experiments.py
Data.calc_true_performance
def calc_true_performance(self, printout = False): """ Evaluate precision, recall and balanced F-measure """ try: self.calc_confusion_matrix(printout = False) except DataError as e: print(e.msg) raise if self.TP + self.FP == 0: ...
python
def calc_true_performance(self, printout = False): """ Evaluate precision, recall and balanced F-measure """ try: self.calc_confusion_matrix(printout = False) except DataError as e: print(e.msg) raise if self.TP + self.FP == 0: ...
[ "def", "calc_true_performance", "(", "self", ",", "printout", "=", "False", ")", ":", "try", ":", "self", ".", "calc_confusion_matrix", "(", "printout", "=", "False", ")", "except", "DataError", "as", "e", ":", "print", "(", "e", ".", "msg", ")", "raise"...
Evaluate precision, recall and balanced F-measure
[ "Evaluate", "precision", "recall", "and", "balanced", "F", "-", "measure" ]
28a037a8924b85ae97db8a93960a910a219d6a4a
https://github.com/ngmarchant/oasis/blob/28a037a8924b85ae97db8a93960a910a219d6a4a/oasis/experiments.py#L242-L271
train
praekeltfoundation/seed-message-sender
message_sender/migrations/0020_outboundsendfailure_db_backed_fk_constraint.py
modify_fk_constraint
def modify_fk_constraint(apps, schema_editor): """ Delete's the current foreign key contraint on the outbound field, and adds it again, but this time with an ON DELETE clause """ model = apps.get_model("message_sender", "OutboundSendFailure") table = model._meta.db_table with schema_editor....
python
def modify_fk_constraint(apps, schema_editor): """ Delete's the current foreign key contraint on the outbound field, and adds it again, but this time with an ON DELETE clause """ model = apps.get_model("message_sender", "OutboundSendFailure") table = model._meta.db_table with schema_editor....
[ "def", "modify_fk_constraint", "(", "apps", ",", "schema_editor", ")", ":", "model", "=", "apps", ".", "get_model", "(", "\"message_sender\"", ",", "\"OutboundSendFailure\"", ")", "table", "=", "model", ".", "_meta", ".", "db_table", "with", "schema_editor", "."...
Delete's the current foreign key contraint on the outbound field, and adds it again, but this time with an ON DELETE clause
[ "Delete", "s", "the", "current", "foreign", "key", "contraint", "on", "the", "outbound", "field", "and", "adds", "it", "again", "but", "this", "time", "with", "an", "ON", "DELETE", "clause" ]
257b01635171b9dbe1f5f13baa810c971bb2620e
https://github.com/praekeltfoundation/seed-message-sender/blob/257b01635171b9dbe1f5f13baa810c971bb2620e/message_sender/migrations/0020_outboundsendfailure_db_backed_fk_constraint.py#L10-L47
train
PythonOptimizers/cygenja
cygenja/generator.py
Generator.log_warning
def log_warning(self, msg): """ Log a warning if ``logger`` exists. Args: msg: Warning to log. Warning: Can raise a ``RuntimeError`` if this was asked in the constructor. """ if self.__logger: self.__logger.warning(msg) if s...
python
def log_warning(self, msg): """ Log a warning if ``logger`` exists. Args: msg: Warning to log. Warning: Can raise a ``RuntimeError`` if this was asked in the constructor. """ if self.__logger: self.__logger.warning(msg) if s...
[ "def", "log_warning", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "__logger", ":", "self", ".", "__logger", ".", "warning", "(", "msg", ")", "if", "self", ".", "__raise_exception_on_warning", ":", "raise", "RuntimeError", "(", "msg", ")" ]
Log a warning if ``logger`` exists. Args: msg: Warning to log. Warning: Can raise a ``RuntimeError`` if this was asked in the constructor.
[ "Log", "a", "warning", "if", "logger", "exists", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/generator.py#L133-L148
train
PythonOptimizers/cygenja
cygenja/generator.py
Generator.log_error
def log_error(self, msg): """ Log an error and raise an exception. Args: msg: Error message to log. Raises: RuntimeError: With the message. """ if self.__logger: self.__logger.error(msg) raise RuntimeError(msg)
python
def log_error(self, msg): """ Log an error and raise an exception. Args: msg: Error message to log. Raises: RuntimeError: With the message. """ if self.__logger: self.__logger.error(msg) raise RuntimeError(msg)
[ "def", "log_error", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "__logger", ":", "self", ".", "__logger", ".", "error", "(", "msg", ")", "raise", "RuntimeError", "(", "msg", ")" ]
Log an error and raise an exception. Args: msg: Error message to log. Raises: RuntimeError: With the message.
[ "Log", "an", "error", "and", "raise", "an", "exception", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/generator.py#L150-L163
train
PythonOptimizers/cygenja
cygenja/generator.py
Generator.__add_action
def __add_action(self, relative_directory, action): """ Add action into the dictionary of actions. Args: relative_directory: action: """ generator_action_container = self.__actions.retrieve_element_or_default(relative_directory, None) if generat...
python
def __add_action(self, relative_directory, action): """ Add action into the dictionary of actions. Args: relative_directory: action: """ generator_action_container = self.__actions.retrieve_element_or_default(relative_directory, None) if generat...
[ "def", "__add_action", "(", "self", ",", "relative_directory", ",", "action", ")", ":", "generator_action_container", "=", "self", ".", "__actions", ".", "retrieve_element_or_default", "(", "relative_directory", ",", "None", ")", "if", "generator_action_container", "i...
Add action into the dictionary of actions. Args: relative_directory: action:
[ "Add", "action", "into", "the", "dictionary", "of", "actions", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/generator.py#L285-L301
train
PythonOptimizers/cygenja
cygenja/generator.py
Generator.__is_function_action
def __is_function_action(self, action_function): """ Detect if given function is really an action function. Args: action_function: Function to test. Note: We don't care if the variable refer to a function but rather if it is callable or not. """ ...
python
def __is_function_action(self, action_function): """ Detect if given function is really an action function. Args: action_function: Function to test. Note: We don't care if the variable refer to a function but rather if it is callable or not. """ ...
[ "def", "__is_function_action", "(", "self", ",", "action_function", ")", ":", "is_function_action", "=", "True", "if", "not", "hasattr", "(", "action_function", ",", "'__call__'", ")", ":", "return", "False", "try", ":", "for", "end_string", ",", "context", "i...
Detect if given function is really an action function. Args: action_function: Function to test. Note: We don't care if the variable refer to a function but rather if it is callable or not.
[ "Detect", "if", "given", "function", "is", "really", "an", "action", "function", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/generator.py#L313-L341
train
PythonOptimizers/cygenja
cygenja/generator.py
Generator.register_default_action
def register_default_action(self, file_pattern, action_function): """ Default action used if no compatible action is found. Args: file_pattern: A :program:`fnmatch` pattern for the files concerned by this action. action_function: Warning: Be careful...
python
def register_default_action(self, file_pattern, action_function): """ Default action used if no compatible action is found. Args: file_pattern: A :program:`fnmatch` pattern for the files concerned by this action. action_function: Warning: Be careful...
[ "def", "register_default_action", "(", "self", ",", "file_pattern", ",", "action_function", ")", ":", "if", "self", ".", "__default_action", "is", "not", "None", ":", "self", ".", "log_error", "(", "'Default action function already exist.'", ")", "if", "not", "sel...
Default action used if no compatible action is found. Args: file_pattern: A :program:`fnmatch` pattern for the files concerned by this action. action_function: Warning: Be careful when defining a default action. This action is be applied to **all** template files fo...
[ "Default", "action", "used", "if", "no", "compatible", "action", "is", "found", "." ]
a9ef91cdfa8452beeeec4f050f928b830379f91c
https://github.com/PythonOptimizers/cygenja/blob/a9ef91cdfa8452beeeec4f050f928b830379f91c/cygenja/generator.py#L373-L393
train
ckcollab/polished
polished/backends/simple.py
SimpleBackend.prepare_page
def prepare_page(self, *args, **kwargs): ''' This is called after the page has been loaded, good time to do extra polishing ''' super(BaseBackend, self).prepare_page(*args, **kwargs)
python
def prepare_page(self, *args, **kwargs): ''' This is called after the page has been loaded, good time to do extra polishing ''' super(BaseBackend, self).prepare_page(*args, **kwargs)
[ "def", "prepare_page", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "super", "(", "BaseBackend", ",", "self", ")", ".", "prepare_page", "(", "*", "args", ",", "**", "kwargs", ")" ]
This is called after the page has been loaded, good time to do extra polishing
[ "This", "is", "called", "after", "the", "page", "has", "been", "loaded", "good", "time", "to", "do", "extra", "polishing" ]
5a00b2fbe569bc957d1647c0849fd344db29b644
https://github.com/ckcollab/polished/blob/5a00b2fbe569bc957d1647c0849fd344db29b644/polished/backends/simple.py#L23-L27
train
Jaymon/decorators
decorators.py
Decorator.set_wrapped
def set_wrapped(self, wrapped): """This will decide what wrapped is and set .wrapped_func or .wrapped_class accordingly :param wrapped: either a function or class """ self.wrapped = wrapped functools.update_wrapper(self, self.wrapped, updated=()) self.wrapped_fun...
python
def set_wrapped(self, wrapped): """This will decide what wrapped is and set .wrapped_func or .wrapped_class accordingly :param wrapped: either a function or class """ self.wrapped = wrapped functools.update_wrapper(self, self.wrapped, updated=()) self.wrapped_fun...
[ "def", "set_wrapped", "(", "self", ",", "wrapped", ")", ":", "self", ".", "wrapped", "=", "wrapped", "functools", ".", "update_wrapper", "(", "self", ",", "self", ".", "wrapped", ",", "updated", "=", "(", ")", ")", "self", ".", "wrapped_func", "=", "Fa...
This will decide what wrapped is and set .wrapped_func or .wrapped_class accordingly :param wrapped: either a function or class
[ "This", "will", "decide", "what", "wrapped", "is", "and", "set", ".", "wrapped_func", "or", ".", "wrapped_class", "accordingly" ]
20525e93b5d259cfa9be771c43279825724c109e
https://github.com/Jaymon/decorators/blob/20525e93b5d259cfa9be771c43279825724c109e/decorators.py#L126-L141
train
Jaymon/decorators
decorators.py
Decorator.decorate_class
def decorate_class(self, klass, *decorator_args, **decorator_kwargs): """override this in a child class with your own logic, it must return a function that returns klass or the like :param klass: the class object that is being decorated :param decorator_args: tuple -- the arguments pass...
python
def decorate_class(self, klass, *decorator_args, **decorator_kwargs): """override this in a child class with your own logic, it must return a function that returns klass or the like :param klass: the class object that is being decorated :param decorator_args: tuple -- the arguments pass...
[ "def", "decorate_class", "(", "self", ",", "klass", ",", "*", "decorator_args", ",", "**", "decorator_kwargs", ")", ":", "raise", "RuntimeError", "(", "\"decorator {} does not support class decoration\"", ".", "format", "(", "self", ".", "__class__", ".", "__name__"...
override this in a child class with your own logic, it must return a function that returns klass or the like :param klass: the class object that is being decorated :param decorator_args: tuple -- the arguments passed into the decorator (eg, @dec(1, 2)) :param decorator_kwargs: dict -- t...
[ "override", "this", "in", "a", "child", "class", "with", "your", "own", "logic", "it", "must", "return", "a", "function", "that", "returns", "klass", "or", "the", "like" ]
20525e93b5d259cfa9be771c43279825724c109e
https://github.com/Jaymon/decorators/blob/20525e93b5d259cfa9be771c43279825724c109e/decorators.py#L212-L222
train
Jaymon/decorators
decorators.py
InstanceDecorator.decorate_class
def decorate_class(self, klass, *decorator_args, **decorator_kwargs): """where the magic happens, this wraps a class to call our decorate method in the init of the class """ class ChildClass(klass): def __init__(slf, *args, **kwargs): super(ChildClass, slf).__...
python
def decorate_class(self, klass, *decorator_args, **decorator_kwargs): """where the magic happens, this wraps a class to call our decorate method in the init of the class """ class ChildClass(klass): def __init__(slf, *args, **kwargs): super(ChildClass, slf).__...
[ "def", "decorate_class", "(", "self", ",", "klass", ",", "*", "decorator_args", ",", "**", "decorator_kwargs", ")", ":", "class", "ChildClass", "(", "klass", ")", ":", "def", "__init__", "(", "slf", ",", "*", "args", ",", "**", "kwargs", ")", ":", "sup...
where the magic happens, this wraps a class to call our decorate method in the init of the class
[ "where", "the", "magic", "happens", "this", "wraps", "a", "class", "to", "call", "our", "decorate", "method", "in", "the", "init", "of", "the", "class" ]
20525e93b5d259cfa9be771c43279825724c109e
https://github.com/Jaymon/decorators/blob/20525e93b5d259cfa9be771c43279825724c109e/decorators.py#L238-L255
train
bradmontgomery/django-blargg
blargg/models.py
generate_entry_tags
def generate_entry_tags(sender, instance, created, raw, using, **kwargs): """Generate the M2M ``Tag``s for an ``Entry`` right after it has been saved.""" Tag.objects.create_tags(instance)
python
def generate_entry_tags(sender, instance, created, raw, using, **kwargs): """Generate the M2M ``Tag``s for an ``Entry`` right after it has been saved.""" Tag.objects.create_tags(instance)
[ "def", "generate_entry_tags", "(", "sender", ",", "instance", ",", "created", ",", "raw", ",", "using", ",", "**", "kwargs", ")", ":", "Tag", ".", "objects", ".", "create_tags", "(", "instance", ")" ]
Generate the M2M ``Tag``s for an ``Entry`` right after it has been saved.
[ "Generate", "the", "M2M", "Tag", "s", "for", "an", "Entry", "right", "after", "it", "has", "been", "saved", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L247-L250
train
bradmontgomery/django-blargg
blargg/models.py
entry_stats
def entry_stats(entries, top_n=10): """Calculates stats for the given ``QuerySet`` of ``Entry``s.""" wc = Counter() # A Word counter for content in entries.values_list("rendered_content", flat=True): # Do a little cleanup content = strip_tags(content) # remove all html tags conten...
python
def entry_stats(entries, top_n=10): """Calculates stats for the given ``QuerySet`` of ``Entry``s.""" wc = Counter() # A Word counter for content in entries.values_list("rendered_content", flat=True): # Do a little cleanup content = strip_tags(content) # remove all html tags conten...
[ "def", "entry_stats", "(", "entries", ",", "top_n", "=", "10", ")", ":", "wc", "=", "Counter", "(", ")", "for", "content", "in", "entries", ".", "values_list", "(", "\"rendered_content\"", ",", "flat", "=", "True", ")", ":", "content", "=", "strip_tags",...
Calculates stats for the given ``QuerySet`` of ``Entry``s.
[ "Calculates", "stats", "for", "the", "given", "QuerySet", "of", "Entry", "s", "." ]
5d683e04723889a0d1c6d6cf1a67a3d431a2e617
https://github.com/bradmontgomery/django-blargg/blob/5d683e04723889a0d1c6d6cf1a67a3d431a2e617/blargg/models.py#L258-L274
train