INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Add the impact severity for the most severe consequence
Args:
variant_obj (puzzle.models.Variant) | def _add_impact_severity(self, variant_obj):
"""Add the impact severity for the most severe consequence
Args:
variant_obj (puzzle.models.Variant)
"""
if variant_obj.most_severe_consequence:
variant_obj.impact_severity = IMPACT_SEVERITIES.... |
Return the class name for the current frame.
If the result is ** None ** means that the call is made from a module. | def check_class():
"""
Return the class name for the current frame.
If the result is ** None ** means that the call is made from a module.
"""
# get frames
frames = inspect.stack()
cls = None
# should be the third frame
# 0: this function
# 1: function/decorator
# 2: class th... |
colleziona elementi per le liste. | def collect_appendvars(ap_, cls):
"""
colleziona elementi per le liste.
"""
for key, value in cls.__dict__.items():
if key.startswith('appendvars_'):
varname = key[11:]
if varname not in ap_.appendvars:
ap_.appendvars[varname] = []
if value not... |
Windows non traduce automaticamente i wildchars così lo facciamo
a mano tramite glob.
:param value: Espressione glob per la lista dei files.
:type value: str | def isglob(value):
"""
Windows non traduce automaticamente i wildchars così lo facciamo
a mano tramite glob.
:param value: Espressione glob per la lista dei files.
:type value: str
"""
if os.name == 'nt':
if isinstance(value, basestring):
value = glob.glob(value)
ret... |
Ritorna True o False in caso venga passata la stringa 'true' o 'false'
(o 't' o 'f') altrimenti ritorna una stringa.
:param value: Stringa da analizzare.
:type value: str | def string_or_bool(value):
"""
Ritorna True o False in caso venga passata la stringa 'true' o 'false'
(o 't' o 'f') altrimenti ritorna una stringa.
:param value: Stringa da analizzare.
:type value: str
"""
if value.lower() in ['t', 'true']:
value = True
elif value.lower() in ['f... |
Verifica se ci sono shared. | def has_shared(arg, shared):
"""
Verifica se ci sono shared.
"""
try:
if isinstance(shared, list):
shared_arguments = shared
else:
shared_arguments = shared.__shared_arguments__
for idx, (args, kwargs) in enumerate(shared_arguments):
arg_name =... |
Verifica se ci sono argument con la classe. | def has_argument(arg, arguments):
"""
Verifica se ci sono argument con la classe.
"""
try:
if not isinstance(arguments, list):
arguments = arguments.__arguments__
for idx, (args, kwargs) in enumerate(arguments):
arg_name = kwargs.get(
'dest', args[... |
Recupera gli argomenti dalla funzione stessa. | def get_functarguments(func):
"""
Recupera gli argomenti dalla funzione stessa.
"""
argspec = inspect.getargspec(func)
if argspec.defaults is not None:
args = argspec.args[:-len(argspec.defaults)]
kwargs = dict(
zip(argspec.args[-len(argspec.defaults):], argspec.defaults)... |
Imposta il parser. | def get_parser(func, parent):
"""
Imposta il parser.
"""
parser = parent.add_parser(func.__cmd_name__, help=func.__doc__)
for args, kwargs in func.__arguments__:
parser.add_argument(*args, **kwargs)
return parser |
return shared. | def get_shared(func):
"""
return shared.
"""
shared = []
if not hasattr(func, '__cls__'):
return shared
if not hasattr(func.__cls__, '__shared_arguments__'):
return shared
if hasattr(func, '__no_share__'):
if func.__no_share__ is True:
return shared
... |
Set subcommands. | def set_subcommands(func, parser):
"""
Set subcommands.
"""
if hasattr(func, '__subcommands__') and func.__subcommands__:
sub_parser = parser.add_subparsers(
title=SUBCOMMANDS_LIST_TITLE, dest='subcommand',
description=SUBCOMMANDS_LIST_DESCRIPTION.format(
... |
check know args in argv. | def check_help():
"""
check know args in argv.
"""
# know arguments
know = set(('-h', '--help', '-v', '--version'))
# arguments
args = set(sys.argv[1:])
# returns True if there is at least one known argument in arguments
return len(know.intersection(args)) > 0 |
Loads the data into Data() - renumbers the residues, imports mol file in rdkit.
If there are trajectories to analyse, the residues that will be plotted are determined
from Residence_time() analysis. | def data_input_and_res_time_analysis(self):
"""
Loads the data into Data() - renumbers the residues, imports mol file in rdkit.
If there are trajectories to analyse, the residues that will be plotted are determined
from Residence_time() analysis.
"""
self.topol_data = Dat... |
The classes and function that deal with protein-ligand interaction analysis. | def analysis_of_prot_lig_interactions(self):
"""
The classes and function that deal with protein-ligand interaction analysis.
"""
self.hbonds = HBonds(self.topol_data,self.trajectory,self.start,self.end,self.skip,self.analysis_cutoff,distance=3)
self.pistacking = PiStacking(self.... |
Draws molecule through Molecule() and then puts the final figure together with
Figure(). | def draw_figure(self,data_for_color=None, data_for_size=None, data_for_clouds=None, rot_bonds=None, color_for_clouds="Blues", color_type_color="viridis"):
"""
Draws molecule through Molecule() and then puts the final figure together with
Figure().
"""
self.molecule = Molecule(sel... |
Saves all output from LINTools run in a single directory named after the output name. | def save_files(self):
"""Saves all output from LINTools run in a single directory named after the output name."""
while True:
try:
os.mkdir(self.output_name)
except Exception as e:
self.output_name = raw_input("This directory already exists - pleas... |
Removes intermediate files. | def remove_files(self):
"""Removes intermediate files."""
file_list = ["molecule.svg","lig.pdb","HIS.pdb","PHE.pdb","TRP.pdb","TYR.pdb","lig.mol","test.xtc"]
for residue in self.topol_data.dict_of_plotted_res.keys():
file_list.append(residue[1]+residue[2]+".svg")
for f in fil... |
Return current readings, as a dictionary with:
duration -- the duration of the measurements, in seconds;
cpm -- the radiation count by minute;
uSvh -- the radiation dose, exprimed in Sievert per house (uSv/h);
uSvhError -- the incertitude for the radiation dose. | def status(self):
"""Return current readings, as a dictionary with:
duration -- the duration of the measurements, in seconds;
cpm -- the radiation count by minute;
uSvh -- the radiation dose, exprimed in Sievert per house (uSv/h);
uSvhError -- the incertitude for ... |
Initialize the driver by setting up GPIO interrupts
and periodic statistics processing. | def setup(self):
"""Initialize the driver by setting up GPIO interrupts
and periodic statistics processing. """
# Initialize the statistics variables.
self.radiation_count = 0
self.noise_count = 0
self.count = 0
# Initialize count_history[].
self.count_his... |
Scrape a MLBAM Data
:param start: Start Day(YYYYMMDD)
:param end: End Day(YYYYMMDD)
:param out: Output directory(default:"../output/mlb") | def main(start, end, out):
"""
Scrape a MLBAM Data
:param start: Start Day(YYYYMMDD)
:param end: End Day(YYYYMMDD)
:param out: Output directory(default:"../output/mlb")
"""
try:
logging.basicConfig(level=logging.WARNING)
MlbAm.scrape(start, end, out)
except MlbAmBadParame... |
Load a variant source into the database.
If no database was found run puzzle init first.
1. VCF: If a vcf file is used it can be loaded with a ped file
2. GEMINI: Ped information will be retreived from the gemini db | def load(ctx, variant_source, family_file, family_type, root):
"""
Load a variant source into the database.
If no database was found run puzzle init first.
1. VCF: If a vcf file is used it can be loaded with a ped file
2. GEMINI: Ped information will be retreived from the gemini db
"""
roo... |
>>> from Redy.Tools.Hash import hash_from_stream
>>> s = iter((1, 2, 3))
>>> assert hash_from_stream(3, iter(s)) == hash((1, 2, 3)) | def hash_from_stream(n, hash_stream):
"""
>>> from Redy.Tools.Hash import hash_from_stream
>>> s = iter((1, 2, 3))
>>> assert hash_from_stream(3, iter(s)) == hash((1, 2, 3))
"""
x = to_int64(0x345678)
multiplied = to_int64(1000003)
for i in range(n - 1, -1, -1):
h = next(hash_st... |
Retrieve deal's associated contacts
Returns all deal associated contacts
:calls: ``get /deals/{deal_id}/associated_contacts``
:param int deal_id: Unique identifier of a Deal.
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-sty... | def list(self, deal_id, **params):
"""
Retrieve deal's associated contacts
Returns all deal associated contacts
:calls: ``get /deals/{deal_id}/associated_contacts``
:param int deal_id: Unique identifier of a Deal.
:param dict params: (optional) Search options.
:... |
Create an associated contact
Creates a deal's associated contact and its role
If the specified deal or contact does not exist, the request will return an error
:calls: ``post /deals/{deal_id}/associated_contacts``
:param int deal_id: Unique identifier of a Deal.
:param tuple *a... | def create(self, deal_id, *args, **kwargs):
"""
Create an associated contact
Creates a deal's associated contact and its role
If the specified deal or contact does not exist, the request will return an error
:calls: ``post /deals/{deal_id}/associated_contacts``
:param i... |
Remove an associated contact
Remove a deal's associated contact
If a deal with the supplied unique identifier does not exist, it returns an error
This operation cannot be undone
:calls: ``delete /deals/{deal_id}/associated_contacts/{contact_id}``
:param int deal_id: Unique iden... | def destroy(self, deal_id, contact_id) :
"""
Remove an associated contact
Remove a deal's associated contact
If a deal with the supplied unique identifier does not exist, it returns an error
This operation cannot be undone
:calls: ``delete /deals/{deal_id}/associated_co... |
Retrieve all contacts
Returns all contacts available to the user according to the parameters provided
:calls: ``get /contacts``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Contacts.
... | def list(self, **params):
"""
Retrieve all contacts
Returns all contacts available to the user according to the parameters provided
:calls: ``get /contacts``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access... |
Retrieve a single contact
Returns a single contact available to the user, according to the unique contact ID provided
If the specified contact does not exist, the request will return an error
:calls: ``get /contacts/{id}``
:param int id: Unique identifier of a Contact.
:return:... | def retrieve(self, id) :
"""
Retrieve a single contact
Returns a single contact available to the user, according to the unique contact ID provided
If the specified contact does not exist, the request will return an error
:calls: ``get /contacts/{id}``
:param int id: Uni... |
Retrieve all deals
Returns all deals available to the user according to the parameters provided
:calls: ``get /deals``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Deals.
:rtype: ... | def list(self, **params):
"""
Retrieve all deals
Returns all deals available to the user according to the parameters provided
:calls: ``get /deals``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which r... |
Create a deal
Create a new deal
:calls: ``post /deals``
:param tuple *args: (optional) Single object representing Deal resource.
:param dict **kwargs: (optional) Deal attributes.
:return: Dictionary that support attriubte-style access and represents newely created Deal resource... | def create(self, *args, **kwargs):
"""
Create a deal
Create a new deal
:calls: ``post /deals``
:param tuple *args: (optional) Single object representing Deal resource.
:param dict **kwargs: (optional) Deal attributes.
:return: Dictionary that support attriubte-s... |
Retrieve a single deal
Returns a single deal available to the user, according to the unique deal ID provided
If the specified deal does not exist, the request will return an error
:calls: ``get /deals/{id}``
:param int id: Unique identifier of a Deal.
:return: Dictionary that s... | def retrieve(self, id) :
"""
Retrieve a single deal
Returns a single deal available to the user, according to the unique deal ID provided
If the specified deal does not exist, the request will return an error
:calls: ``get /deals/{id}``
:param int id: Unique identifier ... |
Update a deal
Updates deal information
If the specified deal does not exist, the request will return an error
<figure class="notice">
In order to modify tags used on a record, you need to supply the entire set
`tags` are replaced every time they are used in a request
</f... | def update(self, id, *args, **kwargs):
"""
Update a deal
Updates deal information
If the specified deal does not exist, the request will return an error
<figure class="notice">
In order to modify tags used on a record, you need to supply the entire set
`tags` are... |
Retrieve all sources
Returns all deal sources available to the user according to the parameters provided
:calls: ``get /deal_sources``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of DealSou... | def list(self, **params):
"""
Retrieve all sources
Returns all deal sources available to the user according to the parameters provided
:calls: ``get /deal_sources``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style... |
Update a source
Updates source information
If the specified source does not exist, the request will return an error
<figure class="notice">
If you want to update a source, you **must** make sure source's name is unique
</figure>
:calls: ``put /deal_sources/{id}``
... | def update(self, id, *args, **kwargs):
"""
Update a source
Updates source information
If the specified source does not exist, the request will return an error
<figure class="notice">
If you want to update a source, you **must** make sure source's name is unique
<... |
Retrieve a single source
Returns a single source available to the user by the provided id
If a source with the supplied unique identifier does not exist it returns an error
:calls: ``get /deal_sources/{id}``
:param int id: Unique identifier of a DealSource.
:return: Dictionary ... | def retrieve(self, id) :
"""
Retrieve a single source
Returns a single source available to the user by the provided id
If a source with the supplied unique identifier does not exist it returns an error
:calls: ``get /deal_sources/{id}``
:param int id: Unique identifier ... |
Delete a source
Delete an existing source
If the specified source does not exist, the request will return an error
This operation cannot be undone
:calls: ``delete /deal_sources/{id}``
:param int id: Unique identifier of a DealSource.
:return: True if the operation succ... | def destroy(self, id) :
"""
Delete a source
Delete an existing source
If the specified source does not exist, the request will return an error
This operation cannot be undone
:calls: ``delete /deal_sources/{id}``
:param int id: Unique identifier of a DealSource.... |
Retrieve all deal unqualified reasons
Returns all deal unqualified reasons available to the user according to the parameters provided
:calls: ``get /deal_unqualified_reasons``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style acce... | def list(self, **params):
"""
Retrieve all deal unqualified reasons
Returns all deal unqualified reasons available to the user according to the parameters provided
:calls: ``get /deal_unqualified_reasons``
:param dict params: (optional) Search options.
:return: List of ... |
Retrieve a single deal unqualified reason
Returns a single deal unqualified reason available to the user by the provided id
If a loss reason with the supplied unique identifier does not exist, it returns an error
:calls: ``get /deal_unqualified_reasons/{id}``
:param int id: Unique iden... | def retrieve(self, id) :
"""
Retrieve a single deal unqualified reason
Returns a single deal unqualified reason available to the user by the provided id
If a loss reason with the supplied unique identifier does not exist, it returns an error
:calls: ``get /deal_unqualified_reas... |
Retrieve all leads
Returns all leads available to the user, according to the parameters provided
:calls: ``get /leads``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Leads.
:rtype:... | def list(self, **params):
"""
Retrieve all leads
Returns all leads available to the user, according to the parameters provided
:calls: ``get /leads``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which ... |
Retrieve a single lead
Returns a single lead available to the user, according to the unique lead ID provided
If the specified lead does not exist, this query returns an error
:calls: ``get /leads/{id}``
:param int id: Unique identifier of a Lead.
:return: Dictionary that suppor... | def retrieve(self, id) :
"""
Retrieve a single lead
Returns a single lead available to the user, according to the unique lead ID provided
If the specified lead does not exist, this query returns an error
:calls: ``get /leads/{id}``
:param int id: Unique identifier of a ... |
Retrieve all sources
Returns all lead sources available to the user according to the parameters provided
:calls: ``get /lead_sources``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of LeadSou... | def list(self, **params):
"""
Retrieve all sources
Returns all lead sources available to the user according to the parameters provided
:calls: ``get /lead_sources``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style... |
Retrieve a single source
Returns a single source available to the user by the provided id
If a source with the supplied unique identifier does not exist it returns an error
:calls: ``get /lead_sources/{id}``
:param int id: Unique identifier of a LeadSource.
:return: Dictionary ... | def retrieve(self, id) :
"""
Retrieve a single source
Returns a single source available to the user by the provided id
If a source with the supplied unique identifier does not exist it returns an error
:calls: ``get /lead_sources/{id}``
:param int id: Unique identifier ... |
Retrieve all lead unqualified reasons
Returns all lead unqualified reasons available to the user according to the parameters provided
:calls: ``get /lead_unqualified_reasons``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style acce... | def list(self, **params):
"""
Retrieve all lead unqualified reasons
Returns all lead unqualified reasons available to the user according to the parameters provided
:calls: ``get /lead_unqualified_reasons``
:param dict params: (optional) Search options.
:return: List of ... |
Retrieve order's line items
Returns all line items associated to order
:calls: ``get /orders/{order_id}/line_items``
:param int order_id: Unique identifier of a Order.
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style acce... | def list(self, order_id, **params):
"""
Retrieve order's line items
Returns all line items associated to order
:calls: ``get /orders/{order_id}/line_items``
:param int order_id: Unique identifier of a Order.
:param dict params: (optional) Search options.
:return... |
Retrieve a single line item
Returns a single line item of an order, according to the unique line item ID provided
:calls: ``get /orders/{order_id}/line_items/{id}``
:param int order_id: Unique identifier of a Order.
:param int id: Unique identifier of a LineItem.
:return: Dicti... | def retrieve(self, order_id, id) :
"""
Retrieve a single line item
Returns a single line item of an order, according to the unique line item ID provided
:calls: ``get /orders/{order_id}/line_items/{id}``
:param int order_id: Unique identifier of a Order.
:param int id: ... |
Retrieve all reasons
Returns all deal loss reasons available to the user according to the parameters provided
:calls: ``get /loss_reasons``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Lo... | def list(self, **params):
"""
Retrieve all reasons
Returns all deal loss reasons available to the user according to the parameters provided
:calls: ``get /loss_reasons``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-... |
Retrieve a single reason
Returns a single loss reason available to the user by the provided id
If a loss reason with the supplied unique identifier does not exist, it returns an error
:calls: ``get /loss_reasons/{id}``
:param int id: Unique identifier of a LossReason.
:return: ... | def retrieve(self, id) :
"""
Retrieve a single reason
Returns a single loss reason available to the user by the provided id
If a loss reason with the supplied unique identifier does not exist, it returns an error
:calls: ``get /loss_reasons/{id}``
:param int id: Unique ... |
Retrieve all notes
Returns all notes available to the user, according to the parameters provided
:calls: ``get /notes``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Notes.
:rtype:... | def list(self, **params):
"""
Retrieve all notes
Returns all notes available to the user, according to the parameters provided
:calls: ``get /notes``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which ... |
Retrieve a single note
Returns a single note available to the user, according to the unique note ID provided
If the note ID does not exist, this request will return an error
:calls: ``get /notes/{id}``
:param int id: Unique identifier of a Note.
:return: Dictionary that support... | def retrieve(self, id) :
"""
Retrieve a single note
Returns a single note available to the user, according to the unique note ID provided
If the note ID does not exist, this request will return an error
:calls: ``get /notes/{id}``
:param int id: Unique identifier of a N... |
Retrieve all orders
Returns all orders available to the user according to the parameters provided
:calls: ``get /orders``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Orders.
:rty... | def list(self, **params):
"""
Retrieve all orders
Returns all orders available to the user according to the parameters provided
:calls: ``get /orders``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, whic... |
Create an order
Create a new order for a deal
User needs to have access to the deal to create an order
Each deal can have at most one order and error is returned when attempting to create more
:calls: ``post /orders``
:param tuple *args: (optional) Single object representing Or... | def create(self, *args, **kwargs):
"""
Create an order
Create a new order for a deal
User needs to have access to the deal to create an order
Each deal can have at most one order and error is returned when attempting to create more
:calls: ``post /orders``
:para... |
Retrieve a single order
Returns a single order available to the user, according to the unique order ID provided
If the specified order does not exist, the request will return an error
:calls: ``get /orders/{id}``
:param int id: Unique identifier of a Order.
:return: Dictionary ... | def retrieve(self, id) :
"""
Retrieve a single order
Returns a single order available to the user, according to the unique order ID provided
If the specified order does not exist, the request will return an error
:calls: ``get /orders/{id}``
:param int id: Unique identi... |
Retrieve all pipelines
Returns all pipelines available to the user, according to the parameters provided
:calls: ``get /pipelines``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Pipelines.... | def list(self, **params):
"""
Retrieve all pipelines
Returns all pipelines available to the user, according to the parameters provided
:calls: ``get /pipelines``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style ac... |
Retrieve all products
Returns all products available to the user according to the parameters provided
:calls: ``get /products``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Products.
... | def list(self, **params):
"""
Retrieve all products
Returns all products available to the user according to the parameters provided
:calls: ``get /products``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access... |
Retrieve a single product
Returns a single product, according to the unique product ID provided
If the specified product does not exist, the request will return an error
:calls: ``get /products/{id}``
:param int id: Unique identifier of a Product.
:return: Dictionary that suppo... | def retrieve(self, id) :
"""
Retrieve a single product
Returns a single product, according to the unique product ID provided
If the specified product does not exist, the request will return an error
:calls: ``get /products/{id}``
:param int id: Unique identifier of a Pr... |
Retrieve all sources
Returns all deal sources available to the user according to the parameters provided
:calls: ``get /sources``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Sources.
... | def list(self, **params):
"""
Retrieve all sources
Returns all deal sources available to the user according to the parameters provided
:calls: ``get /sources``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style acce... |
Retrieve a single source
Returns a single source available to the user by the provided id
If a source with the supplied unique identifier does not exist it returns an error
:calls: ``get /sources/{id}``
:param int id: Unique identifier of a Source.
:return: Dictionary that supp... | def retrieve(self, id) :
"""
Retrieve a single source
Returns a single source available to the user by the provided id
If a source with the supplied unique identifier does not exist it returns an error
:calls: ``get /sources/{id}``
:param int id: Unique identifier of a ... |
Retrieve all tags
Returns all tags available to the user, according to the parameters provided
:calls: ``get /tags``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Tags.
:rtype: lis... | def list(self, **params):
"""
Retrieve all tags
Returns all tags available to the user, according to the parameters provided
:calls: ``get /tags``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which rep... |
Retrieve all stages
Returns all stages available to the user, according to the parameters provided
:calls: ``get /stages``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Stages.
:rt... | def list(self, **params):
"""
Retrieve all stages
Returns all stages available to the user, according to the parameters provided
:calls: ``get /stages``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, whi... |
Retrieve a single tag
Returns a single tag available to the user according to the unique ID provided
If the specified tag does not exist, this query will return an error
:calls: ``get /tags/{id}``
:param int id: Unique identifier of a Tag.
:return: Dictionary that support attri... | def retrieve(self, id) :
"""
Retrieve a single tag
Returns a single tag available to the user according to the unique ID provided
If the specified tag does not exist, this query will return an error
:calls: ``get /tags/{id}``
:param int id: Unique identifier of a Tag.
... |
Retrieve all tasks
Returns all tasks available to the user, according to the parameters provided
If you ask for tasks without any parameter provided Base API will return you both **floating** and **related** tasks
Although you can narrow the search set to either of them via query parameters
... | def list(self, **params):
"""
Retrieve all tasks
Returns all tasks available to the user, according to the parameters provided
If you ask for tasks without any parameter provided Base API will return you both **floating** and **related** tasks
Although you can narrow the search ... |
Retrieve a single task
Returns a single task available to the user according to the unique task ID provided
If the specified task does not exist, this query will return an error
:calls: ``get /tasks/{id}``
:param int id: Unique identifier of a Task.
:return: Dictionary that sup... | def retrieve(self, id) :
"""
Retrieve a single task
Returns a single task available to the user according to the unique task ID provided
If the specified task does not exist, this query will return an error
:calls: ``get /tasks/{id}``
:param int id: Unique identifier of... |
Retrieve text messages
Returns Text Messages, according to the parameters provided
:calls: ``get /text_messages``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of TextMessages.
:rtype... | def list(self, **params):
"""
Retrieve text messages
Returns Text Messages, according to the parameters provided
:calls: ``get /text_messages``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which repres... |
Retrieve a single text message
Returns a single text message according to the unique ID provided
If the specified user does not exist, this query returns an error
:calls: ``get /text_messages/{id}``
:param int id: Unique identifier of a TextMessage.
:return: Dictionary that su... | def retrieve(self, id) :
"""
Retrieve a single text message
Returns a single text message according to the unique ID provided
If the specified user does not exist, this query returns an error
:calls: ``get /text_messages/{id}``
:param int id: Unique identifier of a Tex... |
Retrieve all users
Returns all users, according to the parameters provided
:calls: ``get /users``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Users.
:rtype: list | def list(self, **params):
"""
Retrieve all users
Returns all users, according to the parameters provided
:calls: ``get /users``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection o... |
Retrieve a single user
Returns a single user according to the unique user ID provided
If the specified user does not exist, this query returns an error
:calls: ``get /users/{id}``
:param int id: Unique identifier of a User.
:return: Dictionary that support attriubte-style acces... | def retrieve(self, id) :
"""
Retrieve a single user
Returns a single user according to the unique user ID provided
If the specified user does not exist, this query returns an error
:calls: ``get /users/{id}``
:param int id: Unique identifier of a User.
:return: ... |
Retrieve visits
Returns Visits, according to the parameters provided
:calls: ``get /visits``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Visits.
:rtype: list | def list(self, **params):
"""
Retrieve visits
Returns Visits, according to the parameters provided
:calls: ``get /visits``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of Vis... |
Retrieve visit outcomes
Returns Visit Outcomes, according to the parameters provided
:calls: ``get /visit_outcomes``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which represent collection of VisitOutcomes.
:r... | def list(self, **params):
"""
Retrieve visit outcomes
Returns Visit Outcomes, according to the parameters provided
:calls: ``get /visit_outcomes``
:param dict params: (optional) Search options.
:return: List of dictionaries that support attriubte-style access, which rep... |
Do the HTTP Request and return data | def request(url, *args, **kwargs):
"""Do the HTTP Request and return data"""
method = kwargs.get('method', 'GET')
timeout = kwargs.pop('timeout', 10) # hass default timeout
req = requests.request(method, url, *args, timeout=timeout, **kwargs)
data = req.json()
_LOGGER.debug(json.dumps(data))
... |
Loop through messages and pass them on to right device | def message_worker(device):
"""Loop through messages and pass them on to right device"""
_LOGGER.debug("Starting Worker Thread.")
msg_q = device.messages
while True:
if not msg_q.empty():
message = msg_q.get()
data = {}
try:
data = json.load... |
Socket Loop that fills message queue | def socket_worker(sock, msg_q):
"""Socket Loop that fills message queue"""
_LOGGER.debug("Starting Socket Thread.")
while True:
try:
data, addr = sock.recvfrom(1024) # buffer size is 1024 bytes
except OSError as err:
_LOGGER.error(err)
else:
_LO... |
Toplogically sorts a list match graph.
Tries to perform a topological sort using as tiebreaker the pick_first
argument. If the graph contains cycles, raise ValueError. | def toposort(graph, pick_first='head'):
"""Toplogically sorts a list match graph.
Tries to perform a topological sort using as tiebreaker the pick_first
argument. If the graph contains cycles, raise ValueError.
"""
in_deg = {}
for node, next_nodes in six.iteritems(graph):
for next_node ... |
Fallback for cases in which the graph has cycles. | def sort_cyclic_graph_best_effort(graph, pick_first='head'):
"""Fallback for cases in which the graph has cycles."""
ordered = []
visited = set()
# Go first on the pick_first chain then go back again on the others
# that were not visited. Given the way the graph is built both chains
# will alway... |
Retrieve an url. | def get(url):
"""Retrieve an url."""
writeln("Getting data from url", url)
response = requests.get(url)
if response.status_code == 200:
writeln(response.text)
else:
writeln(str(response.status_code), response.reason) |
Post data to an url. | def post(url, var):
"""Post data to an url."""
data = {b[0]: b[1] for b in [a.split("=") for a in var]}
writeln("Sending data to url", url)
response = requests.post(url, data=data)
if response.status_code == 200:
writeln(response.text)
else:
writeln(str(response.status_code), res... |
cast str or bytes to bytes | def cast_bytes(s, encoding='utf8', errors='strict'):
"""cast str or bytes to bytes"""
if isinstance(s, bytes):
return s
elif isinstance(s, str):
return s.encode(encoding, errors)
else:
raise TypeError("Expected unicode or bytes, got %r" % s) |
cast bytes or str to str | def cast_str(s, encoding='utf8', errors='strict'):
"""cast bytes or str to str"""
if isinstance(s, bytes):
return s.decode(encoding, errors)
elif isinstance(s, str):
return s
else:
raise TypeError("Expected unicode or bytes, got %r" % s) |
cast timestamp to datetime or date str | def cast_datetime(ts, fmt=None):
"""cast timestamp to datetime or date str"""
dt = datetime.datetime.fromtimestamp(ts)
if fmt:
return dt.strftime(fmt)
return dt |
read xml object
:param url: contents url
:param markup: markup provider
:param game: MLBAM Game object
:return: pitchpx.game.players.Players object | def read_xml(cls, url, markup, game):
"""
read xml object
:param url: contents url
:param markup: markup provider
:param game: MLBAM Game object
:return: pitchpx.game.players.Players object
"""
return Players._read_objects(MlbamUtil.find_xml("".join([url, ... |
read objects
:param soup: Beautifulsoup object
:param game: MLBAM Game object
:return: pitchpx.game.players.Players object | def _read_objects(cls, soup, game):
"""
read objects
:param soup: Beautifulsoup object
:param game: MLBAM Game object
:return: pitchpx.game.players.Players object
"""
players = Players()
players.game = Players.Game()
# game data
players.gam... |
ditit check for stats
:param value: stats value
:return: True or False | def isdigit(cls, value):
"""
ditit check for stats
:param value: stats value
:return: True or False
"""
if str(value).replace('.','').replace('-','').isdigit():
return True
return False |
get team data
:param soup: Beautifulsoup object
:return: pitchpx.game.players.Players.Team object | def _get_team(cls, soup):
"""
get team data
:param soup: Beautifulsoup object
:return: pitchpx.game.players.Players.Team object
"""
team = cls.Team()
team.team_type = soup['type']
team.id = soup['id']
team.name = soup['name']
return team |
>>> from Redy.Magic.Classic import singleton
>>> @singleton
>>> class S:
>>> pass
>>> assert isinstance(S, S) | def singleton_init_by(init_fn=None):
"""
>>> from Redy.Magic.Classic import singleton
>>> @singleton
>>> class S:
>>> pass
>>> assert isinstance(S, S)
"""
if not init_fn:
def wrap_init(origin_init):
return origin_init
else:
def wrap_init(origin_init):... |
>>> from Redy.Magic.Classic import const_return
>>> @const_return
>>> def f(x):
>>> return x
>>> r1 = f(1)
>>> assert r1 is 1 and r1 is f(2) | def const_return(func):
"""
>>> from Redy.Magic.Classic import const_return
>>> @const_return
>>> def f(x):
>>> return x
>>> r1 = f(1)
>>> assert r1 is 1 and r1 is f(2)
"""
result = _undef
def ret_call(*args, **kwargs):
nonlocal result
if result is _undef:
... |
>>> from Redy.Magic.Classic import execute
>>> x = 1
>>> @execute
>>> def f(x = x) -> int:
>>> return x + 1
>>> assert f is 2 | def execute(func: types.FunctionType):
"""
>>> from Redy.Magic.Classic import execute
>>> x = 1
>>> @execute
>>> def f(x = x) -> int:
>>> return x + 1
>>> assert f is 2
"""
spec = getfullargspec(func)
default = spec.defaults
arg_cursor = 0
def get_item(name):
... |
>>> from Redy.Magic.Classic import cast
>>> @cast(list)
>>> def f(x):
>>> for each in x:
>>> if each % 2:
>>> continue
>>> yield each | def cast(cast_fn):
"""
>>> from Redy.Magic.Classic import cast
>>> @cast(list)
>>> def f(x):
>>> for each in x:
>>> if each % 2:
>>> continue
>>> yield each
"""
def inner(func):
def call(*args, **kwargs):
return cast_fn(func(*a... |
Namedtuple which could inherit from other types.
>>> from Redy.Magic.Classic import record
>>> class Interface: pass
>>> @record
>>> class S(Interface):
>>> name: str
>>> addr: str
>>> sex : int
>>> s = S("sam", "I/O", 1) | def record(cls_def):
"""
Namedtuple which could inherit from other types.
>>> from Redy.Magic.Classic import record
>>> class Interface: pass
>>> @record
>>> class S(Interface):
>>> name: str
>>> addr: str
>>> sex : int
>>> s = S("sam", "I/O", 1)
"""
annotati... |
>>> from Redy.Magic.Classic import template
>>> import operator
>>> class Point:
>>> def __init__(self, p):
>>> assert isinstance(p, tuple) and len(p) is 2
>>> self.x, self.y = p
>>> def some_metrics(p: Point):
>>> return p.x + 2 * p.y
>>> @template
>>> def c... | def template(spec_fn):
"""
>>> from Redy.Magic.Classic import template
>>> import operator
>>> class Point:
>>> def __init__(self, p):
>>> assert isinstance(p, tuple) and len(p) is 2
>>> self.x, self.y = p
>>> def some_metrics(p: Point):
>>> return p.x + 2 * p... |
add a new action with specific priority
>>> delegate: Delegate
>>> delegate.insert(lambda task, product, ctx: print(product), where=Delegate.Where.after(lambda action: action.__name__ == 'myfunc'))
the codes above inserts an action after the specific action whose name is 'myfunc'. | def insert(self, action: Action, where: 'Union[int, Delegate.Where]'):
"""
add a new action with specific priority
>>> delegate: Delegate
>>> delegate.insert(lambda task, product, ctx: print(product), where=Delegate.Where.after(lambda action: action.__name__ == 'myfunc'))
the co... |
Translates a dictdiffer conflict into a json_merger one. | def patch_to_conflict_set(patch):
"""Translates a dictdiffer conflict into a json_merger one."""
patch_type, patched_key, value = patch
if isinstance(patched_key, list):
key_path = tuple(patched_key)
else:
key_path = tuple(k for k in patched_key.split('.') if k)
conflicts = set()
... |
Perform merge of head and update starting from root. | def merge(self):
"""Perform merge of head and update starting from root."""
if isinstance(self.head, dict) and isinstance(self.update, dict):
if not isinstance(self.root, dict):
self.root = {}
self._merge_dicts()
else:
self._merge_base_values()... |
Is PA terminal
:param ball_tally: Ball telly
:param strike_tally: Strike telly
:param pitch_res: pitching result(Retrosheet format)
:param event_cd: Event code
:return: FLG(T or F) | def is_pa_terminal(cls, ball_tally, strike_tally, pitch_res, event_cd):
"""
Is PA terminal
:param ball_tally: Ball telly
:param strike_tally: Strike telly
:param pitch_res: pitching result(Retrosheet format)
:param event_cd: Event code
:return: FLG(T or F)
... |
Pitching Result
Pitch f/x fields: https://fastballs.wordpress.com/category/pitchfx-glossary/
:param pitch: pitch object(type:Beautifulsoup)
:param pa: At bat data for pa(dict)
:param pitch_list: Pitching
:param ball_tally: Ball telly
:param strike_tally: Strike telly
... | def row(cls, pitch, pa, pitch_list, ball_tally, strike_tally):
"""
Pitching Result
Pitch f/x fields: https://fastballs.wordpress.com/category/pitchfx-glossary/
:param pitch: pitch object(type:Beautifulsoup)
:param pa: At bat data for pa(dict)
:param pitch_list: Pitching
... |
Start Bases & End Bases
:param ab: at bat object(type:Beautifulsoup)
:param attribute_name: attribute name
:return: start base, end base | def _get_bases(cls, ab):
"""
Start Bases & End Bases
:param ab: at bat object(type:Beautifulsoup)
:param attribute_name: attribute name
:return: start base, end base
"""
start_bases, end_bases = [], []
for base in ('1B', '2B', '3B'):
if ab.find... |
At Bat Result
:param ab: at bat object(type:Beautifulsoup)
:param pa: atbat data for plate appearance
:param pitch_list: Pitching data
:return: pa result value(dict) | def result(cls, ab, pa, pitch_list):
"""
At Bat Result
:param ab: at bat object(type:Beautifulsoup)
:param pa: atbat data for plate appearance
:param pitch_list: Pitching data
:return: pa result value(dict)
"""
atbat = OrderedDict()
atbat['ball_ct'... |
action data
:param action: action object(type:Beautifulsoup)
:param game: MLBAM Game object
:param rosters: Game Rosters
:param inning_number: Inning Number
:param inning_id: Inning Id(0:home 1:away)
:return: {
'retro_game_id': Retrosheet Game id
'... | def action(cls, action, game, rosters, inning_number, inning_id):
"""
action data
:param action: action object(type:Beautifulsoup)
:param game: MLBAM Game object
:param rosters: Game Rosters
:param inning_number: Inning Number
:param inning_id: Inning Id(0:home 1:... |
read xml object
:param url: contents url
:param markup: markup provider
:param game: MLBAM Game object
:param players: MLBAM Players object
:return: pitchpx.game.game.Game object | def read_xml(cls, url, markup, game, players):
"""
read xml object
:param url: contents url
:param markup: markup provider
:param game: MLBAM Game object
:param players: MLBAM Players object
:return: pitchpx.game.game.Game object
"""
innings = Inni... |
Inning Actions.
:param soup: Beautifulsoup object
:param inning_number: Inning Number
:param inning_id: Inning Id(0:home, 1:away) | def _inning_actions(self, soup, inning_number, inning_id):
"""
Inning Actions.
:param soup: Beautifulsoup object
:param inning_number: Inning Number
:param inning_id: Inning Id(0:home, 1:away)
"""
# at bat(batter box data) & pitching data
for act in soup.f... |
Inning Events.
:param soup: Beautifulsoup object
:param inning_number: Inning Number
:param inning_id: Inning Id(0:home, 1:away)
:param hit_location: Hitlocation data(dict) | def _inning_events(self, soup, inning_number, inning_id, hit_location):
"""
Inning Events.
:param soup: Beautifulsoup object
:param inning_number: Inning Number
:param inning_id: Inning Id(0:home, 1:away)
:param hit_location: Hitlocation data(dict)
"""
# a... |
get pitch data
:param soup: Beautifulsoup object
:param pa: atbat data for plate appearance
:return: pitches result(list) | def _get_pitch(self, soup, pa):
"""
get pitch data
:param soup: Beautifulsoup object
:param pa: atbat data for plate appearance
:return: pitches result(list)
"""
pitches = []
ball_tally, strike_tally = 0, 0
for pitch in soup.find_all('pitch'):
... |
Add a individual to the adapter
Args:
ind_obj (puzzle.models.Individual) | def _add_individual(self, ind_obj):
"""Add a individual to the adapter
Args:
ind_obj (puzzle.models.Individual)
"""
logger.debug("Adding individual {0} to plugin".format(ind_obj.ind_id))
self.individual_objs.append(ind_obj) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.