text stringlengths 0 828 |
|---|
regionID = region_id, |
typeID = type_id, |
rows = rows, |
)) |
json_dict = { |
'resultType': 'history', |
'version': '0.1', |
'uploadKeys': history_list.upload_keys, |
'generator': history_list.history_generator, |
'currentTime': gen_iso_datetime_str(now_dtime_in_utc()), |
# This must match the order of the values in the row assembling portion |
# above this. |
'columns': STANDARD_ENCODED_COLUMNS, |
'rowsets': rowsets, |
} |
return json.dumps(json_dict)" |
309,"def load(self, configuration): |
"""""" |
Load a YAML configuration file. |
:param configuration: Configuration filename or YAML string |
"""""" |
try: |
self.config = yaml.load(open(configuration, ""rb"")) |
except IOError: |
try: |
self.config = yaml.load(configuration) |
except ParserError, e: |
raise ParserError('Error parsing config: %s' % e) |
# put customer data into self.customer |
if isinstance(self.config, dict): |
self.customer = self.config.get('customer', {}) |
self.instances_dict = self.config.get('instances', {}) |
self.web2py_dir = self.config.get('web2py', None) |
self.api_type = self.config.get('api_type', 'jsonrpc') |
self.valid = True |
else: |
self.customer = {} |
self.instances_dict = {} |
self.web2py_dir = None |
self.valid = False" |
310,"def instances(self, test_type="".*""): |
"""""" |
Returns a dict of all instances defined using a regex |
:param test_type: Regular expression to match for self.instance['test_type'] value names |
"""""" |
import re |
data = {} |
for k, v in self.instances_dict.iteritems(): |
if re.match(test_type, v.get('test_type'), re.IGNORECASE): |
if 'filter_type' in v: |
hostfilter = { |
'filtertype': v['filter_type'], |
'content': v['filter_value'] |
} |
else: |
hostfilter = {} |
data[k] = { |
'name': v.get('name'), |
'start': v.get('start'), |
'end': v.get('end'), |
'url': v.get('url'), |
'hostfilter': hostfilter, |
'test_type': v.get('test_type') |
} |
return data" |
311,"def none_to_blank(s, exchange=''): |
""""""Replaces NoneType with '' |
>>> none_to_blank(None, '') |
'' |
>>> none_to_blank(None) |
'' |
>>> none_to_blank('something', '') |
u'something' |
>>> none_to_blank(['1', None]) |
[u'1', ''] |
:param s: String to replace |
:para exchange: Character to return for None, default is blank ('') |
:return: If s is None, returns exchange |
"""""" |
if isinstance(s, list): |
return [none_to_blank(z) for y, z in enumerate(s)] |
return exchange if s is None else unicode(s)" |
312,"def make_good_url(url=None, addition=""/""): |
""""""Appends addition to url, ensuring the right number of slashes |
exist and the path doesn't get clobbered. |
>>> make_good_url('http://www.server.com/anywhere', 'else') |
'http://www.server.com/anywhere/else' |
>>> make_good_url('http://test.com/', '/somewhere/over/the/rainbow/') |
'http://test.com/somewhere/over/the/rainbow/' |
>>> make_good_url('None') |
'None/' |
>>> make_good_url() |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.