text stringlengths 0 828 |
|---|
if mtime(cache_file) >= time.time() - gw2api.cache_time: |
with open(cache_file, ""r"") as fp: |
tmp = json.load(fp) |
return self.make_response(tmp[""data""], tmp[""meta""]) |
else: |
cache_file = None |
meta, data = self._get(path, **kwargs) |
if cache_file: |
with open(cache_file, ""w"") as fp: |
json.dump({""meta"": meta, ""data"": data}, fp, indent=2) |
return self.make_response(data, meta)" |
4069,"def main(): |
"""""" |
Loop over a list of input text strings. Parse each string using a list of |
parsers, one included in megaparsex and one defined in this script. If a |
confirmation is requested, seek confirmation, otherwise display any response |
text and engage any triggered functions. |
"""""" |
for text in [ |
""how are you"", |
""ip address"", |
""restart"", |
""run command"", |
""rain EGPF"", |
""reverse SSH"" |
]: |
print(""\nparse text: "" + text + ""\nWait 3 seconds, then parse."") |
time.sleep(3) |
response = megaparsex.multiparse( |
text = text, |
parsers = [ |
megaparsex.parse, |
parse_networking |
], |
help_message = ""Does not compute. I can report my IP address and I "" |
""can restart my script."" |
) |
if type(response) is megaparsex.confirmation: |
while response.confirmed() is None: |
response.test( |
text = megaparsex.get_input( |
prompt = response.prompt() + "" "" |
) |
) |
if response.confirmed(): |
print(response.feedback()) |
response.run() |
else: |
print(response.feedback()) |
elif type(response) is megaparsex.command: |
output = response.engage_command( |
command = megaparsex.get_input( |
prompt = response.prompt() + "" "" |
), |
background = False |
) |
if output: |
print(""output:\n{output}"".format(output = output)) |
else: |
print(response)" |
4070,"def get_packet_id(self, packet): |
"""""" |
Returns the ID of a protocol buffer packet. Returns None |
if no ID was found. |
"""""" |
for p in self._packets: |
if isinstance(packet, p['cls']): |
return p['id'] |
return None" |
4071,"def main(*args): |
"""""" Enter point. """""" |
args = args or sys.argv[1:] |
params = PARSER.parse_args(args) |
from .log import setup_logging |
setup_logging(params.level.upper()) |
from .core import Starter |
starter = Starter(params) |
if not starter.params.TEMPLATES or starter.params.list: |
setup_logging('WARN') |
for t in sorted(starter.iterate_templates()): |
logging.warn(""%s -- %s"", t.name, t.params.get( |
'description', 'no description')) |
return True |
try: |
starter.copy() |
except Exception as e: # noqa |
logging.error(e) |
sys.exit(1)" |
4072,"def summarize(df,preview_rows = 8, |
display_max_cols = None,display_width = None, |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.