repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
deepmind/pysc2 | pysc2/lib/renderer_human.py | RendererHuman.render | def render(self, obs):
"""Push an observation onto the queue to be rendered."""
if not self._initialized:
return
now = time.time()
self._game_times.append(
(now - self._last_time,
max(1, obs.observation.game_loop - self._obs.observation.game_loop)))
self._last_time = now
s... | python | def render(self, obs):
"""Push an observation onto the queue to be rendered."""
if not self._initialized:
return
now = time.time()
self._game_times.append(
(now - self._last_time,
max(1, obs.observation.game_loop - self._obs.observation.game_loop)))
self._last_time = now
s... | [
"def",
"render",
"(",
"self",
",",
"obs",
")",
":",
"if",
"not",
"self",
".",
"_initialized",
":",
"return",
"now",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_game_times",
".",
"append",
"(",
"(",
"now",
"-",
"self",
".",
"_last_time",
",",... | Push an observation onto the queue to be rendered. | [
"Push",
"an",
"observation",
"onto",
"the",
"queue",
"to",
"be",
"rendered",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1381-L1393 | train | Push an observation onto the queue to be rendered. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/renderer_human.py | RendererHuman.render_thread | def render_thread(self):
"""A render loop that pulls observations off the queue to render."""
obs = True
while obs: # Send something falsy through the queue to shut down.
obs = self._obs_queue.get()
if obs:
for alert in obs.observation.alerts:
self._alerts[sc_pb.Alert.Name(ale... | python | def render_thread(self):
"""A render loop that pulls observations off the queue to render."""
obs = True
while obs: # Send something falsy through the queue to shut down.
obs = self._obs_queue.get()
if obs:
for alert in obs.observation.alerts:
self._alerts[sc_pb.Alert.Name(ale... | [
"def",
"render_thread",
"(",
"self",
")",
":",
"obs",
"=",
"True",
"while",
"obs",
":",
"# Send something falsy through the queue to shut down.",
"obs",
"=",
"self",
".",
"_obs_queue",
".",
"get",
"(",
")",
"if",
"obs",
":",
"for",
"alert",
"in",
"obs",
".",... | A render loop that pulls observations off the queue to render. | [
"A",
"render",
"loop",
"that",
"pulls",
"observations",
"off",
"the",
"queue",
"to",
"render",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1395-L1413 | train | A render loop that pulls observations off the queue and renders them. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/renderer_human.py | RendererHuman.render_obs | def render_obs(self, obs):
"""Render a frame given an observation."""
start_time = time.time()
self._obs = obs
self.check_valid_queued_action()
self._update_camera(point.Point.build(
self._obs.observation.raw_data.player.camera))
for surf in self._surfaces:
# Render that surface.
... | python | def render_obs(self, obs):
"""Render a frame given an observation."""
start_time = time.time()
self._obs = obs
self.check_valid_queued_action()
self._update_camera(point.Point.build(
self._obs.observation.raw_data.player.camera))
for surf in self._surfaces:
# Render that surface.
... | [
"def",
"render_obs",
"(",
"self",
",",
"obs",
")",
":",
"start_time",
"=",
"time",
".",
"time",
"(",
")",
"self",
".",
"_obs",
"=",
"obs",
"self",
".",
"check_valid_queued_action",
"(",
")",
"self",
".",
"_update_camera",
"(",
"point",
".",
"Point",
".... | Render a frame given an observation. | [
"Render",
"a",
"frame",
"given",
"an",
"observation",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1417-L1440 | train | Render a frame given an observation. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/renderer_human.py | RendererHuman.run | def run(self, run_config, controller, max_game_steps=0, max_episodes=0,
game_steps_per_episode=0, save_replay=False):
"""Run loop that gets observations, renders them, and sends back actions."""
is_replay = (controller.status == remote_controller.Status.in_replay)
total_game_steps = 0
start_ti... | python | def run(self, run_config, controller, max_game_steps=0, max_episodes=0,
game_steps_per_episode=0, save_replay=False):
"""Run loop that gets observations, renders them, and sends back actions."""
is_replay = (controller.status == remote_controller.Status.in_replay)
total_game_steps = 0
start_ti... | [
"def",
"run",
"(",
"self",
",",
"run_config",
",",
"controller",
",",
"max_game_steps",
"=",
"0",
",",
"max_episodes",
"=",
"0",
",",
"game_steps_per_episode",
"=",
"0",
",",
"save_replay",
"=",
"False",
")",
":",
"is_replay",
"=",
"(",
"controller",
".",
... | Run loop that gets observations, renders them, and sends back actions. | [
"Run",
"loop",
"that",
"gets",
"observations",
"renders",
"them",
"and",
"sends",
"back",
"actions",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/renderer_human.py#L1442-L1510 | train | Runs the game loop. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/protocol.py | catch_websocket_connection_errors | def catch_websocket_connection_errors():
"""A context manager that translates websocket errors into ConnectionError."""
try:
yield
except websocket.WebSocketConnectionClosedException:
raise ConnectionError("Connection already closed. SC2 probably crashed. "
"Check the error log."... | python | def catch_websocket_connection_errors():
"""A context manager that translates websocket errors into ConnectionError."""
try:
yield
except websocket.WebSocketConnectionClosedException:
raise ConnectionError("Connection already closed. SC2 probably crashed. "
"Check the error log."... | [
"def",
"catch_websocket_connection_errors",
"(",
")",
":",
"try",
":",
"yield",
"except",
"websocket",
".",
"WebSocketConnectionClosedException",
":",
"raise",
"ConnectionError",
"(",
"\"Connection already closed. SC2 probably crashed. \"",
"\"Check the error log.\"",
")",
"exc... | A context manager that translates websocket errors into ConnectionError. | [
"A",
"context",
"manager",
"that",
"translates",
"websocket",
"errors",
"into",
"ConnectionError",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/protocol.py#L59-L69 | train | A context manager that translates websocket errors into ConnectionError. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/protocol.py | StarcraftProtocol.read | def read(self):
"""Read a Response, do some validation, and return it."""
if FLAGS.sc2_verbose_protocol:
self._log(" Reading response ".center(60, "-"))
start = time.time()
response = self._read()
if FLAGS.sc2_verbose_protocol:
self._log(" %0.1f msec\n" % (1000 * (time.time() - start))... | python | def read(self):
"""Read a Response, do some validation, and return it."""
if FLAGS.sc2_verbose_protocol:
self._log(" Reading response ".center(60, "-"))
start = time.time()
response = self._read()
if FLAGS.sc2_verbose_protocol:
self._log(" %0.1f msec\n" % (1000 * (time.time() - start))... | [
"def",
"read",
"(",
"self",
")",
":",
"if",
"FLAGS",
".",
"sc2_verbose_protocol",
":",
"self",
".",
"_log",
"(",
"\" Reading response \"",
".",
"center",
"(",
"60",
",",
"\"-\"",
")",
")",
"start",
"=",
"time",
".",
"time",
"(",
")",
"response",
"=",
... | Read a Response, do some validation, and return it. | [
"Read",
"a",
"Response",
"do",
"some",
"validation",
"and",
"return",
"it",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/protocol.py#L90-L109 | train | Read a Response from the server and validate it. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/protocol.py | StarcraftProtocol.write | def write(self, request):
"""Write a Request."""
if FLAGS.sc2_verbose_protocol:
self._log(" Writing request ".center(60, "-") + "\n")
self._log_packet(request)
self._write(request) | python | def write(self, request):
"""Write a Request."""
if FLAGS.sc2_verbose_protocol:
self._log(" Writing request ".center(60, "-") + "\n")
self._log_packet(request)
self._write(request) | [
"def",
"write",
"(",
"self",
",",
"request",
")",
":",
"if",
"FLAGS",
".",
"sc2_verbose_protocol",
":",
"self",
".",
"_log",
"(",
"\" Writing request \"",
".",
"center",
"(",
"60",
",",
"\"-\"",
")",
"+",
"\"\\n\"",
")",
"self",
".",
"_log_packet",
"(",
... | Write a Request. | [
"Write",
"a",
"Request",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/protocol.py#L112-L117 | train | Write a request. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/protocol.py | StarcraftProtocol.send | def send(self, **kwargs):
"""Create and send a specific request, and return the response.
For example: send(ping=sc_pb.RequestPing()) => sc_pb.ResponsePing
Args:
**kwargs: A single kwarg with the name and value to fill in to Request.
Returns:
The Response corresponding to your request.
... | python | def send(self, **kwargs):
"""Create and send a specific request, and return the response.
For example: send(ping=sc_pb.RequestPing()) => sc_pb.ResponsePing
Args:
**kwargs: A single kwarg with the name and value to fill in to Request.
Returns:
The Response corresponding to your request.
... | [
"def",
"send",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"len",
"(",
"kwargs",
")",
"==",
"1",
",",
"\"Must make a single request.\"",
"res",
"=",
"self",
".",
"send_req",
"(",
"sc_pb",
".",
"Request",
"(",
"*",
"*",
"kwargs",
")",
")... | Create and send a specific request, and return the response.
For example: send(ping=sc_pb.RequestPing()) => sc_pb.ResponsePing
Args:
**kwargs: A single kwarg with the name and value to fill in to Request.
Returns:
The Response corresponding to your request. | [
"Create",
"and",
"send",
"a",
"specific",
"request",
"and",
"return",
"the",
"response",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/protocol.py#L124-L137 | train | Create and send a specific request and return the response. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/protocol.py | StarcraftProtocol._log | def _log(self, s):
r"""Log a string. It flushes but doesn't append \n, so do that yourself."""
# TODO(tewalds): Should this be using logging.info instead? How to see them
# outside of google infrastructure?
sys.stderr.write(s)
sys.stderr.flush() | python | def _log(self, s):
r"""Log a string. It flushes but doesn't append \n, so do that yourself."""
# TODO(tewalds): Should this be using logging.info instead? How to see them
# outside of google infrastructure?
sys.stderr.write(s)
sys.stderr.flush() | [
"def",
"_log",
"(",
"self",
",",
"s",
")",
":",
"# TODO(tewalds): Should this be using logging.info instead? How to see them",
"# outside of google infrastructure?",
"sys",
".",
"stderr",
".",
"write",
"(",
"s",
")",
"sys",
".",
"stderr",
".",
"flush",
"(",
")"
] | r"""Log a string. It flushes but doesn't append \n, so do that yourself. | [
"r",
"Log",
"a",
"string",
".",
"It",
"flushes",
"but",
"doesn",
"t",
"append",
"\\",
"n",
"so",
"do",
"that",
"yourself",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/protocol.py#L150-L155 | train | r Log a string. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/protocol.py | StarcraftProtocol._read | def _read(self):
"""Actually read the response and parse it, returning a Response."""
with sw("read_response"):
with catch_websocket_connection_errors():
response_str = self._sock.recv()
if not response_str:
raise ProtocolError("Got an empty response from SC2.")
response = sc_pb.Resp... | python | def _read(self):
"""Actually read the response and parse it, returning a Response."""
with sw("read_response"):
with catch_websocket_connection_errors():
response_str = self._sock.recv()
if not response_str:
raise ProtocolError("Got an empty response from SC2.")
response = sc_pb.Resp... | [
"def",
"_read",
"(",
"self",
")",
":",
"with",
"sw",
"(",
"\"read_response\"",
")",
":",
"with",
"catch_websocket_connection_errors",
"(",
")",
":",
"response_str",
"=",
"self",
".",
"_sock",
".",
"recv",
"(",
")",
"if",
"not",
"response_str",
":",
"raise"... | Actually read the response and parse it, returning a Response. | [
"Actually",
"read",
"the",
"response",
"and",
"parse",
"it",
"returning",
"a",
"Response",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/protocol.py#L157-L167 | train | Actually read the response and parse it returning a Response. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/protocol.py | StarcraftProtocol._write | def _write(self, request):
"""Actually serialize and write the request."""
with sw("serialize_request"):
request_str = request.SerializeToString()
with sw("write_request"):
with catch_websocket_connection_errors():
self._sock.send(request_str) | python | def _write(self, request):
"""Actually serialize and write the request."""
with sw("serialize_request"):
request_str = request.SerializeToString()
with sw("write_request"):
with catch_websocket_connection_errors():
self._sock.send(request_str) | [
"def",
"_write",
"(",
"self",
",",
"request",
")",
":",
"with",
"sw",
"(",
"\"serialize_request\"",
")",
":",
"request_str",
"=",
"request",
".",
"SerializeToString",
"(",
")",
"with",
"sw",
"(",
"\"write_request\"",
")",
":",
"with",
"catch_websocket_connecti... | Actually serialize and write the request. | [
"Actually",
"serialize",
"and",
"write",
"the",
"request",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/protocol.py#L169-L175 | train | Actually serialize and write the request. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/maps/lib.py | get_maps | def get_maps():
"""Get the full dict of maps {map_name: map_class}."""
maps = {}
for mp in Map.all_subclasses():
if mp.filename:
map_name = mp.__name__
if map_name in maps:
raise DuplicateMapException("Duplicate map found: " + map_name)
maps[map_name] = mp
return maps | python | def get_maps():
"""Get the full dict of maps {map_name: map_class}."""
maps = {}
for mp in Map.all_subclasses():
if mp.filename:
map_name = mp.__name__
if map_name in maps:
raise DuplicateMapException("Duplicate map found: " + map_name)
maps[map_name] = mp
return maps | [
"def",
"get_maps",
"(",
")",
":",
"maps",
"=",
"{",
"}",
"for",
"mp",
"in",
"Map",
".",
"all_subclasses",
"(",
")",
":",
"if",
"mp",
".",
"filename",
":",
"map_name",
"=",
"mp",
".",
"__name__",
"if",
"map_name",
"in",
"maps",
":",
"raise",
"Duplic... | Get the full dict of maps {map_name: map_class}. | [
"Get",
"the",
"full",
"dict",
"of",
"maps",
"{",
"map_name",
":",
"map_class",
"}",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/maps/lib.py#L113-L122 | train | Get the full dict of maps. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/maps/lib.py | get | def get(map_name):
"""Get an instance of a map by name. Errors if the map doesn't exist."""
if isinstance(map_name, Map):
return map_name
# Get the list of maps. This isn't at module scope to avoid problems of maps
# being defined after this module is imported.
maps = get_maps()
map_class = maps.get(ma... | python | def get(map_name):
"""Get an instance of a map by name. Errors if the map doesn't exist."""
if isinstance(map_name, Map):
return map_name
# Get the list of maps. This isn't at module scope to avoid problems of maps
# being defined after this module is imported.
maps = get_maps()
map_class = maps.get(ma... | [
"def",
"get",
"(",
"map_name",
")",
":",
"if",
"isinstance",
"(",
"map_name",
",",
"Map",
")",
":",
"return",
"map_name",
"# Get the list of maps. This isn't at module scope to avoid problems of maps",
"# being defined after this module is imported.",
"maps",
"=",
"get_maps",... | Get an instance of a map by name. Errors if the map doesn't exist. | [
"Get",
"an",
"instance",
"of",
"a",
"map",
"by",
"name",
".",
"Errors",
"if",
"the",
"map",
"doesn",
"t",
"exist",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/maps/lib.py#L125-L136 | train | Get an instance of a map by name. Errors if the map doesn t exist. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/maps/lib.py | Map.path | def path(self):
"""The full path to the map file: directory, filename and file ending."""
if self.filename:
map_path = os.path.join(self.directory, self.filename)
if not map_path.endswith(".SC2Map"):
map_path += ".SC2Map"
return map_path | python | def path(self):
"""The full path to the map file: directory, filename and file ending."""
if self.filename:
map_path = os.path.join(self.directory, self.filename)
if not map_path.endswith(".SC2Map"):
map_path += ".SC2Map"
return map_path | [
"def",
"path",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
":",
"map_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"directory",
",",
"self",
".",
"filename",
")",
"if",
"not",
"map_path",
".",
"endswith",
"(",
"\".SC2Map\"",... | The full path to the map file: directory, filename and file ending. | [
"The",
"full",
"path",
"to",
"the",
"map",
"file",
":",
"directory",
"filename",
"and",
"file",
"ending",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/maps/lib.py#L72-L78 | train | The full path to the map file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/maps/lib.py | Map.data | def data(self, run_config):
"""Return the map data."""
try:
return run_config.map_data(self.path)
except (IOError, OSError) as e: # Catch both for python 2/3 compatibility.
if self.download and hasattr(e, "filename"):
logging.error("Error reading map '%s' from: %s", self.name, e.filenam... | python | def data(self, run_config):
"""Return the map data."""
try:
return run_config.map_data(self.path)
except (IOError, OSError) as e: # Catch both for python 2/3 compatibility.
if self.download and hasattr(e, "filename"):
logging.error("Error reading map '%s' from: %s", self.name, e.filenam... | [
"def",
"data",
"(",
"self",
",",
"run_config",
")",
":",
"try",
":",
"return",
"run_config",
".",
"map_data",
"(",
"self",
".",
"path",
")",
"except",
"(",
"IOError",
",",
"OSError",
")",
"as",
"e",
":",
"# Catch both for python 2/3 compatibility.",
"if",
... | Return the map data. | [
"Return",
"the",
"map",
"data",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/maps/lib.py#L80-L88 | train | Return the map data. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | _to_point | def _to_point(dims):
"""Convert (width, height) or size -> point.Point."""
assert dims
if isinstance(dims, (tuple, list)):
if len(dims) != 2:
raise ValueError(
"A two element tuple or list is expected here, got {}.".format(dims))
else:
width = int(dims[0])
height = int(dims[1]... | python | def _to_point(dims):
"""Convert (width, height) or size -> point.Point."""
assert dims
if isinstance(dims, (tuple, list)):
if len(dims) != 2:
raise ValueError(
"A two element tuple or list is expected here, got {}.".format(dims))
else:
width = int(dims[0])
height = int(dims[1]... | [
"def",
"_to_point",
"(",
"dims",
")",
":",
"assert",
"dims",
"if",
"isinstance",
"(",
"dims",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"if",
"len",
"(",
"dims",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"A two element tuple or list is expe... | Convert (width, height) or size -> point.Point. | [
"Convert",
"(",
"width",
"height",
")",
"or",
"size",
"-",
">",
"point",
".",
"Point",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L342-L363 | train | Convert width height or size to point. Point. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | parse_agent_interface_format | def parse_agent_interface_format(
feature_screen=None,
feature_minimap=None,
rgb_screen=None,
rgb_minimap=None,
action_space=None,
camera_width_world_units=None,
use_feature_units=False,
use_raw_units=False,
use_unit_counts=False,
use_camera_position=False):
"""Creates an Agent... | python | def parse_agent_interface_format(
feature_screen=None,
feature_minimap=None,
rgb_screen=None,
rgb_minimap=None,
action_space=None,
camera_width_world_units=None,
use_feature_units=False,
use_raw_units=False,
use_unit_counts=False,
use_camera_position=False):
"""Creates an Agent... | [
"def",
"parse_agent_interface_format",
"(",
"feature_screen",
"=",
"None",
",",
"feature_minimap",
"=",
"None",
",",
"rgb_screen",
"=",
"None",
",",
"rgb_minimap",
"=",
"None",
",",
"action_space",
"=",
"None",
",",
"camera_width_world_units",
"=",
"None",
",",
... | Creates an AgentInterfaceFormat object from keyword args.
Convenient when using dictionaries or command-line arguments for config.
Note that the feature_* and rgb_* properties define the respective spatial
observation dimensions and accept:
* None or 0 to disable that spatial observation.
* A single... | [
"Creates",
"an",
"AgentInterfaceFormat",
"object",
"from",
"keyword",
"args",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L536-L598 | train | Parses the AgentInterfaceFormat object from keyword args. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | features_from_game_info | def features_from_game_info(
game_info,
use_feature_units=False,
use_raw_units=False,
action_space=None,
hide_specific_actions=True,
use_unit_counts=False,
use_camera_position=False):
"""Construct a Features object using data extracted from game info.
Args:
game_info: A `sc_pb.Respo... | python | def features_from_game_info(
game_info,
use_feature_units=False,
use_raw_units=False,
action_space=None,
hide_specific_actions=True,
use_unit_counts=False,
use_camera_position=False):
"""Construct a Features object using data extracted from game info.
Args:
game_info: A `sc_pb.Respo... | [
"def",
"features_from_game_info",
"(",
"game_info",
",",
"use_feature_units",
"=",
"False",
",",
"use_raw_units",
"=",
"False",
",",
"action_space",
"=",
"None",
",",
"hide_specific_actions",
"=",
"True",
",",
"use_unit_counts",
"=",
"False",
",",
"use_camera_positi... | Construct a Features object using data extracted from game info.
Args:
game_info: A `sc_pb.ResponseGameInfo` from the game.
use_feature_units: Whether to include the feature unit observation.
use_raw_units: Whether to include raw unit data in observations. This
differs from feature_units because ... | [
"Construct",
"a",
"Features",
"object",
"using",
"data",
"extracted",
"from",
"game",
"info",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L601-L670 | train | Construct a Features object from game info. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | _init_valid_functions | def _init_valid_functions(action_dimensions):
"""Initialize ValidFunctions and set up the callbacks."""
sizes = {
"screen": tuple(int(i) for i in action_dimensions.screen),
"screen2": tuple(int(i) for i in action_dimensions.screen),
"minimap": tuple(int(i) for i in action_dimensions.minimap),
}
... | python | def _init_valid_functions(action_dimensions):
"""Initialize ValidFunctions and set up the callbacks."""
sizes = {
"screen": tuple(int(i) for i in action_dimensions.screen),
"screen2": tuple(int(i) for i in action_dimensions.screen),
"minimap": tuple(int(i) for i in action_dimensions.minimap),
}
... | [
"def",
"_init_valid_functions",
"(",
"action_dimensions",
")",
":",
"sizes",
"=",
"{",
"\"screen\"",
":",
"tuple",
"(",
"int",
"(",
"i",
")",
"for",
"i",
"in",
"action_dimensions",
".",
"screen",
")",
",",
"\"screen2\"",
":",
"tuple",
"(",
"int",
"(",
"i... | Initialize ValidFunctions and set up the callbacks. | [
"Initialize",
"ValidFunctions",
"and",
"set",
"up",
"the",
"callbacks",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L673-L689 | train | Initialize ValidFunctions and set up the callbacks. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Feature.unpack | def unpack(self, obs):
"""Return a correctly shaped numpy array for this feature."""
planes = getattr(obs.feature_layer_data, self.layer_set)
plane = getattr(planes, self.name)
return self.unpack_layer(plane) | python | def unpack(self, obs):
"""Return a correctly shaped numpy array for this feature."""
planes = getattr(obs.feature_layer_data, self.layer_set)
plane = getattr(planes, self.name)
return self.unpack_layer(plane) | [
"def",
"unpack",
"(",
"self",
",",
"obs",
")",
":",
"planes",
"=",
"getattr",
"(",
"obs",
".",
"feature_layer_data",
",",
"self",
".",
"layer_set",
")",
"plane",
"=",
"getattr",
"(",
"planes",
",",
"self",
".",
"name",
")",
"return",
"self",
".",
"un... | Return a correctly shaped numpy array for this feature. | [
"Return",
"a",
"correctly",
"shaped",
"numpy",
"array",
"for",
"this",
"feature",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L222-L226 | train | Return a correctly shaped numpy array for this feature. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Feature.unpack_layer | def unpack_layer(plane):
"""Return a correctly shaped numpy array given the feature layer bytes."""
size = point.Point.build(plane.size)
if size == (0, 0):
# New layer that isn't implemented in this SC2 version.
return None
data = np.frombuffer(plane.data, dtype=Feature.dtypes[plane.bits_per... | python | def unpack_layer(plane):
"""Return a correctly shaped numpy array given the feature layer bytes."""
size = point.Point.build(plane.size)
if size == (0, 0):
# New layer that isn't implemented in this SC2 version.
return None
data = np.frombuffer(plane.data, dtype=Feature.dtypes[plane.bits_per... | [
"def",
"unpack_layer",
"(",
"plane",
")",
":",
"size",
"=",
"point",
".",
"Point",
".",
"build",
"(",
"plane",
".",
"size",
")",
"if",
"size",
"==",
"(",
"0",
",",
"0",
")",
":",
"# New layer that isn't implemented in this SC2 version.",
"return",
"None",
... | Return a correctly shaped numpy array given the feature layer bytes. | [
"Return",
"a",
"correctly",
"shaped",
"numpy",
"array",
"given",
"the",
"feature",
"layer",
"bytes",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L230-L244 | train | Return a correctly shaped numpy array given the feature layer bytes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Feature.unpack_rgb_image | def unpack_rgb_image(plane):
"""Return a correctly shaped numpy array given the image bytes."""
assert plane.bits_per_pixel == 24, "{} != 24".format(plane.bits_per_pixel)
size = point.Point.build(plane.size)
data = np.frombuffer(plane.data, dtype=np.uint8)
return data.reshape(size.y, size.x, 3) | python | def unpack_rgb_image(plane):
"""Return a correctly shaped numpy array given the image bytes."""
assert plane.bits_per_pixel == 24, "{} != 24".format(plane.bits_per_pixel)
size = point.Point.build(plane.size)
data = np.frombuffer(plane.data, dtype=np.uint8)
return data.reshape(size.y, size.x, 3) | [
"def",
"unpack_rgb_image",
"(",
"plane",
")",
":",
"assert",
"plane",
".",
"bits_per_pixel",
"==",
"24",
",",
"\"{} != 24\"",
".",
"format",
"(",
"plane",
".",
"bits_per_pixel",
")",
"size",
"=",
"point",
".",
"Point",
".",
"build",
"(",
"plane",
".",
"s... | Return a correctly shaped numpy array given the image bytes. | [
"Return",
"a",
"correctly",
"shaped",
"numpy",
"array",
"given",
"the",
"image",
"bytes",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L248-L253 | train | Return a correctly shaped numpy array given the image bytes. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Features.init_camera | def init_camera(
self, feature_dimensions, map_size, camera_width_world_units):
"""Initialize the camera (especially for feature_units).
This is called in the constructor and may be called repeatedly after
`Features` is constructed, since it deals with rescaling coordinates and not
changing envir... | python | def init_camera(
self, feature_dimensions, map_size, camera_width_world_units):
"""Initialize the camera (especially for feature_units).
This is called in the constructor and may be called repeatedly after
`Features` is constructed, since it deals with rescaling coordinates and not
changing envir... | [
"def",
"init_camera",
"(",
"self",
",",
"feature_dimensions",
",",
"map_size",
",",
"camera_width_world_units",
")",
":",
"if",
"not",
"map_size",
"or",
"not",
"camera_width_world_units",
":",
"raise",
"ValueError",
"(",
"\"Either pass the game_info with raw enabled, or m... | Initialize the camera (especially for feature_units).
This is called in the constructor and may be called repeatedly after
`Features` is constructed, since it deals with rescaling coordinates and not
changing environment/action specs.
Args:
feature_dimensions: See the documentation in `AgentInte... | [
"Initialize",
"the",
"camera",
"(",
"especially",
"for",
"feature_units",
")",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L733-L766 | train | Initialize the camera. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Features._update_camera | def _update_camera(self, camera_center):
"""Update the camera transform based on the new camera center."""
self._world_tl_to_world_camera_rel.offset = (
-self._world_to_world_tl.fwd_pt(camera_center) *
self._world_tl_to_world_camera_rel.scale) | python | def _update_camera(self, camera_center):
"""Update the camera transform based on the new camera center."""
self._world_tl_to_world_camera_rel.offset = (
-self._world_to_world_tl.fwd_pt(camera_center) *
self._world_tl_to_world_camera_rel.scale) | [
"def",
"_update_camera",
"(",
"self",
",",
"camera_center",
")",
":",
"self",
".",
"_world_tl_to_world_camera_rel",
".",
"offset",
"=",
"(",
"-",
"self",
".",
"_world_to_world_tl",
".",
"fwd_pt",
"(",
"camera_center",
")",
"*",
"self",
".",
"_world_tl_to_world_c... | Update the camera transform based on the new camera center. | [
"Update",
"the",
"camera",
"transform",
"based",
"on",
"the",
"new",
"camera",
"center",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L768-L772 | train | Update the camera transform based on the new camera center. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Features.observation_spec | def observation_spec(self):
"""The observation spec for the SC2 environment.
It's worth noting that the image-like observations are in y,x/row,column
order which is different than the actions which are in x,y order. This is
due to conflicting conventions, and to facilitate printing of the images.
... | python | def observation_spec(self):
"""The observation spec for the SC2 environment.
It's worth noting that the image-like observations are in y,x/row,column
order which is different than the actions which are in x,y order. This is
due to conflicting conventions, and to facilitate printing of the images.
... | [
"def",
"observation_spec",
"(",
"self",
")",
":",
"obs_spec",
"=",
"named_array",
".",
"NamedDict",
"(",
"{",
"\"action_result\"",
":",
"(",
"0",
",",
")",
",",
"# See error.proto: ActionResult.",
"\"alerts\"",
":",
"(",
"0",
",",
")",
",",
"# See sc2api.proto... | The observation spec for the SC2 environment.
It's worth noting that the image-like observations are in y,x/row,column
order which is different than the actions which are in x,y order. This is
due to conflicting conventions, and to facilitate printing of the images.
Returns:
The dict of observat... | [
"The",
"observation",
"spec",
"for",
"the",
"SC2",
"environment",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L774-L832 | train | The observation spec for the SC2 environment. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Features.transform_obs | def transform_obs(self, obs):
"""Render some SC2 observations into something an agent can handle."""
empty = np.array([], dtype=np.int32).reshape((0, 7))
out = named_array.NamedDict({ # Fill out some that are sometimes empty.
"single_select": empty,
"multi_select": empty,
"build_que... | python | def transform_obs(self, obs):
"""Render some SC2 observations into something an agent can handle."""
empty = np.array([], dtype=np.int32).reshape((0, 7))
out = named_array.NamedDict({ # Fill out some that are sometimes empty.
"single_select": empty,
"multi_select": empty,
"build_que... | [
"def",
"transform_obs",
"(",
"self",
",",
"obs",
")",
":",
"empty",
"=",
"np",
".",
"array",
"(",
"[",
"]",
",",
"dtype",
"=",
"np",
".",
"int32",
")",
".",
"reshape",
"(",
"(",
"0",
",",
"7",
")",
")",
"out",
"=",
"named_array",
".",
"NamedDic... | Render some SC2 observations into something an agent can handle. | [
"Render",
"some",
"SC2",
"observations",
"into",
"something",
"an",
"agent",
"can",
"handle",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L839-L1054 | train | Transform some SC2 observations into something an agent can handle. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Features.available_actions | def available_actions(self, obs):
"""Return the list of available action ids."""
available_actions = set()
hide_specific_actions = self._agent_interface_format.hide_specific_actions
for i, func in six.iteritems(actions.FUNCTIONS_AVAILABLE):
if func.avail_fn(obs):
available_actions.add(i)
... | python | def available_actions(self, obs):
"""Return the list of available action ids."""
available_actions = set()
hide_specific_actions = self._agent_interface_format.hide_specific_actions
for i, func in six.iteritems(actions.FUNCTIONS_AVAILABLE):
if func.avail_fn(obs):
available_actions.add(i)
... | [
"def",
"available_actions",
"(",
"self",
",",
"obs",
")",
":",
"available_actions",
"=",
"set",
"(",
")",
"hide_specific_actions",
"=",
"self",
".",
"_agent_interface_format",
".",
"hide_specific_actions",
"for",
"i",
",",
"func",
"in",
"six",
".",
"iteritems",
... | Return the list of available action ids. | [
"Return",
"the",
"list",
"of",
"available",
"action",
"ids",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L1057-L1079 | train | Return the list of available action ids. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Features.transform_action | def transform_action(self, obs, func_call, skip_available=False):
"""Tranform an agent-style action to one that SC2 can consume.
Args:
obs: a `sc_pb.Observation` from the previous frame.
func_call: a `FunctionCall` to be turned into a `sc_pb.Action`.
skip_available: If True, assume the action... | python | def transform_action(self, obs, func_call, skip_available=False):
"""Tranform an agent-style action to one that SC2 can consume.
Args:
obs: a `sc_pb.Observation` from the previous frame.
func_call: a `FunctionCall` to be turned into a `sc_pb.Action`.
skip_available: If True, assume the action... | [
"def",
"transform_action",
"(",
"self",
",",
"obs",
",",
"func_call",
",",
"skip_available",
"=",
"False",
")",
":",
"func_id",
"=",
"func_call",
".",
"function",
"try",
":",
"func",
"=",
"actions",
".",
"FUNCTIONS",
"[",
"func_id",
"]",
"except",
"KeyErro... | Tranform an agent-style action to one that SC2 can consume.
Args:
obs: a `sc_pb.Observation` from the previous frame.
func_call: a `FunctionCall` to be turned into a `sc_pb.Action`.
skip_available: If True, assume the action is available. This should only
be used for testing or if you e... | [
"Tranform",
"an",
"agent",
"-",
"style",
"action",
"to",
"one",
"that",
"SC2",
"can",
"consume",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L1082-L1146 | train | Transform an agent - style action to one that SC2 can consume. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/features.py | Features.reverse_action | def reverse_action(self, action):
"""Transform an SC2-style action into an agent-style action.
This should be the inverse of `transform_action`.
Args:
action: a `sc_pb.Action` to be transformed.
Returns:
A corresponding `actions.FunctionCall`.
Raises:
ValueError: if it doesn't ... | python | def reverse_action(self, action):
"""Transform an SC2-style action into an agent-style action.
This should be the inverse of `transform_action`.
Args:
action: a `sc_pb.Action` to be transformed.
Returns:
A corresponding `actions.FunctionCall`.
Raises:
ValueError: if it doesn't ... | [
"def",
"reverse_action",
"(",
"self",
",",
"action",
")",
":",
"FUNCTIONS",
"=",
"actions",
".",
"FUNCTIONS",
"# pylint: disable=invalid-name",
"aif",
"=",
"self",
".",
"_agent_interface_format",
"def",
"func_call_ability",
"(",
"ability_id",
",",
"cmd_type",
",",
... | Transform an SC2-style action into an agent-style action.
This should be the inverse of `transform_action`.
Args:
action: a `sc_pb.Action` to be transformed.
Returns:
A corresponding `actions.FunctionCall`.
Raises:
ValueError: if it doesn't know how to transform this action. | [
"Transform",
"an",
"SC2",
"-",
"style",
"action",
"into",
"an",
"agent",
"-",
"style",
"action",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/features.py#L1149-L1247 | train | Transform an action into an agent - style action. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/agents/scripted_agent.py | _xy_locs | def _xy_locs(mask):
"""Mask should be a set of bools from comparison with a feature layer."""
y, x = mask.nonzero()
return list(zip(x, y)) | python | def _xy_locs(mask):
"""Mask should be a set of bools from comparison with a feature layer."""
y, x = mask.nonzero()
return list(zip(x, y)) | [
"def",
"_xy_locs",
"(",
"mask",
")",
":",
"y",
",",
"x",
"=",
"mask",
".",
"nonzero",
"(",
")",
"return",
"list",
"(",
"zip",
"(",
"x",
",",
"y",
")",
")"
] | Mask should be a set of bools from comparison with a feature layer. | [
"Mask",
"should",
"be",
"a",
"set",
"of",
"bools",
"from",
"comparison",
"with",
"a",
"feature",
"layer",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/agents/scripted_agent.py#L33-L36 | train | Returns a list of indices of the x y values in the mask. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/bin/play.py | main | def main(unused_argv):
"""Run SC2 to play a game or a replay."""
stopwatch.sw.enabled = FLAGS.profile or FLAGS.trace
stopwatch.sw.trace = FLAGS.trace
if (FLAGS.map and FLAGS.replay) or (not FLAGS.map and not FLAGS.replay):
sys.exit("Must supply either a map or replay.")
if FLAGS.replay and not FLAGS.rep... | python | def main(unused_argv):
"""Run SC2 to play a game or a replay."""
stopwatch.sw.enabled = FLAGS.profile or FLAGS.trace
stopwatch.sw.trace = FLAGS.trace
if (FLAGS.map and FLAGS.replay) or (not FLAGS.map and not FLAGS.replay):
sys.exit("Must supply either a map or replay.")
if FLAGS.replay and not FLAGS.rep... | [
"def",
"main",
"(",
"unused_argv",
")",
":",
"stopwatch",
".",
"sw",
".",
"enabled",
"=",
"FLAGS",
".",
"profile",
"or",
"FLAGS",
".",
"trace",
"stopwatch",
".",
"sw",
".",
"trace",
"=",
"FLAGS",
".",
"trace",
"if",
"(",
"FLAGS",
".",
"map",
"and",
... | Run SC2 to play a game or a replay. | [
"Run",
"SC2",
"to",
"play",
"a",
"game",
"or",
"a",
"replay",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/play.py#L84-L197 | train | Run SC2 to play a game or a replay. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/sc_process.py | _shutdown_proc | def _shutdown_proc(p, timeout):
"""Wait for a proc to shut down, then terminate or kill it after `timeout`."""
freq = 10 # how often to check per second
for _ in range(1 + timeout * freq):
ret = p.poll()
if ret is not None:
logging.info("Shutdown gracefully.")
return ret
time.sleep(1 / fr... | python | def _shutdown_proc(p, timeout):
"""Wait for a proc to shut down, then terminate or kill it after `timeout`."""
freq = 10 # how often to check per second
for _ in range(1 + timeout * freq):
ret = p.poll()
if ret is not None:
logging.info("Shutdown gracefully.")
return ret
time.sleep(1 / fr... | [
"def",
"_shutdown_proc",
"(",
"p",
",",
"timeout",
")",
":",
"freq",
"=",
"10",
"# how often to check per second",
"for",
"_",
"in",
"range",
"(",
"1",
"+",
"timeout",
"*",
"freq",
")",
":",
"ret",
"=",
"p",
".",
"poll",
"(",
")",
"if",
"ret",
"is",
... | Wait for a proc to shut down, then terminate or kill it after `timeout`. | [
"Wait",
"for",
"a",
"proc",
"to",
"shut",
"down",
"then",
"terminate",
"or",
"kill",
"it",
"after",
"timeout",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/sc_process.py#L195-L206 | train | Wait for a process to shut down then terminate or kill it after timeout. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/sc_process.py | StarcraftProcess.close | def close(self):
"""Shut down the game and clean up."""
if hasattr(self, "_controller") and self._controller:
self._controller.quit()
self._controller.close()
self._controller = None
self._shutdown()
if hasattr(self, "_port") and self._port:
portpicker.return_port(self._port)
... | python | def close(self):
"""Shut down the game and clean up."""
if hasattr(self, "_controller") and self._controller:
self._controller.quit()
self._controller.close()
self._controller = None
self._shutdown()
if hasattr(self, "_port") and self._port:
portpicker.return_port(self._port)
... | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_controller\"",
")",
"and",
"self",
".",
"_controller",
":",
"self",
".",
"_controller",
".",
"quit",
"(",
")",
"self",
".",
"_controller",
".",
"close",
"(",
")",
"self",
"... | Shut down the game and clean up. | [
"Shut",
"down",
"the",
"game",
"and",
"clean",
"up",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/sc_process.py#L122-L133 | train | Shut down the game and clean up. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/sc_process.py | StarcraftProcess._launch | def _launch(self, run_config, args, **kwargs):
"""Launch the process and return the process object."""
del kwargs
try:
with sw("popen"):
return subprocess.Popen(args, cwd=run_config.cwd, env=run_config.env)
except OSError:
logging.exception("Failed to launch")
raise SC2LaunchEr... | python | def _launch(self, run_config, args, **kwargs):
"""Launch the process and return the process object."""
del kwargs
try:
with sw("popen"):
return subprocess.Popen(args, cwd=run_config.cwd, env=run_config.env)
except OSError:
logging.exception("Failed to launch")
raise SC2LaunchEr... | [
"def",
"_launch",
"(",
"self",
",",
"run_config",
",",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"del",
"kwargs",
"try",
":",
"with",
"sw",
"(",
"\"popen\"",
")",
":",
"return",
"subprocess",
".",
"Popen",
"(",
"args",
",",
"cwd",
"=",
"run_config",... | Launch the process and return the process object. | [
"Launch",
"the",
"process",
"and",
"return",
"the",
"process",
"object",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/sc_process.py#L168-L176 | train | Launch the process and return the process object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/sc_process.py | StarcraftProcess._shutdown | def _shutdown(self):
"""Terminate the sub-process."""
if self._proc:
ret = _shutdown_proc(self._proc, 3)
logging.info("Shutdown with return code: %s", ret)
self._proc = None | python | def _shutdown(self):
"""Terminate the sub-process."""
if self._proc:
ret = _shutdown_proc(self._proc, 3)
logging.info("Shutdown with return code: %s", ret)
self._proc = None | [
"def",
"_shutdown",
"(",
"self",
")",
":",
"if",
"self",
".",
"_proc",
":",
"ret",
"=",
"_shutdown_proc",
"(",
"self",
".",
"_proc",
",",
"3",
")",
"logging",
".",
"info",
"(",
"\"Shutdown with return code: %s\"",
",",
"ret",
")",
"self",
".",
"_proc",
... | Terminate the sub-process. | [
"Terminate",
"the",
"sub",
"-",
"process",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/sc_process.py#L178-L183 | train | Terminate the sub - process. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/bin/gen_actions.py | get_data | def get_data():
"""Retrieve static data from the game."""
run_config = run_configs.get()
with run_config.start(want_rgb=False) as controller:
m = maps.get("Sequencer") # Arbitrary ladder map.
create = sc_pb.RequestCreateGame(local_map=sc_pb.LocalMap(
map_path=m.path, map_data=m.data(run_config))... | python | def get_data():
"""Retrieve static data from the game."""
run_config = run_configs.get()
with run_config.start(want_rgb=False) as controller:
m = maps.get("Sequencer") # Arbitrary ladder map.
create = sc_pb.RequestCreateGame(local_map=sc_pb.LocalMap(
map_path=m.path, map_data=m.data(run_config))... | [
"def",
"get_data",
"(",
")",
":",
"run_config",
"=",
"run_configs",
".",
"get",
"(",
")",
"with",
"run_config",
".",
"start",
"(",
"want_rgb",
"=",
"False",
")",
"as",
"controller",
":",
"m",
"=",
"maps",
".",
"get",
"(",
"\"Sequencer\"",
")",
"# Arbit... | Retrieve static data from the game. | [
"Retrieve",
"static",
"data",
"from",
"the",
"game",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/gen_actions.py#L39-L55 | train | Retrieve static data from the game. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/bin/gen_actions.py | generate_csv | def generate_csv(data):
"""Generate a CSV of the abilities for easy commenting."""
print(",".join([
"ability_id",
"link_name",
"link_index",
"button_name",
"hotkey",
"friendly_name",
"remap_to",
"mismatch",
]))
for ability in sorted(six.itervalues(data.abilities),... | python | def generate_csv(data):
"""Generate a CSV of the abilities for easy commenting."""
print(",".join([
"ability_id",
"link_name",
"link_index",
"button_name",
"hotkey",
"friendly_name",
"remap_to",
"mismatch",
]))
for ability in sorted(six.itervalues(data.abilities),... | [
"def",
"generate_csv",
"(",
"data",
")",
":",
"print",
"(",
"\",\"",
".",
"join",
"(",
"[",
"\"ability_id\"",
",",
"\"link_name\"",
",",
"\"link_index\"",
",",
"\"button_name\"",
",",
"\"hotkey\"",
",",
"\"friendly_name\"",
",",
"\"remap_to\"",
",",
"\"mismatch\... | Generate a CSV of the abilities for easy commenting. | [
"Generate",
"a",
"CSV",
"of",
"the",
"abilities",
"for",
"easy",
"commenting",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/gen_actions.py#L72-L124 | train | Generate a CSV of the abilities for easy commenting. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/bin/gen_actions.py | generate_py_abilities | def generate_py_abilities(data):
"""Generate the list of functions in actions.py."""
def print_action(func_id, name, func, ab_id, general_id):
args = [func_id, '"%s"' % name, func, ab_id]
if general_id:
args.append(general_id)
print(" Function.ability(%s)," % ", ".join(str(v) for v in args))
... | python | def generate_py_abilities(data):
"""Generate the list of functions in actions.py."""
def print_action(func_id, name, func, ab_id, general_id):
args = [func_id, '"%s"' % name, func, ab_id]
if general_id:
args.append(general_id)
print(" Function.ability(%s)," % ", ".join(str(v) for v in args))
... | [
"def",
"generate_py_abilities",
"(",
"data",
")",
":",
"def",
"print_action",
"(",
"func_id",
",",
"name",
",",
"func",
",",
"ab_id",
",",
"general_id",
")",
":",
"args",
"=",
"[",
"func_id",
",",
"'\"%s\"'",
"%",
"name",
",",
"func",
",",
"ab_id",
"]"... | Generate the list of functions in actions.py. | [
"Generate",
"the",
"list",
"of",
"functions",
"in",
"actions",
".",
"py",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/gen_actions.py#L127-L157 | train | Generate the list of functions in actions. py. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/bin/agent_remote.py | agent | def agent():
"""Run the agent, connecting to a (remote) host started independently."""
agent_module, agent_name = FLAGS.agent.rsplit(".", 1)
agent_cls = getattr(importlib.import_module(agent_module), agent_name)
logging.info("Starting agent:")
with remote_sc2_env.RemoteSC2Env(
map_name=FLAGS.map,
... | python | def agent():
"""Run the agent, connecting to a (remote) host started independently."""
agent_module, agent_name = FLAGS.agent.rsplit(".", 1)
agent_cls = getattr(importlib.import_module(agent_module), agent_name)
logging.info("Starting agent:")
with remote_sc2_env.RemoteSC2Env(
map_name=FLAGS.map,
... | [
"def",
"agent",
"(",
")",
":",
"agent_module",
",",
"agent_name",
"=",
"FLAGS",
".",
"agent",
".",
"rsplit",
"(",
"\".\"",
",",
"1",
")",
"agent_cls",
"=",
"getattr",
"(",
"importlib",
".",
"import_module",
"(",
"agent_module",
")",
",",
"agent_name",
")... | Run the agent, connecting to a (remote) host started independently. | [
"Run",
"the",
"agent",
"connecting",
"to",
"a",
"(",
"remote",
")",
"host",
"started",
"independently",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/agent_remote.py#L124-L152 | train | Run the agent connecting to a remote host. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/bin/agent_remote.py | human | def human():
"""Run a host which expects one player to connect remotely."""
run_config = run_configs.get()
map_inst = maps.get(FLAGS.map)
if not FLAGS.rgb_screen_size or not FLAGS.rgb_minimap_size:
logging.info("Use --rgb_screen_size and --rgb_minimap_size if you want rgb "
"observations.... | python | def human():
"""Run a host which expects one player to connect remotely."""
run_config = run_configs.get()
map_inst = maps.get(FLAGS.map)
if not FLAGS.rgb_screen_size or not FLAGS.rgb_minimap_size:
logging.info("Use --rgb_screen_size and --rgb_minimap_size if you want rgb "
"observations.... | [
"def",
"human",
"(",
")",
":",
"run_config",
"=",
"run_configs",
".",
"get",
"(",
")",
"map_inst",
"=",
"maps",
".",
"get",
"(",
"FLAGS",
".",
"map",
")",
"if",
"not",
"FLAGS",
".",
"rgb_screen_size",
"or",
"not",
"FLAGS",
".",
"rgb_minimap_size",
":",... | Run a host which expects one player to connect remotely. | [
"Run",
"a",
"host",
"which",
"expects",
"one",
"player",
"to",
"connect",
"remotely",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/agent_remote.py#L155-L229 | train | Run a host which expects one player to connect remotely. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/stopwatch.py | Stat.dev | def dev(self):
"""Standard deviation."""
if self.num == 0:
return 0
return math.sqrt(max(0, self.sum_sq / self.num - (self.sum / self.num)**2)) | python | def dev(self):
"""Standard deviation."""
if self.num == 0:
return 0
return math.sqrt(max(0, self.sum_sq / self.num - (self.sum / self.num)**2)) | [
"def",
"dev",
"(",
"self",
")",
":",
"if",
"self",
".",
"num",
"==",
"0",
":",
"return",
"0",
"return",
"math",
".",
"sqrt",
"(",
"max",
"(",
"0",
",",
"self",
".",
"sum_sq",
"/",
"self",
".",
"num",
"-",
"(",
"self",
".",
"sum",
"/",
"self",... | Standard deviation. | [
"Standard",
"deviation",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/stopwatch.py#L60-L64 | train | Standard deviation of the current object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/stopwatch.py | StopWatch.decorate | def decorate(self, name_or_func):
"""Decorate a function/method to check its timings.
To use the function's name:
@sw.decorate
def func():
pass
To name it explicitly:
@sw.decorate("name")
def random_func_name():
pass
Args:
name_or_func: the name or the fu... | python | def decorate(self, name_or_func):
"""Decorate a function/method to check its timings.
To use the function's name:
@sw.decorate
def func():
pass
To name it explicitly:
@sw.decorate("name")
def random_func_name():
pass
Args:
name_or_func: the name or the fu... | [
"def",
"decorate",
"(",
"self",
",",
"name_or_func",
")",
":",
"if",
"os",
".",
"environ",
".",
"get",
"(",
"\"SC2_NO_STOPWATCH\"",
")",
":",
"return",
"name_or_func",
"if",
"callable",
"(",
"name_or_func",
")",
"else",
"lambda",
"func",
":",
"func",
"def"... | Decorate a function/method to check its timings.
To use the function's name:
@sw.decorate
def func():
pass
To name it explicitly:
@sw.decorate("name")
def random_func_name():
pass
Args:
name_or_func: the name or the function to decorate.
Returns:
I... | [
"Decorate",
"a",
"function",
"/",
"method",
"to",
"check",
"its",
"timings",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/stopwatch.py#L174-L206 | train | Decorate a function or method to check its timings. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/stopwatch.py | StopWatch.parse | def parse(s):
"""Parse the output below to create a new StopWatch."""
stopwatch = StopWatch()
for line in s.splitlines():
if line.strip():
parts = line.split(None)
name = parts[0]
if name != "%": # ie not the header line
rest = (float(v) for v in parts[2:])
... | python | def parse(s):
"""Parse the output below to create a new StopWatch."""
stopwatch = StopWatch()
for line in s.splitlines():
if line.strip():
parts = line.split(None)
name = parts[0]
if name != "%": # ie not the header line
rest = (float(v) for v in parts[2:])
... | [
"def",
"parse",
"(",
"s",
")",
":",
"stopwatch",
"=",
"StopWatch",
"(",
")",
"for",
"line",
"in",
"s",
".",
"splitlines",
"(",
")",
":",
"if",
"line",
".",
"strip",
"(",
")",
":",
"parts",
"=",
"line",
".",
"split",
"(",
"None",
")",
"name",
"=... | Parse the output below to create a new StopWatch. | [
"Parse",
"the",
"output",
"below",
"to",
"create",
"a",
"new",
"StopWatch",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/stopwatch.py#L242-L252 | train | Parse the output below to create a new StopWatch object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/stopwatch.py | StopWatch.str | def str(self, threshold=0.1):
"""Return a string representation of the timings."""
if not self._times:
return ""
total = sum(s.sum for k, s in six.iteritems(self._times) if "." not in k)
table = [["", "% total", "sum", "avg", "dev", "min", "max", "num"]]
for k, v in sorted(self._times.items())... | python | def str(self, threshold=0.1):
"""Return a string representation of the timings."""
if not self._times:
return ""
total = sum(s.sum for k, s in six.iteritems(self._times) if "." not in k)
table = [["", "% total", "sum", "avg", "dev", "min", "max", "num"]]
for k, v in sorted(self._times.items())... | [
"def",
"str",
"(",
"self",
",",
"threshold",
"=",
"0.1",
")",
":",
"if",
"not",
"self",
".",
"_times",
":",
"return",
"\"\"",
"total",
"=",
"sum",
"(",
"s",
".",
"sum",
"for",
"k",
",",
"s",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"_ti... | Return a string representation of the timings. | [
"Return",
"a",
"string",
"representation",
"of",
"the",
"timings",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/stopwatch.py#L254-L282 | train | Return a string representation of the timings. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/bin/gen_units.py | generate_py_units | def generate_py_units(data):
"""Generate the list of units in units.py."""
units = collections.defaultdict(list)
for unit in sorted(data.units, key=lambda a: a.name):
if unit.unit_id in static_data.UNIT_TYPES:
units[unit.race].append(unit)
def print_race(name, race):
print("class %s(enum.IntEnum)... | python | def generate_py_units(data):
"""Generate the list of units in units.py."""
units = collections.defaultdict(list)
for unit in sorted(data.units, key=lambda a: a.name):
if unit.unit_id in static_data.UNIT_TYPES:
units[unit.race].append(unit)
def print_race(name, race):
print("class %s(enum.IntEnum)... | [
"def",
"generate_py_units",
"(",
"data",
")",
":",
"units",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"for",
"unit",
"in",
"sorted",
"(",
"data",
".",
"units",
",",
"key",
"=",
"lambda",
"a",
":",
"a",
".",
"name",
")",
":",
"if",
"... | Generate the list of units in units.py. | [
"Generate",
"the",
"list",
"of",
"units",
"in",
"units",
".",
"py",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/bin/gen_units.py#L51-L68 | train | Generate the list of units in units. py. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
deepmind/pysc2 | pysc2/lib/run_parallel.py | RunParallel.run | def run(self, funcs):
"""Run a set of functions in parallel, returning their results.
Make sure any function you pass exits with a reasonable timeout. If it
doesn't return within the timeout or the result is ignored due an exception
in a separate thread it will continue to stick around until it finishe... | python | def run(self, funcs):
"""Run a set of functions in parallel, returning their results.
Make sure any function you pass exits with a reasonable timeout. If it
doesn't return within the timeout or the result is ignored due an exception
in a separate thread it will continue to stick around until it finishe... | [
"def",
"run",
"(",
"self",
",",
"funcs",
")",
":",
"funcs",
"=",
"[",
"f",
"if",
"callable",
"(",
"f",
")",
"else",
"functools",
".",
"partial",
"(",
"*",
"f",
")",
"for",
"f",
"in",
"funcs",
"]",
"if",
"len",
"(",
"funcs",
")",
"==",
"1",
":... | Run a set of functions in parallel, returning their results.
Make sure any function you pass exits with a reasonable timeout. If it
doesn't return within the timeout or the result is ignored due an exception
in a separate thread it will continue to stick around until it finishes,
including blocking pro... | [
"Run",
"a",
"set",
"of",
"functions",
"in",
"parallel",
"returning",
"their",
"results",
"."
] | df4cc4b00f07a2242be9ba153d4a7f4ad2017897 | https://github.com/deepmind/pysc2/blob/df4cc4b00f07a2242be9ba153d4a7f4ad2017897/pysc2/lib/run_parallel.py#L37-L75 | train | Run a set of functions in parallel returning their results. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/charts/jsontools.py | dict_to_json | def dict_to_json(xcol, ycols, labels, value_columns):
"""
Converts a list of dicts from datamodel query results
to google chart json data.
:param xcol:
The name of a string column to be used has X axis on chart
:param ycols:
A list with the names of series co... | python | def dict_to_json(xcol, ycols, labels, value_columns):
"""
Converts a list of dicts from datamodel query results
to google chart json data.
:param xcol:
The name of a string column to be used has X axis on chart
:param ycols:
A list with the names of series co... | [
"def",
"dict_to_json",
"(",
"xcol",
",",
"ycols",
",",
"labels",
",",
"value_columns",
")",
":",
"json_data",
"=",
"dict",
"(",
")",
"json_data",
"[",
"'cols'",
"]",
"=",
"[",
"{",
"'id'",
":",
"xcol",
",",
"'label'",
":",
"as_unicode",
"(",
"labels",
... | Converts a list of dicts from datamodel query results
to google chart json data.
:param xcol:
The name of a string column to be used has X axis on chart
:param ycols:
A list with the names of series cols, that can be used as numeric
:param labels:
A d... | [
"Converts",
"a",
"list",
"of",
"dicts",
"from",
"datamodel",
"query",
"results",
"to",
"google",
"chart",
"json",
"data",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/charts/jsontools.py#L6-L42 | train | Converts a list of dicts from datamodel query results
AttributeNames to google chart json data. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/api/manager.py | OpenApi.get | def get(self, version):
""" Endpoint that renders an OpenApi spec for all views that belong
to a certain version
---
get:
parameters:
- in: path
schema:
type: string
name: version
responses:
200:
... | python | def get(self, version):
""" Endpoint that renders an OpenApi spec for all views that belong
to a certain version
---
get:
parameters:
- in: path
schema:
type: string
name: version
responses:
200:
... | [
"def",
"get",
"(",
"self",
",",
"version",
")",
":",
"version_found",
"=",
"False",
"api_spec",
"=",
"self",
".",
"_create_api_spec",
"(",
"version",
")",
"for",
"base_api",
"in",
"current_app",
".",
"appbuilder",
".",
"baseviews",
":",
"if",
"isinstance",
... | Endpoint that renders an OpenApi spec for all views that belong
to a certain version
---
get:
parameters:
- in: path
schema:
type: string
name: version
responses:
200:
description: Item from Model
... | [
"Endpoint",
"that",
"renders",
"an",
"OpenApi",
"spec",
"for",
"all",
"views",
"that",
"belong",
"to",
"a",
"certain",
"version",
"---",
"get",
":",
"parameters",
":",
"-",
"in",
":",
"path",
"schema",
":",
"type",
":",
"string",
"name",
":",
"version",
... | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/manager.py#L18-L49 | train | Endpoint that renders an OpenApi spec for all views that belong to a certain version | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/sqla/filters.py | get_field_setup_query | def get_field_setup_query(query, model, column_name):
"""
Help function for SQLA filters, checks for dot notation on column names.
If it exists, will join the query with the model
from the first part of the field name.
example:
Contact.created_by: if created_by is a User... | python | def get_field_setup_query(query, model, column_name):
"""
Help function for SQLA filters, checks for dot notation on column names.
If it exists, will join the query with the model
from the first part of the field name.
example:
Contact.created_by: if created_by is a User... | [
"def",
"get_field_setup_query",
"(",
"query",
",",
"model",
",",
"column_name",
")",
":",
"if",
"not",
"hasattr",
"(",
"model",
",",
"column_name",
")",
":",
"# it's an inner obj attr",
"rel_model",
"=",
"getattr",
"(",
"model",
",",
"column_name",
".",
"split... | Help function for SQLA filters, checks for dot notation on column names.
If it exists, will join the query with the model
from the first part of the field name.
example:
Contact.created_by: if created_by is a User model,
it will be joined to the query. | [
"Help",
"function",
"for",
"SQLA",
"filters",
"checks",
"for",
"dot",
"notation",
"on",
"column",
"names",
".",
"If",
"it",
"exists",
"will",
"join",
"the",
"query",
"with",
"the",
"model",
"from",
"the",
"first",
"part",
"of",
"the",
"field",
"name",
".... | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/sqla/filters.py#L30-L46 | train | Help function for SQLA filters. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/mongoengine/manager.py | SecurityManager.add_permission | def add_permission(self, name):
"""
Adds a permission to the backend, model permission
:param name:
name of the permission: 'can_add','can_edit' etc...
"""
perm = self.find_permission(name)
if perm is None:
try:
perm = ... | python | def add_permission(self, name):
"""
Adds a permission to the backend, model permission
:param name:
name of the permission: 'can_add','can_edit' etc...
"""
perm = self.find_permission(name)
if perm is None:
try:
perm = ... | [
"def",
"add_permission",
"(",
"self",
",",
"name",
")",
":",
"perm",
"=",
"self",
".",
"find_permission",
"(",
"name",
")",
"if",
"perm",
"is",
"None",
":",
"try",
":",
"perm",
"=",
"self",
".",
"permission_model",
"(",
"name",
"=",
"name",
")",
"per... | Adds a permission to the backend, model permission
:param name:
name of the permission: 'can_add','can_edit' etc... | [
"Adds",
"a",
"permission",
"to",
"the",
"backend",
"model",
"permission"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/mongoengine/manager.py#L187-L202 | train | Adds a permission to the backend model permission
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/mongoengine/manager.py | SecurityManager.add_view_menu | def add_view_menu(self, name):
"""
Adds a view or menu to the backend, model view_menu
param name:
name of the view menu to add
"""
view_menu = self.find_view_menu(name)
if view_menu is None:
try:
view_menu = self.viewme... | python | def add_view_menu(self, name):
"""
Adds a view or menu to the backend, model view_menu
param name:
name of the view menu to add
"""
view_menu = self.find_view_menu(name)
if view_menu is None:
try:
view_menu = self.viewme... | [
"def",
"add_view_menu",
"(",
"self",
",",
"name",
")",
":",
"view_menu",
"=",
"self",
".",
"find_view_menu",
"(",
"name",
")",
"if",
"view_menu",
"is",
"None",
":",
"try",
":",
"view_menu",
"=",
"self",
".",
"viewmenu_model",
"(",
"name",
"=",
"name",
... | Adds a view or menu to the backend, model view_menu
param name:
name of the view menu to add | [
"Adds",
"a",
"view",
"or",
"menu",
"to",
"the",
"backend",
"model",
"view_menu",
"param",
"name",
":",
"name",
"of",
"the",
"view",
"menu",
"to",
"add"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/mongoengine/manager.py#L233-L247 | train | Adds a view or menu to the backend model view_menu
returns the newly created view_menu object | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/mongoengine/manager.py | SecurityManager.del_view_menu | def del_view_menu(self, name):
"""
Deletes a ViewMenu from the backend
:param name:
name of the ViewMenu
"""
obj = self.find_view_menu(name)
if obj:
try:
obj.delete()
except Exception as e:
l... | python | def del_view_menu(self, name):
"""
Deletes a ViewMenu from the backend
:param name:
name of the ViewMenu
"""
obj = self.find_view_menu(name)
if obj:
try:
obj.delete()
except Exception as e:
l... | [
"def",
"del_view_menu",
"(",
"self",
",",
"name",
")",
":",
"obj",
"=",
"self",
".",
"find_view_menu",
"(",
"name",
")",
"if",
"obj",
":",
"try",
":",
"obj",
".",
"delete",
"(",
")",
"except",
"Exception",
"as",
"e",
":",
"log",
".",
"error",
"(",
... | Deletes a ViewMenu from the backend
:param name:
name of the ViewMenu | [
"Deletes",
"a",
"ViewMenu",
"from",
"the",
"backend"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/mongoengine/manager.py#L249-L261 | train | Deletes a ViewMenu from the backend | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/mongoengine/manager.py | SecurityManager.find_permission_view_menu | def find_permission_view_menu(self, permission_name, view_menu_name):
"""
Finds and returns a PermissionView by names
"""
permission = self.find_permission(permission_name)
view_menu = self.find_view_menu(view_menu_name)
if permission and view_menu:
return... | python | def find_permission_view_menu(self, permission_name, view_menu_name):
"""
Finds and returns a PermissionView by names
"""
permission = self.find_permission(permission_name)
view_menu = self.find_view_menu(view_menu_name)
if permission and view_menu:
return... | [
"def",
"find_permission_view_menu",
"(",
"self",
",",
"permission_name",
",",
"view_menu_name",
")",
":",
"permission",
"=",
"self",
".",
"find_permission",
"(",
"permission_name",
")",
"view_menu",
"=",
"self",
".",
"find_view_menu",
"(",
"view_menu_name",
")",
"... | Finds and returns a PermissionView by names | [
"Finds",
"and",
"returns",
"a",
"PermissionView",
"by",
"names"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/mongoengine/manager.py#L269-L278 | train | Finds and returns a PermissionView by names
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/mongoengine/manager.py | SecurityManager.add_permission_view_menu | def add_permission_view_menu(self, permission_name, view_menu_name):
"""
Adds a permission on a view or menu to the backend
:param permission_name:
name of the permission to add: 'can_add','can_edit' etc...
:param view_menu_name:
name of the v... | python | def add_permission_view_menu(self, permission_name, view_menu_name):
"""
Adds a permission on a view or menu to the backend
:param permission_name:
name of the permission to add: 'can_add','can_edit' etc...
:param view_menu_name:
name of the v... | [
"def",
"add_permission_view_menu",
"(",
"self",
",",
"permission_name",
",",
"view_menu_name",
")",
":",
"if",
"not",
"(",
"permission_name",
"and",
"view_menu_name",
")",
":",
"return",
"None",
"pv",
"=",
"self",
".",
"find_permission_view_menu",
"(",
"permission... | Adds a permission on a view or menu to the backend
:param permission_name:
name of the permission to add: 'can_add','can_edit' etc...
:param view_menu_name:
name of the view menu to add | [
"Adds",
"a",
"permission",
"on",
"a",
"view",
"or",
"menu",
"to",
"the",
"backend"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/mongoengine/manager.py#L289-L315 | train | Adds a permission on a view or menu to the backend. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/mongoengine/manager.py | SecurityManager.add_permission_role | def add_permission_role(self, role, perm_view):
"""
Add permission-ViewMenu object to Role
:param role:
The role object
:param perm_view:
The PermissionViewMenu object
"""
if perm_view not in role.permissions:
try:
... | python | def add_permission_role(self, role, perm_view):
"""
Add permission-ViewMenu object to Role
:param role:
The role object
:param perm_view:
The PermissionViewMenu object
"""
if perm_view not in role.permissions:
try:
... | [
"def",
"add_permission_role",
"(",
"self",
",",
"role",
",",
"perm_view",
")",
":",
"if",
"perm_view",
"not",
"in",
"role",
".",
"permissions",
":",
"try",
":",
"role",
".",
"permissions",
".",
"append",
"(",
"perm_view",
")",
"role",
".",
"save",
"(",
... | Add permission-ViewMenu object to Role
:param role:
The role object
:param perm_view:
The PermissionViewMenu object | [
"Add",
"permission",
"-",
"ViewMenu",
"object",
"to",
"Role"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/mongoengine/manager.py#L344-L361 | train | Adds permission - ViewMenu object to the specified role. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/mongoengine/manager.py | SecurityManager.del_permission_role | def del_permission_role(self, role, perm_view):
"""
Remove permission-ViewMenu object to Role
:param role:
The role object
:param perm_view:
The PermissionViewMenu object
"""
if perm_view in role.permissions:
try:
... | python | def del_permission_role(self, role, perm_view):
"""
Remove permission-ViewMenu object to Role
:param role:
The role object
:param perm_view:
The PermissionViewMenu object
"""
if perm_view in role.permissions:
try:
... | [
"def",
"del_permission_role",
"(",
"self",
",",
"role",
",",
"perm_view",
")",
":",
"if",
"perm_view",
"in",
"role",
".",
"permissions",
":",
"try",
":",
"role",
".",
"permissions",
".",
"remove",
"(",
"perm_view",
")",
"role",
".",
"save",
"(",
")",
"... | Remove permission-ViewMenu object to Role
:param role:
The role object
:param perm_view:
The PermissionViewMenu object | [
"Remove",
"permission",
"-",
"ViewMenu",
"object",
"to",
"Role"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/mongoengine/manager.py#L363-L380 | train | Removes permission - ViewMenu object to the specified role. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/mongoengine/interface.py | MongoEngineInterface.get_columns_list | def get_columns_list(self):
"""
modified: removing the '_cls' column added by Mongoengine to support
mongodb document inheritance
cf. http://docs.mongoengine.org/apireference.html#documents:
"A Document subclass may be itself subclassed,
to create a specialised version of... | python | def get_columns_list(self):
"""
modified: removing the '_cls' column added by Mongoengine to support
mongodb document inheritance
cf. http://docs.mongoengine.org/apireference.html#documents:
"A Document subclass may be itself subclassed,
to create a specialised version of... | [
"def",
"get_columns_list",
"(",
"self",
")",
":",
"columns",
"=",
"list",
"(",
"self",
".",
"obj",
".",
"_fields",
".",
"keys",
"(",
")",
")",
"if",
"\"_cls\"",
"in",
"columns",
":",
"columns",
".",
"remove",
"(",
"\"_cls\"",
")",
"return",
"columns"
] | modified: removing the '_cls' column added by Mongoengine to support
mongodb document inheritance
cf. http://docs.mongoengine.org/apireference.html#documents:
"A Document subclass may be itself subclassed,
to create a specialised version of the document that will be
stored in the... | [
"modified",
":",
"removing",
"the",
"_cls",
"column",
"added",
"by",
"Mongoengine",
"to",
"support",
"mongodb",
"document",
"inheritance",
"cf",
".",
"http",
":",
"//",
"docs",
".",
"mongoengine",
".",
"org",
"/",
"apireference",
".",
"html#documents",
":",
... | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/mongoengine/interface.py#L238-L254 | train | Returns a list of the columns that are used by the object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/mongoengine/interface.py | MongoEngineInterface.get_order_columns_list | def get_order_columns_list(self, list_columns=None):
"""
Returns the columns that can be ordered
:param list_columns: optional list of columns name, if provided will
use this list only.
"""
ret_lst = list()
list_columns = list_columns or self.get_... | python | def get_order_columns_list(self, list_columns=None):
"""
Returns the columns that can be ordered
:param list_columns: optional list of columns name, if provided will
use this list only.
"""
ret_lst = list()
list_columns = list_columns or self.get_... | [
"def",
"get_order_columns_list",
"(",
"self",
",",
"list_columns",
"=",
"None",
")",
":",
"ret_lst",
"=",
"list",
"(",
")",
"list_columns",
"=",
"list_columns",
"or",
"self",
".",
"get_columns_list",
"(",
")",
"for",
"col_name",
"in",
"list_columns",
":",
"i... | Returns the columns that can be ordered
:param list_columns: optional list of columns name, if provided will
use this list only. | [
"Returns",
"the",
"columns",
"that",
"can",
"be",
"ordered"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/mongoengine/interface.py#L274-L289 | train | Returns the list of columns that can be ordered by the user. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/mongoengine/interface.py | MongoEngineInterface.get_keys | def get_keys(self, lst):
"""
return a list of pk values from object list
"""
pk_name = self.get_pk_name()
return [getattr(item, pk_name) for item in lst] | python | def get_keys(self, lst):
"""
return a list of pk values from object list
"""
pk_name = self.get_pk_name()
return [getattr(item, pk_name) for item in lst] | [
"def",
"get_keys",
"(",
"self",
",",
"lst",
")",
":",
"pk_name",
"=",
"self",
".",
"get_pk_name",
"(",
")",
"return",
"[",
"getattr",
"(",
"item",
",",
"pk_name",
")",
"for",
"item",
"in",
"lst",
"]"
] | return a list of pk values from object list | [
"return",
"a",
"list",
"of",
"pk",
"values",
"from",
"object",
"list"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/mongoengine/interface.py#L305-L310 | train | get_keys returns a list of pk values from object list
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/decorators.py | renders | def renders(col_name):
"""
Use this decorator to map your custom Model properties to actual
Model db properties. As an example::
class MyModel(Model):
id = Column(Integer, primary_key=True)
name = Column(String(50), unique = True, nullable=False)
... | python | def renders(col_name):
"""
Use this decorator to map your custom Model properties to actual
Model db properties. As an example::
class MyModel(Model):
id = Column(Integer, primary_key=True)
name = Column(String(50), unique = True, nullable=False)
... | [
"def",
"renders",
"(",
"col_name",
")",
":",
"def",
"wrap",
"(",
"f",
")",
":",
"if",
"not",
"hasattr",
"(",
"f",
",",
"'_col_name'",
")",
":",
"f",
".",
"_col_name",
"=",
"col_name",
"return",
"f",
"return",
"wrap"
] | Use this decorator to map your custom Model properties to actual
Model db properties. As an example::
class MyModel(Model):
id = Column(Integer, primary_key=True)
name = Column(String(50), unique = True, nullable=False)
custom = Column(Integer(20))
... | [
"Use",
"this",
"decorator",
"to",
"map",
"your",
"custom",
"Model",
"properties",
"to",
"actual",
"Model",
"db",
"properties",
".",
"As",
"an",
"example",
"::"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/decorators.py#L1-L27 | train | Decorator to map your custom Model properties to actual
Model db properties. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/base.py | BaseInterface._get_values | def _get_values(self, lst, list_columns):
"""
Get Values: formats values for list template.
returns [{'col_name':'col_value',....},{'col_name':'col_value',....}]
:param lst:
The list of item objects from query
:param list_columns:
... | python | def _get_values(self, lst, list_columns):
"""
Get Values: formats values for list template.
returns [{'col_name':'col_value',....},{'col_name':'col_value',....}]
:param lst:
The list of item objects from query
:param list_columns:
... | [
"def",
"_get_values",
"(",
"self",
",",
"lst",
",",
"list_columns",
")",
":",
"retlst",
"=",
"[",
"]",
"for",
"item",
"in",
"lst",
":",
"retdict",
"=",
"{",
"}",
"for",
"col",
"in",
"list_columns",
":",
"retdict",
"[",
"col",
"]",
"=",
"self",
".",... | Get Values: formats values for list template.
returns [{'col_name':'col_value',....},{'col_name':'col_value',....}]
:param lst:
The list of item objects from query
:param list_columns:
The list of columns to include | [
"Get",
"Values",
":",
"formats",
"values",
"for",
"list",
"template",
".",
"returns",
"[",
"{",
"col_name",
":",
"col_value",
"....",
"}",
"{",
"col_name",
":",
"col_value",
"....",
"}",
"]"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/base.py#L93-L109 | train | Formats values for list template.
returns a list of dicts | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/base.py | BaseInterface.get_values | def get_values(self, lst, list_columns):
"""
Get Values: formats values for list template.
returns [{'col_name':'col_value',....},{'col_name':'col_value',....}]
:param lst:
The list of item objects from query
:param list_columns:
T... | python | def get_values(self, lst, list_columns):
"""
Get Values: formats values for list template.
returns [{'col_name':'col_value',....},{'col_name':'col_value',....}]
:param lst:
The list of item objects from query
:param list_columns:
T... | [
"def",
"get_values",
"(",
"self",
",",
"lst",
",",
"list_columns",
")",
":",
"for",
"item",
"in",
"lst",
":",
"retdict",
"=",
"{",
"}",
"for",
"col",
"in",
"list_columns",
":",
"retdict",
"[",
"col",
"]",
"=",
"self",
".",
"_get_attr_value",
"(",
"it... | Get Values: formats values for list template.
returns [{'col_name':'col_value',....},{'col_name':'col_value',....}]
:param lst:
The list of item objects from query
:param list_columns:
The list of columns to include | [
"Get",
"Values",
":",
"formats",
"values",
"for",
"list",
"template",
".",
"returns",
"[",
"{",
"col_name",
":",
"col_value",
"....",
"}",
"{",
"col_name",
":",
"col_value",
"....",
"}",
"]"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/base.py#L111-L125 | train | Get values for the items in lst | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/base.py | BaseInterface.get_values_json | def get_values_json(self, lst, list_columns):
"""
Converts list of objects from query to JSON
"""
result = []
for item in self.get_values(lst, list_columns):
for key, value in list(item.items()):
if isinstance(value, datetime.datetime) or isinstanc... | python | def get_values_json(self, lst, list_columns):
"""
Converts list of objects from query to JSON
"""
result = []
for item in self.get_values(lst, list_columns):
for key, value in list(item.items()):
if isinstance(value, datetime.datetime) or isinstanc... | [
"def",
"get_values_json",
"(",
"self",
",",
"lst",
",",
"list_columns",
")",
":",
"result",
"=",
"[",
"]",
"for",
"item",
"in",
"self",
".",
"get_values",
"(",
"lst",
",",
"list_columns",
")",
":",
"for",
"key",
",",
"value",
"in",
"list",
"(",
"item... | Converts list of objects from query to JSON | [
"Converts",
"list",
"of",
"objects",
"from",
"query",
"to",
"JSON"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/base.py#L127-L142 | train | Converts list of objects from query to JSON | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/models/base.py | BaseInterface.get_keys | def get_keys(self, lst):
"""
return a list of pk values from object list
"""
pk_name = self.get_pk_name()
if self.is_pk_composite():
return [[getattr(item, pk) for pk in pk_name] for item in lst]
else:
return [getattr(item, pk_name) for item in... | python | def get_keys(self, lst):
"""
return a list of pk values from object list
"""
pk_name = self.get_pk_name()
if self.is_pk_composite():
return [[getattr(item, pk) for pk in pk_name] for item in lst]
else:
return [getattr(item, pk_name) for item in... | [
"def",
"get_keys",
"(",
"self",
",",
"lst",
")",
":",
"pk_name",
"=",
"self",
".",
"get_pk_name",
"(",
")",
"if",
"self",
".",
"is_pk_composite",
"(",
")",
":",
"return",
"[",
"[",
"getattr",
"(",
"item",
",",
"pk",
")",
"for",
"pk",
"in",
"pk_name... | return a list of pk values from object list | [
"return",
"a",
"list",
"of",
"pk",
"values",
"from",
"object",
"list"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/models/base.py#L275-L283 | train | get_keys returns a list of pk values from object list
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/registerviews.py | BaseRegisterUser.send_email | def send_email(self, register_user):
"""
Method for sending the registration Email to the user
"""
try:
from flask_mail import Mail, Message
except Exception:
log.error("Install Flask-Mail to use User registration")
return False
mai... | python | def send_email(self, register_user):
"""
Method for sending the registration Email to the user
"""
try:
from flask_mail import Mail, Message
except Exception:
log.error("Install Flask-Mail to use User registration")
return False
mai... | [
"def",
"send_email",
"(",
"self",
",",
"register_user",
")",
":",
"try",
":",
"from",
"flask_mail",
"import",
"Mail",
",",
"Message",
"except",
"Exception",
":",
"log",
".",
"error",
"(",
"\"Install Flask-Mail to use User registration\"",
")",
"return",
"False",
... | Method for sending the registration Email to the user | [
"Method",
"for",
"sending",
"the",
"registration",
"Email",
"to",
"the",
"user"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/registerviews.py#L72-L102 | train | Method for sending the registration Email to the user | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/registerviews.py | BaseRegisterUser.add_registration | def add_registration(self, username, first_name, last_name, email, password=""):
"""
Add a registration request for the user.
:rtype : RegisterUser
"""
register_user = self.appbuilder.sm.add_register_user(
username, first_name, last_name, email, password
... | python | def add_registration(self, username, first_name, last_name, email, password=""):
"""
Add a registration request for the user.
:rtype : RegisterUser
"""
register_user = self.appbuilder.sm.add_register_user(
username, first_name, last_name, email, password
... | [
"def",
"add_registration",
"(",
"self",
",",
"username",
",",
"first_name",
",",
"last_name",
",",
"email",
",",
"password",
"=",
"\"\"",
")",
":",
"register_user",
"=",
"self",
".",
"appbuilder",
".",
"sm",
".",
"add_register_user",
"(",
"username",
",",
... | Add a registration request for the user.
:rtype : RegisterUser | [
"Add",
"a",
"registration",
"request",
"for",
"the",
"user",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/registerviews.py#L104-L120 | train | Adds a new registration request for the user. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/registerviews.py | BaseRegisterUser.activation | def activation(self, activation_hash):
"""
Endpoint to expose an activation url, this url
is sent to the user by email, when accessed the user is inserted
and activated
"""
reg = self.appbuilder.sm.find_register_user(activation_hash)
if not reg:
... | python | def activation(self, activation_hash):
"""
Endpoint to expose an activation url, this url
is sent to the user by email, when accessed the user is inserted
and activated
"""
reg = self.appbuilder.sm.find_register_user(activation_hash)
if not reg:
... | [
"def",
"activation",
"(",
"self",
",",
"activation_hash",
")",
":",
"reg",
"=",
"self",
".",
"appbuilder",
".",
"sm",
".",
"find_register_user",
"(",
"activation_hash",
")",
"if",
"not",
"reg",
":",
"log",
".",
"error",
"(",
"c",
".",
"LOGMSG_ERR_SEC_NO_RE... | Endpoint to expose an activation url, this url
is sent to the user by email, when accessed the user is inserted
and activated | [
"Endpoint",
"to",
"expose",
"an",
"activation",
"url",
"this",
"url",
"is",
"sent",
"to",
"the",
"user",
"by",
"email",
"when",
"accessed",
"the",
"user",
"is",
"inserted",
"and",
"activated"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/registerviews.py#L123-L154 | train | This endpoint is used to expose an activation url for the user. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/registerviews.py | RegisterUserOIDView.oid_login_handler | def oid_login_handler(self, f, oid):
"""
Hackish method to make use of oid.login_handler decorator.
"""
if request.args.get("openid_complete") != u"yes":
return f(False)
consumer = Consumer(SessionWrapper(self), oid.store_factory())
openid_response = consu... | python | def oid_login_handler(self, f, oid):
"""
Hackish method to make use of oid.login_handler decorator.
"""
if request.args.get("openid_complete") != u"yes":
return f(False)
consumer = Consumer(SessionWrapper(self), oid.store_factory())
openid_response = consu... | [
"def",
"oid_login_handler",
"(",
"self",
",",
"f",
",",
"oid",
")",
":",
"if",
"request",
".",
"args",
".",
"get",
"(",
"\"openid_complete\"",
")",
"!=",
"u\"yes\"",
":",
"return",
"f",
"(",
"False",
")",
"consumer",
"=",
"Consumer",
"(",
"SessionWrapper... | Hackish method to make use of oid.login_handler decorator. | [
"Hackish",
"method",
"to",
"make",
"use",
"of",
"oid",
".",
"login_handler",
"decorator",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/registerviews.py#L233-L249 | train | This method is used to make use of oid. login_handler decorator. It is used to make use of oid. login_handler decorator. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/fields.py | AJAXSelectField.process_data | def process_data(self, value):
"""
Process the Python data applied to this field and store the result.
This will be called during form construction by the form's `kwargs` or
`obj` argument.
Converting ORM object to primary key for client form.
:param value: The python o... | python | def process_data(self, value):
"""
Process the Python data applied to this field and store the result.
This will be called during form construction by the form's `kwargs` or
`obj` argument.
Converting ORM object to primary key for client form.
:param value: The python o... | [
"def",
"process_data",
"(",
"self",
",",
"value",
")",
":",
"if",
"value",
":",
"if",
"self",
".",
"is_related",
":",
"self",
".",
"data",
"=",
"self",
".",
"datamodel",
".",
"get_related_interface",
"(",
"self",
".",
"col_name",
")",
".",
"get_pk_value"... | Process the Python data applied to this field and store the result.
This will be called during form construction by the form's `kwargs` or
`obj` argument.
Converting ORM object to primary key for client form.
:param value: The python object containing the value to process. | [
"Process",
"the",
"Python",
"data",
"applied",
"to",
"this",
"field",
"and",
"store",
"the",
"result",
".",
"This",
"will",
"be",
"called",
"during",
"form",
"construction",
"by",
"the",
"form",
"s",
"kwargs",
"or",
"obj",
"argument",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/fields.py#L40-L58 | train | Process the Python data applied to this field and store the result in the object attribute. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/fields.py | AJAXSelectField.process_formdata | def process_formdata(self, valuelist):
"""
Process data received over the wire from a form.
This will be called during form construction with data supplied
through the `formdata` argument.
Converting primary key to ORM for server processing.
:param valuelist: A list of ... | python | def process_formdata(self, valuelist):
"""
Process data received over the wire from a form.
This will be called during form construction with data supplied
through the `formdata` argument.
Converting primary key to ORM for server processing.
:param valuelist: A list of ... | [
"def",
"process_formdata",
"(",
"self",
",",
"valuelist",
")",
":",
"if",
"valuelist",
":",
"if",
"self",
".",
"is_related",
":",
"self",
".",
"data",
"=",
"self",
".",
"datamodel",
".",
"get_related_interface",
"(",
"self",
".",
"col_name",
")",
".",
"g... | Process data received over the wire from a form.
This will be called during form construction with data supplied
through the `formdata` argument.
Converting primary key to ORM for server processing.
:param valuelist: A list of strings to process. | [
"Process",
"data",
"received",
"over",
"the",
"wire",
"from",
"a",
"form",
".",
"This",
"will",
"be",
"called",
"during",
"form",
"construction",
"with",
"data",
"supplied",
"through",
"the",
"formdata",
"argument",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/fields.py#L60-L76 | train | Process data received over the wire from a form. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/charts/views.py | GroupByChartView.get_group_by_class | def get_group_by_class(self, definition):
"""
intantiates the processing class (Direct or Grouped) and returns it.
"""
group_by = definition["group"]
series = definition["series"]
if "formatter" in definition:
formatter = {group_by: definition["formatter"]... | python | def get_group_by_class(self, definition):
"""
intantiates the processing class (Direct or Grouped) and returns it.
"""
group_by = definition["group"]
series = definition["series"]
if "formatter" in definition:
formatter = {group_by: definition["formatter"]... | [
"def",
"get_group_by_class",
"(",
"self",
",",
"definition",
")",
":",
"group_by",
"=",
"definition",
"[",
"\"group\"",
"]",
"series",
"=",
"definition",
"[",
"\"series\"",
"]",
"if",
"\"formatter\"",
"in",
"definition",
":",
"formatter",
"=",
"{",
"group_by",... | intantiates the processing class (Direct or Grouped) and returns it. | [
"intantiates",
"the",
"processing",
"class",
"(",
"Direct",
"or",
"Grouped",
")",
"and",
"returns",
"it",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/charts/views.py#L140-L150 | train | Returns the processing class that is a direct or grouped object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/urltools.py | get_page_args | def get_page_args():
"""
Get page arguments, returns a dictionary
{ <VIEW_NAME>: PAGE_NUMBER }
Arguments are passed: page_<VIEW_NAME>=<PAGE_NUMBER>
"""
pages = {}
for arg in request.args:
re_match = re.findall("page_(.*)", arg)
if re_match:
pages[re_... | python | def get_page_args():
"""
Get page arguments, returns a dictionary
{ <VIEW_NAME>: PAGE_NUMBER }
Arguments are passed: page_<VIEW_NAME>=<PAGE_NUMBER>
"""
pages = {}
for arg in request.args:
re_match = re.findall("page_(.*)", arg)
if re_match:
pages[re_... | [
"def",
"get_page_args",
"(",
")",
":",
"pages",
"=",
"{",
"}",
"for",
"arg",
"in",
"request",
".",
"args",
":",
"re_match",
"=",
"re",
".",
"findall",
"(",
"\"page_(.*)\"",
",",
"arg",
")",
"if",
"re_match",
":",
"pages",
"[",
"re_match",
"[",
"0",
... | Get page arguments, returns a dictionary
{ <VIEW_NAME>: PAGE_NUMBER }
Arguments are passed: page_<VIEW_NAME>=<PAGE_NUMBER> | [
"Get",
"page",
"arguments",
"returns",
"a",
"dictionary",
"{",
"<VIEW_NAME",
">",
":",
"PAGE_NUMBER",
"}"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/urltools.py#L44-L57 | train | Get page arguments returns a dictionary containing the page number of the current page. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/urltools.py | get_page_size_args | def get_page_size_args():
"""
Get page size arguments, returns an int
{ <VIEW_NAME>: PAGE_NUMBER }
Arguments are passed: psize_<VIEW_NAME>=<PAGE_SIZE>
"""
page_sizes = {}
for arg in request.args:
re_match = re.findall("psize_(.*)", arg)
if re_match:
... | python | def get_page_size_args():
"""
Get page size arguments, returns an int
{ <VIEW_NAME>: PAGE_NUMBER }
Arguments are passed: psize_<VIEW_NAME>=<PAGE_SIZE>
"""
page_sizes = {}
for arg in request.args:
re_match = re.findall("psize_(.*)", arg)
if re_match:
... | [
"def",
"get_page_size_args",
"(",
")",
":",
"page_sizes",
"=",
"{",
"}",
"for",
"arg",
"in",
"request",
".",
"args",
":",
"re_match",
"=",
"re",
".",
"findall",
"(",
"\"psize_(.*)\"",
",",
"arg",
")",
"if",
"re_match",
":",
"page_sizes",
"[",
"re_match",... | Get page size arguments, returns an int
{ <VIEW_NAME>: PAGE_NUMBER }
Arguments are passed: psize_<VIEW_NAME>=<PAGE_SIZE> | [
"Get",
"page",
"size",
"arguments",
"returns",
"an",
"int",
"{",
"<VIEW_NAME",
">",
":",
"PAGE_NUMBER",
"}"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/urltools.py#L60-L73 | train | Get page size arguments returns an int
racket | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/urltools.py | get_order_args | def get_order_args():
"""
Get order arguments, return a dictionary
{ <VIEW_NAME>: (ORDER_COL, ORDER_DIRECTION) }
Arguments are passed like: _oc_<VIEW_NAME>=<COL_NAME>&_od_<VIEW_NAME>='asc'|'desc'
"""
orders = {}
for arg in request.args:
re_match = re.findall("_oc_(.*)",... | python | def get_order_args():
"""
Get order arguments, return a dictionary
{ <VIEW_NAME>: (ORDER_COL, ORDER_DIRECTION) }
Arguments are passed like: _oc_<VIEW_NAME>=<COL_NAME>&_od_<VIEW_NAME>='asc'|'desc'
"""
orders = {}
for arg in request.args:
re_match = re.findall("_oc_(.*)",... | [
"def",
"get_order_args",
"(",
")",
":",
"orders",
"=",
"{",
"}",
"for",
"arg",
"in",
"request",
".",
"args",
":",
"re_match",
"=",
"re",
".",
"findall",
"(",
"\"_oc_(.*)\"",
",",
"arg",
")",
"if",
"re_match",
":",
"order_direction",
"=",
"request",
"."... | Get order arguments, return a dictionary
{ <VIEW_NAME>: (ORDER_COL, ORDER_DIRECTION) }
Arguments are passed like: _oc_<VIEW_NAME>=<COL_NAME>&_od_<VIEW_NAME>='asc'|'desc' | [
"Get",
"order",
"arguments",
"return",
"a",
"dictionary",
"{",
"<VIEW_NAME",
">",
":",
"(",
"ORDER_COL",
"ORDER_DIRECTION",
")",
"}"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/urltools.py#L76-L91 | train | Get order arguments from request. args | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/api/convert.py | Model2SchemaConverter._meta_schema_factory | def _meta_schema_factory(self, columns, model, class_mixin):
"""
Creates ModelSchema marshmallow-sqlalchemy
:param columns: a list of columns to mix
:param model: Model
:param class_mixin: a marshamallow Schema to mix
:return: ModelSchema
"""
_model =... | python | def _meta_schema_factory(self, columns, model, class_mixin):
"""
Creates ModelSchema marshmallow-sqlalchemy
:param columns: a list of columns to mix
:param model: Model
:param class_mixin: a marshamallow Schema to mix
:return: ModelSchema
"""
_model =... | [
"def",
"_meta_schema_factory",
"(",
"self",
",",
"columns",
",",
"model",
",",
"class_mixin",
")",
":",
"_model",
"=",
"model",
"if",
"columns",
":",
"class",
"MetaSchema",
"(",
"ModelSchema",
",",
"class_mixin",
")",
":",
"class",
"Meta",
":",
"model",
"=... | Creates ModelSchema marshmallow-sqlalchemy
:param columns: a list of columns to mix
:param model: Model
:param class_mixin: a marshamallow Schema to mix
:return: ModelSchema | [
"Creates",
"ModelSchema",
"marshmallow",
"-",
"sqlalchemy"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/convert.py#L87-L110 | train | Creates a MetaSchema class for the given model and class_mixin. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/api/convert.py | Model2SchemaConverter.convert | def convert(self, columns, model=None, nested=True, enum_dump_by_name=False):
"""
Creates a Marshmallow ModelSchema class
:param columns: List with columns to include, if empty converts all on model
:param model: Override Model to convert
:param nested: Generate relation wi... | python | def convert(self, columns, model=None, nested=True, enum_dump_by_name=False):
"""
Creates a Marshmallow ModelSchema class
:param columns: List with columns to include, if empty converts all on model
:param model: Override Model to convert
:param nested: Generate relation wi... | [
"def",
"convert",
"(",
"self",
",",
"columns",
",",
"model",
"=",
"None",
",",
"nested",
"=",
"True",
",",
"enum_dump_by_name",
"=",
"False",
")",
":",
"super",
"(",
"Model2SchemaConverter",
",",
"self",
")",
".",
"convert",
"(",
"columns",
",",
"model",... | Creates a Marshmallow ModelSchema class
:param columns: List with columns to include, if empty converts all on model
:param model: Override Model to convert
:param nested: Generate relation with nested schemas
:return: ModelSchema object | [
"Creates",
"a",
"Marshmallow",
"ModelSchema",
"class"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/api/convert.py#L187-L224 | train | Convert a list of columns into a Marshmallow ModelSchema. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/decorators.py | protect | def protect(allow_browser_login=False):
"""
Use this decorator to enable granular security permissions
to your API methods (BaseApi and child classes).
Permissions will be associated to a role, and roles are associated to users.
allow_browser_login will accept signed cookies obtaine... | python | def protect(allow_browser_login=False):
"""
Use this decorator to enable granular security permissions
to your API methods (BaseApi and child classes).
Permissions will be associated to a role, and roles are associated to users.
allow_browser_login will accept signed cookies obtaine... | [
"def",
"protect",
"(",
"allow_browser_login",
"=",
"False",
")",
":",
"def",
"_protect",
"(",
"f",
")",
":",
"if",
"hasattr",
"(",
"f",
",",
"'_permission_name'",
")",
":",
"permission_str",
"=",
"f",
".",
"_permission_name",
"else",
":",
"permission_str",
... | Use this decorator to enable granular security permissions
to your API methods (BaseApi and child classes).
Permissions will be associated to a role, and roles are associated to users.
allow_browser_login will accept signed cookies obtained from the normal MVC app::
class MyApi(Bas... | [
"Use",
"this",
"decorator",
"to",
"enable",
"granular",
"security",
"permissions",
"to",
"your",
"API",
"methods",
"(",
"BaseApi",
"and",
"child",
"classes",
")",
".",
"Permissions",
"will",
"be",
"associated",
"to",
"a",
"role",
"and",
"roles",
"are",
"asso... | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/decorators.py#L25-L85 | train | Decorator to protect the user s API methods. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/decorators.py | has_access | def has_access(f):
"""
Use this decorator to enable granular security permissions to your methods.
Permissions will be associated to a role, and roles are associated to users.
By default the permission's name is the methods name.
"""
if hasattr(f, '_permission_name'):
permis... | python | def has_access(f):
"""
Use this decorator to enable granular security permissions to your methods.
Permissions will be associated to a role, and roles are associated to users.
By default the permission's name is the methods name.
"""
if hasattr(f, '_permission_name'):
permis... | [
"def",
"has_access",
"(",
"f",
")",
":",
"if",
"hasattr",
"(",
"f",
",",
"'_permission_name'",
")",
":",
"permission_str",
"=",
"f",
".",
"_permission_name",
"else",
":",
"permission_str",
"=",
"f",
".",
"__name__",
"def",
"wraps",
"(",
"self",
",",
"*",... | Use this decorator to enable granular security permissions to your methods.
Permissions will be associated to a role, and roles are associated to users.
By default the permission's name is the methods name. | [
"Use",
"this",
"decorator",
"to",
"enable",
"granular",
"security",
"permissions",
"to",
"your",
"methods",
".",
"Permissions",
"will",
"be",
"associated",
"to",
"a",
"role",
"and",
"roles",
"are",
"associated",
"to",
"users",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/decorators.py#L88-L122 | train | Decorator to enable granular security permissions to your methods. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/decorators.py | has_access_api | def has_access_api(f):
"""
Use this decorator to enable granular security permissions to your API methods.
Permissions will be associated to a role, and roles are associated to users.
By default the permission's name is the methods name.
this will return a message and HTTP 401 is c... | python | def has_access_api(f):
"""
Use this decorator to enable granular security permissions to your API methods.
Permissions will be associated to a role, and roles are associated to users.
By default the permission's name is the methods name.
this will return a message and HTTP 401 is c... | [
"def",
"has_access_api",
"(",
"f",
")",
":",
"if",
"hasattr",
"(",
"f",
",",
"'_permission_name'",
")",
":",
"permission_str",
"=",
"f",
".",
"_permission_name",
"else",
":",
"permission_str",
"=",
"f",
".",
"__name__",
"def",
"wraps",
"(",
"self",
",",
... | Use this decorator to enable granular security permissions to your API methods.
Permissions will be associated to a role, and roles are associated to users.
By default the permission's name is the methods name.
this will return a message and HTTP 401 is case of unauthorized access. | [
"Use",
"this",
"decorator",
"to",
"enable",
"granular",
"security",
"permissions",
"to",
"your",
"API",
"methods",
".",
"Permissions",
"will",
"be",
"associated",
"to",
"a",
"role",
"and",
"roles",
"are",
"associated",
"to",
"users",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/decorators.py#L125-L165 | train | Decorator to enable granular security permissions to your API methods. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/actions.py | action | def action(name, text, confirmation=None, icon=None, multiple=True, single=True):
"""
Use this decorator to expose actions
:param name:
Action name
:param text:
Action text.
:param confirmation:
Confirmation text. If not provided, action will be e... | python | def action(name, text, confirmation=None, icon=None, multiple=True, single=True):
"""
Use this decorator to expose actions
:param name:
Action name
:param text:
Action text.
:param confirmation:
Confirmation text. If not provided, action will be e... | [
"def",
"action",
"(",
"name",
",",
"text",
",",
"confirmation",
"=",
"None",
",",
"icon",
"=",
"None",
",",
"multiple",
"=",
"True",
",",
"single",
"=",
"True",
")",
":",
"def",
"wrap",
"(",
"f",
")",
":",
"f",
".",
"_action",
"=",
"(",
"name",
... | Use this decorator to expose actions
:param name:
Action name
:param text:
Action text.
:param confirmation:
Confirmation text. If not provided, action will be executed
unconditionally.
:param icon:
Font Awesome icon name
... | [
"Use",
"this",
"decorator",
"to",
"expose",
"actions"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/actions.py#L27-L50 | train | Decorator to expose an action to a list or show view. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | _oauth_tokengetter | def _oauth_tokengetter(token=None):
"""
Default function to return the current user oauth token
from session cookie.
"""
token = session.get("oauth")
log.debug("Token Get: {0}".format(token))
return token | python | def _oauth_tokengetter(token=None):
"""
Default function to return the current user oauth token
from session cookie.
"""
token = session.get("oauth")
log.debug("Token Get: {0}".format(token))
return token | [
"def",
"_oauth_tokengetter",
"(",
"token",
"=",
"None",
")",
":",
"token",
"=",
"session",
".",
"get",
"(",
"\"oauth\"",
")",
"log",
".",
"debug",
"(",
"\"Token Get: {0}\"",
".",
"format",
"(",
"token",
")",
")",
"return",
"token"
] | Default function to return the current user oauth token
from session cookie. | [
"Default",
"function",
"to",
"return",
"the",
"current",
"user",
"oauth",
"token",
"from",
"session",
"cookie",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L113-L120 | train | Default function to return the current user oauth token from session cookie. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.create_login_manager | def create_login_manager(self, app) -> LoginManager:
"""
Override to implement your custom login manager instance
:param app: Flask app
"""
lm = LoginManager(app)
lm.login_view = "login"
lm.user_loader(self.load_user)
return lm | python | def create_login_manager(self, app) -> LoginManager:
"""
Override to implement your custom login manager instance
:param app: Flask app
"""
lm = LoginManager(app)
lm.login_view = "login"
lm.user_loader(self.load_user)
return lm | [
"def",
"create_login_manager",
"(",
"self",
",",
"app",
")",
"->",
"LoginManager",
":",
"lm",
"=",
"LoginManager",
"(",
"app",
")",
"lm",
".",
"login_view",
"=",
"\"login\"",
"lm",
".",
"user_loader",
"(",
"self",
".",
"load_user",
")",
"return",
"lm"
] | Override to implement your custom login manager instance
:param app: Flask app | [
"Override",
"to",
"implement",
"your",
"custom",
"login",
"manager",
"instance"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L271-L280 | train | Create a custom login manager instance. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.create_jwt_manager | def create_jwt_manager(self, app) -> JWTManager:
"""
Override to implement your custom JWT manager instance
:param app: Flask app
"""
jwt_manager = JWTManager()
jwt_manager.init_app(app)
jwt_manager.user_loader_callback_loader(self.load_user)
retu... | python | def create_jwt_manager(self, app) -> JWTManager:
"""
Override to implement your custom JWT manager instance
:param app: Flask app
"""
jwt_manager = JWTManager()
jwt_manager.init_app(app)
jwt_manager.user_loader_callback_loader(self.load_user)
retu... | [
"def",
"create_jwt_manager",
"(",
"self",
",",
"app",
")",
"->",
"JWTManager",
":",
"jwt_manager",
"=",
"JWTManager",
"(",
")",
"jwt_manager",
".",
"init_app",
"(",
"app",
")",
"jwt_manager",
".",
"user_loader_callback_loader",
"(",
"self",
".",
"load_user",
"... | Override to implement your custom JWT manager instance
:param app: Flask app | [
"Override",
"to",
"implement",
"your",
"custom",
"JWT",
"manager",
"instance"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L282-L291 | train | Create a custom JWT manager instance. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.oauth_user_info_getter | def oauth_user_info_getter(self, f):
"""
Decorator function to be the OAuth user info getter
for all the providers, receives provider and response
return a dict with the information returned from the provider.
The returned user info dict should have it's keys with... | python | def oauth_user_info_getter(self, f):
"""
Decorator function to be the OAuth user info getter
for all the providers, receives provider and response
return a dict with the information returned from the provider.
The returned user info dict should have it's keys with... | [
"def",
"oauth_user_info_getter",
"(",
"self",
",",
"f",
")",
":",
"def",
"wraps",
"(",
"provider",
",",
"response",
"=",
"None",
")",
":",
"ret",
"=",
"f",
"(",
"self",
",",
"provider",
",",
"response",
"=",
"response",
")",
"# Checks if decorator is well ... | Decorator function to be the OAuth user info getter
for all the providers, receives provider and response
return a dict with the information returned from the provider.
The returned user info dict should have it's keys with the same
name as the User Model.
Us... | [
"Decorator",
"function",
"to",
"be",
"the",
"OAuth",
"user",
"info",
"getter",
"for",
"all",
"the",
"providers",
"receives",
"provider",
"and",
"response",
"return",
"a",
"dict",
"with",
"the",
"information",
"returned",
"from",
"the",
"provider",
".",
"The",
... | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L412-L445 | train | Decorator to be the OAuth user info getter for all the providers receives provider and response
return a dict with the information returned from the provider and response
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.get_oauth_token_key_name | def get_oauth_token_key_name(self, provider):
"""
Returns the token_key name for the oauth provider
if none is configured defaults to oauth_token
this is configured using OAUTH_PROVIDERS and token_key key.
"""
for _provider in self.oauth_providers:
... | python | def get_oauth_token_key_name(self, provider):
"""
Returns the token_key name for the oauth provider
if none is configured defaults to oauth_token
this is configured using OAUTH_PROVIDERS and token_key key.
"""
for _provider in self.oauth_providers:
... | [
"def",
"get_oauth_token_key_name",
"(",
"self",
",",
"provider",
")",
":",
"for",
"_provider",
"in",
"self",
".",
"oauth_providers",
":",
"if",
"_provider",
"[",
"\"name\"",
"]",
"==",
"provider",
":",
"return",
"_provider",
".",
"get",
"(",
"\"token_key\"",
... | Returns the token_key name for the oauth provider
if none is configured defaults to oauth_token
this is configured using OAUTH_PROVIDERS and token_key key. | [
"Returns",
"the",
"token_key",
"name",
"for",
"the",
"oauth",
"provider",
"if",
"none",
"is",
"configured",
"defaults",
"to",
"oauth_token",
"this",
"is",
"configured",
"using",
"OAUTH_PROVIDERS",
"and",
"token_key",
"key",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L447-L455 | train | Returns the token_key name for the oauth provider
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.get_oauth_token_secret_name | def get_oauth_token_secret_name(self, provider):
"""
Returns the token_secret name for the oauth provider
if none is configured defaults to oauth_secret
this is configured using OAUTH_PROVIDERS and token_secret
"""
for _provider in self.oauth_providers:
... | python | def get_oauth_token_secret_name(self, provider):
"""
Returns the token_secret name for the oauth provider
if none is configured defaults to oauth_secret
this is configured using OAUTH_PROVIDERS and token_secret
"""
for _provider in self.oauth_providers:
... | [
"def",
"get_oauth_token_secret_name",
"(",
"self",
",",
"provider",
")",
":",
"for",
"_provider",
"in",
"self",
".",
"oauth_providers",
":",
"if",
"_provider",
"[",
"\"name\"",
"]",
"==",
"provider",
":",
"return",
"_provider",
".",
"get",
"(",
"\"token_secret... | Returns the token_secret name for the oauth provider
if none is configured defaults to oauth_secret
this is configured using OAUTH_PROVIDERS and token_secret | [
"Returns",
"the",
"token_secret",
"name",
"for",
"the",
"oauth",
"provider",
"if",
"none",
"is",
"configured",
"defaults",
"to",
"oauth_secret",
"this",
"is",
"configured",
"using",
"OAUTH_PROVIDERS",
"and",
"token_secret"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L457-L465 | train | Returns the token_secret name for the oauth provider
defaults to oauth_secret
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.set_oauth_session | def set_oauth_session(self, provider, oauth_response):
"""
Set the current session with OAuth user secrets
"""
# Get this provider key names for token_key and token_secret
token_key = self.appbuilder.sm.get_oauth_token_key_name(provider)
token_secret = self.appbuilder... | python | def set_oauth_session(self, provider, oauth_response):
"""
Set the current session with OAuth user secrets
"""
# Get this provider key names for token_key and token_secret
token_key = self.appbuilder.sm.get_oauth_token_key_name(provider)
token_secret = self.appbuilder... | [
"def",
"set_oauth_session",
"(",
"self",
",",
"provider",
",",
"oauth_response",
")",
":",
"# Get this provider key names for token_key and token_secret",
"token_key",
"=",
"self",
".",
"appbuilder",
".",
"sm",
".",
"get_oauth_token_key_name",
"(",
"provider",
")",
"tok... | Set the current session with OAuth user secrets | [
"Set",
"the",
"current",
"session",
"with",
"OAuth",
"user",
"secrets"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L467-L479 | train | Set the current session with OAuth user secrets | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.get_oauth_user_info | def get_oauth_user_info(self, provider, resp):
"""
Since there are different OAuth API's with different ways to
retrieve user info
"""
# for GITHUB
if provider == "github" or provider == "githublocal":
me = self.appbuilder.sm.oauth_remotes[provider].ge... | python | def get_oauth_user_info(self, provider, resp):
"""
Since there are different OAuth API's with different ways to
retrieve user info
"""
# for GITHUB
if provider == "github" or provider == "githublocal":
me = self.appbuilder.sm.oauth_remotes[provider].ge... | [
"def",
"get_oauth_user_info",
"(",
"self",
",",
"provider",
",",
"resp",
")",
":",
"# for GITHUB",
"if",
"provider",
"==",
"\"github\"",
"or",
"provider",
"==",
"\"githublocal\"",
":",
"me",
"=",
"self",
".",
"appbuilder",
".",
"sm",
".",
"oauth_remotes",
"[... | Since there are different OAuth API's with different ways to
retrieve user info | [
"Since",
"there",
"are",
"different",
"OAuth",
"API",
"s",
"with",
"different",
"ways",
"to",
"retrieve",
"user",
"info"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L481-L538 | train | Retrieve user info from OAuth API | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.create_db | def create_db(self):
"""
Setups the DB, creates admin and public roles if they don't exist.
"""
self.add_role(self.auth_role_admin)
self.add_role(self.auth_role_public)
if self.count_users() == 0:
log.warning(LOGMSG_WAR_SEC_NO_USER) | python | def create_db(self):
"""
Setups the DB, creates admin and public roles if they don't exist.
"""
self.add_role(self.auth_role_admin)
self.add_role(self.auth_role_public)
if self.count_users() == 0:
log.warning(LOGMSG_WAR_SEC_NO_USER) | [
"def",
"create_db",
"(",
"self",
")",
":",
"self",
".",
"add_role",
"(",
"self",
".",
"auth_role_admin",
")",
"self",
".",
"add_role",
"(",
"self",
".",
"auth_role_public",
")",
"if",
"self",
".",
"count_users",
"(",
")",
"==",
"0",
":",
"log",
".",
... | Setups the DB, creates admin and public roles if they don't exist. | [
"Setups",
"the",
"DB",
"creates",
"admin",
"and",
"public",
"roles",
"if",
"they",
"don",
"t",
"exist",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L671-L678 | train | Creates the DB. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.reset_password | def reset_password(self, userid, password):
"""
Change/Reset a user's password for authdb.
Password will be hashed and saved.
:param userid:
the user.id to reset the password
:param password:
The clear text password to reset and sa... | python | def reset_password(self, userid, password):
"""
Change/Reset a user's password for authdb.
Password will be hashed and saved.
:param userid:
the user.id to reset the password
:param password:
The clear text password to reset and sa... | [
"def",
"reset_password",
"(",
"self",
",",
"userid",
",",
"password",
")",
":",
"user",
"=",
"self",
".",
"get_user_by_id",
"(",
"userid",
")",
"user",
".",
"password",
"=",
"generate_password_hash",
"(",
"password",
")",
"self",
".",
"update_user",
"(",
"... | Change/Reset a user's password for authdb.
Password will be hashed and saved.
:param userid:
the user.id to reset the password
:param password:
The clear text password to reset and save hashed on the db | [
"Change",
"/",
"Reset",
"a",
"user",
"s",
"password",
"for",
"authdb",
".",
"Password",
"will",
"be",
"hashed",
"and",
"saved",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L680-L692 | train | Change or reset a user s password for authdb. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.update_user_auth_stat | def update_user_auth_stat(self, user, success=True):
"""
Update authentication successful to user.
:param user:
The authenticated user model
:param success:
Default to true, if false increments fail_login_count on user model
"""
... | python | def update_user_auth_stat(self, user, success=True):
"""
Update authentication successful to user.
:param user:
The authenticated user model
:param success:
Default to true, if false increments fail_login_count on user model
"""
... | [
"def",
"update_user_auth_stat",
"(",
"self",
",",
"user",
",",
"success",
"=",
"True",
")",
":",
"if",
"not",
"user",
".",
"login_count",
":",
"user",
".",
"login_count",
"=",
"0",
"if",
"not",
"user",
".",
"fail_login_count",
":",
"user",
".",
"fail_log... | Update authentication successful to user.
:param user:
The authenticated user model
:param success:
Default to true, if false increments fail_login_count on user model | [
"Update",
"authentication",
"successful",
"to",
"user",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L694-L713 | train | Update the user authentication stat. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.auth_user_db | def auth_user_db(self, username, password):
"""
Method for authenticating user, auth db style
:param username:
The username or registered email address
:param password:
The password, will be tested against hashed password on db
"""
... | python | def auth_user_db(self, username, password):
"""
Method for authenticating user, auth db style
:param username:
The username or registered email address
:param password:
The password, will be tested against hashed password on db
"""
... | [
"def",
"auth_user_db",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"if",
"username",
"is",
"None",
"or",
"username",
"==",
"\"\"",
":",
"return",
"None",
"user",
"=",
"self",
".",
"find_user",
"(",
"username",
"=",
"username",
")",
"if",
"... | Method for authenticating user, auth db style
:param username:
The username or registered email address
:param password:
The password, will be tested against hashed password on db | [
"Method",
"for",
"authenticating",
"user",
"auth",
"db",
"style"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L715-L738 | train | Method for authenticating user on auth db style | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager._search_ldap | def _search_ldap(self, ldap, con, username):
"""
Searches LDAP for user, assumes ldap_search is set.
:param ldap: The ldap module reference
:param con: The ldap connection
:param username: username to match with auth_ldap_uid_field
:return: ldap objec... | python | def _search_ldap(self, ldap, con, username):
"""
Searches LDAP for user, assumes ldap_search is set.
:param ldap: The ldap module reference
:param con: The ldap connection
:param username: username to match with auth_ldap_uid_field
:return: ldap objec... | [
"def",
"_search_ldap",
"(",
"self",
",",
"ldap",
",",
"con",
",",
"username",
")",
":",
"if",
"self",
".",
"auth_ldap_append_domain",
":",
"username",
"=",
"username",
"+",
"\"@\"",
"+",
"self",
".",
"auth_ldap_append_domain",
"if",
"self",
".",
"auth_ldap_s... | Searches LDAP for user, assumes ldap_search is set.
:param ldap: The ldap module reference
:param con: The ldap connection
:param username: username to match with auth_ldap_uid_field
:return: ldap object array | [
"Searches",
"LDAP",
"for",
"user",
"assumes",
"ldap_search",
"is",
"set",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L740-L772 | train | Searches LDAP for user and returns user object | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager._bind_indirect_user | def _bind_indirect_user(self, ldap, con):
"""
If using AUTH_LDAP_BIND_USER bind this user before performing search
:param ldap: The ldap module reference
:param con: The ldap connection
"""
indirect_user = self.auth_ldap_bind_user
if indirect_user:
... | python | def _bind_indirect_user(self, ldap, con):
"""
If using AUTH_LDAP_BIND_USER bind this user before performing search
:param ldap: The ldap module reference
:param con: The ldap connection
"""
indirect_user = self.auth_ldap_bind_user
if indirect_user:
... | [
"def",
"_bind_indirect_user",
"(",
"self",
",",
"ldap",
",",
"con",
")",
":",
"indirect_user",
"=",
"self",
".",
"auth_ldap_bind_user",
"if",
"indirect_user",
":",
"indirect_password",
"=",
"self",
".",
"auth_ldap_bind_password",
"log",
".",
"debug",
"(",
"\"LDA... | If using AUTH_LDAP_BIND_USER bind this user before performing search
:param ldap: The ldap module reference
:param con: The ldap connection | [
"If",
"using",
"AUTH_LDAP_BIND_USER",
"bind",
"this",
"user",
"before",
"performing",
"search",
":",
"param",
"ldap",
":",
"The",
"ldap",
"module",
"reference",
":",
"param",
"con",
":",
"The",
"ldap",
"connection"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L774-L785 | train | Bind indirect user to the LDAP connection | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager._bind_ldap | def _bind_ldap(self, ldap, con, username, password):
"""
Private to bind/Authenticate a user.
If AUTH_LDAP_BIND_USER exists then it will bind first with it,
next will search the LDAP server using the username with UID
and try to bind to it (OpenLDAP).
... | python | def _bind_ldap(self, ldap, con, username, password):
"""
Private to bind/Authenticate a user.
If AUTH_LDAP_BIND_USER exists then it will bind first with it,
next will search the LDAP server using the username with UID
and try to bind to it (OpenLDAP).
... | [
"def",
"_bind_ldap",
"(",
"self",
",",
"ldap",
",",
"con",
",",
"username",
",",
"password",
")",
":",
"try",
":",
"if",
"self",
".",
"auth_ldap_bind_user",
":",
"self",
".",
"_bind_indirect_user",
"(",
"ldap",
",",
"con",
")",
"user",
"=",
"self",
"."... | Private to bind/Authenticate a user.
If AUTH_LDAP_BIND_USER exists then it will bind first with it,
next will search the LDAP server using the username with UID
and try to bind to it (OpenLDAP).
If AUTH_LDAP_BIND_USER does not exit, will bind with username/password | [
"Private",
"to",
"bind",
"/",
"Authenticate",
"a",
"user",
".",
"If",
"AUTH_LDAP_BIND_USER",
"exists",
"then",
"it",
"will",
"bind",
"first",
"with",
"it",
"next",
"will",
"search",
"the",
"LDAP",
"server",
"using",
"the",
"username",
"with",
"UID",
"and",
... | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L787-L814 | train | Private method to bind a user to LDAP server. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.auth_user_ldap | def auth_user_ldap(self, username, password):
"""
Method for authenticating user, auth LDAP style.
depends on ldap module that is not mandatory requirement
for F.A.B.
:param username:
The username
:param password:
The p... | python | def auth_user_ldap(self, username, password):
"""
Method for authenticating user, auth LDAP style.
depends on ldap module that is not mandatory requirement
for F.A.B.
:param username:
The username
:param password:
The p... | [
"def",
"auth_user_ldap",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"if",
"username",
"is",
"None",
"or",
"username",
"==",
"\"\"",
":",
"return",
"None",
"user",
"=",
"self",
".",
"find_user",
"(",
"username",
"=",
"username",
")",
"if",
... | Method for authenticating user, auth LDAP style.
depends on ldap module that is not mandatory requirement
for F.A.B.
:param username:
The username
:param password:
The password | [
"Method",
"for",
"authenticating",
"user",
"auth",
"LDAP",
"style",
".",
"depends",
"on",
"ldap",
"module",
"that",
"is",
"not",
"mandatory",
"requirement",
"for",
"F",
".",
"A",
".",
"B",
"."
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L822-L916 | train | Authenticates a user using LDAP | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.auth_user_oid | def auth_user_oid(self, email):
"""
OpenID user Authentication
:param email: user's email to authenticate
:type self: User model
"""
user = self.find_user(email=email)
if user is None or (not user.is_active):
log.info(LOGMSG_WAR_SEC_LOGIN_... | python | def auth_user_oid(self, email):
"""
OpenID user Authentication
:param email: user's email to authenticate
:type self: User model
"""
user = self.find_user(email=email)
if user is None or (not user.is_active):
log.info(LOGMSG_WAR_SEC_LOGIN_... | [
"def",
"auth_user_oid",
"(",
"self",
",",
"email",
")",
":",
"user",
"=",
"self",
".",
"find_user",
"(",
"email",
"=",
"email",
")",
"if",
"user",
"is",
"None",
"or",
"(",
"not",
"user",
".",
"is_active",
")",
":",
"log",
".",
"info",
"(",
"LOGMSG_... | OpenID user Authentication
:param email: user's email to authenticate
:type self: User model | [
"OpenID",
"user",
"Authentication"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L918-L931 | train | Authenticates a user by email | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.auth_user_remote_user | def auth_user_remote_user(self, username):
"""
REMOTE_USER user Authentication
:param username: user's username for remote auth
:type self: User model
"""
user = self.find_user(username=username)
# User does not exist, create one if auto user registr... | python | def auth_user_remote_user(self, username):
"""
REMOTE_USER user Authentication
:param username: user's username for remote auth
:type self: User model
"""
user = self.find_user(username=username)
# User does not exist, create one if auto user registr... | [
"def",
"auth_user_remote_user",
"(",
"self",
",",
"username",
")",
":",
"user",
"=",
"self",
".",
"find_user",
"(",
"username",
"=",
"username",
")",
"# User does not exist, create one if auto user registration.",
"if",
"user",
"is",
"None",
"and",
"self",
".",
"a... | REMOTE_USER user Authentication
:param username: user's username for remote auth
:type self: User model | [
"REMOTE_USER",
"user",
"Authentication"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L933-L961 | train | Authenticates a user on the DB. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.auth_user_oauth | def auth_user_oauth(self, userinfo):
"""
OAuth user Authentication
:userinfo: dict with user information the keys have the same name
as User model columns.
"""
if "username" in userinfo:
user = self.find_user(username=userinfo["username"])
... | python | def auth_user_oauth(self, userinfo):
"""
OAuth user Authentication
:userinfo: dict with user information the keys have the same name
as User model columns.
"""
if "username" in userinfo:
user = self.find_user(username=userinfo["username"])
... | [
"def",
"auth_user_oauth",
"(",
"self",
",",
"userinfo",
")",
":",
"if",
"\"username\"",
"in",
"userinfo",
":",
"user",
"=",
"self",
".",
"find_user",
"(",
"username",
"=",
"userinfo",
"[",
"\"username\"",
"]",
")",
"elif",
"\"email\"",
"in",
"userinfo",
":... | OAuth user Authentication
:userinfo: dict with user information the keys have the same name
as User model columns. | [
"OAuth",
"user",
"Authentication"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L963-L997 | train | Authenticates a user based on the user information. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dpgaspar/Flask-AppBuilder | flask_appbuilder/security/manager.py | BaseSecurityManager.is_item_public | def is_item_public(self, permission_name, view_name):
"""
Check if view has public permissions
:param permission_name:
the permission: can_show, can_edit...
:param view_name:
the name of the class view (child of BaseView)
"""
p... | python | def is_item_public(self, permission_name, view_name):
"""
Check if view has public permissions
:param permission_name:
the permission: can_show, can_edit...
:param view_name:
the name of the class view (child of BaseView)
"""
p... | [
"def",
"is_item_public",
"(",
"self",
",",
"permission_name",
",",
"view_name",
")",
":",
"permissions",
"=",
"self",
".",
"get_public_permissions",
"(",
")",
"if",
"permissions",
":",
"for",
"i",
"in",
"permissions",
":",
"if",
"(",
"view_name",
"==",
"i",
... | Check if view has public permissions
:param permission_name:
the permission: can_show, can_edit...
:param view_name:
the name of the class view (child of BaseView) | [
"Check",
"if",
"view",
"has",
"public",
"permissions"
] | c293734c1b86e176a3ba57ee2deab6676d125576 | https://github.com/dpgaspar/Flask-AppBuilder/blob/c293734c1b86e176a3ba57ee2deab6676d125576/flask_appbuilder/security/manager.py#L1005-L1023 | train | Check if the item is public | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.