body stringlengths 26 98.2k | body_hash int64 -9,222,864,604,528,158,000 9,221,803,474B | docstring stringlengths 1 16.8k | path stringlengths 5 230 | name stringlengths 1 96 | repository_name stringlengths 7 89 | lang stringclasses 1
value | body_without_docstring stringlengths 20 98.2k |
|---|---|---|---|---|---|---|---|
def compare(self, other, name='self'):
'Compare two objects and return list of differences'
if (type(other) != type(self)):
return [(('type(' + name) + ')')]
diff_list = list()
diff_list.extend(super(LamSlotWind, self).compare(other, name=name))
if (other._Ksfill != self._Ksfill):
di... | -6,851,858,460,286,233,000 | Compare two objects and return list of differences | pyleecan/Classes/LamSlotWind.py | compare | IrakozeFD/pyleecan | python | def compare(self, other, name='self'):
if (type(other) != type(self)):
return [(('type(' + name) + ')')]
diff_list = list()
diff_list.extend(super(LamSlotWind, self).compare(other, name=name))
if (other._Ksfill != self._Ksfill):
diff_list.append((name + '.Ksfill'))
if (((other.w... |
def __sizeof__(self):
'Return the size in memory of the object (including all subobject)'
S = 0
S += super(LamSlotWind, self).__sizeof__()
S += getsizeof(self.Ksfill)
S += getsizeof(self.winding)
return S | 6,686,156,564,589,825,000 | Return the size in memory of the object (including all subobject) | pyleecan/Classes/LamSlotWind.py | __sizeof__ | IrakozeFD/pyleecan | python | def __sizeof__(self):
S = 0
S += super(LamSlotWind, self).__sizeof__()
S += getsizeof(self.Ksfill)
S += getsizeof(self.winding)
return S |
def as_dict(self):
'Convert this object in a json seriable dict (can be use in __init__)'
LamSlotWind_dict = super(LamSlotWind, self).as_dict()
LamSlotWind_dict['Ksfill'] = self.Ksfill
if (self.winding is None):
LamSlotWind_dict['winding'] = None
else:
LamSlotWind_dict['winding'] = s... | -2,586,795,700,191,412,000 | Convert this object in a json seriable dict (can be use in __init__) | pyleecan/Classes/LamSlotWind.py | as_dict | IrakozeFD/pyleecan | python | def as_dict(self):
LamSlotWind_dict = super(LamSlotWind, self).as_dict()
LamSlotWind_dict['Ksfill'] = self.Ksfill
if (self.winding is None):
LamSlotWind_dict['winding'] = None
else:
LamSlotWind_dict['winding'] = self.winding.as_dict()
LamSlotWind_dict['__class__'] = 'LamSlotWind... |
def _set_None(self):
'Set all the properties to None (except pyleecan object)'
self.Ksfill = None
if (self.winding is not None):
self.winding._set_None()
super(LamSlotWind, self)._set_None() | -6,787,604,911,379,125,000 | Set all the properties to None (except pyleecan object) | pyleecan/Classes/LamSlotWind.py | _set_None | IrakozeFD/pyleecan | python | def _set_None(self):
self.Ksfill = None
if (self.winding is not None):
self.winding._set_None()
super(LamSlotWind, self)._set_None() |
def _get_Ksfill(self):
'getter of Ksfill'
return self._Ksfill | 6,475,719,411,689,306,000 | getter of Ksfill | pyleecan/Classes/LamSlotWind.py | _get_Ksfill | IrakozeFD/pyleecan | python | def _get_Ksfill(self):
return self._Ksfill |
def _set_Ksfill(self, value):
'setter of Ksfill'
check_var('Ksfill', value, 'float', Vmin=0, Vmax=1)
self._Ksfill = value | -7,171,397,597,108,831,000 | setter of Ksfill | pyleecan/Classes/LamSlotWind.py | _set_Ksfill | IrakozeFD/pyleecan | python | def _set_Ksfill(self, value):
check_var('Ksfill', value, 'float', Vmin=0, Vmax=1)
self._Ksfill = value |
def _get_winding(self):
'getter of winding'
return self._winding | 2,205,193,926,475,906,000 | getter of winding | pyleecan/Classes/LamSlotWind.py | _get_winding | IrakozeFD/pyleecan | python | def _get_winding(self):
return self._winding |
def _set_winding(self, value):
'setter of winding'
if isinstance(value, str):
value = load_init_dict(value)[1]
if (isinstance(value, dict) and ('__class__' in value)):
class_obj = import_class('pyleecan.Classes', value.get('__class__'), 'winding')
value = class_obj(init_dict=value)
... | 4,680,165,766,541,386,000 | setter of winding | pyleecan/Classes/LamSlotWind.py | _set_winding | IrakozeFD/pyleecan | python | def _set_winding(self, value):
if isinstance(value, str):
value = load_init_dict(value)[1]
if (isinstance(value, dict) and ('__class__' in value)):
class_obj = import_class('pyleecan.Classes', value.get('__class__'), 'winding')
value = class_obj(init_dict=value)
elif ((type(valu... |
def get_rules(rule_list=None):
'Get the rules governing the snapshot creation\n\n Args:\n rule_list: List of rules\n Returns:\n Rules object with attribute `rules`. See Rules object for detailed doc.\n '
if (not rule_list):
rule_list = DEFAULT_RULE_LIST
return Rules(rule_list) | 2,234,582,819,427,399,000 | Get the rules governing the snapshot creation
Args:
rule_list: List of rules
Returns:
Rules object with attribute `rules`. See Rules object for detailed doc. | src/ggrc/snapshotter/rules.py | get_rules | MikalaiMikalalai/ggrc-core | python | def get_rules(rule_list=None):
'Get the rules governing the snapshot creation\n\n Args:\n rule_list: List of rules\n Returns:\n Rules object with attribute `rules`. See Rules object for detailed doc.\n '
if (not rule_list):
rule_list = DEFAULT_RULE_LIST
return Rules(rule_list) |
@classmethod
def internal_types(cls):
'Return set of internal type names.'
return (cls.all - cls.external) | 7,308,573,336,677,186,000 | Return set of internal type names. | src/ggrc/snapshotter/rules.py | internal_types | MikalaiMikalalai/ggrc-core | python | @classmethod
def internal_types(cls):
return (cls.all - cls.external) |
@classmethod
def external_types(cls):
'Return set of external type names.'
return cls.external | 4,920,418,971,284,829,000 | Return set of external type names. | src/ggrc/snapshotter/rules.py | external_types | MikalaiMikalalai/ggrc-core | python | @classmethod
def external_types(cls):
return cls.external |
def __init__(self, publish_key, subscribe_key, secret_key=False, ssl_on=False, origin='pubsub.pubnub.com', pres_uuid=None):
"\n #**\n #* Pubnub\n #*\n #* Init the Pubnub Client API\n #*\n #* @param string publish_key required key to send messages.\n #* @param string ... | -71,531,499,991,373,630 | #**
#* Pubnub
#*
#* Init the Pubnub Client API
#*
#* @param string publish_key required key to send messages.
#* @param string subscribe_key required key to receive messages.
#* @param string secret_key optional key to sign messages.
#* @param boolean ssl required for 2048 bit encrypted messages.
#* @param string origi... | python/3.2/Pubnub.py | __init__ | goodybag/pubnub-api | python | def __init__(self, publish_key, subscribe_key, secret_key=False, ssl_on=False, origin='pubsub.pubnub.com', pres_uuid=None):
"\n #**\n #* Pubnub\n #*\n #* Init the Pubnub Client API\n #*\n #* @param string publish_key required key to send messages.\n #* @param string ... |
def publish(self, args):
"\n #**\n #* Publish\n #*\n #* Send a message to a channel.\n #*\n #* @param array args with channel and message.\n #* @return array success information.\n #**\n\n ## Publish Example\n info = pubnub.publish({\n ... | -4,403,577,038,890,871,000 | #**
#* Publish
#*
#* Send a message to a channel.
#*
#* @param array args with channel and message.
#* @return array success information.
#**
## Publish Example
info = pubnub.publish({
'channel' : 'hello_world',
'message' : {
'some_text' : 'Hello my World'
}
})
print(info) | python/3.2/Pubnub.py | publish | goodybag/pubnub-api | python | def publish(self, args):
"\n #**\n #* Publish\n #*\n #* Send a message to a channel.\n #*\n #* @param array args with channel and message.\n #* @return array success information.\n #**\n\n ## Publish Example\n info = pubnub.publish({\n ... |
def subscribe(self, args):
"\n #**\n #* Subscribe\n #*\n #* This is BLOCKING.\n #* Listen for a message on a channel.\n #*\n #* @param array args with channel and callback.\n #* @return false on fail, array on success.\n #**\n\n ## Subscribe Exam... | -3,626,650,639,731,726,000 | #**
#* Subscribe
#*
#* This is BLOCKING.
#* Listen for a message on a channel.
#*
#* @param array args with channel and callback.
#* @return false on fail, array on success.
#**
## Subscribe Example
def receive(message) :
print(message)
return True
pubnub.subscribe({
'channel' : 'hello_world',
'callb... | python/3.2/Pubnub.py | subscribe | goodybag/pubnub-api | python | def subscribe(self, args):
"\n #**\n #* Subscribe\n #*\n #* This is BLOCKING.\n #* Listen for a message on a channel.\n #*\n #* @param array args with channel and callback.\n #* @return false on fail, array on success.\n #**\n\n ## Subscribe Exam... |
def presence(self, args):
"\n #**\n #* presence\n #*\n #* This is BLOCKING.\n #* Listen for presence events on a channel.\n #*\n #* @param array args with channel and callback.\n #* @return false on fail, array on success.\n #**\n\n ## Presence E... | 3,188,163,242,192,742,400 | #**
#* presence
#*
#* This is BLOCKING.
#* Listen for presence events on a channel.
#*
#* @param array args with channel and callback.
#* @return false on fail, array on success.
#**
## Presence Example
def pres_event(message) :
print(message)
return True
pubnub.presence({
'channel' : 'hello_world',
... | python/3.2/Pubnub.py | presence | goodybag/pubnub-api | python | def presence(self, args):
"\n #**\n #* presence\n #*\n #* This is BLOCKING.\n #* Listen for presence events on a channel.\n #*\n #* @param array args with channel and callback.\n #* @return false on fail, array on success.\n #**\n\n ## Presence E... |
def here_now(self, args):
"\n #**\n #* Here Now\n #*\n #* Load current occupancy from a channel.\n #*\n #* @param array args with 'channel'.\n #* @return mixed false on fail, array on success.\n #*\n\n ## Presence Example\n here_now = pubnub.here... | 4,767,466,575,551,364,000 | #**
#* Here Now
#*
#* Load current occupancy from a channel.
#*
#* @param array args with 'channel'.
#* @return mixed false on fail, array on success.
#*
## Presence Example
here_now = pubnub.here_now({
'channel' : 'hello_world',
})
print(here_now['occupancy'])
print(here_now['uuids']) | python/3.2/Pubnub.py | here_now | goodybag/pubnub-api | python | def here_now(self, args):
"\n #**\n #* Here Now\n #*\n #* Load current occupancy from a channel.\n #*\n #* @param array args with 'channel'.\n #* @return mixed false on fail, array on success.\n #*\n\n ## Presence Example\n here_now = pubnub.here... |
def history(self, args):
"\n #**\n #* History\n #*\n #* Load history from a channel.\n #*\n #* @param array args with 'channel' and 'limit'.\n #* @return mixed false on fail, array on success.\n #*\n\n ## History Example\n history = pubnub.histor... | -5,782,023,336,559,540,000 | #**
#* History
#*
#* Load history from a channel.
#*
#* @param array args with 'channel' and 'limit'.
#* @return mixed false on fail, array on success.
#*
## History Example
history = pubnub.history({
'channel' : 'hello_world',
'limit' : 1
})
print(history) | python/3.2/Pubnub.py | history | goodybag/pubnub-api | python | def history(self, args):
"\n #**\n #* History\n #*\n #* Load history from a channel.\n #*\n #* @param array args with 'channel' and 'limit'.\n #* @return mixed false on fail, array on success.\n #*\n\n ## History Example\n history = pubnub.histor... |
def time(self):
'\n #**\n #* Time\n #*\n #* Timestamp from PubNub Cloud.\n #*\n #* @return int timestamp.\n #*\n\n ## PubNub Server Time Example\n timestamp = pubnub.time()\n print(timestamp)\n\n '
return self._request(['time', '0'])[0... | 8,419,300,377,443,495,000 | #**
#* Time
#*
#* Timestamp from PubNub Cloud.
#*
#* @return int timestamp.
#*
## PubNub Server Time Example
timestamp = pubnub.time()
print(timestamp) | python/3.2/Pubnub.py | time | goodybag/pubnub-api | python | def time(self):
'\n #**\n #* Time\n #*\n #* Timestamp from PubNub Cloud.\n #*\n #* @return int timestamp.\n #*\n\n ## PubNub Server Time Example\n timestamp = pubnub.time()\n print(timestamp)\n\n '
return self._request(['time', '0'])[0... |
def award_id_values(data, obj):
' Get values from the awardID level of the xml '
value_map = {'modNumber': 'award_modification_amendme', 'transactionNumber': 'transaction_number', 'PIID': 'piid', 'agencyID': 'agency_id'}
for (key, value) in value_map.items():
try:
obj[value] = extract_te... | 1,619,012,655,650,988,300 | Get values from the awardID level of the xml | dataactcore/scripts/pull_fpds_data.py | award_id_values | RonSherfey/data-act-broker-backend | python | def award_id_values(data, obj):
' '
value_map = {'modNumber': 'award_modification_amendme', 'transactionNumber': 'transaction_number', 'PIID': 'piid', 'agencyID': 'agency_id'}
for (key, value) in value_map.items():
try:
obj[value] = extract_text(data['awardContractID'][key])
exc... |
def contract_id_values(data, obj):
' Get values from the contractID level of the xml '
value_map = {'modNumber': 'award_modification_amendme', 'PIID': 'piid', 'agencyID': 'agency_id'}
for (key, value) in value_map.items():
try:
obj[value] = extract_text(data['IDVID'][key])
except... | -7,614,765,690,476,562,000 | Get values from the contractID level of the xml | dataactcore/scripts/pull_fpds_data.py | contract_id_values | RonSherfey/data-act-broker-backend | python | def contract_id_values(data, obj):
' '
value_map = {'modNumber': 'award_modification_amendme', 'PIID': 'piid', 'agencyID': 'agency_id'}
for (key, value) in value_map.items():
try:
obj[value] = extract_text(data['IDVID'][key])
except (KeyError, TypeError):
obj[value] ... |
def competition_values(data, obj):
' Get values from the competition level of the xml '
value_map = {'A76Action': 'a_76_fair_act_action', 'commercialItemAcquisitionProcedures': 'commercial_item_acquisitio', 'commercialItemTestProgram': 'commercial_item_test_progr', 'evaluatedPreference': 'evaluated_preference',... | -3,159,530,546,042,139,600 | Get values from the competition level of the xml | dataactcore/scripts/pull_fpds_data.py | competition_values | RonSherfey/data-act-broker-backend | python | def competition_values(data, obj):
' '
value_map = {'A76Action': 'a_76_fair_act_action', 'commercialItemAcquisitionProcedures': 'commercial_item_acquisitio', 'commercialItemTestProgram': 'commercial_item_test_progr', 'evaluatedPreference': 'evaluated_preference', 'extentCompeted': 'extent_competed', 'fedBizOpp... |
def contract_data_values(data, obj, atom_type):
' Get values from the contractData level of the xml '
value_map = {'consolidatedContract': 'consolidated_contract', 'contingencyHumanitarianPeacekeepingOperation': 'contingency_humanitarian_o', 'contractFinancing': 'contract_financing', 'costAccountingStandardsCla... | -520,491,788,961,469,760 | Get values from the contractData level of the xml | dataactcore/scripts/pull_fpds_data.py | contract_data_values | RonSherfey/data-act-broker-backend | python | def contract_data_values(data, obj, atom_type):
' '
value_map = {'consolidatedContract': 'consolidated_contract', 'contingencyHumanitarianPeacekeepingOperation': 'contingency_humanitarian_o', 'contractFinancing': 'contract_financing', 'costAccountingStandardsClause': 'cost_accounting_standards', 'costOrPricing... |
def dollar_values_values(data, obj):
' Get values from the dollarValues level of the xml '
value_map = {'baseAndAllOptionsValue': 'base_and_all_options_value', 'baseAndExercisedOptionsValue': 'base_exercised_options_val', 'obligatedAmount': 'federal_action_obligation'}
for (key, value) in value_map.items():... | -25,077,798,399,392,490 | Get values from the dollarValues level of the xml | dataactcore/scripts/pull_fpds_data.py | dollar_values_values | RonSherfey/data-act-broker-backend | python | def dollar_values_values(data, obj):
' '
value_map = {'baseAndAllOptionsValue': 'base_and_all_options_value', 'baseAndExercisedOptionsValue': 'base_exercised_options_val', 'obligatedAmount': 'federal_action_obligation'}
for (key, value) in value_map.items():
try:
obj[value] = extract_te... |
def total_dollar_values_values(data, obj):
' Get values from the totalDollarValues level of the xml '
value_map = {'totalBaseAndAllOptionsValue': 'potential_total_value_awar', 'totalBaseAndExercisedOptionsValue': 'current_total_value_award', 'totalObligatedAmount': 'total_obligated_amount'}
for (key, value)... | -6,938,656,846,285,551,000 | Get values from the totalDollarValues level of the xml | dataactcore/scripts/pull_fpds_data.py | total_dollar_values_values | RonSherfey/data-act-broker-backend | python | def total_dollar_values_values(data, obj):
' '
value_map = {'totalBaseAndAllOptionsValue': 'potential_total_value_awar', 'totalBaseAndExercisedOptionsValue': 'current_total_value_award', 'totalObligatedAmount': 'total_obligated_amount'}
for (key, value) in value_map.items():
try:
obj[va... |
def legislative_mandates_values(data, obj):
' Get values from the legislativeMandates level of the xml '
value_map = {'ClingerCohenAct': 'clinger_cohen_act_planning', 'constructionWageRateRequirements': 'construction_wage_rate_req', 'interagencyContractingAuthority': 'interagency_contracting_au', 'otherStatutor... | 5,262,888,862,239,357,000 | Get values from the legislativeMandates level of the xml | dataactcore/scripts/pull_fpds_data.py | legislative_mandates_values | RonSherfey/data-act-broker-backend | python | def legislative_mandates_values(data, obj):
' '
value_map = {'ClingerCohenAct': 'clinger_cohen_act_planning', 'constructionWageRateRequirements': 'construction_wage_rate_req', 'interagencyContractingAuthority': 'interagency_contracting_au', 'otherStatutoryAuthority': 'other_statutory_authority', 'laborStandard... |
def place_of_performance_values(data, obj):
' Get values from the placeOfPerformance level of the xml '
value_map = {'placeOfPerformanceCongressionalDistrict': 'place_of_performance_congr', 'placeOfPerformanceZIPCode': 'place_of_performance_zip4a'}
for (key, value) in value_map.items():
try:
... | -7,840,436,803,331,249,000 | Get values from the placeOfPerformance level of the xml | dataactcore/scripts/pull_fpds_data.py | place_of_performance_values | RonSherfey/data-act-broker-backend | python | def place_of_performance_values(data, obj):
' '
value_map = {'placeOfPerformanceCongressionalDistrict': 'place_of_performance_congr', 'placeOfPerformanceZIPCode': 'place_of_performance_zip4a'}
for (key, value) in value_map.items():
try:
obj[value] = extract_text(data[key])
excep... |
def product_or_service_information_values(data, obj):
' Get values from the productOrServiceInformation level of the xml '
value_map = {'claimantProgramCode': 'dod_claimant_program_code', 'contractBundling': 'contract_bundling', 'countryOfOrigin': 'country_of_product_or_serv', 'informationTechnologyCommercialIt... | 2,910,396,238,477,755,000 | Get values from the productOrServiceInformation level of the xml | dataactcore/scripts/pull_fpds_data.py | product_or_service_information_values | RonSherfey/data-act-broker-backend | python | def product_or_service_information_values(data, obj):
' '
value_map = {'claimantProgramCode': 'dod_claimant_program_code', 'contractBundling': 'contract_bundling', 'countryOfOrigin': 'country_of_product_or_serv', 'informationTechnologyCommercialItemCategory': 'information_technology_com', 'manufacturingOrganiz... |
def purchaser_information_values(data, obj):
' Get values from the purchaserInformation level of the xml '
value_map = {'contractingOfficeAgencyID': 'awarding_sub_tier_agency_c', 'contractingOfficeID': 'awarding_office_code', 'foreignFunding': 'foreign_funding', 'fundingRequestingAgencyID': 'funding_sub_tier_ag... | -4,637,374,741,167,060,000 | Get values from the purchaserInformation level of the xml | dataactcore/scripts/pull_fpds_data.py | purchaser_information_values | RonSherfey/data-act-broker-backend | python | def purchaser_information_values(data, obj):
' '
value_map = {'contractingOfficeAgencyID': 'awarding_sub_tier_agency_c', 'contractingOfficeID': 'awarding_office_code', 'foreignFunding': 'foreign_funding', 'fundingRequestingAgencyID': 'funding_sub_tier_agency_co', 'fundingRequestingOfficeID': 'funding_office_co... |
def relevant_contract_dates_values(data, obj):
' Get values from the relevantContractDates level of the xml '
value_map = {'currentCompletionDate': 'period_of_performance_curr', 'effectiveDate': 'period_of_performance_star', 'lastDateToOrder': 'ordering_period_end_date', 'signedDate': 'action_date', 'ultimateCo... | -1,361,555,611,856,029,400 | Get values from the relevantContractDates level of the xml | dataactcore/scripts/pull_fpds_data.py | relevant_contract_dates_values | RonSherfey/data-act-broker-backend | python | def relevant_contract_dates_values(data, obj):
' '
value_map = {'currentCompletionDate': 'period_of_performance_curr', 'effectiveDate': 'period_of_performance_star', 'lastDateToOrder': 'ordering_period_end_date', 'signedDate': 'action_date', 'ultimateCompletionDate': 'period_of_perf_potential_e'}
for (key,... |
def vendor_values(data, obj):
' Get values from the vendor level of the xml '
value_map = {'CCRException': 'sam_exception', 'contractingOfficerBusinessSizeDetermination': 'contracting_officers_deter'}
for (key, value) in value_map.items():
try:
obj[value] = extract_text(data[key])
... | 3,875,442,262,193,164,000 | Get values from the vendor level of the xml | dataactcore/scripts/pull_fpds_data.py | vendor_values | RonSherfey/data-act-broker-backend | python | def vendor_values(data, obj):
' '
value_map = {'CCRException': 'sam_exception', 'contractingOfficerBusinessSizeDetermination': 'contracting_officers_deter'}
for (key, value) in value_map.items():
try:
obj[value] = extract_text(data[key])
except (KeyError, TypeError):
... |
def vendor_site_details_values(data, obj):
' Get values from the vendorSiteDetails level of the xml (sub-level of vendor) '
value_map = {'divisionName': 'division_name', 'divisionNumberOrOfficeCode': 'division_number_or_office', 'vendorAlternateSiteCode': 'vendor_alternate_site_code', 'vendorSiteCode': 'vendor_... | -6,068,436,029,579,838,000 | Get values from the vendorSiteDetails level of the xml (sub-level of vendor) | dataactcore/scripts/pull_fpds_data.py | vendor_site_details_values | RonSherfey/data-act-broker-backend | python | def vendor_site_details_values(data, obj):
' '
value_map = {'divisionName': 'division_name', 'divisionNumberOrOfficeCode': 'division_number_or_office', 'vendorAlternateSiteCode': 'vendor_alternate_site_code', 'vendorSiteCode': 'vendor_site_code'}
for (key, value) in value_map.items():
try:
... |
def generic_values(data, obj):
' Get values from the genericTags level of the xml '
generic_strings_value_map = {'genericString01': 'solicitation_date'}
for (key, value) in generic_strings_value_map.items():
try:
obj[value] = extract_text(data['genericStrings'][key])
except (KeyE... | -1,668,385,486,940,818,700 | Get values from the genericTags level of the xml | dataactcore/scripts/pull_fpds_data.py | generic_values | RonSherfey/data-act-broker-backend | python | def generic_values(data, obj):
' '
generic_strings_value_map = {'genericString01': 'solicitation_date'}
for (key, value) in generic_strings_value_map.items():
try:
obj[value] = extract_text(data['genericStrings'][key])
except (KeyError, TypeError):
obj[value] = None
... |
def calculate_ppop_fields(obj, sess, county_by_name, county_by_code, state_code_list, country_list):
" calculate values that aren't in any feed (or haven't been provided properly) for place of performance "
if (obj['place_of_perform_country_c'] in country_code_map):
if (obj['place_of_perform_country_c']... | -2,007,915,120,336,223,500 | calculate values that aren't in any feed (or haven't been provided properly) for place of performance | dataactcore/scripts/pull_fpds_data.py | calculate_ppop_fields | RonSherfey/data-act-broker-backend | python | def calculate_ppop_fields(obj, sess, county_by_name, county_by_code, state_code_list, country_list):
" "
if (obj['place_of_perform_country_c'] in country_code_map):
if (obj['place_of_perform_country_c'] != 'USA'):
obj['place_of_performance_state'] = country_code_map[obj['place_of_perform_co... |
def calculate_legal_entity_fields(obj, sess, county_by_code, state_code_list, country_list):
" calculate values that aren't in any feed (or haven't been provided properly) for legal entity "
if (obj['legal_entity_country_code'] in country_code_map):
if (obj['legal_entity_country_code'] != 'USA'):
... | 7,126,306,193,214,378,000 | calculate values that aren't in any feed (or haven't been provided properly) for legal entity | dataactcore/scripts/pull_fpds_data.py | calculate_legal_entity_fields | RonSherfey/data-act-broker-backend | python | def calculate_legal_entity_fields(obj, sess, county_by_code, state_code_list, country_list):
" "
if (obj['legal_entity_country_code'] in country_code_map):
if (obj['legal_entity_country_code'] != 'USA'):
obj['legal_entity_state_code'] = country_code_map[obj['legal_entity_country_code']]
... |
def calculate_remaining_fields(obj, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict, atom_type):
" Calculate values that aren't in any feed but can be calculated.\n\n Args:\n obj: a dictionary containing the details we need to derive from and to\n... | 1,665,732,658,534,018,300 | Calculate values that aren't in any feed but can be calculated.
Args:
obj: a dictionary containing the details we need to derive from and to
sess: the database connection
sub_tier_list: a dictionary containing all the sub tier agency information keyed by sub tier agency code
county_by_name: a dictionar... | dataactcore/scripts/pull_fpds_data.py | calculate_remaining_fields | RonSherfey/data-act-broker-backend | python | def calculate_remaining_fields(obj, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict, atom_type):
" Calculate values that aren't in any feed but can be calculated.\n\n Args:\n obj: a dictionary containing the details we need to derive from and to\n... |
def process_data(data, sess, atom_type, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict):
" Process the data coming in.\n\n Args:\n data: an object containing the data gathered from the feed\n sess: the database connection\n atom_t... | 4,557,314,005,484,484,000 | Process the data coming in.
Args:
data: an object containing the data gathered from the feed
sess: the database connection
atom_type: a string indicating whether the atom feed being checked is 'award' or 'IDV'
sub_tier_list: a dictionary containing all the sub tier agency information keyed by sub tier ... | dataactcore/scripts/pull_fpds_data.py | process_data | RonSherfey/data-act-broker-backend | python | def process_data(data, sess, atom_type, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict):
" Process the data coming in.\n\n Args:\n data: an object containing the data gathered from the feed\n sess: the database connection\n atom_t... |
def process_delete_data(data, atom_type):
' process the delete feed data coming in '
unique_string = ''
if (atom_type == 'award'):
try:
unique_string += extract_text(data['awardID']['awardContractID']['agencyID'])
except (KeyError, TypeError):
unique_string += '-none-... | 3,757,567,124,557,474,000 | process the delete feed data coming in | dataactcore/scripts/pull_fpds_data.py | process_delete_data | RonSherfey/data-act-broker-backend | python | def process_delete_data(data, atom_type):
' '
unique_string =
if (atom_type == 'award'):
try:
unique_string += extract_text(data['awardID']['awardContractID']['agencyID'])
except (KeyError, TypeError):
unique_string += '-none-'
unique_string += '_'
t... |
def create_processed_data_list(data, contract_type, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict):
" Create a list of processed data\n\n Args:\n data: an object containing the data gathered from the feed\n sess: the database connecti... | -8,462,654,797,997,696,000 | Create a list of processed data
Args:
data: an object containing the data gathered from the feed
sess: the database connection
contract_type: a string indicating whether the atom feed being checked is 'award' or 'IDV'
sub_tier_list: a dictionary containing all the sub tier agency information keyed by s... | dataactcore/scripts/pull_fpds_data.py | create_processed_data_list | RonSherfey/data-act-broker-backend | python | def create_processed_data_list(data, contract_type, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict):
" Create a list of processed data\n\n Args:\n data: an object containing the data gathered from the feed\n sess: the database connecti... |
def process_and_add(data, contract_type, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict, now, threaded=False):
" Start the processing for data and add it to the DB.\n\n Args:\n data: an object containing the data gathered from the feed\n ... | -456,377,001,736,376,100 | Start the processing for data and add it to the DB.
Args:
data: an object containing the data gathered from the feed
contract_type: a string indicating whether the atom feed being checked is 'award' or 'IDV'
sess: the database connection
sub_tier_list: a dictionary containing all the sub tier agency in... | dataactcore/scripts/pull_fpds_data.py | process_and_add | RonSherfey/data-act-broker-backend | python | def process_and_add(data, contract_type, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict, now, threaded=False):
" Start the processing for data and add it to the DB.\n\n Args:\n data: an object containing the data gathered from the feed\n ... |
def get_with_exception_hand(url_string, expect_entries=True):
' Retrieve data from FPDS, allow for multiple retries and timeouts '
exception_retries = (- 1)
retry_sleep_times = [5, 30, 60, 180, 300, 360, 420, 480, 540, 600]
request_timeout = 60
while (exception_retries < len(retry_sleep_times)):
... | -7,146,710,792,793,508,000 | Retrieve data from FPDS, allow for multiple retries and timeouts | dataactcore/scripts/pull_fpds_data.py | get_with_exception_hand | RonSherfey/data-act-broker-backend | python | def get_with_exception_hand(url_string, expect_entries=True):
' '
exception_retries = (- 1)
retry_sleep_times = [5, 30, 60, 180, 300, 360, 420, 480, 540, 600]
request_timeout = 60
while (exception_retries < len(retry_sleep_times)):
try:
resp = requests.get(url_string, timeout=re... |
def get_total_expected_records(base_url):
' Retrieve the total number of expected records based on the last paginated URL '
initial_request = get_with_exception_hand(base_url, expect_entries=False)
initial_request_xml = xmltodict.parse(initial_request.text, process_namespaces=True, namespaces=FPDS_NAMESPACE... | -6,784,017,721,531,892,000 | Retrieve the total number of expected records based on the last paginated URL | dataactcore/scripts/pull_fpds_data.py | get_total_expected_records | RonSherfey/data-act-broker-backend | python | def get_total_expected_records(base_url):
' '
initial_request = get_with_exception_hand(base_url, expect_entries=False)
initial_request_xml = xmltodict.parse(initial_request.text, process_namespaces=True, namespaces=FPDS_NAMESPACES)
try:
urls_list = list_data(initial_request_xml['feed']['link']... |
def get_data(contract_type, award_type, now, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict, last_run=None, threaded=False, start_date=None, end_date=None, metrics=None, specific_params=None):
" Get the data from the atom feed based on contract/award type and the ... | -8,891,078,290,683,547,000 | Get the data from the atom feed based on contract/award type and the last time the script was run.
Args:
contract_type: a string indicating whether the atom feed being checked is 'award' or 'IDV'
award_type: a string indicating what the award type of the feed being checked is
now: a timestamp indicating th... | dataactcore/scripts/pull_fpds_data.py | get_data | RonSherfey/data-act-broker-backend | python | def get_data(contract_type, award_type, now, sess, sub_tier_list, county_by_name, county_by_code, state_code_list, country_list, exec_comp_dict, last_run=None, threaded=False, start_date=None, end_date=None, metrics=None, specific_params=None):
" Get the data from the atom feed based on contract/award type and the ... |
def get_delete_data(contract_type, now, sess, last_run, start_date=None, end_date=None, metrics=None):
' Get data from the delete feed '
if (not metrics):
metrics = {}
data = []
yesterday = (now - datetime.timedelta(days=1))
last_run_date = (last_run - relativedelta(days=1))
params = (((... | 6,783,106,870,836,893,000 | Get data from the delete feed | dataactcore/scripts/pull_fpds_data.py | get_delete_data | RonSherfey/data-act-broker-backend | python | def get_delete_data(contract_type, now, sess, last_run, start_date=None, end_date=None, metrics=None):
' '
if (not metrics):
metrics = {}
data = []
yesterday = (now - datetime.timedelta(days=1))
last_run_date = (last_run - relativedelta(days=1))
params = (((('LAST_MOD_DATE:[' + last_run... |
def create_lookups(sess):
' Create the lookups used for FPDS derivations.\n\n Args:\n sess: connection to database\n\n Returns:\n Dictionaries of sub tier agencies by code, country names by code, county names by state code + county\n code, county codes by state code + ... | 623,045,959,743,068,400 | Create the lookups used for FPDS derivations.
Args:
sess: connection to database
Returns:
Dictionaries of sub tier agencies by code, country names by code, county names by state code + county
code, county codes by state code + county name, state name by code, and executive compensation data by
DUNS nu... | dataactcore/scripts/pull_fpds_data.py | create_lookups | RonSherfey/data-act-broker-backend | python | def create_lookups(sess):
' Create the lookups used for FPDS derivations.\n\n Args:\n sess: connection to database\n\n Returns:\n Dictionaries of sub tier agencies by code, country names by code, county names by state code + county\n code, county codes by state code + ... |
def parse_error(self, response):
'Parse an error response'
error_code = response.split(' ')[0]
if (error_code in self.EXCEPTION_CLASSES):
response = response[(len(error_code) + 1):]
return self.EXCEPTION_CLASSES[error_code](response)
return ResponseError(response) | -334,308,344,740,590,700 | Parse an error response | redis/connection.py | parse_error | theatlantic/redis-py | python | def parse_error(self, response):
error_code = response.split(' ')[0]
if (error_code in self.EXCEPTION_CLASSES):
response = response[(len(error_code) + 1):]
return self.EXCEPTION_CLASSES[error_code](response)
return ResponseError(response) |
def on_connect(self, connection):
'Called when the socket connects'
self._sock = connection._sock
self._buffer = SocketBuffer(self._sock, self.socket_read_size)
if connection.decode_responses:
self.encoding = connection.encoding | -1,395,762,390,120,864,500 | Called when the socket connects | redis/connection.py | on_connect | theatlantic/redis-py | python | def on_connect(self, connection):
self._sock = connection._sock
self._buffer = SocketBuffer(self._sock, self.socket_read_size)
if connection.decode_responses:
self.encoding = connection.encoding |
def on_disconnect(self):
'Called when the socket disconnects'
if (self._sock is not None):
self._sock.close()
self._sock = None
if (self._buffer is not None):
self._buffer.close()
self._buffer = None
self.encoding = None | -1,984,250,152,985,980,400 | Called when the socket disconnects | redis/connection.py | on_disconnect | theatlantic/redis-py | python | def on_disconnect(self):
if (self._sock is not None):
self._sock.close()
self._sock = None
if (self._buffer is not None):
self._buffer.close()
self._buffer = None
self.encoding = None |
def connect(self):
'Connects to the Redis server if not already connected'
if self._sock:
return
try:
sock = self._connect()
except socket.error:
e = sys.exc_info()[1]
raise ConnectionError(self._error_message(e))
self._sock = sock
try:
self.on_connect()
... | -1,121,706,814,142,285,700 | Connects to the Redis server if not already connected | redis/connection.py | connect | theatlantic/redis-py | python | def connect(self):
if self._sock:
return
try:
sock = self._connect()
except socket.error:
e = sys.exc_info()[1]
raise ConnectionError(self._error_message(e))
self._sock = sock
try:
self.on_connect()
except RedisError:
self.disconnect()
... |
def _connect(self):
'Create a TCP socket connection'
err = None
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
(family, socktype, proto, canonname, socket_address) = res
sock = None
try:
sock = socket.socket(family, socktype, proto)
... | -3,561,479,361,814,386,000 | Create a TCP socket connection | redis/connection.py | _connect | theatlantic/redis-py | python | def _connect(self):
err = None
for res in socket.getaddrinfo(self.host, self.port, 0, socket.SOCK_STREAM):
(family, socktype, proto, canonname, socket_address) = res
sock = None
try:
sock = socket.socket(family, socktype, proto)
sock.setsockopt(socket.IPPROTO... |
def on_connect(self):
'Initialize the connection, authenticate and select a database'
self._parser.on_connect(self)
if self.password:
self.send_command('AUTH', self.password)
if (nativestr(self.read_response()) != 'OK'):
raise AuthenticationError('Invalid Password')
if self.d... | 6,806,879,356,599,901,000 | Initialize the connection, authenticate and select a database | redis/connection.py | on_connect | theatlantic/redis-py | python | def on_connect(self):
self._parser.on_connect(self)
if self.password:
self.send_command('AUTH', self.password)
if (nativestr(self.read_response()) != 'OK'):
raise AuthenticationError('Invalid Password')
if self.db:
self.send_command('SELECT', self.db)
if (nat... |
def disconnect(self):
'Disconnects from the Redis server'
self._parser.on_disconnect()
if (self._sock is None):
return
try:
self._sock.shutdown(socket.SHUT_RDWR)
self._sock.close()
except socket.error:
pass
self._sock = None | -2,481,068,027,114,127,400 | Disconnects from the Redis server | redis/connection.py | disconnect | theatlantic/redis-py | python | def disconnect(self):
self._parser.on_disconnect()
if (self._sock is None):
return
try:
self._sock.shutdown(socket.SHUT_RDWR)
self._sock.close()
except socket.error:
pass
self._sock = None |
def send_packed_command(self, command):
'Send an already packed command to the Redis server'
if (not self._sock):
self.connect()
try:
if isinstance(command, str):
command = [command]
for item in command:
self._sock.sendall(item)
except socket.timeout:
... | 5,029,571,864,003,598,000 | Send an already packed command to the Redis server | redis/connection.py | send_packed_command | theatlantic/redis-py | python | def send_packed_command(self, command):
if (not self._sock):
self.connect()
try:
if isinstance(command, str):
command = [command]
for item in command:
self._sock.sendall(item)
except socket.timeout:
self.disconnect()
raise TimeoutError('Ti... |
def send_command(self, *args):
'Pack and send a command to the Redis server'
self.send_packed_command(self.pack_command(*args)) | -5,852,361,404,330,154,000 | Pack and send a command to the Redis server | redis/connection.py | send_command | theatlantic/redis-py | python | def send_command(self, *args):
self.send_packed_command(self.pack_command(*args)) |
def can_read(self, timeout=0):
"Poll the socket to see if there's data that can be read."
sock = self._sock
if (not sock):
self.connect()
sock = self._sock
return (self._parser.can_read() or bool(select([sock], [], [], timeout)[0])) | 3,041,537,158,249,160,700 | Poll the socket to see if there's data that can be read. | redis/connection.py | can_read | theatlantic/redis-py | python | def can_read(self, timeout=0):
sock = self._sock
if (not sock):
self.connect()
sock = self._sock
return (self._parser.can_read() or bool(select([sock], [], [], timeout)[0])) |
def read_response(self):
'Read the response from a previously sent command'
try:
response = self._parser.read_response()
except:
self.disconnect()
raise
if isinstance(response, ResponseError):
raise response
return response | -6,449,246,373,174,010,000 | Read the response from a previously sent command | redis/connection.py | read_response | theatlantic/redis-py | python | def read_response(self):
try:
response = self._parser.read_response()
except:
self.disconnect()
raise
if isinstance(response, ResponseError):
raise response
return response |
def encode(self, value):
'Return a bytestring representation of the value'
if isinstance(value, Token):
return b(value.value)
elif isinstance(value, bytes):
return value
elif isinstance(value, (int, long)):
value = b(str(value))
elif isinstance(value, float):
value = ... | 5,629,754,806,404,947,000 | Return a bytestring representation of the value | redis/connection.py | encode | theatlantic/redis-py | python | def encode(self, value):
if isinstance(value, Token):
return b(value.value)
elif isinstance(value, bytes):
return value
elif isinstance(value, (int, long)):
value = b(str(value))
elif isinstance(value, float):
value = b(repr(value))
elif (not isinstance(value, ba... |
def pack_command(self, *args):
'Pack a series of arguments into the Redis protocol'
output = []
command = args[0]
if (' ' in command):
args = (tuple([Token(s) for s in command.split(' ')]) + args[1:])
else:
args = ((Token(command),) + args[1:])
buff = SYM_EMPTY.join((SYM_STAR, b(... | 4,355,786,805,303,592,400 | Pack a series of arguments into the Redis protocol | redis/connection.py | pack_command | theatlantic/redis-py | python | def pack_command(self, *args):
output = []
command = args[0]
if (' ' in command):
args = (tuple([Token(s) for s in command.split(' ')]) + args[1:])
else:
args = ((Token(command),) + args[1:])
buff = SYM_EMPTY.join((SYM_STAR, b(str(len(args))), SYM_CRLF))
for arg in imap(self... |
def pack_commands(self, commands):
'Pack multiple commands into the Redis protocol'
output = []
pieces = []
buffer_length = 0
for cmd in commands:
for chunk in self.pack_command(*cmd):
pieces.append(chunk)
buffer_length += len(chunk)
if (buffer_length > 6000):... | -8,819,228,036,080,144,000 | Pack multiple commands into the Redis protocol | redis/connection.py | pack_commands | theatlantic/redis-py | python | def pack_commands(self, commands):
output = []
pieces = []
buffer_length = 0
for cmd in commands:
for chunk in self.pack_command(*cmd):
pieces.append(chunk)
buffer_length += len(chunk)
if (buffer_length > 6000):
output.append(SYM_EMPTY.join(pieces... |
def _connect(self):
'Wrap the socket with SSL support'
sock = super(SSLConnection, self)._connect()
sock = ssl.wrap_socket(sock, cert_reqs=self.cert_reqs, keyfile=self.keyfile, certfile=self.certfile, ca_certs=self.ca_certs)
return sock | -2,325,370,612,891,198,500 | Wrap the socket with SSL support | redis/connection.py | _connect | theatlantic/redis-py | python | def _connect(self):
sock = super(SSLConnection, self)._connect()
sock = ssl.wrap_socket(sock, cert_reqs=self.cert_reqs, keyfile=self.keyfile, certfile=self.certfile, ca_certs=self.ca_certs)
return sock |
def _connect(self):
'Create a Unix domain socket connection'
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.settimeout(self.socket_timeout)
sock.connect(self.path)
return sock | 2,119,124,442,193,394,700 | Create a Unix domain socket connection | redis/connection.py | _connect | theatlantic/redis-py | python | def _connect(self):
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
sock.settimeout(self.socket_timeout)
sock.connect(self.path)
return sock |
@classmethod
def from_url(cls, url, db=None, decode_components=False, **kwargs):
"\n Return a connection pool configured from the given URL.\n\n For example::\n\n redis://[:password]@localhost:6379/0\n rediss://[:password]@localhost:6379/0\n unix://[:password]@/path/to... | 8,498,954,111,016,500,000 | Return a connection pool configured from the given URL.
For example::
redis://[:password]@localhost:6379/0
rediss://[:password]@localhost:6379/0
unix://[:password]@/path/to/socket.sock?db=0
Three URL schemes are supported:
redis:// creates a normal TCP socket connection
rediss:// creates a SSL wr... | redis/connection.py | from_url | theatlantic/redis-py | python | @classmethod
def from_url(cls, url, db=None, decode_components=False, **kwargs):
"\n Return a connection pool configured from the given URL.\n\n For example::\n\n redis://[:password]@localhost:6379/0\n rediss://[:password]@localhost:6379/0\n unix://[:password]@/path/to... |
def __init__(self, connection_class=Connection, max_connections=None, **connection_kwargs):
"\n Create a connection pool. If max_connections is set, then this\n object raises redis.ConnectionError when the pool's limit is reached.\n\n By default, TCP connections are created connection_class is ... | -376,968,440,516,761,660 | Create a connection pool. If max_connections is set, then this
object raises redis.ConnectionError when the pool's limit is reached.
By default, TCP connections are created connection_class is specified.
Use redis.UnixDomainSocketConnection for unix sockets.
Any additional keyword arguments are passed to the construc... | redis/connection.py | __init__ | theatlantic/redis-py | python | def __init__(self, connection_class=Connection, max_connections=None, **connection_kwargs):
"\n Create a connection pool. If max_connections is set, then this\n object raises redis.ConnectionError when the pool's limit is reached.\n\n By default, TCP connections are created connection_class is ... |
def get_connection(self, command_name, *keys, **options):
'Get a connection from the pool'
self._checkpid()
try:
connection = self._available_connections.pop()
except IndexError:
connection = self.make_connection()
self._in_use_connections.add(connection)
return connection | 3,067,355,640,920,227,300 | Get a connection from the pool | redis/connection.py | get_connection | theatlantic/redis-py | python | def get_connection(self, command_name, *keys, **options):
self._checkpid()
try:
connection = self._available_connections.pop()
except IndexError:
connection = self.make_connection()
self._in_use_connections.add(connection)
return connection |
def make_connection(self):
'Create a new connection'
if (self._created_connections >= self.max_connections):
raise ConnectionError('Too many connections')
self._created_connections += 1
return self.connection_class(**self.connection_kwargs) | 6,708,195,135,593,214,000 | Create a new connection | redis/connection.py | make_connection | theatlantic/redis-py | python | def make_connection(self):
if (self._created_connections >= self.max_connections):
raise ConnectionError('Too many connections')
self._created_connections += 1
return self.connection_class(**self.connection_kwargs) |
def release(self, connection):
'Releases the connection back to the pool'
self._checkpid()
if (connection.pid != self.pid):
return
self._in_use_connections.remove(connection)
self._available_connections.append(connection) | 8,546,149,006,600,573,000 | Releases the connection back to the pool | redis/connection.py | release | theatlantic/redis-py | python | def release(self, connection):
self._checkpid()
if (connection.pid != self.pid):
return
self._in_use_connections.remove(connection)
self._available_connections.append(connection) |
def disconnect(self):
'Disconnects all connections in the pool'
all_conns = chain(self._available_connections, self._in_use_connections)
for connection in all_conns:
connection.disconnect() | 4,989,466,151,080,915,000 | Disconnects all connections in the pool | redis/connection.py | disconnect | theatlantic/redis-py | python | def disconnect(self):
all_conns = chain(self._available_connections, self._in_use_connections)
for connection in all_conns:
connection.disconnect() |
def make_connection(self):
'Make a fresh connection.'
connection = self.connection_class(**self.connection_kwargs)
self._connections.append(connection)
return connection | -3,766,099,365,760,060,000 | Make a fresh connection. | redis/connection.py | make_connection | theatlantic/redis-py | python | def make_connection(self):
connection = self.connection_class(**self.connection_kwargs)
self._connections.append(connection)
return connection |
def get_connection(self, command_name, *keys, **options):
'\n Get a connection, blocking for ``self.timeout`` until a connection\n is available from the pool.\n\n If the connection returned is ``None`` then creates a new connection.\n Because we use a last-in first-out queue, the existin... | 1,012,438,289,656,912,300 | Get a connection, blocking for ``self.timeout`` until a connection
is available from the pool.
If the connection returned is ``None`` then creates a new connection.
Because we use a last-in first-out queue, the existing connections
(having been returned to the pool after the initial ``None`` values
were added) will be... | redis/connection.py | get_connection | theatlantic/redis-py | python | def get_connection(self, command_name, *keys, **options):
'\n Get a connection, blocking for ``self.timeout`` until a connection\n is available from the pool.\n\n If the connection returned is ``None`` then creates a new connection.\n Because we use a last-in first-out queue, the existin... |
def release(self, connection):
'Releases the connection back to the pool.'
self._checkpid()
if (connection.pid != self.pid):
return
try:
self.pool.put_nowait(connection)
except Full:
pass | 4,498,462,219,287,807,000 | Releases the connection back to the pool. | redis/connection.py | release | theatlantic/redis-py | python | def release(self, connection):
self._checkpid()
if (connection.pid != self.pid):
return
try:
self.pool.put_nowait(connection)
except Full:
pass |
def disconnect(self):
'Disconnects all connections in the pool.'
for connection in self._connections:
connection.disconnect() | 8,128,324,116,068,593,000 | Disconnects all connections in the pool. | redis/connection.py | disconnect | theatlantic/redis-py | python | def disconnect(self):
for connection in self._connections:
connection.disconnect() |
def input_dictionary(run_str):
' Parses the `input` block and builds a\n dictionary of keywords and their corresponding values.\n\n :param run_str: input string of the run.dat block\n :type run_str: str\n :rtype: dict[str: obj]\n '
inp_block = ioformat.ptt.end_block(run_str, 'inpu... | 655,159,734,187,371,000 | Parses the `input` block and builds a
dictionary of keywords and their corresponding values.
:param run_str: input string of the run.dat block
:type run_str: str
:rtype: dict[str: obj] | mechlib/amech_io/parser/run.py | input_dictionary | Auto-Mech/moldriver | python | def input_dictionary(run_str):
' Parses the `input` block and builds a\n dictionary of keywords and their corresponding values.\n\n :param run_str: input string of the run.dat block\n :type run_str: str\n :rtype: dict[str: obj]\n '
inp_block = ioformat.ptt.end_block(run_str, 'inpu... |
def chem_idxs(run_str):
' Parses the `pes` block of the run.dat file and\n builds a dictionary of the PESs and corresponding channels the\n user wishes to run.\n\n Parses the `spc` block of the run.dat file and\n builds a dictionary of the species the\n user wishes to run.\n... | 487,741,308,159,634,100 | Parses the `pes` block of the run.dat file and
builds a dictionary of the PESs and corresponding channels the
user wishes to run.
Parses the `spc` block of the run.dat file and
builds a dictionary of the species the
user wishes to run.
May break if idx is given on two lines of string.
:param run_str: string of... | mechlib/amech_io/parser/run.py | chem_idxs | Auto-Mech/moldriver | python | def chem_idxs(run_str):
' Parses the `pes` block of the run.dat file and\n builds a dictionary of the PESs and corresponding channels the\n user wishes to run.\n\n Parses the `spc` block of the run.dat file and\n builds a dictionary of the species the\n user wishes to run.\n... |
def extract_task(tsk, tsk_lst):
' Searches for a task in the task lst and if found:\n the corresponding keywords and values will be returned\n\n Function only works if task is present in the list one time.\n\n :param tsk: task to extract information for\n :type tsk: str\n :param t... | 5,581,091,852,028,295,000 | Searches for a task in the task lst and if found:
the corresponding keywords and values will be returned
Function only works if task is present in the list one time.
:param tsk: task to extract information for
:type tsk: str
:param tsk_lst: list of tasks to run for some driver
:type tsk_lst: tuple(tuple(str/dict))
:r... | mechlib/amech_io/parser/run.py | extract_task | Auto-Mech/moldriver | python | def extract_task(tsk, tsk_lst):
' Searches for a task in the task lst and if found:\n the corresponding keywords and values will be returned\n\n Function only works if task is present in the list one time.\n\n :param tsk: task to extract information for\n :type tsk: str\n :param t... |
def tasks(run_str, thy_dct):
' runstr\n '
es_block = ioformat.ptt.end_block(run_str, 'els', footer='els')
trans_block = ioformat.ptt.end_block(run_str, 'trans', footer='trans')
therm_block = ioformat.ptt.end_block(run_str, 'thermo', footer='thermo')
ktp_block = ioformat.ptt.end_block(run_str, 'kt... | -5,821,437,077,531,401,000 | runstr | mechlib/amech_io/parser/run.py | tasks | Auto-Mech/moldriver | python | def tasks(run_str, thy_dct):
' \n '
es_block = ioformat.ptt.end_block(run_str, 'els', footer='els')
trans_block = ioformat.ptt.end_block(run_str, 'trans', footer='trans')
therm_block = ioformat.ptt.end_block(run_str, 'thermo', footer='thermo')
ktp_block = ioformat.ptt.end_block(run_str, 'ktp', fo... |
def _tsk_lst(tsk_str, num):
' Set the sequence of electronic structure tasks for a given\n species or PESs\n '
if (tsk_str is not None):
tsks = []
tsk_str = ioformat.remove_whitespace_from_string(tsk_str)
for line in tsk_str.splitlines():
_tsk = _split_line(line, nu... | 8,422,428,378,274,636,000 | Set the sequence of electronic structure tasks for a given
species or PESs | mechlib/amech_io/parser/run.py | _tsk_lst | Auto-Mech/moldriver | python | def _tsk_lst(tsk_str, num):
' Set the sequence of electronic structure tasks for a given\n species or PESs\n '
if (tsk_str is not None):
tsks = []
tsk_str = ioformat.remove_whitespace_from_string(tsk_str)
for line in tsk_str.splitlines():
_tsk = _split_line(line, nu... |
def _expand_tsks(tsks_lst):
' Loops over the driver task list and checks if each task is a\n macro-task that should be expanded into sub-tasks.\n\n Right now, it splits all obj tasks into spc and ts\n\n :param tsk_lst: list of tasks to run for some driver\n :type tsk_lst: tuple(tuple... | 8,819,405,878,303,621,000 | Loops over the driver task list and checks if each task is a
macro-task that should be expanded into sub-tasks.
Right now, it splits all obj tasks into spc and ts
:param tsk_lst: list of tasks to run for some driver
:type tsk_lst: tuple(tuple(str/dict))
:rtype: tuple(str/dict) | mechlib/amech_io/parser/run.py | _expand_tsks | Auto-Mech/moldriver | python | def _expand_tsks(tsks_lst):
' Loops over the driver task list and checks if each task is a\n macro-task that should be expanded into sub-tasks.\n\n Right now, it splits all obj tasks into spc and ts\n\n :param tsk_lst: list of tasks to run for some driver\n :type tsk_lst: tuple(tuple... |
def _tsk_defaults(tsk_lst):
' Fill out the keyword dictionaries for various task lists with\n default values\n '
if (tsk_lst is not None):
mod_tsk_lst = []
for _tsk_lst in tsk_lst:
keyword_dct = _tsk_lst[(- 1)]
tsk = _tsk_lst[:(- 1)][(- 1)]
default_d... | -5,588,439,981,594,771,000 | Fill out the keyword dictionaries for various task lists with
default values | mechlib/amech_io/parser/run.py | _tsk_defaults | Auto-Mech/moldriver | python | def _tsk_defaults(tsk_lst):
' Fill out the keyword dictionaries for various task lists with\n default values\n '
if (tsk_lst is not None):
mod_tsk_lst = []
for _tsk_lst in tsk_lst:
keyword_dct = _tsk_lst[(- 1)]
tsk = _tsk_lst[:(- 1)][(- 1)]
default_d... |
def _check_tsks(tsk_lsts, thy_dct):
' Loop over all of the tasks, add default keywords and parameters\n and assesses if all the input is valid\n '
if (tsk_lsts is not None):
for tsk_lst in tsk_lsts:
_tsk = tsk_lst[:(- 1)]
if (len(_tsk) == 2):
(obj, tsk) ... | -1,710,753,616,298,786,600 | Loop over all of the tasks, add default keywords and parameters
and assesses if all the input is valid | mechlib/amech_io/parser/run.py | _check_tsks | Auto-Mech/moldriver | python | def _check_tsks(tsk_lsts, thy_dct):
' Loop over all of the tasks, add default keywords and parameters\n and assesses if all the input is valid\n '
if (tsk_lsts is not None):
for tsk_lst in tsk_lsts:
_tsk = tsk_lst[:(- 1)]
if (len(_tsk) == 2):
(obj, tsk) ... |
def _split_line(line, num):
' Split a line\n '
line = line.split()
if (num == 3):
(tsk, key_lst) = (line[:2], line[2:])
elif (num == 2):
(tsk, key_lst) = (line[:1], line[1:])
key_dct = ioformat.ptt.keyword_dct_from_block('\n'.join(key_lst))
return (tsk + [key_dct]) | -5,998,307,887,310,728,000 | Split a line | mechlib/amech_io/parser/run.py | _split_line | Auto-Mech/moldriver | python | def _split_line(line, num):
' \n '
line = line.split()
if (num == 3):
(tsk, key_lst) = (line[:2], line[2:])
elif (num == 2):
(tsk, key_lst) = (line[:1], line[1:])
key_dct = ioformat.ptt.keyword_dct_from_block('\n'.join(key_lst))
return (tsk + [key_dct]) |
def check_inputs(tsk_dct, pes_dct, pes_mod_dct, spc_mod_dct):
' Check if inputs placed that is required\n '
if (tsk_dct['ktp'] or tsk_dct['thermo']):
if (pes_mod_dct is None):
error_message('kTPDriver or Thermo Requested. \n However no kin model provided in models.dat\n Exiting MechDriver... | 6,198,580,794,665,911,000 | Check if inputs placed that is required | mechlib/amech_io/parser/run.py | check_inputs | Auto-Mech/moldriver | python | def check_inputs(tsk_dct, pes_dct, pes_mod_dct, spc_mod_dct):
' \n '
if (tsk_dct['ktp'] or tsk_dct['thermo']):
if (pes_mod_dct is None):
error_message('kTPDriver or Thermo Requested. \n However no kin model provided in models.dat\n Exiting MechDriver...')
sys.exit()
if... |
def ngram_processor(items, ngram_len):
'\n Given a sequence or iterable of arbitrary items, return an iterator of\n item ngrams tuples of length ngram_len. Buffers at most ngram_len iterable\n items.\n\n For example::\n\n >>> list(ngram_processor([1, 2, 3, 4, 5... | 179,317,752,332,103,300 | Given a sequence or iterable of arbitrary items, return an iterator of
item ngrams tuples of length ngram_len. Buffers at most ngram_len iterable
items.
For example::
>>> list(ngram_processor([1, 2, 3, 4, 5], ngram_len=3))
[(1, 2, 3), (2, 3, 4), (3, 4, 5)] | tests/textcode/test_analysis.py | ngram_processor | pombredanne/scancode-toolkit | python | def ngram_processor(items, ngram_len):
'\n Given a sequence or iterable of arbitrary items, return an iterator of\n item ngrams tuples of length ngram_len. Buffers at most ngram_len iterable\n items.\n\n For example::\n\n >>> list(ngram_processor([1, 2, 3, 4, 5... |
def ignore(x):
'Method to indicate bypassing property validation'
return x | 857,614,166,513,775,100 | Method to indicate bypassing property validation | troposphere/validators.py | ignore | akerbergen/troposphere | python | def ignore(x):
return x |
def defer(x):
'Method to indicate defering property validation'
return x | 2,087,068,956,255,348,000 | Method to indicate defering property validation | troposphere/validators.py | defer | akerbergen/troposphere | python | def defer(x):
return x |
def __init__(self, assets_dir=None, physics_backend='BulletPhysics', time_step=0.001, gravity=[0, 0, (- 9.8)], worker_id=0, use_visualizer=False):
'Initialize the simulator.\n\n Args:\n assets_dir: The assets directory.\n physics_backend: Name of the physics engine backend.\n ... | -3,805,035,608,652,995,600 | Initialize the simulator.
Args:
assets_dir: The assets directory.
physics_backend: Name of the physics engine backend.
time_step: Time step of the simulation.
gravity: The gravity as a 3-dimensional vector.
worker_id: The id of the multi-threaded simulation.
use_visualizer: Render the simulatio... | robovat/simulation/simulator.py | __init__ | StanfordVL/robovat | python | def __init__(self, assets_dir=None, physics_backend='BulletPhysics', time_step=0.001, gravity=[0, 0, (- 9.8)], worker_id=0, use_visualizer=False):
'Initialize the simulator.\n\n Args:\n assets_dir: The assets directory.\n physics_backend: Name of the physics engine backend.\n ... |
def __del__(self):
'Delete the simulator.'
del self._physics | -1,470,313,404,570,486,500 | Delete the simulator. | robovat/simulation/simulator.py | __del__ | StanfordVL/robovat | python | def __del__(self):
del self._physics |
def reset(self):
'Reset the simulation.'
self.physics.reset()
self.physics.set_gravity(self._gravity)
self._bodies = dict()
self._constraints = dict()
self._num_steps = 0 | 8,568,562,312,400,552,000 | Reset the simulation. | robovat/simulation/simulator.py | reset | StanfordVL/robovat | python | def reset(self):
self.physics.reset()
self.physics.set_gravity(self._gravity)
self._bodies = dict()
self._constraints = dict()
self._num_steps = 0 |
def start(self):
'Start the simulation.'
self.physics.start()
self._num_steps = 0 | -3,988,843,183,428,890,000 | Start the simulation. | robovat/simulation/simulator.py | start | StanfordVL/robovat | python | def start(self):
self.physics.start()
self._num_steps = 0 |
def step(self):
'Take a simulation step.'
for body in self.bodies.values():
body.update()
for constraint in self.constraints.values():
constraint.update()
self.physics.step()
self._num_steps += 1 | 5,010,890,271,759,245,000 | Take a simulation step. | robovat/simulation/simulator.py | step | StanfordVL/robovat | python | def step(self):
for body in self.bodies.values():
body.update()
for constraint in self.constraints.values():
constraint.update()
self.physics.step()
self._num_steps += 1 |
def add_body(self, filename, pose=None, scale=1.0, is_static=False, is_controllable=False, name=None):
'Add a body to the simulation.\n\n Args:\n filename: The path to the URDF file to be loaded. If the path is\n not absolute path, it will be joined with the assets directory.\n ... | -787,321,298,949,126,800 | Add a body to the simulation.
Args:
filename: The path to the URDF file to be loaded. If the path is
not absolute path, it will be joined with the assets directory.
pose: The initial pose as an instance of Pose.
scale: The scaling factor of the body.
is_static: If True, set the base of the body... | robovat/simulation/simulator.py | add_body | StanfordVL/robovat | python | def add_body(self, filename, pose=None, scale=1.0, is_static=False, is_controllable=False, name=None):
'Add a body to the simulation.\n\n Args:\n filename: The path to the URDF file to be loaded. If the path is\n not absolute path, it will be joined with the assets directory.\n ... |
def remove_body(self, name):
'Remove the body.\n\n Args:\n body: An instance of Body.\n '
self.physics.remove_body(self._bodies[name].uid)
del self._bodies[name] | -7,921,277,802,025,198,000 | Remove the body.
Args:
body: An instance of Body. | robovat/simulation/simulator.py | remove_body | StanfordVL/robovat | python | def remove_body(self, name):
'Remove the body.\n\n Args:\n body: An instance of Body.\n '
self.physics.remove_body(self._bodies[name].uid)
del self._bodies[name] |
def add_constraint(self, parent, child, joint_type='fixed', joint_axis=[0, 0, 0], parent_frame_pose=None, child_frame_pose=None, max_force=None, max_linear_velocity=None, max_angular_velocity=None, is_controllable=False, name=None):
'Add a constraint to the simulation.\n\n Args:\n parent: The pare... | -7,531,566,976,571,550,000 | Add a constraint to the simulation.
Args:
parent: The parent entity as an instance of Entity.
child: The child entity as an instance of Entity.
joint_type: The type of the joint.
joint_axis: The axis of the joint.
parent_frame_pose: The pose of the joint in the parent frame.
child_frame_pose: T... | robovat/simulation/simulator.py | add_constraint | StanfordVL/robovat | python | def add_constraint(self, parent, child, joint_type='fixed', joint_axis=[0, 0, 0], parent_frame_pose=None, child_frame_pose=None, max_force=None, max_linear_velocity=None, max_angular_velocity=None, is_controllable=False, name=None):
'Add a constraint to the simulation.\n\n Args:\n parent: The pare... |
def receive_robot_commands(self, robot_command, component_type='body'):
"Receive a robot command.\n\n Args:\n robot_command: An instance of RobotCommand.\n component_type: Either 'body' or 'constraint'.\n "
if (component_type == 'body'):
component = self._bodies[robot... | -704,132,049,575,272,300 | Receive a robot command.
Args:
robot_command: An instance of RobotCommand.
component_type: Either 'body' or 'constraint'. | robovat/simulation/simulator.py | receive_robot_commands | StanfordVL/robovat | python | def receive_robot_commands(self, robot_command, component_type='body'):
"Receive a robot command.\n\n Args:\n robot_command: An instance of RobotCommand.\n component_type: Either 'body' or 'constraint'.\n "
if (component_type == 'body'):
component = self._bodies[robot... |
def check_contact(self, entity_a, entity_b=None):
'Check if the loaded object is stable.\n\n Args:\n entity_a: The first entity.\n entity_b: The second entity, None for any entities.\n\n Returns:\n True if they have contacts, False otherwise.\n '
def _check... | -2,138,105,238,576,339,000 | Check if the loaded object is stable.
Args:
entity_a: The first entity.
entity_b: The second entity, None for any entities.
Returns:
True if they have contacts, False otherwise. | robovat/simulation/simulator.py | check_contact | StanfordVL/robovat | python | def check_contact(self, entity_a, entity_b=None):
'Check if the loaded object is stable.\n\n Args:\n entity_a: The first entity.\n entity_b: The second entity, None for any entities.\n\n Returns:\n True if they have contacts, False otherwise.\n '
def _check... |
def check_stable(self, body, linear_velocity_threshold, angular_velocity_threshold):
'Check if the loaded object is stable.\n\n Args:\n body: An instance of body or a list of bodies.\n linear_velocity_threshold: Linear velocity threshold of being\n stable.\n an... | 7,935,277,843,279,572,000 | Check if the loaded object is stable.
Args:
body: An instance of body or a list of bodies.
linear_velocity_threshold: Linear velocity threshold of being
stable.
angular_velocity_threshold: Angular velocity threshold of being
stable.
Returns:
is_stable: True if the linear velocity and t... | robovat/simulation/simulator.py | check_stable | StanfordVL/robovat | python | def check_stable(self, body, linear_velocity_threshold, angular_velocity_threshold):
'Check if the loaded object is stable.\n\n Args:\n body: An instance of body or a list of bodies.\n linear_velocity_threshold: Linear velocity threshold of being\n stable.\n an... |
def wait_until_stable(self, body, linear_velocity_threshold=0.005, angular_velocity_threshold=0.005, check_after_steps=100, min_stable_steps=100, max_steps=2000):
'Wait until the objects are stable.\n\n Args:\n body: An instance of body or a list of bodies.\n linear_velocity_threshold: ... | 731,992,707,841,130,100 | Wait until the objects are stable.
Args:
body: An instance of body or a list of bodies.
linear_velocity_threshold: Linear velocity threshold of being
stable.
angular_velocity_threshold: Angular velocity threshold of being
stable.
check_after_steps: Number of steps before checking.
m... | robovat/simulation/simulator.py | wait_until_stable | StanfordVL/robovat | python | def wait_until_stable(self, body, linear_velocity_threshold=0.005, angular_velocity_threshold=0.005, check_after_steps=100, min_stable_steps=100, max_steps=2000):
'Wait until the objects are stable.\n\n Args:\n body: An instance of body or a list of bodies.\n linear_velocity_threshold: ... |
def plot_pose(self, pose, axis_length=1.0, text=None, text_size=1.0, text_color=[0, 0, 0]):
'Plot a 6-DoF pose or a frame in the debugging visualizer.\n\n Args:\n pose: The pose to be plot.\n axis_length: The length of the axes.\n text: Text showing up next to the frame.\n ... | -8,379,458,917,217,585,000 | Plot a 6-DoF pose or a frame in the debugging visualizer.
Args:
pose: The pose to be plot.
axis_length: The length of the axes.
text: Text showing up next to the frame.
text_size: Size of the text.
text_color: Color of the text. | robovat/simulation/simulator.py | plot_pose | StanfordVL/robovat | python | def plot_pose(self, pose, axis_length=1.0, text=None, text_size=1.0, text_color=[0, 0, 0]):
'Plot a 6-DoF pose or a frame in the debugging visualizer.\n\n Args:\n pose: The pose to be plot.\n axis_length: The length of the axes.\n text: Text showing up next to the frame.\n ... |
def plot_line(self, start, end, line_color=[0, 0, 0], line_width=1):
'Plot a pose or a frame in the debugging visualizer.\n\n Args:\n start: Starting point of the line.\n end: Ending point of the line.\n line_color: Color of the line.\n line_width: Width of the lin... | 8,925,551,087,014,710,000 | Plot a pose or a frame in the debugging visualizer.
Args:
start: Starting point of the line.
end: Ending point of the line.
line_color: Color of the line.
line_width: Width of the line. | robovat/simulation/simulator.py | plot_line | StanfordVL/robovat | python | def plot_line(self, start, end, line_color=[0, 0, 0], line_width=1):
'Plot a pose or a frame in the debugging visualizer.\n\n Args:\n start: Starting point of the line.\n end: Ending point of the line.\n line_color: Color of the line.\n line_width: Width of the lin... |
def clear_visualization(self):
'Clear all visualization items.'
pybullet.removeAllUserDebugItems() | 5,383,127,262,027,536,000 | Clear all visualization items. | robovat/simulation/simulator.py | clear_visualization | StanfordVL/robovat | python | def clear_visualization(self):
pybullet.removeAllUserDebugItems() |
def __init__(self):
'Default constructor'
self.rgb_image_topic = rospy.get_param('~rgb_image_topic', '/camera/rgb/image_raw')
self.camera_publisher = rospy.Publisher(self.rgb_image_topic, sensor_msgs.msg.Image, queue_size=1)
self.camera_pub_frequency = rospy.get_param('~camera_pub_frequency', 20)
se... | 7,922,984,320,217,438,000 | Default constructor | scripts/camera_publisher_node.py | __init__ | Alexandre-Bonneau/uwds3_perception | python | def __init__(self):
self.rgb_image_topic = rospy.get_param('~rgb_image_topic', '/camera/rgb/image_raw')
self.camera_publisher = rospy.Publisher(self.rgb_image_topic, sensor_msgs.msg.Image, queue_size=1)
self.camera_pub_frequency = rospy.get_param('~camera_pub_frequency', 20)
self.bridge = CvBridge(... |
def test_get_time_range() -> None:
'\n Test finding the time range of a query.\n '
body = {'selected_columns': ['event_id'], 'conditions': [('timestamp', '>=', '2019-09-18T10:00:00'), ('timestamp', '>=', '2000-09-18T10:00:00'), ('timestamp', '<', '2019-09-19T12:00:00'), [('timestamp', '<', '2019-09-18T12:... | -293,156,988,971,422,200 | Test finding the time range of a query. | tests/clickhouse/query_dsl/test_time_range.py | test_get_time_range | fpacifici/snuba | python | def test_get_time_range() -> None:
'\n \n '
body = {'selected_columns': ['event_id'], 'conditions': [('timestamp', '>=', '2019-09-18T10:00:00'), ('timestamp', '>=', '2000-09-18T10:00:00'), ('timestamp', '<', '2019-09-19T12:00:00'), [('timestamp', '<', '2019-09-18T12:00:00'), ('project_id', 'IN', [1])], ('... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.