id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
239,800 | JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/main.py | wrap | def wrap(ptr, base=None):
"""Wrap the given pointer with shiboken and return the appropriate QObject
:returns: if ptr is not None returns a QObject that is cast to the appropriate class
:rtype: QObject | None
:raises: None
"""
if ptr is None:
return None
ptr = long(ptr) # Ensure typ... | python | def wrap(ptr, base=None):
"""Wrap the given pointer with shiboken and return the appropriate QObject
:returns: if ptr is not None returns a QObject that is cast to the appropriate class
:rtype: QObject | None
:raises: None
"""
if ptr is None:
return None
ptr = long(ptr) # Ensure typ... | [
"def",
"wrap",
"(",
"ptr",
",",
"base",
"=",
"None",
")",
":",
"if",
"ptr",
"is",
"None",
":",
"return",
"None",
"ptr",
"=",
"long",
"(",
"ptr",
")",
"# Ensure type",
"if",
"base",
"is",
"None",
":",
"qObj",
"=",
"shiboken",
".",
"wrapInstance",
"(... | Wrap the given pointer with shiboken and return the appropriate QObject
:returns: if ptr is not None returns a QObject that is cast to the appropriate class
:rtype: QObject | None
:raises: None | [
"Wrap",
"the",
"given",
"pointer",
"with",
"shiboken",
"and",
"return",
"the",
"appropriate",
"QObject"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/main.py#L89-L110 |
239,801 | JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/main.py | dt_to_qdatetime | def dt_to_qdatetime(dt):
"""Convert a python datetime.datetime object to QDateTime
:param dt: the datetime object
:type dt: :class:`datetime.datetime`
:returns: the QDateTime conversion
:rtype: :class:`QtCore.QDateTime`
:raises: None
"""
return QtCore.QDateTime(QtCore.QDate(dt.year, dt.... | python | def dt_to_qdatetime(dt):
"""Convert a python datetime.datetime object to QDateTime
:param dt: the datetime object
:type dt: :class:`datetime.datetime`
:returns: the QDateTime conversion
:rtype: :class:`QtCore.QDateTime`
:raises: None
"""
return QtCore.QDateTime(QtCore.QDate(dt.year, dt.... | [
"def",
"dt_to_qdatetime",
"(",
"dt",
")",
":",
"return",
"QtCore",
".",
"QDateTime",
"(",
"QtCore",
".",
"QDate",
"(",
"dt",
".",
"year",
",",
"dt",
".",
"month",
",",
"dt",
".",
"day",
")",
",",
"QtCore",
".",
"QTime",
"(",
"dt",
".",
"hour",
",... | Convert a python datetime.datetime object to QDateTime
:param dt: the datetime object
:type dt: :class:`datetime.datetime`
:returns: the QDateTime conversion
:rtype: :class:`QtCore.QDateTime`
:raises: None | [
"Convert",
"a",
"python",
"datetime",
".",
"datetime",
"object",
"to",
"QDateTime"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/main.py#L113-L123 |
239,802 | JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/main.py | get_icon | def get_icon(name, aspix=False, asicon=False):
"""Return the real file path to the given icon name
If aspix is True return as QtGui.QPixmap, if asicon is True return as QtGui.QIcon.
:param name: the name of the icon
:type name: str
:param aspix: If True, return a QtGui.QPixmap.
:type aspix: boo... | python | def get_icon(name, aspix=False, asicon=False):
"""Return the real file path to the given icon name
If aspix is True return as QtGui.QPixmap, if asicon is True return as QtGui.QIcon.
:param name: the name of the icon
:type name: str
:param aspix: If True, return a QtGui.QPixmap.
:type aspix: boo... | [
"def",
"get_icon",
"(",
"name",
",",
"aspix",
"=",
"False",
",",
"asicon",
"=",
"False",
")",
":",
"datapath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"ICON_PATH",
",",
"name",
")",
"icon",
"=",
"pkg_resources",
".",
"resource_filename",
"(",
"'jukeb... | Return the real file path to the given icon name
If aspix is True return as QtGui.QPixmap, if asicon is True return as QtGui.QIcon.
:param name: the name of the icon
:type name: str
:param aspix: If True, return a QtGui.QPixmap.
:type aspix: bool
:param asicon: If True, return a QtGui.QIcon.
... | [
"Return",
"the",
"real",
"file",
"path",
"to",
"the",
"given",
"icon",
"name",
"If",
"aspix",
"is",
"True",
"return",
"as",
"QtGui",
".",
"QPixmap",
"if",
"asicon",
"is",
"True",
"return",
"as",
"QtGui",
".",
"QIcon",
"."
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/main.py#L126-L148 |
239,803 | JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/main.py | JB_Gui.allinstances | def allinstances(cls):
"""Return all instances that inherit from JB_Gui
:returns: all instances that inherit from JB_Gui
:rtype: list
:raises: None
"""
JB_Gui._allinstances = weakref.WeakSet([i for i in cls._allinstances if shiboken.isValid(i)])
return list(cls._... | python | def allinstances(cls):
"""Return all instances that inherit from JB_Gui
:returns: all instances that inherit from JB_Gui
:rtype: list
:raises: None
"""
JB_Gui._allinstances = weakref.WeakSet([i for i in cls._allinstances if shiboken.isValid(i)])
return list(cls._... | [
"def",
"allinstances",
"(",
"cls",
")",
":",
"JB_Gui",
".",
"_allinstances",
"=",
"weakref",
".",
"WeakSet",
"(",
"[",
"i",
"for",
"i",
"in",
"cls",
".",
"_allinstances",
"if",
"shiboken",
".",
"isValid",
"(",
"i",
")",
"]",
")",
"return",
"list",
"(... | Return all instances that inherit from JB_Gui
:returns: all instances that inherit from JB_Gui
:rtype: list
:raises: None | [
"Return",
"all",
"instances",
"that",
"inherit",
"from",
"JB_Gui"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/main.py#L178-L186 |
239,804 | JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/main.py | JB_Gui.classinstances | def classinstances(cls):
"""Return all instances of the current class
JB_Gui will not return the instances of subclasses
A subclass will only return the instances that have the same
type as the subclass. So it won\'t return instances of further subclasses.
:returns: all instnac... | python | def classinstances(cls):
"""Return all instances of the current class
JB_Gui will not return the instances of subclasses
A subclass will only return the instances that have the same
type as the subclass. So it won\'t return instances of further subclasses.
:returns: all instnac... | [
"def",
"classinstances",
"(",
"cls",
")",
":",
"l",
"=",
"[",
"i",
"for",
"i",
"in",
"cls",
".",
"allinstances",
"(",
")",
"if",
"type",
"(",
"i",
")",
"==",
"cls",
"]",
"return",
"l"
] | Return all instances of the current class
JB_Gui will not return the instances of subclasses
A subclass will only return the instances that have the same
type as the subclass. So it won\'t return instances of further subclasses.
:returns: all instnaces of the current class
:rty... | [
"Return",
"all",
"instances",
"of",
"the",
"current",
"class"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/main.py#L189-L201 |
239,805 | JukeboxPipeline/jukebox-core | src/jukeboxcore/gui/main.py | JB_Gui.instances | def instances(cls):
"""Return all instances of this class and subclasses
:returns: all instances of the current class and subclasses
:rtype: list
:raises: None
"""
l = [i for i in cls.allinstances() if isinstance(i, cls)]
return l | python | def instances(cls):
"""Return all instances of this class and subclasses
:returns: all instances of the current class and subclasses
:rtype: list
:raises: None
"""
l = [i for i in cls.allinstances() if isinstance(i, cls)]
return l | [
"def",
"instances",
"(",
"cls",
")",
":",
"l",
"=",
"[",
"i",
"for",
"i",
"in",
"cls",
".",
"allinstances",
"(",
")",
"if",
"isinstance",
"(",
"i",
",",
"cls",
")",
"]",
"return",
"l"
] | Return all instances of this class and subclasses
:returns: all instances of the current class and subclasses
:rtype: list
:raises: None | [
"Return",
"all",
"instances",
"of",
"this",
"class",
"and",
"subclasses"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/gui/main.py#L204-L212 |
239,806 | etcher-be/elib_miz | elib_miz/validator.py | Validator.error | def error(self, error_msg):
"""
Outputs error message on own logger. Also raises exceptions if need be.
Args:
error_msg: message to output
"""
if self.logger is not None:
self.logger.error(error_msg)
if self.exc is not None:
raise se... | python | def error(self, error_msg):
"""
Outputs error message on own logger. Also raises exceptions if need be.
Args:
error_msg: message to output
"""
if self.logger is not None:
self.logger.error(error_msg)
if self.exc is not None:
raise se... | [
"def",
"error",
"(",
"self",
",",
"error_msg",
")",
":",
"if",
"self",
".",
"logger",
"is",
"not",
"None",
":",
"self",
".",
"logger",
".",
"error",
"(",
"error_msg",
")",
"if",
"self",
".",
"exc",
"is",
"not",
"None",
":",
"raise",
"self",
".",
... | Outputs error message on own logger. Also raises exceptions if need be.
Args:
error_msg: message to output | [
"Outputs",
"error",
"message",
"on",
"own",
"logger",
".",
"Also",
"raises",
"exceptions",
"if",
"need",
"be",
"."
] | f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7 | https://github.com/etcher-be/elib_miz/blob/f28db58fadb2cd9341e0ae4d65101c0cc7d8f3d7/elib_miz/validator.py#L76-L88 |
239,807 | flo-compbio/goparser | goparser/parser.py | GOParser.clear_data | def clear_data(self):
"""Clear both ontology and annotation data.
Parameters
----------
Returns
-------
None
"""
self.clear_annotation_data()
self.terms = {}
self._alt_id = {}
self._syn2id = {}
self._name2id = {}
s... | python | def clear_data(self):
"""Clear both ontology and annotation data.
Parameters
----------
Returns
-------
None
"""
self.clear_annotation_data()
self.terms = {}
self._alt_id = {}
self._syn2id = {}
self._name2id = {}
s... | [
"def",
"clear_data",
"(",
"self",
")",
":",
"self",
".",
"clear_annotation_data",
"(",
")",
"self",
".",
"terms",
"=",
"{",
"}",
"self",
".",
"_alt_id",
"=",
"{",
"}",
"self",
".",
"_syn2id",
"=",
"{",
"}",
"self",
".",
"_name2id",
"=",
"{",
"}",
... | Clear both ontology and annotation data.
Parameters
----------
Returns
-------
None | [
"Clear",
"both",
"ontology",
"and",
"annotation",
"data",
"."
] | 5e27d7d04a26a70a1d9dc113357041abff72be3f | https://github.com/flo-compbio/goparser/blob/5e27d7d04a26a70a1d9dc113357041abff72be3f/goparser/parser.py#L288-L303 |
239,808 | flo-compbio/goparser | goparser/parser.py | GOParser.clear_annotation_data | def clear_annotation_data(self):
"""Clear annotation data.
Parameters
----------
Returns
-------
None
"""
self.genes = set()
self.annotations = []
self.term_annotations = {}
self.gene_annotations = {} | python | def clear_annotation_data(self):
"""Clear annotation data.
Parameters
----------
Returns
-------
None
"""
self.genes = set()
self.annotations = []
self.term_annotations = {}
self.gene_annotations = {} | [
"def",
"clear_annotation_data",
"(",
"self",
")",
":",
"self",
".",
"genes",
"=",
"set",
"(",
")",
"self",
".",
"annotations",
"=",
"[",
"]",
"self",
".",
"term_annotations",
"=",
"{",
"}",
"self",
".",
"gene_annotations",
"=",
"{",
"}"
] | Clear annotation data.
Parameters
----------
Returns
-------
None | [
"Clear",
"annotation",
"data",
"."
] | 5e27d7d04a26a70a1d9dc113357041abff72be3f | https://github.com/flo-compbio/goparser/blob/5e27d7d04a26a70a1d9dc113357041abff72be3f/goparser/parser.py#L305-L318 |
239,809 | flo-compbio/goparser | goparser/parser.py | GOParser._flatten_ancestors | def _flatten_ancestors(self, include_part_of=True):
"""Determines and stores all ancestors of each GO term.
Parameters
----------
include_part_of: bool, optional
Whether to include ``part_of`` relations in determining
ancestors.
Returns
-------
... | python | def _flatten_ancestors(self, include_part_of=True):
"""Determines and stores all ancestors of each GO term.
Parameters
----------
include_part_of: bool, optional
Whether to include ``part_of`` relations in determining
ancestors.
Returns
-------
... | [
"def",
"_flatten_ancestors",
"(",
"self",
",",
"include_part_of",
"=",
"True",
")",
":",
"def",
"get_all_ancestors",
"(",
"term",
")",
":",
"ancestors",
"=",
"set",
"(",
")",
"for",
"id_",
"in",
"term",
".",
"is_a",
":",
"ancestors",
".",
"add",
"(",
"... | Determines and stores all ancestors of each GO term.
Parameters
----------
include_part_of: bool, optional
Whether to include ``part_of`` relations in determining
ancestors.
Returns
-------
None | [
"Determines",
"and",
"stores",
"all",
"ancestors",
"of",
"each",
"GO",
"term",
"."
] | 5e27d7d04a26a70a1d9dc113357041abff72be3f | https://github.com/flo-compbio/goparser/blob/5e27d7d04a26a70a1d9dc113357041abff72be3f/goparser/parser.py#L405-L431 |
239,810 | flo-compbio/goparser | goparser/parser.py | GOParser.get_gene_goterms | def get_gene_goterms(self, gene, ancestors=False):
"""Return all GO terms a particular gene is annotated with.
Parameters
----------
gene: str
The gene symbol of the gene.
ancestors: bool, optional
If set to True, also return all ancestor GO terms.
... | python | def get_gene_goterms(self, gene, ancestors=False):
"""Return all GO terms a particular gene is annotated with.
Parameters
----------
gene: str
The gene symbol of the gene.
ancestors: bool, optional
If set to True, also return all ancestor GO terms.
... | [
"def",
"get_gene_goterms",
"(",
"self",
",",
"gene",
",",
"ancestors",
"=",
"False",
")",
":",
"annotations",
"=",
"self",
".",
"gene_annotations",
"[",
"gene",
"]",
"terms",
"=",
"set",
"(",
"ann",
".",
"term",
"for",
"ann",
"in",
"annotations",
")",
... | Return all GO terms a particular gene is annotated with.
Parameters
----------
gene: str
The gene symbol of the gene.
ancestors: bool, optional
If set to True, also return all ancestor GO terms.
Returns
-------
set of GOTerm objects
... | [
"Return",
"all",
"GO",
"terms",
"a",
"particular",
"gene",
"is",
"annotated",
"with",
"."
] | 5e27d7d04a26a70a1d9dc113357041abff72be3f | https://github.com/flo-compbio/goparser/blob/5e27d7d04a26a70a1d9dc113357041abff72be3f/goparser/parser.py#L666-L697 |
239,811 | flo-compbio/goparser | goparser/parser.py | GOParser.get_goterm_genes | def get_goterm_genes(self, id_, descendants=True):
"""Return all genes that are annotated with a particular GO term.
Parameters
----------
id_: str
GO term ID of the GO term.
descendants: bool, optional
If set to False, only return genes that are directly... | python | def get_goterm_genes(self, id_, descendants=True):
"""Return all genes that are annotated with a particular GO term.
Parameters
----------
id_: str
GO term ID of the GO term.
descendants: bool, optional
If set to False, only return genes that are directly... | [
"def",
"get_goterm_genes",
"(",
"self",
",",
"id_",
",",
"descendants",
"=",
"True",
")",
":",
"# determine which terms to include",
"main_term",
"=",
"self",
".",
"terms",
"[",
"id_",
"]",
"check_terms",
"=",
"{",
"main_term",
",",
"}",
"if",
"descendants",
... | Return all genes that are annotated with a particular GO term.
Parameters
----------
id_: str
GO term ID of the GO term.
descendants: bool, optional
If set to False, only return genes that are directly annotated with
the specified GO term. By default,... | [
"Return",
"all",
"genes",
"that",
"are",
"annotated",
"with",
"a",
"particular",
"GO",
"term",
"."
] | 5e27d7d04a26a70a1d9dc113357041abff72be3f | https://github.com/flo-compbio/goparser/blob/5e27d7d04a26a70a1d9dc113357041abff72be3f/goparser/parser.py#L699-L730 |
239,812 | flo-compbio/goparser | goparser/parser.py | GOParser.get_gene_sets | def get_gene_sets(self, min_genes=None, max_genes=None):
"""Return the set of annotated genes for each GO term.
Parameters
----------
min_genes: int, optional
Exclude GO terms with fewer than this number of genes.
max_genes: int, optional
Exclude GO terms... | python | def get_gene_sets(self, min_genes=None, max_genes=None):
"""Return the set of annotated genes for each GO term.
Parameters
----------
min_genes: int, optional
Exclude GO terms with fewer than this number of genes.
max_genes: int, optional
Exclude GO terms... | [
"def",
"get_gene_sets",
"(",
"self",
",",
"min_genes",
"=",
"None",
",",
"max_genes",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"terms",
":",
"raise",
"ValueError",
"(",
"'You need to first parse both an OBO file and '",
"'a gene association file!'",
")",
"... | Return the set of annotated genes for each GO term.
Parameters
----------
min_genes: int, optional
Exclude GO terms with fewer than this number of genes.
max_genes: int, optional
Exclude GO terms with more than this number of genes.
Returns
-----... | [
"Return",
"the",
"set",
"of",
"annotated",
"genes",
"for",
"each",
"GO",
"term",
"."
] | 5e27d7d04a26a70a1d9dc113357041abff72be3f | https://github.com/flo-compbio/goparser/blob/5e27d7d04a26a70a1d9dc113357041abff72be3f/goparser/parser.py#L732-L826 |
239,813 | openmeteo/pd2hts | pd2hts/__init__.py | _ReadFile.read_meta | def read_meta(self, f):
"""Read the headers of a file in file format and place them in the
self.meta dictionary.
"""
if not isinstance(f, BacktrackableFile):
f = BacktrackableFile(f)
try:
(name, value) = self.read_meta_line(f)
while name:
... | python | def read_meta(self, f):
"""Read the headers of a file in file format and place them in the
self.meta dictionary.
"""
if not isinstance(f, BacktrackableFile):
f = BacktrackableFile(f)
try:
(name, value) = self.read_meta_line(f)
while name:
... | [
"def",
"read_meta",
"(",
"self",
",",
"f",
")",
":",
"if",
"not",
"isinstance",
"(",
"f",
",",
"BacktrackableFile",
")",
":",
"f",
"=",
"BacktrackableFile",
"(",
"f",
")",
"try",
":",
"(",
"name",
",",
"value",
")",
"=",
"self",
".",
"read_meta_line"... | Read the headers of a file in file format and place them in the
self.meta dictionary. | [
"Read",
"the",
"headers",
"of",
"a",
"file",
"in",
"file",
"format",
"and",
"place",
"them",
"in",
"the",
"self",
".",
"meta",
"dictionary",
"."
] | b8f982046e2b99680445298b63a488dd76f6e104 | https://github.com/openmeteo/pd2hts/blob/b8f982046e2b99680445298b63a488dd76f6e104/pd2hts/__init__.py#L161-L183 |
239,814 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter._is_excluded | def _is_excluded(self, prop, info_dict):
"""
Check if the given prop should be excluded from the export
"""
if prop.key in BLACKLISTED_KEYS:
return True
if info_dict.get('exclude', False):
return True
if prop.key in self.excludes:
ret... | python | def _is_excluded(self, prop, info_dict):
"""
Check if the given prop should be excluded from the export
"""
if prop.key in BLACKLISTED_KEYS:
return True
if info_dict.get('exclude', False):
return True
if prop.key in self.excludes:
ret... | [
"def",
"_is_excluded",
"(",
"self",
",",
"prop",
",",
"info_dict",
")",
":",
"if",
"prop",
".",
"key",
"in",
"BLACKLISTED_KEYS",
":",
"return",
"True",
"if",
"info_dict",
".",
"get",
"(",
"'exclude'",
",",
"False",
")",
":",
"return",
"True",
"if",
"pr... | Check if the given prop should be excluded from the export | [
"Check",
"if",
"the",
"given",
"prop",
"should",
"be",
"excluded",
"from",
"the",
"export"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L149-L165 |
239,815 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter._get_title | def _get_title(self, prop, main_infos, info_dict):
"""
Return the title configured as in colanderalchemy
"""
result = main_infos.get('label')
if result is None:
result = info_dict.get('colanderalchemy', {}).get('title')
if result is None:
result = ... | python | def _get_title(self, prop, main_infos, info_dict):
"""
Return the title configured as in colanderalchemy
"""
result = main_infos.get('label')
if result is None:
result = info_dict.get('colanderalchemy', {}).get('title')
if result is None:
result = ... | [
"def",
"_get_title",
"(",
"self",
",",
"prop",
",",
"main_infos",
",",
"info_dict",
")",
":",
"result",
"=",
"main_infos",
".",
"get",
"(",
"'label'",
")",
"if",
"result",
"is",
"None",
":",
"result",
"=",
"info_dict",
".",
"get",
"(",
"'colanderalchemy'... | Return the title configured as in colanderalchemy | [
"Return",
"the",
"title",
"configured",
"as",
"in",
"colanderalchemy"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L167-L176 |
239,816 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter._get_prop_infos | def _get_prop_infos(self, prop):
"""
Return the infos configured for this specific prop, merging the
different configuration level
"""
info_dict = self.get_info_field(prop)
main_infos = info_dict.get('export', {}).copy()
infos = main_infos.get(self.config_key, {})... | python | def _get_prop_infos(self, prop):
"""
Return the infos configured for this specific prop, merging the
different configuration level
"""
info_dict = self.get_info_field(prop)
main_infos = info_dict.get('export', {}).copy()
infos = main_infos.get(self.config_key, {})... | [
"def",
"_get_prop_infos",
"(",
"self",
",",
"prop",
")",
":",
"info_dict",
"=",
"self",
".",
"get_info_field",
"(",
"prop",
")",
"main_infos",
"=",
"info_dict",
".",
"get",
"(",
"'export'",
",",
"{",
"}",
")",
".",
"copy",
"(",
")",
"infos",
"=",
"ma... | Return the infos configured for this specific prop, merging the
different configuration level | [
"Return",
"the",
"infos",
"configured",
"for",
"this",
"specific",
"prop",
"merging",
"the",
"different",
"configuration",
"level"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L178-L191 |
239,817 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter._collect_headers | def _collect_headers(self):
"""
Collect headers from the models attribute info col
"""
res = []
for prop in self.get_sorted_columns():
main_infos = self._get_prop_infos(prop)
if self._is_excluded(prop, main_infos):
continue
... | python | def _collect_headers(self):
"""
Collect headers from the models attribute info col
"""
res = []
for prop in self.get_sorted_columns():
main_infos = self._get_prop_infos(prop)
if self._is_excluded(prop, main_infos):
continue
... | [
"def",
"_collect_headers",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"prop",
"in",
"self",
".",
"get_sorted_columns",
"(",
")",
":",
"main_infos",
"=",
"self",
".",
"_get_prop_infos",
"(",
"prop",
")",
"if",
"self",
".",
"_is_excluded",
"(",
... | Collect headers from the models attribute info col | [
"Collect",
"headers",
"from",
"the",
"models",
"attribute",
"info",
"col"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L193-L226 |
239,818 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter._merge_many_to_one_field_from_fkey | def _merge_many_to_one_field_from_fkey(self, main_infos, prop, result):
"""
Find the relationship associated with this fkey and set the title
:param dict main_infos: The already collected datas about this column
:param obj prop: The property mapper of the relationship
:param lis... | python | def _merge_many_to_one_field_from_fkey(self, main_infos, prop, result):
"""
Find the relationship associated with this fkey and set the title
:param dict main_infos: The already collected datas about this column
:param obj prop: The property mapper of the relationship
:param lis... | [
"def",
"_merge_many_to_one_field_from_fkey",
"(",
"self",
",",
"main_infos",
",",
"prop",
",",
"result",
")",
":",
"if",
"prop",
".",
"columns",
"[",
"0",
"]",
".",
"foreign_keys",
"and",
"prop",
".",
"key",
".",
"endswith",
"(",
"'_id'",
")",
":",
"# We... | Find the relationship associated with this fkey and set the title
:param dict main_infos: The already collected datas about this column
:param obj prop: The property mapper of the relationship
:param list result: The actual collected headers
:returns: a main_infos dict or None | [
"Find",
"the",
"relationship",
"associated",
"with",
"this",
"fkey",
"and",
"set",
"the",
"title"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L308-L326 |
239,819 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter.add_row | def add_row(self, obj):
"""
fill a new row with the given obj
obj
instance of the exporter's model
"""
row = {}
for column in self.headers:
value = ''
if '__col__' in column:
if isinstance(column['__col__'], C... | python | def add_row(self, obj):
"""
fill a new row with the given obj
obj
instance of the exporter's model
"""
row = {}
for column in self.headers:
value = ''
if '__col__' in column:
if isinstance(column['__col__'], C... | [
"def",
"add_row",
"(",
"self",
",",
"obj",
")",
":",
"row",
"=",
"{",
"}",
"for",
"column",
"in",
"self",
".",
"headers",
":",
"value",
"=",
"''",
"if",
"'__col__'",
"in",
"column",
":",
"if",
"isinstance",
"(",
"column",
"[",
"'__col__'",
"]",
","... | fill a new row with the given obj
obj
instance of the exporter's model | [
"fill",
"a",
"new",
"row",
"with",
"the",
"given",
"obj"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L328-L350 |
239,820 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter._get_formatted_val | def _get_formatted_val(self, obj, name, column):
"""
Format the value of the attribute 'name' from the given object
"""
attr_path = name.split('.')
val = None
tmp_val = obj
for attr in attr_path:
tmp_val = getattr(tmp_val, attr, None)
if tm... | python | def _get_formatted_val(self, obj, name, column):
"""
Format the value of the attribute 'name' from the given object
"""
attr_path = name.split('.')
val = None
tmp_val = obj
for attr in attr_path:
tmp_val = getattr(tmp_val, attr, None)
if tm... | [
"def",
"_get_formatted_val",
"(",
"self",
",",
"obj",
",",
"name",
",",
"column",
")",
":",
"attr_path",
"=",
"name",
".",
"split",
"(",
"'.'",
")",
"val",
"=",
"None",
"tmp_val",
"=",
"obj",
"for",
"attr",
"in",
"attr_path",
":",
"tmp_val",
"=",
"ge... | Format the value of the attribute 'name' from the given object | [
"Format",
"the",
"value",
"of",
"the",
"attribute",
"name",
"from",
"the",
"given",
"object"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L352-L366 |
239,821 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter._get_relationship_cell_val | def _get_relationship_cell_val(self, obj, column):
"""
Return the value to insert in a relationship cell
"""
val = ""
key = column['key']
related_key = column.get('related_key', None)
related_obj = getattr(obj, key, None)
if related_obj is None:
... | python | def _get_relationship_cell_val(self, obj, column):
"""
Return the value to insert in a relationship cell
"""
val = ""
key = column['key']
related_key = column.get('related_key', None)
related_obj = getattr(obj, key, None)
if related_obj is None:
... | [
"def",
"_get_relationship_cell_val",
"(",
"self",
",",
"obj",
",",
"column",
")",
":",
"val",
"=",
"\"\"",
"key",
"=",
"column",
"[",
"'key'",
"]",
"related_key",
"=",
"column",
".",
"get",
"(",
"'related_key'",
",",
"None",
")",
"related_obj",
"=",
"get... | Return the value to insert in a relationship cell | [
"Return",
"the",
"value",
"to",
"insert",
"in",
"a",
"relationship",
"cell"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L368-L409 |
239,822 | majerteam/sqla_inspect | sqla_inspect/export.py | SqlaExporter._get_column_cell_val | def _get_column_cell_val(self, obj, column):
"""
Return a value of a "column" cell
"""
name = column['name']
return self._get_formatted_val(obj, name, column) | python | def _get_column_cell_val(self, obj, column):
"""
Return a value of a "column" cell
"""
name = column['name']
return self._get_formatted_val(obj, name, column) | [
"def",
"_get_column_cell_val",
"(",
"self",
",",
"obj",
",",
"column",
")",
":",
"name",
"=",
"column",
"[",
"'name'",
"]",
"return",
"self",
".",
"_get_formatted_val",
"(",
"obj",
",",
"name",
",",
"column",
")"
] | Return a value of a "column" cell | [
"Return",
"a",
"value",
"of",
"a",
"column",
"cell"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/export.py#L411-L416 |
239,823 | PlatformStories/geojsontools | geojsontools/geojsontools.py | join | def join(input_files, output_file):
'''
Join geojsons into one. The spatial reference system of the output file is the same
as the one of the last file in the list.
Args:
input_files (list): List of file name strings.
output_file (str): Output file name.
'''
# get feature c... | python | def join(input_files, output_file):
'''
Join geojsons into one. The spatial reference system of the output file is the same
as the one of the last file in the list.
Args:
input_files (list): List of file name strings.
output_file (str): Output file name.
'''
# get feature c... | [
"def",
"join",
"(",
"input_files",
",",
"output_file",
")",
":",
"# get feature collections",
"final_features",
"=",
"[",
"]",
"for",
"file",
"in",
"input_files",
":",
"with",
"open",
"(",
"file",
")",
"as",
"f",
":",
"feat_collection",
"=",
"geojson",
".",
... | Join geojsons into one. The spatial reference system of the output file is the same
as the one of the last file in the list.
Args:
input_files (list): List of file name strings.
output_file (str): Output file name. | [
"Join",
"geojsons",
"into",
"one",
".",
"The",
"spatial",
"reference",
"system",
"of",
"the",
"output",
"file",
"is",
"the",
"same",
"as",
"the",
"one",
"of",
"the",
"last",
"file",
"in",
"the",
"list",
"."
] | 80bf5cdde017a14338ee3962d1b59523ef2efdf1 | https://github.com/PlatformStories/geojsontools/blob/80bf5cdde017a14338ee3962d1b59523ef2efdf1/geojsontools/geojsontools.py#L11-L32 |
239,824 | PlatformStories/geojsontools | geojsontools/geojsontools.py | split | def split(input_file, file_1, file_2, no_in_first_file):
'''
Split a geojson in two separate files.
Args:
input_file (str): Input filename.
file_1 (str): Output file name 1.
file_2 (str): Output file name 2.
no_features (int): Number of features in input_file to go to file_1... | python | def split(input_file, file_1, file_2, no_in_first_file):
'''
Split a geojson in two separate files.
Args:
input_file (str): Input filename.
file_1 (str): Output file name 1.
file_2 (str): Output file name 2.
no_features (int): Number of features in input_file to go to file_1... | [
"def",
"split",
"(",
"input_file",
",",
"file_1",
",",
"file_2",
",",
"no_in_first_file",
")",
":",
"# get feature collection",
"with",
"open",
"(",
"input_file",
")",
"as",
"f",
":",
"feat_collection",
"=",
"geojson",
".",
"load",
"(",
"f",
")",
"features",... | Split a geojson in two separate files.
Args:
input_file (str): Input filename.
file_1 (str): Output file name 1.
file_2 (str): Output file name 2.
no_features (int): Number of features in input_file to go to file_1.
output_file (str): Output file name. | [
"Split",
"a",
"geojson",
"in",
"two",
"separate",
"files",
"."
] | 80bf5cdde017a14338ee3962d1b59523ef2efdf1 | https://github.com/PlatformStories/geojsontools/blob/80bf5cdde017a14338ee3962d1b59523ef2efdf1/geojsontools/geojsontools.py#L35-L59 |
239,825 | PlatformStories/geojsontools | geojsontools/geojsontools.py | get_from | def get_from(input_file, property_names):
'''
Reads a geojson and returns a list of value tuples, each value corresponding to a
property in property_names.
Args:
input_file (str): File name.
property_names: List of strings; each string is a property name.
Returns:
List ... | python | def get_from(input_file, property_names):
'''
Reads a geojson and returns a list of value tuples, each value corresponding to a
property in property_names.
Args:
input_file (str): File name.
property_names: List of strings; each string is a property name.
Returns:
List ... | [
"def",
"get_from",
"(",
"input_file",
",",
"property_names",
")",
":",
"# get feature collections",
"with",
"open",
"(",
"input_file",
")",
"as",
"f",
":",
"feature_collection",
"=",
"geojson",
".",
"load",
"(",
"f",
")",
"features",
"=",
"feature_collection",
... | Reads a geojson and returns a list of value tuples, each value corresponding to a
property in property_names.
Args:
input_file (str): File name.
property_names: List of strings; each string is a property name.
Returns:
List of value tuples. | [
"Reads",
"a",
"geojson",
"and",
"returns",
"a",
"list",
"of",
"value",
"tuples",
"each",
"value",
"corresponding",
"to",
"a",
"property",
"in",
"property_names",
"."
] | 80bf5cdde017a14338ee3962d1b59523ef2efdf1 | https://github.com/PlatformStories/geojsontools/blob/80bf5cdde017a14338ee3962d1b59523ef2efdf1/geojsontools/geojsontools.py#L62-L83 |
239,826 | PlatformStories/geojsontools | geojsontools/geojsontools.py | write_properties_to | def write_properties_to(data, property_names, input_file, output_file, filter=None):
'''
Writes property data to polygon_file for all geometries indicated in the filter, and
creates output file. The length of data must be equal to the number of geometries
in the filter. Existing property values ... | python | def write_properties_to(data, property_names, input_file, output_file, filter=None):
'''
Writes property data to polygon_file for all geometries indicated in the filter, and
creates output file. The length of data must be equal to the number of geometries
in the filter. Existing property values ... | [
"def",
"write_properties_to",
"(",
"data",
",",
"property_names",
",",
"input_file",
",",
"output_file",
",",
"filter",
"=",
"None",
")",
":",
"with",
"open",
"(",
"input_file",
")",
"as",
"f",
":",
"feature_collection",
"=",
"geojson",
".",
"load",
"(",
"... | Writes property data to polygon_file for all geometries indicated in the filter, and
creates output file. The length of data must be equal to the number of geometries
in the filter. Existing property values are overwritten.
Args
data (list): List of tuples. Each entry is a tuple of dimensio... | [
"Writes",
"property",
"data",
"to",
"polygon_file",
"for",
"all",
"geometries",
"indicated",
"in",
"the",
"filter",
"and",
"creates",
"output",
"file",
".",
"The",
"length",
"of",
"data",
"must",
"be",
"equal",
"to",
"the",
"number",
"of",
"geometries",
"in"... | 80bf5cdde017a14338ee3962d1b59523ef2efdf1 | https://github.com/PlatformStories/geojsontools/blob/80bf5cdde017a14338ee3962d1b59523ef2efdf1/geojsontools/geojsontools.py#L86-L127 |
239,827 | PlatformStories/geojsontools | geojsontools/geojsontools.py | find_unique_values | def find_unique_values(input_file, property_name):
'''
Find unique values of a given property in a geojson file.
Args
input_file (str): File name.
property_name (str): Property name.
Returns
List of distinct values of property. If property does not exist, it returns None.
''... | python | def find_unique_values(input_file, property_name):
'''
Find unique values of a given property in a geojson file.
Args
input_file (str): File name.
property_name (str): Property name.
Returns
List of distinct values of property. If property does not exist, it returns None.
''... | [
"def",
"find_unique_values",
"(",
"input_file",
",",
"property_name",
")",
":",
"with",
"open",
"(",
"input_file",
")",
"as",
"f",
":",
"feature_collection",
"=",
"geojson",
".",
"load",
"(",
"f",
")",
"features",
"=",
"feature_collection",
"[",
"'features'",
... | Find unique values of a given property in a geojson file.
Args
input_file (str): File name.
property_name (str): Property name.
Returns
List of distinct values of property. If property does not exist, it returns None. | [
"Find",
"unique",
"values",
"of",
"a",
"given",
"property",
"in",
"a",
"geojson",
"file",
"."
] | 80bf5cdde017a14338ee3962d1b59523ef2efdf1 | https://github.com/PlatformStories/geojsontools/blob/80bf5cdde017a14338ee3962d1b59523ef2efdf1/geojsontools/geojsontools.py#L130-L147 |
239,828 | PlatformStories/geojsontools | geojsontools/geojsontools.py | create_balanced_geojson | def create_balanced_geojson(input_file, classes, output_file='balanced.geojson',
samples_per_class=None):
'''
Create a geojson comprised of balanced classes from the class_name property in
input_file. Randomly selects polygons from all classes.
Args:
input_file (... | python | def create_balanced_geojson(input_file, classes, output_file='balanced.geojson',
samples_per_class=None):
'''
Create a geojson comprised of balanced classes from the class_name property in
input_file. Randomly selects polygons from all classes.
Args:
input_file (... | [
"def",
"create_balanced_geojson",
"(",
"input_file",
",",
"classes",
",",
"output_file",
"=",
"'balanced.geojson'",
",",
"samples_per_class",
"=",
"None",
")",
":",
"if",
"not",
"output_file",
".",
"endswith",
"(",
"'.geojson'",
")",
":",
"output_file",
"+=",
"'... | Create a geojson comprised of balanced classes from the class_name property in
input_file. Randomly selects polygons from all classes.
Args:
input_file (str): File name
classes (list[str]): Classes in input_file to include in the balanced output file.
Must exactly match the 'cla... | [
"Create",
"a",
"geojson",
"comprised",
"of",
"balanced",
"classes",
"from",
"the",
"class_name",
"property",
"in",
"input_file",
".",
"Randomly",
"selects",
"polygons",
"from",
"all",
"classes",
"."
] | 80bf5cdde017a14338ee3962d1b59523ef2efdf1 | https://github.com/PlatformStories/geojsontools/blob/80bf5cdde017a14338ee3962d1b59523ef2efdf1/geojsontools/geojsontools.py#L226-L276 |
239,829 | JukeboxPipeline/jukebox-core | src/jukeboxcore/launcher.py | Launcher.setup_manage_parser | def setup_manage_parser(self, parser):
"""Setup the given parser for manage command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None
"""
parser.set_defaults(func=self.mana... | python | def setup_manage_parser(self, parser):
"""Setup the given parser for manage command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None
"""
parser.set_defaults(func=self.mana... | [
"def",
"setup_manage_parser",
"(",
"self",
",",
"parser",
")",
":",
"parser",
".",
"set_defaults",
"(",
"func",
"=",
"self",
".",
"manage",
")",
"parser",
".",
"add_argument",
"(",
"\"args\"",
",",
"nargs",
"=",
"argparse",
".",
"REMAINDER",
",",
"help",
... | Setup the given parser for manage command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None | [
"Setup",
"the",
"given",
"parser",
"for",
"manage",
"command"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/launcher.py#L137-L148 |
239,830 | JukeboxPipeline/jukebox-core | src/jukeboxcore/launcher.py | Launcher.manage | def manage(self, namespace, unknown):
"""Execute the manage command for django
:param namespace: namespace containing args with django manage.py arguments
:type namespace: Namespace
:param unknown: list of unknown arguments that get passed to the manage.py command
:type unknown:... | python | def manage(self, namespace, unknown):
"""Execute the manage command for django
:param namespace: namespace containing args with django manage.py arguments
:type namespace: Namespace
:param unknown: list of unknown arguments that get passed to the manage.py command
:type unknown:... | [
"def",
"manage",
"(",
"self",
",",
"namespace",
",",
"unknown",
")",
":",
"# first argument is usually manage.py. This will also adapt the help messages",
"args",
"=",
"[",
"'jukebox manage'",
"]",
"args",
".",
"extend",
"(",
"namespace",
".",
"args",
")",
"args",
"... | Execute the manage command for django
:param namespace: namespace containing args with django manage.py arguments
:type namespace: Namespace
:param unknown: list of unknown arguments that get passed to the manage.py command
:type unknown: list
:returns: None
:rtype: None... | [
"Execute",
"the",
"manage",
"command",
"for",
"django"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/launcher.py#L150-L166 |
239,831 | JukeboxPipeline/jukebox-core | src/jukeboxcore/launcher.py | Launcher.setup_compile_ui_parser | def setup_compile_ui_parser(self, parser):
"""Setup the given parser for the compile_ui command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None
"""
parser.set_defaults(fu... | python | def setup_compile_ui_parser(self, parser):
"""Setup the given parser for the compile_ui command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None
"""
parser.set_defaults(fu... | [
"def",
"setup_compile_ui_parser",
"(",
"self",
",",
"parser",
")",
":",
"parser",
".",
"set_defaults",
"(",
"func",
"=",
"self",
".",
"compile_ui",
")",
"parser",
".",
"add_argument",
"(",
"'uifile'",
",",
"nargs",
"=",
"\"+\"",
",",
"help",
"=",
"'the uif... | Setup the given parser for the compile_ui command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None | [
"Setup",
"the",
"given",
"parser",
"for",
"the",
"compile_ui",
"command"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/launcher.py#L168-L183 |
239,832 | JukeboxPipeline/jukebox-core | src/jukeboxcore/launcher.py | Launcher.compile_ui | def compile_ui(self, namespace, unknown):
"""Compile qt designer files
:param namespace: namespace containing arguments from the launch parser
:type namespace: Namespace
:param unknown: list of unknown arguments
:type unknown: list
:returns: None
:rtype: None
... | python | def compile_ui(self, namespace, unknown):
"""Compile qt designer files
:param namespace: namespace containing arguments from the launch parser
:type namespace: Namespace
:param unknown: list of unknown arguments
:type unknown: list
:returns: None
:rtype: None
... | [
"def",
"compile_ui",
"(",
"self",
",",
"namespace",
",",
"unknown",
")",
":",
"uifiles",
"=",
"namespace",
".",
"uifile",
"for",
"f",
"in",
"uifiles",
":",
"qtcompile",
".",
"compile_ui",
"(",
"f",
".",
"name",
")"
] | Compile qt designer files
:param namespace: namespace containing arguments from the launch parser
:type namespace: Namespace
:param unknown: list of unknown arguments
:type unknown: list
:returns: None
:rtype: None
:raises: None | [
"Compile",
"qt",
"designer",
"files"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/launcher.py#L185-L198 |
239,833 | JukeboxPipeline/jukebox-core | src/jukeboxcore/launcher.py | Launcher.setup_compile_rcc_parser | def setup_compile_rcc_parser(self, parser):
"""Setup the given parser for the compile_rcc command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None
"""
parser.set_defaults(... | python | def setup_compile_rcc_parser(self, parser):
"""Setup the given parser for the compile_rcc command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None
"""
parser.set_defaults(... | [
"def",
"setup_compile_rcc_parser",
"(",
"self",
",",
"parser",
")",
":",
"parser",
".",
"set_defaults",
"(",
"func",
"=",
"self",
".",
"compile_rcc",
")",
"parser",
".",
"add_argument",
"(",
"'rccfile'",
",",
"help",
"=",
"'the resource file to compile.\\\n ... | Setup the given parser for the compile_rcc command
:param parser: the argument parser to setup
:type parser: :class:`argparse.ArgumentParser`
:returns: None
:rtype: None
:raises: None | [
"Setup",
"the",
"given",
"parser",
"for",
"the",
"compile_rcc",
"command"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/launcher.py#L200-L213 |
239,834 | JukeboxPipeline/jukebox-core | src/jukeboxcore/launcher.py | Launcher.compile_rcc | def compile_rcc(self, namespace, unknown):
"""Compile qt resource files
:param namespace: namespace containing arguments from the launch parser
:type namespace: Namespace
:param unknown: list of unknown arguments
:type unknown: list
:returns: None
:rtype: None
... | python | def compile_rcc(self, namespace, unknown):
"""Compile qt resource files
:param namespace: namespace containing arguments from the launch parser
:type namespace: Namespace
:param unknown: list of unknown arguments
:type unknown: list
:returns: None
:rtype: None
... | [
"def",
"compile_rcc",
"(",
"self",
",",
"namespace",
",",
"unknown",
")",
":",
"rccfile",
"=",
"namespace",
".",
"rccfile",
".",
"name",
"qtcompile",
".",
"compile_rcc",
"(",
"rccfile",
")"
] | Compile qt resource files
:param namespace: namespace containing arguments from the launch parser
:type namespace: Namespace
:param unknown: list of unknown arguments
:type unknown: list
:returns: None
:rtype: None
:raises: None | [
"Compile",
"qt",
"resource",
"files"
] | bac2280ca49940355270e4b69400ce9976ab2e6f | https://github.com/JukeboxPipeline/jukebox-core/blob/bac2280ca49940355270e4b69400ce9976ab2e6f/src/jukeboxcore/launcher.py#L215-L227 |
239,835 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/convert/ArrayConverter.py | ArrayConverter.to_nullable_array | def to_nullable_array(value):
"""
Converts value into array object.
Single values are converted into arrays with a single element.
:param value: the value to convert.
:return: array object or None when value is None.
"""
# Shortcuts
if value == None:
... | python | def to_nullable_array(value):
"""
Converts value into array object.
Single values are converted into arrays with a single element.
:param value: the value to convert.
:return: array object or None when value is None.
"""
# Shortcuts
if value == None:
... | [
"def",
"to_nullable_array",
"(",
"value",
")",
":",
"# Shortcuts",
"if",
"value",
"==",
"None",
":",
"return",
"None",
"if",
"type",
"(",
"value",
")",
"==",
"list",
":",
"return",
"value",
"if",
"type",
"(",
"value",
")",
"in",
"[",
"tuple",
",",
"s... | Converts value into array object.
Single values are converted into arrays with a single element.
:param value: the value to convert.
:return: array object or None when value is None. | [
"Converts",
"value",
"into",
"array",
"object",
".",
"Single",
"values",
"are",
"converted",
"into",
"arrays",
"with",
"a",
"single",
"element",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/convert/ArrayConverter.py#L23-L41 |
239,836 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/convert/ArrayConverter.py | ArrayConverter.to_array_with_default | def to_array_with_default(value, default_value):
"""
Converts value into array object with specified default.
Single values are converted into arrays with single element.
:param value: the value to convert.
:param default_value: default array object.
:return: array obj... | python | def to_array_with_default(value, default_value):
"""
Converts value into array object with specified default.
Single values are converted into arrays with single element.
:param value: the value to convert.
:param default_value: default array object.
:return: array obj... | [
"def",
"to_array_with_default",
"(",
"value",
",",
"default_value",
")",
":",
"result",
"=",
"ArrayConverter",
".",
"to_nullable_array",
"(",
"value",
")",
"return",
"result",
"if",
"result",
"!=",
"None",
"else",
"default_value"
] | Converts value into array object with specified default.
Single values are converted into arrays with single element.
:param value: the value to convert.
:param default_value: default array object.
:return: array object or default array when value is None. | [
"Converts",
"value",
"into",
"array",
"object",
"with",
"specified",
"default",
".",
"Single",
"values",
"are",
"converted",
"into",
"arrays",
"with",
"single",
"element",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/convert/ArrayConverter.py#L56-L68 |
239,837 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/convert/ArrayConverter.py | ArrayConverter.list_to_array | def list_to_array(value):
"""
Converts value into array object with empty array as default.
Strings with comma-delimited values are split into array of strings.
:param value: the list to convert.
:return: array object or empty array when value is None
"""
if val... | python | def list_to_array(value):
"""
Converts value into array object with empty array as default.
Strings with comma-delimited values are split into array of strings.
:param value: the list to convert.
:return: array object or empty array when value is None
"""
if val... | [
"def",
"list_to_array",
"(",
"value",
")",
":",
"if",
"value",
"==",
"None",
":",
"return",
"[",
"]",
"elif",
"type",
"(",
"value",
")",
"in",
"[",
"list",
",",
"tuple",
",",
"set",
"]",
":",
"return",
"list",
"(",
"value",
")",
"elif",
"type",
"... | Converts value into array object with empty array as default.
Strings with comma-delimited values are split into array of strings.
:param value: the list to convert.
:return: array object or empty array when value is None | [
"Converts",
"value",
"into",
"array",
"object",
"with",
"empty",
"array",
"as",
"default",
".",
"Strings",
"with",
"comma",
"-",
"delimited",
"values",
"are",
"split",
"into",
"array",
"of",
"strings",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/convert/ArrayConverter.py#L71-L87 |
239,838 | theSage21/lanchat | lanchat/utils.py | get_server_sock | def get_server_sock():
"Get a server socket"
s = _socket.socket()
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, True)
s.setblocking(False)
s.bind(('0.0.0.0', _config.server_listen_port))
s.listen(5)
return s | python | def get_server_sock():
"Get a server socket"
s = _socket.socket()
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, True)
s.setblocking(False)
s.bind(('0.0.0.0', _config.server_listen_port))
s.listen(5)
return s | [
"def",
"get_server_sock",
"(",
")",
":",
"s",
"=",
"_socket",
".",
"socket",
"(",
")",
"s",
".",
"setsockopt",
"(",
"_socket",
".",
"SOL_SOCKET",
",",
"_socket",
".",
"SO_REUSEADDR",
",",
"True",
")",
"s",
".",
"setblocking",
"(",
"False",
")",
"s",
... | Get a server socket | [
"Get",
"a",
"server",
"socket"
] | 66f5dcead67fef815347b956b1d3e149a7e13b29 | https://github.com/theSage21/lanchat/blob/66f5dcead67fef815347b956b1d3e149a7e13b29/lanchat/utils.py#L33-L40 |
239,839 | theSage21/lanchat | lanchat/utils.py | get_client_sock | def get_client_sock(addr):
"Get a client socket"
s = _socket.create_connection(addr)
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, True)
s.setblocking(False)
return s | python | def get_client_sock(addr):
"Get a client socket"
s = _socket.create_connection(addr)
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, True)
s.setblocking(False)
return s | [
"def",
"get_client_sock",
"(",
"addr",
")",
":",
"s",
"=",
"_socket",
".",
"create_connection",
"(",
"addr",
")",
"s",
".",
"setsockopt",
"(",
"_socket",
".",
"SOL_SOCKET",
",",
"_socket",
".",
"SO_REUSEADDR",
",",
"True",
")",
"s",
".",
"setblocking",
"... | Get a client socket | [
"Get",
"a",
"client",
"socket"
] | 66f5dcead67fef815347b956b1d3e149a7e13b29 | https://github.com/theSage21/lanchat/blob/66f5dcead67fef815347b956b1d3e149a7e13b29/lanchat/utils.py#L43-L48 |
239,840 | theSage21/lanchat | lanchat/utils.py | get_beacon | def get_beacon():
"Get a beacon socket"
s = _socket.socket(_socket.AF_INET, _socket.SOCK_DGRAM)
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, True)
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_BROADCAST, True)
return s | python | def get_beacon():
"Get a beacon socket"
s = _socket.socket(_socket.AF_INET, _socket.SOCK_DGRAM)
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_REUSEADDR, True)
s.setsockopt(_socket.SOL_SOCKET, _socket.SO_BROADCAST, True)
return s | [
"def",
"get_beacon",
"(",
")",
":",
"s",
"=",
"_socket",
".",
"socket",
"(",
"_socket",
".",
"AF_INET",
",",
"_socket",
".",
"SOCK_DGRAM",
")",
"s",
".",
"setsockopt",
"(",
"_socket",
".",
"SOL_SOCKET",
",",
"_socket",
".",
"SO_REUSEADDR",
",",
"True",
... | Get a beacon socket | [
"Get",
"a",
"beacon",
"socket"
] | 66f5dcead67fef815347b956b1d3e149a7e13b29 | https://github.com/theSage21/lanchat/blob/66f5dcead67fef815347b956b1d3e149a7e13b29/lanchat/utils.py#L51-L56 |
239,841 | endeepak/pungi | pungi/matchers.py | Base.message | def message(self):
''' Override this to provide failure message'''
name = self.__class__.__name__
return "{0} {1}".format(humanize(name),
pp(*self.expectedArgs, **self.expectedKwArgs)) | python | def message(self):
''' Override this to provide failure message'''
name = self.__class__.__name__
return "{0} {1}".format(humanize(name),
pp(*self.expectedArgs, **self.expectedKwArgs)) | [
"def",
"message",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"__class__",
".",
"__name__",
"return",
"\"{0} {1}\"",
".",
"format",
"(",
"humanize",
"(",
"name",
")",
",",
"pp",
"(",
"*",
"self",
".",
"expectedArgs",
",",
"*",
"*",
"self",
".",
... | Override this to provide failure message | [
"Override",
"this",
"to",
"provide",
"failure",
"message"
] | 4c90e0959f3498d0be85aa1e8e3ee4348be45593 | https://github.com/endeepak/pungi/blob/4c90e0959f3498d0be85aa1e8e3ee4348be45593/pungi/matchers.py#L25-L29 |
239,842 | realestate-com-au/dashmat | dashmat/core_modules/splunk/splunk-sdk-1.3.0/splunklib/searchcommands/search_command.py | SearchCommand.search_results_info | def search_results_info(self):
""" Returns the search results info for this command invocation or None.
The search results info object is created from the search results info
file associated with the command invocation. Splunk does not pass the
location of this file by default. You must... | python | def search_results_info(self):
""" Returns the search results info for this command invocation or None.
The search results info object is created from the search results info
file associated with the command invocation. Splunk does not pass the
location of this file by default. You must... | [
"def",
"search_results_info",
"(",
"self",
")",
":",
"if",
"self",
".",
"_search_results_info",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_search_results_info",
"try",
":",
"info_path",
"=",
"self",
".",
"input_header",
"[",
"'infoPath'",
"]",
"except"... | Returns the search results info for this command invocation or None.
The search results info object is created from the search results info
file associated with the command invocation. Splunk does not pass the
location of this file by default. You must request it by specifying
these con... | [
"Returns",
"the",
"search",
"results",
"info",
"for",
"this",
"command",
"invocation",
"or",
"None",
"."
] | 433886e52698f0ddb9956f087b76041966c3bcd1 | https://github.com/realestate-com-au/dashmat/blob/433886e52698f0ddb9956f087b76041966c3bcd1/dashmat/core_modules/splunk/splunk-sdk-1.3.0/splunklib/searchcommands/search_command.py#L169-L232 |
239,843 | realestate-com-au/dashmat | dashmat/core_modules/splunk/splunk-sdk-1.3.0/splunklib/searchcommands/search_command.py | SearchCommand.process | def process(self, args=argv, input_file=stdin, output_file=stdout):
""" Processes search results as specified by command arguments.
:param args: Sequence of command arguments
:param input_file: Pipeline input file
:param output_file: Pipeline output file
"""
self.logger... | python | def process(self, args=argv, input_file=stdin, output_file=stdout):
""" Processes search results as specified by command arguments.
:param args: Sequence of command arguments
:param input_file: Pipeline input file
:param output_file: Pipeline output file
"""
self.logger... | [
"def",
"process",
"(",
"self",
",",
"args",
"=",
"argv",
",",
"input_file",
"=",
"stdin",
",",
"output_file",
"=",
"stdout",
")",
":",
"self",
".",
"logger",
".",
"debug",
"(",
"u'%s arguments: %s'",
",",
"type",
"(",
"self",
")",
".",
"__name__",
",",... | Processes search results as specified by command arguments.
:param args: Sequence of command arguments
:param input_file: Pipeline input file
:param output_file: Pipeline output file | [
"Processes",
"search",
"results",
"as",
"specified",
"by",
"command",
"arguments",
"."
] | 433886e52698f0ddb9956f087b76041966c3bcd1 | https://github.com/realestate-com-au/dashmat/blob/433886e52698f0ddb9956f087b76041966c3bcd1/dashmat/core_modules/splunk/splunk-sdk-1.3.0/splunklib/searchcommands/search_command.py#L282-L356 |
239,844 | gisce/heman | heman/auth/__init__.py | check_contract_allowed | def check_contract_allowed(func):
"""Check if Contract is allowed by token
"""
@wraps(func)
def decorator(*args, **kwargs):
contract = kwargs.get('contract')
if (contract and current_user.is_authenticated()
and not current_user.allowed(contract)):
return curre... | python | def check_contract_allowed(func):
"""Check if Contract is allowed by token
"""
@wraps(func)
def decorator(*args, **kwargs):
contract = kwargs.get('contract')
if (contract and current_user.is_authenticated()
and not current_user.allowed(contract)):
return curre... | [
"def",
"check_contract_allowed",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"contract",
"=",
"kwargs",
".",
"get",
"(",
"'contract'",
")",
"if",
"(",
"contract",
"an... | Check if Contract is allowed by token | [
"Check",
"if",
"Contract",
"is",
"allowed",
"by",
"token"
] | cf09fca09953f12454b2910ddfa9d7586709657b | https://github.com/gisce/heman/blob/cf09fca09953f12454b2910ddfa9d7586709657b/heman/auth/__init__.py#L16-L26 |
239,845 | gisce/heman | heman/auth/__init__.py | check_cups_allowed | def check_cups_allowed(func):
"""Check if CUPS is allowd by token
"""
@wraps(func)
def decorator(*args, **kwargs):
cups = kwargs.get('cups')
if (cups and current_user.is_authenticated()
and not current_user.allowed(cups, 'cups')):
return current_app.login_mana... | python | def check_cups_allowed(func):
"""Check if CUPS is allowd by token
"""
@wraps(func)
def decorator(*args, **kwargs):
cups = kwargs.get('cups')
if (cups and current_user.is_authenticated()
and not current_user.allowed(cups, 'cups')):
return current_app.login_mana... | [
"def",
"check_cups_allowed",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cups",
"=",
"kwargs",
".",
"get",
"(",
"'cups'",
")",
"if",
"(",
"cups",
"and",
"current_u... | Check if CUPS is allowd by token | [
"Check",
"if",
"CUPS",
"is",
"allowd",
"by",
"token"
] | cf09fca09953f12454b2910ddfa9d7586709657b | https://github.com/gisce/heman/blob/cf09fca09953f12454b2910ddfa9d7586709657b/heman/auth/__init__.py#L29-L39 |
239,846 | majerteam/sqla_inspect | sqla_inspect/py3o.py | format_py3o_val | def format_py3o_val(value):
"""
format a value to fit py3o's context
* Handle linebreaks
"""
value = force_unicode(value)
value = escape(value)
value = value.replace(u'\n', u'<text:line-break/>')
return Markup(value) | python | def format_py3o_val(value):
"""
format a value to fit py3o's context
* Handle linebreaks
"""
value = force_unicode(value)
value = escape(value)
value = value.replace(u'\n', u'<text:line-break/>')
return Markup(value) | [
"def",
"format_py3o_val",
"(",
"value",
")",
":",
"value",
"=",
"force_unicode",
"(",
"value",
")",
"value",
"=",
"escape",
"(",
"value",
")",
"value",
"=",
"value",
".",
"replace",
"(",
"u'\\n'",
",",
"u'<text:line-break/>'",
")",
"return",
"Markup",
"(",... | format a value to fit py3o's context
* Handle linebreaks | [
"format",
"a",
"value",
"to",
"fit",
"py3o",
"s",
"context"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L39-L48 |
239,847 | majerteam/sqla_inspect | sqla_inspect/py3o.py | get_compilation_context | def get_compilation_context(instance):
"""
Return the compilation context for py3o templating
Build a deep dict representation of the given instance and add config values
:param obj instance: a SQLAlchemy model instance
:return: a multi level dict with context datas
:rtype: dict
"""
co... | python | def get_compilation_context(instance):
"""
Return the compilation context for py3o templating
Build a deep dict representation of the given instance and add config values
:param obj instance: a SQLAlchemy model instance
:return: a multi level dict with context datas
:rtype: dict
"""
co... | [
"def",
"get_compilation_context",
"(",
"instance",
")",
":",
"context_builder",
"=",
"SqlaContext",
"(",
"instance",
".",
"__class__",
")",
"py3o_context",
"=",
"context_builder",
".",
"compile_obj",
"(",
"instance",
")",
"return",
"py3o_context"
] | Return the compilation context for py3o templating
Build a deep dict representation of the given instance and add config values
:param obj instance: a SQLAlchemy model instance
:return: a multi level dict with context datas
:rtype: dict | [
"Return",
"the",
"compilation",
"context",
"for",
"py3o",
"templating"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L348-L360 |
239,848 | majerteam/sqla_inspect | sqla_inspect/py3o.py | compile_template | def compile_template(instance, template, additionnal_context=None):
"""
Fill the given template with the instance's datas and return the odt file
For every instance class, common values are also inserted in the context
dict (and so can be used) :
* config values
:param obj instance: the i... | python | def compile_template(instance, template, additionnal_context=None):
"""
Fill the given template with the instance's datas and return the odt file
For every instance class, common values are also inserted in the context
dict (and so can be used) :
* config values
:param obj instance: the i... | [
"def",
"compile_template",
"(",
"instance",
",",
"template",
",",
"additionnal_context",
"=",
"None",
")",
":",
"py3o_context",
"=",
"get_compilation_context",
"(",
"instance",
")",
"if",
"additionnal_context",
"is",
"not",
"None",
":",
"py3o_context",
".",
"updat... | Fill the given template with the instance's datas and return the odt file
For every instance class, common values are also inserted in the context
dict (and so can be used) :
* config values
:param obj instance: the instance of a model (like Userdatas, Company)
:param template: the template o... | [
"Fill",
"the",
"given",
"template",
"with",
"the",
"instance",
"s",
"datas",
"and",
"return",
"the",
"odt",
"file"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L363-L388 |
239,849 | majerteam/sqla_inspect | sqla_inspect/py3o.py | SqlaContext.collect_columns | def collect_columns(self):
"""
Collect columns information from a given model.
a column info contains
the py3 informations
exclude
Should the column be excluded from the current context ?
name
the name of t... | python | def collect_columns(self):
"""
Collect columns information from a given model.
a column info contains
the py3 informations
exclude
Should the column be excluded from the current context ?
name
the name of t... | [
"def",
"collect_columns",
"(",
"self",
")",
":",
"res",
"=",
"[",
"]",
"for",
"prop",
"in",
"self",
".",
"get_sorted_columns",
"(",
")",
":",
"info_dict",
"=",
"self",
".",
"get_info_field",
"(",
"prop",
")",
"export_infos",
"=",
"info_dict",
".",
"get",... | Collect columns information from a given model.
a column info contains
the py3 informations
exclude
Should the column be excluded from the current context ?
name
the name of the key in the resulting py3o context of the
... | [
"Collect",
"columns",
"information",
"from",
"a",
"given",
"model",
"."
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L85-L143 |
239,850 | majerteam/sqla_inspect | sqla_inspect/py3o.py | SqlaContext.gen_xml_doc | def gen_xml_doc(self):
"""
Generate the text tags that should be inserted in the content.xml of a
full model
"""
res = self.make_doc()
var_tag = """
<text:user-field-decl office:value-type="string"
office:string-value="%s" text:name="py3o.%s"/>"""
... | python | def gen_xml_doc(self):
"""
Generate the text tags that should be inserted in the content.xml of a
full model
"""
res = self.make_doc()
var_tag = """
<text:user-field-decl office:value-type="string"
office:string-value="%s" text:name="py3o.%s"/>"""
... | [
"def",
"gen_xml_doc",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"make_doc",
"(",
")",
"var_tag",
"=",
"\"\"\"\n <text:user-field-decl office:value-type=\"string\"\n office:string-value=\"%s\" text:name=\"py3o.%s\"/>\"\"\"",
"text_tag",
"=",
"\"\"\"<text:p text... | Generate the text tags that should be inserted in the content.xml of a
full model | [
"Generate",
"the",
"text",
"tags",
"that",
"should",
"be",
"inserted",
"in",
"the",
"content",
".",
"xml",
"of",
"a",
"full",
"model"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L205-L226 |
239,851 | majerteam/sqla_inspect | sqla_inspect/py3o.py | SqlaContext._get_formatted_val | def _get_formatted_val(self, obj, attribute, column):
"""
Return the formatted value of the attribute "attribute" of the obj "obj"
regarding the column's description
:param obj obj: The instance we manage
:param str attribute: The string defining the path to access the end
... | python | def _get_formatted_val(self, obj, attribute, column):
"""
Return the formatted value of the attribute "attribute" of the obj "obj"
regarding the column's description
:param obj obj: The instance we manage
:param str attribute: The string defining the path to access the end
... | [
"def",
"_get_formatted_val",
"(",
"self",
",",
"obj",
",",
"attribute",
",",
"column",
")",
":",
"attr_path",
"=",
"attribute",
".",
"split",
"(",
"'.'",
")",
"val",
"=",
"None",
"tmp_val",
"=",
"obj",
"for",
"attr",
"in",
"attr_path",
":",
"tmp_val",
... | Return the formatted value of the attribute "attribute" of the obj "obj"
regarding the column's description
:param obj obj: The instance we manage
:param str attribute: The string defining the path to access the end
attribute we want to manage
:param dict column: The column desc... | [
"Return",
"the",
"formatted",
"value",
"of",
"the",
"attribute",
"attribute",
"of",
"the",
"obj",
"obj",
"regarding",
"the",
"column",
"s",
"description"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L228-L250 |
239,852 | majerteam/sqla_inspect | sqla_inspect/py3o.py | SqlaContext._get_column_value | def _get_column_value(self, obj, column):
"""
Return a single cell's value
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value
"""
return self._get_formatted_val(obj, column['__col__'].key, ... | python | def _get_column_value(self, obj, column):
"""
Return a single cell's value
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value
"""
return self._get_formatted_val(obj, column['__col__'].key, ... | [
"def",
"_get_column_value",
"(",
"self",
",",
"obj",
",",
"column",
")",
":",
"return",
"self",
".",
"_get_formatted_val",
"(",
"obj",
",",
"column",
"[",
"'__col__'",
"]",
".",
"key",
",",
"column",
")"
] | Return a single cell's value
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value | [
"Return",
"a",
"single",
"cell",
"s",
"value"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L252-L260 |
239,853 | majerteam/sqla_inspect | sqla_inspect/py3o.py | SqlaContext._get_to_many_relationship_value | def _get_to_many_relationship_value(self, obj, column):
"""
Get the resulting datas for a One To many or a many to many relationship
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value
"""
r... | python | def _get_to_many_relationship_value(self, obj, column):
"""
Get the resulting datas for a One To many or a many to many relationship
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value
"""
r... | [
"def",
"_get_to_many_relationship_value",
"(",
"self",
",",
"obj",
",",
"column",
")",
":",
"related_key",
"=",
"column",
".",
"get",
"(",
"'related_key'",
",",
"None",
")",
"related",
"=",
"getattr",
"(",
"obj",
",",
"column",
"[",
"'__col__'",
"]",
".",
... | Get the resulting datas for a One To many or a many to many relationship
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value | [
"Get",
"the",
"resulting",
"datas",
"for",
"a",
"One",
"To",
"many",
"or",
"a",
"many",
"to",
"many",
"relationship"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L262-L295 |
239,854 | majerteam/sqla_inspect | sqla_inspect/py3o.py | SqlaContext._get_to_one_relationship_value | def _get_to_one_relationship_value(self, obj, column):
"""
Compute datas produced for a many to one relationship
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value
"""
related_key = column.... | python | def _get_to_one_relationship_value(self, obj, column):
"""
Compute datas produced for a many to one relationship
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value
"""
related_key = column.... | [
"def",
"_get_to_one_relationship_value",
"(",
"self",
",",
"obj",
",",
"column",
")",
":",
"related_key",
"=",
"column",
".",
"get",
"(",
"'related_key'",
",",
"None",
")",
"related",
"=",
"getattr",
"(",
"obj",
",",
"column",
"[",
"'__col__'",
"]",
".",
... | Compute datas produced for a many to one relationship
:param obj obj: The instance we manage
:param dict column: The column description dictionnary
:returns: The associated value | [
"Compute",
"datas",
"produced",
"for",
"a",
"many",
"to",
"one",
"relationship"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L297-L316 |
239,855 | majerteam/sqla_inspect | sqla_inspect/py3o.py | SqlaContext._get_relationship_value | def _get_relationship_value(self, obj, column):
"""
Compute datas produced for a given relationship
"""
if column['__col__'].uselist:
value = self._get_to_many_relationship_value(obj, column)
else:
value = self._get_to_one_relationship_value(obj, column)
... | python | def _get_relationship_value(self, obj, column):
"""
Compute datas produced for a given relationship
"""
if column['__col__'].uselist:
value = self._get_to_many_relationship_value(obj, column)
else:
value = self._get_to_one_relationship_value(obj, column)
... | [
"def",
"_get_relationship_value",
"(",
"self",
",",
"obj",
",",
"column",
")",
":",
"if",
"column",
"[",
"'__col__'",
"]",
".",
"uselist",
":",
"value",
"=",
"self",
".",
"_get_to_many_relationship_value",
"(",
"obj",
",",
"column",
")",
"else",
":",
"valu... | Compute datas produced for a given relationship | [
"Compute",
"datas",
"produced",
"for",
"a",
"given",
"relationship"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L318-L327 |
239,856 | majerteam/sqla_inspect | sqla_inspect/py3o.py | SqlaContext.compile_obj | def compile_obj(self, obj):
"""
generate a context based on the given obj
:param obj: an instance of the model
"""
res = {}
for column in self.columns:
if isinstance(column['__col__'], ColumnProperty):
value = self._get_column_value(obj, colum... | python | def compile_obj(self, obj):
"""
generate a context based on the given obj
:param obj: an instance of the model
"""
res = {}
for column in self.columns:
if isinstance(column['__col__'], ColumnProperty):
value = self._get_column_value(obj, colum... | [
"def",
"compile_obj",
"(",
"self",
",",
"obj",
")",
":",
"res",
"=",
"{",
"}",
"for",
"column",
"in",
"self",
".",
"columns",
":",
"if",
"isinstance",
"(",
"column",
"[",
"'__col__'",
"]",
",",
"ColumnProperty",
")",
":",
"value",
"=",
"self",
".",
... | generate a context based on the given obj
:param obj: an instance of the model | [
"generate",
"a",
"context",
"based",
"on",
"the",
"given",
"obj"
] | 67edb5541e6a56b0a657d3774d1e19c1110cd402 | https://github.com/majerteam/sqla_inspect/blob/67edb5541e6a56b0a657d3774d1e19c1110cd402/sqla_inspect/py3o.py#L329-L345 |
239,857 | host-anshu/simpleInterceptor | example/call_graph/advices.py | write | def write(_filename, _long, enter=True):
"""Write the call info to file"""
def method(*arg, **kw): # pylint: disable=W0613
"""Reference to the advice in order to facilitate argument support."""
def get_short(_fname):
"""Get basename of the file. If file is __init__.py, get its direc... | python | def write(_filename, _long, enter=True):
"""Write the call info to file"""
def method(*arg, **kw): # pylint: disable=W0613
"""Reference to the advice in order to facilitate argument support."""
def get_short(_fname):
"""Get basename of the file. If file is __init__.py, get its direc... | [
"def",
"write",
"(",
"_filename",
",",
"_long",
",",
"enter",
"=",
"True",
")",
":",
"def",
"method",
"(",
"*",
"arg",
",",
"*",
"*",
"kw",
")",
":",
"# pylint: disable=W0613",
"\"\"\"Reference to the advice in order to facilitate argument support.\"\"\"",
"def",
... | Write the call info to file | [
"Write",
"the",
"call",
"info",
"to",
"file"
] | 71238fed57c62b5f77ce32d0c9b98acad73ab6a8 | https://github.com/host-anshu/simpleInterceptor/blob/71238fed57c62b5f77ce32d0c9b98acad73ab6a8/example/call_graph/advices.py#L24-L69 |
239,858 | adsabs/adsutils | adsutils/sourcematchers.py | TrigdictSourceMatcher._addPub | def _addPub(self, stem, source):
"""Enters stem as value for source.
"""
key = re.sub("[^A-Za-z0-9&]+", " ", source).strip().upper()
self.sourceDict[key] = stem
self.bibstemWords.setdefault(stem, set()).update(
key.lower().split()) | python | def _addPub(self, stem, source):
"""Enters stem as value for source.
"""
key = re.sub("[^A-Za-z0-9&]+", " ", source).strip().upper()
self.sourceDict[key] = stem
self.bibstemWords.setdefault(stem, set()).update(
key.lower().split()) | [
"def",
"_addPub",
"(",
"self",
",",
"stem",
",",
"source",
")",
":",
"key",
"=",
"re",
".",
"sub",
"(",
"\"[^A-Za-z0-9&]+\"",
",",
"\" \"",
",",
"source",
")",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"self",
".",
"sourceDict",
"[",
"key",
... | Enters stem as value for source. | [
"Enters",
"stem",
"as",
"value",
"for",
"source",
"."
] | fb9d6b4f6ed5e6ca19c552efc3cdd6466c587fdb | https://github.com/adsabs/adsutils/blob/fb9d6b4f6ed5e6ca19c552efc3cdd6466c587fdb/adsutils/sourcematchers.py#L75-L81 |
239,859 | adsabs/adsutils | adsutils/sourcematchers.py | TrigdictSourceMatcher._loadOneSource | def _loadOneSource(self, sourceFName):
"""handles one authority file including format auto-detection.
"""
sourceLines = open(sourceFName).readlines()
del sourceLines[0]
if len(sourceLines[0].split("\t"))==2:
self._loadTwoPartSource(sourceFName, sourceLines)
el... | python | def _loadOneSource(self, sourceFName):
"""handles one authority file including format auto-detection.
"""
sourceLines = open(sourceFName).readlines()
del sourceLines[0]
if len(sourceLines[0].split("\t"))==2:
self._loadTwoPartSource(sourceFName, sourceLines)
el... | [
"def",
"_loadOneSource",
"(",
"self",
",",
"sourceFName",
")",
":",
"sourceLines",
"=",
"open",
"(",
"sourceFName",
")",
".",
"readlines",
"(",
")",
"del",
"sourceLines",
"[",
"0",
"]",
"if",
"len",
"(",
"sourceLines",
"[",
"0",
"]",
".",
"split",
"(",... | handles one authority file including format auto-detection. | [
"handles",
"one",
"authority",
"file",
"including",
"format",
"auto",
"-",
"detection",
"."
] | fb9d6b4f6ed5e6ca19c552efc3cdd6466c587fdb | https://github.com/adsabs/adsutils/blob/fb9d6b4f6ed5e6ca19c552efc3cdd6466c587fdb/adsutils/sourcematchers.py#L119-L129 |
239,860 | adsabs/adsutils | adsutils/sourcematchers.py | TrigdictSourceMatcher._loadSources | def _loadSources(self):
"""creates a trigdict and populates it with data from self.autorityFiles
"""
self.confstems = {}
self.sourceDict = newtrigdict.Trigdict()
for fName in self.authorityFiles:
self._loadOneSource(fName)
# We want to allow naked bibstems in ... | python | def _loadSources(self):
"""creates a trigdict and populates it with data from self.autorityFiles
"""
self.confstems = {}
self.sourceDict = newtrigdict.Trigdict()
for fName in self.authorityFiles:
self._loadOneSource(fName)
# We want to allow naked bibstems in ... | [
"def",
"_loadSources",
"(",
"self",
")",
":",
"self",
".",
"confstems",
"=",
"{",
"}",
"self",
".",
"sourceDict",
"=",
"newtrigdict",
".",
"Trigdict",
"(",
")",
"for",
"fName",
"in",
"self",
".",
"authorityFiles",
":",
"self",
".",
"_loadOneSource",
"(",... | creates a trigdict and populates it with data from self.autorityFiles | [
"creates",
"a",
"trigdict",
"and",
"populates",
"it",
"with",
"data",
"from",
"self",
".",
"autorityFiles"
] | fb9d6b4f6ed5e6ca19c552efc3cdd6466c587fdb | https://github.com/adsabs/adsutils/blob/fb9d6b4f6ed5e6ca19c552efc3cdd6466c587fdb/adsutils/sourcematchers.py#L131-L141 |
239,861 | ringly/django-postgres-dbdefaults | setup.py | long_description | def long_description():
"""
Build the long description from a README file located in the same directory
as this module.
"""
base_path = os.path.dirname(os.path.realpath(__file__))
with io.open(os.path.join(base_path, 'README.md'), encoding='utf-8') as f:
return f.read() | python | def long_description():
"""
Build the long description from a README file located in the same directory
as this module.
"""
base_path = os.path.dirname(os.path.realpath(__file__))
with io.open(os.path.join(base_path, 'README.md'), encoding='utf-8') as f:
return f.read() | [
"def",
"long_description",
"(",
")",
":",
"base_path",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"realpath",
"(",
"__file__",
")",
")",
"with",
"io",
".",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"base_path",
","... | Build the long description from a README file located in the same directory
as this module. | [
"Build",
"the",
"long",
"description",
"from",
"a",
"README",
"file",
"located",
"in",
"the",
"same",
"directory",
"as",
"this",
"module",
"."
] | fb59ed3e77d15647831434597082fc72161ff55b | https://github.com/ringly/django-postgres-dbdefaults/blob/fb59ed3e77d15647831434597082fc72161ff55b/setup.py#L7-L14 |
239,862 | toumorokoshi/jenks | jenks/subcommand/build.py | get_build_info | def get_build_info(api_instance, build_id=None,
keys=DEFAULT_BUILD_KEYS, wait=False):
""" print build info about a job """
build = (api_instance.get_build(build_id) if build_id
else api_instance.get_last_build())
output = ""
if wait:
build.block_until_complete()
... | python | def get_build_info(api_instance, build_id=None,
keys=DEFAULT_BUILD_KEYS, wait=False):
""" print build info about a job """
build = (api_instance.get_build(build_id) if build_id
else api_instance.get_last_build())
output = ""
if wait:
build.block_until_complete()
... | [
"def",
"get_build_info",
"(",
"api_instance",
",",
"build_id",
"=",
"None",
",",
"keys",
"=",
"DEFAULT_BUILD_KEYS",
",",
"wait",
"=",
"False",
")",
":",
"build",
"=",
"(",
"api_instance",
".",
"get_build",
"(",
"build_id",
")",
"if",
"build_id",
"else",
"a... | print build info about a job | [
"print",
"build",
"info",
"about",
"a",
"job"
] | d3333a7b86ba290b7185aa5b8da75e76a28124f5 | https://github.com/toumorokoshi/jenks/blob/d3333a7b86ba290b7185aa5b8da75e76a28124f5/jenks/subcommand/build.py#L58-L82 |
239,863 | racker/python-twisted-service-registry-client | utils/dist.py | _filter_names | def _filter_names(names):
"""
Given a list of file names, return those names that should be copied.
"""
names = [n for n in names
if n not in EXCLUDE_NAMES]
# This is needed when building a distro from a working
# copy (likely a checkout) rather than a pristine export:
for patte... | python | def _filter_names(names):
"""
Given a list of file names, return those names that should be copied.
"""
names = [n for n in names
if n not in EXCLUDE_NAMES]
# This is needed when building a distro from a working
# copy (likely a checkout) rather than a pristine export:
for patte... | [
"def",
"_filter_names",
"(",
"names",
")",
":",
"names",
"=",
"[",
"n",
"for",
"n",
"in",
"names",
"if",
"n",
"not",
"in",
"EXCLUDE_NAMES",
"]",
"# This is needed when building a distro from a working",
"# copy (likely a checkout) rather than a pristine export:",
"for",
... | Given a list of file names, return those names that should be copied. | [
"Given",
"a",
"list",
"of",
"file",
"names",
"return",
"those",
"names",
"that",
"should",
"be",
"copied",
"."
] | 72adfce04c609d72f09ee2f21e9d31be12aefd80 | https://github.com/racker/python-twisted-service-registry-client/blob/72adfce04c609d72f09ee2f21e9d31be12aefd80/utils/dist.py#L28-L40 |
239,864 | racker/python-twisted-service-registry-client | utils/dist.py | relative_to | def relative_to(base, relativee):
"""
Gets 'relativee' relative to 'basepath'.
i.e.,
>>> relative_to('/home/', '/home/radix/')
'radix'
>>> relative_to('.', '/home/radix/Projects/Twisted') # curdir is /home/radix
'Projects/Twisted'
The 'relativee' must be a child of 'basepath'.
"""... | python | def relative_to(base, relativee):
"""
Gets 'relativee' relative to 'basepath'.
i.e.,
>>> relative_to('/home/', '/home/radix/')
'radix'
>>> relative_to('.', '/home/radix/Projects/Twisted') # curdir is /home/radix
'Projects/Twisted'
The 'relativee' must be a child of 'basepath'.
"""... | [
"def",
"relative_to",
"(",
"base",
",",
"relativee",
")",
":",
"basepath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"base",
")",
"relativee",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"relativee",
")",
"if",
"relativee",
".",
"startswith",
"(",
... | Gets 'relativee' relative to 'basepath'.
i.e.,
>>> relative_to('/home/', '/home/radix/')
'radix'
>>> relative_to('.', '/home/radix/Projects/Twisted') # curdir is /home/radix
'Projects/Twisted'
The 'relativee' must be a child of 'basepath'. | [
"Gets",
"relativee",
"relative",
"to",
"basepath",
"."
] | 72adfce04c609d72f09ee2f21e9d31be12aefd80 | https://github.com/racker/python-twisted-service-registry-client/blob/72adfce04c609d72f09ee2f21e9d31be12aefd80/utils/dist.py#L43-L63 |
239,865 | racker/python-twisted-service-registry-client | utils/dist.py | get_packages | def get_packages(dname, pkgname=None, results=None, ignore=None, parent=None):
"""
Get all packages which are under dname. This is necessary for
Python 2.2's distutils. Pretty similar arguments to getDataFiles,
including 'parent'.
"""
parent = parent or ""
prefix = []
if parent:
... | python | def get_packages(dname, pkgname=None, results=None, ignore=None, parent=None):
"""
Get all packages which are under dname. This is necessary for
Python 2.2's distutils. Pretty similar arguments to getDataFiles,
including 'parent'.
"""
parent = parent or ""
prefix = []
if parent:
... | [
"def",
"get_packages",
"(",
"dname",
",",
"pkgname",
"=",
"None",
",",
"results",
"=",
"None",
",",
"ignore",
"=",
"None",
",",
"parent",
"=",
"None",
")",
":",
"parent",
"=",
"parent",
"or",
"\"\"",
"prefix",
"=",
"[",
"]",
"if",
"parent",
":",
"p... | Get all packages which are under dname. This is necessary for
Python 2.2's distutils. Pretty similar arguments to getDataFiles,
including 'parent'. | [
"Get",
"all",
"packages",
"which",
"are",
"under",
"dname",
".",
"This",
"is",
"necessary",
"for",
"Python",
"2",
".",
"2",
"s",
"distutils",
".",
"Pretty",
"similar",
"arguments",
"to",
"getDataFiles",
"including",
"parent",
"."
] | 72adfce04c609d72f09ee2f21e9d31be12aefd80 | https://github.com/racker/python-twisted-service-registry-client/blob/72adfce04c609d72f09ee2f21e9d31be12aefd80/utils/dist.py#L65-L93 |
239,866 | racker/python-twisted-service-registry-client | utils/dist.py | get_data_files | def get_data_files(dname, ignore=None, parent=None):
"""
Get all the data files that should be included in this distutils Project.
'dname' should be the path to the package that you're distributing.
'ignore' is a list of sub-packages to ignore. This facilitates
disparate package hierarchies. Tha... | python | def get_data_files(dname, ignore=None, parent=None):
"""
Get all the data files that should be included in this distutils Project.
'dname' should be the path to the package that you're distributing.
'ignore' is a list of sub-packages to ignore. This facilitates
disparate package hierarchies. Tha... | [
"def",
"get_data_files",
"(",
"dname",
",",
"ignore",
"=",
"None",
",",
"parent",
"=",
"None",
")",
":",
"parent",
"=",
"parent",
"or",
"\".\"",
"ignore",
"=",
"ignore",
"or",
"[",
"]",
"result",
"=",
"[",
"]",
"for",
"directory",
",",
"subdirectories"... | Get all the data files that should be included in this distutils Project.
'dname' should be the path to the package that you're distributing.
'ignore' is a list of sub-packages to ignore. This facilitates
disparate package hierarchies. That's a fancy way of saying that
the 'twisted' package doesn't ... | [
"Get",
"all",
"the",
"data",
"files",
"that",
"should",
"be",
"included",
"in",
"this",
"distutils",
"Project",
"."
] | 72adfce04c609d72f09ee2f21e9d31be12aefd80 | https://github.com/racker/python-twisted-service-registry-client/blob/72adfce04c609d72f09ee2f21e9d31be12aefd80/utils/dist.py#L96-L134 |
239,867 | cltrudeau/wrench | wrench/logtools/srothandler.py | SizeRotatingFileHandler.acquire | def acquire(self):
""" Acquire thread and file locks. Re-opening log for 'degraded' mode.
"""
# handle thread lock
if Handler:
# under some tests Handler ends up being null due to instantiation
# order
Handler.acquire(self)
# Issue a file loc... | python | def acquire(self):
""" Acquire thread and file locks. Re-opening log for 'degraded' mode.
"""
# handle thread lock
if Handler:
# under some tests Handler ends up being null due to instantiation
# order
Handler.acquire(self)
# Issue a file loc... | [
"def",
"acquire",
"(",
"self",
")",
":",
"# handle thread lock",
"if",
"Handler",
":",
"# under some tests Handler ends up being null due to instantiation",
"# order",
"Handler",
".",
"acquire",
"(",
"self",
")",
"# Issue a file lock. (This is inefficient for multiple active thr... | Acquire thread and file locks. Re-opening log for 'degraded' mode. | [
"Acquire",
"thread",
"and",
"file",
"locks",
".",
"Re",
"-",
"opening",
"log",
"for",
"degraded",
"mode",
"."
] | bc231dd085050a63a87ff3eb8f0a863928f65a41 | https://github.com/cltrudeau/wrench/blob/bc231dd085050a63a87ff3eb8f0a863928f65a41/wrench/logtools/srothandler.py#L118-L144 |
239,868 | cltrudeau/wrench | wrench/logtools/srothandler.py | SizeRotatingFileHandler.release | def release(self):
""" Release file and thread locks. If in 'degraded' mode, close the
stream to reduce contention until the log files can be rotated. """
try:
if self._rotateFailed:
self._close()
except Exception:
self.handleError(NullLogRecord())... | python | def release(self):
""" Release file and thread locks. If in 'degraded' mode, close the
stream to reduce contention until the log files can be rotated. """
try:
if self._rotateFailed:
self._close()
except Exception:
self.handleError(NullLogRecord())... | [
"def",
"release",
"(",
"self",
")",
":",
"try",
":",
"if",
"self",
".",
"_rotateFailed",
":",
"self",
".",
"_close",
"(",
")",
"except",
"Exception",
":",
"self",
".",
"handleError",
"(",
"NullLogRecord",
"(",
")",
")",
"finally",
":",
"try",
":",
"i... | Release file and thread locks. If in 'degraded' mode, close the
stream to reduce contention until the log files can be rotated. | [
"Release",
"file",
"and",
"thread",
"locks",
".",
"If",
"in",
"degraded",
"mode",
"close",
"the",
"stream",
"to",
"reduce",
"contention",
"until",
"the",
"log",
"files",
"can",
"be",
"rotated",
"."
] | bc231dd085050a63a87ff3eb8f0a863928f65a41 | https://github.com/cltrudeau/wrench/blob/bc231dd085050a63a87ff3eb8f0a863928f65a41/wrench/logtools/srothandler.py#L147-L164 |
239,869 | cltrudeau/wrench | wrench/logtools/srothandler.py | SizeRotatingFileHandler._degrade | def _degrade(self, degrade, msg, *args):
""" Set degrade mode or not. Ignore msg. """
self._rotateFailed = degrade
del msg, args | python | def _degrade(self, degrade, msg, *args):
""" Set degrade mode or not. Ignore msg. """
self._rotateFailed = degrade
del msg, args | [
"def",
"_degrade",
"(",
"self",
",",
"degrade",
",",
"msg",
",",
"*",
"args",
")",
":",
"self",
".",
"_rotateFailed",
"=",
"degrade",
"del",
"msg",
",",
"args"
] | Set degrade mode or not. Ignore msg. | [
"Set",
"degrade",
"mode",
"or",
"not",
".",
"Ignore",
"msg",
"."
] | bc231dd085050a63a87ff3eb8f0a863928f65a41 | https://github.com/cltrudeau/wrench/blob/bc231dd085050a63a87ff3eb8f0a863928f65a41/wrench/logtools/srothandler.py#L179-L182 |
239,870 | gevious/flask_slither | flask_slither/decorators.py | crossdomain | def crossdomain(f):
"""This decorator sets the rules for the crossdomain request per http
method. The settings are taken from the actual resource itself, and
returned as per the CORS spec.
All CORS requests are rejected if the resource's `allow_methods`
doesn't include the 'OPTIONS' met... | python | def crossdomain(f):
"""This decorator sets the rules for the crossdomain request per http
method. The settings are taken from the actual resource itself, and
returned as per the CORS spec.
All CORS requests are rejected if the resource's `allow_methods`
doesn't include the 'OPTIONS' met... | [
"def",
"crossdomain",
"(",
"f",
")",
":",
"@",
"wraps",
"(",
"f",
")",
"def",
"decorator",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# TODO: if a non-cors request has the origin header, this will fail",
"if",
"not",
"self",
".",
"cor... | This decorator sets the rules for the crossdomain request per http
method. The settings are taken from the actual resource itself, and
returned as per the CORS spec.
All CORS requests are rejected if the resource's `allow_methods`
doesn't include the 'OPTIONS' method. | [
"This",
"decorator",
"sets",
"the",
"rules",
"for",
"the",
"crossdomain",
"request",
"per",
"http",
"method",
".",
"The",
"settings",
"are",
"taken",
"from",
"the",
"actual",
"resource",
"itself",
"and",
"returned",
"as",
"per",
"the",
"CORS",
"spec",
"."
] | bf1fd1e58224c19883f4b19c5f727f47ee9857da | https://github.com/gevious/flask_slither/blob/bf1fd1e58224c19883f4b19c5f727f47ee9857da/flask_slither/decorators.py#L7-L53 |
239,871 | mikicz/arca | arca/_arca.py | Arca.get_backend_instance | def get_backend_instance(self, backend: BackendDefinitionType) -> BaseBackend:
""" Returns a backend instance, either from the argument or from the settings.
:raise ArcaMisconfigured: If the instance is not a subclass of :class:`BaseBackend`
"""
if backend is NOT_SET:
backen... | python | def get_backend_instance(self, backend: BackendDefinitionType) -> BaseBackend:
""" Returns a backend instance, either from the argument or from the settings.
:raise ArcaMisconfigured: If the instance is not a subclass of :class:`BaseBackend`
"""
if backend is NOT_SET:
backen... | [
"def",
"get_backend_instance",
"(",
"self",
",",
"backend",
":",
"BackendDefinitionType",
")",
"->",
"BaseBackend",
":",
"if",
"backend",
"is",
"NOT_SET",
":",
"backend",
"=",
"self",
".",
"get_setting",
"(",
"\"backend\"",
",",
"\"arca.CurrentEnvironmentBackend\"",... | Returns a backend instance, either from the argument or from the settings.
:raise ArcaMisconfigured: If the instance is not a subclass of :class:`BaseBackend` | [
"Returns",
"a",
"backend",
"instance",
"either",
"from",
"the",
"argument",
"or",
"from",
"the",
"settings",
"."
] | e67fdc00be473ecf8ec16d024e1a3f2c47ca882c | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L61-L78 |
239,872 | mikicz/arca | arca/_arca.py | Arca.validate_repo_url | def validate_repo_url(self, repo: str):
""" Validates repo URL - if it's a valid git URL and if Arca can handle that type of repo URL
:raise ValueError: If the URL is not valid
"""
# that should match valid git repos
if not isinstance(repo, str) or not re.match(r"^(https?|file):... | python | def validate_repo_url(self, repo: str):
""" Validates repo URL - if it's a valid git URL and if Arca can handle that type of repo URL
:raise ValueError: If the URL is not valid
"""
# that should match valid git repos
if not isinstance(repo, str) or not re.match(r"^(https?|file):... | [
"def",
"validate_repo_url",
"(",
"self",
",",
"repo",
":",
"str",
")",
":",
"# that should match valid git repos",
"if",
"not",
"isinstance",
"(",
"repo",
",",
"str",
")",
"or",
"not",
"re",
".",
"match",
"(",
"r\"^(https?|file)://[\\w._\\-/~]*[.git]?/?$\"",
",",
... | Validates repo URL - if it's a valid git URL and if Arca can handle that type of repo URL
:raise ValueError: If the URL is not valid | [
"Validates",
"repo",
"URL",
"-",
"if",
"it",
"s",
"a",
"valid",
"git",
"URL",
"and",
"if",
"Arca",
"can",
"handle",
"that",
"type",
"of",
"repo",
"URL"
] | e67fdc00be473ecf8ec16d024e1a3f2c47ca882c | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L136-L143 |
239,873 | mikicz/arca | arca/_arca.py | Arca.repo_id | def repo_id(self, repo: str) -> str:
""" Returns an unique identifier from a repo URL for the folder the repo is gonna be pulled in.
"""
if repo.startswith("http"):
repo_id = re.sub(r"https?://(.www)?", "", repo)
repo_id = re.sub(r"\.git/?$", "", repo_id)
else:
... | python | def repo_id(self, repo: str) -> str:
""" Returns an unique identifier from a repo URL for the folder the repo is gonna be pulled in.
"""
if repo.startswith("http"):
repo_id = re.sub(r"https?://(.www)?", "", repo)
repo_id = re.sub(r"\.git/?$", "", repo_id)
else:
... | [
"def",
"repo_id",
"(",
"self",
",",
"repo",
":",
"str",
")",
"->",
"str",
":",
"if",
"repo",
".",
"startswith",
"(",
"\"http\"",
")",
":",
"repo_id",
"=",
"re",
".",
"sub",
"(",
"r\"https?://(.www)?\"",
",",
"\"\"",
",",
"repo",
")",
"repo_id",
"=",
... | Returns an unique identifier from a repo URL for the folder the repo is gonna be pulled in. | [
"Returns",
"an",
"unique",
"identifier",
"from",
"a",
"repo",
"URL",
"for",
"the",
"folder",
"the",
"repo",
"is",
"gonna",
"be",
"pulled",
"in",
"."
] | e67fdc00be473ecf8ec16d024e1a3f2c47ca882c | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L145-L163 |
239,874 | mikicz/arca | arca/_arca.py | Arca.pull_again | def pull_again(self, repo: Optional[str]=None, branch: Optional[str]=None) -> None:
""" When ``single_pull`` is enables, tells Arca to pull again.
If ``repo`` and ``branch`` are not specified, pull again everything.
:param repo: (Optional) Pull again all branches from a specified repository.
... | python | def pull_again(self, repo: Optional[str]=None, branch: Optional[str]=None) -> None:
""" When ``single_pull`` is enables, tells Arca to pull again.
If ``repo`` and ``branch`` are not specified, pull again everything.
:param repo: (Optional) Pull again all branches from a specified repository.
... | [
"def",
"pull_again",
"(",
"self",
",",
"repo",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"branch",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"None",
":",
"if",
"repo",
"is",
"None",
"and",
"branch",
"is",
"None",
":",
"s... | When ``single_pull`` is enables, tells Arca to pull again.
If ``repo`` and ``branch`` are not specified, pull again everything.
:param repo: (Optional) Pull again all branches from a specified repository.
:param branch: (Optional) When ``repo`` is specified, pull again only this branch from th... | [
"When",
"single_pull",
"is",
"enables",
"tells",
"Arca",
"to",
"pull",
"again",
"."
] | e67fdc00be473ecf8ec16d024e1a3f2c47ca882c | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L210-L231 |
239,875 | mikicz/arca | arca/_arca.py | Arca.cache_key | def cache_key(self, repo: str, branch: str, task: Task, git_repo: Repo) -> str:
""" Returns the key used for storing results in cache.
"""
return "{repo}_{branch}_{hash}_{task}".format(repo=self.repo_id(repo),
branch=branch,
... | python | def cache_key(self, repo: str, branch: str, task: Task, git_repo: Repo) -> str:
""" Returns the key used for storing results in cache.
"""
return "{repo}_{branch}_{hash}_{task}".format(repo=self.repo_id(repo),
branch=branch,
... | [
"def",
"cache_key",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"task",
":",
"Task",
",",
"git_repo",
":",
"Repo",
")",
"->",
"str",
":",
"return",
"\"{repo}_{branch}_{hash}_{task}\"",
".",
"format",
"(",
"repo",
"=",
"self",
... | Returns the key used for storing results in cache. | [
"Returns",
"the",
"key",
"used",
"for",
"storing",
"results",
"in",
"cache",
"."
] | e67fdc00be473ecf8ec16d024e1a3f2c47ca882c | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L346-L352 |
239,876 | mikicz/arca | arca/_arca.py | Arca.run | def run(self, repo: str, branch: str, task: Task, *,
depth: DepthDefinitionType=1,
reference: ReferenceDefinitionType=None
) -> Result:
""" Runs the ``task`` using the configured backend.
:param repo: Target git repository
:param branch: Target git branch
... | python | def run(self, repo: str, branch: str, task: Task, *,
depth: DepthDefinitionType=1,
reference: ReferenceDefinitionType=None
) -> Result:
""" Runs the ``task`` using the configured backend.
:param repo: Target git repository
:param branch: Target git branch
... | [
"def",
"run",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"task",
":",
"Task",
",",
"*",
",",
"depth",
":",
"DepthDefinitionType",
"=",
"1",
",",
"reference",
":",
"ReferenceDefinitionType",
"=",
"None",
")",
"->",
"Result",
... | Runs the ``task`` using the configured backend.
:param repo: Target git repository
:param branch: Target git branch
:param task: Task which will be run in the target repository
:param depth: How many commits back should the repo be cloned in case the target repository isn't cloned yet.
... | [
"Runs",
"the",
"task",
"using",
"the",
"configured",
"backend",
"."
] | e67fdc00be473ecf8ec16d024e1a3f2c47ca882c | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L354-L393 |
239,877 | mikicz/arca | arca/_arca.py | Arca.static_filename | def static_filename(self, repo: str, branch: str, relative_path: Union[str, Path], *,
depth: DepthDefinitionType=1,
reference: ReferenceDefinitionType=None
) -> Path:
"""
Returns an absolute path to where a file from the repo was cl... | python | def static_filename(self, repo: str, branch: str, relative_path: Union[str, Path], *,
depth: DepthDefinitionType=1,
reference: ReferenceDefinitionType=None
) -> Path:
"""
Returns an absolute path to where a file from the repo was cl... | [
"def",
"static_filename",
"(",
"self",
",",
"repo",
":",
"str",
",",
"branch",
":",
"str",
",",
"relative_path",
":",
"Union",
"[",
"str",
",",
"Path",
"]",
",",
"*",
",",
"depth",
":",
"DepthDefinitionType",
"=",
"1",
",",
"reference",
":",
"Reference... | Returns an absolute path to where a file from the repo was cloned to.
:param repo: Repo URL
:param branch: Branch name
:param relative_path: Relative path to the requested file
:param depth: See :meth:`run`
:param reference: See :meth:`run`
:return: Absolute path to the... | [
"Returns",
"an",
"absolute",
"path",
"to",
"where",
"a",
"file",
"from",
"the",
"repo",
"was",
"cloned",
"to",
"."
] | e67fdc00be473ecf8ec16d024e1a3f2c47ca882c | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L402-L440 |
239,878 | mikicz/arca | arca/_arca.py | Arca.validate_depth | def validate_depth(self, depth: DepthDefinitionType) -> Optional[int]:
""" Converts the depth to int and validates that the value can be used.
:raise ValueError: If the provided depth is not valid
"""
if depth is not None:
try:
depth = int(depth)
... | python | def validate_depth(self, depth: DepthDefinitionType) -> Optional[int]:
""" Converts the depth to int and validates that the value can be used.
:raise ValueError: If the provided depth is not valid
"""
if depth is not None:
try:
depth = int(depth)
... | [
"def",
"validate_depth",
"(",
"self",
",",
"depth",
":",
"DepthDefinitionType",
")",
"->",
"Optional",
"[",
"int",
"]",
":",
"if",
"depth",
"is",
"not",
"None",
":",
"try",
":",
"depth",
"=",
"int",
"(",
"depth",
")",
"except",
"ValueError",
":",
"rais... | Converts the depth to int and validates that the value can be used.
:raise ValueError: If the provided depth is not valid | [
"Converts",
"the",
"depth",
"to",
"int",
"and",
"validates",
"that",
"the",
"value",
"can",
"be",
"used",
"."
] | e67fdc00be473ecf8ec16d024e1a3f2c47ca882c | https://github.com/mikicz/arca/blob/e67fdc00be473ecf8ec16d024e1a3f2c47ca882c/arca/_arca.py#L442-L457 |
239,879 | brinkframework/brink | brink/fields.py | Field.validate | def validate(self, data):
"""
Runs all field validators.
"""
for v in self.validators:
v(self, data)
return data | python | def validate(self, data):
"""
Runs all field validators.
"""
for v in self.validators:
v(self, data)
return data | [
"def",
"validate",
"(",
"self",
",",
"data",
")",
":",
"for",
"v",
"in",
"self",
".",
"validators",
":",
"v",
"(",
"self",
",",
"data",
")",
"return",
"data"
] | Runs all field validators. | [
"Runs",
"all",
"field",
"validators",
"."
] | e837ee35a57140994b4e761cc756af172e5d5aa1 | https://github.com/brinkframework/brink/blob/e837ee35a57140994b4e761cc756af172e5d5aa1/brink/fields.py#L88-L94 |
239,880 | 6809/dragonlib | dragonlib/dragon32/pygments_lexer.py | list_styles | def list_styles(style_name):
"""
Just list all different styles entries
"""
style = get_style_by_name(style_name)
keys = list(style)[0][1]
Styles = namedtuple("Style", keys)
existing_styles = {}
for ttype, ndef in style:
s = Styles(**ndef)
if s in existing_styles:
... | python | def list_styles(style_name):
"""
Just list all different styles entries
"""
style = get_style_by_name(style_name)
keys = list(style)[0][1]
Styles = namedtuple("Style", keys)
existing_styles = {}
for ttype, ndef in style:
s = Styles(**ndef)
if s in existing_styles:
... | [
"def",
"list_styles",
"(",
"style_name",
")",
":",
"style",
"=",
"get_style_by_name",
"(",
"style_name",
")",
"keys",
"=",
"list",
"(",
"style",
")",
"[",
"0",
"]",
"[",
"1",
"]",
"Styles",
"=",
"namedtuple",
"(",
"\"Style\"",
",",
"keys",
")",
"existi... | Just list all different styles entries | [
"Just",
"list",
"all",
"different",
"styles",
"entries"
] | faa4011e76c5857db96efdb4199e2fd49711e999 | https://github.com/6809/dragonlib/blob/faa4011e76c5857db96efdb4199e2fd49711e999/dragonlib/dragon32/pygments_lexer.py#L87-L108 |
239,881 | azavea/django-tinsel | django_tinsel/utils.py | decorate | def decorate(*reversed_views):
"""
provide a syntax decorating views without nested calls.
instead of:
json_api_call(etag(<hash_fn>)(<view_fn>)))
you can write:
decorate(json_api_call, etag(<hash_fn>), <view_fn>)
"""
fns = reversed_views[::-1]
view = fns[0]
for wrapper in fns[1... | python | def decorate(*reversed_views):
"""
provide a syntax decorating views without nested calls.
instead of:
json_api_call(etag(<hash_fn>)(<view_fn>)))
you can write:
decorate(json_api_call, etag(<hash_fn>), <view_fn>)
"""
fns = reversed_views[::-1]
view = fns[0]
for wrapper in fns[1... | [
"def",
"decorate",
"(",
"*",
"reversed_views",
")",
":",
"fns",
"=",
"reversed_views",
"[",
":",
":",
"-",
"1",
"]",
"view",
"=",
"fns",
"[",
"0",
"]",
"for",
"wrapper",
"in",
"fns",
"[",
"1",
":",
"]",
":",
"view",
"=",
"wrapper",
"(",
"view",
... | provide a syntax decorating views without nested calls.
instead of:
json_api_call(etag(<hash_fn>)(<view_fn>)))
you can write:
decorate(json_api_call, etag(<hash_fn>), <view_fn>) | [
"provide",
"a",
"syntax",
"decorating",
"views",
"without",
"nested",
"calls",
"."
] | ef9e70750d98907b8f72248c1ba4c4423f04f60f | https://github.com/azavea/django-tinsel/blob/ef9e70750d98907b8f72248c1ba4c4423f04f60f/django_tinsel/utils.py#L15-L29 |
239,882 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/StringValueMap.py | StringValueMap.set_as_object | def set_as_object(self, *args):
"""
Sets a new value to map element specified by its index.
When the index is not defined, it resets the entire map value.
This method has double purpose because method overrides are not supported in JavaScript.
:param args: objects to set
... | python | def set_as_object(self, *args):
"""
Sets a new value to map element specified by its index.
When the index is not defined, it resets the entire map value.
This method has double purpose because method overrides are not supported in JavaScript.
:param args: objects to set
... | [
"def",
"set_as_object",
"(",
"self",
",",
"*",
"args",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"self",
".",
"set_as_map",
"(",
"args",
"[",
"0",
"]",
")",
"elif",
"len",
"(",
"args",
")",
"==",
"2",
":",
"self",
".",
"put",
"... | Sets a new value to map element specified by its index.
When the index is not defined, it resets the entire map value.
This method has double purpose because method overrides are not supported in JavaScript.
:param args: objects to set | [
"Sets",
"a",
"new",
"value",
"to",
"map",
"element",
"specified",
"by",
"its",
"index",
".",
"When",
"the",
"index",
"is",
"not",
"defined",
"it",
"resets",
"the",
"entire",
"map",
"value",
".",
"This",
"method",
"has",
"double",
"purpose",
"because",
"m... | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/StringValueMap.py#L114-L125 |
239,883 | pip-services3-python/pip-services3-commons-python | pip_services3_commons/data/StringValueMap.py | StringValueMap.from_string | def from_string(line):
"""
Parses semicolon-separated key-value pairs and returns them as a StringValueMap.
:param line: semicolon-separated key-value list to initialize StringValueMap.
:return: a newly created StringValueMap.
"""
result = StringValueMap()
... | python | def from_string(line):
"""
Parses semicolon-separated key-value pairs and returns them as a StringValueMap.
:param line: semicolon-separated key-value list to initialize StringValueMap.
:return: a newly created StringValueMap.
"""
result = StringValueMap()
... | [
"def",
"from_string",
"(",
"line",
")",
":",
"result",
"=",
"StringValueMap",
"(",
")",
"if",
"line",
"==",
"None",
"or",
"len",
"(",
"line",
")",
"==",
"0",
":",
"return",
"result",
"tokens",
"=",
"str",
"(",
"line",
")",
".",
"split",
"(",
"';'",... | Parses semicolon-separated key-value pairs and returns them as a StringValueMap.
:param line: semicolon-separated key-value list to initialize StringValueMap.
:return: a newly created StringValueMap. | [
"Parses",
"semicolon",
"-",
"separated",
"key",
"-",
"value",
"pairs",
"and",
"returns",
"them",
"as",
"a",
"StringValueMap",
"."
] | 22cbbb3e91e49717f65c083d36147fdb07ba9e3b | https://github.com/pip-services3-python/pip-services3-commons-python/blob/22cbbb3e91e49717f65c083d36147fdb07ba9e3b/pip_services3_commons/data/StringValueMap.py#L508-L530 |
239,884 | 20c/django-handleref | django_handleref/models.py | HandleRefModel.delete | def delete(self, hard=False):
"""
Override the vanilla delete functionality to soft-delete
instead. Soft-delete is accomplished by setting the
status field to "deleted"
Arguments:
hard <bool=False> if true, do a hard delete instead, effectively
removing the obj... | python | def delete(self, hard=False):
"""
Override the vanilla delete functionality to soft-delete
instead. Soft-delete is accomplished by setting the
status field to "deleted"
Arguments:
hard <bool=False> if true, do a hard delete instead, effectively
removing the obj... | [
"def",
"delete",
"(",
"self",
",",
"hard",
"=",
"False",
")",
":",
"if",
"hard",
":",
"return",
"models",
".",
"Model",
".",
"delete",
"(",
"self",
")",
"self",
".",
"status",
"=",
"\"deleted\"",
"self",
".",
"save",
"(",
")",
"for",
"key",
"in",
... | Override the vanilla delete functionality to soft-delete
instead. Soft-delete is accomplished by setting the
status field to "deleted"
Arguments:
hard <bool=False> if true, do a hard delete instead, effectively
removing the object from the database | [
"Override",
"the",
"vanilla",
"delete",
"functionality",
"to",
"soft",
"-",
"delete",
"instead",
".",
"Soft",
"-",
"delete",
"is",
"accomplished",
"by",
"setting",
"the",
"status",
"field",
"to",
"deleted"
] | ff4ca6ad39c68947e8a6d8e478daae4cd43663ca | https://github.com/20c/django-handleref/blob/ff4ca6ad39c68947e8a6d8e478daae4cd43663ca/django_handleref/models.py#L118-L145 |
239,885 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_trainer_from_username | def get_trainer_from_username(self, username, detail=False):
"""Returns a Trainer object from a Trainers username"""
params = {
'detail': '1' if detail is True else '0',
'q': username
}
r = requests.get(api_url+'trainers/', params=params, headers=self.headers)
print(request_status(r))
try:
r = r.js... | python | def get_trainer_from_username(self, username, detail=False):
"""Returns a Trainer object from a Trainers username"""
params = {
'detail': '1' if detail is True else '0',
'q': username
}
r = requests.get(api_url+'trainers/', params=params, headers=self.headers)
print(request_status(r))
try:
r = r.js... | [
"def",
"get_trainer_from_username",
"(",
"self",
",",
"username",
",",
"detail",
"=",
"False",
")",
":",
"params",
"=",
"{",
"'detail'",
":",
"'1'",
"if",
"detail",
"is",
"True",
"else",
"'0'",
",",
"'q'",
":",
"username",
"}",
"r",
"=",
"requests",
".... | Returns a Trainer object from a Trainers username | [
"Returns",
"a",
"Trainer",
"object",
"from",
"a",
"Trainers",
"username"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L26-L38 |
239,886 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.discord_to_users | def discord_to_users(self, memberlist):
"""
expects a list of discord.py user objects
returns a list of TrainerDex.py user objects
"""
_memberlist = self.get_discord_user(x.id for x in memberlist)
return list(set(x.owner() for x in _memberlist)) | python | def discord_to_users(self, memberlist):
"""
expects a list of discord.py user objects
returns a list of TrainerDex.py user objects
"""
_memberlist = self.get_discord_user(x.id for x in memberlist)
return list(set(x.owner() for x in _memberlist)) | [
"def",
"discord_to_users",
"(",
"self",
",",
"memberlist",
")",
":",
"_memberlist",
"=",
"self",
".",
"get_discord_user",
"(",
"x",
".",
"id",
"for",
"x",
"in",
"memberlist",
")",
"return",
"list",
"(",
"set",
"(",
"x",
".",
"owner",
"(",
")",
"for",
... | expects a list of discord.py user objects
returns a list of TrainerDex.py user objects | [
"expects",
"a",
"list",
"of",
"discord",
".",
"py",
"user",
"objects",
"returns",
"a",
"list",
"of",
"TrainerDex",
".",
"py",
"user",
"objects"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L40-L46 |
239,887 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.create_trainer | def create_trainer(self, username, team, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=True, daily_goal=None, total_goal=None, prefered=True, account=None, verified=False):
"""Add a trainer to the database"""
args = locals()
url = api_url+'trainers/'
payload = {
'use... | python | def create_trainer(self, username, team, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=True, daily_goal=None, total_goal=None, prefered=True, account=None, verified=False):
"""Add a trainer to the database"""
args = locals()
url = api_url+'trainers/'
payload = {
'use... | [
"def",
"create_trainer",
"(",
"self",
",",
"username",
",",
"team",
",",
"start_date",
"=",
"None",
",",
"has_cheated",
"=",
"None",
",",
"last_cheated",
"=",
"None",
",",
"currently_cheats",
"=",
"None",
",",
"statistics",
"=",
"True",
",",
"daily_goal",
... | Add a trainer to the database | [
"Add",
"a",
"trainer",
"to",
"the",
"database"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L48-L71 |
239,888 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.update_trainer | def update_trainer(self, trainer, username=None, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=None, daily_goal=None, total_goal=None, prefered=None):
"""Update parts of a trainer in a database"""
args = locals()
if not isinstance(trainer, Trainer):
raise ValueError
... | python | def update_trainer(self, trainer, username=None, start_date=None, has_cheated=None, last_cheated=None, currently_cheats=None, statistics=None, daily_goal=None, total_goal=None, prefered=None):
"""Update parts of a trainer in a database"""
args = locals()
if not isinstance(trainer, Trainer):
raise ValueError
... | [
"def",
"update_trainer",
"(",
"self",
",",
"trainer",
",",
"username",
"=",
"None",
",",
"start_date",
"=",
"None",
",",
"has_cheated",
"=",
"None",
",",
"last_cheated",
"=",
"None",
",",
"currently_cheats",
"=",
"None",
",",
"statistics",
"=",
"None",
","... | Update parts of a trainer in a database | [
"Update",
"parts",
"of",
"a",
"trainer",
"in",
"a",
"database"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L73-L92 |
239,889 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.import_discord_user | def import_discord_user(self, uid, user):
"""Add a discord user to the database if not already present, get if is present. """
url = api_url+'users/social/'
payload = {
'user': int(user),
'provider': 'discord',
'uid': str(uid)
}
print(json.dumps(payload))
r = requests.put(url, data=json.dumps(paylo... | python | def import_discord_user(self, uid, user):
"""Add a discord user to the database if not already present, get if is present. """
url = api_url+'users/social/'
payload = {
'user': int(user),
'provider': 'discord',
'uid': str(uid)
}
print(json.dumps(payload))
r = requests.put(url, data=json.dumps(paylo... | [
"def",
"import_discord_user",
"(",
"self",
",",
"uid",
",",
"user",
")",
":",
"url",
"=",
"api_url",
"+",
"'users/social/'",
"payload",
"=",
"{",
"'user'",
":",
"int",
"(",
"user",
")",
",",
"'provider'",
":",
"'discord'",
",",
"'uid'",
":",
"str",
"("... | Add a discord user to the database if not already present, get if is present. | [
"Add",
"a",
"discord",
"user",
"to",
"the",
"database",
"if",
"not",
"already",
"present",
"get",
"if",
"is",
"present",
"."
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L121-L133 |
239,890 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.create_user | def create_user(self, username, first_name=None, last_name=None):
"""
Creates a new user object on database
Returns the User Object. Must be linked to a new trainer soon after
"""
url = api_url+'users/'
payload = {
'username':username
}
if first_name:
payload['first_name'] = first_name
if las... | python | def create_user(self, username, first_name=None, last_name=None):
"""
Creates a new user object on database
Returns the User Object. Must be linked to a new trainer soon after
"""
url = api_url+'users/'
payload = {
'username':username
}
if first_name:
payload['first_name'] = first_name
if las... | [
"def",
"create_user",
"(",
"self",
",",
"username",
",",
"first_name",
"=",
"None",
",",
"last_name",
"=",
"None",
")",
":",
"url",
"=",
"api_url",
"+",
"'users/'",
"payload",
"=",
"{",
"'username'",
":",
"username",
"}",
"if",
"first_name",
":",
"payloa... | Creates a new user object on database
Returns the User Object. Must be linked to a new trainer soon after | [
"Creates",
"a",
"new",
"user",
"object",
"on",
"database",
"Returns",
"the",
"User",
"Object",
".",
"Must",
"be",
"linked",
"to",
"a",
"new",
"trainer",
"soon",
"after"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L135-L152 |
239,891 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.update_user | def update_user(self, user, username=None, first_name=None, last_name=None):
"""Update user info"""
if not isinstance(user, User):
raise ValueError
args = locals()
url = api_url+'users/'+str(user.id)+'/'
payload = {}
for i in args:
if args[i] is not None and i not in ['self', 'user']:
payload[i... | python | def update_user(self, user, username=None, first_name=None, last_name=None):
"""Update user info"""
if not isinstance(user, User):
raise ValueError
args = locals()
url = api_url+'users/'+str(user.id)+'/'
payload = {}
for i in args:
if args[i] is not None and i not in ['self', 'user']:
payload[i... | [
"def",
"update_user",
"(",
"self",
",",
"user",
",",
"username",
"=",
"None",
",",
"first_name",
"=",
"None",
",",
"last_name",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"user",
",",
"User",
")",
":",
"raise",
"ValueError",
"args",
"=",
... | Update user info | [
"Update",
"user",
"info"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L154-L168 |
239,892 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_trainer | def get_trainer(self, id_, respect_privacy=True, detail=True):
"""Returns the Trainer object for the ID"""
parameters = {}
if respect_privacy is False:
parameters['statistics'] = 'force'
if detail is False:
parameters['detail'] = 'low'
r = requests.get(api_url+'trainers/'+str(id_)+'/', headers=se... | python | def get_trainer(self, id_, respect_privacy=True, detail=True):
"""Returns the Trainer object for the ID"""
parameters = {}
if respect_privacy is False:
parameters['statistics'] = 'force'
if detail is False:
parameters['detail'] = 'low'
r = requests.get(api_url+'trainers/'+str(id_)+'/', headers=se... | [
"def",
"get_trainer",
"(",
"self",
",",
"id_",
",",
"respect_privacy",
"=",
"True",
",",
"detail",
"=",
"True",
")",
":",
"parameters",
"=",
"{",
"}",
"if",
"respect_privacy",
"is",
"False",
":",
"parameters",
"[",
"'statistics'",
"]",
"=",
"'force'",
"i... | Returns the Trainer object for the ID | [
"Returns",
"the",
"Trainer",
"object",
"for",
"the",
"ID"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L170-L182 |
239,893 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_detailed_update | def get_detailed_update(self, uid, uuid):
"""Returns the update object for the ID"""
r = requests.get(api_url+'users/'+str(uid)+'/update/'+str(uuid)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return Update(r.json()) | python | def get_detailed_update(self, uid, uuid):
"""Returns the update object for the ID"""
r = requests.get(api_url+'users/'+str(uid)+'/update/'+str(uuid)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return Update(r.json()) | [
"def",
"get_detailed_update",
"(",
"self",
",",
"uid",
",",
"uuid",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"api_url",
"+",
"'users/'",
"+",
"str",
"(",
"uid",
")",
"+",
"'/update/'",
"+",
"str",
"(",
"uuid",
")",
"+",
"'/'",
",",
"headers... | Returns the update object for the ID | [
"Returns",
"the",
"update",
"object",
"for",
"the",
"ID"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L184-L190 |
239,894 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_user | def get_user(self, uid):
"""Returns the User object for the ID"""
r = requests.get(api_url+'users/'+str(uid)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return User(r.json()) | python | def get_user(self, uid):
"""Returns the User object for the ID"""
r = requests.get(api_url+'users/'+str(uid)+'/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
return User(r.json()) | [
"def",
"get_user",
"(",
"self",
",",
"uid",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"api_url",
"+",
"'users/'",
"+",
"str",
"(",
"uid",
")",
"+",
"'/'",
",",
"headers",
"=",
"self",
".",
"headers",
")",
"print",
"(",
"request_status",
"(",... | Returns the User object for the ID | [
"Returns",
"the",
"User",
"object",
"for",
"the",
"ID"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L192-L198 |
239,895 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_discord_user | def get_discord_user(self, uid=None, user=None, trainer=None):
"""Returns the DiscordUsers object for the ID
Expects list of string representions discord IDs, trainer IDs or user IDs
Returns DiscordUser objects
"""
uids = ','.join(uid) if uid else None
users =','.join(user) if user else None
trainers = ',... | python | def get_discord_user(self, uid=None, user=None, trainer=None):
"""Returns the DiscordUsers object for the ID
Expects list of string representions discord IDs, trainer IDs or user IDs
Returns DiscordUser objects
"""
uids = ','.join(uid) if uid else None
users =','.join(user) if user else None
trainers = ',... | [
"def",
"get_discord_user",
"(",
"self",
",",
"uid",
"=",
"None",
",",
"user",
"=",
"None",
",",
"trainer",
"=",
"None",
")",
":",
"uids",
"=",
"','",
".",
"join",
"(",
"uid",
")",
"if",
"uid",
"else",
"None",
"users",
"=",
"','",
".",
"join",
"("... | Returns the DiscordUsers object for the ID
Expects list of string representions discord IDs, trainer IDs or user IDs
Returns DiscordUser objects | [
"Returns",
"the",
"DiscordUsers",
"object",
"for",
"the",
"ID",
"Expects",
"list",
"of",
"string",
"representions",
"discord",
"IDs",
"trainer",
"IDs",
"or",
"user",
"IDs",
"Returns",
"DiscordUser",
"objects"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L200-L221 |
239,896 | TrainerDex/TrainerDex.py | trainerdex/client.py | Client.get_all_users | def get_all_users(self):
"""Returns all the users"""
r = requests.get(api_url+'users/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
output = r.json()
result = []
for x in output:
result.append(User(x))
return result | python | def get_all_users(self):
"""Returns all the users"""
r = requests.get(api_url+'users/', headers=self.headers)
print(request_status(r))
r.raise_for_status()
output = r.json()
result = []
for x in output:
result.append(User(x))
return result | [
"def",
"get_all_users",
"(",
"self",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"api_url",
"+",
"'users/'",
",",
"headers",
"=",
"self",
".",
"headers",
")",
"print",
"(",
"request_status",
"(",
"r",
")",
")",
"r",
".",
"raise_for_status",
"(",
... | Returns all the users | [
"Returns",
"all",
"the",
"users"
] | a693e1321abf2825f74bcbf29f0800f0c6835b62 | https://github.com/TrainerDex/TrainerDex.py/blob/a693e1321abf2825f74bcbf29f0800f0c6835b62/trainerdex/client.py#L223-L233 |
239,897 | syndbg/demonoid-api | demonoid/urls.py | Url.combine | def combine(self, path):
"""
Gives a combined `self.BASE_URL` with the given `path`.
Used to build urls without modifying the current `self.path`.
Handles conflicts of trailing or preceding slashes.
:param str path: `path` to append
:return: combined `self.base_url` and ... | python | def combine(self, path):
"""
Gives a combined `self.BASE_URL` with the given `path`.
Used to build urls without modifying the current `self.path`.
Handles conflicts of trailing or preceding slashes.
:param str path: `path` to append
:return: combined `self.base_url` and ... | [
"def",
"combine",
"(",
"self",
",",
"path",
")",
":",
"url",
"=",
"self",
".",
"base_url",
"if",
"url",
".",
"endswith",
"(",
"'/'",
")",
"and",
"path",
".",
"startswith",
"(",
"'/'",
")",
":",
"url",
"+=",
"path",
"[",
"1",
":",
"]",
"elif",
"... | Gives a combined `self.BASE_URL` with the given `path`.
Used to build urls without modifying the current `self.path`.
Handles conflicts of trailing or preceding slashes.
:param str path: `path` to append
:return: combined `self.base_url` and given `path`.
:rtype: str | [
"Gives",
"a",
"combined",
"self",
".",
"BASE_URL",
"with",
"the",
"given",
"path",
".",
"Used",
"to",
"build",
"urls",
"without",
"modifying",
"the",
"current",
"self",
".",
"path",
".",
"Handles",
"conflicts",
"of",
"trailing",
"or",
"preceding",
"slashes",... | 518aa389ac91b5243b92fc19923103f31041a61e | https://github.com/syndbg/demonoid-api/blob/518aa389ac91b5243b92fc19923103f31041a61e/demonoid/urls.py#L69-L86 |
239,898 | syndbg/demonoid-api | demonoid/urls.py | Url.update_DOM | def update_DOM(self):
"""
Makes a request and updates `self._DOM`.
Worth using only if you manually change `self.base_url` or `self.path`.
:return: self
:rtype: Url
"""
response = self.fetch()
self._DOM = html.fromstring(response.text)
return self | python | def update_DOM(self):
"""
Makes a request and updates `self._DOM`.
Worth using only if you manually change `self.base_url` or `self.path`.
:return: self
:rtype: Url
"""
response = self.fetch()
self._DOM = html.fromstring(response.text)
return self | [
"def",
"update_DOM",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"fetch",
"(",
")",
"self",
".",
"_DOM",
"=",
"html",
".",
"fromstring",
"(",
"response",
".",
"text",
")",
"return",
"self"
] | Makes a request and updates `self._DOM`.
Worth using only if you manually change `self.base_url` or `self.path`.
:return: self
:rtype: Url | [
"Makes",
"a",
"request",
"and",
"updates",
"self",
".",
"_DOM",
".",
"Worth",
"using",
"only",
"if",
"you",
"manually",
"change",
"self",
".",
"base_url",
"or",
"self",
".",
"path",
"."
] | 518aa389ac91b5243b92fc19923103f31041a61e | https://github.com/syndbg/demonoid-api/blob/518aa389ac91b5243b92fc19923103f31041a61e/demonoid/urls.py#L100-L110 |
239,899 | syndbg/demonoid-api | demonoid/urls.py | Url.fetch | def fetch(self):
"""
Makes a request to combined url with `self._params` as parameters.
If the server at combined url responds with Client or Server error, raises an exception.
:return: the response from combined url
:rtype: requests.models.Response
"""
response ... | python | def fetch(self):
"""
Makes a request to combined url with `self._params` as parameters.
If the server at combined url responds with Client or Server error, raises an exception.
:return: the response from combined url
:rtype: requests.models.Response
"""
response ... | [
"def",
"fetch",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"_session",
".",
"get",
"(",
"self",
".",
"url",
",",
"params",
"=",
"self",
".",
"params",
")",
"response",
".",
"raise_for_status",
"(",
")",
"return",
"response"
] | Makes a request to combined url with `self._params` as parameters.
If the server at combined url responds with Client or Server error, raises an exception.
:return: the response from combined url
:rtype: requests.models.Response | [
"Makes",
"a",
"request",
"to",
"combined",
"url",
"with",
"self",
".",
"_params",
"as",
"parameters",
".",
"If",
"the",
"server",
"at",
"combined",
"url",
"responds",
"with",
"Client",
"or",
"Server",
"error",
"raises",
"an",
"exception",
"."
] | 518aa389ac91b5243b92fc19923103f31041a61e | https://github.com/syndbg/demonoid-api/blob/518aa389ac91b5243b92fc19923103f31041a61e/demonoid/urls.py#L112-L122 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.