text stringlengths 0 828 |
|---|
'USER': url.username or '', |
'PASSWORD': url.password or '', |
'HOST': url.hostname or '', |
'PORT': url.port or '', |
}) |
if url.scheme in DATABASE_SCHEMES: |
config['ENGINE'] = DATABASE_SCHEMES[url.scheme] |
return config" |
4078,"def config(name='DATABASE_URL', default='sqlite://:memory:'): |
""""""Returns configured DATABASE dictionary from DATABASE_URL."""""" |
config = {} |
s = env(name, default) |
if s: |
config = parse_database_url(s) |
return config" |
4079,"def json_unicode_to_utf8(data): |
""""""Change all strings in a JSON structure to UTF-8."""""" |
if isinstance(data, unicode): |
return data.encode('utf-8') |
elif isinstance(data, dict): |
newdict = {} |
for key in data: |
newdict[json_unicode_to_utf8( |
key)] = json_unicode_to_utf8(data[key]) |
return newdict |
elif isinstance(data, list): |
return [json_unicode_to_utf8(elem) for elem in data] |
else: |
return data" |
4080,"def json_decode_file(filename): |
"""""" |
Parses a textfile using json to build a python object representation |
"""""" |
seq = open(filename).read() |
# The JSON standard has no comments syntax. We have to remove them |
# before feeding python's JSON parser |
seq = json_remove_comments(seq) |
# Parse all the unicode stuff to utf-8 |
return json_unicode_to_utf8(json.loads(seq))" |
4081,"def wash_for_js(text): |
"""""" |
DEPRECATED: use htmlutils.escape_javascript_string() instead, |
and take note that returned value is no longer enclosed into |
quotes. |
"""""" |
from invenio_utils.html import escape_javascript_string |
if isinstance(text, six.string_types): |
return '""%s""' % escape_javascript_string( |
text, |
escape_for_html=False, |
escape_CDATA=False, |
escape_script_tag_with_quote=None) |
else: |
return text" |
4082,"def _post_init(self): |
""""""A post init trigger"""""" |
try: |
return self.postinit() |
except Exception as exc: |
return self._onerror(Result.from_exception(exc, uuid=self.uuid))" |
4083,"def check_required_params(self): |
"""""" Check if all required parameters are set"""""" |
for param in self.REQUIRED_FIELDS: |
if param not in self.params: |
raise ValidationError(""Missing parameter: {}"".format(param))" |
4084,"def _onsuccess(self, result): |
"""""" To execute on execution success |
:param kser.result.Result result: Execution result |
:return: Execution result |
:rtype: kser.result.Result |
"""""" |
if KSER_METRICS_ENABLED == ""yes"": |
KSER_TASKS_STATUS.labels( |
__hostname__, self.__class__.path, 'SUCCESS' |
).inc() |
if result: |
result = self.result + result |
else: |
result = self.result |
logger.info( |
""{}.Success: {}[{}]: {}"".format( |
self.__class__.__name__, self.__class__.path, self.uuid, result |
), |
extra=dict( |
kmsg=Message( |
self.uuid, entrypoint=self.__class__.path, |
params=self.params, metadata=self.metadata |
).dump(), |
kresult=ResultSchema().dump(result) if result else dict() |
) |
) |
return self.onsuccess(result)" |
4085,"def _onerror(self, result): |
"""""" To execute on execution failure |
:param kser.result.Result result: Execution result |
:return: Execution result |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.