function stringlengths 11 56k | repo_name stringlengths 5 60 | features list |
|---|---|---|
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self,
**kwargs | Azure/azure-sdk-for-python | [
3526,
2256,
3526,
986,
1335285972
] |
def __init__(
self, plotly_name="color", parent_name="scatter.unselected.textfont", **kwargs | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def add_dflt(func, dflt_if_none):
@wraps(func)
def wrapped_func(*args, **kwargs):
result = func(*args, **kwargs)
if result is not None:
return result
else:
if callable(dflt_if_none):
return dflt_if_none()
else:
return dflt_if_none
return wrapped_func | thorwhalen/ut | [
4,
3,
4,
24,
1426246351
] |
def pipe10(xs):
for i in pipelined(range(len(xs) - 1), ii=-1):
v = xs[i] + xs[i + 1]
v >>= 1
xs[i] = v | ktok07b6/polyphony | [
90,
7,
90,
1,
1448846734
] |
def test():
data = [0, 16, 32, -16, -64]
pipe10(data)
assert 8 == data[0]
assert 24 == data[1]
assert 8 == data[2]
assert -40 == data[3]
assert -64 == data[4] | ktok07b6/polyphony | [
90,
7,
90,
1,
1448846734
] |
def __init__(self, mode="fixed", targetRange=0.0, discrete=False, targetValue=0.0, monitoredPhase="s12N", RegulatingCondEq=None, Terminal=None, RegulationSchedule=None, *args, **kw_args):
"""Initialises a new 'RegulatingControl' instance.
@param mode: The regulating control mode presently available. This specifications allows for determining the kind of regualation without need for obtaining the units from a schedule. Values are: "fixed", "timeScheduled", "voltage", "admittance", "reactivePower", "powerFactor", "currentFlow", "activePower", "temperature"
@param targetRange: This is the case input target range. This performs the same function as the value2 attribute on the regulation schedule in the case that schedules are not used. The units of those appropriate for the mode.
@param discrete: The regulation is performed in a discrete mode.
@param targetValue: The target value specified for case input. This value can be used for the target value wihout the use of schedules. The value has the units appropriate to the mode attribute.
@param monitoredPhase: Phase voltage controlling this regulator, measured at regulator location. Values are: "s12N", "BN", "BC", "ABN", "s2N", "N", "ACN", "BCN", "ABCN", "AC", "s1N", "AN", "B", "AB", "C", "A", "CN", "ABC"
@param RegulatingCondEq: The equipment that participates in this regulating control scheme.
@param Terminal: The terminal associated with this regulating control.
@param RegulationSchedule: Schedule for this Regulating regulating control.
"""
#: The regulating control mode presently available. This specifications allows for determining the kind of regualation without need for obtaining the units from a schedule. Values are: "fixed", "timeScheduled", "voltage", "admittance", "reactivePower", "powerFactor", "currentFlow", "activePower", "temperature"
self.mode = mode
#: This is the case input target range. This performs the same function as the value2 attribute on the regulation schedule in the case that schedules are not used. The units of those appropriate for the mode.
self.targetRange = targetRange
#: The regulation is performed in a discrete mode.
self.discrete = discrete
#: The target value specified for case input. This value can be used for the target value wihout the use of schedules. The value has the units appropriate to the mode attribute.
self.targetValue = targetValue
#: Phase voltage controlling this regulator, measured at regulator location. Values are: "s12N", "BN", "BC", "ABN", "s2N", "N", "ACN", "BCN", "ABCN", "AC", "s1N", "AN", "B", "AB", "C", "A", "CN", "ABC"
self.monitoredPhase = monitoredPhase
self._RegulatingCondEq = []
self.RegulatingCondEq = [] if RegulatingCondEq is None else RegulatingCondEq
self._Terminal = None
self.Terminal = Terminal
self._RegulationSchedule = []
self.RegulationSchedule = [] if RegulationSchedule is None else RegulationSchedule
super(RegulatingControl, self).__init__(*args, **kw_args) | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def getRegulatingCondEq(self):
"""The equipment that participates in this regulating control scheme.
"""
return self._RegulatingCondEq | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def addRegulatingCondEq(self, *RegulatingCondEq):
for obj in RegulatingCondEq:
obj.RegulatingControl = self | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def getTerminal(self):
"""The terminal associated with this regulating control.
"""
return self._Terminal | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def getRegulationSchedule(self):
"""Schedule for this Regulating regulating control.
"""
return self._RegulationSchedule | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def addRegulationSchedule(self, *RegulationSchedule):
for obj in RegulationSchedule:
obj.RegulatingControl = self | rwl/PyCIM | [
68,
33,
68,
7,
1238978196
] |
def __init__(self, message, code=None):
self.message = message
self.code = code | indico/indico | [
1446,
358,
1446,
649,
1311774990
] |
def __init__(self, results, path='', query='', ts=None, extra=None):
if ts is None:
ts = int(time.time())
self.results = results
self.path = path
self.query = query
self.ts = ts
self.extra = extra or {} | indico/indico | [
1446,
358,
1446,
649,
1311774990
] |
def url(self):
prefix = config.BASE_URL
if self.query:
return f'{prefix}{self.path}?{self.query}'
return prefix + self.path | indico/indico | [
1446,
358,
1446,
649,
1311774990
] |
def count(self):
return len(self.results) | indico/indico | [
1446,
358,
1446,
649,
1311774990
] |
def __init__(
self, plotly_name="align", parent_name="scatterternary.hoverlabel", **kwargs | plotly/python-api | [
13052,
2308,
13052,
1319,
1385013188
] |
def __init__(self, *args, **kwargs):
wrap = kwargs.pop('wrap_longitude', True)
super().__init__(*args, **kwargs)
if wrap and isinstance(self._data, (coord.UnitSphericalRepresentation,
coord.SphericalRepresentation)):
self._data.lon.wrap_angle = self._default_wrap_angle | adrn/gala | [
104,
51,
104,
37,
1394412978
] |
def represent_as(self, base, s='base', in_frame_units=False):
r = super().represent_as(base, s=s, in_frame_units=in_frame_units)
if hasattr(r, "lon"):
r.lon.wrap_angle = self._default_wrap_angle
return r | adrn/gala | [
104,
51,
104,
37,
1394412978
] |
def icrs_to_jhelum():
""" Compute the transformation from Galactic spherical to
heliocentric Jhelum coordinates.
"""
return R | adrn/gala | [
104,
51,
104,
37,
1394412978
] |
def test_add_comment_marker_props(self):
f = aaf.open()
# add RGBColor TypeDef
rgb_id = AUID("urn:uuid:e96e6d43-c383-11d3-a069-006094eb75cb")
rgb_typedef_pairs = [('red', 'UInt16'),
('green', 'UInt16'),
("blue", 'UInt16'),
]
rgb_typdef = aaf.define.TypeDefRecord(f, rgb_typedef_pairs, rgb_id, 'RGBColor')
f.dictionary.register_def(rgb_typdef)
cm_classdef = f.dictionary.lookup_classdef("CommentMarker")
string_typedef = f.dictionary.lookup_typedef("string")
# add CommentMarkerTime property
cm_time_id = AUID("urn:uuid:c4c45d9c-0967-11d4-a08a-006094eb75cb")
cm_prop_name = "CommentMarkerTime"
cm_classdef.register_optional_propertydef(string_typedef, cm_time_id, cm_prop_name)
# add CommentMarkerDate property
cm_date_id = AUID("urn:uuid:c4c45d9b-0967-11d4-a08a-006094eb75cb")
cm_prop_name = "CommentMarkerDate"
cm_classdef.register_optional_propertydef(string_typedef, cm_date_id, cm_prop_name)
# add CommentMarkerUSer property
cm_user_id = AUID("urn:uuid:c4c45d9a-0967-11d4-a08a-006094eb75cb")
cm_prop_name = "CommentMarkerUSer"
cm_classdef.register_optional_propertydef(string_typedef, cm_user_id, cm_prop_name)
# add CommentMarkerColor property
cm_color_id = AUID("urn:uuid:e96e6d44-c383-11d3-a069-006094eb75cb")
cm_prop_name = "CommentMarkerColor"
cm_classdef.register_optional_propertydef(rgb_typdef, cm_color_id, cm_prop_name)
# add CommentMarkerAttributeList property
cm_attr_list_id = AUID("urn:uuid:c72cc817-aac5-499b-af34-bc47fec1eaa8")
strongref = f.dictionary.lookup_typedef("TaggedValueStrongReferenceVector")
cm_prop_name = "CommentMarkerAttributeList"
cm_classdef.register_optional_propertydef(strongref, cm_attr_list_id, cm_prop_name)
marker = f.create.DescriptiveMarker()
marker['CommentMarkerTime'].value = "22:40"
marker['CommentMarkerDate'].value = "06/18/2016"
marker['CommentMarkerUSer'].value = "USERNAME"
marker_colors = {"red":41471, "green":12134, "blue":6564}
marker["CommentMarkerColor"].value = marker_colors
int32_typedef = f.dictionary.lookup_typedef("Int32")
crm_id = "060a2b340101010101010f0013-000000-5766066e2cd404e5-060e2b347f7f-2a80"
crm_com = "This is the first marker text"
attr_data = [('_ATN_CRM_LONG_CREATE_DATE', 1466304031, int32_typedef ),
('_ATN_CRM_USER', "USERNAME", string_typedef),
('_ATN_CRM_DATE', "06/18/2016", string_typedef),
('_ATN_CRM_TIME', "22:40", string_typedef),
('_ATN_CRM_COLOR', "Red", string_typedef),
('_ATN_CRM_COM', crm_com, string_typedef),
('_ATN_CRM_LONG_MOD_DATE', 1466304042, int32_typedef ),
('_ATN_CRM_ID', crm_id, string_typedef),
]
tagged_values = [f.create.TaggedValue(name, value, typedef) for name, value,typedef in attr_data]
marker["CommentMarkerAttributeList"].value = tagged_values
for i,tag in enumerate(marker["CommentMarkerAttributeList"].value):
self.assertEqual(tag.name, attr_data[i][0])
self.assertEqual(tag.value, attr_data[i][1])
self.assertEqual(tag.typedef(), attr_data[i][2])
self.assertEqual(marker["CommentMarkerColor"].value, marker_colors)
self.assertEqual(marker['CommentMarkerUSer'].value, "USERNAME") | markreidvfx/pyaaf | [
46,
8,
46,
14,
1377887118
] |
def page_dumb(strng, start=0, screen_lines=25):
"""Very dumb 'pager' in Python, for when nothing else works.
Only moves forward, same interface as page(), except for pager_cmd and
mode."""
out_ln = strng.splitlines()[start:]
screens = chop(out_ln, screen_lines - 1)
if len(screens) == 1:
print(os.linesep.join(screens[0]), file=io.stdout)
else:
last_escape = ""
for scr in screens[0:-1]:
hunk = os.linesep.join(scr)
print(last_escape + hunk, file=io.stdout)
if not page_more():
return
esc_list = esc_re.findall(hunk)
if len(esc_list) > 0:
last_escape = esc_list[-1]
print(last_escape + os.linesep.join(screens[-1]), file=io.stdout) | mattvonrocketstein/smash | [
12,
1,
12,
10,
1321798817
] |
def page(strng, start=0, screen_lines=0, pager_cmd=None):
"""Display a string, piping through a pager after a certain length.
strng can be a mime-bundle dict, supplying multiple representations,
keyed by mime-type.
The screen_lines parameter specifies the number of *usable* lines of your
terminal screen (total lines minus lines you need to reserve to show other
information).
If you set screen_lines to a number <=0, page() will try to auto-determine
your screen size and will only use up to (screen_size+screen_lines) for
printing, paging after that. That is, if you want auto-detection but need
to reserve the bottom 3 lines of the screen, use screen_lines = -3, and for
auto-detection without any lines reserved simply use screen_lines = 0.
If a string won't fit in the allowed lines, it is sent through the
specified pager command. If none given, look for PAGER in the environment,
and ultimately default to less.
If no system pager works, the string is sent through a 'dumb pager'
written in python, very simplistic.
"""
# for compatibility with mime-bundle form:
if isinstance(strng, dict):
strng = strng['text/plain']
# Some routines may auto-compute start offsets incorrectly and pass a
# negative value. Offset to 0 for robustness.
start = max(0, start)
# first, try the hook
ip = get_ipython()
if ip:
try:
ip.hooks.show_in_pager(strng)
return
except TryNext:
pass
# Ugly kludge, but calling curses.initscr() flat out crashes in emacs
TERM = os.environ.get('TERM', 'dumb')
if TERM in ['dumb', 'emacs'] and os.name != 'nt':
print(strng)
return
# chop off the topmost part of the string we don't want to see
str_lines = strng.splitlines()[start:]
str_toprint = os.linesep.join(str_lines)
num_newlines = len(str_lines)
len_str = len(str_toprint)
# Dumb heuristics to guesstimate number of on-screen lines the string
# takes. Very basic, but good enough for docstrings in reasonable
# terminals. If someone later feels like refining it, it's not hard.
numlines = max(num_newlines, int(len_str / 80) + 1)
screen_lines_def = get_terminal_size()[1]
# auto-determine screen size
if screen_lines <= 0:
try:
screen_lines += _detect_screen_size(screen_lines_def)
except (TypeError, UnsupportedOperation):
print(str_toprint, file=io.stdout)
return
# print 'numlines',numlines,'screenlines',screen_lines # dbg
if numlines <= screen_lines:
# print '*** normal print' # dbg
print(str_toprint, file=io.stdout)
else:
# Try to open pager and default to internal one if that fails.
# All failure modes are tagged as 'retval=1', to match the return
# value of a failed system command. If any intermediate attempt
# sets retval to 1, at the end we resort to our own page_dumb() pager.
pager_cmd = get_pager_cmd(pager_cmd)
pager_cmd += ' ' + get_pager_start(pager_cmd, start)
if os.name == 'nt':
if pager_cmd.startswith('type'):
# The default WinXP 'type' command is failing on complex
# strings.
retval = 1
else:
fd, tmpname = tempfile.mkstemp('.txt')
try:
os.close(fd)
with open(tmpname, 'wt') as tmpfile:
tmpfile.write(strng)
cmd = "%s < %s" % (pager_cmd, tmpname)
# tmpfile needs to be closed for windows
if os.system(cmd):
retval = 1
else:
retval = None
finally:
os.remove(tmpname)
else:
try:
retval = None
# if I use popen4, things hang. No idea why.
#pager,shell_out = os.popen4(pager_cmd)
pager = os.popen(pager_cmd, 'w')
try:
pager_encoding = pager.encoding or sys.stdout.encoding
pager.write(py3compat.cast_bytes_py2(
strng, encoding=pager_encoding))
finally:
retval = pager.close()
except IOError as msg: # broken pipe when user quits
if msg.args == (32, 'Broken pipe'):
retval = None
else:
retval = 1
except OSError:
# Other strange problems, sometimes seen in Win2k/cygwin
retval = 1
if retval is not None:
page_dumb(strng, screen_lines=screen_lines) | mattvonrocketstein/smash | [
12,
1,
12,
10,
1321798817
] |
def get_pager_cmd(pager_cmd=None):
"""Return a pager command.
Makes some attempts at finding an OS-correct one.
"""
if os.name == 'posix':
default_pager_cmd = 'less -r' # -r for color control sequences
elif os.name in ['nt', 'dos']:
default_pager_cmd = 'type'
if pager_cmd is None:
try:
pager_cmd = os.environ['PAGER']
except:
pager_cmd = default_pager_cmd
return pager_cmd | mattvonrocketstein/smash | [
12,
1,
12,
10,
1321798817
] |
def page_more():
""" Smart pausing between pages
@return: True if need print more lines, False if quit
"""
io.stdout.write('---Return to continue, q to quit--- ')
ans = msvcrt.getwch()
if ans in ("q", "Q"):
result = False
else:
result = True
io.stdout.write("\b" * 37 + " " * 37 + "\b" * 37)
return result | mattvonrocketstein/smash | [
12,
1,
12,
10,
1321798817
] |
def page_more():
ans = py3compat.input('---Return to continue, q to quit--- ')
if ans.lower().startswith('q'):
return False
else:
return True | mattvonrocketstein/smash | [
12,
1,
12,
10,
1321798817
] |
def get(self):
user = g.user
query = apply_rules_blueprint_templates(user)
query = query.order_by(BlueprintTemplate.name)
results = []
for blueprint_template in query.all():
plugin = Plugin.query.filter_by(id=blueprint_template.plugin).first()
blueprint_template.schema = plugin.schema
blueprint_template.form = plugin.form
# Due to immutable nature of config field, whole dict needs to be reassigned.
# Issue #444 in github
blueprint_template_config = blueprint_template.config
blueprint_template_config['name'] = blueprint_template.name
blueprint_template.config = blueprint_template_config
results.append(blueprint_template)
return results | CSC-IT-Center-for-Science/pouta-blueprints | [
7,
6,
7,
71,
1418128274
] |
def post(self):
form = BlueprintTemplateForm()
if not form.validate_on_submit():
logging.warn("validation error on create blueprint_template")
return form.errors, 422
blueprint_template = BlueprintTemplate()
blueprint_template.name = form.name.data
blueprint_template.plugin = form.plugin.data
config = form.config.data
config.pop('name', None)
blueprint_template.config = config
try:
validate_max_lifetime_template(config) # Validate the maximum lifetime from config
except ValueError:
timeformat_error = {"timeformat error": "pattern should be [days]d [hours]h [minutes]m"}
return timeformat_error, 422
if isinstance(form.allowed_attrs.data, dict): # WTForms can only fetch a dict
blueprint_template.allowed_attrs = form.allowed_attrs.data['allowed_attrs']
blueprint_template = blueprint_schemaform_config(blueprint_template)
db.session.add(blueprint_template)
db.session.commit() | CSC-IT-Center-for-Science/pouta-blueprints | [
7,
6,
7,
71,
1418128274
] |
def get(self, template_id):
args = {'template_id': template_id}
query = apply_rules_blueprint_templates(g.user, args)
blueprint_template = query.first()
if not blueprint_template:
abort(404)
return blueprint_template | CSC-IT-Center-for-Science/pouta-blueprints | [
7,
6,
7,
71,
1418128274
] |
def put(self, template_id):
form = BlueprintTemplateForm()
if not form.validate_on_submit():
logging.warn("validation error on update blueprint_template config")
return form.errors, 422
blueprint_template = BlueprintTemplate.query.filter_by(id=template_id).first()
if not blueprint_template:
abort(404)
blueprint_template.name = form.config.data.get('name') or form.name.data
blueprint_template.plugin = form.plugin.data
config = form.config.data
config.pop('name', None)
blueprint_template.config = config
try:
validate_max_lifetime_template(config) # Validate the maximum lifetime from config
except ValueError:
timeformat_error = {"timeformat error": "pattern should be [days]d [hours]h [minutes]m"}
return timeformat_error, 422
if isinstance(form.allowed_attrs.data, dict): # WTForms can only fetch a dict
blueprint_template.allowed_attrs = form.allowed_attrs.data['allowed_attrs']
blueprint_template = blueprint_schemaform_config(blueprint_template)
args = self.parser.parse_args()
blueprint_template = toggle_enable_template(form, args, blueprint_template)
db.session.add(blueprint_template)
db.session.commit() | CSC-IT-Center-for-Science/pouta-blueprints | [
7,
6,
7,
71,
1418128274
] |
def put(self, template_id):
template = BlueprintTemplate.query.get_or_404(template_id)
db.session.expunge(template)
make_transient(template)
template.id = uuid.uuid4().hex
template.name = format("%s - %s" % (template.name, 'Copy'))
db.session.add(template)
db.session.commit() | CSC-IT-Center-for-Science/pouta-blueprints | [
7,
6,
7,
71,
1418128274
] |
def blueprint_schemaform_config(blueprint_template):
"""Generates config,schema and model objects used in schemaform ui component for blueprints"""
plugin = Plugin.query.filter_by(id=blueprint_template.plugin).first()
schema = plugin.schema
blueprint_schema = {'type': 'object', 'title': 'Comment', 'description': 'Description', 'required': ['name', 'description'], 'properties': {}}
config = blueprint_template.config
blueprint_model = {}
allowed_attrs = blueprint_template.allowed_attrs
blueprint_form = allowed_attrs
allowed_attrs = ['name', 'description'] + allowed_attrs
for attr in allowed_attrs:
blueprint_schema['properties'][attr] = schema['properties'][attr]
if attr in ('name', 'description'):
blueprint_model[attr] = ''
else:
blueprint_model[attr] = config[attr]
blueprint_form = [
{
"key": "name",
"type": "textfield",
"placeholder": "Blueprint name"
},
{
"key": "description",
"type": "textarea",
"placeholder": "Blueprint details"
}
] + blueprint_form
blueprint_template.blueprint_schema = blueprint_schema
blueprint_template.blueprint_form = blueprint_form
blueprint_template.blueprint_model = blueprint_model
return blueprint_template | CSC-IT-Center-for-Science/pouta-blueprints | [
7,
6,
7,
71,
1418128274
] |
def __init__(self, event_queue, watch, timeout=DEFAULT_EMITTER_TIMEOUT):
EventEmitter.__init__(self, event_queue, watch, timeout)
self._lock = threading.Lock()
self._inotify = None | wandb/client | [
5607,
445,
5607,
725,
1490334383
] |
def on_thread_stop(self):
if self._inotify:
self._inotify.close() | wandb/client | [
5607,
445,
5607,
725,
1490334383
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.