content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
"""Take 2 strings s1 and s2 including only letters from ato z.
Return a new sorted string, the longest possible, containing distinct letters,
each taken only once - coming from s1 or s2.
=== Examples: ===
a = "xyaabbbccccdefww"
b = "xxxxyyyyabklmopq"
longest(a, b) -> "abcdefklmopqwxy"
a = "abcdefghijklmnopqrstuvwxyz"
longest(a, a) -> "abcdefghijklmnopqrstuvwxyz"
"""
def longest(s1: str, s2: str) -> str:
union_set = set(s1 + s2)
return ''.join(sorted(list(union_set)))
| """Take 2 strings s1 and s2 including only letters from ato z.
Return a new sorted string, the longest possible, containing distinct letters,
each taken only once - coming from s1 or s2.
=== Examples: ===
a = "xyaabbbccccdefww"
b = "xxxxyyyyabklmopq"
longest(a, b) -> "abcdefklmopqwxy"
a = "abcdefghijklmnopqrstuvwxyz"
longest(a, a) -> "abcdefghijklmnopqrstuvwxyz"
"""
def longest(s1: str, s2: str) -> str:
union_set = set(s1 + s2)
return ''.join(sorted(list(union_set))) |
def hrs2min(x): return x * 60
def min2sec(x): return x * 60
def SEC_TO_HR(x): return x / 3600.0
# Kelvin to Celcius
def check_range(value, min_val, max_val, descrip):
"""
Check the range of the value
Args:
value: value to check
min_val: minimum value
max_val: maximum value
descrip: short description of input
Returns:
True if within range
"""
if (value < min_val) or (value > max_val):
raise ValueError("%s (%f) out of range: %f to %f",
descrip, value, min_val, max_val)
return True
| def hrs2min(x):
return x * 60
def min2sec(x):
return x * 60
def sec_to_hr(x):
return x / 3600.0
def check_range(value, min_val, max_val, descrip):
"""
Check the range of the value
Args:
value: value to check
min_val: minimum value
max_val: maximum value
descrip: short description of input
Returns:
True if within range
"""
if value < min_val or value > max_val:
raise value_error('%s (%f) out of range: %f to %f', descrip, value, min_val, max_val)
return True |
def test():
a = {'foo': 'bar'}
print(a)
print(a['foo'])
b = {'x':'y'}
a.update(b)
print(a)
keys = a.keys()
print(keys)
vals = a.values()
print(vals)
test()
| def test():
a = {'foo': 'bar'}
print(a)
print(a['foo'])
b = {'x': 'y'}
a.update(b)
print(a)
keys = a.keys()
print(keys)
vals = a.values()
print(vals)
test() |
def process(s):
n = s.find(";")
if n > 0:
left = s[:n]+(" " * 64)
s = left[:34]+s[n:]
return s
f = open("revenge.asm")
code = f.readlines()
f.close()
code = [process(c.rstrip()) for c in code]
print("\n".join(code)) | def process(s):
n = s.find(';')
if n > 0:
left = s[:n] + ' ' * 64
s = left[:34] + s[n:]
return s
f = open('revenge.asm')
code = f.readlines()
f.close()
code = [process(c.rstrip()) for c in code]
print('\n'.join(code)) |
# Copyright (c) 2021 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
load("//bazel_tools:java.bzl", "da_java_library")
load("//bazel_tools:javadoc_library.bzl", "javadoc_library")
load("//bazel_tools:pkg.bzl", "pkg_empty_zip")
load("//bazel_tools:pom_file.bzl", "pom_file")
load("//bazel_tools:scala.bzl", "scala_source_jar", "scaladoc_jar")
load("@io_bazel_rules_scala//scala:scala.bzl", "scala_library")
load("@os_info//:os_info.bzl", "is_windows")
load("@rules_pkg//:pkg.bzl", "pkg_tar")
load("@rules_proto//proto:defs.bzl", "proto_library")
load("@scala_version//:index.bzl", "scala_major_version_suffix")
# taken from rules_proto:
# https://github.com/stackb/rules_proto/blob/f5d6eea6a4528bef3c1d3a44d486b51a214d61c2/compile.bzl#L369-L393
def get_plugin_runfiles(tool, plugin_runfiles):
"""Gather runfiles for a plugin.
"""
files = []
if not tool:
return files
info = tool[DefaultInfo]
if not info:
return files
if info.files:
files += info.files.to_list()
if info.default_runfiles:
runfiles = info.default_runfiles
if runfiles.files:
files += runfiles.files.to_list()
if info.data_runfiles:
runfiles = info.data_runfiles
if runfiles.files:
files += runfiles.files.to_list()
if plugin_runfiles:
for target in plugin_runfiles:
files += target.files.to_list()
return files
def _proto_gen_impl(ctx):
sources_out = ctx.actions.declare_directory(ctx.attr.name + "-sources")
descriptor_set_delim = "\\;" if _is_windows(ctx) else ":"
descriptors = [depset for src in ctx.attr.srcs for depset in src[ProtoInfo].transitive_descriptor_sets.to_list()]
args = [
"--descriptor_set_in=" + descriptor_set_delim.join([depset.path for depset in descriptors]),
"--{}_out={}:{}".format(ctx.attr.plugin_name, ",".join(ctx.attr.plugin_options), sources_out.path),
]
plugins = []
plugin_runfiles = []
if ctx.attr.plugin_name not in ["java", "python"]:
plugins = [ctx.executable.plugin_exec]
plugin_runfiles = get_plugin_runfiles(ctx.attr.plugin_exec, ctx.attr.plugin_runfiles)
args += [
"--plugin=protoc-gen-{}={}".format(ctx.attr.plugin_name, ctx.executable.plugin_exec.path),
]
inputs = []
for src in ctx.attr.srcs:
src_root = src[ProtoInfo].proto_source_root
for direct_source in src[ProtoInfo].direct_sources:
path = ""
# in some cases the paths of src_root and direct_source are only partially
# overlapping. the following for loop finds the maximum overlap of these two paths
for i in range(len(src_root) + 1):
if direct_source.path.startswith(src_root[-i:]):
path = direct_source.path[i:]
else:
# this noop is needed to make bazel happy
noop = ""
path = direct_source.short_path if not path else path
path = path[1:] if path.startswith("/") else path
inputs += [path]
args += inputs
posix = ctx.toolchains["@rules_sh//sh/posix:toolchain_type"]
ctx.actions.run_shell(
mnemonic = "ProtoGen",
outputs = [sources_out],
inputs = descriptors + [ctx.executable.protoc] + plugin_runfiles,
command = posix.commands["mkdir"] + " -p " + sources_out.path + " && " + ctx.executable.protoc.path + " " + " ".join(args),
tools = plugins,
)
# since we only have the output directory of the protoc compilation,
# we need to find all the files below sources_out and add them to the zipper args file
zipper_args_file = ctx.actions.declare_file(ctx.label.name + ".zipper_args")
ctx.actions.run_shell(
mnemonic = "CreateZipperArgsFile",
outputs = [zipper_args_file],
inputs = [sources_out],
command = "{find} -L {src_path} -type f | {sed} -E 's#^{src_path}/(.*)$#\\1={src_path}/\\1#' | {sort} > {args_file}".format(
find = posix.commands["find"],
sed = posix.commands["sed"],
sort = posix.commands["sort"],
src_path = sources_out.path,
args_file = zipper_args_file.path,
),
progress_message = "zipper_args_file %s" % zipper_args_file.path,
)
# Call zipper to create srcjar
zipper_args = ctx.actions.args()
zipper_args.add("c")
zipper_args.add(ctx.outputs.out.path)
zipper_args.add("@%s" % zipper_args_file.path)
ctx.actions.run(
executable = ctx.executable._zipper,
inputs = [sources_out, zipper_args_file],
outputs = [ctx.outputs.out],
arguments = [zipper_args],
progress_message = "srcjar %s" % ctx.outputs.out.short_path,
)
proto_gen = rule(
implementation = _proto_gen_impl,
attrs = {
"srcs": attr.label_list(providers = [ProtoInfo]),
"plugin_name": attr.string(),
"plugin_exec": attr.label(
cfg = "host",
executable = True,
),
"plugin_options": attr.string_list(),
"plugin_runfiles": attr.label_list(
default = [],
allow_files = True,
),
"protoc": attr.label(
default = Label("@com_google_protobuf//:protoc"),
cfg = "host",
allow_files = True,
executable = True,
),
"_zipper": attr.label(
default = Label("@bazel_tools//tools/zip:zipper"),
cfg = "host",
executable = True,
allow_files = True,
),
},
outputs = {
"out": "%{name}.srcjar",
},
output_to_genfiles = True,
toolchains = ["@rules_sh//sh/posix:toolchain_type"],
)
def _is_windows(ctx):
return ctx.configuration.host_path_separator == ";"
def _maven_tags(group, artifact_prefix, artifact_suffix):
if group and artifact_prefix:
artifact = artifact_prefix + "-" + artifact_suffix
return ["maven_coordinates=%s:%s:__VERSION__" % (group, artifact)]
else:
return []
def _proto_scala_srcs(name, grpc):
return [":%s" % name] + ([
"@com_github_googleapis_googleapis//google/rpc:code_proto",
"@com_github_googleapis_googleapis//google/rpc:status_proto",
"@com_github_grpc_grpc//src/proto/grpc/health/v1:health_proto_descriptor",
] if grpc else [])
def _proto_scala_deps(grpc, proto_deps):
return [
"@maven//:com_google_protobuf_protobuf_java",
"@maven//:com_thesamet_scalapb_lenses_{}".format(scala_major_version_suffix),
"@maven//:com_thesamet_scalapb_scalapb_runtime_{}".format(scala_major_version_suffix),
] + ([
"@maven//:com_thesamet_scalapb_scalapb_runtime_grpc_{}".format(scala_major_version_suffix),
"@maven//:io_grpc_grpc_api",
"@maven//:io_grpc_grpc_core",
"@maven//:io_grpc_grpc_protobuf",
"@maven//:io_grpc_grpc_stub",
] if grpc else []) + [
"%s_scala" % label
for label in proto_deps
]
def proto_jars(
name,
srcs,
visibility = None,
strip_import_prefix = "",
grpc = False,
deps = [],
proto_deps = [],
java_deps = [],
scala_deps = [],
javadoc_root_packages = [],
maven_group = None,
maven_artifact_prefix = None,
maven_artifact_proto_suffix = "proto",
maven_artifact_java_suffix = "java-proto",
maven_artifact_scala_suffix = "scala-proto"):
# Tarball containing the *.proto files.
pkg_tar(
name = "%s_tar" % name,
srcs = srcs,
extension = "tar.gz",
strip_prefix = strip_import_prefix,
visibility = [":__subpackages__", "//release:__subpackages__"],
)
# JAR and source JAR containing the *.proto files.
da_java_library(
name = "%s_jar" % name,
srcs = None,
deps = None,
runtime_deps = ["%s_jar" % label for label in proto_deps],
resources = srcs,
resource_strip_prefix = "%s/%s/" % (native.package_name(), strip_import_prefix),
tags = _maven_tags(maven_group, maven_artifact_prefix, maven_artifact_proto_suffix),
visibility = visibility,
)
# An empty Javadoc JAR for uploading the source proto JAR to Maven Central.
pkg_empty_zip(
name = "%s_jar_javadoc" % name,
out = "%s_jar_javadoc.jar" % name,
)
# Compiled protobufs.
proto_library(
name = name,
srcs = srcs,
strip_import_prefix = strip_import_prefix,
visibility = visibility,
deps = deps + proto_deps,
)
# JAR and source JAR containing the generated Java bindings.
native.java_proto_library(
name = "%s_java" % name,
tags = _maven_tags(maven_group, maven_artifact_prefix, maven_artifact_java_suffix),
visibility = visibility,
deps = [":%s" % name],
)
if maven_group and maven_artifact_prefix:
pom_file(
name = "%s_java_pom" % name,
tags = _maven_tags(maven_group, maven_artifact_prefix, maven_artifact_java_suffix),
target = ":%s_java" % name,
visibility = visibility,
)
if javadoc_root_packages:
javadoc_library(
name = "%s_java_javadoc" % name,
srcs = [":%s_java" % name],
root_packages = javadoc_root_packages,
deps = ["@maven//:com_google_protobuf_protobuf_java"],
) if not is_windows else None
else:
# An empty Javadoc JAR for uploading the compiled proto JAR to Maven Central.
pkg_empty_zip(
name = "%s_java_javadoc" % name,
out = "%s_java_javadoc.jar" % name,
)
# JAR containing the generated Scala bindings.
proto_gen(
name = "%s_scala_sources" % name,
srcs = _proto_scala_srcs(name, grpc),
plugin_exec = "//scala-protoc-plugins/scalapb:protoc-gen-scalapb",
plugin_name = "scalapb",
plugin_options = ["grpc"] if grpc else [],
)
all_scala_deps = _proto_scala_deps(grpc, proto_deps)
scala_library(
name = "%s_scala" % name,
srcs = [":%s_scala_sources" % name],
tags = _maven_tags(maven_group, maven_artifact_prefix, maven_artifact_scala_suffix),
unused_dependency_checker_mode = "error",
visibility = visibility,
deps = all_scala_deps,
exports = all_scala_deps,
)
scala_source_jar(
name = "%s_scala_src" % name,
srcs = [":%s_scala_sources" % name],
)
scaladoc_jar(
name = "%s_scala_scaladoc" % name,
srcs = [":%s_scala_sources" % name],
tags = ["scaladoc"],
deps = [],
) if is_windows == False else None
if maven_group and maven_artifact_prefix:
pom_file(
name = "%s_scala_pom" % name,
target = ":%s_scala" % name,
visibility = visibility,
)
| load('//bazel_tools:java.bzl', 'da_java_library')
load('//bazel_tools:javadoc_library.bzl', 'javadoc_library')
load('//bazel_tools:pkg.bzl', 'pkg_empty_zip')
load('//bazel_tools:pom_file.bzl', 'pom_file')
load('//bazel_tools:scala.bzl', 'scala_source_jar', 'scaladoc_jar')
load('@io_bazel_rules_scala//scala:scala.bzl', 'scala_library')
load('@os_info//:os_info.bzl', 'is_windows')
load('@rules_pkg//:pkg.bzl', 'pkg_tar')
load('@rules_proto//proto:defs.bzl', 'proto_library')
load('@scala_version//:index.bzl', 'scala_major_version_suffix')
def get_plugin_runfiles(tool, plugin_runfiles):
"""Gather runfiles for a plugin.
"""
files = []
if not tool:
return files
info = tool[DefaultInfo]
if not info:
return files
if info.files:
files += info.files.to_list()
if info.default_runfiles:
runfiles = info.default_runfiles
if runfiles.files:
files += runfiles.files.to_list()
if info.data_runfiles:
runfiles = info.data_runfiles
if runfiles.files:
files += runfiles.files.to_list()
if plugin_runfiles:
for target in plugin_runfiles:
files += target.files.to_list()
return files
def _proto_gen_impl(ctx):
sources_out = ctx.actions.declare_directory(ctx.attr.name + '-sources')
descriptor_set_delim = '\\;' if _is_windows(ctx) else ':'
descriptors = [depset for src in ctx.attr.srcs for depset in src[ProtoInfo].transitive_descriptor_sets.to_list()]
args = ['--descriptor_set_in=' + descriptor_set_delim.join([depset.path for depset in descriptors]), '--{}_out={}:{}'.format(ctx.attr.plugin_name, ','.join(ctx.attr.plugin_options), sources_out.path)]
plugins = []
plugin_runfiles = []
if ctx.attr.plugin_name not in ['java', 'python']:
plugins = [ctx.executable.plugin_exec]
plugin_runfiles = get_plugin_runfiles(ctx.attr.plugin_exec, ctx.attr.plugin_runfiles)
args += ['--plugin=protoc-gen-{}={}'.format(ctx.attr.plugin_name, ctx.executable.plugin_exec.path)]
inputs = []
for src in ctx.attr.srcs:
src_root = src[ProtoInfo].proto_source_root
for direct_source in src[ProtoInfo].direct_sources:
path = ''
for i in range(len(src_root) + 1):
if direct_source.path.startswith(src_root[-i:]):
path = direct_source.path[i:]
else:
noop = ''
path = direct_source.short_path if not path else path
path = path[1:] if path.startswith('/') else path
inputs += [path]
args += inputs
posix = ctx.toolchains['@rules_sh//sh/posix:toolchain_type']
ctx.actions.run_shell(mnemonic='ProtoGen', outputs=[sources_out], inputs=descriptors + [ctx.executable.protoc] + plugin_runfiles, command=posix.commands['mkdir'] + ' -p ' + sources_out.path + ' && ' + ctx.executable.protoc.path + ' ' + ' '.join(args), tools=plugins)
zipper_args_file = ctx.actions.declare_file(ctx.label.name + '.zipper_args')
ctx.actions.run_shell(mnemonic='CreateZipperArgsFile', outputs=[zipper_args_file], inputs=[sources_out], command="{find} -L {src_path} -type f | {sed} -E 's#^{src_path}/(.*)$#\\1={src_path}/\\1#' | {sort} > {args_file}".format(find=posix.commands['find'], sed=posix.commands['sed'], sort=posix.commands['sort'], src_path=sources_out.path, args_file=zipper_args_file.path), progress_message='zipper_args_file %s' % zipper_args_file.path)
zipper_args = ctx.actions.args()
zipper_args.add('c')
zipper_args.add(ctx.outputs.out.path)
zipper_args.add('@%s' % zipper_args_file.path)
ctx.actions.run(executable=ctx.executable._zipper, inputs=[sources_out, zipper_args_file], outputs=[ctx.outputs.out], arguments=[zipper_args], progress_message='srcjar %s' % ctx.outputs.out.short_path)
proto_gen = rule(implementation=_proto_gen_impl, attrs={'srcs': attr.label_list(providers=[ProtoInfo]), 'plugin_name': attr.string(), 'plugin_exec': attr.label(cfg='host', executable=True), 'plugin_options': attr.string_list(), 'plugin_runfiles': attr.label_list(default=[], allow_files=True), 'protoc': attr.label(default=label('@com_google_protobuf//:protoc'), cfg='host', allow_files=True, executable=True), '_zipper': attr.label(default=label('@bazel_tools//tools/zip:zipper'), cfg='host', executable=True, allow_files=True)}, outputs={'out': '%{name}.srcjar'}, output_to_genfiles=True, toolchains=['@rules_sh//sh/posix:toolchain_type'])
def _is_windows(ctx):
return ctx.configuration.host_path_separator == ';'
def _maven_tags(group, artifact_prefix, artifact_suffix):
if group and artifact_prefix:
artifact = artifact_prefix + '-' + artifact_suffix
return ['maven_coordinates=%s:%s:__VERSION__' % (group, artifact)]
else:
return []
def _proto_scala_srcs(name, grpc):
return [':%s' % name] + (['@com_github_googleapis_googleapis//google/rpc:code_proto', '@com_github_googleapis_googleapis//google/rpc:status_proto', '@com_github_grpc_grpc//src/proto/grpc/health/v1:health_proto_descriptor'] if grpc else [])
def _proto_scala_deps(grpc, proto_deps):
return ['@maven//:com_google_protobuf_protobuf_java', '@maven//:com_thesamet_scalapb_lenses_{}'.format(scala_major_version_suffix), '@maven//:com_thesamet_scalapb_scalapb_runtime_{}'.format(scala_major_version_suffix)] + (['@maven//:com_thesamet_scalapb_scalapb_runtime_grpc_{}'.format(scala_major_version_suffix), '@maven//:io_grpc_grpc_api', '@maven//:io_grpc_grpc_core', '@maven//:io_grpc_grpc_protobuf', '@maven//:io_grpc_grpc_stub'] if grpc else []) + ['%s_scala' % label for label in proto_deps]
def proto_jars(name, srcs, visibility=None, strip_import_prefix='', grpc=False, deps=[], proto_deps=[], java_deps=[], scala_deps=[], javadoc_root_packages=[], maven_group=None, maven_artifact_prefix=None, maven_artifact_proto_suffix='proto', maven_artifact_java_suffix='java-proto', maven_artifact_scala_suffix='scala-proto'):
pkg_tar(name='%s_tar' % name, srcs=srcs, extension='tar.gz', strip_prefix=strip_import_prefix, visibility=[':__subpackages__', '//release:__subpackages__'])
da_java_library(name='%s_jar' % name, srcs=None, deps=None, runtime_deps=['%s_jar' % label for label in proto_deps], resources=srcs, resource_strip_prefix='%s/%s/' % (native.package_name(), strip_import_prefix), tags=_maven_tags(maven_group, maven_artifact_prefix, maven_artifact_proto_suffix), visibility=visibility)
pkg_empty_zip(name='%s_jar_javadoc' % name, out='%s_jar_javadoc.jar' % name)
proto_library(name=name, srcs=srcs, strip_import_prefix=strip_import_prefix, visibility=visibility, deps=deps + proto_deps)
native.java_proto_library(name='%s_java' % name, tags=_maven_tags(maven_group, maven_artifact_prefix, maven_artifact_java_suffix), visibility=visibility, deps=[':%s' % name])
if maven_group and maven_artifact_prefix:
pom_file(name='%s_java_pom' % name, tags=_maven_tags(maven_group, maven_artifact_prefix, maven_artifact_java_suffix), target=':%s_java' % name, visibility=visibility)
if javadoc_root_packages:
javadoc_library(name='%s_java_javadoc' % name, srcs=[':%s_java' % name], root_packages=javadoc_root_packages, deps=['@maven//:com_google_protobuf_protobuf_java']) if not is_windows else None
else:
pkg_empty_zip(name='%s_java_javadoc' % name, out='%s_java_javadoc.jar' % name)
proto_gen(name='%s_scala_sources' % name, srcs=_proto_scala_srcs(name, grpc), plugin_exec='//scala-protoc-plugins/scalapb:protoc-gen-scalapb', plugin_name='scalapb', plugin_options=['grpc'] if grpc else [])
all_scala_deps = _proto_scala_deps(grpc, proto_deps)
scala_library(name='%s_scala' % name, srcs=[':%s_scala_sources' % name], tags=_maven_tags(maven_group, maven_artifact_prefix, maven_artifact_scala_suffix), unused_dependency_checker_mode='error', visibility=visibility, deps=all_scala_deps, exports=all_scala_deps)
scala_source_jar(name='%s_scala_src' % name, srcs=[':%s_scala_sources' % name])
scaladoc_jar(name='%s_scala_scaladoc' % name, srcs=[':%s_scala_sources' % name], tags=['scaladoc'], deps=[]) if is_windows == False else None
if maven_group and maven_artifact_prefix:
pom_file(name='%s_scala_pom' % name, target=':%s_scala' % name, visibility=visibility) |
def reindent(s, numSpaces):
leading_space = numSpaces * ' '
lines = [ leading_space + line.strip()
for line in s.splitlines() ]
return '\n'.join(lines)
| def reindent(s, numSpaces):
leading_space = numSpaces * ' '
lines = [leading_space + line.strip() for line in s.splitlines()]
return '\n'.join(lines) |
__author__ = "ricksy"
__email__ = "ricksy@mailbox.org"
__copyright__ = "(c) 2020 ricksy"
__version__ = "1.0.0"
__title__ = "py1"
__description__ = "have not idea"
__license__ = "MIT"
| __author__ = 'ricksy'
__email__ = 'ricksy@mailbox.org'
__copyright__ = '(c) 2020 ricksy'
__version__ = '1.0.0'
__title__ = 'py1'
__description__ = 'have not idea'
__license__ = 'MIT' |
initials = [
"b",
"c",
"ch",
"d",
"f",
"g",
"h",
"j",
"k",
"l",
"m",
"n",
"p",
"q",
"r",
"s",
"sh",
"t",
"w",
"x",
"y",
"z",
"zh",
]
finals = ['S', 'Sj', 'StS', 'StSj', 'Z', 'Zj', 'a', 'b', 'bj', 'd', 'dj', 'e', 'f', 'g', 'hrd', 'i', 'i2', 'j', 'jA', 'jE', 'jO', 'jU', 'k', 'l', 'lj', 'm', 'mj', 'n', 'nj', 'o', 'p', 'pj', 'r', 'rj', 's', 'sj', 't', 'tS', 'tSj', 'tj', 'ts', 'u', 'v', 'vj', 'x', 'z', 'zj']
valid_symbols = initials + finals + ["rr"]
| initials = ['b', 'c', 'ch', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 'sh', 't', 'w', 'x', 'y', 'z', 'zh']
finals = ['S', 'Sj', 'StS', 'StSj', 'Z', 'Zj', 'a', 'b', 'bj', 'd', 'dj', 'e', 'f', 'g', 'hrd', 'i', 'i2', 'j', 'jA', 'jE', 'jO', 'jU', 'k', 'l', 'lj', 'm', 'mj', 'n', 'nj', 'o', 'p', 'pj', 'r', 'rj', 's', 'sj', 't', 'tS', 'tSj', 'tj', 'ts', 'u', 'v', 'vj', 'x', 'z', 'zj']
valid_symbols = initials + finals + ['rr'] |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
class Student(object):
def __init__(self):
self.name = "Michael"
def __getattr__(self, attr):
if attr == "score":
return 99
if attr == "age":
return lambda: 25
raise AttributeError("'Student' object has no attribute '%s'" % attr)
s = Student()
print(s.name)
print(s.score)
print(s.age())
# AttributeError: 'Student' object has no attribute 'grade'
print(s.grade)
| class Student(object):
def __init__(self):
self.name = 'Michael'
def __getattr__(self, attr):
if attr == 'score':
return 99
if attr == 'age':
return lambda : 25
raise attribute_error("'Student' object has no attribute '%s'" % attr)
s = student()
print(s.name)
print(s.score)
print(s.age())
print(s.grade) |
while True:
try:
n = int(input())
app_list = input().strip().split()
tick_num = int(input())
tick_list = input().strip().split()
invalid = 0
tick_dict = {}
for app in app_list:
tick_dict[app] = 0
for tick in tick_list:
if tick in tick_dict:
tick_dict[tick] += 1
else:
invalid += 1
for app in app_list:
print(app+" : "+str(tick_dict[app]))
print("Invalid : "+str(invalid))
except:
break | while True:
try:
n = int(input())
app_list = input().strip().split()
tick_num = int(input())
tick_list = input().strip().split()
invalid = 0
tick_dict = {}
for app in app_list:
tick_dict[app] = 0
for tick in tick_list:
if tick in tick_dict:
tick_dict[tick] += 1
else:
invalid += 1
for app in app_list:
print(app + ' : ' + str(tick_dict[app]))
print('Invalid : ' + str(invalid))
except:
break |
"""
This file contains the implementation of a 'left-leaning'
Red Black Binary Search Tree (LLRBT). The implementation is based
on the one described in the book 'Algorithms Fourth Edition'
by Robert Sedgewick and Kevin Wayne.
A LLRBT is a Tree in which every Node have one of
two colors: red or black. The color of a Node represents
the color of the link between the Node and its parent.
Also, a LLRBT must satisfy the following conditions:
- Red links lean left (right red links are not allowed.)
- No node has two red links connected to it.
- The Tree has perfect black balance: every path from the
root to a null link has the same number of black links.
http://algs4.cs.princeton.edu/33balanced/
Here another good explanation of the algorithm:
http://www.teachsolaisgames.com/articles/balanced_left_leaning.html
"""
RED = True
BLACK = False
# Used to print trees in colors
TERM_RESET_COLOR = '\033[00m'
TERM_RED_COLOR = '\033[01;31m'
def is_red(node):
"""Return if `node` is red. None nodes considered black."""
return False if node is None else node.color == RED
def is_black(node):
"""Return if `node` is black. None nodes considered black."""
return True if node is None else node.color == BLACK
def _node_size(node):
"""Return the `node` size."""
size = 0
if node:
size += 1
if node.left:
size += node.left.size
if node.right:
size += node.right.size
return size
return size
class LLRBT(object):
class LLRBTNode(object):
def __init__(self, value):
self.value = value
self.size = 1
self.left = None
self.right = None
self.color = RED
def __str__(self):
def _print_value(node):
"""Return `node` value as a string. If the node is red,
the value is represented as red."""
if is_red(node):
return "{red_color}{value}{reset_color}".format(
red_color=TERM_RED_COLOR,
value=node.value,
reset_color=TERM_RESET_COLOR
)
else:
return str(node.value)
def _print(node, depth=0):
"""Recursively create a string representation of `node`. The
representation flows from left to right.
300
200
150
100
80
50
30
"""
ret = ""
if node.right:
ret += _print(node.right, depth + 1)
ret += "\n" + (" " * depth) + _print_value(node)
if node.left:
ret += _print(node.left, depth + 1)
return ret
return _print(self, 0)
def __init__(self, initialization_list=None):
"""Initialize the Tree and insert Nodes if an initialization list was given."""
self._root = None
self._size = 0
if initialization_list:
for v in initialization_list:
self.insert(v)
def __str__(self):
return self._root.__str__() if self._root else ""
def insert(self, value):
"""Return True if `value` was inserted, False otherwise.
On repeated values it doesn't do anything.
"""
def _insert(node):
if node is None:
return LLRBT.LLRBTNode(value), True
if node.value > value:
node.left, inserted = _insert(node.left)
elif node.value < value:
node.right, inserted = _insert(node.right)
else:
inserted = False
node = LLRBT._balance(node)
return node, inserted
self._root, inserted = _insert(self._root)
self._size = self._root.size
self._root.color = BLACK
return inserted
def remove(self, value):
"""Remove a Node which contains the value `value` and return True
if the value was found."""
def _remove(node):
# Continue the search on the left tree.
if node.value > value:
if node.left:
# If we have two consecutive black links on the left,
# we move one red node from the right to the left.
if is_black(node.left) and is_black(node.left.left):
node = LLRBT._move_red_left(node)
node.left, removed = _remove(node.left)
# In this case, the value is not present in the tree.
else:
removed = False
# Two things can happen here: the search must continue on the
# right branch or the value is present in the current node.
else:
# In any case, if the left child is red we should move it
# to the right. This will allow us to eventually delete
# a node from the right branch.
if is_red(node.left):
node = LLRBT._rotate_right(node)
# Node found. Delete it and return True.
if node.value == value and node.right is None:
return None, True
# At this point, the search continues on the right sub tree.
if node.right:
# If we have a right node on the left, we move it to
# the right.
if is_black(node.right) and is_black(node.right.left):
node = LLRBT._move_red_right(node)
# The value was found, so we need to replace that node
# with its successor.
if node.value == value:
successor, _ = LLRBT._min(node.right)
node.value = successor.value
node.right = LLRBT._remove_min(node.right)
removed = True
# The search continues on the right branch
else:
node.right, removed = _remove(node.right)
# The current node doesn't have the value we are looking for
# and the right branch is empty.
else:
removed = False
return LLRBT._balance(node), removed
if self._root:
self._root, removed = _remove(self._root)
self._size -= int(removed)
return removed
def remove_min(self):
"""Delete the smallest key from the tree and return True if succeeded.
Deleting a black node could break the tree invariant, so we need to
push down a red node until we get to the leaf node (the one to be deleted)."""
if self._root:
self._root = LLRBT._remove_min(self._root)
if self._root:
self._size = self._root.size
self._root.color = BLACK
return True
else:
return False
@staticmethod
def _remove_min(node):
"""Remove the smallest node of the tree rooted on `node`."""
# This is the smallest key -> delete it
if node.left is None:
return None
# Force left child to be red
if is_black(node.left) and is_black(node.left.left):
node = LLRBT._move_red_left(node)
node.left = LLRBT._remove_min(node.left)
# On the way up, fix right leaning trees and 4-nodes
return LLRBT._balance(node)
def remove_max(self):
def _remove_max(node):
# Make the left red node the root (move upwards the red)
if is_red(node.left):
node = LLRBT._rotate_right(node)
# This is the greatest key -> delete it
if node.right is None:
return None
if is_black(node.right) and node.right and is_black(node.right.left):
node = LLRBT._move_red_right(node)
node.right = _remove_max(node.right)
return LLRBT._balance(node)
if self._root:
self._root = _remove_max(self._root)
if self._root:
self._size = self._root.size
self._root.color = BLACK
return True
else:
return False
def contains(self, value):
"""Return True if `value` exists in the Tree."""
def _contains(node):
if node.value == value:
return True
if node.value > value and node.left:
return _contains(node.left)
if node.value < value and node.right:
return _contains(node.right)
return False
if self._root:
return _contains(self._root)
return False
def max(self):
"""Return the biggest value of the Tree."""
node = self._root
if node is None:
return None
while node.right:
node = node.right
return node.value
def min(self):
"""Return the smallest value of the Tree."""
min_node, found = LLRBT._min(self._root)
if found:
return min_node.value
else:
return None
@staticmethod
def _min(node):
"""Return the smallest node of the tree rooted on `node`. Return True
if there is a node, False otherwise."""
if node is None:
return None, False
while node.left:
node = node.left
return node, True
def floor(self, value):
"""Return the floor element of `value`."""
def _floor(node):
if node is None:
return None
if node.value == value:
return value
if node.value > value:
return _floor(node.left)
if node.value < value:
successor = _floor(node.right)
return node if successor is None else successor
return _floor(self._root)
def ceiling(self, value):
"""Return the ceiling element of `value`."""
def _ceiling(node):
if node is None:
return None
if node.value == value:
return value
if node.value < value:
return _ceiling(node.right)
if node.value > value:
ancestor = _ceiling(node.left)
return node if ancestor is None else ancestor
return _ceiling(self._root)
def select(self, rank):
"""Return the key/value of rank k such that precisely k other
keys in the BST are smaller than it."""
def _select(node, rank):
if node is None:
return None
if _node_size(node.left) == rank:
return node.value
if _node_size(node.left) > rank:
return _select(node.left, rank)
if _node_size(node.left) < rank:
return _select(node.right, rank - _node_size(node.left) - 1)
return _select(self._root, rank)
def rank(self, value):
"""Return the rank of `value` in the Tree."""
def _rank(node):
if node is None:
return 0
if node.value == value:
return _node_size(node.left)
if node.value > value:
return _rank(node.left)
if node.value < value:
return 1 + _node_size(node.left) + _rank(node.right)
return _rank(self._root)
def pre_order_traversal(self):
"""Return a generator to traverse the Tree in pre-order."""
def _pre_order_traversal(node):
if node is None:
return
yield node
yield from _pre_order_traversal(node.left)
yield from _pre_order_traversal(node.right)
yield from _pre_order_traversal(self._root)
def in_order_traversal(self):
"""Return a generator to traverse the Tree in in-order."""
def _in_order_traversal(node):
if node is None:
return
yield from _in_order_traversal(node.left)
yield node
yield from _in_order_traversal(node.right)
yield from _in_order_traversal(self._root)
def in_order_traversal_iterative(self):
def _in_order_traversal_iterative(node):
stack = []
while stack or node:
if node:
stack.append(node)
node = node.left
else:
node = stack.pop()
yield node
node = node.right
yield from _in_order_traversal_iterative(self._root)
def post_order_traversal(self):
"""Return a generator to traverse the Tree in post-order."""
def _post_order_traversal(node):
if node is None:
return
yield from _post_order_traversal(node.left)
yield from _post_order_traversal(node.right)
yield node
yield from _post_order_traversal(self._root)
@staticmethod
def _rotate_left(node):
"""Perform a left rotation. Fix a right red link."""
right_node = node.right
node.right = right_node.left
right_node.left = node
right_node.color = node.color
node.color = RED
right_node.size = node.size
node.size = _node_size(node)
return right_node
@staticmethod
def _rotate_right(node):
"""Perform a left rotation. Fix a double left red link."""
left_node = node.left
node.left = left_node.right
left_node.right = node
left_node.color = node.color
node.color = RED
left_node.size = node.size
node.size = _node_size(node)
return left_node
@staticmethod
def _flip_colors(node):
"""Flip colors of `node` and its children."""
node.color = not node.color
node.left.color = not node.left.color
node.right.color = not node.right.color
@staticmethod
def _move_red_left(node):
"""Move a red child from the right to the left sub tree."""
# Merge parent and children into a 4-node making their links red
LLRBT._flip_colors(node)
# Move red child from right branch to the left branch
if node.right and is_red(node.right.left):
node.right = LLRBT._rotate_right(node.right)
node = LLRBT._rotate_left(node)
LLRBT._flip_colors(node)
return node
@staticmethod
def _move_red_right(node):
# Merge parent and children into a 4-node making their links red
LLRBT._flip_colors(node)
if node.left and is_red(node.left.left):
node = LLRBT._rotate_right(node)
LLRBT._flip_colors(node)
return node
@staticmethod
def _balance(node):
"""Restore LLRBT invariant by applying rotations and flipping colors."""
# Fix a right leaning tree -> rotate left
if is_black(node.left) and is_red(node.right):
node = LLRBT._rotate_left(node)
# 4-node on the left -> rotate right and flip colors
if is_red(node.left) and is_red(node.left.left):
node = LLRBT._rotate_right(node)
# Split 4-node -> flip colors
if is_red(node.left) and is_red(node.right):
LLRBT._flip_colors(node)
node.size = _node_size(node)
return node
def check_integrity(self):
def _check_node_integrity(node):
if node is None:
return 1
# Check there is no two consecutive left red nodes
if is_red(node) and is_red(node.left):
raise IntegrityError("RED VIOLATION",
"Two consecutive left red nodes.",
node)
left_height = _check_node_integrity(node.left)
right_height = _check_node_integrity(node.right)
# Check if it's a valid binary search tree
if (node.left and node.left.value >= node.value) or \
(node.right and node.right.value <= node.value):
raise IntegrityError(
"BINARY SEARCH TREE VIOLATION",
"Left child is bigger than root or right child is smaller than root.",
node)
# Check black height of both children
if left_height != 0 and right_height != 0 and left_height != right_height:
raise IntegrityError("BLACK HEIGHT VIOLATION",
"Left and right subtree doesn't have the same black height.",
node)
# If node is black, add 1 to the height
if left_height != 0:
if is_red(node):
return left_height
else:
return left_height + 1
else:
return 0
return _check_node_integrity(self._root)
@property
def size(self):
"""Return the number of Nodes."""
return self._size
class IntegrityError(Exception):
"""Class to signal integrity errors."""
def __init__(self, invalidation_type, message, node):
self.invalidation_type = invalidation_type
self.message = message
self.node = node
if __name__ == "__main__":
initialization_list = ["S", "E", "A", "R", "C", "H", "X", "M", "P", "L"]
# initialization_list = range(20)
tree = LLRBT()
for value in initialization_list:
tree.insert(value)
print(TERM_RED_COLOR + "-> Last key inserted: " + value + TERM_RESET_COLOR)
print("------------------------------------")
print(tree)
print("\n")
tree.check_integrity()
| """
This file contains the implementation of a 'left-leaning'
Red Black Binary Search Tree (LLRBT). The implementation is based
on the one described in the book 'Algorithms Fourth Edition'
by Robert Sedgewick and Kevin Wayne.
A LLRBT is a Tree in which every Node have one of
two colors: red or black. The color of a Node represents
the color of the link between the Node and its parent.
Also, a LLRBT must satisfy the following conditions:
- Red links lean left (right red links are not allowed.)
- No node has two red links connected to it.
- The Tree has perfect black balance: every path from the
root to a null link has the same number of black links.
http://algs4.cs.princeton.edu/33balanced/
Here another good explanation of the algorithm:
http://www.teachsolaisgames.com/articles/balanced_left_leaning.html
"""
red = True
black = False
term_reset_color = '\x1b[00m'
term_red_color = '\x1b[01;31m'
def is_red(node):
"""Return if `node` is red. None nodes considered black."""
return False if node is None else node.color == RED
def is_black(node):
"""Return if `node` is black. None nodes considered black."""
return True if node is None else node.color == BLACK
def _node_size(node):
"""Return the `node` size."""
size = 0
if node:
size += 1
if node.left:
size += node.left.size
if node.right:
size += node.right.size
return size
return size
class Llrbt(object):
class Llrbtnode(object):
def __init__(self, value):
self.value = value
self.size = 1
self.left = None
self.right = None
self.color = RED
def __str__(self):
def _print_value(node):
"""Return `node` value as a string. If the node is red,
the value is represented as red."""
if is_red(node):
return '{red_color}{value}{reset_color}'.format(red_color=TERM_RED_COLOR, value=node.value, reset_color=TERM_RESET_COLOR)
else:
return str(node.value)
def _print(node, depth=0):
"""Recursively create a string representation of `node`. The
representation flows from left to right.
300
200
150
100
80
50
30
"""
ret = ''
if node.right:
ret += _print(node.right, depth + 1)
ret += '\n' + ' ' * depth + _print_value(node)
if node.left:
ret += _print(node.left, depth + 1)
return ret
return _print(self, 0)
def __init__(self, initialization_list=None):
"""Initialize the Tree and insert Nodes if an initialization list was given."""
self._root = None
self._size = 0
if initialization_list:
for v in initialization_list:
self.insert(v)
def __str__(self):
return self._root.__str__() if self._root else ''
def insert(self, value):
"""Return True if `value` was inserted, False otherwise.
On repeated values it doesn't do anything.
"""
def _insert(node):
if node is None:
return (LLRBT.LLRBTNode(value), True)
if node.value > value:
(node.left, inserted) = _insert(node.left)
elif node.value < value:
(node.right, inserted) = _insert(node.right)
else:
inserted = False
node = LLRBT._balance(node)
return (node, inserted)
(self._root, inserted) = _insert(self._root)
self._size = self._root.size
self._root.color = BLACK
return inserted
def remove(self, value):
"""Remove a Node which contains the value `value` and return True
if the value was found."""
def _remove(node):
if node.value > value:
if node.left:
if is_black(node.left) and is_black(node.left.left):
node = LLRBT._move_red_left(node)
(node.left, removed) = _remove(node.left)
else:
removed = False
else:
if is_red(node.left):
node = LLRBT._rotate_right(node)
if node.value == value and node.right is None:
return (None, True)
if node.right:
if is_black(node.right) and is_black(node.right.left):
node = LLRBT._move_red_right(node)
if node.value == value:
(successor, _) = LLRBT._min(node.right)
node.value = successor.value
node.right = LLRBT._remove_min(node.right)
removed = True
else:
(node.right, removed) = _remove(node.right)
else:
removed = False
return (LLRBT._balance(node), removed)
if self._root:
(self._root, removed) = _remove(self._root)
self._size -= int(removed)
return removed
def remove_min(self):
"""Delete the smallest key from the tree and return True if succeeded.
Deleting a black node could break the tree invariant, so we need to
push down a red node until we get to the leaf node (the one to be deleted)."""
if self._root:
self._root = LLRBT._remove_min(self._root)
if self._root:
self._size = self._root.size
self._root.color = BLACK
return True
else:
return False
@staticmethod
def _remove_min(node):
"""Remove the smallest node of the tree rooted on `node`."""
if node.left is None:
return None
if is_black(node.left) and is_black(node.left.left):
node = LLRBT._move_red_left(node)
node.left = LLRBT._remove_min(node.left)
return LLRBT._balance(node)
def remove_max(self):
def _remove_max(node):
if is_red(node.left):
node = LLRBT._rotate_right(node)
if node.right is None:
return None
if is_black(node.right) and node.right and is_black(node.right.left):
node = LLRBT._move_red_right(node)
node.right = _remove_max(node.right)
return LLRBT._balance(node)
if self._root:
self._root = _remove_max(self._root)
if self._root:
self._size = self._root.size
self._root.color = BLACK
return True
else:
return False
def contains(self, value):
"""Return True if `value` exists in the Tree."""
def _contains(node):
if node.value == value:
return True
if node.value > value and node.left:
return _contains(node.left)
if node.value < value and node.right:
return _contains(node.right)
return False
if self._root:
return _contains(self._root)
return False
def max(self):
"""Return the biggest value of the Tree."""
node = self._root
if node is None:
return None
while node.right:
node = node.right
return node.value
def min(self):
"""Return the smallest value of the Tree."""
(min_node, found) = LLRBT._min(self._root)
if found:
return min_node.value
else:
return None
@staticmethod
def _min(node):
"""Return the smallest node of the tree rooted on `node`. Return True
if there is a node, False otherwise."""
if node is None:
return (None, False)
while node.left:
node = node.left
return (node, True)
def floor(self, value):
"""Return the floor element of `value`."""
def _floor(node):
if node is None:
return None
if node.value == value:
return value
if node.value > value:
return _floor(node.left)
if node.value < value:
successor = _floor(node.right)
return node if successor is None else successor
return _floor(self._root)
def ceiling(self, value):
"""Return the ceiling element of `value`."""
def _ceiling(node):
if node is None:
return None
if node.value == value:
return value
if node.value < value:
return _ceiling(node.right)
if node.value > value:
ancestor = _ceiling(node.left)
return node if ancestor is None else ancestor
return _ceiling(self._root)
def select(self, rank):
"""Return the key/value of rank k such that precisely k other
keys in the BST are smaller than it."""
def _select(node, rank):
if node is None:
return None
if _node_size(node.left) == rank:
return node.value
if _node_size(node.left) > rank:
return _select(node.left, rank)
if _node_size(node.left) < rank:
return _select(node.right, rank - _node_size(node.left) - 1)
return _select(self._root, rank)
def rank(self, value):
"""Return the rank of `value` in the Tree."""
def _rank(node):
if node is None:
return 0
if node.value == value:
return _node_size(node.left)
if node.value > value:
return _rank(node.left)
if node.value < value:
return 1 + _node_size(node.left) + _rank(node.right)
return _rank(self._root)
def pre_order_traversal(self):
"""Return a generator to traverse the Tree in pre-order."""
def _pre_order_traversal(node):
if node is None:
return
yield node
yield from _pre_order_traversal(node.left)
yield from _pre_order_traversal(node.right)
yield from _pre_order_traversal(self._root)
def in_order_traversal(self):
"""Return a generator to traverse the Tree in in-order."""
def _in_order_traversal(node):
if node is None:
return
yield from _in_order_traversal(node.left)
yield node
yield from _in_order_traversal(node.right)
yield from _in_order_traversal(self._root)
def in_order_traversal_iterative(self):
def _in_order_traversal_iterative(node):
stack = []
while stack or node:
if node:
stack.append(node)
node = node.left
else:
node = stack.pop()
yield node
node = node.right
yield from _in_order_traversal_iterative(self._root)
def post_order_traversal(self):
"""Return a generator to traverse the Tree in post-order."""
def _post_order_traversal(node):
if node is None:
return
yield from _post_order_traversal(node.left)
yield from _post_order_traversal(node.right)
yield node
yield from _post_order_traversal(self._root)
@staticmethod
def _rotate_left(node):
"""Perform a left rotation. Fix a right red link."""
right_node = node.right
node.right = right_node.left
right_node.left = node
right_node.color = node.color
node.color = RED
right_node.size = node.size
node.size = _node_size(node)
return right_node
@staticmethod
def _rotate_right(node):
"""Perform a left rotation. Fix a double left red link."""
left_node = node.left
node.left = left_node.right
left_node.right = node
left_node.color = node.color
node.color = RED
left_node.size = node.size
node.size = _node_size(node)
return left_node
@staticmethod
def _flip_colors(node):
"""Flip colors of `node` and its children."""
node.color = not node.color
node.left.color = not node.left.color
node.right.color = not node.right.color
@staticmethod
def _move_red_left(node):
"""Move a red child from the right to the left sub tree."""
LLRBT._flip_colors(node)
if node.right and is_red(node.right.left):
node.right = LLRBT._rotate_right(node.right)
node = LLRBT._rotate_left(node)
LLRBT._flip_colors(node)
return node
@staticmethod
def _move_red_right(node):
LLRBT._flip_colors(node)
if node.left and is_red(node.left.left):
node = LLRBT._rotate_right(node)
LLRBT._flip_colors(node)
return node
@staticmethod
def _balance(node):
"""Restore LLRBT invariant by applying rotations and flipping colors."""
if is_black(node.left) and is_red(node.right):
node = LLRBT._rotate_left(node)
if is_red(node.left) and is_red(node.left.left):
node = LLRBT._rotate_right(node)
if is_red(node.left) and is_red(node.right):
LLRBT._flip_colors(node)
node.size = _node_size(node)
return node
def check_integrity(self):
def _check_node_integrity(node):
if node is None:
return 1
if is_red(node) and is_red(node.left):
raise integrity_error('RED VIOLATION', 'Two consecutive left red nodes.', node)
left_height = _check_node_integrity(node.left)
right_height = _check_node_integrity(node.right)
if node.left and node.left.value >= node.value or (node.right and node.right.value <= node.value):
raise integrity_error('BINARY SEARCH TREE VIOLATION', 'Left child is bigger than root or right child is smaller than root.', node)
if left_height != 0 and right_height != 0 and (left_height != right_height):
raise integrity_error('BLACK HEIGHT VIOLATION', "Left and right subtree doesn't have the same black height.", node)
if left_height != 0:
if is_red(node):
return left_height
else:
return left_height + 1
else:
return 0
return _check_node_integrity(self._root)
@property
def size(self):
"""Return the number of Nodes."""
return self._size
class Integrityerror(Exception):
"""Class to signal integrity errors."""
def __init__(self, invalidation_type, message, node):
self.invalidation_type = invalidation_type
self.message = message
self.node = node
if __name__ == '__main__':
initialization_list = ['S', 'E', 'A', 'R', 'C', 'H', 'X', 'M', 'P', 'L']
tree = llrbt()
for value in initialization_list:
tree.insert(value)
print(TERM_RED_COLOR + '-> Last key inserted: ' + value + TERM_RESET_COLOR)
print('------------------------------------')
print(tree)
print('\n')
tree.check_integrity() |
"""
Faster R-CNN with GIOU Assigner
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=1500 ] = 0.110
Average Precision (AP) @[ IoU=0.25 | area= all | maxDets=1500 ] = -1.000
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.265
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=1500 ] = 0.075
Average Precision (AP) @[ IoU=0.50:0.95 | area=verytiny | maxDets=1500 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area= tiny | maxDets=1500 ] = 0.077
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1500 ] = 0.227
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1500 ] = 0.331
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.169
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 ] = 0.174
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=1500 ] = 0.174
Average Recall (AR) @[ IoU=0.50:0.95 | area=verytiny | maxDets=1500 ] = 0.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= tiny | maxDets=1500 ] = 0.110
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1500 ] = 0.372
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1500 ] = 0.458
Optimal LRP @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.897
Optimal LRP Loc @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.290
Optimal LRP FP @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.438
Optimal LRP FN @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.717
# Class-specific LRP-Optimal Thresholds #
[0.76 0.446 0.603 0.588 0.713 0.445 0.511 nan]
+----------+-------+---------------+-------+--------------+-------+
| category | AP | category | AP | category | AP |
+----------+-------+---------------+-------+--------------+-------+
| airplane | 0.208 | bridge | 0.029 | storage-tank | 0.205 |
| ship | 0.195 | swimming-pool | 0.073 | vehicle | 0.127 |
| person | 0.044 | wind-mill | 0.000 | None | None |
+----------+-------+---------------+-------+--------------+-------+
+----------+-------+---------------+-------+--------------+-------+
| category | oLRP | category | oLRP | category | oLRP |
+----------+-------+---------------+-------+--------------+-------+
| airplane | 0.817 | bridge | 0.968 | storage-tank | 0.812 |
| ship | 0.827 | swimming-pool | 0.919 | vehicle | 0.879 |
| person | 0.954 | wind-mill | 1.000 | None | None |
+----------+-------+---------------+-------+--------------+-------+
"""
_base_ = [
'../_base_/models/faster_rcnn_r50_fpn_aitod.py',
'../_base_/datasets/aitod_detection.py',
'../_base_/schedules/schedule_1x.py',
'../_base_/default_runtime.py'
]
model = dict(
train_cfg=dict(
rpn=dict(
assigner=dict(
iou_calculator=dict(type='BboxOverlaps2D'),
assign_metric='iou')),
rcnn=dict(
assigner=dict(
iou_calculator=dict(type='BboxOverlaps2D'),
assign_metric='iou'))))
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
# learning policy
checkpoint_config = dict(interval=4)
| """
Faster R-CNN with GIOU Assigner
Average Precision (AP) @[ IoU=0.50:0.95 | area= all | maxDets=1500 ] = 0.110
Average Precision (AP) @[ IoU=0.25 | area= all | maxDets=1500 ] = -1.000
Average Precision (AP) @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.265
Average Precision (AP) @[ IoU=0.75 | area= all | maxDets=1500 ] = 0.075
Average Precision (AP) @[ IoU=0.50:0.95 | area=verytiny | maxDets=1500 ] = 0.000
Average Precision (AP) @[ IoU=0.50:0.95 | area= tiny | maxDets=1500 ] = 0.077
Average Precision (AP) @[ IoU=0.50:0.95 | area= small | maxDets=1500 ] = 0.227
Average Precision (AP) @[ IoU=0.50:0.95 | area=medium | maxDets=1500 ] = 0.331
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=100 ] = 0.169
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=300 ] = 0.174
Average Recall (AR) @[ IoU=0.50:0.95 | area= all | maxDets=1500 ] = 0.174
Average Recall (AR) @[ IoU=0.50:0.95 | area=verytiny | maxDets=1500 ] = 0.000
Average Recall (AR) @[ IoU=0.50:0.95 | area= tiny | maxDets=1500 ] = 0.110
Average Recall (AR) @[ IoU=0.50:0.95 | area= small | maxDets=1500 ] = 0.372
Average Recall (AR) @[ IoU=0.50:0.95 | area=medium | maxDets=1500 ] = 0.458
Optimal LRP @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.897
Optimal LRP Loc @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.290
Optimal LRP FP @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.438
Optimal LRP FN @[ IoU=0.50 | area= all | maxDets=1500 ] = 0.717
# Class-specific LRP-Optimal Thresholds #
[0.76 0.446 0.603 0.588 0.713 0.445 0.511 nan]
+----------+-------+---------------+-------+--------------+-------+
| category | AP | category | AP | category | AP |
+----------+-------+---------------+-------+--------------+-------+
| airplane | 0.208 | bridge | 0.029 | storage-tank | 0.205 |
| ship | 0.195 | swimming-pool | 0.073 | vehicle | 0.127 |
| person | 0.044 | wind-mill | 0.000 | None | None |
+----------+-------+---------------+-------+--------------+-------+
+----------+-------+---------------+-------+--------------+-------+
| category | oLRP | category | oLRP | category | oLRP |
+----------+-------+---------------+-------+--------------+-------+
| airplane | 0.817 | bridge | 0.968 | storage-tank | 0.812 |
| ship | 0.827 | swimming-pool | 0.919 | vehicle | 0.879 |
| person | 0.954 | wind-mill | 1.000 | None | None |
+----------+-------+---------------+-------+--------------+-------+
"""
_base_ = ['../_base_/models/faster_rcnn_r50_fpn_aitod.py', '../_base_/datasets/aitod_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
model = dict(train_cfg=dict(rpn=dict(assigner=dict(iou_calculator=dict(type='BboxOverlaps2D'), assign_metric='iou')), rcnn=dict(assigner=dict(iou_calculator=dict(type='BboxOverlaps2D'), assign_metric='iou'))))
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
checkpoint_config = dict(interval=4) |
SESSION_NAME = "researcher_username"
EXPIRY_NAME = "expiry"
SESSION_UUID = "session_uuid"
STUDY_ADMIN_RESTRICTION = "study_admin_restriction"
| session_name = 'researcher_username'
expiry_name = 'expiry'
session_uuid = 'session_uuid'
study_admin_restriction = 'study_admin_restriction' |
class Solution:
def addDigits(self, num: int) -> int:
while num > 9:
num = sum([int(x) for x in str(num)])
return num
| class Solution:
def add_digits(self, num: int) -> int:
while num > 9:
num = sum([int(x) for x in str(num)])
return num |
class Node:
def __init__(self, data):
self.data = data
self.left = self.right = None
class Solution:
def tiltOfBinaryTreeUtil(self, root):
if root is None:
return 0
left_tilt = self.tiltOfBinaryTreeUtil(root.left)
right_tilt = self.tiltOfBinaryTreeUtil(root.right)
currentNode_tilt = abs(left_tilt - right_tilt)
self.total_tilt += currentNode_tilt
return root.data + left_tilt + right_tilt
def tiltOfBinaryTree(self, root):
self.total_tilt = 0
self.tiltOfBinaryTreeUtil(root)
return self.total_tilt
if __name__ == '__main__':
root = Node(50)
root.left = Node(10)
root.right = Node(40)
root.left.left = Node(30)
root.left.right = Node(20)
print(Solution().tiltOfBinaryTree(root))
# 4
# / \
# 2 9
# / \ \
# 3 5 7
# Explanation:
# Tilt of node 3 : 0
# Tilt of node 5 : 0
# Tilt of node 7 : 0
# Tilt of node 2 : |3-5| = 2
# Tilt of node 9 : |0-7| = 7
# Tilt of node 4 : |(3+5+2)-(9+7)| = 6
# Tilt of binary tree : 0 + 0 + 0 + 2 + 7 + 6 = 15
root = Node(4)
root.left = Node(2)
root.right = Node(9)
root.right.right = Node(7)
root.left.left = Node(3)
root.left.right = Node(5)
print(Solution().tiltOfBinaryTree(root))
| class Node:
def __init__(self, data):
self.data = data
self.left = self.right = None
class Solution:
def tilt_of_binary_tree_util(self, root):
if root is None:
return 0
left_tilt = self.tiltOfBinaryTreeUtil(root.left)
right_tilt = self.tiltOfBinaryTreeUtil(root.right)
current_node_tilt = abs(left_tilt - right_tilt)
self.total_tilt += currentNode_tilt
return root.data + left_tilt + right_tilt
def tilt_of_binary_tree(self, root):
self.total_tilt = 0
self.tiltOfBinaryTreeUtil(root)
return self.total_tilt
if __name__ == '__main__':
root = node(50)
root.left = node(10)
root.right = node(40)
root.left.left = node(30)
root.left.right = node(20)
print(solution().tiltOfBinaryTree(root))
root = node(4)
root.left = node(2)
root.right = node(9)
root.right.right = node(7)
root.left.left = node(3)
root.left.right = node(5)
print(solution().tiltOfBinaryTree(root)) |
def getLongestPalindrome(start: int, end: int, s: str) -> str:
while start > -1 and end < len(s) and s[start] == s[end]:
start -= 1
end += 1
return s[start + 1:end]
def longestPalindrome(s: str) -> str:
if not s or len(s) == 0:
return ""
if len(s) == 1:
return s
result = ""
for index in range(len(s)):
odd = getLongestPalindrome(index, index, s)
even = getLongestPalindrome(index, index + 1, s)
if len(odd) > len(result):
result = odd
if len(even) > len(result):
result = even
return result
if __name__ == "__main__":
print(longestPalindrome("babad"))
print(longestPalindrome("cbbd"))
print(longestPalindrome("a"))
print(longestPalindrome("ac"))
print(longestPalindrome("bb")) | def get_longest_palindrome(start: int, end: int, s: str) -> str:
while start > -1 and end < len(s) and (s[start] == s[end]):
start -= 1
end += 1
return s[start + 1:end]
def longest_palindrome(s: str) -> str:
if not s or len(s) == 0:
return ''
if len(s) == 1:
return s
result = ''
for index in range(len(s)):
odd = get_longest_palindrome(index, index, s)
even = get_longest_palindrome(index, index + 1, s)
if len(odd) > len(result):
result = odd
if len(even) > len(result):
result = even
return result
if __name__ == '__main__':
print(longest_palindrome('babad'))
print(longest_palindrome('cbbd'))
print(longest_palindrome('a'))
print(longest_palindrome('ac'))
print(longest_palindrome('bb')) |
class WeatherItem:
def __init__(self, name, prefix="", suffix="", condition_type_list=[]):
self.__name = name
self.__prefix = prefix
self.__suffix = suffix
self.__condition_list = condition_type_list
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__name == other.name
return False
def __ne__(self, other):
return not self.__eq__(other)
def __str__(self):
return "{%s, %s, %s, %s}" % (self.__name, self.__prefix, self.__suffix, self.__condition_list)
__repr__ = __str__
@property
def name(self):
return self.__name
@property
def conditions(self):
return self.__condition_list
def is_for_condition_type(self, condition_type):
return condition_type in self.__condition_list
def format_for_output(self):
output = self.__name
if self.__prefix != "":
output = self.__prefix + " " + output
if self.__suffix != "":
output = output + " " + self.__suffix
return output
| class Weatheritem:
def __init__(self, name, prefix='', suffix='', condition_type_list=[]):
self.__name = name
self.__prefix = prefix
self.__suffix = suffix
self.__condition_list = condition_type_list
def __eq__(self, other):
if isinstance(other, self.__class__):
return self.__name == other.name
return False
def __ne__(self, other):
return not self.__eq__(other)
def __str__(self):
return '{%s, %s, %s, %s}' % (self.__name, self.__prefix, self.__suffix, self.__condition_list)
__repr__ = __str__
@property
def name(self):
return self.__name
@property
def conditions(self):
return self.__condition_list
def is_for_condition_type(self, condition_type):
return condition_type in self.__condition_list
def format_for_output(self):
output = self.__name
if self.__prefix != '':
output = self.__prefix + ' ' + output
if self.__suffix != '':
output = output + ' ' + self.__suffix
return output |
secondary_todo_list
| secondary_todo_list |
window = None
scene = 'title'
state = ''
class Cursor():
class Title():
menu = 0
class Save_Select():
save = 0
class Roguelike_Menu():
level = 0
character = 0
class Roguelike_Start():
select = 0
class Save():
data = {
0 : '',
1 : '',
2 : '',
}
class Select():
class Roguelike_Menu():
level = 0
character = 0
class Pool():
card = {
'all' : [],
'fire' : [],
'water' : [],
'nature' : [],
'earth' : [],
'light' : [],
'normal' : []
}
item = {
'common' : [],
}
class Field():
wall = []
thing = []
portal = []
class Player():
level = 0
exp = 0
exp_max = 0
life = 20
card = []
equip = []
item = []
class Player_Rogue():
level = 0
exp = 0
exp_max = 0
life = 20
deck = []
equip = []
item = []
| window = None
scene = 'title'
state = ''
class Cursor:
class Title:
menu = 0
class Save_Select:
save = 0
class Roguelike_Menu:
level = 0
character = 0
class Roguelike_Start:
select = 0
class Save:
data = {0: '', 1: '', 2: ''}
class Select:
class Roguelike_Menu:
level = 0
character = 0
class Pool:
card = {'all': [], 'fire': [], 'water': [], 'nature': [], 'earth': [], 'light': [], 'normal': []}
item = {'common': []}
class Field:
wall = []
thing = []
portal = []
class Player:
level = 0
exp = 0
exp_max = 0
life = 20
card = []
equip = []
item = []
class Player_Rogue:
level = 0
exp = 0
exp_max = 0
life = 20
deck = []
equip = []
item = [] |
class Car:
"""
Add class description here
"""
def __init__(self, name, length, location, orientation):
"""
A constructor for a Car object
:param name: A string representing the car's name
:param length: A positive int representing the car's length.
:param location: A tuple representing the car's head (row, col) location
:param orientation: One of either 0 (VERTICAL) or 1 (HORIZONTAL)
"""
# Note that this function is required in your Car implementation.
# However, is not part of the API for general car types.
self.__length = length
self.__orientation = orientation
self.__location = location
self.__name = name
def car_coordinates(self):
"""
:return: A list of coordinates the car is in
"""
result = []
for i in range(self.__length):
if self.__orientation == 0:
result.append((self.__location[0] + i, self.__location[1]))
elif self.__orientation == 1:
result.append((self.__location[0], self.__location[1] + i))
return result
def possible_moves(self):
"""
:return: A dictionary of strings describing possible movements permitted by this car.
"""
# For this car type, keys are from 'udrl'
# The keys for vertical cars are 'u' and 'd'.
# The keys for horizontal cars are 'l' and 'r'.
# You may choose appropriate strings.
# implement your code and erase the "pass"
# The dictionary returned should look something like this:
# result = {'f': "cause the car to fly and reach the Moon",
# 'd': "cause the car to dig and reach the core of Earth",
# 'a': "another unknown action"}
# A car returning this dictionary supports the commands 'f','d','a'.
result = {}
if self.__orientation == 0:
result['u'] = 'cause the car can get up to the reach of the mountains'
result['d'] = 'cause the car get go down to the center of Earth'
elif self.__orientation == 1:
result['l'] = 'cause the car get go west in to the sea'
result['r'] = 'cause the car get go east to the desert'
return result
def movement_requirements(self, movekey):
"""
:param movekey: A string representing the key of the required move.
:return: A list of cell locations which must be empty in order for this move to be legal.
"""
# For example, a car in locations [(1,2),(2,2)] requires [(3,2)] to
# be empty in order to move down (with a key 'd').
if movekey == 'u':
return (self.__location[0] - 1, self.__location[1])
elif movekey == 'r':
return (self.__location[0], self.__location[1] + self.__length)
elif movekey == 'l':
return (self.__location[0], self.__location[1] - 1)
elif movekey == 'd':
return (self.__location[0] + self.__length, self.__location[1])
return None
def move(self, movekey):
"""
:param movekey: A string representing the key of the required move.
:return: True upon success, False otherwise
"""
if movekey == 'u':
self.__location = (self.__location[0] - 1, self.__location[1])
elif movekey == 'r':
self.__location = (self.__location[0], self.__location[1] + 1)
elif movekey == 'd':
self.__location = (self.__location[0] + 1, self.__location[1])
elif movekey == 'l':
self.__location = (self.__location[0], self.__location[1] - 1)
return None
def get_name(self):
"""
:return: The name of this car.
"""
# implement your code and erase the "pass"
return self.__name
| class Car:
"""
Add class description here
"""
def __init__(self, name, length, location, orientation):
"""
A constructor for a Car object
:param name: A string representing the car's name
:param length: A positive int representing the car's length.
:param location: A tuple representing the car's head (row, col) location
:param orientation: One of either 0 (VERTICAL) or 1 (HORIZONTAL)
"""
self.__length = length
self.__orientation = orientation
self.__location = location
self.__name = name
def car_coordinates(self):
"""
:return: A list of coordinates the car is in
"""
result = []
for i in range(self.__length):
if self.__orientation == 0:
result.append((self.__location[0] + i, self.__location[1]))
elif self.__orientation == 1:
result.append((self.__location[0], self.__location[1] + i))
return result
def possible_moves(self):
"""
:return: A dictionary of strings describing possible movements permitted by this car.
"""
result = {}
if self.__orientation == 0:
result['u'] = 'cause the car can get up to the reach of the mountains'
result['d'] = 'cause the car get go down to the center of Earth'
elif self.__orientation == 1:
result['l'] = 'cause the car get go west in to the sea'
result['r'] = 'cause the car get go east to the desert'
return result
def movement_requirements(self, movekey):
"""
:param movekey: A string representing the key of the required move.
:return: A list of cell locations which must be empty in order for this move to be legal.
"""
if movekey == 'u':
return (self.__location[0] - 1, self.__location[1])
elif movekey == 'r':
return (self.__location[0], self.__location[1] + self.__length)
elif movekey == 'l':
return (self.__location[0], self.__location[1] - 1)
elif movekey == 'd':
return (self.__location[0] + self.__length, self.__location[1])
return None
def move(self, movekey):
"""
:param movekey: A string representing the key of the required move.
:return: True upon success, False otherwise
"""
if movekey == 'u':
self.__location = (self.__location[0] - 1, self.__location[1])
elif movekey == 'r':
self.__location = (self.__location[0], self.__location[1] + 1)
elif movekey == 'd':
self.__location = (self.__location[0] + 1, self.__location[1])
elif movekey == 'l':
self.__location = (self.__location[0], self.__location[1] - 1)
return None
def get_name(self):
"""
:return: The name of this car.
"""
return self.__name |
in_file = open('occurrences.txt', 'r')
out_file = open('present.txt', 'w')
counter = 7740
for line in in_file:
row = line.split('\t')
country = row[5]
id = row[0]
ref = row[8]
if country == '':
country = row[6]
if country == '':
pass
else:
out_file.write('M' + str(counter) + '\t' + id + '\t\ttrue\t' + 'http://eol.org/schema/terms/Present' + '\t' + country + '\t\t\t\tCompiler: Anne E Thessen\t' + ref + '\n')
counter = counter + 1 | in_file = open('occurrences.txt', 'r')
out_file = open('present.txt', 'w')
counter = 7740
for line in in_file:
row = line.split('\t')
country = row[5]
id = row[0]
ref = row[8]
if country == '':
country = row[6]
if country == '':
pass
else:
out_file.write('M' + str(counter) + '\t' + id + '\t\ttrue\t' + 'http://eol.org/schema/terms/Present' + '\t' + country + '\t\t\t\tCompiler: Anne E Thessen\t' + ref + '\n')
counter = counter + 1 |
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
# This line will be programatically read/write by setup.py.
# Leave them at the bottom of this file and don't touch them.
__version__ = "0.1.1"
| __version__ = '0.1.1' |
"""
@author: David Lei
@since: 19/09/2017
Bottom up solution to find the nth fibonacci number.
"""
def fib(n):
TABLE = [0, 1]
calculated = 1
while calculated < n:
next_number = TABLE[calculated] + TABLE[calculated - 1]
print("Adding computed value to table {0} + {1} = {2}".format(
TABLE[calculated ], TABLE[calculated - 1], next_number))
TABLE.append(next_number)
calculated += 1
return TABLE[n]
print(fib(14))
| """
@author: David Lei
@since: 19/09/2017
Bottom up solution to find the nth fibonacci number.
"""
def fib(n):
table = [0, 1]
calculated = 1
while calculated < n:
next_number = TABLE[calculated] + TABLE[calculated - 1]
print('Adding computed value to table {0} + {1} = {2}'.format(TABLE[calculated], TABLE[calculated - 1], next_number))
TABLE.append(next_number)
calculated += 1
return TABLE[n]
print(fib(14)) |
# Create a dictionary of lists with new data
avocados_dict = {
"date": ["2019-11-17", "2019-12-01"],
"small_sold": [10859987, 9291631],
"large_sold": [7674135, 6238096]
}
# Convert dictionary into DataFrame
avocados_2019 = pd.DataFrame(avocados_dict)
# Print the new DataFrame
print(avocados_2019) | avocados_dict = {'date': ['2019-11-17', '2019-12-01'], 'small_sold': [10859987, 9291631], 'large_sold': [7674135, 6238096]}
avocados_2019 = pd.DataFrame(avocados_dict)
print(avocados_2019) |
Li = [ 22, 35 , 26 , 98 , 55 , 10 , 67 ]
Li.sort()
Li.reverse()
print(Li)
| li = [22, 35, 26, 98, 55, 10, 67]
Li.sort()
Li.reverse()
print(Li) |
class HsrpOutput(object):
# 'show hsrp detail' output
showHsrpDetailOutput = \
{
'GigabitEthernet0/0/0/0': {
'address_family': {
'ipv4': {
'version': {
1: {
'groups': {
0: {
'active_ip_address': 'unknown',
'active_router': 'unknown',
'bfd': {
'address': '10.1.1.1',
'interface_name': 'GigabitEthernet0/0/0/1',
'state': 'inactive'
},
'group_number': 0,
'hsrp_router_state': 'init',
'preempt': True,
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'stored',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': 'never',
'num_state_changes': 0
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0000.0c07.ac00'
},
10: {
'active_ip_address': 'local',
'active_priority': 63,
'active_router': 'local',
'authentication': 'cisco123',
'group_number': 10,
'hsrp_router_state': 'active',
'num_of_slaves': 1,
'preempt': True,
'primary_ipv4_address': {
'address': '10.1.1.254'
},
'priority': 63,
'session_name': 'group10',
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:36:53',
'num_state_changes': 4
},
'timers': {
'cfgd_hello_msec': 10000,
'cfgd_hold_msec': 30000,
'hello_msec': 10000,
'hello_msec_flag': True,
'hold_msec': 30000,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 123
}
},
'tracked_objects': {
'1': {
'object_name': '1',
'priority_decrement': 25
},
'num_tracked_objects': 2,
'num_tracked_objects_up': 1
},
'virtual_mac_address': '0000.0c07.ac0a'
},
20: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'primary_ipv4_address': {
'address': '10.1.1.128'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:52',
'num_state_changes': 4
},
'timers': {
'cfgd_hello_msec': 111,
'cfgd_hold_msec': 333,
'hello_msec': 111,
'hello_msec_flag': True,
'hold_msec': 333,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 251
}
},
'tracked_objects': {
'num_tracked_objects': 1,
'num_tracked_objects_up': 1
},
'virtual_mac_address': '0000.0c07.ac14'
}
},
'slave_groups': {
30: {
'follow': 'group10',
'group_number': 30,
'hsrp_router_state': 'init',
'primary_ipv4_address': {
'address': 'unknown'
},
'priority': 100,
'standby_state': 'stored',
'virtual_mac_address': '0000.0c07.ac1e'
}
}
}
}
},
'ipv6': {
'version': {
2: {
'groups': {
10: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 10,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:a'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.000a'
},
20: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:14'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.0014'
},
30: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 30,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:1e'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.001e'
}
}
}
}
}
},
'bfd': {
'detection_multiplier': 3,
'enabled': True,
'interval': 15
},
'delay': {
'minimum_delay': 100,
'reload_delay': 1000
},
'interface': 'GigabitEthernet0/0/0/0',
'redirects_disable': True,
'use_bia': False
}
}
showHsrpDetailOutputIncomplete = \
{
'GigabitEthernet0/0/0/0': {
'address_family': {
'ipv4': {
'version': {
1: {
'groups': {
0: {
'active_ip_address': 'unknown',
'active_router': 'unknown',
'bfd': {
'address': '10.1.1.1',
'interface_name': 'GigabitEthernet0/0/0/1',
'state': 'inactive'
},
'group_number': 0,
'hsrp_router_state': 'init',
'preempt': True,
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'stored',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': 'never',
'num_state_changes': 0
},
'virtual_mac_address': '0000.0c07.ac00'
},
10: {
'active_ip_address': 'local',
'active_priority': 63,
'active_router': 'local',
'authentication': 'cisco123',
'group_number': 10,
'hsrp_router_state': 'active',
'num_of_slaves': 1,
'preempt': True,
'primary_ipv4_address': {
'address': '10.1.1.254'
},
'priority': 63,
'session_name': 'group10',
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:36:53',
'num_state_changes': 4
},
'timers': {
'cfgd_hello_msec': 10000,
'cfgd_hold_msec': 30000,
'hello_msec': 10000,
'hello_msec_flag': True,
'hold_msec': 30000,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 123
}
},
'tracked_objects': {
'1': {
'object_name': '1',
'priority_decrement': 25
},
'num_tracked_objects': 2,
'num_tracked_objects_up': 1
},
'virtual_mac_address': '0000.0c07.ac0a'
},
20: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'primary_ipv4_address': {
'address': '10.1.1.128'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:52',
'num_state_changes': 4
},
'timers': {
'cfgd_hello_msec': 111,
'cfgd_hold_msec': 333,
'hello_msec': 111,
'hello_msec_flag': True,
'hold_msec': 333,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 251
}
},
'tracked_objects': {
'num_tracked_objects': 1,
'num_tracked_objects_up': 1
},
'virtual_mac_address': '0000.0c07.ac14'
}
},
'slave_groups': {
30: {
'follow': 'group10',
'group_number': 30,
'hsrp_router_state': 'init',
'primary_ipv4_address': {
'address': 'unknown'
},
'priority': 100,
'standby_state': 'stored',
'virtual_mac_address': '0000.0c07.ac1e'
}
}
}
}
},
'ipv6': {
'version': {
2: {
'groups': {
10: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 10,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:a'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.000a'
},
20: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:14'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.0014'
},
30: {
'active_ip_address': 'local',
'active_priority': 100,
'active_router': 'local',
'group_number': 30,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:1e'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'standby_state': 'reserving',
'statistics': {
'last_coup_received': 'Never',
'last_coup_sent': 'Never',
'last_resign_received': 'Never',
'last_resign_sent': 'Never',
'last_state_change': '09:37:18',
'num_state_changes': 4
},
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.001e'
}
}
}
}
}
},
'bfd': {
'detection_multiplier': 3,
'enabled': True,
'interval': 15
},
'delay': {
'minimum_delay': 100,
'reload_delay': 1000
},
'interface': 'GigabitEthernet0/0/0/0',
'redirects_disable': True,
'use_bia': False
}
}
# 'show hsrp summary' output
showHsrpSummaryOutput = \
{
'address_family': {
'ipv4': {
'intf_down': 0,
'intf_total': 1,
'intf_up': 1,
'state': {
'ACTIVE': {
'sessions': 2,
'slaves': 0,
'total': 2
},
'ALL': {
'sessions': 3,
'slaves': 1,
'total': 4
},
'INIT': {
'sessions': 1,
'slaves': 1,
'total': 2
},
'LEARN': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'LISTEN': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'SPEAK': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'STANDBY': {
'sessions': 0,
'slaves': 0,
'total': 0
}
},
'virtual_addresses_active': 3,
'virtual_addresses_inactive': 0,
'vritual_addresses_total': 3
},
'ipv6': {
'intf_down': 0,
'intf_total': 1,
'intf_up': 1,
'state': {
'ACTIVE': {
'sessions': 3,
'slaves': 0,
'total': 3
},
'ALL': {
'sessions': 3,
'slaves': 0,
'total': 3
},
'INIT': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'LEARN': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'LISTEN': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'SPEAK': {
'sessions': 0,
'slaves': 0,
'total': 0
},
'STANDBY': {
'sessions': 0,
'slaves': 0,
'total': 0
}
},
'virtual_addresses_active': 5,
'virtual_addresses_inactive': 0,
'vritual_addresses_total': 5
}
},
'bfd_sessions_down': 0,
'bfd_sessions_inactive': 1,
'bfd_sessions_up': 0,
'num_bfd_sessions': 1,
'num_tracked_objects': 2,
'tracked_objects_down': 1,
'tracked_objects_up': 1
}
# Hsrp Ops Object final output
hsrpOpsOutput = \
{
'GigabitEthernet0/0/0/0': {
'address_family': {
'ipv4': {
'version': {
1: {
'groups': {
0: {
'active_ip_address': 'unknown',
'active_router': 'unknown',
'bfd': {
'address': '10.1.1.1',
'interface_name': 'GigabitEthernet0/0/0/1'
},
'group_number': 0,
'hsrp_router_state': 'init',
'preempt': True,
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0000.0c07.ac00'
},
10: {
'active_ip_address': 'local',
'active_router': 'local',
'authentication': 'cisco123',
'group_number': 10,
'hsrp_router_state': 'active',
'preempt': True,
'primary_ipv4_address': {
'address': '10.1.1.254'
},
'priority': 63,
'session_name': 'group10',
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 10000,
'hello_msec_flag': True,
'hold_msec': 30000,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 123
}
},
'tracked_objects': {
'1': {
'object_name': '1',
'priority_decrement': 25
}
},
'virtual_mac_address': '0000.0c07.ac0a'
},
20: {
'active_ip_address': 'local',
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'primary_ipv4_address': {
'address': '10.1.1.128'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 111,
'hello_msec_flag': True,
'hold_msec': 333,
'hold_msec_flag': True
},
'tracked_interfaces': {
'GigabitEthernet0/0/0/1': {
'interface_name': 'GigabitEthernet0/0/0/1',
'priority_decrement': 251
}
},
'virtual_mac_address': '0000.0c07.ac14'
}
},
'slave_groups': {
30: {
'follow': 'group10',
'primary_ipv4_address': {
'address': 'unknown'
},
'virtual_mac_address': '0000.0c07.ac1e'
}
}
}
}
},
'ipv6': {
'version': {
2: {
'groups': {
10: {
'active_ip_address': 'local',
'active_router': 'local',
'group_number': 10,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:a'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.000a'
},
20: {
'active_ip_address': 'local',
'active_router': 'local',
'group_number': 20,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:14'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.0014'
},
30: {
'active_ip_address': 'local',
'active_router': 'local',
'group_number': 30,
'hsrp_router_state': 'active',
'link_local_ipv6_address': {
'address': 'fe80::205:73ff:fea0:1e'
},
'priority': 100,
'standby_ip_address': 'unknown',
'standby_router': 'unknown',
'timers': {
'hello_msec': 3000,
'hello_msec_flag': True,
'hold_msec': 10000,
'hold_msec_flag': True
},
'virtual_mac_address': '0005.73a0.001e'
}
}
}
}
}
},
'bfd': {
'detection_multiplier': 3,
'enabled': True,
'interval': 15
},
'delay': {
'minimum_delay': 100,
'reload_delay': 1000
},
'interface': 'GigabitEthernet0/0/0/0',
'redirects_disable': True,
'use_bia': False
}
}
# vim: ft=python et sw=4
| class Hsrpoutput(object):
show_hsrp_detail_output = {'GigabitEthernet0/0/0/0': {'address_family': {'ipv4': {'version': {1: {'groups': {0: {'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': {'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1', 'state': 'inactive'}, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'stored', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': 'never', 'num_state_changes': 0}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0000.0c07.ac00'}, 10: {'active_ip_address': 'local', 'active_priority': 63, 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'num_of_slaves': 1, 'preempt': True, 'primary_ipv4_address': {'address': '10.1.1.254'}, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:36:53', 'num_state_changes': 4}, 'timers': {'cfgd_hello_msec': 10000, 'cfgd_hold_msec': 30000, 'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123}}, 'tracked_objects': {'1': {'object_name': '1', 'priority_decrement': 25}, 'num_tracked_objects': 2, 'num_tracked_objects_up': 1}, 'virtual_mac_address': '0000.0c07.ac0a'}, 20: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': {'address': '10.1.1.128'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:52', 'num_state_changes': 4}, 'timers': {'cfgd_hello_msec': 111, 'cfgd_hold_msec': 333, 'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251}}, 'tracked_objects': {'num_tracked_objects': 1, 'num_tracked_objects_up': 1}, 'virtual_mac_address': '0000.0c07.ac14'}}, 'slave_groups': {30: {'follow': 'group10', 'group_number': 30, 'hsrp_router_state': 'init', 'primary_ipv4_address': {'address': 'unknown'}, 'priority': 100, 'standby_state': 'stored', 'virtual_mac_address': '0000.0c07.ac1e'}}}}}, 'ipv6': {'version': {2: {'groups': {10: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:a'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.000a'}, 20: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:14'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.0014'}, 30: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:1e'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.001e'}}}}}}, 'bfd': {'detection_multiplier': 3, 'enabled': True, 'interval': 15}, 'delay': {'minimum_delay': 100, 'reload_delay': 1000}, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False}}
show_hsrp_detail_output_incomplete = {'GigabitEthernet0/0/0/0': {'address_family': {'ipv4': {'version': {1: {'groups': {0: {'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': {'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1', 'state': 'inactive'}, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'stored', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': 'never', 'num_state_changes': 0}, 'virtual_mac_address': '0000.0c07.ac00'}, 10: {'active_ip_address': 'local', 'active_priority': 63, 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'num_of_slaves': 1, 'preempt': True, 'primary_ipv4_address': {'address': '10.1.1.254'}, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:36:53', 'num_state_changes': 4}, 'timers': {'cfgd_hello_msec': 10000, 'cfgd_hold_msec': 30000, 'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123}}, 'tracked_objects': {'1': {'object_name': '1', 'priority_decrement': 25}, 'num_tracked_objects': 2, 'num_tracked_objects_up': 1}, 'virtual_mac_address': '0000.0c07.ac0a'}, 20: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': {'address': '10.1.1.128'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:52', 'num_state_changes': 4}, 'timers': {'cfgd_hello_msec': 111, 'cfgd_hold_msec': 333, 'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251}}, 'tracked_objects': {'num_tracked_objects': 1, 'num_tracked_objects_up': 1}, 'virtual_mac_address': '0000.0c07.ac14'}}, 'slave_groups': {30: {'follow': 'group10', 'group_number': 30, 'hsrp_router_state': 'init', 'primary_ipv4_address': {'address': 'unknown'}, 'priority': 100, 'standby_state': 'stored', 'virtual_mac_address': '0000.0c07.ac1e'}}}}}, 'ipv6': {'version': {2: {'groups': {10: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:a'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.000a'}, 20: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:14'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.0014'}, 30: {'active_ip_address': 'local', 'active_priority': 100, 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:1e'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'standby_state': 'reserving', 'statistics': {'last_coup_received': 'Never', 'last_coup_sent': 'Never', 'last_resign_received': 'Never', 'last_resign_sent': 'Never', 'last_state_change': '09:37:18', 'num_state_changes': 4}, 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.001e'}}}}}}, 'bfd': {'detection_multiplier': 3, 'enabled': True, 'interval': 15}, 'delay': {'minimum_delay': 100, 'reload_delay': 1000}, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False}}
show_hsrp_summary_output = {'address_family': {'ipv4': {'intf_down': 0, 'intf_total': 1, 'intf_up': 1, 'state': {'ACTIVE': {'sessions': 2, 'slaves': 0, 'total': 2}, 'ALL': {'sessions': 3, 'slaves': 1, 'total': 4}, 'INIT': {'sessions': 1, 'slaves': 1, 'total': 2}, 'LEARN': {'sessions': 0, 'slaves': 0, 'total': 0}, 'LISTEN': {'sessions': 0, 'slaves': 0, 'total': 0}, 'SPEAK': {'sessions': 0, 'slaves': 0, 'total': 0}, 'STANDBY': {'sessions': 0, 'slaves': 0, 'total': 0}}, 'virtual_addresses_active': 3, 'virtual_addresses_inactive': 0, 'vritual_addresses_total': 3}, 'ipv6': {'intf_down': 0, 'intf_total': 1, 'intf_up': 1, 'state': {'ACTIVE': {'sessions': 3, 'slaves': 0, 'total': 3}, 'ALL': {'sessions': 3, 'slaves': 0, 'total': 3}, 'INIT': {'sessions': 0, 'slaves': 0, 'total': 0}, 'LEARN': {'sessions': 0, 'slaves': 0, 'total': 0}, 'LISTEN': {'sessions': 0, 'slaves': 0, 'total': 0}, 'SPEAK': {'sessions': 0, 'slaves': 0, 'total': 0}, 'STANDBY': {'sessions': 0, 'slaves': 0, 'total': 0}}, 'virtual_addresses_active': 5, 'virtual_addresses_inactive': 0, 'vritual_addresses_total': 5}}, 'bfd_sessions_down': 0, 'bfd_sessions_inactive': 1, 'bfd_sessions_up': 0, 'num_bfd_sessions': 1, 'num_tracked_objects': 2, 'tracked_objects_down': 1, 'tracked_objects_up': 1}
hsrp_ops_output = {'GigabitEthernet0/0/0/0': {'address_family': {'ipv4': {'version': {1: {'groups': {0: {'active_ip_address': 'unknown', 'active_router': 'unknown', 'bfd': {'address': '10.1.1.1', 'interface_name': 'GigabitEthernet0/0/0/1'}, 'group_number': 0, 'hsrp_router_state': 'init', 'preempt': True, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0000.0c07.ac00'}, 10: {'active_ip_address': 'local', 'active_router': 'local', 'authentication': 'cisco123', 'group_number': 10, 'hsrp_router_state': 'active', 'preempt': True, 'primary_ipv4_address': {'address': '10.1.1.254'}, 'priority': 63, 'session_name': 'group10', 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 10000, 'hello_msec_flag': True, 'hold_msec': 30000, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 123}}, 'tracked_objects': {'1': {'object_name': '1', 'priority_decrement': 25}}, 'virtual_mac_address': '0000.0c07.ac0a'}, 20: {'active_ip_address': 'local', 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'primary_ipv4_address': {'address': '10.1.1.128'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 111, 'hello_msec_flag': True, 'hold_msec': 333, 'hold_msec_flag': True}, 'tracked_interfaces': {'GigabitEthernet0/0/0/1': {'interface_name': 'GigabitEthernet0/0/0/1', 'priority_decrement': 251}}, 'virtual_mac_address': '0000.0c07.ac14'}}, 'slave_groups': {30: {'follow': 'group10', 'primary_ipv4_address': {'address': 'unknown'}, 'virtual_mac_address': '0000.0c07.ac1e'}}}}}, 'ipv6': {'version': {2: {'groups': {10: {'active_ip_address': 'local', 'active_router': 'local', 'group_number': 10, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:a'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.000a'}, 20: {'active_ip_address': 'local', 'active_router': 'local', 'group_number': 20, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:14'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.0014'}, 30: {'active_ip_address': 'local', 'active_router': 'local', 'group_number': 30, 'hsrp_router_state': 'active', 'link_local_ipv6_address': {'address': 'fe80::205:73ff:fea0:1e'}, 'priority': 100, 'standby_ip_address': 'unknown', 'standby_router': 'unknown', 'timers': {'hello_msec': 3000, 'hello_msec_flag': True, 'hold_msec': 10000, 'hold_msec_flag': True}, 'virtual_mac_address': '0005.73a0.001e'}}}}}}, 'bfd': {'detection_multiplier': 3, 'enabled': True, 'interval': 15}, 'delay': {'minimum_delay': 100, 'reload_delay': 1000}, 'interface': 'GigabitEthernet0/0/0/0', 'redirects_disable': True, 'use_bia': False}} |
SPECS = {
"org.freedesktop.DBus.ObjectManager": """
<interface name="org.freedesktop.DBus.ObjectManager">
<method name="GetManagedObjects">
<arg name="objpath_interfaces_and_properties" type="a{oa{sa{sv}}}" direction="out" />
</method>
</interface>
""",
"org.storage.stratis2.FetchProperties.r4": """
<interface name="org.storage.stratis2.FetchProperties.r4">
<method name="GetAllProperties">
<arg name="results" type="a{s(bv)}" direction="out" />
</method>
<method name="GetProperties">
<arg name="properties" type="as" direction="in" />
<arg name="results" type="a{s(bv)}" direction="out" />
</method>
</interface>
""",
"org.storage.stratis2.Manager.r4": """
<interface name="org.storage.stratis2.Manager.r4">
<method name="ConfigureSimulator">
<arg name="denominator" type="u" direction="in" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="CreatePool">
<arg name="name" type="s" direction="in" />
<arg name="redundancy" type="(bq)" direction="in" />
<arg name="devices" type="as" direction="in" />
<arg name="key_desc" type="(bs)" direction="in" />
<arg name="clevis_info" type="(b(ss))" direction="in" />
<arg name="result" type="(b(oao))" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="DestroyPool">
<arg name="pool" type="o" direction="in" />
<arg name="result" type="(bs)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="EngineStateReport">
<arg name="result" type="s" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="SetKey">
<arg name="key_desc" type="s" direction="in" />
<arg name="key_fd" type="h" direction="in" />
<arg name="interactive" type="b" direction="in" />
<arg name="result" type="(bb)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="UnlockPool">
<arg name="pool_uuid" type="s" direction="in" />
<arg name="unlock_method" type="s" direction="in" />
<arg name="result" type="(bas)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="UnsetKey">
<arg name="key_desc" type="s" direction="in" />
<arg name="result" type="b" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<property name="Version" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
</interface>
""",
"org.storage.stratis2.Report.r4": """
<interface name="org.storage.stratis2.Report.r4">
<method name="GetReport">
<arg name="name" type="s" direction="in" />
<arg name="result" type="s" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
</interface>
""",
"org.storage.stratis2.blockdev.r4": """
<interface name="org.storage.stratis2.blockdev.r4">
<method name="SetUserInfo">
<arg name="id" type="(bs)" direction="in" />
<arg name="changed" type="(bs)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<property name="Devnode" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
<property name="HardwareInfo" type="(bs)" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
<property name="InitializationTime" type="t" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
<property name="PhysicalPath" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
<property name="Pool" type="o" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
<property name="Tier" type="q" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false" />
</property>
<property name="UserInfo" type="(bs)" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false" />
</property>
<property name="Uuid" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
</interface>
""",
"org.storage.stratis2.filesystem.r4": """
<interface name="org.storage.stratis2.filesystem.r4">
<method name="SetName">
<arg name="name" type="s" direction="in" />
<arg name="result" type="(bs)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<property name="Created" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
<property name="Devnode" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="invalidates" />
</property>
<property name="Name" type="s" access="read" />
<property name="Pool" type="o" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
<property name="Uuid" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
</interface>
""",
"org.storage.stratis2.pool.r4": """
<interface name="org.storage.stratis2.pool.r4">
<method name="AddCacheDevs">
<arg name="devices" type="as" direction="in" />
<arg name="results" type="(bao)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="AddDataDevs">
<arg name="devices" type="as" direction="in" />
<arg name="results" type="(bao)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="Bind">
<arg name="pin" type="s" direction="in" />
<arg name="json" type="s" direction="in" />
<arg name="results" type="b" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="BindKeyring">
<arg name="key_desc" type="s" direction="in" />
<arg name="results" type="b" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="CreateFilesystems">
<arg name="specs" type="as" direction="in" />
<arg name="results" type="(ba(os))" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="DestroyFilesystems">
<arg name="filesystems" type="ao" direction="in" />
<arg name="results" type="(bas)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="InitCache">
<arg name="devices" type="as" direction="in" />
<arg name="results" type="(bao)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="SetName">
<arg name="name" type="s" direction="in" />
<arg name="result" type="(bs)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="SnapshotFilesystem">
<arg name="origin" type="o" direction="in" />
<arg name="snapshot_name" type="s" direction="in" />
<arg name="result" type="(bo)" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="Unbind">
<arg name="results" type="b" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<method name="UnbindKeyring">
<arg name="results" type="b" direction="out" />
<arg name="return_code" type="q" direction="out" />
<arg name="return_string" type="s" direction="out" />
</method>
<property name="Encrypted" type="b" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
<property name="Name" type="s" access="read" />
<property name="Uuid" type="s" access="read">
<annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />
</property>
</interface>
""",
}
| specs = {'org.freedesktop.DBus.ObjectManager': '\n<interface name="org.freedesktop.DBus.ObjectManager">\n <method name="GetManagedObjects">\n <arg name="objpath_interfaces_and_properties" type="a{oa{sa{sv}}}" direction="out" />\n </method>\n </interface>\n', 'org.storage.stratis2.FetchProperties.r4': '\n<interface name="org.storage.stratis2.FetchProperties.r4">\n <method name="GetAllProperties">\n <arg name="results" type="a{s(bv)}" direction="out" />\n </method>\n <method name="GetProperties">\n <arg name="properties" type="as" direction="in" />\n <arg name="results" type="a{s(bv)}" direction="out" />\n </method>\n </interface>\n', 'org.storage.stratis2.Manager.r4': '\n<interface name="org.storage.stratis2.Manager.r4">\n <method name="ConfigureSimulator">\n <arg name="denominator" type="u" direction="in" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="CreatePool">\n <arg name="name" type="s" direction="in" />\n <arg name="redundancy" type="(bq)" direction="in" />\n <arg name="devices" type="as" direction="in" />\n <arg name="key_desc" type="(bs)" direction="in" />\n <arg name="clevis_info" type="(b(ss))" direction="in" />\n <arg name="result" type="(b(oao))" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="DestroyPool">\n <arg name="pool" type="o" direction="in" />\n <arg name="result" type="(bs)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="EngineStateReport">\n <arg name="result" type="s" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="SetKey">\n <arg name="key_desc" type="s" direction="in" />\n <arg name="key_fd" type="h" direction="in" />\n <arg name="interactive" type="b" direction="in" />\n <arg name="result" type="(bb)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="UnlockPool">\n <arg name="pool_uuid" type="s" direction="in" />\n <arg name="unlock_method" type="s" direction="in" />\n <arg name="result" type="(bas)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="UnsetKey">\n <arg name="key_desc" type="s" direction="in" />\n <arg name="result" type="b" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <property name="Version" type="s" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n </interface>\n', 'org.storage.stratis2.Report.r4': '\n<interface name="org.storage.stratis2.Report.r4">\n <method name="GetReport">\n <arg name="name" type="s" direction="in" />\n <arg name="result" type="s" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n </interface>\n', 'org.storage.stratis2.blockdev.r4': '\n<interface name="org.storage.stratis2.blockdev.r4">\n <method name="SetUserInfo">\n <arg name="id" type="(bs)" direction="in" />\n <arg name="changed" type="(bs)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <property name="Devnode" type="s" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n <property name="HardwareInfo" type="(bs)" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n <property name="InitializationTime" type="t" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n <property name="PhysicalPath" type="s" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n <property name="Pool" type="o" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n <property name="Tier" type="q" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false" />\n </property>\n <property name="UserInfo" type="(bs)" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="false" />\n </property>\n <property name="Uuid" type="s" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n </interface>\n', 'org.storage.stratis2.filesystem.r4': '\n<interface name="org.storage.stratis2.filesystem.r4">\n <method name="SetName">\n <arg name="name" type="s" direction="in" />\n <arg name="result" type="(bs)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <property name="Created" type="s" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n <property name="Devnode" type="s" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="invalidates" />\n </property>\n <property name="Name" type="s" access="read" />\n <property name="Pool" type="o" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n <property name="Uuid" type="s" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n </interface>\n', 'org.storage.stratis2.pool.r4': '\n<interface name="org.storage.stratis2.pool.r4">\n <method name="AddCacheDevs">\n <arg name="devices" type="as" direction="in" />\n <arg name="results" type="(bao)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="AddDataDevs">\n <arg name="devices" type="as" direction="in" />\n <arg name="results" type="(bao)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="Bind">\n <arg name="pin" type="s" direction="in" />\n <arg name="json" type="s" direction="in" />\n <arg name="results" type="b" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="BindKeyring">\n <arg name="key_desc" type="s" direction="in" />\n <arg name="results" type="b" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="CreateFilesystems">\n <arg name="specs" type="as" direction="in" />\n <arg name="results" type="(ba(os))" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="DestroyFilesystems">\n <arg name="filesystems" type="ao" direction="in" />\n <arg name="results" type="(bas)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="InitCache">\n <arg name="devices" type="as" direction="in" />\n <arg name="results" type="(bao)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="SetName">\n <arg name="name" type="s" direction="in" />\n <arg name="result" type="(bs)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="SnapshotFilesystem">\n <arg name="origin" type="o" direction="in" />\n <arg name="snapshot_name" type="s" direction="in" />\n <arg name="result" type="(bo)" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="Unbind">\n <arg name="results" type="b" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <method name="UnbindKeyring">\n <arg name="results" type="b" direction="out" />\n <arg name="return_code" type="q" direction="out" />\n <arg name="return_string" type="s" direction="out" />\n </method>\n <property name="Encrypted" type="b" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n <property name="Name" type="s" access="read" />\n <property name="Uuid" type="s" access="read">\n <annotation name="org.freedesktop.DBus.Property.EmitsChangedSignal" value="const" />\n </property>\n </interface>\n'} |
"""
Code generated from go.sum by //:gazelle-update-repos
"""
load("@bazel_gazelle//:deps.bzl", "go_repository")
def go_dependencies():
"""
Managed by gazelle. Add "# keep" comment to modified lines.
"""
go_repository(
name = "co_honnef_go_tools",
importpath = "honnef.co/go/tools",
sum = "h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=",
version = "v0.0.1-2020.1.4",
)
go_repository(
name = "com_github_abbot_go_http_auth",
importpath = "github.com/abbot/go-http-auth",
sum = "h1:9ZqcMQ0fB+ywKACVjGfZM4C7Uq9D5rq0iSmwIjX187k=",
version = "v0.4.1-0.20181019201920-860ed7f246ff",
)
go_repository(
name = "com_github_alecthomas_template",
importpath = "github.com/alecthomas/template",
sum = "h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=",
version = "v0.0.0-20190718012654-fb15b899a751",
)
go_repository(
name = "com_github_alecthomas_units",
importpath = "github.com/alecthomas/units",
sum = "h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=",
version = "v0.0.0-20190924025748-f65c72e2690d",
)
go_repository(
name = "com_github_andybalholm_brotli",
importpath = "github.com/andybalholm/brotli",
sum = "h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E=",
version = "v1.0.2",
)
go_repository(
name = "com_github_antihax_optional",
importpath = "github.com/antihax/optional",
sum = "h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=",
version = "v1.0.0",
)
go_repository(
name = "com_github_beorn7_perks",
importpath = "github.com/beorn7/perks",
sum = "h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=",
version = "v1.0.1",
)
go_repository(
name = "com_github_burntsushi_toml",
importpath = "github.com/BurntSushi/toml",
sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=",
version = "v0.3.1",
)
go_repository(
name = "com_github_burntsushi_xgb",
importpath = "github.com/BurntSushi/xgb",
sum = "h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=",
version = "v0.0.0-20160522181843-27f122750802",
)
go_repository(
name = "com_github_census_instrumentation_opencensus_proto",
importpath = "github.com/census-instrumentation/opencensus-proto",
sum = "h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=",
version = "v0.2.1",
)
go_repository(
name = "com_github_cespare_xxhash",
importpath = "github.com/cespare/xxhash",
sum = "h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=",
version = "v1.1.0",
)
go_repository(
name = "com_github_cespare_xxhash_v2",
importpath = "github.com/cespare/xxhash/v2",
sum = "h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=",
version = "v2.1.2",
)
go_repository(
name = "com_github_chzyer_logex",
importpath = "github.com/chzyer/logex",
sum = "h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=",
version = "v1.1.10",
)
go_repository(
name = "com_github_chzyer_readline",
importpath = "github.com/chzyer/readline",
sum = "h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=",
version = "v0.0.0-20180603132655-2972be24d48e",
)
go_repository(
name = "com_github_chzyer_test",
importpath = "github.com/chzyer/test",
sum = "h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=",
version = "v0.0.0-20180213035817-a1ea475d72b1",
)
go_repository(
name = "com_github_client9_misspell",
importpath = "github.com/client9/misspell",
sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=",
version = "v0.3.4",
)
go_repository(
name = "com_github_cncf_udpa_go",
importpath = "github.com/cncf/udpa/go",
sum = "h1:hzAQntlaYRkVSFEfj9OTWlVV1H155FMD8BTKktLv0QI=",
version = "v0.0.0-20210930031921-04548b0d99d4",
)
go_repository(
name = "com_github_cncf_xds_go",
importpath = "github.com/cncf/xds/go",
sum = "h1:zH8ljVhhq7yC0MIeUL/IviMtY8hx2mK8cN9wEYb8ggw=",
version = "v0.0.0-20211011173535-cb28da3451f1",
)
go_repository(
name = "com_github_cpuguy83_go_md2man_v2",
importpath = "github.com/cpuguy83/go-md2man/v2",
sum = "h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=",
version = "v2.0.1",
)
go_repository(
name = "com_github_creack_pty",
importpath = "github.com/creack/pty",
sum = "h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=",
version = "v1.1.9",
)
go_repository(
name = "com_github_davecgh_go_spew",
importpath = "github.com/davecgh/go-spew",
sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=",
version = "v1.1.1",
)
go_repository(
name = "com_github_djherbis_atime",
importpath = "github.com/djherbis/atime",
sum = "h1:rgwVbP/5by8BvvjBNrbh64Qz33idKT3pSnMSJsxhi0g=",
version = "v1.1.0",
)
go_repository(
name = "com_github_dustin_go_humanize",
importpath = "github.com/dustin/go-humanize",
sum = "h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=",
version = "v1.0.0",
)
go_repository(
name = "com_github_emicklei_go_restful_v3",
importpath = "github.com/emicklei/go-restful/v3",
sum = "h1:R5iagkkTsfFpe1nce6Yniw3wmSx0Qw5YP469YzRFNEs=",
version = "v3.7.1",
)
go_repository(
name = "com_github_envoyproxy_go_control_plane",
importpath = "github.com/envoyproxy/go-control-plane",
sum = "h1:fP+fF0up6oPY49OrjPrhIJ8yQfdIM85NXMLkMg1EXVs=",
version = "v0.9.10-0.20210907150352-cf90f659a021",
)
go_repository(
name = "com_github_envoyproxy_protoc_gen_validate",
importpath = "github.com/envoyproxy/protoc-gen-validate",
sum = "h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=",
version = "v0.1.0",
)
go_repository(
name = "com_github_fasthttp_router",
importpath = "github.com/fasthttp/router",
sum = "h1:Z025tHFTjDp6T6QMBjloyGL6KV5wtakW365K/7KiE1c=",
version = "v1.4.4",
)
go_repository(
name = "com_github_frankban_quicktest",
importpath = "github.com/frankban/quicktest",
sum = "h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=",
version = "v1.14.0",
)
go_repository(
name = "com_github_fsnotify_fsnotify",
importpath = "github.com/fsnotify/fsnotify",
sum = "h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=",
version = "v1.4.7",
)
go_repository(
name = "com_github_ghodss_yaml",
importpath = "github.com/ghodss/yaml",
sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=",
version = "v1.0.0",
)
go_repository(
name = "com_github_gin_contrib_sse",
importpath = "github.com/gin-contrib/sse",
sum = "h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=",
version = "v0.1.0",
)
go_repository(
name = "com_github_gin_gonic_gin",
importpath = "github.com/gin-gonic/gin",
sum = "h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=",
version = "v1.7.4",
)
go_repository(
name = "com_github_go_chi_chi",
importpath = "github.com/go-chi/chi",
sum = "h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=",
version = "v4.1.2+incompatible",
)
go_repository(
name = "com_github_go_gl_glfw",
importpath = "github.com/go-gl/glfw",
sum = "h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=",
version = "v0.0.0-20190409004039-e6da0acd62b1",
)
go_repository(
name = "com_github_go_gl_glfw_v3_3_glfw",
importpath = "github.com/go-gl/glfw/v3.3/glfw",
sum = "h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=",
version = "v0.0.0-20200222043503-6f7a984d4dc4",
)
go_repository(
name = "com_github_go_kit_kit",
importpath = "github.com/go-kit/kit",
sum = "h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=",
version = "v0.9.0",
)
go_repository(
name = "com_github_go_kit_log",
importpath = "github.com/go-kit/log",
sum = "h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ=",
version = "v0.1.0",
)
go_repository(
name = "com_github_go_logfmt_logfmt",
importpath = "github.com/go-logfmt/logfmt",
sum = "h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4=",
version = "v0.5.0",
)
go_repository(
name = "com_github_go_playground_locales",
importpath = "github.com/go-playground/locales",
sum = "h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=",
version = "v0.13.0",
)
go_repository(
name = "com_github_go_playground_universal_translator",
importpath = "github.com/go-playground/universal-translator",
sum = "h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=",
version = "v0.17.0",
)
go_repository(
name = "com_github_go_playground_validator_v10",
importpath = "github.com/go-playground/validator/v10",
sum = "h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=",
version = "v10.4.1",
)
go_repository(
name = "com_github_go_stack_stack",
importpath = "github.com/go-stack/stack",
sum = "h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=",
version = "v1.8.0",
)
go_repository(
name = "com_github_gogo_protobuf",
importpath = "github.com/gogo/protobuf",
sum = "h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=",
version = "v1.1.1",
)
go_repository(
name = "com_github_golang_glog",
importpath = "github.com/golang/glog",
sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=",
version = "v0.0.0-20160126235308-23def4e6c14b",
)
go_repository(
name = "com_github_golang_groupcache",
importpath = "github.com/golang/groupcache",
sum = "h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=",
version = "v0.0.0-20210331224755-41bb18bfe9da",
)
go_repository(
name = "com_github_golang_mock",
importpath = "github.com/golang/mock",
sum = "h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=",
version = "v1.6.0",
)
go_repository(
name = "com_github_golang_protobuf",
importpath = "github.com/golang/protobuf",
sum = "h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=",
version = "v1.5.2",
)
go_repository(
name = "com_github_golang_snappy",
importpath = "github.com/golang/snappy",
sum = "h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=",
version = "v0.0.4",
)
go_repository(
name = "com_github_google_btree",
importpath = "github.com/google/btree",
sum = "h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=",
version = "v1.0.0",
)
go_repository(
name = "com_github_google_go_cmp",
importpath = "github.com/google/go-cmp",
sum = "h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=",
version = "v0.5.6",
)
go_repository(
name = "com_github_google_gofuzz",
importpath = "github.com/google/gofuzz",
sum = "h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=",
version = "v1.0.0",
)
go_repository(
name = "com_github_google_martian",
importpath = "github.com/google/martian",
sum = "h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=",
version = "v2.1.0+incompatible",
)
go_repository(
name = "com_github_google_martian_v3",
importpath = "github.com/google/martian/v3",
sum = "h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ=",
version = "v3.2.1",
)
go_repository(
name = "com_github_google_pprof",
importpath = "github.com/google/pprof",
sum = "h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=",
version = "v0.0.0-20210720184732-4bb14d4b1be1",
)
go_repository(
name = "com_github_google_renameio",
importpath = "github.com/google/renameio",
sum = "h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=",
version = "v0.1.0",
)
go_repository(
name = "com_github_google_uuid",
importpath = "github.com/google/uuid",
sum = "h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=",
version = "v1.3.0",
)
go_repository(
name = "com_github_googleapis_gax_go_v2",
importpath = "github.com/googleapis/gax-go/v2",
sum = "h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU=",
version = "v2.1.1",
)
go_repository(
name = "com_github_gorilla_mux",
importpath = "github.com/gorilla/mux",
sum = "h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=",
version = "v1.8.0",
)
go_repository(
name = "com_github_grpc_ecosystem_go_grpc_prometheus",
importpath = "github.com/grpc-ecosystem/go-grpc-prometheus",
sum = "h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=",
version = "v1.2.0",
)
go_repository(
name = "com_github_grpc_ecosystem_grpc_gateway",
importpath = "github.com/grpc-ecosystem/grpc-gateway",
sum = "h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=",
version = "v1.16.0",
)
go_repository(
name = "com_github_hashicorp_golang_lru",
importpath = "github.com/hashicorp/golang-lru",
sum = "h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=",
version = "v0.5.1",
)
go_repository(
name = "com_github_hpcloud_tail",
importpath = "github.com/hpcloud/tail",
sum = "h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=",
version = "v1.0.0",
)
go_repository(
name = "com_github_ianlancetaylor_demangle",
importpath = "github.com/ianlancetaylor/demangle",
sum = "h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI=",
version = "v0.0.0-20200824232613-28f6c0f3b639",
)
go_repository(
name = "com_github_jpillora_backoff",
importpath = "github.com/jpillora/backoff",
sum = "h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=",
version = "v1.0.0",
)
go_repository(
name = "com_github_json_iterator_go",
importpath = "github.com/json-iterator/go",
sum = "h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=",
version = "v1.1.12",
)
go_repository(
name = "com_github_jstemmer_go_junit_report",
importpath = "github.com/jstemmer/go-junit-report",
sum = "h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=",
version = "v0.9.1",
)
go_repository(
name = "com_github_julienschmidt_httprouter",
importpath = "github.com/julienschmidt/httprouter",
sum = "h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=",
version = "v1.3.0",
)
go_repository(
name = "com_github_justinas_alice",
importpath = "github.com/justinas/alice",
sum = "h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo=",
version = "v1.2.0",
)
go_repository(
name = "com_github_kisielk_gotool",
importpath = "github.com/kisielk/gotool",
sum = "h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=",
version = "v1.0.0",
)
go_repository(
name = "com_github_klauspost_compress",
importpath = "github.com/klauspost/compress",
sum = "h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds=",
version = "v1.14.1",
)
go_repository(
name = "com_github_klauspost_cpuid",
importpath = "github.com/klauspost/cpuid",
sum = "h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s=",
version = "v1.3.1",
)
go_repository(
name = "com_github_klauspost_cpuid_v2",
importpath = "github.com/klauspost/cpuid/v2",
sum = "h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=",
version = "v2.0.9",
)
go_repository(
name = "com_github_konsorten_go_windows_terminal_sequences",
importpath = "github.com/konsorten/go-windows-terminal-sequences",
sum = "h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=",
version = "v1.0.3",
)
go_repository(
name = "com_github_kr_logfmt",
importpath = "github.com/kr/logfmt",
sum = "h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=",
version = "v0.0.0-20140226030751-b84e30acd515",
)
go_repository(
name = "com_github_kr_pretty",
importpath = "github.com/kr/pretty",
sum = "h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=",
version = "v0.3.0",
)
go_repository(
name = "com_github_kr_pty",
importpath = "github.com/kr/pty",
sum = "h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=",
version = "v1.1.1",
)
go_repository(
name = "com_github_kr_text",
importpath = "github.com/kr/text",
sum = "h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=",
version = "v0.2.0",
)
go_repository(
name = "com_github_labstack_echo_v4",
importpath = "github.com/labstack/echo/v4",
sum = "h1:OMVsrnNFzYlGSdaiYGHbgWQnr+JM7NG+B9suCPie14M=",
version = "v4.6.1",
)
go_repository(
name = "com_github_labstack_gommon",
importpath = "github.com/labstack/gommon",
sum = "h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=",
version = "v0.3.0",
)
go_repository(
name = "com_github_leodido_go_urn",
importpath = "github.com/leodido/go-urn",
sum = "h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=",
version = "v1.2.0",
)
go_repository(
name = "com_github_mattn_go_colorable",
importpath = "github.com/mattn/go-colorable",
sum = "h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=",
version = "v0.1.8",
)
go_repository(
name = "com_github_mattn_go_isatty",
importpath = "github.com/mattn/go-isatty",
sum = "h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=",
version = "v0.0.14",
)
go_repository(
name = "com_github_matttproud_golang_protobuf_extensions",
importpath = "github.com/matttproud/golang_protobuf_extensions",
sum = "h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=",
version = "v1.0.1",
)
go_repository(
name = "com_github_minio_md5_simd",
importpath = "github.com/minio/md5-simd",
sum = "h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=",
version = "v1.1.2",
)
go_repository(
name = "com_github_minio_minio_go_v7",
importpath = "github.com/minio/minio-go/v7",
sum = "h1:0+Xt1SkCKDgcx5cmo3UxXcJ37u5Gy+/2i/+eQYqmYJw=",
version = "v7.0.20",
)
go_repository(
name = "com_github_minio_sha256_simd",
importpath = "github.com/minio/sha256-simd",
sum = "h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=",
version = "v1.0.0",
)
go_repository(
name = "com_github_mitchellh_colorstring",
importpath = "github.com/mitchellh/colorstring",
sum = "h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=",
version = "v0.0.0-20190213212951-d06e56a500db",
)
go_repository(
name = "com_github_mitchellh_go_homedir",
importpath = "github.com/mitchellh/go-homedir",
sum = "h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=",
version = "v1.1.0",
)
go_repository(
name = "com_github_modern_go_concurrent",
importpath = "github.com/modern-go/concurrent",
sum = "h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=",
version = "v0.0.0-20180306012644-bacd9c7ef1dd",
)
go_repository(
name = "com_github_modern_go_reflect2",
importpath = "github.com/modern-go/reflect2",
sum = "h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=",
version = "v1.0.2",
)
go_repository(
name = "com_github_mostynb_go_grpc_compression",
importpath = "github.com/mostynb/go-grpc-compression",
sum = "h1:D9tGUINmcII049pxOj9dl32Fzhp26TrDVQXECoKJqQg=",
version = "v1.1.16",
)
go_repository(
name = "com_github_mostynb_zstdpool_syncpool",
importpath = "github.com/mostynb/zstdpool-syncpool",
sum = "h1:vE8zD0+YdQD9Rca0TAGNexUCOCt1IQbdqRUHJoxxERA=",
version = "v0.0.12",
)
go_repository(
name = "com_github_mwitkow_go_conntrack",
importpath = "github.com/mwitkow/go-conntrack",
sum = "h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=",
version = "v0.0.0-20190716064945-2f068394615f",
)
go_repository(
name = "com_github_oneofone_xxhash",
importpath = "github.com/OneOfOne/xxhash",
sum = "h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=",
version = "v1.2.2",
)
go_repository(
name = "com_github_onsi_ginkgo",
importpath = "github.com/onsi/ginkgo",
sum = "h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=",
version = "v1.8.0",
)
go_repository(
name = "com_github_onsi_gomega",
importpath = "github.com/onsi/gomega",
sum = "h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=",
version = "v1.5.0",
)
go_repository(
name = "com_github_pierrec_cmdflag",
importpath = "github.com/pierrec/cmdflag",
sum = "h1:ybjGJnPr/aURn2IKWjO49znx9N0DL6YfGsIxN0PYuVY=",
version = "v0.0.2",
)
go_repository(
name = "com_github_pierrec_lz4_v3",
importpath = "github.com/pierrec/lz4/v3",
sum = "h1:fqXL+KOc232xP6JgmKMp22fd+gn8/RFZjTreqbbqExc=",
version = "v3.3.4",
)
go_repository(
name = "com_github_pkg_errors",
importpath = "github.com/pkg/errors",
sum = "h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=",
version = "v0.9.1",
)
go_repository(
name = "com_github_pmezard_go_difflib",
importpath = "github.com/pmezard/go-difflib",
sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=",
version = "v1.0.0",
)
go_repository(
name = "com_github_prometheus_client_golang",
importpath = "github.com/prometheus/client_golang",
sum = "h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ=",
version = "v1.11.0",
)
go_repository(
name = "com_github_prometheus_client_model",
importpath = "github.com/prometheus/client_model",
sum = "h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=",
version = "v0.2.0",
)
go_repository(
name = "com_github_prometheus_common",
importpath = "github.com/prometheus/common",
sum = "h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=",
version = "v0.32.1",
)
go_repository(
name = "com_github_prometheus_procfs",
importpath = "github.com/prometheus/procfs",
sum = "h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=",
version = "v0.7.3",
)
go_repository(
name = "com_github_prometheus_statsd_exporter",
importpath = "github.com/prometheus/statsd_exporter",
sum = "h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8=",
version = "v0.21.0",
)
go_repository(
name = "com_github_rogpeppe_fastuuid",
importpath = "github.com/rogpeppe/fastuuid",
sum = "h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=",
version = "v1.2.0",
)
go_repository(
name = "com_github_rogpeppe_go_internal",
importpath = "github.com/rogpeppe/go-internal",
sum = "h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=",
version = "v1.6.1",
)
go_repository(
name = "com_github_rs_xid",
importpath = "github.com/rs/xid",
sum = "h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4=",
version = "v1.3.0",
)
go_repository(
name = "com_github_russross_blackfriday_v2",
importpath = "github.com/russross/blackfriday/v2",
sum = "h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=",
version = "v2.1.0",
)
go_repository(
name = "com_github_savsgio_gotils",
importpath = "github.com/savsgio/gotils",
sum = "h1:ocK/D6lCgLji37Z2so4xhMl46se1ntReQQCUIU4BWI8=",
version = "v0.0.0-20210921075833-21a6215cb0e4",
)
go_repository(
name = "com_github_schollz_progressbar_v2",
importpath = "github.com/schollz/progressbar/v2",
sum = "h1:3L9bP5KQOGEnFP8P5V8dz+U0yo5I29iY5Oa9s9EAwn0=",
version = "v2.13.2",
)
go_repository(
name = "com_github_shurcool_sanitized_anchor_name",
importpath = "github.com/shurcooL/sanitized_anchor_name",
sum = "h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=",
version = "v1.0.0",
)
go_repository(
name = "com_github_sirupsen_logrus",
importpath = "github.com/sirupsen/logrus",
sum = "h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=",
version = "v1.8.1",
)
go_repository(
name = "com_github_slok_go_http_metrics",
importpath = "github.com/slok/go-http-metrics",
sum = "h1:rh0LaYEKza5eaYRGDXujKrOln57nHBi4TtVhmNEpbgM=",
version = "v0.10.0",
)
go_repository(
name = "com_github_smartystreets_goconvey",
importpath = "github.com/smartystreets/goconvey",
sum = "h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=",
version = "v1.6.4",
)
go_repository(
name = "com_github_spaolacci_murmur3",
importpath = "github.com/spaolacci/murmur3",
sum = "h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=",
version = "v0.0.0-20180118202830-f09979ecbc72",
)
go_repository(
name = "com_github_stretchr_objx",
importpath = "github.com/stretchr/objx",
sum = "h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=",
version = "v0.1.1",
)
go_repository(
name = "com_github_stretchr_testify",
importpath = "github.com/stretchr/testify",
sum = "h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=",
version = "v1.7.0",
)
go_repository(
name = "com_github_ugorji_go_codec",
importpath = "github.com/ugorji/go/codec",
sum = "h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=",
version = "v1.1.7",
)
go_repository(
name = "com_github_urfave_cli_v2",
importpath = "github.com/urfave/cli/v2",
sum = "h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=",
version = "v2.3.0",
)
go_repository(
name = "com_github_urfave_negroni",
importpath = "github.com/urfave/negroni",
sum = "h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=",
version = "v1.0.0",
)
go_repository(
name = "com_github_valyala_bytebufferpool",
importpath = "github.com/valyala/bytebufferpool",
sum = "h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=",
version = "v1.0.0",
)
go_repository(
name = "com_github_valyala_fasthttp",
importpath = "github.com/valyala/fasthttp",
sum = "h1:lrauRLII19afgCs2fnWRJ4M5IkV0lo2FqA61uGkNBfE=",
version = "v1.31.0",
)
go_repository(
name = "com_github_valyala_fasttemplate",
importpath = "github.com/valyala/fasttemplate",
sum = "h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=",
version = "v1.2.1",
)
go_repository(
name = "com_github_yuin_goldmark",
importpath = "github.com/yuin/goldmark",
sum = "h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs=",
version = "v1.3.5",
)
go_repository(
name = "com_google_cloud_go",
importpath = "cloud.google.com/go",
sum = "h1:y/cM2iqGgGi5D5DQZl6D9STN/3dR/Vx5Mp8s752oJTY=",
version = "v0.99.0",
)
go_repository(
name = "com_google_cloud_go_bigquery",
importpath = "cloud.google.com/go/bigquery",
sum = "h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA=",
version = "v1.8.0",
)
go_repository(
name = "com_google_cloud_go_datastore",
importpath = "cloud.google.com/go/datastore",
sum = "h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ=",
version = "v1.1.0",
)
go_repository(
name = "com_google_cloud_go_pubsub",
importpath = "cloud.google.com/go/pubsub",
sum = "h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU=",
version = "v1.3.1",
)
go_repository(
name = "com_google_cloud_go_storage",
importpath = "cloud.google.com/go/storage",
sum = "h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA=",
version = "v1.10.0",
)
go_repository(
name = "com_shuralyov_dmitri_gpu_mtl",
importpath = "dmitri.shuralyov.com/gpu/mtl",
sum = "h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=",
version = "v0.0.0-20190408044501-666a987793e9",
)
go_repository(
name = "in_gopkg_alecthomas_kingpin_v2",
importpath = "gopkg.in/alecthomas/kingpin.v2",
sum = "h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=",
version = "v2.2.6",
)
go_repository(
name = "in_gopkg_check_v1",
importpath = "gopkg.in/check.v1",
sum = "h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=",
version = "v1.0.0-20190902080502-41f04d3bba15",
)
go_repository(
name = "in_gopkg_errgo_v2",
importpath = "gopkg.in/errgo.v2",
sum = "h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=",
version = "v2.1.0",
)
go_repository(
name = "in_gopkg_fsnotify_v1",
importpath = "gopkg.in/fsnotify.v1",
sum = "h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=",
version = "v1.4.7",
)
go_repository(
name = "in_gopkg_ini_v1",
importpath = "gopkg.in/ini.v1",
sum = "h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=",
version = "v1.66.2",
)
go_repository(
name = "in_gopkg_tomb_v1",
importpath = "gopkg.in/tomb.v1",
sum = "h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=",
version = "v1.0.0-20141024135613-dd632973f1e7",
)
go_repository(
name = "in_gopkg_yaml_v2",
importpath = "gopkg.in/yaml.v2",
sum = "h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=",
version = "v2.4.0",
)
go_repository(
name = "in_gopkg_yaml_v3",
importpath = "gopkg.in/yaml.v3",
sum = "h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=",
version = "v3.0.0-20200313102051-9f266ea9e77c",
)
go_repository(
name = "io_goji",
importpath = "goji.io",
sum = "h1:uIssv/elbKRLznFUy3Xj4+2Mz/qKhek/9aZQDUMae7c=",
version = "v2.0.2+incompatible",
)
go_repository(
name = "io_opencensus_go",
importpath = "go.opencensus.io",
sum = "h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=",
version = "v0.23.0",
)
go_repository(
name = "io_opencensus_go_contrib_exporter_prometheus",
importpath = "contrib.go.opencensus.io/exporter/prometheus",
sum = "h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs=",
version = "v0.4.0",
)
go_repository(
name = "io_opentelemetry_go_proto_otlp",
importpath = "go.opentelemetry.io/proto/otlp",
sum = "h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8=",
version = "v0.7.0",
)
go_repository(
name = "io_rsc_binaryregexp",
importpath = "rsc.io/binaryregexp",
sum = "h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=",
version = "v0.2.0",
)
go_repository(
name = "io_rsc_quote_v3",
importpath = "rsc.io/quote/v3",
sum = "h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=",
version = "v3.1.0",
)
go_repository(
name = "io_rsc_sampler",
importpath = "rsc.io/sampler",
sum = "h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=",
version = "v1.3.0",
)
go_repository(
name = "org_cloudfoundry_code_bytefmt",
importpath = "code.cloudfoundry.org/bytefmt",
sum = "h1:tW+ztA4A9UT9xnco5wUjW1oNi35k22eUEn9tNpPYVwE=",
version = "v0.0.0-20190710193110-1eb035ffe2b6",
)
go_repository(
name = "org_golang_google_api",
importpath = "google.golang.org/api",
sum = "h1:TXXKS1slM3b2bZNJwD5DV/Tp6/M2cLzLOLh9PjDhrw8=",
version = "v0.61.0",
)
go_repository(
name = "org_golang_google_appengine",
importpath = "google.golang.org/appengine",
sum = "h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=",
version = "v1.6.7",
)
go_repository(
name = "org_golang_google_genproto",
importpath = "google.golang.org/genproto",
sum = "h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw=",
version = "v0.0.0-20211223182754-3ac035c7e7cb",
)
go_repository(
name = "org_golang_google_grpc",
importpath = "google.golang.org/grpc",
sum = "h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM=",
version = "v1.43.0",
)
go_repository(
name = "org_golang_google_grpc_cmd_protoc_gen_go_grpc",
importpath = "google.golang.org/grpc/cmd/protoc-gen-go-grpc",
sum = "h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE=",
version = "v1.1.0",
)
go_repository(
name = "org_golang_google_protobuf",
importpath = "google.golang.org/protobuf",
sum = "h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=",
version = "v1.27.1",
)
go_repository(
name = "org_golang_x_crypto",
importpath = "golang.org/x/crypto",
sum = "h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=",
version = "v0.0.0-20211215153901-e495a2d5b3d3",
)
go_repository(
name = "org_golang_x_exp",
importpath = "golang.org/x/exp",
sum = "h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y=",
version = "v0.0.0-20200224162631-6cc2880d07d6",
)
go_repository(
name = "org_golang_x_image",
importpath = "golang.org/x/image",
sum = "h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=",
version = "v0.0.0-20190802002840-cff245a6509b",
)
go_repository(
name = "org_golang_x_lint",
importpath = "golang.org/x/lint",
sum = "h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=",
version = "v0.0.0-20210508222113-6edffad5e616",
)
go_repository(
name = "org_golang_x_mobile",
importpath = "golang.org/x/mobile",
sum = "h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs=",
version = "v0.0.0-20190719004257-d2bd2a29d028",
)
go_repository(
name = "org_golang_x_mod",
importpath = "golang.org/x/mod",
sum = "h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=",
version = "v0.4.2",
)
go_repository(
name = "org_golang_x_net",
importpath = "golang.org/x/net",
sum = "h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=",
version = "v0.0.0-20211216030914-fe4d6282115f",
)
go_repository(
name = "org_golang_x_oauth2",
importpath = "golang.org/x/oauth2",
sum = "h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg=",
version = "v0.0.0-20211104180415-d3ed0bb246c8",
)
go_repository(
name = "org_golang_x_sync",
importpath = "golang.org/x/sync",
sum = "h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=",
version = "v0.0.0-20210220032951-036812b2e83c",
)
go_repository(
name = "org_golang_x_sys",
importpath = "golang.org/x/sys",
sum = "h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=",
version = "v0.0.0-20211216021012-1d35b9e2eb4e",
)
go_repository(
name = "org_golang_x_term",
importpath = "golang.org/x/term",
sum = "h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=",
version = "v0.0.0-20201126162022-7de9c90e9dd1",
)
go_repository(
name = "org_golang_x_text",
importpath = "golang.org/x/text",
sum = "h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=",
version = "v0.3.7",
)
go_repository(
name = "org_golang_x_time",
importpath = "golang.org/x/time",
sum = "h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=",
version = "v0.0.0-20191024005414-555d28b269f0",
)
go_repository(
name = "org_golang_x_tools",
importpath = "golang.org/x/tools",
sum = "h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=",
version = "v0.1.5",
)
go_repository(
name = "org_golang_x_xerrors",
importpath = "golang.org/x/xerrors",
sum = "h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=",
version = "v0.0.0-20200804184101-5ec99f83aff1",
)
| """
Code generated from go.sum by //:gazelle-update-repos
"""
load('@bazel_gazelle//:deps.bzl', 'go_repository')
def go_dependencies():
"""
Managed by gazelle. Add "# keep" comment to modified lines.
"""
go_repository(name='co_honnef_go_tools', importpath='honnef.co/go/tools', sum='h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=', version='v0.0.1-2020.1.4')
go_repository(name='com_github_abbot_go_http_auth', importpath='github.com/abbot/go-http-auth', sum='h1:9ZqcMQ0fB+ywKACVjGfZM4C7Uq9D5rq0iSmwIjX187k=', version='v0.4.1-0.20181019201920-860ed7f246ff')
go_repository(name='com_github_alecthomas_template', importpath='github.com/alecthomas/template', sum='h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=', version='v0.0.0-20190718012654-fb15b899a751')
go_repository(name='com_github_alecthomas_units', importpath='github.com/alecthomas/units', sum='h1:UQZhZ2O0vMHr2cI+DC1Mbh0TJxzA3RcLoMsFw+aXw7E=', version='v0.0.0-20190924025748-f65c72e2690d')
go_repository(name='com_github_andybalholm_brotli', importpath='github.com/andybalholm/brotli', sum='h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E=', version='v1.0.2')
go_repository(name='com_github_antihax_optional', importpath='github.com/antihax/optional', sum='h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg=', version='v1.0.0')
go_repository(name='com_github_beorn7_perks', importpath='github.com/beorn7/perks', sum='h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=', version='v1.0.1')
go_repository(name='com_github_burntsushi_toml', importpath='github.com/BurntSushi/toml', sum='h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=', version='v0.3.1')
go_repository(name='com_github_burntsushi_xgb', importpath='github.com/BurntSushi/xgb', sum='h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc=', version='v0.0.0-20160522181843-27f122750802')
go_repository(name='com_github_census_instrumentation_opencensus_proto', importpath='github.com/census-instrumentation/opencensus-proto', sum='h1:glEXhBS5PSLLv4IXzLA5yPRVX4bilULVyxxbrfOtDAk=', version='v0.2.1')
go_repository(name='com_github_cespare_xxhash', importpath='github.com/cespare/xxhash', sum='h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=', version='v1.1.0')
go_repository(name='com_github_cespare_xxhash_v2', importpath='github.com/cespare/xxhash/v2', sum='h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=', version='v2.1.2')
go_repository(name='com_github_chzyer_logex', importpath='github.com/chzyer/logex', sum='h1:Swpa1K6QvQznwJRcfTfQJmTE72DqScAa40E+fbHEXEE=', version='v1.1.10')
go_repository(name='com_github_chzyer_readline', importpath='github.com/chzyer/readline', sum='h1:fY5BOSpyZCqRo5OhCuC+XN+r/bBCmeuuJtjz+bCNIf8=', version='v0.0.0-20180603132655-2972be24d48e')
go_repository(name='com_github_chzyer_test', importpath='github.com/chzyer/test', sum='h1:q763qf9huN11kDQavWsoZXJNW3xEE4JJyHa5Q25/sd8=', version='v0.0.0-20180213035817-a1ea475d72b1')
go_repository(name='com_github_client9_misspell', importpath='github.com/client9/misspell', sum='h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=', version='v0.3.4')
go_repository(name='com_github_cncf_udpa_go', importpath='github.com/cncf/udpa/go', sum='h1:hzAQntlaYRkVSFEfj9OTWlVV1H155FMD8BTKktLv0QI=', version='v0.0.0-20210930031921-04548b0d99d4')
go_repository(name='com_github_cncf_xds_go', importpath='github.com/cncf/xds/go', sum='h1:zH8ljVhhq7yC0MIeUL/IviMtY8hx2mK8cN9wEYb8ggw=', version='v0.0.0-20211011173535-cb28da3451f1')
go_repository(name='com_github_cpuguy83_go_md2man_v2', importpath='github.com/cpuguy83/go-md2man/v2', sum='h1:r/myEWzV9lfsM1tFLgDyu0atFtJ1fXn261LKYj/3DxU=', version='v2.0.1')
go_repository(name='com_github_creack_pty', importpath='github.com/creack/pty', sum='h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w=', version='v1.1.9')
go_repository(name='com_github_davecgh_go_spew', importpath='github.com/davecgh/go-spew', sum='h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=', version='v1.1.1')
go_repository(name='com_github_djherbis_atime', importpath='github.com/djherbis/atime', sum='h1:rgwVbP/5by8BvvjBNrbh64Qz33idKT3pSnMSJsxhi0g=', version='v1.1.0')
go_repository(name='com_github_dustin_go_humanize', importpath='github.com/dustin/go-humanize', sum='h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=', version='v1.0.0')
go_repository(name='com_github_emicklei_go_restful_v3', importpath='github.com/emicklei/go-restful/v3', sum='h1:R5iagkkTsfFpe1nce6Yniw3wmSx0Qw5YP469YzRFNEs=', version='v3.7.1')
go_repository(name='com_github_envoyproxy_go_control_plane', importpath='github.com/envoyproxy/go-control-plane', sum='h1:fP+fF0up6oPY49OrjPrhIJ8yQfdIM85NXMLkMg1EXVs=', version='v0.9.10-0.20210907150352-cf90f659a021')
go_repository(name='com_github_envoyproxy_protoc_gen_validate', importpath='github.com/envoyproxy/protoc-gen-validate', sum='h1:EQciDnbrYxy13PgWoY8AqoxGiPrpgBZ1R8UNe3ddc+A=', version='v0.1.0')
go_repository(name='com_github_fasthttp_router', importpath='github.com/fasthttp/router', sum='h1:Z025tHFTjDp6T6QMBjloyGL6KV5wtakW365K/7KiE1c=', version='v1.4.4')
go_repository(name='com_github_frankban_quicktest', importpath='github.com/frankban/quicktest', sum='h1:+cqqvzZV87b4adx/5ayVOaYZ2CrvM4ejQvUdBzPPUss=', version='v1.14.0')
go_repository(name='com_github_fsnotify_fsnotify', importpath='github.com/fsnotify/fsnotify', sum='h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=', version='v1.4.7')
go_repository(name='com_github_ghodss_yaml', importpath='github.com/ghodss/yaml', sum='h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=', version='v1.0.0')
go_repository(name='com_github_gin_contrib_sse', importpath='github.com/gin-contrib/sse', sum='h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=', version='v0.1.0')
go_repository(name='com_github_gin_gonic_gin', importpath='github.com/gin-gonic/gin', sum='h1:QmUZXrvJ9qZ3GfWvQ+2wnW/1ePrTEJqPKMYEU3lD/DM=', version='v1.7.4')
go_repository(name='com_github_go_chi_chi', importpath='github.com/go-chi/chi', sum='h1:fGFk2Gmi/YKXk0OmGfBh0WgmN3XB8lVnEyNz34tQRec=', version='v4.1.2+incompatible')
go_repository(name='com_github_go_gl_glfw', importpath='github.com/go-gl/glfw', sum='h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0=', version='v0.0.0-20190409004039-e6da0acd62b1')
go_repository(name='com_github_go_gl_glfw_v3_3_glfw', importpath='github.com/go-gl/glfw/v3.3/glfw', sum='h1:WtGNWLvXpe6ZudgnXrq0barxBImvnnJoMEhXAzcbM0I=', version='v0.0.0-20200222043503-6f7a984d4dc4')
go_repository(name='com_github_go_kit_kit', importpath='github.com/go-kit/kit', sum='h1:wDJmvq38kDhkVxi50ni9ykkdUr1PKgqKOoi01fa0Mdk=', version='v0.9.0')
go_repository(name='com_github_go_kit_log', importpath='github.com/go-kit/log', sum='h1:DGJh0Sm43HbOeYDNnVZFl8BvcYVvjD5bqYJvp0REbwQ=', version='v0.1.0')
go_repository(name='com_github_go_logfmt_logfmt', importpath='github.com/go-logfmt/logfmt', sum='h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4=', version='v0.5.0')
go_repository(name='com_github_go_playground_locales', importpath='github.com/go-playground/locales', sum='h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q=', version='v0.13.0')
go_repository(name='com_github_go_playground_universal_translator', importpath='github.com/go-playground/universal-translator', sum='h1:icxd5fm+REJzpZx7ZfpaD876Lmtgy7VtROAbHHXk8no=', version='v0.17.0')
go_repository(name='com_github_go_playground_validator_v10', importpath='github.com/go-playground/validator/v10', sum='h1:pH2c5ADXtd66mxoE0Zm9SUhxE20r7aM3F26W0hOn+GE=', version='v10.4.1')
go_repository(name='com_github_go_stack_stack', importpath='github.com/go-stack/stack', sum='h1:5SgMzNM5HxrEjV0ww2lTmX6E2Izsfxas4+YHWRs3Lsk=', version='v1.8.0')
go_repository(name='com_github_gogo_protobuf', importpath='github.com/gogo/protobuf', sum='h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=', version='v1.1.1')
go_repository(name='com_github_golang_glog', importpath='github.com/golang/glog', sum='h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=', version='v0.0.0-20160126235308-23def4e6c14b')
go_repository(name='com_github_golang_groupcache', importpath='github.com/golang/groupcache', sum='h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=', version='v0.0.0-20210331224755-41bb18bfe9da')
go_repository(name='com_github_golang_mock', importpath='github.com/golang/mock', sum='h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc=', version='v1.6.0')
go_repository(name='com_github_golang_protobuf', importpath='github.com/golang/protobuf', sum='h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=', version='v1.5.2')
go_repository(name='com_github_golang_snappy', importpath='github.com/golang/snappy', sum='h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=', version='v0.0.4')
go_repository(name='com_github_google_btree', importpath='github.com/google/btree', sum='h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo=', version='v1.0.0')
go_repository(name='com_github_google_go_cmp', importpath='github.com/google/go-cmp', sum='h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=', version='v0.5.6')
go_repository(name='com_github_google_gofuzz', importpath='github.com/google/gofuzz', sum='h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw=', version='v1.0.0')
go_repository(name='com_github_google_martian', importpath='github.com/google/martian', sum='h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=', version='v2.1.0+incompatible')
go_repository(name='com_github_google_martian_v3', importpath='github.com/google/martian/v3', sum='h1:d8MncMlErDFTwQGBK1xhv026j9kqhvw1Qv9IbWT1VLQ=', version='v3.2.1')
go_repository(name='com_github_google_pprof', importpath='github.com/google/pprof', sum='h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec=', version='v0.0.0-20210720184732-4bb14d4b1be1')
go_repository(name='com_github_google_renameio', importpath='github.com/google/renameio', sum='h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA=', version='v0.1.0')
go_repository(name='com_github_google_uuid', importpath='github.com/google/uuid', sum='h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=', version='v1.3.0')
go_repository(name='com_github_googleapis_gax_go_v2', importpath='github.com/googleapis/gax-go/v2', sum='h1:dp3bWCh+PPO1zjRRiCSczJav13sBvG4UhNyVTa1KqdU=', version='v2.1.1')
go_repository(name='com_github_gorilla_mux', importpath='github.com/gorilla/mux', sum='h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=', version='v1.8.0')
go_repository(name='com_github_grpc_ecosystem_go_grpc_prometheus', importpath='github.com/grpc-ecosystem/go-grpc-prometheus', sum='h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho=', version='v1.2.0')
go_repository(name='com_github_grpc_ecosystem_grpc_gateway', importpath='github.com/grpc-ecosystem/grpc-gateway', sum='h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo=', version='v1.16.0')
go_repository(name='com_github_hashicorp_golang_lru', importpath='github.com/hashicorp/golang-lru', sum='h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU=', version='v0.5.1')
go_repository(name='com_github_hpcloud_tail', importpath='github.com/hpcloud/tail', sum='h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=', version='v1.0.0')
go_repository(name='com_github_ianlancetaylor_demangle', importpath='github.com/ianlancetaylor/demangle', sum='h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI=', version='v0.0.0-20200824232613-28f6c0f3b639')
go_repository(name='com_github_jpillora_backoff', importpath='github.com/jpillora/backoff', sum='h1:uvFg412JmmHBHw7iwprIxkPMI+sGQ4kzOWsMeHnm2EA=', version='v1.0.0')
go_repository(name='com_github_json_iterator_go', importpath='github.com/json-iterator/go', sum='h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=', version='v1.1.12')
go_repository(name='com_github_jstemmer_go_junit_report', importpath='github.com/jstemmer/go-junit-report', sum='h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o=', version='v0.9.1')
go_repository(name='com_github_julienschmidt_httprouter', importpath='github.com/julienschmidt/httprouter', sum='h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=', version='v1.3.0')
go_repository(name='com_github_justinas_alice', importpath='github.com/justinas/alice', sum='h1:+MHSA/vccVCF4Uq37S42jwlkvI2Xzl7zTPCN5BnZNVo=', version='v1.2.0')
go_repository(name='com_github_kisielk_gotool', importpath='github.com/kisielk/gotool', sum='h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=', version='v1.0.0')
go_repository(name='com_github_klauspost_compress', importpath='github.com/klauspost/compress', sum='h1:hLQYb23E8/fO+1u53d02A97a8UnsddcvYzq4ERRU4ds=', version='v1.14.1')
go_repository(name='com_github_klauspost_cpuid', importpath='github.com/klauspost/cpuid', sum='h1:5JNjFYYQrZeKRJ0734q51WCEEn2huer72Dc7K+R/b6s=', version='v1.3.1')
go_repository(name='com_github_klauspost_cpuid_v2', importpath='github.com/klauspost/cpuid/v2', sum='h1:lgaqFMSdTdQYdZ04uHyN2d/eKdOMyi2YLSvlQIBFYa4=', version='v2.0.9')
go_repository(name='com_github_konsorten_go_windows_terminal_sequences', importpath='github.com/konsorten/go-windows-terminal-sequences', sum='h1:CE8S1cTafDpPvMhIxNJKvHsGVBgn1xWYf1NbHQhywc8=', version='v1.0.3')
go_repository(name='com_github_kr_logfmt', importpath='github.com/kr/logfmt', sum='h1:T+h1c/A9Gawja4Y9mFVWj2vyii2bbUNDw3kt9VxK2EY=', version='v0.0.0-20140226030751-b84e30acd515')
go_repository(name='com_github_kr_pretty', importpath='github.com/kr/pretty', sum='h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=', version='v0.3.0')
go_repository(name='com_github_kr_pty', importpath='github.com/kr/pty', sum='h1:VkoXIwSboBpnk99O/KFauAEILuNHv5DVFKZMBN/gUgw=', version='v1.1.1')
go_repository(name='com_github_kr_text', importpath='github.com/kr/text', sum='h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=', version='v0.2.0')
go_repository(name='com_github_labstack_echo_v4', importpath='github.com/labstack/echo/v4', sum='h1:OMVsrnNFzYlGSdaiYGHbgWQnr+JM7NG+B9suCPie14M=', version='v4.6.1')
go_repository(name='com_github_labstack_gommon', importpath='github.com/labstack/gommon', sum='h1:JEeO0bvc78PKdyHxloTKiF8BD5iGrH8T6MSeGvSgob0=', version='v0.3.0')
go_repository(name='com_github_leodido_go_urn', importpath='github.com/leodido/go-urn', sum='h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=', version='v1.2.0')
go_repository(name='com_github_mattn_go_colorable', importpath='github.com/mattn/go-colorable', sum='h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=', version='v0.1.8')
go_repository(name='com_github_mattn_go_isatty', importpath='github.com/mattn/go-isatty', sum='h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=', version='v0.0.14')
go_repository(name='com_github_matttproud_golang_protobuf_extensions', importpath='github.com/matttproud/golang_protobuf_extensions', sum='h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=', version='v1.0.1')
go_repository(name='com_github_minio_md5_simd', importpath='github.com/minio/md5-simd', sum='h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=', version='v1.1.2')
go_repository(name='com_github_minio_minio_go_v7', importpath='github.com/minio/minio-go/v7', sum='h1:0+Xt1SkCKDgcx5cmo3UxXcJ37u5Gy+/2i/+eQYqmYJw=', version='v7.0.20')
go_repository(name='com_github_minio_sha256_simd', importpath='github.com/minio/sha256-simd', sum='h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=', version='v1.0.0')
go_repository(name='com_github_mitchellh_colorstring', importpath='github.com/mitchellh/colorstring', sum='h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ=', version='v0.0.0-20190213212951-d06e56a500db')
go_repository(name='com_github_mitchellh_go_homedir', importpath='github.com/mitchellh/go-homedir', sum='h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=', version='v1.1.0')
go_repository(name='com_github_modern_go_concurrent', importpath='github.com/modern-go/concurrent', sum='h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=', version='v0.0.0-20180306012644-bacd9c7ef1dd')
go_repository(name='com_github_modern_go_reflect2', importpath='github.com/modern-go/reflect2', sum='h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=', version='v1.0.2')
go_repository(name='com_github_mostynb_go_grpc_compression', importpath='github.com/mostynb/go-grpc-compression', sum='h1:D9tGUINmcII049pxOj9dl32Fzhp26TrDVQXECoKJqQg=', version='v1.1.16')
go_repository(name='com_github_mostynb_zstdpool_syncpool', importpath='github.com/mostynb/zstdpool-syncpool', sum='h1:vE8zD0+YdQD9Rca0TAGNexUCOCt1IQbdqRUHJoxxERA=', version='v0.0.12')
go_repository(name='com_github_mwitkow_go_conntrack', importpath='github.com/mwitkow/go-conntrack', sum='h1:KUppIJq7/+SVif2QVs3tOP0zanoHgBEVAwHxUSIzRqU=', version='v0.0.0-20190716064945-2f068394615f')
go_repository(name='com_github_oneofone_xxhash', importpath='github.com/OneOfOne/xxhash', sum='h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=', version='v1.2.2')
go_repository(name='com_github_onsi_ginkgo', importpath='github.com/onsi/ginkgo', sum='h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w=', version='v1.8.0')
go_repository(name='com_github_onsi_gomega', importpath='github.com/onsi/gomega', sum='h1:izbySO9zDPmjJ8rDjLvkA2zJHIo+HkYXHnf7eN7SSyo=', version='v1.5.0')
go_repository(name='com_github_pierrec_cmdflag', importpath='github.com/pierrec/cmdflag', sum='h1:ybjGJnPr/aURn2IKWjO49znx9N0DL6YfGsIxN0PYuVY=', version='v0.0.2')
go_repository(name='com_github_pierrec_lz4_v3', importpath='github.com/pierrec/lz4/v3', sum='h1:fqXL+KOc232xP6JgmKMp22fd+gn8/RFZjTreqbbqExc=', version='v3.3.4')
go_repository(name='com_github_pkg_errors', importpath='github.com/pkg/errors', sum='h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=', version='v0.9.1')
go_repository(name='com_github_pmezard_go_difflib', importpath='github.com/pmezard/go-difflib', sum='h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=', version='v1.0.0')
go_repository(name='com_github_prometheus_client_golang', importpath='github.com/prometheus/client_golang', sum='h1:HNkLOAEQMIDv/K+04rukrLx6ch7msSRwf3/SASFAGtQ=', version='v1.11.0')
go_repository(name='com_github_prometheus_client_model', importpath='github.com/prometheus/client_model', sum='h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=', version='v0.2.0')
go_repository(name='com_github_prometheus_common', importpath='github.com/prometheus/common', sum='h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4=', version='v0.32.1')
go_repository(name='com_github_prometheus_procfs', importpath='github.com/prometheus/procfs', sum='h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU=', version='v0.7.3')
go_repository(name='com_github_prometheus_statsd_exporter', importpath='github.com/prometheus/statsd_exporter', sum='h1:hA05Q5RFeIjgwKIYEdFd59xu5Wwaznf33yKI+pyX6T8=', version='v0.21.0')
go_repository(name='com_github_rogpeppe_fastuuid', importpath='github.com/rogpeppe/fastuuid', sum='h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s=', version='v1.2.0')
go_repository(name='com_github_rogpeppe_go_internal', importpath='github.com/rogpeppe/go-internal', sum='h1:/FiVV8dS/e+YqF2JvO3yXRFbBLTIuSDkuC7aBOAvL+k=', version='v1.6.1')
go_repository(name='com_github_rs_xid', importpath='github.com/rs/xid', sum='h1:6NjYksEUlhurdVehpc7S7dk6DAmcKv8V9gG0FsVN2U4=', version='v1.3.0')
go_repository(name='com_github_russross_blackfriday_v2', importpath='github.com/russross/blackfriday/v2', sum='h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=', version='v2.1.0')
go_repository(name='com_github_savsgio_gotils', importpath='github.com/savsgio/gotils', sum='h1:ocK/D6lCgLji37Z2so4xhMl46se1ntReQQCUIU4BWI8=', version='v0.0.0-20210921075833-21a6215cb0e4')
go_repository(name='com_github_schollz_progressbar_v2', importpath='github.com/schollz/progressbar/v2', sum='h1:3L9bP5KQOGEnFP8P5V8dz+U0yo5I29iY5Oa9s9EAwn0=', version='v2.13.2')
go_repository(name='com_github_shurcool_sanitized_anchor_name', importpath='github.com/shurcooL/sanitized_anchor_name', sum='h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=', version='v1.0.0')
go_repository(name='com_github_sirupsen_logrus', importpath='github.com/sirupsen/logrus', sum='h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=', version='v1.8.1')
go_repository(name='com_github_slok_go_http_metrics', importpath='github.com/slok/go-http-metrics', sum='h1:rh0LaYEKza5eaYRGDXujKrOln57nHBi4TtVhmNEpbgM=', version='v0.10.0')
go_repository(name='com_github_smartystreets_goconvey', importpath='github.com/smartystreets/goconvey', sum='h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=', version='v1.6.4')
go_repository(name='com_github_spaolacci_murmur3', importpath='github.com/spaolacci/murmur3', sum='h1:qLC7fQah7D6K1B0ujays3HV9gkFtllcxhzImRR7ArPQ=', version='v0.0.0-20180118202830-f09979ecbc72')
go_repository(name='com_github_stretchr_objx', importpath='github.com/stretchr/objx', sum='h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=', version='v0.1.1')
go_repository(name='com_github_stretchr_testify', importpath='github.com/stretchr/testify', sum='h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=', version='v1.7.0')
go_repository(name='com_github_ugorji_go_codec', importpath='github.com/ugorji/go/codec', sum='h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=', version='v1.1.7')
go_repository(name='com_github_urfave_cli_v2', importpath='github.com/urfave/cli/v2', sum='h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M=', version='v2.3.0')
go_repository(name='com_github_urfave_negroni', importpath='github.com/urfave/negroni', sum='h1:kIimOitoypq34K7TG7DUaJ9kq/N4Ofuwi1sjz0KipXc=', version='v1.0.0')
go_repository(name='com_github_valyala_bytebufferpool', importpath='github.com/valyala/bytebufferpool', sum='h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=', version='v1.0.0')
go_repository(name='com_github_valyala_fasthttp', importpath='github.com/valyala/fasthttp', sum='h1:lrauRLII19afgCs2fnWRJ4M5IkV0lo2FqA61uGkNBfE=', version='v1.31.0')
go_repository(name='com_github_valyala_fasttemplate', importpath='github.com/valyala/fasttemplate', sum='h1:TVEnxayobAdVkhQfrfes2IzOB6o+z4roRkPF52WA1u4=', version='v1.2.1')
go_repository(name='com_github_yuin_goldmark', importpath='github.com/yuin/goldmark', sum='h1:dPmz1Snjq0kmkz159iL7S6WzdahUTHnHB5M56WFVifs=', version='v1.3.5')
go_repository(name='com_google_cloud_go', importpath='cloud.google.com/go', sum='h1:y/cM2iqGgGi5D5DQZl6D9STN/3dR/Vx5Mp8s752oJTY=', version='v0.99.0')
go_repository(name='com_google_cloud_go_bigquery', importpath='cloud.google.com/go/bigquery', sum='h1:PQcPefKFdaIzjQFbiyOgAqyx8q5djaE7x9Sqe712DPA=', version='v1.8.0')
go_repository(name='com_google_cloud_go_datastore', importpath='cloud.google.com/go/datastore', sum='h1:/May9ojXjRkPBNVrq+oWLqmWCkr4OU5uRY29bu0mRyQ=', version='v1.1.0')
go_repository(name='com_google_cloud_go_pubsub', importpath='cloud.google.com/go/pubsub', sum='h1:ukjixP1wl0LpnZ6LWtZJ0mX5tBmjp1f8Sqer8Z2OMUU=', version='v1.3.1')
go_repository(name='com_google_cloud_go_storage', importpath='cloud.google.com/go/storage', sum='h1:STgFzyU5/8miMl0//zKh2aQeTyeaUH3WN9bSUiJ09bA=', version='v1.10.0')
go_repository(name='com_shuralyov_dmitri_gpu_mtl', importpath='dmitri.shuralyov.com/gpu/mtl', sum='h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY=', version='v0.0.0-20190408044501-666a987793e9')
go_repository(name='in_gopkg_alecthomas_kingpin_v2', importpath='gopkg.in/alecthomas/kingpin.v2', sum='h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc=', version='v2.2.6')
go_repository(name='in_gopkg_check_v1', importpath='gopkg.in/check.v1', sum='h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo=', version='v1.0.0-20190902080502-41f04d3bba15')
go_repository(name='in_gopkg_errgo_v2', importpath='gopkg.in/errgo.v2', sum='h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8=', version='v2.1.0')
go_repository(name='in_gopkg_fsnotify_v1', importpath='gopkg.in/fsnotify.v1', sum='h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=', version='v1.4.7')
go_repository(name='in_gopkg_ini_v1', importpath='gopkg.in/ini.v1', sum='h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI=', version='v1.66.2')
go_repository(name='in_gopkg_tomb_v1', importpath='gopkg.in/tomb.v1', sum='h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=', version='v1.0.0-20141024135613-dd632973f1e7')
go_repository(name='in_gopkg_yaml_v2', importpath='gopkg.in/yaml.v2', sum='h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=', version='v2.4.0')
go_repository(name='in_gopkg_yaml_v3', importpath='gopkg.in/yaml.v3', sum='h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=', version='v3.0.0-20200313102051-9f266ea9e77c')
go_repository(name='io_goji', importpath='goji.io', sum='h1:uIssv/elbKRLznFUy3Xj4+2Mz/qKhek/9aZQDUMae7c=', version='v2.0.2+incompatible')
go_repository(name='io_opencensus_go', importpath='go.opencensus.io', sum='h1:gqCw0LfLxScz8irSi8exQc7fyQ0fKQU/qnC/X8+V/1M=', version='v0.23.0')
go_repository(name='io_opencensus_go_contrib_exporter_prometheus', importpath='contrib.go.opencensus.io/exporter/prometheus', sum='h1:0QfIkj9z/iVZgK31D9H9ohjjIDApI2GOPScCKwxedbs=', version='v0.4.0')
go_repository(name='io_opentelemetry_go_proto_otlp', importpath='go.opentelemetry.io/proto/otlp', sum='h1:rwOQPCuKAKmwGKq2aVNnYIibI6wnV7EvzgfTCzcdGg8=', version='v0.7.0')
go_repository(name='io_rsc_binaryregexp', importpath='rsc.io/binaryregexp', sum='h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE=', version='v0.2.0')
go_repository(name='io_rsc_quote_v3', importpath='rsc.io/quote/v3', sum='h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY=', version='v3.1.0')
go_repository(name='io_rsc_sampler', importpath='rsc.io/sampler', sum='h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4=', version='v1.3.0')
go_repository(name='org_cloudfoundry_code_bytefmt', importpath='code.cloudfoundry.org/bytefmt', sum='h1:tW+ztA4A9UT9xnco5wUjW1oNi35k22eUEn9tNpPYVwE=', version='v0.0.0-20190710193110-1eb035ffe2b6')
go_repository(name='org_golang_google_api', importpath='google.golang.org/api', sum='h1:TXXKS1slM3b2bZNJwD5DV/Tp6/M2cLzLOLh9PjDhrw8=', version='v0.61.0')
go_repository(name='org_golang_google_appengine', importpath='google.golang.org/appengine', sum='h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c=', version='v1.6.7')
go_repository(name='org_golang_google_genproto', importpath='google.golang.org/genproto', sum='h1:ZrsicilzPCS/Xr8qtBZZLpy4P9TYXAfl49ctG1/5tgw=', version='v0.0.0-20211223182754-3ac035c7e7cb')
go_repository(name='org_golang_google_grpc', importpath='google.golang.org/grpc', sum='h1:Eeu7bZtDZ2DpRCsLhUlcrLnvYaMK1Gz86a+hMVvELmM=', version='v1.43.0')
go_repository(name='org_golang_google_grpc_cmd_protoc_gen_go_grpc', importpath='google.golang.org/grpc/cmd/protoc-gen-go-grpc', sum='h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE=', version='v1.1.0')
go_repository(name='org_golang_google_protobuf', importpath='google.golang.org/protobuf', sum='h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ=', version='v1.27.1')
go_repository(name='org_golang_x_crypto', importpath='golang.org/x/crypto', sum='h1:0es+/5331RGQPcXlMfP+WrnIIS6dNnNRe0WB02W0F4M=', version='v0.0.0-20211215153901-e495a2d5b3d3')
go_repository(name='org_golang_x_exp', importpath='golang.org/x/exp', sum='h1:QE6XYQK6naiK1EPAe1g/ILLxN5RBoH5xkJk3CqlMI/Y=', version='v0.0.0-20200224162631-6cc2880d07d6')
go_repository(name='org_golang_x_image', importpath='golang.org/x/image', sum='h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4=', version='v0.0.0-20190802002840-cff245a6509b')
go_repository(name='org_golang_x_lint', importpath='golang.org/x/lint', sum='h1:VLliZ0d+/avPrXXH+OakdXhpJuEoBZuwh1m2j7U6Iug=', version='v0.0.0-20210508222113-6edffad5e616')
go_repository(name='org_golang_x_mobile', importpath='golang.org/x/mobile', sum='h1:4+4C/Iv2U4fMZBiMCc98MG1In4gJY5YRhtpDNeDeHWs=', version='v0.0.0-20190719004257-d2bd2a29d028')
go_repository(name='org_golang_x_mod', importpath='golang.org/x/mod', sum='h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=', version='v0.4.2')
go_repository(name='org_golang_x_net', importpath='golang.org/x/net', sum='h1:hEYJvxw1lSnWIl8X9ofsYMklzaDs90JI2az5YMd4fPM=', version='v0.0.0-20211216030914-fe4d6282115f')
go_repository(name='org_golang_x_oauth2', importpath='golang.org/x/oauth2', sum='h1:RerP+noqYHUQ8CMRcPlC2nvTa4dcBIjegkuWdcUDuqg=', version='v0.0.0-20211104180415-d3ed0bb246c8')
go_repository(name='org_golang_x_sync', importpath='golang.org/x/sync', sum='h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=', version='v0.0.0-20210220032951-036812b2e83c')
go_repository(name='org_golang_x_sys', importpath='golang.org/x/sys', sum='h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=', version='v0.0.0-20211216021012-1d35b9e2eb4e')
go_repository(name='org_golang_x_term', importpath='golang.org/x/term', sum='h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=', version='v0.0.0-20201126162022-7de9c90e9dd1')
go_repository(name='org_golang_x_text', importpath='golang.org/x/text', sum='h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=', version='v0.3.7')
go_repository(name='org_golang_x_time', importpath='golang.org/x/time', sum='h1:/5xXl8Y5W96D+TtHSlonuFqGHIWVuyCkGJLwGh9JJFs=', version='v0.0.0-20191024005414-555d28b269f0')
go_repository(name='org_golang_x_tools', importpath='golang.org/x/tools', sum='h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=', version='v0.1.5')
go_repository(name='org_golang_x_xerrors', importpath='golang.org/x/xerrors', sum='h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=', version='v0.0.0-20200804184101-5ec99f83aff1') |
k=[]
for i in range(3):
#while True:
try:
a=input()
except:
break
k.append(a)
check = [True for i in range(len(k))]
check_three = False
three_s=(-1,-1)
three_e=(-1,-1)
remove_list = []
for num,i in enumerate(k):
for j in range(len(i)):
if j+2 <len(i):
if not check_three and (i[j],i[j+1],i[j+2]) == ('`','`','`'):
three_s=(num,j)
check_three=True
elif check_three and (i[j],i[j+1],i[j+2]) == ('`','`','`'):
three_e=(num,j+2)
remove_list.append((three_s,three_e))
three_s=(-1,-1)
three_e=(-1,-1)
check_three=False
print(remove_list)
| k = []
for i in range(3):
try:
a = input()
except:
break
k.append(a)
check = [True for i in range(len(k))]
check_three = False
three_s = (-1, -1)
three_e = (-1, -1)
remove_list = []
for (num, i) in enumerate(k):
for j in range(len(i)):
if j + 2 < len(i):
if not check_three and (i[j], i[j + 1], i[j + 2]) == ('`', '`', '`'):
three_s = (num, j)
check_three = True
elif check_three and (i[j], i[j + 1], i[j + 2]) == ('`', '`', '`'):
three_e = (num, j + 2)
remove_list.append((three_s, three_e))
three_s = (-1, -1)
three_e = (-1, -1)
check_three = False
print(remove_list) |
#
# Device Database and registry
#
# Need to be adapted to your local devices.
# And these are just default values, not my ones... :)
mqtt_ip = "192.168.178.10"
mqtt_port = 1883
influxdb_ip = "192.168.178.12"
influxdb_user = "myuser"
influxdb_pw = "mypw"
influxdb_db = "mydb"
fritz_ip = "192.168.17.1"
fritz_user = "fritzuser"
fritz_pw = "fritzpasswd"
fritz_evswitch = "11234 0134134"
gen24_ip = "192.168.178.13"
ipump_ip = "192.168.178.14"
| mqtt_ip = '192.168.178.10'
mqtt_port = 1883
influxdb_ip = '192.168.178.12'
influxdb_user = 'myuser'
influxdb_pw = 'mypw'
influxdb_db = 'mydb'
fritz_ip = '192.168.17.1'
fritz_user = 'fritzuser'
fritz_pw = 'fritzpasswd'
fritz_evswitch = '11234 0134134'
gen24_ip = '192.168.178.13'
ipump_ip = '192.168.178.14' |
def react_chat_red(eventType, GPIO):
RED_LED = 'P8_8'
if len(eventType) != 0:
if eventType[0] == "on":
GPIO.output(RED_LED, GPIO.HIGH)
elif eventType[0] == "off":
GPIO.output(RED_LED, GPIO.LOW)
elif eventType[0] == "toggle":
state = GPIO.input(RED_LED)
if state == 1:
GPIO.output(RED_LED, GPIO.LOW)
elif state == 0:
GPIO.output(RED_LED, GPIO.HIGH)
| def react_chat_red(eventType, GPIO):
red_led = 'P8_8'
if len(eventType) != 0:
if eventType[0] == 'on':
GPIO.output(RED_LED, GPIO.HIGH)
elif eventType[0] == 'off':
GPIO.output(RED_LED, GPIO.LOW)
elif eventType[0] == 'toggle':
state = GPIO.input(RED_LED)
if state == 1:
GPIO.output(RED_LED, GPIO.LOW)
elif state == 0:
GPIO.output(RED_LED, GPIO.HIGH) |
#%%
def numDistinctIslands(grid):
cnt_row, cnt_col = len(grid), len(grid[0])
def dfs(index_row, index_col, dir):
if (
index_row < 0
or index_row >= cnt_row
or index_col < 0
or index_col >= cnt_col
or not grid[index_row][index_col]
):
return ""
grid[index_row][index_col] = 0
return (
dir
+ dfs(index_row + 1, index_col, "1")
+ dfs(index_row - 1, index_col, "2")
+ dfs(index_row, index_col + 1, "3")
+ dfs(index_row, index_col - 1, "4")
+ "-"
+ dir
)
island_set = set()
for index_row in range(cnt_row):
for index_col in range(cnt_col):
if grid[index_row][index_col]:
island_set.add(dfs(index_row, index_col, "*"))
print(island_set)
return len(island_set)
grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]]
print(numDistinctIslands(grid))
# %%
| def num_distinct_islands(grid):
(cnt_row, cnt_col) = (len(grid), len(grid[0]))
def dfs(index_row, index_col, dir):
if index_row < 0 or index_row >= cnt_row or index_col < 0 or (index_col >= cnt_col) or (not grid[index_row][index_col]):
return ''
grid[index_row][index_col] = 0
return dir + dfs(index_row + 1, index_col, '1') + dfs(index_row - 1, index_col, '2') + dfs(index_row, index_col + 1, '3') + dfs(index_row, index_col - 1, '4') + '-' + dir
island_set = set()
for index_row in range(cnt_row):
for index_col in range(cnt_col):
if grid[index_row][index_col]:
island_set.add(dfs(index_row, index_col, '*'))
print(island_set)
return len(island_set)
grid = [[1, 1, 0, 1, 1], [1, 0, 0, 0, 0], [0, 0, 0, 0, 1], [1, 1, 0, 1, 1]]
print(num_distinct_islands(grid)) |
"""
Experiment on the work of Faten.
Manully define preference relationship between several alternatives and run the .
"""
# Author: Yiru Zhang <yiru.zhang@irisa.fr>
# License: Unlicense
| """
Experiment on the work of Faten.
Manully define preference relationship between several alternatives and run the .
""" |
with open('input') as f:
data = f.read().strip().split('\n')
initial = {(j, i, 0, 0) for i, s in enumerate(data) for j, c in enumerate(s) if c=='#'}
def fence(s):
min_x = min(s, key=lambda x: x[0])[0]
min_y = min(s, key=lambda x: x[1])[1]
min_z = min(s, key=lambda x: x[2])[2]
min_w = min(s, key=lambda x: x[3])[3]
max_x = max(s, key=lambda x: x[0])[0]
max_y = max(s, key=lambda x: x[1])[1]
max_z = max(s, key=lambda x: x[2])[2]
max_w = max(s, key=lambda x: x[3])[3]
return (min_x-1, max_x+2), (min_y-1, max_y+2), (min_z-1, max_z+2), (min_w-1, max_w+2)
def neighbours(s, x, y, z, w):
n=0
for _x in range(x-1, x+2):
for _y in range(y-1, y+2):
for _z in range(z-1, z+2):
for _w in range(w-1, w+2):
if not (_x==x and _y==y and _z==z and _w==w):
if (_x, _y, _z, _w) in s:
n+=1
return n
for _ in range(6):
new = set()
r_x, r_y, r_z, r_w = fence(initial)
for x in range(*r_x):
for y in range(*r_y):
for z in range(*r_z):
for w in range(*r_w):
n = neighbours(initial, x, y, z, w)
if (x,y,z, w) in initial:
if n==2 or n==3:
new.add((x,y,z,w))
else:
if n==3:
new.add((x,y,z,w))
initial = new
print(len(initial))
print('done')
| with open('input') as f:
data = f.read().strip().split('\n')
initial = {(j, i, 0, 0) for (i, s) in enumerate(data) for (j, c) in enumerate(s) if c == '#'}
def fence(s):
min_x = min(s, key=lambda x: x[0])[0]
min_y = min(s, key=lambda x: x[1])[1]
min_z = min(s, key=lambda x: x[2])[2]
min_w = min(s, key=lambda x: x[3])[3]
max_x = max(s, key=lambda x: x[0])[0]
max_y = max(s, key=lambda x: x[1])[1]
max_z = max(s, key=lambda x: x[2])[2]
max_w = max(s, key=lambda x: x[3])[3]
return ((min_x - 1, max_x + 2), (min_y - 1, max_y + 2), (min_z - 1, max_z + 2), (min_w - 1, max_w + 2))
def neighbours(s, x, y, z, w):
n = 0
for _x in range(x - 1, x + 2):
for _y in range(y - 1, y + 2):
for _z in range(z - 1, z + 2):
for _w in range(w - 1, w + 2):
if not (_x == x and _y == y and (_z == z) and (_w == w)):
if (_x, _y, _z, _w) in s:
n += 1
return n
for _ in range(6):
new = set()
(r_x, r_y, r_z, r_w) = fence(initial)
for x in range(*r_x):
for y in range(*r_y):
for z in range(*r_z):
for w in range(*r_w):
n = neighbours(initial, x, y, z, w)
if (x, y, z, w) in initial:
if n == 2 or n == 3:
new.add((x, y, z, w))
elif n == 3:
new.add((x, y, z, w))
initial = new
print(len(initial))
print('done') |
# import time
# #Indroduction to the game
# print("Hello there \nWelcome to TIC-TAC-TOE")
# time.sleep(1)
# #list of numbers
# num_list = [1,2,3,4,5,6,7,8,9]
# print(num_list)
# #Request for tutorial
# def tutorial():
# tutorial_list = ["=>This game is restricted to 2 players only",
# "=>There are two characters used to play this game 'X' and 'O'",
# "=>Whoever chooses 'X' would go first",
# "=>A board would be printed out every time a player makes a move",
# "=>Numbers 1-9 would be used to determine postions on the board",
# "=>The first player to get '3' of their characters to either horizontally, vertically or diagonally WINS!",
# "=>Goodluck and REMEMBER TO HAVE FUN"]
# for item in tutorial_list:
# print(item)
# time.sleep(5)
# #countdown to begin game
# def countdown():
# t = 3
# while t > 0:
# print(t)
# time.sleep(1)
# t -=1
# return "Lets Go!!!"
# def begin_game():
# start = 'no'
# if start == 'y':
# print(countdown())
# elif start == 'n':
# print('Closing Game')
# while start != 'y' or start !='n':
# start = input("Begin Game?(y/n)")
# start = start.lower()
boardlist = [" " for i in range(10)]
boardlist[0] = "nil"
def board(boardlist):
print(f"\n {boardlist[1]} | {boardlist[2]} | {boardlist[3]} ")
print("-----|-----|-----")
print(f" {boardlist[4]} | {boardlist[5]} | {boardlist[6]} ")
print("-----|-----|-----")
print(f" {boardlist[7]} | {boardlist[8]} | {boardlist[9]} ")
def insertLetter(pos, letter):
board[pos] = letter
def freeSpace(pos):
return boardlist[pos] == " "
def isBoardFull():
return " " not in boardlist
def playerMove():
a = True
while a:
position = input("Enter the position to place an 'X' (1-9): ")
try:
position = int(position)
if position in range(1,10):
if freeSpace(position):
insertLetter(position, 'X')
a = False
else:
print("Sorry, this spot is occupied!")
else:
print("Enter a number between 1-9!")
except:
print("Enter a number!")
def computerMove():
possiblePositions = []
for i, letter in enumerate(boardlist):
if letter == " ":
possiblePositions.append(i)
moves = ['X', 'O']
for _ in moves:
for i in possiblePositions:
sampleBoard = boardlist[:]
sampleBoard[i] = _
if checkWin(sampleBoard, _):
move = i
return move
# function to check who won the game
def checkWin(bod, let):
return (bod[1] == let and bod[2] == let and bod[3] == let) or (bod[4] == let and bod[5] == let and bod[6] == let) or (bod[7] == let and bod[8] == let and bod[9] == let) or (bod[1] == let and bod[4] == let and bod[7] == let) or (bod[2] == let and bod[5] == let and bod[8] == let) or (bod[3] == let and bod[6] == let and bod[9] == let) or (bod[1] == let and bod[5] == let and bod[9] == let) or (bod[3] == let and bod[5] == let and bod[7] == let)
def m():
game = 3
charCount = 1
while game > 0:
if charCount % 2 == 0:
char = 'O'
else:
char = 'X'
print(char)
charCount += 1
game -= 1
def preset():
new = 'none'
new = new.lower()
while new != 'y':
new = input('Do you wish to go through the tutorial?(y/n): ')
return tutorial()
print(begin_game())
def main():
board()
while not isBoardFull():
if checkWin(boardlist, 'X'):
print("X won!")
break
else:
computerMove()
board()
if checkWin(boardlist, 'O'):
print("O won!")
break
else:
playerMove()
board()
else:
print("Tie game")
#function to print the score board
def scoreboard(score_board):
print("------------------------------")
print(" SCOREBOARD ")
print("------------------------------")
players = [score_board.keys()]
for i in range(2):
print(f" {players[i]}, {score_board[players[i]]}")
print("------------------------------")
| boardlist = [' ' for i in range(10)]
boardlist[0] = 'nil'
def board(boardlist):
print(f'\n {boardlist[1]} | {boardlist[2]} | {boardlist[3]} ')
print('-----|-----|-----')
print(f' {boardlist[4]} | {boardlist[5]} | {boardlist[6]} ')
print('-----|-----|-----')
print(f' {boardlist[7]} | {boardlist[8]} | {boardlist[9]} ')
def insert_letter(pos, letter):
board[pos] = letter
def free_space(pos):
return boardlist[pos] == ' '
def is_board_full():
return ' ' not in boardlist
def player_move():
a = True
while a:
position = input("Enter the position to place an 'X' (1-9): ")
try:
position = int(position)
if position in range(1, 10):
if free_space(position):
insert_letter(position, 'X')
a = False
else:
print('Sorry, this spot is occupied!')
else:
print('Enter a number between 1-9!')
except:
print('Enter a number!')
def computer_move():
possible_positions = []
for (i, letter) in enumerate(boardlist):
if letter == ' ':
possiblePositions.append(i)
moves = ['X', 'O']
for _ in moves:
for i in possiblePositions:
sample_board = boardlist[:]
sampleBoard[i] = _
if check_win(sampleBoard, _):
move = i
return move
def check_win(bod, let):
return bod[1] == let and bod[2] == let and (bod[3] == let) or (bod[4] == let and bod[5] == let and (bod[6] == let)) or (bod[7] == let and bod[8] == let and (bod[9] == let)) or (bod[1] == let and bod[4] == let and (bod[7] == let)) or (bod[2] == let and bod[5] == let and (bod[8] == let)) or (bod[3] == let and bod[6] == let and (bod[9] == let)) or (bod[1] == let and bod[5] == let and (bod[9] == let)) or (bod[3] == let and bod[5] == let and (bod[7] == let))
def m():
game = 3
char_count = 1
while game > 0:
if charCount % 2 == 0:
char = 'O'
else:
char = 'X'
print(char)
char_count += 1
game -= 1
def preset():
new = 'none'
new = new.lower()
while new != 'y':
new = input('Do you wish to go through the tutorial?(y/n): ')
return tutorial()
print(begin_game())
def main():
board()
while not is_board_full():
if check_win(boardlist, 'X'):
print('X won!')
break
else:
computer_move()
board()
if check_win(boardlist, 'O'):
print('O won!')
break
else:
player_move()
board()
else:
print('Tie game')
def scoreboard(score_board):
print('------------------------------')
print(' SCOREBOARD ')
print('------------------------------')
players = [score_board.keys()]
for i in range(2):
print(f' {players[i]}, {score_board[players[i]]}')
print('------------------------------') |
#
# PySNMP MIB module HH3C-MIRRORGROUP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-MIRRORGROUP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:15:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion")
hh3cCommon, = mibBuilder.importSymbols("HH3C-OID-MIB", "hh3cCommon")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
MibIdentifier, ObjectIdentity, ModuleIdentity, NotificationType, TimeTicks, iso, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, Bits, Unsigned32, IpAddress, Integer32, Gauge32, Counter64 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "ObjectIdentity", "ModuleIdentity", "NotificationType", "TimeTicks", "iso", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "Bits", "Unsigned32", "IpAddress", "Integer32", "Gauge32", "Counter64")
RowStatus, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "TextualConvention", "DisplayString")
hh3cMirrGroup = ModuleIdentity((1, 3, 6, 1, 4, 1, 25506, 2, 68))
hh3cMirrGroup.setRevisions(('2006-01-10 19:03',))
if mibBuilder.loadTexts: hh3cMirrGroup.setLastUpdated('200601131403Z')
if mibBuilder.loadTexts: hh3cMirrGroup.setOrganization('Hangzhou H3C Tech. Co., Ltd.')
hh3cMGInfoObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1))
hh3cMGObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1))
hh3cMGTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1), )
if mibBuilder.loadTexts: hh3cMGTable.setStatus('current')
hh3cMGEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"))
if mibBuilder.loadTexts: hh3cMGEntry.setStatus('current')
hh3cMGID = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: hh3cMGID.setStatus('current')
hh3cMGType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("local", 1), ("remoteSource", 2), ("remoteDestination", 3)))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGType.setStatus('current')
hh3cMGStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("inactive", 2)))).setMaxAccess("readonly")
if mibBuilder.loadTexts: hh3cMGStatus.setStatus('current')
hh3cMGRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 4), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGRowStatus.setStatus('current')
hh3cMGMirrorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2))
hh3cMGMirrorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1), )
if mibBuilder.loadTexts: hh3cMGMirrorIfTable.setStatus('current')
hh3cMGMirrorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMirrorIfIndex"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMirrorDirection"))
if mibBuilder.loadTexts: hh3cMGMirrorIfEntry.setStatus('current')
hh3cMGMirrorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: hh3cMGMirrorIfIndex.setStatus('current')
hh3cMGMirrorDirection = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("inbound", 1), ("outbound", 2), ("both", 3))))
if mibBuilder.loadTexts: hh3cMGMirrorDirection.setStatus('current')
hh3cMGMirrorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 3), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGMirrorRowStatus.setStatus('current')
hh3cMGMonitorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3))
hh3cMGMonitorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1), )
if mibBuilder.loadTexts: hh3cMGMonitorIfTable.setStatus('current')
hh3cMGMonitorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGMonitorIfIndex"))
if mibBuilder.loadTexts: hh3cMGMonitorIfEntry.setStatus('current')
hh3cMGMonitorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: hh3cMGMonitorIfIndex.setStatus('current')
hh3cMGMonitorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGMonitorRowStatus.setStatus('current')
hh3cMGReflectorIfObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4))
hh3cMGReflectorIfTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1), )
if mibBuilder.loadTexts: hh3cMGReflectorIfTable.setStatus('current')
hh3cMGReflectorIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGReflectorIfIndex"))
if mibBuilder.loadTexts: hh3cMGReflectorIfEntry.setStatus('current')
hh3cMGReflectorIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 1), Integer32())
if mibBuilder.loadTexts: hh3cMGReflectorIfIndex.setStatus('current')
hh3cMGReflectorRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGReflectorRowStatus.setStatus('current')
hh3cMGRprobeVlanObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5))
hh3cMGRprobeVlanTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1), )
if mibBuilder.loadTexts: hh3cMGRprobeVlanTable.setStatus('current')
hh3cMGRprobeVlanEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1), ).setIndexNames((0, "HH3C-MIRRORGROUP-MIB", "hh3cMGID"), (0, "HH3C-MIRRORGROUP-MIB", "hh3cMGRprobeVlanID"))
if mibBuilder.loadTexts: hh3cMGRprobeVlanEntry.setStatus('current')
hh3cMGRprobeVlanID = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 4094)))
if mibBuilder.loadTexts: hh3cMGRprobeVlanID.setStatus('current')
hh3cMGRprobeVlanRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hh3cMGRprobeVlanRowStatus.setStatus('current')
mibBuilder.exportSymbols("HH3C-MIRRORGROUP-MIB", hh3cMGMonitorRowStatus=hh3cMGMonitorRowStatus, hh3cMGRprobeVlanObjects=hh3cMGRprobeVlanObjects, hh3cMGMirrorRowStatus=hh3cMGMirrorRowStatus, hh3cMGRowStatus=hh3cMGRowStatus, hh3cMGObjects=hh3cMGObjects, hh3cMGMonitorIfIndex=hh3cMGMonitorIfIndex, hh3cMGRprobeVlanEntry=hh3cMGRprobeVlanEntry, hh3cMGMonitorIfObjects=hh3cMGMonitorIfObjects, hh3cMGReflectorIfTable=hh3cMGReflectorIfTable, hh3cMGReflectorIfObjects=hh3cMGReflectorIfObjects, hh3cMGMirrorIfTable=hh3cMGMirrorIfTable, hh3cMGReflectorIfIndex=hh3cMGReflectorIfIndex, hh3cMGRprobeVlanTable=hh3cMGRprobeVlanTable, hh3cMGRprobeVlanRowStatus=hh3cMGRprobeVlanRowStatus, hh3cMGMonitorIfEntry=hh3cMGMonitorIfEntry, hh3cMirrGroup=hh3cMirrGroup, hh3cMGMirrorIfIndex=hh3cMGMirrorIfIndex, hh3cMGMirrorIfEntry=hh3cMGMirrorIfEntry, PYSNMP_MODULE_ID=hh3cMirrGroup, hh3cMGID=hh3cMGID, hh3cMGInfoObjects=hh3cMGInfoObjects, hh3cMGTable=hh3cMGTable, hh3cMGMirrorIfObjects=hh3cMGMirrorIfObjects, hh3cMGReflectorIfEntry=hh3cMGReflectorIfEntry, hh3cMGReflectorRowStatus=hh3cMGReflectorRowStatus, hh3cMGType=hh3cMGType, hh3cMGStatus=hh3cMGStatus, hh3cMGEntry=hh3cMGEntry, hh3cMGMonitorIfTable=hh3cMGMonitorIfTable, hh3cMGMirrorDirection=hh3cMGMirrorDirection, hh3cMGRprobeVlanID=hh3cMGRprobeVlanID)
| (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsUnion')
(hh3c_common,) = mibBuilder.importSymbols('HH3C-OID-MIB', 'hh3cCommon')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(mib_identifier, object_identity, module_identity, notification_type, time_ticks, iso, mib_scalar, mib_table, mib_table_row, mib_table_column, counter32, bits, unsigned32, ip_address, integer32, gauge32, counter64) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibIdentifier', 'ObjectIdentity', 'ModuleIdentity', 'NotificationType', 'TimeTicks', 'iso', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter32', 'Bits', 'Unsigned32', 'IpAddress', 'Integer32', 'Gauge32', 'Counter64')
(row_status, textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'TextualConvention', 'DisplayString')
hh3c_mirr_group = module_identity((1, 3, 6, 1, 4, 1, 25506, 2, 68))
hh3cMirrGroup.setRevisions(('2006-01-10 19:03',))
if mibBuilder.loadTexts:
hh3cMirrGroup.setLastUpdated('200601131403Z')
if mibBuilder.loadTexts:
hh3cMirrGroup.setOrganization('Hangzhou H3C Tech. Co., Ltd.')
hh3c_mg_info_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1))
hh3c_mg_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1))
hh3c_mg_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1))
if mibBuilder.loadTexts:
hh3cMGTable.setStatus('current')
hh3c_mg_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'))
if mibBuilder.loadTexts:
hh3cMGEntry.setStatus('current')
hh3c_mgid = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 1), integer32())
if mibBuilder.loadTexts:
hh3cMGID.setStatus('current')
hh3c_mg_type = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('local', 1), ('remoteSource', 2), ('remoteDestination', 3)))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGType.setStatus('current')
hh3c_mg_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('active', 1), ('inactive', 2)))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
hh3cMGStatus.setStatus('current')
hh3c_mg_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 1, 1, 1, 4), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGRowStatus.setStatus('current')
hh3c_mg_mirror_if_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2))
hh3c_mg_mirror_if_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1))
if mibBuilder.loadTexts:
hh3cMGMirrorIfTable.setStatus('current')
hh3c_mg_mirror_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGMirrorIfIndex'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGMirrorDirection'))
if mibBuilder.loadTexts:
hh3cMGMirrorIfEntry.setStatus('current')
hh3c_mg_mirror_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 1), integer32())
if mibBuilder.loadTexts:
hh3cMGMirrorIfIndex.setStatus('current')
hh3c_mg_mirror_direction = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('inbound', 1), ('outbound', 2), ('both', 3))))
if mibBuilder.loadTexts:
hh3cMGMirrorDirection.setStatus('current')
hh3c_mg_mirror_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 2, 1, 1, 3), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGMirrorRowStatus.setStatus('current')
hh3c_mg_monitor_if_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3))
hh3c_mg_monitor_if_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1))
if mibBuilder.loadTexts:
hh3cMGMonitorIfTable.setStatus('current')
hh3c_mg_monitor_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGMonitorIfIndex'))
if mibBuilder.loadTexts:
hh3cMGMonitorIfEntry.setStatus('current')
hh3c_mg_monitor_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 1), integer32())
if mibBuilder.loadTexts:
hh3cMGMonitorIfIndex.setStatus('current')
hh3c_mg_monitor_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 3, 1, 1, 2), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGMonitorRowStatus.setStatus('current')
hh3c_mg_reflector_if_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4))
hh3c_mg_reflector_if_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1))
if mibBuilder.loadTexts:
hh3cMGReflectorIfTable.setStatus('current')
hh3c_mg_reflector_if_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGReflectorIfIndex'))
if mibBuilder.loadTexts:
hh3cMGReflectorIfEntry.setStatus('current')
hh3c_mg_reflector_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 1), integer32())
if mibBuilder.loadTexts:
hh3cMGReflectorIfIndex.setStatus('current')
hh3c_mg_reflector_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 4, 1, 1, 2), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGReflectorRowStatus.setStatus('current')
hh3c_mg_rprobe_vlan_objects = mib_identifier((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5))
hh3c_mg_rprobe_vlan_table = mib_table((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1))
if mibBuilder.loadTexts:
hh3cMGRprobeVlanTable.setStatus('current')
hh3c_mg_rprobe_vlan_entry = mib_table_row((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1)).setIndexNames((0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGID'), (0, 'HH3C-MIRRORGROUP-MIB', 'hh3cMGRprobeVlanID'))
if mibBuilder.loadTexts:
hh3cMGRprobeVlanEntry.setStatus('current')
hh3c_mg_rprobe_vlan_id = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 4094)))
if mibBuilder.loadTexts:
hh3cMGRprobeVlanID.setStatus('current')
hh3c_mg_rprobe_vlan_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 25506, 2, 68, 1, 5, 1, 1, 2), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hh3cMGRprobeVlanRowStatus.setStatus('current')
mibBuilder.exportSymbols('HH3C-MIRRORGROUP-MIB', hh3cMGMonitorRowStatus=hh3cMGMonitorRowStatus, hh3cMGRprobeVlanObjects=hh3cMGRprobeVlanObjects, hh3cMGMirrorRowStatus=hh3cMGMirrorRowStatus, hh3cMGRowStatus=hh3cMGRowStatus, hh3cMGObjects=hh3cMGObjects, hh3cMGMonitorIfIndex=hh3cMGMonitorIfIndex, hh3cMGRprobeVlanEntry=hh3cMGRprobeVlanEntry, hh3cMGMonitorIfObjects=hh3cMGMonitorIfObjects, hh3cMGReflectorIfTable=hh3cMGReflectorIfTable, hh3cMGReflectorIfObjects=hh3cMGReflectorIfObjects, hh3cMGMirrorIfTable=hh3cMGMirrorIfTable, hh3cMGReflectorIfIndex=hh3cMGReflectorIfIndex, hh3cMGRprobeVlanTable=hh3cMGRprobeVlanTable, hh3cMGRprobeVlanRowStatus=hh3cMGRprobeVlanRowStatus, hh3cMGMonitorIfEntry=hh3cMGMonitorIfEntry, hh3cMirrGroup=hh3cMirrGroup, hh3cMGMirrorIfIndex=hh3cMGMirrorIfIndex, hh3cMGMirrorIfEntry=hh3cMGMirrorIfEntry, PYSNMP_MODULE_ID=hh3cMirrGroup, hh3cMGID=hh3cMGID, hh3cMGInfoObjects=hh3cMGInfoObjects, hh3cMGTable=hh3cMGTable, hh3cMGMirrorIfObjects=hh3cMGMirrorIfObjects, hh3cMGReflectorIfEntry=hh3cMGReflectorIfEntry, hh3cMGReflectorRowStatus=hh3cMGReflectorRowStatus, hh3cMGType=hh3cMGType, hh3cMGStatus=hh3cMGStatus, hh3cMGEntry=hh3cMGEntry, hh3cMGMonitorIfTable=hh3cMGMonitorIfTable, hh3cMGMirrorDirection=hh3cMGMirrorDirection, hh3cMGRprobeVlanID=hh3cMGRprobeVlanID) |
'''THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.'''
# Bitcoin Cash (BCH) qpz32c4lg7x7lnk9jg6qg7s4uavdce89myax5v5nuk
# Ether (ETH) - 0x843d3DEC2A4705BD4f45F674F641cE2D0022c9FB
# Litecoin (LTC) - Lfk5y4F7KZa9oRxpazETwjQnHszEPvqPvu
# Bitcoin (BTC) - 34L8qWiQyKr8k4TnHDacfjbaSqQASbBtTd
# contact :- github@jamessawyer.co.uk
"""
You have m types of coins available in infinite quantities
where the value of each coins is given in the array S=[S0,... Sm-1]
Can you determine number of ways of making change for n units using
the given types of coins?
https://www.hackerrank.com/challenges/coin-change/problem
"""
def dp_count(S, m, n):
# table[i] represents the number of ways to get to amount i
table = [0] * (n + 1)
# There is exactly 1 way to get to zero(You pick no coins).
table[0] = 1
# Pick all coins one by one and update table[] values
# after the index greater than or equal to the value of the
# picked coin
for coin_val in S:
for j in range(coin_val, n + 1):
table[j] += table[j - coin_val]
return table[n]
if __name__ == "__main__":
print(dp_count([1, 2, 3], 3, 4)) # answer 4
print(dp_count([2, 5, 3, 6], 4, 10)) # answer 5
| """THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY,
WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE."""
'\nYou have m types of coins available in infinite quantities\nwhere the value of each coins is given in the array S=[S0,... Sm-1]\nCan you determine number of ways of making change for n units using\nthe given types of coins?\nhttps://www.hackerrank.com/challenges/coin-change/problem\n'
def dp_count(S, m, n):
table = [0] * (n + 1)
table[0] = 1
for coin_val in S:
for j in range(coin_val, n + 1):
table[j] += table[j - coin_val]
return table[n]
if __name__ == '__main__':
print(dp_count([1, 2, 3], 3, 4))
print(dp_count([2, 5, 3, 6], 4, 10)) |
# 2020.07.26
# May not have time to do it on 27th, so...
# Problem Statement
# https://leetcode.com/problems/merge-k-sorted-lists/
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
# one by one compare
class Solution:
def mergeKLists(self, lists: List[ListNode]) -> ListNode:
# get rid of empty linked lists
lists = [i for i in lists if i]
# check empty case
if len(lists) == 0: return None
# initialize pointers
list_ptr = []
for list_head in lists:
list_ptr.append(list_head)
answer_ptr = ListNode()
answer_head = ListNode()
first_time = True
# loop until finish going through all the nodes
while len(list_ptr) != 0:
# pick the smallest value and add
smallest = inf
smallest_idx = 0
for i in range(0, len(list_ptr)):
if list_ptr[i] is not None and list_ptr[i].val < smallest:
smallest = list_ptr[i].val
smallest_idx = i
answer_ptr.val = smallest
if first_time:
answer_head = answer_ptr
first_time = False
# move the ptr which points to the smallest value to the next
if list_ptr[smallest_idx].next is not None:
list_ptr[smallest_idx] = list_ptr[smallest_idx].next
# if has been traversed, remove from the list
else:
list_ptr.remove(list_ptr[smallest_idx])
# if all have been traversed
if len(list_ptr) == 0:
return answer_head
else:
# should add other nodes
answer_ptr.next = ListNode()
answer_ptr = answer_ptr.next
# only one list left, can do early return
if len(list_ptr) == 1:
answer_ptr.val = list_ptr[0].val
answer_ptr.next = list_ptr[0].next
return answer_head
return answer_head | class Solution:
def merge_k_lists(self, lists: List[ListNode]) -> ListNode:
lists = [i for i in lists if i]
if len(lists) == 0:
return None
list_ptr = []
for list_head in lists:
list_ptr.append(list_head)
answer_ptr = list_node()
answer_head = list_node()
first_time = True
while len(list_ptr) != 0:
smallest = inf
smallest_idx = 0
for i in range(0, len(list_ptr)):
if list_ptr[i] is not None and list_ptr[i].val < smallest:
smallest = list_ptr[i].val
smallest_idx = i
answer_ptr.val = smallest
if first_time:
answer_head = answer_ptr
first_time = False
if list_ptr[smallest_idx].next is not None:
list_ptr[smallest_idx] = list_ptr[smallest_idx].next
else:
list_ptr.remove(list_ptr[smallest_idx])
if len(list_ptr) == 0:
return answer_head
else:
answer_ptr.next = list_node()
answer_ptr = answer_ptr.next
if len(list_ptr) == 1:
answer_ptr.val = list_ptr[0].val
answer_ptr.next = list_ptr[0].next
return answer_head
return answer_head |
class BalanceResponse(object):
def __init__(self, data):
self.exchangeId = data['exchangeId']
self.currencyId = data['currencyId']
self.availableBalance = data['availableBalance']
self.realizedBalance = data['realizedBalance']
self.currencySymbol = data['currencySymbol']
self.exchangeName = data['exchangeName']
| class Balanceresponse(object):
def __init__(self, data):
self.exchangeId = data['exchangeId']
self.currencyId = data['currencyId']
self.availableBalance = data['availableBalance']
self.realizedBalance = data['realizedBalance']
self.currencySymbol = data['currencySymbol']
self.exchangeName = data['exchangeName'] |
#!/usr/bin/python3
"""
Copyright 2018 Nicolas Simonin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
"""
'''
A 433MHz Wireless Switch protocol decoder
This class expects to be initialized with a protocol dictionary and some
tollerance parameters.
the protocol dictionary shall contain "pulse_len", "start","zero" and "one" like
this example:
{ "pulse_len": 0.000350, "start": [ 1, 31 ], "zero": [ 1, 3 ], "one": [ 3, 1 ] }
the pulse_len_tollerance is applied at pulse_len and then moltiplied.
Format for protocol definitions:
pulselength: pulse length in seconds, e.g. 0.000350
"start": [1, 31] means 1 high pulse and 31 low pulses:
_
| |_______________________________
"zero" bit: waveform for a data bit of value "0", [1, 3] means 1 high pulse
and 3 low pulses, total length (1+3)*pulselength:
_
| |___
"one" bit: waveform for a data bit of value "1", e.g. [3,1]:
___
| |_
'''
class Decoder:
def __init__(self, protocol, pulse_len_tollerance, extra_tollerance,
tollerance_delay, min_duration = 0.000200, expected_bit_count = 24):
self.state = "reset"
self.protocol = protocol
self.expected_bit_count = expected_bit_count
self.current_result = None
self.start_time = None
self.results_list = []
self.discarded_list = []
self.values = []
self.pulse_len_tollerance = pulse_len_tollerance
self.extra_tollerance = extra_tollerance
self.tollerance_delay = tollerance_delay
self.min_duration = min_duration
def parse(self,values):
self.values.append(values)
#print(repr(self.values))
while(len(self.values) >= 3):
if (self.filterGlitchesOut()):
continue
if (self.state == "reset"): #looking for a start
if(self.is_a("start")):
self.state = "started"
self.current_result = ""
self.start_time = self.values[0]["time"]
#print("started" + str(self.values[0]["time"]))
del self.values[0] #remove one extra entry if the start sequence is identified
elif (self.state == "started"):
if(self.is_a("zero")):
self.current_result += "0"
#print("0", end='', flush=True)
del self.values[0] #remove one extra entry if the sequence is identified
elif(self.is_a("one")):
self.current_result += "1"
#print("1", end='', flush=True)
del self.values[0] #remove one extra entry if the sequence is identified
elif (self.is_a("start")):
self.save_result()
self.state = "started"
self.current_result = ""
self.start_time = self.values[0]["time"]
#print("started"+ str(self.values[0]["time"]))
del self.values[0] #remove one extra entry if the start sequence is identified
else:
if (self.is_a("zero", long_last_bit_check = True)):
self.current_result += "0"
#print("0", end='', flush=True)
elif(self.is_a("one", long_last_bit_check = True)):
self.current_result += "1"
#print("1", end='', flush=True)
self.save_result()
self.state = "reset"
self.current_result = None
self.start_time = None
#print ("abort")
del self.values[0] #remove one edge anyhow
def save_result(self):
if(len(self.current_result) == self.expected_bit_count):
self.results_list.append({"time": self.start_time, "data" : self.current_result})
else:
self.discarded_list.append({"time": self.start_time, "data" : self.current_result, "discard_time": self.values[0]["time"]})
#print (str(len(self.current_result)) + " bits received from " + str(self.start_time) +
# " but discarded at " + str(self.values[0]["time"]) + ".") #todo make it part of the result
if(len(self.current_result) >self.expected_bit_count):
print("Warning: received " +str(self.current_result) + " bits.")
def filterGlitchesOut(self):
hi_time = self.values[1]["time"] - self.values[0]["time"]
if (hi_time < self.min_duration):
del self.values[1]
del self.values[0]
return True
low_time = self.values[2]["time"] - self.values[1]["time"]
if (low_time < self.min_duration):
del self.values[2]
del self.values[1]
return True
return False
def is_a(self,protocol_element, long_last_bit_check = False):
#print (repr(self.values))
if(self.values[0]["value"] == 0):
return False
hi_time = self.values[1]["time"] - self.values[0]["time"]
low_time = self.values[2]["time"] - self.values[1]["time"]
p_hi_time_min = self.protocol[protocol_element][0] * (self.protocol["pulse_len"]-self.pulse_len_tollerance) - self.extra_tollerance + self.tollerance_delay
p_hi_time_max = self.protocol[protocol_element][0] * (self.protocol["pulse_len"]+self.pulse_len_tollerance) + self.extra_tollerance + self.tollerance_delay
p_low_time_min = self.protocol[protocol_element][1] * (self.protocol["pulse_len"]-self.pulse_len_tollerance) - self.extra_tollerance + self.tollerance_delay
p_low_time_max = self.protocol[protocol_element][1] * (self.protocol["pulse_len"]+self.pulse_len_tollerance) + self.extra_tollerance + self.tollerance_delay
if (hi_time < p_hi_time_min):
#if(protocol_element is not "start"):
# print ("hi: "+ str(hi_time) + ", min: " + str(p_hi_time_min))
return False
if (hi_time > p_hi_time_max):
#if(protocol_element is not "start"):
# print ("hi: "+ str(hi_time) + ", max: " + str(p_hi_time_max))
return False
if (low_time < p_low_time_min):
#if(protocol_element is not "start"):
# print ("low " + str(low_time) + ", min:" + str(p_low_time_min))
return False
if (low_time > p_low_time_max):
if long_last_bit_check is True:
#print("last bit set on " + protocol_element + " at " + str(self.values[0]["time"]) )
return True
else:
return False
#if we reach this point we have a match
return True
| """
Copyright 2018 Nicolas Simonin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
MIT License
"""
'\nA 433MHz Wireless Switch protocol decoder\n\nThis class expects to be initialized with a protocol dictionary and some\ntollerance parameters.\nthe protocol dictionary shall contain "pulse_len", "start","zero" and "one" like\nthis example:\n{ "pulse_len": 0.000350, "start": [ 1, 31 ], "zero": [ 1, 3 ], "one": [ 3, 1 ] }\nthe pulse_len_tollerance is applied at pulse_len and then moltiplied.\n\nFormat for protocol definitions:\n\npulselength: pulse length in seconds, e.g. 0.000350\n"start": [1, 31] means 1 high pulse and 31 low pulses:\n _\n | |_______________________________\n\n"zero" bit: waveform for a data bit of value "0", [1, 3] means 1 high pulse\n and 3 low pulses, total length (1+3)*pulselength:\n _\n | |___\n"one" bit: waveform for a data bit of value "1", e.g. [3,1]:\n ___\n | |_\n'
class Decoder:
def __init__(self, protocol, pulse_len_tollerance, extra_tollerance, tollerance_delay, min_duration=0.0002, expected_bit_count=24):
self.state = 'reset'
self.protocol = protocol
self.expected_bit_count = expected_bit_count
self.current_result = None
self.start_time = None
self.results_list = []
self.discarded_list = []
self.values = []
self.pulse_len_tollerance = pulse_len_tollerance
self.extra_tollerance = extra_tollerance
self.tollerance_delay = tollerance_delay
self.min_duration = min_duration
def parse(self, values):
self.values.append(values)
while len(self.values) >= 3:
if self.filterGlitchesOut():
continue
if self.state == 'reset':
if self.is_a('start'):
self.state = 'started'
self.current_result = ''
self.start_time = self.values[0]['time']
del self.values[0]
elif self.state == 'started':
if self.is_a('zero'):
self.current_result += '0'
del self.values[0]
elif self.is_a('one'):
self.current_result += '1'
del self.values[0]
elif self.is_a('start'):
self.save_result()
self.state = 'started'
self.current_result = ''
self.start_time = self.values[0]['time']
del self.values[0]
else:
if self.is_a('zero', long_last_bit_check=True):
self.current_result += '0'
elif self.is_a('one', long_last_bit_check=True):
self.current_result += '1'
self.save_result()
self.state = 'reset'
self.current_result = None
self.start_time = None
del self.values[0]
def save_result(self):
if len(self.current_result) == self.expected_bit_count:
self.results_list.append({'time': self.start_time, 'data': self.current_result})
else:
self.discarded_list.append({'time': self.start_time, 'data': self.current_result, 'discard_time': self.values[0]['time']})
if len(self.current_result) > self.expected_bit_count:
print('Warning: received ' + str(self.current_result) + ' bits.')
def filter_glitches_out(self):
hi_time = self.values[1]['time'] - self.values[0]['time']
if hi_time < self.min_duration:
del self.values[1]
del self.values[0]
return True
low_time = self.values[2]['time'] - self.values[1]['time']
if low_time < self.min_duration:
del self.values[2]
del self.values[1]
return True
return False
def is_a(self, protocol_element, long_last_bit_check=False):
if self.values[0]['value'] == 0:
return False
hi_time = self.values[1]['time'] - self.values[0]['time']
low_time = self.values[2]['time'] - self.values[1]['time']
p_hi_time_min = self.protocol[protocol_element][0] * (self.protocol['pulse_len'] - self.pulse_len_tollerance) - self.extra_tollerance + self.tollerance_delay
p_hi_time_max = self.protocol[protocol_element][0] * (self.protocol['pulse_len'] + self.pulse_len_tollerance) + self.extra_tollerance + self.tollerance_delay
p_low_time_min = self.protocol[protocol_element][1] * (self.protocol['pulse_len'] - self.pulse_len_tollerance) - self.extra_tollerance + self.tollerance_delay
p_low_time_max = self.protocol[protocol_element][1] * (self.protocol['pulse_len'] + self.pulse_len_tollerance) + self.extra_tollerance + self.tollerance_delay
if hi_time < p_hi_time_min:
return False
if hi_time > p_hi_time_max:
return False
if low_time < p_low_time_min:
return False
if low_time > p_low_time_max:
if long_last_bit_check is True:
return True
else:
return False
return True |
'''
Given a sorted, increasing-order array with unique integer elements,
write an algorithm to create a binary search tree with minimal height.
'''
class myBST():
def __init__(self,key = None, parent = None):
# quick BST structure
self.key = key
self.parent = parent
self.right = None
self.left = None
def insert(self,key):
# insertion to a tree
if self.key == None: # edge case: key of node is None
self.key = key
else:
node = self
if key > node.key:
if node.right: # if there is a right child, recurse right, else create new node
node.right.insert(key)
else:
self.right = self.__class__(key,node)
self.right.key = key
else:
if node.left:
node.left.insert(key)
else:
self.left = self.__class__(key,node)
self.left.key = key
def __str__(self):
"Returns ASCII drawing of the tree"
s = str(self.key)
if (self.left is not None) or (self.right is not None):
ws = len(s)
sl, wl, cl = [''], 0, 0
if self.left is not None:
sl = str(self.left).splitlines()
wl = len(sl[0])
cl = len(sl[0].lstrip(' _'))
sr, wr, cr = [''], 0, 0
if self.right is not None:
sr = str(self.right).splitlines()
wr = len(sr[0])
cr = len(sr[0].rstrip(' _'))
while len(sl) < len(sr):
sl.append(' ' * wl)
while len(sr) < len(sl):
sr.append(' ' * wr)
s = s.rjust(ws + cl, '_').ljust(ws + cl + cr, '_')
s = [s.rjust(ws + wl + cr).ljust(ws + wl + wr)]
s = '\n'.join(s + [l + (' ' * ws) + r for (l,r) in zip(sl, sr)])
return s
def create_minimal_tree(self,arr):
# takes sorted increasing array of unique elements and creates a minimal height tree.
mid = len(arr)//2
self.insert(arr[mid]) # insert middle element
left = [i for i in arr[:mid]]
right = [i for i in arr[mid+1:]]
#print(left,right)
if left: # recurse on the left half of array
self.create_minimal_tree(left)
if right: # recurse on the right half of the array
self.create_minimal_tree(right)
bst = myBST()
a = range(31)
bst.create_minimal_tree(a)
print(bst)
| """
Given a sorted, increasing-order array with unique integer elements,
write an algorithm to create a binary search tree with minimal height.
"""
class Mybst:
def __init__(self, key=None, parent=None):
self.key = key
self.parent = parent
self.right = None
self.left = None
def insert(self, key):
if self.key == None:
self.key = key
else:
node = self
if key > node.key:
if node.right:
node.right.insert(key)
else:
self.right = self.__class__(key, node)
self.right.key = key
elif node.left:
node.left.insert(key)
else:
self.left = self.__class__(key, node)
self.left.key = key
def __str__(self):
"""Returns ASCII drawing of the tree"""
s = str(self.key)
if self.left is not None or self.right is not None:
ws = len(s)
(sl, wl, cl) = ([''], 0, 0)
if self.left is not None:
sl = str(self.left).splitlines()
wl = len(sl[0])
cl = len(sl[0].lstrip(' _'))
(sr, wr, cr) = ([''], 0, 0)
if self.right is not None:
sr = str(self.right).splitlines()
wr = len(sr[0])
cr = len(sr[0].rstrip(' _'))
while len(sl) < len(sr):
sl.append(' ' * wl)
while len(sr) < len(sl):
sr.append(' ' * wr)
s = s.rjust(ws + cl, '_').ljust(ws + cl + cr, '_')
s = [s.rjust(ws + wl + cr).ljust(ws + wl + wr)]
s = '\n'.join(s + [l + ' ' * ws + r for (l, r) in zip(sl, sr)])
return s
def create_minimal_tree(self, arr):
mid = len(arr) // 2
self.insert(arr[mid])
left = [i for i in arr[:mid]]
right = [i for i in arr[mid + 1:]]
if left:
self.create_minimal_tree(left)
if right:
self.create_minimal_tree(right)
bst = my_bst()
a = range(31)
bst.create_minimal_tree(a)
print(bst) |
"""
Prefer Interpolated F-Strings Over C-style Format Strings and str.format
"""
# Defining binary and hexadecimal variables
binary = 0b10111011
hexadecimal = 0xc5f
key = "my_var"
value = 1.234
pantry = [
("avocados", 125),
("bananas", 2.5),
("cherries", 15)
]
template = "%s loves food, See %s cook."
name = "everlookneversee"
if __name__ == '__main__':
# Converting binary and hexadecimal values to integer strings
print("Binary is %d, hexadecimal is %d" % (binary, hexadecimal))
print("\n" + "*-*" * 50 + "\n")
# First problem in c-style string formatting
formatted = "%-10s = %.2f" % (key, value)
print(formatted)
try:
formatted = "%-10s = %.2f" % (value, key)
print(formatted)
except TypeError:
print("Must be real number, not str")
try:
formatted = "%.2f = %-10s" % (key, value)
print(formatted)
except TypeError:
print("Must be real number, not str")
print("\n" + "*-*" * 50 + "\n")
# Second problem in c-style string formatting
for i, (item , count) in enumerate(pantry):
print('#%d: %-10s = %.2f' % (i, item, count))
print("\n")
for i, (item, count) in enumerate(pantry):
print('#%d: %-10s = %d' % (
i + 1,
item.title(),
round(count)
))
print("\n" + "*-*" * 50 + "\n")
# Third problem in c-style string formatting
formatted = template % (name, name)
print(formatted)
formatted = template % (name.title(), name.title())
print(formatted)
| """
Prefer Interpolated F-Strings Over C-style Format Strings and str.format
"""
binary = 187
hexadecimal = 3167
key = 'my_var'
value = 1.234
pantry = [('avocados', 125), ('bananas', 2.5), ('cherries', 15)]
template = '%s loves food, See %s cook.'
name = 'everlookneversee'
if __name__ == '__main__':
print('Binary is %d, hexadecimal is %d' % (binary, hexadecimal))
print('\n' + '*-*' * 50 + '\n')
formatted = '%-10s = %.2f' % (key, value)
print(formatted)
try:
formatted = '%-10s = %.2f' % (value, key)
print(formatted)
except TypeError:
print('Must be real number, not str')
try:
formatted = '%.2f = %-10s' % (key, value)
print(formatted)
except TypeError:
print('Must be real number, not str')
print('\n' + '*-*' * 50 + '\n')
for (i, (item, count)) in enumerate(pantry):
print('#%d: %-10s = %.2f' % (i, item, count))
print('\n')
for (i, (item, count)) in enumerate(pantry):
print('#%d: %-10s = %d' % (i + 1, item.title(), round(count)))
print('\n' + '*-*' * 50 + '\n')
formatted = template % (name, name)
print(formatted)
formatted = template % (name.title(), name.title())
print(formatted) |
#! /usr/bin/env python3
# Load maze file into nested array:
with open('../inputs/input25.txt') as fp:
grid = [list(line.strip()) for line in fp.readlines()]
ydim = len(grid)
xdim = len(grid[0])
SYMBOLS = { 'east': '>', 'south': 'v', 'empty': '.'}
# Look up which coords a mover wants to move to
def target_cell(coords, type):
(x, y) = coords
if type == SYMBOLS['east']:
return ((x + 1) % xdim, y)
elif type == SYMBOLS['south']:
return (x, (y + 1) % ydim)
# Prepare the new grid after moving all of one type of symbol
def move_all_facers(grid, type):
# Count how many moved:
moves = 0
# Pre-fill with empties
grid1 = [[SYMBOLS['empty'] for _x in range(xdim)] for _y in range(ydim)]
# Map movers into grid1
for y in range(ydim):
for x in range(xdim):
if grid[y][x] == type:
(tx, ty) = target_cell((x,y), type)
if grid[ty][tx] == SYMBOLS['empty']:
# Make move
grid1[ty][tx] = type
grid1[y][x] = SYMBOLS['empty']
moves += 1
else:
# Stay put
grid1[y][x] = type
# Current movers all changed in grid from symbol to dot, in grid1 from dot to symbol
# Now backfill all non-movers:
for y in range(ydim):
for x in range(xdim):
if grid[y][x] != type and grid1[y][x] != type:
grid1[y][x] = grid[y][x]
return (grid1, moves)
def pgrid(grid):
for row in grid:
print("".join(row))
print("---")
# Do one step, moving all the symbols that have a space to move into
def step(grid):
# East moves first, then South
(grid, east_moves) = move_all_facers(grid, SYMBOLS['east'])
# pgrid(grid)
(grid, south_moves) = move_all_facers(grid, SYMBOLS['south'])
# pgrid(grid)
return (grid, east_moves + south_moves)
# How many steps before grid reaches a settled state?
steps = 0
while 1:
steps += 1
# print("Step {}".format(steps))
(grid, moves) = step(grid)
if moves == 0:
break
print("Part 1:", steps)
| with open('../inputs/input25.txt') as fp:
grid = [list(line.strip()) for line in fp.readlines()]
ydim = len(grid)
xdim = len(grid[0])
symbols = {'east': '>', 'south': 'v', 'empty': '.'}
def target_cell(coords, type):
(x, y) = coords
if type == SYMBOLS['east']:
return ((x + 1) % xdim, y)
elif type == SYMBOLS['south']:
return (x, (y + 1) % ydim)
def move_all_facers(grid, type):
moves = 0
grid1 = [[SYMBOLS['empty'] for _x in range(xdim)] for _y in range(ydim)]
for y in range(ydim):
for x in range(xdim):
if grid[y][x] == type:
(tx, ty) = target_cell((x, y), type)
if grid[ty][tx] == SYMBOLS['empty']:
grid1[ty][tx] = type
grid1[y][x] = SYMBOLS['empty']
moves += 1
else:
grid1[y][x] = type
for y in range(ydim):
for x in range(xdim):
if grid[y][x] != type and grid1[y][x] != type:
grid1[y][x] = grid[y][x]
return (grid1, moves)
def pgrid(grid):
for row in grid:
print(''.join(row))
print('---')
def step(grid):
(grid, east_moves) = move_all_facers(grid, SYMBOLS['east'])
(grid, south_moves) = move_all_facers(grid, SYMBOLS['south'])
return (grid, east_moves + south_moves)
steps = 0
while 1:
steps += 1
(grid, moves) = step(grid)
if moves == 0:
break
print('Part 1:', steps) |
def solve(arr):
n = len(arr)
lis = [1 for _ in range(n)]
for i in range(1, n):
for j in range(0, i):
if arr[j] < arr[i] and lis[i] < 1 + lis[j]:
lis[i] = 1 + lis[j]
return max(lis)
arr = [3, 10, 2, 1, 20]
assert 3 == solve(arr)
arr = [3, 2]
assert 1 == solve(arr)
arr = [50, 3, 10, 7, 40, 80]
assert 4 == solve(arr) | def solve(arr):
n = len(arr)
lis = [1 for _ in range(n)]
for i in range(1, n):
for j in range(0, i):
if arr[j] < arr[i] and lis[i] < 1 + lis[j]:
lis[i] = 1 + lis[j]
return max(lis)
arr = [3, 10, 2, 1, 20]
assert 3 == solve(arr)
arr = [3, 2]
assert 1 == solve(arr)
arr = [50, 3, 10, 7, 40, 80]
assert 4 == solve(arr) |
#pragma error
#pragma repy restrictions.badcallname
pass
| pass |
class TestAnomalyDetector(object):
# Lets make some dummy tests to test our Travis-CI configuration
def test_pass(self):
assert 1 == 1
def nothing(self):
print('This does nothing'); | class Testanomalydetector(object):
def test_pass(self):
assert 1 == 1
def nothing(self):
print('This does nothing') |
# Copyright 2022 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The implementation of the `java_proto_library` rule and its aspect."""
load(":common/java/java_semantics.bzl", "semantics")
load(":common/proto/proto_common.bzl", "ProtoLangToolchainInfo", proto_common = "proto_common_do_not_use")
java_common = _builtins.toplevel.java_common
JavaInfo = _builtins.toplevel.JavaInfo
ProtoInfo = _builtins.toplevel.ProtoInfo
# The provider is used to collect source and runtime jars in the `proto_library` dependency graph.
JavaProtoAspectInfo = provider("JavaProtoAspectInfo", fields = ["jars"])
def _filter_provider(provider, *attrs):
return [dep[provider] for attr in attrs for dep in attr if provider in dep]
def _bazel_java_proto_aspect_impl(target, ctx):
"""Generates and compiles Java code for a proto_library.
The function runs protobuf compiler on the `proto_library` target using
`proto_lang_toolchain` specified by `--proto_toolchain_for_java` flag.
This generates a source jar.
After that the source jar is compiled, respecting `deps` and `exports` of
the `proto_library`.
Args:
target: (Target) The `proto_library` target (any target providing `ProtoInfo`.
ctx: (RuleContext) The rule context.
Returns:
([JavaInfo, JavaProtoAspectInfo]) A JavaInfo describing compiled Java
version of`proto_library` and `JavaProtoAspectInfo` with all source and
runtime jars.
"""
proto_toolchain_info = ctx.attr._aspect_java_proto_toolchain[ProtoLangToolchainInfo]
source_jar = None
if proto_common.experimental_should_generate_code(target, proto_toolchain_info, "java_proto_library"):
# Generate source jar using proto compiler.
source_jar = ctx.actions.declare_file(ctx.label.name + "-speed-src.jar")
proto_common.compile(
ctx.actions,
proto_toolchain_info,
[source_jar],
source_jar,
proto_info = target[ProtoInfo],
)
# Compile Java sources (or just merge if there aren't any)
deps = _filter_provider(JavaInfo, ctx.rule.attr.deps)
exports = _filter_provider(JavaInfo, ctx.rule.attr.exports)
if source_jar and proto_toolchain_info.runtime:
deps.append(proto_toolchain_info.runtime[JavaInfo])
java_info, jars = java_compile_for_protos(
ctx,
"-speed.jar",
source_jar,
deps,
exports,
)
transitive_jars = [dep[JavaProtoAspectInfo].jars for dep in ctx.rule.attr.deps if JavaProtoAspectInfo in dep]
return [
java_info,
JavaProtoAspectInfo(jars = depset(jars, transitive = transitive_jars)),
]
def java_compile_for_protos(ctx, output_jar_suffix, source_jar = None, deps = [], exports = [], injecting_rule_kind = "java_proto_library"):
"""Compiles Java source jar returned by proto compiler.
Use this call for java_xxx_proto_library. It uses java_common.compile with
some checks disabled (via javacopts) and jspecify disabled, so that the
generated code passes.
It also takes care that input source jar is not repackaged with a different
name.
When `source_jar` is `None`, the function only merges `deps` and `exports`.
Args:
ctx: (RuleContext) Used to call `java_common.compile`
output_jar_suffix: (str) How to name the output jar. For example: `-speed.jar`.
source_jar: (File) Input source jar (may be `None`).
deps: (list[JavaInfo]) `deps` of the `proto_library`.
exports: (list[JavaInfo]) `exports` of the `proto_library`.
injecting_rule_kind: (str) Rule kind requesting the compilation.
It's embedded into META-INF of the produced runtime jar, for debugging.
Returns:
((JavaInfo, list[File])) JavaInfo of this target and list containing source
and runtime jar, when they are created.
"""
if source_jar != None:
path, sep, filename = ctx.label.name.rpartition("/")
output_jar = ctx.actions.declare_file(path + sep + "lib" + filename + output_jar_suffix)
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo]
java_info = java_common.compile(
ctx,
source_jars = [source_jar],
deps = deps,
exports = exports,
output = output_jar,
output_source_jar = source_jar,
injecting_rule_kind = injecting_rule_kind,
javac_opts = java_toolchain.compatible_javacopts("proto"),
enable_jspecify = False,
java_toolchain = java_toolchain,
include_compilation_info = False,
)
jars = [source_jar, output_jar]
else:
# If there are no proto sources just pass along the compilation dependencies.
java_info = java_common.merge(deps + exports, merge_java_outputs = False, merge_source_jars = False)
jars = []
return java_info, jars
bazel_java_proto_aspect = aspect(
implementation = _bazel_java_proto_aspect_impl,
attrs = {
"_aspect_java_proto_toolchain": attr.label(
default = configuration_field(fragment = "proto", name = "proto_toolchain_for_java"),
),
"_java_toolchain": attr.label(
default = Label(semantics.JAVA_TOOLCHAIN_LABEL),
),
},
attr_aspects = ["deps", "exports"],
required_providers = [ProtoInfo],
provides = [JavaInfo, JavaProtoAspectInfo],
fragments = ["java"],
)
def bazel_java_proto_library_rule(ctx):
"""Merges results of `java_proto_aspect` in `deps`.
Args:
ctx: (RuleContext) The rule context.
Returns:
([JavaInfo, DefaultInfo, OutputGroupInfo])
"""
java_info = java_common.merge([dep[JavaInfo] for dep in ctx.attr.deps], merge_java_outputs = False)
transitive_src_and_runtime_jars = depset(transitive = [dep[JavaProtoAspectInfo].jars for dep in ctx.attr.deps])
transitive_runtime_jars = depset(transitive = [java_info.transitive_runtime_jars])
return [
java_info,
DefaultInfo(
files = transitive_src_and_runtime_jars,
runfiles = ctx.runfiles(transitive_files = transitive_runtime_jars),
),
OutputGroupInfo(default = depset()),
]
java_proto_library = rule(
implementation = bazel_java_proto_library_rule,
attrs = {
"deps": attr.label_list(providers = [ProtoInfo], aspects = [bazel_java_proto_aspect]),
"licenses": attr.license() if hasattr(attr, "license") else attr.string_list(),
"distribs": attr.string_list(),
},
provides = [JavaInfo],
)
| """The implementation of the `java_proto_library` rule and its aspect."""
load(':common/java/java_semantics.bzl', 'semantics')
load(':common/proto/proto_common.bzl', 'ProtoLangToolchainInfo', proto_common='proto_common_do_not_use')
java_common = _builtins.toplevel.java_common
java_info = _builtins.toplevel.JavaInfo
proto_info = _builtins.toplevel.ProtoInfo
java_proto_aspect_info = provider('JavaProtoAspectInfo', fields=['jars'])
def _filter_provider(provider, *attrs):
return [dep[provider] for attr in attrs for dep in attr if provider in dep]
def _bazel_java_proto_aspect_impl(target, ctx):
"""Generates and compiles Java code for a proto_library.
The function runs protobuf compiler on the `proto_library` target using
`proto_lang_toolchain` specified by `--proto_toolchain_for_java` flag.
This generates a source jar.
After that the source jar is compiled, respecting `deps` and `exports` of
the `proto_library`.
Args:
target: (Target) The `proto_library` target (any target providing `ProtoInfo`.
ctx: (RuleContext) The rule context.
Returns:
([JavaInfo, JavaProtoAspectInfo]) A JavaInfo describing compiled Java
version of`proto_library` and `JavaProtoAspectInfo` with all source and
runtime jars.
"""
proto_toolchain_info = ctx.attr._aspect_java_proto_toolchain[ProtoLangToolchainInfo]
source_jar = None
if proto_common.experimental_should_generate_code(target, proto_toolchain_info, 'java_proto_library'):
source_jar = ctx.actions.declare_file(ctx.label.name + '-speed-src.jar')
proto_common.compile(ctx.actions, proto_toolchain_info, [source_jar], source_jar, proto_info=target[ProtoInfo])
deps = _filter_provider(JavaInfo, ctx.rule.attr.deps)
exports = _filter_provider(JavaInfo, ctx.rule.attr.exports)
if source_jar and proto_toolchain_info.runtime:
deps.append(proto_toolchain_info.runtime[JavaInfo])
(java_info, jars) = java_compile_for_protos(ctx, '-speed.jar', source_jar, deps, exports)
transitive_jars = [dep[JavaProtoAspectInfo].jars for dep in ctx.rule.attr.deps if JavaProtoAspectInfo in dep]
return [java_info, java_proto_aspect_info(jars=depset(jars, transitive=transitive_jars))]
def java_compile_for_protos(ctx, output_jar_suffix, source_jar=None, deps=[], exports=[], injecting_rule_kind='java_proto_library'):
"""Compiles Java source jar returned by proto compiler.
Use this call for java_xxx_proto_library. It uses java_common.compile with
some checks disabled (via javacopts) and jspecify disabled, so that the
generated code passes.
It also takes care that input source jar is not repackaged with a different
name.
When `source_jar` is `None`, the function only merges `deps` and `exports`.
Args:
ctx: (RuleContext) Used to call `java_common.compile`
output_jar_suffix: (str) How to name the output jar. For example: `-speed.jar`.
source_jar: (File) Input source jar (may be `None`).
deps: (list[JavaInfo]) `deps` of the `proto_library`.
exports: (list[JavaInfo]) `exports` of the `proto_library`.
injecting_rule_kind: (str) Rule kind requesting the compilation.
It's embedded into META-INF of the produced runtime jar, for debugging.
Returns:
((JavaInfo, list[File])) JavaInfo of this target and list containing source
and runtime jar, when they are created.
"""
if source_jar != None:
(path, sep, filename) = ctx.label.name.rpartition('/')
output_jar = ctx.actions.declare_file(path + sep + 'lib' + filename + output_jar_suffix)
java_toolchain = ctx.attr._java_toolchain[java_common.JavaToolchainInfo]
java_info = java_common.compile(ctx, source_jars=[source_jar], deps=deps, exports=exports, output=output_jar, output_source_jar=source_jar, injecting_rule_kind=injecting_rule_kind, javac_opts=java_toolchain.compatible_javacopts('proto'), enable_jspecify=False, java_toolchain=java_toolchain, include_compilation_info=False)
jars = [source_jar, output_jar]
else:
java_info = java_common.merge(deps + exports, merge_java_outputs=False, merge_source_jars=False)
jars = []
return (java_info, jars)
bazel_java_proto_aspect = aspect(implementation=_bazel_java_proto_aspect_impl, attrs={'_aspect_java_proto_toolchain': attr.label(default=configuration_field(fragment='proto', name='proto_toolchain_for_java')), '_java_toolchain': attr.label(default=label(semantics.JAVA_TOOLCHAIN_LABEL))}, attr_aspects=['deps', 'exports'], required_providers=[ProtoInfo], provides=[JavaInfo, JavaProtoAspectInfo], fragments=['java'])
def bazel_java_proto_library_rule(ctx):
"""Merges results of `java_proto_aspect` in `deps`.
Args:
ctx: (RuleContext) The rule context.
Returns:
([JavaInfo, DefaultInfo, OutputGroupInfo])
"""
java_info = java_common.merge([dep[JavaInfo] for dep in ctx.attr.deps], merge_java_outputs=False)
transitive_src_and_runtime_jars = depset(transitive=[dep[JavaProtoAspectInfo].jars for dep in ctx.attr.deps])
transitive_runtime_jars = depset(transitive=[java_info.transitive_runtime_jars])
return [java_info, default_info(files=transitive_src_and_runtime_jars, runfiles=ctx.runfiles(transitive_files=transitive_runtime_jars)), output_group_info(default=depset())]
java_proto_library = rule(implementation=bazel_java_proto_library_rule, attrs={'deps': attr.label_list(providers=[ProtoInfo], aspects=[bazel_java_proto_aspect]), 'licenses': attr.license() if hasattr(attr, 'license') else attr.string_list(), 'distribs': attr.string_list()}, provides=[JavaInfo]) |
"""
Define contstants
"""
LOOP_DEV = "/dev/loop0"
IMG_FILE = "/tmp/hl_lvm.img"
IMG_SIZE = 128 * 1024 ** 2
TEST_VG = "holland"
TEST_LV = "test_lv"
| """
Define contstants
"""
loop_dev = '/dev/loop0'
img_file = '/tmp/hl_lvm.img'
img_size = 128 * 1024 ** 2
test_vg = 'holland'
test_lv = 'test_lv' |
load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
load("@bazel_skylib//lib:paths.bzl", "paths")
load("//ocaml:providers.bzl",
"CompilationModeSettingProvider",
"OcamlProvider",
"OcamlNsResolverProvider",
"OcamlLibraryMarker",
"OcamlModuleMarker",
"OcamlNsMarker")
load("//ppx:providers.bzl",
"PpxCodepsProvider",
)
load(":impl_common.bzl", "dsorder", "module_sep", "resolver_suffix")
load(":impl_ccdeps.bzl", "dump_CcInfo")
# load("//ocaml/_functions:utils.bzl", "get_sdkpath")
## Plain Library targets do not produce anything, they just pass on
## their deps.
## NS Lib targets also do not directly produce anything, they just
## pass on their deps. The real work is done in the transition
## functions, which set the ConfigState that controls build actions of
## deps.
#################
def impl_library(ctx, mode, tool, tool_args):
debug = False
# print("**** NS_LIB {} ****************".format(ctx.label))
# env = {"PATH": get_sdkpath(ctx)}
# tc = ctx.toolchains["@rules_ocaml//ocaml:toolchain"]
# mode = ctx.attr._mode[CompilationModeSettingProvider].value
ns_resolver_depset = None
ns_resolver_module = None
ns_resolver = []
ns_resolver_files = []
the_ns_resolvers = []
# WARNING: due to transition processing, ns_resolver providers
# must be indexed by [0]
if ctx.attr._rule.startswith("ocaml_ns"):
# print("tgt: %s" % ctx.label)
# print("rule: %s" % ctx.attr._rule)
if ctx.attr.resolver:
# print("user-provided resolver")
ns_resolver = ctx.attr.resolver
ns_resolver_module = ctx.file.resolver
ns_name = ctx.attr.ns
else:
# print("generated resolver")
# print("NS RESOLVER FILECT: %s" % len(ctx.files._ns_resolver))
ns_resolver = ctx.attr._ns_resolver[0] # index by int
ns_resolver_module = ctx.files._ns_resolver[0]
# print("ns_resolver: %s" % ns_resolver)
# print("ns_resolver_module: %s" % ns_resolver_module)
if OcamlNsResolverProvider in ns_resolver:
# print("LBL: %s" % ctx.label)
# print("ns_resolver: %s" % ns_resolver[OcamlNsResolverProvider])
if hasattr(ns_resolver[OcamlNsResolverProvider], "ns_name"):
ns_name = ns_resolver[OcamlNsResolverProvider].ns_name
else:
# FIXME: when does this happen?
ns_name = ""
## if ns_resolver ends in __0Resolver, then we know that one
## of the submodules is a user-provided resolver; the
## __0Resolver was just used to compile the submodules. So we
## need to find the user-provided resolver (its name matches
## the ns name), and make all the other submodules depend on
## it.
## pathological case: ns contains a single user-provided
## resolver. in that case we have no aliases so no resolver.
## there would be no point in such an ns but its possible.
if ns_resolver_module:
# print("LBL: %s" % ctx.label)
(ns_resolver_mname, ext) = paths.split_extension(ns_resolver_module.basename)
# print("ns_resolver_mname: %s" % ns_resolver_mname)
if ns_resolver_mname == ns_name + resolver_suffix:
print("Resolver is user-provided")
user_provided_resolver = True
else:
user_provided_resolver = False
else:
user_provided_resolver = False
if user_provided_resolver:
##FIXME: efficiency
for submodule in ctx.files.submodules:
(bname, ext) = paths.split_extension(submodule.basename)
if bname == ns_name:
print("Found user-provided resolver submodule")
the_ns_resolvers.append(submodule)
# else:
if OcamlProvider in ns_resolver: ##ctx.attr._ns_resolver[0]:
# print("ns_resolver provider: %s" % ns_resolver[OcamlProvider])
ns_resolver_files = ns_resolver[OcamlProvider].inputs
ns_resolver_depset = ns_resolver[OcamlProvider].inputs
# the_ns_resolvers.append(ns_resolver_module[0])
# print("ns_resolver_depset: %s" % ns_resolver_depset)
# print("ns_name: %s" % ns_name)
################
## FIXME: does lib need to handle adjunct deps? they're carried by
## modules
indirect_adjunct_depsets = []
indirect_adjunct_path_depsets = []
################
paths_direct = []
# resolver_depsets_list = []
#######################
direct_deps_attr = None
if ctx.attr._rule == "ocaml_ns_archive":
direct_dep_files = ctx.files.submodules
direct_deps_attr = ctx.attr.submodules
elif ctx.attr._rule == "ocaml_ns_library":
direct_dep_files = ctx.files.submodules
direct_deps_attr = ctx.attr.submodules
elif ctx.attr._rule == "ocaml_archive":
direct_dep_files = ctx.files.manifest
direct_deps_attr = ctx.attr.manifest
elif ctx.attr._rule == "ocaml_library":
direct_dep_files = ctx.files.manifest
direct_deps_attr = ctx.attr.manifest
else:
fail("impl_library called by non-aggregator: %s" % ctx.attr._rule)
## FIXME: direct_dep_files (and direct_deps_attr) are in the order
## set by the submodule/modules attribute; they must be put in
## dependency-order.
for f in direct_dep_files:
paths_direct.append(f.dirname)
# if ctx.label.name == "tezos-shell":
# print("LBL: %s" % ctx.label)
# for dep in direct_deps_attr:
# print("DEP: %s" % dep[OcamlProvider].fileset)
#### INDIRECT DEPS first ####
# these are "indirect" from the perspective of the consumer
indirect_fileset_depsets = []
indirect_inputs_depsets = []
indirect_linkargs_depsets = []
indirect_paths_depsets = []
ccInfo_list = []
direct_module_deps_files = ctx.files.submodules if ctx.attr._rule.startswith("ocaml_ns") else ctx.files.manifest
direct_module_deps = ctx.attr.submodules if ctx.attr._rule.startswith("ocaml_ns") else ctx.attr.manifest
for dep in direct_module_deps:
# if ctx.label.name == 'tezos-base':
# print("DEPPP: %s" % dep)
# ignore DefaultInfo, its just for printing, not propagation
if OcamlProvider in dep: # should always be True
# if ctx.label.name == 'tezos-base':
# print("directdep: %s" % dep[OcamlProvider])
indirect_fileset_depsets.append(dep[OcamlProvider].fileset)
# linkargs: what goes on cmd line to build archive or
# executable FIXME: __excluding__ sibling modules! Why?
# because even if we put only indirect deps in linkargs,
# the head (direct) dep could still appear anywhere in the
# dep closure; in particular, we may have sibling deps, in
# which case omitting the head dep for linkargs would do
# us no good. So we need to filter to remove ALL
# (sub)modules from linkargs.
# if linkarg not in direct_module_deps_files:
indirect_linkargs_depsets.append(dep[OcamlProvider].linkargs)
# if ctx.label.name == "tezos-base":
# print("LIBDEP LINKARGS: %s" % dep[OcamlProvider].linkargs)
# indirect_linkargs_depsets.append(dep[OcamlProvider].files)
## inputs == all deps
indirect_inputs_depsets.append(dep[OcamlProvider].inputs)
indirect_paths_depsets.append(dep[OcamlProvider].paths)
indirect_linkargs_depsets.append(dep[DefaultInfo].files)
if CcInfo in dep:
## we do not need to do anything with ccdeps here,
## just pass them on in a provider
# if ctx.label.name == "tezos-legacy-store":
# dump_CcInfo(ctx, dep)
ccInfo_list.append(dep[CcInfo])
if PpxCodepsProvider in dep:
indirect_adjunct_path_depsets.append(dep[PpxCodepsProvider].paths)
indirect_adjunct_depsets.append(dep[PpxCodepsProvider].ppx_codeps)
# print("indirect_inputs_depsets: %s" % indirect_inputs_depsets)
# normalized_direct_dep_files = []
# for dep in direct_dep_files:
# print("direct dep: %s" % dep)
# print("the_ns_resolvers: %s" % the_ns_resolvers)
# # (bname, ext) = paths.split_extension(dep.basename)
# if dep.basename not in the_ns_resolvers: ## [0].basename:
# normalized_direct_dep_files.append(dep)
# else:
# print("removing %s" % dep)
inputs_depset = depset(
order = dsorder,
direct = direct_dep_files,
transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + indirect_inputs_depsets
# + [depset(direct_dep_files)]
)
## To put direct deps in dep-order, we need to merge the linkargs
## deps and iterate over them:
new_linkargs = []
## start with ns_resolver:
if ctx.attr._rule.startswith("ocaml_ns"):
if ns_resolver:
for f in ns_resolver[DefaultInfo].files.to_list():
# for f in ns_resolver[0].files.to_list():
paths_direct.append(f.dirname)
new_linkargs.append(f)
linkargs_depset = depset(
order = dsorder,
## direct = ns_resolver_files,
transitive = indirect_linkargs_depsets
# transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + indirect_linkargs_depsets
)
for dep in inputs_depset.to_list():
if dep in direct_dep_files:
new_linkargs.append(dep)
#######################
## Do we need to do this? Why?
ctx.actions.do_nothing(
mnemonic = "NS_LIB",
inputs = inputs_depset
)
#######################
# print("INPUTS_DEPSET: %s" % inputs_depset)
# print("the_ns_resolvers: %s" % the_ns_resolvers)
#### PROVIDERS ####
defaultDepset = depset(
order = dsorder,
# direct = normalized_direct_dep_files, # ns_resolver_module,
# transitive = [depset(direct = the_ns_resolvers)]
direct = the_ns_resolvers + [ns_resolver_module] if ns_resolver_module else [],
transitive = [depset(direct_dep_files)]
# transitive = [depset(normalized_direct_dep_files)]
)
defaultInfo = DefaultInfo(
files = defaultDepset
)
################ ppx codeps ################
ppx_codeps_depset = depset(
order = dsorder,
transitive = indirect_adjunct_depsets
)
ppxAdjunctsProvider = PpxCodepsProvider(
ppx_codeps = ppx_codeps_depset,
paths = depset(
order = dsorder,
transitive = indirect_adjunct_path_depsets
)
)
new_inputs_depset = depset(
order = dsorder,
## direct = ns_resolver_files,
transitive = ([ns_resolver_depset] if ns_resolver_depset else []) + [inputs_depset]
# + indirect_inputs_depsets
)
paths_depset = depset(
order = dsorder,
direct = paths_direct,
transitive = indirect_paths_depsets
)
# print("new_linkargs: %s" % new_linkargs)
ocamlProvider = OcamlProvider(
files = depset(direct=new_linkargs),
fileset = depset(
transitive=([ns_resolver_depset] if ns_resolver_depset else []) + indirect_fileset_depsets
),
inputs = new_inputs_depset,
linkargs = linkargs_depset,
paths = paths_depset,
ns_resolver = ns_resolver,
)
# print("ocamlProvider: %s" % ocamlProvider)
outputGroupInfo = OutputGroupInfo(
resolver = ns_resolver_files,
ppx_codeps = ppx_codeps_depset,
# cc = ... extract from CcInfo?
all = depset(
order = dsorder,
transitive=[
new_inputs_depset,
]
)
)
providers = [
defaultInfo,
ocamlProvider,
ppxAdjunctsProvider,
outputGroupInfo,
]
providers.append(
OcamlLibraryMarker(marker = "OcamlLibraryMarker")
)
if ctx.attr._rule.startswith("ocaml_ns"):
providers.append(
OcamlNsMarker(
marker = "OcamlNsMarker",
ns_name = ns_name if ns_resolver else ""
),
)
# if ctx.label.name == "tezos-legacy-store":
# print("ccInfo_list ct: %s" % len(ccInfo_list))
ccInfo_merged = cc_common.merge_cc_infos(cc_infos = ccInfo_list)
# if ctx.label.name == "tezos-legacy-store":
# print("ccInfo_merged: %s" % ccInfo_merged)
if ccInfo_list:
providers.append(ccInfo_merged)
return providers
| load('@bazel_skylib//rules:common_settings.bzl', 'BuildSettingInfo')
load('@bazel_skylib//lib:paths.bzl', 'paths')
load('//ocaml:providers.bzl', 'CompilationModeSettingProvider', 'OcamlProvider', 'OcamlNsResolverProvider', 'OcamlLibraryMarker', 'OcamlModuleMarker', 'OcamlNsMarker')
load('//ppx:providers.bzl', 'PpxCodepsProvider')
load(':impl_common.bzl', 'dsorder', 'module_sep', 'resolver_suffix')
load(':impl_ccdeps.bzl', 'dump_CcInfo')
def impl_library(ctx, mode, tool, tool_args):
debug = False
ns_resolver_depset = None
ns_resolver_module = None
ns_resolver = []
ns_resolver_files = []
the_ns_resolvers = []
if ctx.attr._rule.startswith('ocaml_ns'):
if ctx.attr.resolver:
ns_resolver = ctx.attr.resolver
ns_resolver_module = ctx.file.resolver
ns_name = ctx.attr.ns
else:
ns_resolver = ctx.attr._ns_resolver[0]
ns_resolver_module = ctx.files._ns_resolver[0]
if OcamlNsResolverProvider in ns_resolver:
if hasattr(ns_resolver[OcamlNsResolverProvider], 'ns_name'):
ns_name = ns_resolver[OcamlNsResolverProvider].ns_name
else:
ns_name = ''
if ns_resolver_module:
(ns_resolver_mname, ext) = paths.split_extension(ns_resolver_module.basename)
if ns_resolver_mname == ns_name + resolver_suffix:
print('Resolver is user-provided')
user_provided_resolver = True
else:
user_provided_resolver = False
else:
user_provided_resolver = False
if user_provided_resolver:
for submodule in ctx.files.submodules:
(bname, ext) = paths.split_extension(submodule.basename)
if bname == ns_name:
print('Found user-provided resolver submodule')
the_ns_resolvers.append(submodule)
if OcamlProvider in ns_resolver:
ns_resolver_files = ns_resolver[OcamlProvider].inputs
ns_resolver_depset = ns_resolver[OcamlProvider].inputs
indirect_adjunct_depsets = []
indirect_adjunct_path_depsets = []
paths_direct = []
direct_deps_attr = None
if ctx.attr._rule == 'ocaml_ns_archive':
direct_dep_files = ctx.files.submodules
direct_deps_attr = ctx.attr.submodules
elif ctx.attr._rule == 'ocaml_ns_library':
direct_dep_files = ctx.files.submodules
direct_deps_attr = ctx.attr.submodules
elif ctx.attr._rule == 'ocaml_archive':
direct_dep_files = ctx.files.manifest
direct_deps_attr = ctx.attr.manifest
elif ctx.attr._rule == 'ocaml_library':
direct_dep_files = ctx.files.manifest
direct_deps_attr = ctx.attr.manifest
else:
fail('impl_library called by non-aggregator: %s' % ctx.attr._rule)
for f in direct_dep_files:
paths_direct.append(f.dirname)
indirect_fileset_depsets = []
indirect_inputs_depsets = []
indirect_linkargs_depsets = []
indirect_paths_depsets = []
cc_info_list = []
direct_module_deps_files = ctx.files.submodules if ctx.attr._rule.startswith('ocaml_ns') else ctx.files.manifest
direct_module_deps = ctx.attr.submodules if ctx.attr._rule.startswith('ocaml_ns') else ctx.attr.manifest
for dep in direct_module_deps:
if OcamlProvider in dep:
indirect_fileset_depsets.append(dep[OcamlProvider].fileset)
indirect_linkargs_depsets.append(dep[OcamlProvider].linkargs)
indirect_inputs_depsets.append(dep[OcamlProvider].inputs)
indirect_paths_depsets.append(dep[OcamlProvider].paths)
indirect_linkargs_depsets.append(dep[DefaultInfo].files)
if CcInfo in dep:
ccInfo_list.append(dep[CcInfo])
if PpxCodepsProvider in dep:
indirect_adjunct_path_depsets.append(dep[PpxCodepsProvider].paths)
indirect_adjunct_depsets.append(dep[PpxCodepsProvider].ppx_codeps)
inputs_depset = depset(order=dsorder, direct=direct_dep_files, transitive=([ns_resolver_depset] if ns_resolver_depset else []) + indirect_inputs_depsets)
new_linkargs = []
if ctx.attr._rule.startswith('ocaml_ns'):
if ns_resolver:
for f in ns_resolver[DefaultInfo].files.to_list():
paths_direct.append(f.dirname)
new_linkargs.append(f)
linkargs_depset = depset(order=dsorder, transitive=indirect_linkargs_depsets)
for dep in inputs_depset.to_list():
if dep in direct_dep_files:
new_linkargs.append(dep)
ctx.actions.do_nothing(mnemonic='NS_LIB', inputs=inputs_depset)
default_depset = depset(order=dsorder, direct=the_ns_resolvers + [ns_resolver_module] if ns_resolver_module else [], transitive=[depset(direct_dep_files)])
default_info = default_info(files=defaultDepset)
ppx_codeps_depset = depset(order=dsorder, transitive=indirect_adjunct_depsets)
ppx_adjuncts_provider = ppx_codeps_provider(ppx_codeps=ppx_codeps_depset, paths=depset(order=dsorder, transitive=indirect_adjunct_path_depsets))
new_inputs_depset = depset(order=dsorder, transitive=([ns_resolver_depset] if ns_resolver_depset else []) + [inputs_depset])
paths_depset = depset(order=dsorder, direct=paths_direct, transitive=indirect_paths_depsets)
ocaml_provider = ocaml_provider(files=depset(direct=new_linkargs), fileset=depset(transitive=([ns_resolver_depset] if ns_resolver_depset else []) + indirect_fileset_depsets), inputs=new_inputs_depset, linkargs=linkargs_depset, paths=paths_depset, ns_resolver=ns_resolver)
output_group_info = output_group_info(resolver=ns_resolver_files, ppx_codeps=ppx_codeps_depset, all=depset(order=dsorder, transitive=[new_inputs_depset]))
providers = [defaultInfo, ocamlProvider, ppxAdjunctsProvider, outputGroupInfo]
providers.append(ocaml_library_marker(marker='OcamlLibraryMarker'))
if ctx.attr._rule.startswith('ocaml_ns'):
providers.append(ocaml_ns_marker(marker='OcamlNsMarker', ns_name=ns_name if ns_resolver else ''))
cc_info_merged = cc_common.merge_cc_infos(cc_infos=ccInfo_list)
if ccInfo_list:
providers.append(ccInfo_merged)
return providers |
def celsius_to_fahrenheit(Celsius):
F = (Celsius/5)*9 + 32
print(F)
def celsius_to_kelvin(Celsius):
K = Celsius + 273
print(K)
def kelvin_to_celsius(Kelvin):
C = Kelvin - 273
print(C)
def kelvin_to_fahrenheit(Kelvin):
F = (((Kelvin - 273) / 5) * 9) + 32
print(F)
def fahrenheit_to_kelvin(Fahrenheit):
K = (((Fahrenheit - 32) / 9) * 5) + 273
print(K)
def fahrenheit_to_celsius(Fahrenheit):
C = ((Fahrenheit - 32) / 9) * 5
print(C) | def celsius_to_fahrenheit(Celsius):
f = Celsius / 5 * 9 + 32
print(F)
def celsius_to_kelvin(Celsius):
k = Celsius + 273
print(K)
def kelvin_to_celsius(Kelvin):
c = Kelvin - 273
print(C)
def kelvin_to_fahrenheit(Kelvin):
f = (Kelvin - 273) / 5 * 9 + 32
print(F)
def fahrenheit_to_kelvin(Fahrenheit):
k = (Fahrenheit - 32) / 9 * 5 + 273
print(K)
def fahrenheit_to_celsius(Fahrenheit):
c = (Fahrenheit - 32) / 9 * 5
print(C) |
"""Module for compilation configuration."""
class CompilationConfiguration:
"""Class that allows the compilation process to be customized."""
dump_artifacts_on_unexpected_failures: bool
enable_topological_optimizations: bool
check_every_input_in_inputset: bool
treat_warnings_as_errors: bool
enable_unsafe_features: bool
random_inputset_samples: int
use_insecure_key_cache: bool
def __init__(
self,
dump_artifacts_on_unexpected_failures: bool = True,
enable_topological_optimizations: bool = True,
check_every_input_in_inputset: bool = False,
treat_warnings_as_errors: bool = False,
enable_unsafe_features: bool = False,
random_inputset_samples: int = 30,
use_insecure_key_cache: bool = False,
):
self.dump_artifacts_on_unexpected_failures = dump_artifacts_on_unexpected_failures
self.enable_topological_optimizations = enable_topological_optimizations
self.check_every_input_in_inputset = check_every_input_in_inputset
self.treat_warnings_as_errors = treat_warnings_as_errors
self.enable_unsafe_features = enable_unsafe_features
self.random_inputset_samples = random_inputset_samples
self.use_insecure_key_cache = use_insecure_key_cache
def __eq__(self, other) -> bool:
return isinstance(other, CompilationConfiguration) and self.__dict__ == other.__dict__
| """Module for compilation configuration."""
class Compilationconfiguration:
"""Class that allows the compilation process to be customized."""
dump_artifacts_on_unexpected_failures: bool
enable_topological_optimizations: bool
check_every_input_in_inputset: bool
treat_warnings_as_errors: bool
enable_unsafe_features: bool
random_inputset_samples: int
use_insecure_key_cache: bool
def __init__(self, dump_artifacts_on_unexpected_failures: bool=True, enable_topological_optimizations: bool=True, check_every_input_in_inputset: bool=False, treat_warnings_as_errors: bool=False, enable_unsafe_features: bool=False, random_inputset_samples: int=30, use_insecure_key_cache: bool=False):
self.dump_artifacts_on_unexpected_failures = dump_artifacts_on_unexpected_failures
self.enable_topological_optimizations = enable_topological_optimizations
self.check_every_input_in_inputset = check_every_input_in_inputset
self.treat_warnings_as_errors = treat_warnings_as_errors
self.enable_unsafe_features = enable_unsafe_features
self.random_inputset_samples = random_inputset_samples
self.use_insecure_key_cache = use_insecure_key_cache
def __eq__(self, other) -> bool:
return isinstance(other, CompilationConfiguration) and self.__dict__ == other.__dict__ |
def add(x, y):
return x + y
a = 1
b = 2
result = add(a, b)
print("This is the sum: {}, {}, {}".format(a,b,result))
| def add(x, y):
return x + y
a = 1
b = 2
result = add(a, b)
print('This is the sum: {}, {}, {}'.format(a, b, result)) |
def regex(ref, char):
passed = True
for i in ref:
if char == i:
passed = False
return passed | def regex(ref, char):
passed = True
for i in ref:
if char == i:
passed = False
return passed |
'''
Created on Aug 30, 2018
@author: Manikandan.R
'''
print ('Running Fibonacci')
a, b = 0, 1
while a < 10:
print(a, end=',')
a, b = b, a + b
print ('Handling Strings')
alphas = "abcdefghijklmnopqrstuvwxyz"
index = len(alphas) // 2
alpha1 = alphas[: index]
alpha2 = alphas[index :]
print ('alphas: ' + alphas)
print ('alpha1: ' + alpha1)
print ('alpha2: ' + alpha2)
print ('Handling Lists')
lists = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print ('My List: ', lists)
print ('4th element from start: ', lists[4])
print ('1st element from end: ', lists[-1]) | """
Created on Aug 30, 2018
@author: Manikandan.R
"""
print('Running Fibonacci')
(a, b) = (0, 1)
while a < 10:
print(a, end=',')
(a, b) = (b, a + b)
print('Handling Strings')
alphas = 'abcdefghijklmnopqrstuvwxyz'
index = len(alphas) // 2
alpha1 = alphas[:index]
alpha2 = alphas[index:]
print('alphas: ' + alphas)
print('alpha1: ' + alpha1)
print('alpha2: ' + alpha2)
print('Handling Lists')
lists = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print('My List: ', lists)
print('4th element from start: ', lists[4])
print('1st element from end: ', lists[-1]) |
class DebuggableAttribute(Attribute,_Attribute):
"""
Modifies code generation for runtime just-in-time (JIT) debugging. This class cannot be inherited.
DebuggableAttribute(isJITTrackingEnabled: bool,isJITOptimizerDisabled: bool)
DebuggableAttribute(modes: DebuggingModes)
"""
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self,*__args):
"""
__new__(cls: type,isJITTrackingEnabled: bool,isJITOptimizerDisabled: bool)
__new__(cls: type,modes: DebuggingModes)
"""
pass
DebuggingFlags=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets the debugging modes for the attribute.
Get: DebuggingFlags(self: DebuggableAttribute) -> DebuggingModes
"""
IsJITOptimizerDisabled=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets a value that indicates whether the runtime optimizer is disabled.
Get: IsJITOptimizerDisabled(self: DebuggableAttribute) -> bool
"""
IsJITTrackingEnabled=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets a value that indicates whether the runtime will track information during code generation for the debugger.
Get: IsJITTrackingEnabled(self: DebuggableAttribute) -> bool
"""
DebuggingModes=None
| class Debuggableattribute(Attribute, _Attribute):
"""
Modifies code generation for runtime just-in-time (JIT) debugging. This class cannot be inherited.
DebuggableAttribute(isJITTrackingEnabled: bool,isJITOptimizerDisabled: bool)
DebuggableAttribute(modes: DebuggingModes)
"""
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
@staticmethod
def __new__(self, *__args):
"""
__new__(cls: type,isJITTrackingEnabled: bool,isJITOptimizerDisabled: bool)
__new__(cls: type,modes: DebuggingModes)
"""
pass
debugging_flags = property(lambda self: object(), lambda self, v: None, lambda self: None)
'Gets the debugging modes for the attribute.\n\n\n\nGet: DebuggingFlags(self: DebuggableAttribute) -> DebuggingModes\n\n\n\n'
is_jit_optimizer_disabled = property(lambda self: object(), lambda self, v: None, lambda self: None)
'Gets a value that indicates whether the runtime optimizer is disabled.\n\n\n\nGet: IsJITOptimizerDisabled(self: DebuggableAttribute) -> bool\n\n\n\n'
is_jit_tracking_enabled = property(lambda self: object(), lambda self, v: None, lambda self: None)
'Gets a value that indicates whether the runtime will track information during code generation for the debugger.\n\n\n\nGet: IsJITTrackingEnabled(self: DebuggableAttribute) -> bool\n\n\n\n'
debugging_modes = None |
class Appointment():
def __init__(self):
self.patient_ID = 0
self.doctor_ID = 0
self.profession = ""
self.day = ""
self.confirm = 0
self.success = 0
| class Appointment:
def __init__(self):
self.patient_ID = 0
self.doctor_ID = 0
self.profession = ''
self.day = ''
self.confirm = 0
self.success = 0 |
class Solution:
def singleNumber(self, nums: List[int]) -> int:
result = 0
for n in nums:
result ^= n
return result | class Solution:
def single_number(self, nums: List[int]) -> int:
result = 0
for n in nums:
result ^= n
return result |
x_range_callback = """
var start = cb_obj.start;
var end = cb_obj.end;
var width = end - start;
var threshold = %f * width; // threshold factor is set from python-side configuration
var intron_alpha = %f; // alpha value is set from python-side configuration
// iterate over each intron
var data = source.data;
for (i=0; i<data["x"].length; i++)
{
// if the screen-space width is large enough, make the intron visible
if(data["width"][i] >= threshold)
data["alpha"][i] = intron_alpha;
else
// otherwise, make the intron fully transparent
data["alpha"][i] = 0;
}
source.change.emit();
""" | x_range_callback = '\nvar start = cb_obj.start;\nvar end = cb_obj.end;\nvar width = end - start;\nvar threshold = %f * width; // threshold factor is set from python-side configuration\nvar intron_alpha = %f; // alpha value is set from python-side configuration\n\n// iterate over each intron\nvar data = source.data;\nfor (i=0; i<data["x"].length; i++)\n{\n // if the screen-space width is large enough, make the intron visible\n if(data["width"][i] >= threshold)\n data["alpha"][i] = intron_alpha;\n else\n // otherwise, make the intron fully transparent\n data["alpha"][i] = 0;\n}\n\nsource.change.emit();\n' |
X_full = brca.data
X_train, X_test, y_train, y_test = train_test_split(X_full, y, test_size=0.2, random_state=0)
scaler.fit(X_train)
X_train = scaler.transform(X_train)
X_test = scaler.transform(X_test)
clf = neighbors.KNeighborsClassifier(n_neighbors=5)
clf.fit(X_train, y_train)
test_score = clf.score(X_test, y_test)
train_score = clf.score(X_train, y_train)
print(f"test score: {test_score} \ntrain score: {train_score}") | x_full = brca.data
(x_train, x_test, y_train, y_test) = train_test_split(X_full, y, test_size=0.2, random_state=0)
scaler.fit(X_train)
x_train = scaler.transform(X_train)
x_test = scaler.transform(X_test)
clf = neighbors.KNeighborsClassifier(n_neighbors=5)
clf.fit(X_train, y_train)
test_score = clf.score(X_test, y_test)
train_score = clf.score(X_train, y_train)
print(f'test score: {test_score} \ntrain score: {train_score}') |
# -*- coding: utf-8 -*-
def main():
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
print('Bad')
else:
print('Good')
if __name__ == '__main__':
main()
| def main():
s = input()
if s[0] == s[1] or s[1] == s[2] or s[2] == s[3]:
print('Bad')
else:
print('Good')
if __name__ == '__main__':
main() |
#UNION
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 | my_set2
print(my_set3)
# {3, 4, 5, 6, 7}
#INTERSECCION
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 & my_set2
print(my_set3)
# {5}
#DIFERENCIA
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 - my_set2
print(my_set3)
my_set4 = my_set2 - my_set1
print(my_set4)
# {3, 4}
# {6, 7}
# DIFERENCIA SIMETRICA
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 ^ my_set2
print(my_set3)
# {3, 4, 6, 7}
| my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 | my_set2
print(my_set3)
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 & my_set2
print(my_set3)
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 - my_set2
print(my_set3)
my_set4 = my_set2 - my_set1
print(my_set4)
my_set1 = {3, 4, 5}
my_set2 = {5, 6, 7}
my_set3 = my_set1 ^ my_set2
print(my_set3) |
#!/usr/bin/env python
#
# description: Edit Distance
# difficulty: Hard
# leetcode_num: 72
# leetcode_url: https://leetcode.com/problems/edit-distance/
#
# Given two words word1 and word2, find the minimum number of operations
# required to convert word1 to word2.
#
# You have the following 3 operations permitted on a word:
#
# Insert a character
# Delete a character
# Replace a character
# Example 1:
#
# Input: word1 = "horse", word2 = "ros"
# Output: 3
# Explanation:
# horse -> rorse (replace 'h' with 'r')
# rorse -> rose (remove 'r')
# rose -> ros (remove 'e')
# Example 2:
#
# Input: word1 = "intention", word2 = "execution"
# Output: 5
# Explanation:
# intention -> inention (remove 't')
# inention -> enention (replace 'i' with 'e')
# enention -> exention (replace 'n' with 'x')
# exention -> exection (replace 'n' with 'c')
# exection -> execution (insert 'u')
def getMinEditDistance(source, dest, m, n):
if m == 0:
return n
if n == 0:
return m
if source[m-1] == dest[n-1]:
return getMinEditDistance(source, dest, m-1, n-1) # No edits
return 1 + min(
getMinEditDistance(source, dest, m, n-1), # Character addition
getMinEditDistance(source, dest, m-1, n), # Charater removal
getMinEditDistance(source, dest, m-1, n-1), # Charater replacement
)
# Recursive Solution
def MinEditDistanceRecursive(source, dest):
return getMinEditDistance(source, dest, len(source), len(dest))
# Solution using dynamic programming
def MinEditDistance(source, dest):
m = len(source)
n = len(dest)
dist = [[0 for _ in range(n+1)] for _ in range(m+1)]
for i in range(m+1):
for j in range(n+1):
if i == 0:
dist[i][j] = j
elif j == 0:
dist[i][j] = i
elif source[i-1] == dest[j-1]:
dist[i][j] = dist[i-1][j-1] # No edits
else:
dist[i][j] = 1 + min(
dist[i][j-1], # Character addition
dist[i-1][j], # Charater removal
dist[i-1][j-1] # Charater replacement
)
return dist[m][n]
if __name__ == '__main__':
test_cases = [
(('horse', 'ros'), 3),
(('intention', 'execution'), 5)
]
for args, res in test_cases:
assert MinEditDistanceRecursive(args[0], args[1]) == res, 'Test Failed'
assert MinEditDistance(args[0], args[1]) == res, 'Test Failed'
| def get_min_edit_distance(source, dest, m, n):
if m == 0:
return n
if n == 0:
return m
if source[m - 1] == dest[n - 1]:
return get_min_edit_distance(source, dest, m - 1, n - 1)
return 1 + min(get_min_edit_distance(source, dest, m, n - 1), get_min_edit_distance(source, dest, m - 1, n), get_min_edit_distance(source, dest, m - 1, n - 1))
def min_edit_distance_recursive(source, dest):
return get_min_edit_distance(source, dest, len(source), len(dest))
def min_edit_distance(source, dest):
m = len(source)
n = len(dest)
dist = [[0 for _ in range(n + 1)] for _ in range(m + 1)]
for i in range(m + 1):
for j in range(n + 1):
if i == 0:
dist[i][j] = j
elif j == 0:
dist[i][j] = i
elif source[i - 1] == dest[j - 1]:
dist[i][j] = dist[i - 1][j - 1]
else:
dist[i][j] = 1 + min(dist[i][j - 1], dist[i - 1][j], dist[i - 1][j - 1])
return dist[m][n]
if __name__ == '__main__':
test_cases = [(('horse', 'ros'), 3), (('intention', 'execution'), 5)]
for (args, res) in test_cases:
assert min_edit_distance_recursive(args[0], args[1]) == res, 'Test Failed'
assert min_edit_distance(args[0], args[1]) == res, 'Test Failed' |
'''
Contains all the modules that should be available when this folder is imported.
'''
__all__ = [
'google_search',
'bumble_help',
'clock_in',
'clock_out',
'chatbot',
'grepapp_search',
'send_email',
'open_notepad',
'wiki_search',
'wolfram_search',
'start_research_server',
'stop_research_server',
'store_research_data',
'silent_mode_on',
'voice_mode_on',
'youtube_search',
'add_zoom_link',
'open_zoom_link',
'sleep',
'stop_listening',
'add_contact',
'add_employer',
'set_default_speech_mode',
'load_routines',
'run_routine',
'internet_speed_test',
'run_online_tasks'
]
'''Essential Features that should be included in every custon list.'''
__essential__ = [
'sleep',
'stop_listening',
'silent_mode_on',
'voice_mode_on',
'set_default_speech_mode'
]
'''Contains cybersecurity specific features.'''
__cybersecurity__ = __essential__ + []
'''Contains geo specific features.'''
__geo__ = __essential__ + []
def create_feature_lists():
feature_lists = {}
feature_lists['all'] = __all__
feature_lists['cybersecurity'] = __cybersecurity__
feature_lists['geo'] = __geo__
return feature_lists
feature_lists = create_feature_lists()
| """
Contains all the modules that should be available when this folder is imported.
"""
__all__ = ['google_search', 'bumble_help', 'clock_in', 'clock_out', 'chatbot', 'grepapp_search', 'send_email', 'open_notepad', 'wiki_search', 'wolfram_search', 'start_research_server', 'stop_research_server', 'store_research_data', 'silent_mode_on', 'voice_mode_on', 'youtube_search', 'add_zoom_link', 'open_zoom_link', 'sleep', 'stop_listening', 'add_contact', 'add_employer', 'set_default_speech_mode', 'load_routines', 'run_routine', 'internet_speed_test', 'run_online_tasks']
'Essential Features that should be included in every custon list.'
__essential__ = ['sleep', 'stop_listening', 'silent_mode_on', 'voice_mode_on', 'set_default_speech_mode']
'Contains cybersecurity specific features.'
__cybersecurity__ = __essential__ + []
'Contains geo specific features.'
__geo__ = __essential__ + []
def create_feature_lists():
feature_lists = {}
feature_lists['all'] = __all__
feature_lists['cybersecurity'] = __cybersecurity__
feature_lists['geo'] = __geo__
return feature_lists
feature_lists = create_feature_lists() |
class Test():
def __init__(self, test_attr):
self.test_attr = test_attr
self.test_fn()
print(self.test_attr)
def test_fn(self):
self.test_attr = "goodbye world" | class Test:
def __init__(self, test_attr):
self.test_attr = test_attr
self.test_fn()
print(self.test_attr)
def test_fn(self):
self.test_attr = 'goodbye world' |
class Library:
def __init__(self,libraryname,booklist):
self.lend_book={}
self.library_name=libraryname
self.booklist=booklist
for book in self.booklist:
self.lend_book[book] = None
def add_books(self,book_name):
self.booklist.append(book_name)
self.lend_book[book_name]=None
def lendz_books(self,book,author):
if book in self.booklist:
if self.lend_book[book] is None:
self.lend_book[book]=author
else:
print("the book is already taken")
else:
print("wrong book name entered:")
def return_books(self,book,author):
if book in self.booklist:
if self.book[book] is not None:
self.booklist.append(book)
self.lend_book[book] = None
def delete_books(self,book_name):
if book_name in self.booklist:
self.booklist.remove(book_name)
self.lend_book.pop(book_name)
else:
print("the book is not the list")
def print_details(self):
return f"the book's list is {self.booklist} and library name is {self.library_name}"
if __name__ == "__main__":
list_books = ['Cookbook', 'Motu Patlu', 'Chacha_chaudhary', 'Rich Dad and Poor Dad']
Library_name = 'Harry'
secret_key = 123456
harry = Library( Library_name,list_books)
print("welcome to the library system\n There are various function in this library")
print("to add books 'a'\n to lend book 'l'\nto return the book 'r'\nto delete the book 'd'\to print the book list 'p' :")
Exit=False
while(Exit is not True):
input_1 = input("options:")
if input_1 == 'a':
input_2 = input("enter the book name you want to enter:")
harry.add_books(input_2)
elif input_1 == 'l':
input_2 = input("enter the book name you want to lend:")
input_3 = input("enter your name :")
harry.lendz_books(input_2, input_3)
elif input_1 == "r":
input_2 = input("enter the book name you want to return")
input_3 = input("enter your name :")
harry.return_books(input_2, input_3)
elif input_1 == 'd':
input_2 = input("enter the book you want to delete:")
secret = input("enter the secret key to get access:")
if secret == secret_key:
harry.delete_books(input_2)
else:
print("key is wrong")
elif input_1 == 'p':
print(harry.print_details())
| class Library:
def __init__(self, libraryname, booklist):
self.lend_book = {}
self.library_name = libraryname
self.booklist = booklist
for book in self.booklist:
self.lend_book[book] = None
def add_books(self, book_name):
self.booklist.append(book_name)
self.lend_book[book_name] = None
def lendz_books(self, book, author):
if book in self.booklist:
if self.lend_book[book] is None:
self.lend_book[book] = author
else:
print('the book is already taken')
else:
print('wrong book name entered:')
def return_books(self, book, author):
if book in self.booklist:
if self.book[book] is not None:
self.booklist.append(book)
self.lend_book[book] = None
def delete_books(self, book_name):
if book_name in self.booklist:
self.booklist.remove(book_name)
self.lend_book.pop(book_name)
else:
print('the book is not the list')
def print_details(self):
return f"the book's list is {self.booklist} and library name is {self.library_name}"
if __name__ == '__main__':
list_books = ['Cookbook', 'Motu Patlu', 'Chacha_chaudhary', 'Rich Dad and Poor Dad']
library_name = 'Harry'
secret_key = 123456
harry = library(Library_name, list_books)
print('welcome to the library system\n There are various function in this library')
print("to add books 'a'\n to lend book 'l'\nto return the book 'r'\nto delete the book 'd'\to print the book list 'p' :")
exit = False
while Exit is not True:
input_1 = input('options:')
if input_1 == 'a':
input_2 = input('enter the book name you want to enter:')
harry.add_books(input_2)
elif input_1 == 'l':
input_2 = input('enter the book name you want to lend:')
input_3 = input('enter your name :')
harry.lendz_books(input_2, input_3)
elif input_1 == 'r':
input_2 = input('enter the book name you want to return')
input_3 = input('enter your name :')
harry.return_books(input_2, input_3)
elif input_1 == 'd':
input_2 = input('enter the book you want to delete:')
secret = input('enter the secret key to get access:')
if secret == secret_key:
harry.delete_books(input_2)
else:
print('key is wrong')
elif input_1 == 'p':
print(harry.print_details()) |
class Solution:
# O(n) time | O(1) space where n is the length of the input array
def missingNumber(self, nums: List[int]) -> int:
missingNumber = 0
for i in range(len(nums)):
missingNumber ^= nums[i]
for i in range(len(nums) + 1):
missingNumber ^= i
return missingNumber
| class Solution:
def missing_number(self, nums: List[int]) -> int:
missing_number = 0
for i in range(len(nums)):
missing_number ^= nums[i]
for i in range(len(nums) + 1):
missing_number ^= i
return missingNumber |
"""Consts for Cast integration."""
DOMAIN = "cast"
DEFAULT_PORT = 8009
# Stores a threading.Lock that is held by the internal pychromecast discovery.
INTERNAL_DISCOVERY_RUNNING_KEY = "cast_discovery_running"
# Stores UUIDs of cast devices that were added as entities. Doesn't store
# None UUIDs.
ADDED_CAST_DEVICES_KEY = "cast_added_cast_devices"
# Stores an audio group manager.
CAST_MULTIZONE_MANAGER_KEY = "cast_multizone_manager"
# Store a CastBrowser
CAST_BROWSER_KEY = "cast_browser"
# Dispatcher signal fired with a ChromecastInfo every time we discover a new
# Chromecast or receive it through configuration
SIGNAL_CAST_DISCOVERED = "cast_discovered"
# Dispatcher signal fired with a ChromecastInfo every time a Chromecast is
# removed
SIGNAL_CAST_REMOVED = "cast_removed"
# Dispatcher signal fired when a Chromecast should show a Safegate Pro Cast view.
SIGNAL_HASS_CAST_SHOW_VIEW = "cast_show_view"
CONF_IGNORE_CEC = "ignore_cec"
CONF_KNOWN_HOSTS = "known_hosts"
CONF_UUID = "uuid"
| """Consts for Cast integration."""
domain = 'cast'
default_port = 8009
internal_discovery_running_key = 'cast_discovery_running'
added_cast_devices_key = 'cast_added_cast_devices'
cast_multizone_manager_key = 'cast_multizone_manager'
cast_browser_key = 'cast_browser'
signal_cast_discovered = 'cast_discovered'
signal_cast_removed = 'cast_removed'
signal_hass_cast_show_view = 'cast_show_view'
conf_ignore_cec = 'ignore_cec'
conf_known_hosts = 'known_hosts'
conf_uuid = 'uuid' |
# Write a program that prints the next 20 leap years (enter year or if not, get current year as default)
print('Type your year that you want to check:')
value = int(input())
count = 1
i = 0
def leap_years(year):
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
elif year % 4 == 0:
return True
else:
return False
while count <= 20:
if not leap_years(value):
if leap_years(value + i):
print(value + i)
count += 1
i += 1
else:
if leap_years(value + i):
print(value + i)
count += 1
i += 4
# print(leap_years(value))
| print('Type your year that you want to check:')
value = int(input())
count = 1
i = 0
def leap_years(year):
if year % 100 == 0:
if year % 400 == 0:
return True
else:
return False
elif year % 4 == 0:
return True
else:
return False
while count <= 20:
if not leap_years(value):
if leap_years(value + i):
print(value + i)
count += 1
i += 1
else:
if leap_years(value + i):
print(value + i)
count += 1
i += 4 |
# Top fields
BANDIT_TYPE = 'bandit_type'
BANDIT_ID = 'bandit_id'
PRIORS = 'priors'
ARM_IDS = 'arm_ids'
PARAMETERS = 'parameters'
# Values
N = 'n'
REWARD_SUM = 'reward_sum'
SQUARED_REWARD_SUM = 'squared_reward_sum'
N_REWARDS = 'n_rewards'
# Parametres
EPSILON = 'epsilon'
| bandit_type = 'bandit_type'
bandit_id = 'bandit_id'
priors = 'priors'
arm_ids = 'arm_ids'
parameters = 'parameters'
n = 'n'
reward_sum = 'reward_sum'
squared_reward_sum = 'squared_reward_sum'
n_rewards = 'n_rewards'
epsilon = 'epsilon' |
class PyCrudException(Exception):
pass
class DBException(PyCrudException):
pass
class PermissionException(PyCrudException):
pass
class UnknownDatabaseException(PyCrudException):
pass
class InvalidQueryConditionColumn(PyCrudException):
pass
class InvalidQueryConditionOperator(PyCrudException):
pass
class InvalidQueryConditionValue(PyCrudException):
pass
class UnknownQueryOperator(PyCrudException):
pass
class InvalidQueryValue(PyCrudException):
pass
class InvalidOrderSyntax(PyCrudException):
pass
class UnsupportedQueryOperator(PyCrudException):
pass
| class Pycrudexception(Exception):
pass
class Dbexception(PyCrudException):
pass
class Permissionexception(PyCrudException):
pass
class Unknowndatabaseexception(PyCrudException):
pass
class Invalidqueryconditioncolumn(PyCrudException):
pass
class Invalidqueryconditionoperator(PyCrudException):
pass
class Invalidqueryconditionvalue(PyCrudException):
pass
class Unknownqueryoperator(PyCrudException):
pass
class Invalidqueryvalue(PyCrudException):
pass
class Invalidordersyntax(PyCrudException):
pass
class Unsupportedqueryoperator(PyCrudException):
pass |
# -*- coding: UTF-8 -*-
def formatMultiline(text, line_length):
return "\n".join(text[i - line_length: i] for i
in range(line_length,
len(text) + line_length,
line_length)
)
def breakByWords(text, max_len):
result = ""
words = text.split()
while len(words):
wordsInLine = len(words)
while sum(len(word) for word in words[0:wordsInLine]) > max_len:
wordsInLine = wordsInLine - 1
if wordsInLine == 0:
wordsInLine = 1
result += " ".join(words[0:wordsInLine]) + "\n"
del words[0:wordsInLine]
return result | def format_multiline(text, line_length):
return '\n'.join((text[i - line_length:i] for i in range(line_length, len(text) + line_length, line_length)))
def break_by_words(text, max_len):
result = ''
words = text.split()
while len(words):
words_in_line = len(words)
while sum((len(word) for word in words[0:wordsInLine])) > max_len:
words_in_line = wordsInLine - 1
if wordsInLine == 0:
words_in_line = 1
result += ' '.join(words[0:wordsInLine]) + '\n'
del words[0:wordsInLine]
return result |
if __name__ == '__main__':
string = "2018-11-13"
print(string.replace("-", ""))
string = "201812"
print(string.count("2"))
string = "12345678901234567890"
for i in range(len(string)):
print(string[i], end="")
if (i + 1) % 4 == 0:
print("\n")
string = "12345678901234567890"
column_num = 1
last_i = 0
for i in range(len(string)):
print(string[i], end="")
if (i - last_i) % column_num == 0:
last_i = i
column_num += 1
print("\n")
string = "123abcABCDE"
print("\n")
subline_num = 0
digit_num = 0
alpha_num = 0
for ch in string:
if ch.isdigit():
digit_num += 1
elif ch.isalpha():
alpha_num += 1
else:
subline_num += 1
print(subline_num)
print(digit_num)
print(alpha_num)
| if __name__ == '__main__':
string = '2018-11-13'
print(string.replace('-', ''))
string = '201812'
print(string.count('2'))
string = '12345678901234567890'
for i in range(len(string)):
print(string[i], end='')
if (i + 1) % 4 == 0:
print('\n')
string = '12345678901234567890'
column_num = 1
last_i = 0
for i in range(len(string)):
print(string[i], end='')
if (i - last_i) % column_num == 0:
last_i = i
column_num += 1
print('\n')
string = '123abcABCDE'
print('\n')
subline_num = 0
digit_num = 0
alpha_num = 0
for ch in string:
if ch.isdigit():
digit_num += 1
elif ch.isalpha():
alpha_num += 1
else:
subline_num += 1
print(subline_num)
print(digit_num)
print(alpha_num) |
UNK = 0
BOS = 1
EOS = 2
WORD = {
UNK: '<unk>',
BOS: '<s>',
EOS: '</s>'
}
| unk = 0
bos = 1
eos = 2
word = {UNK: '<unk>', BOS: '<s>', EOS: '</s>'} |
'''
Created on Feb 14, 2019
@author: jcorley
'''
PROTOCOL = "tcp"
IP_ADDRESS = "127.0.0.1"
PORT="5555"
KEY_REQUEST_TYPE = "request_type"
KEY_FAILURE_MESSAGE = "failure_message"
KEY_RECIPES = "recipes"
KEY_STATUS = "status"
SUCCESS_STATUS = 1
BAD_MESSAGE_STATUS = -1
UNSUPPORTED_OPERATION_STATUS = -1
LOAD_RECIPES_REQUEST_TYPE = "load_recipes"
| """
Created on Feb 14, 2019
@author: jcorley
"""
protocol = 'tcp'
ip_address = '127.0.0.1'
port = '5555'
key_request_type = 'request_type'
key_failure_message = 'failure_message'
key_recipes = 'recipes'
key_status = 'status'
success_status = 1
bad_message_status = -1
unsupported_operation_status = -1
load_recipes_request_type = 'load_recipes' |
CLI_OPTS = {
'data_path': {
'env': 'ELLIOTT_DATA_PATH',
'help': 'Git URL or File Path to build data'
},
'group': {
'env': 'ELLIOTT_GROUP',
'help': 'Sub-group directory or branch to pull build data'
},
'working_dir': {
'env': 'ELLIOTT_WORKING_DIR',
'help': 'Persistent working directory to use'
},
}
CLI_ENV_VARS = {k: v['env'] for (k, v) in CLI_OPTS.iteritems()}
CLI_CONFIG_TEMPLATE = '\n'.join(['#{}\n{}:\n'.format(v['help'], k) for (k, v) in CLI_OPTS.iteritems()]) | cli_opts = {'data_path': {'env': 'ELLIOTT_DATA_PATH', 'help': 'Git URL or File Path to build data'}, 'group': {'env': 'ELLIOTT_GROUP', 'help': 'Sub-group directory or branch to pull build data'}, 'working_dir': {'env': 'ELLIOTT_WORKING_DIR', 'help': 'Persistent working directory to use'}}
cli_env_vars = {k: v['env'] for (k, v) in CLI_OPTS.iteritems()}
cli_config_template = '\n'.join(['#{}\n{}:\n'.format(v['help'], k) for (k, v) in CLI_OPTS.iteritems()]) |
def show_sequence(n):
if n == 0:
return '0=0'
elif n < 0:
return '{}<0'.format(n)
return '{} = {}'.format(
'+'.join(str(a) for a in xrange(n + 1)), n * (n + 1) // 2
)
| def show_sequence(n):
if n == 0:
return '0=0'
elif n < 0:
return '{}<0'.format(n)
return '{} = {}'.format('+'.join((str(a) for a in xrange(n + 1))), n * (n + 1) // 2) |
class Pool:
__slots__ = ('_value', 'max_value', )
def __init__(self, value, max_value=None):
self._value = 0
value = int(value)
max_value = max_value and int(max_value)
self.max_value = max_value or value
self.value = value
@property
def value(self):
return self._value
@value.setter
def value(self, value):
self._value = max(0, min(value, self.max_value))
def __iadd__(self, value):
self._value += int(value)
return self
def __isub__(self, value):
self._value -= int(value)
return self
def __int__(self):
return self.value
class Attribute:
__slots__ = ('base', 'modifier')
def __init__(self, base, modifier=None):
self.base = base
self.modifier = modifier or 0
@property
def total(self):
return self.base + self.modifier
def __int__(self):
return self.total
| class Pool:
__slots__ = ('_value', 'max_value')
def __init__(self, value, max_value=None):
self._value = 0
value = int(value)
max_value = max_value and int(max_value)
self.max_value = max_value or value
self.value = value
@property
def value(self):
return self._value
@value.setter
def value(self, value):
self._value = max(0, min(value, self.max_value))
def __iadd__(self, value):
self._value += int(value)
return self
def __isub__(self, value):
self._value -= int(value)
return self
def __int__(self):
return self.value
class Attribute:
__slots__ = ('base', 'modifier')
def __init__(self, base, modifier=None):
self.base = base
self.modifier = modifier or 0
@property
def total(self):
return self.base + self.modifier
def __int__(self):
return self.total |
class ArticleTypeNotAllowed(Exception):
def __init__(self):
super().__init__("403 The article type is not allowed")
| class Articletypenotallowed(Exception):
def __init__(self):
super().__init__('403 The article type is not allowed') |
"""
You are going to be given an array of integers. Your job is to take that array and find an index N
where the sum of the integers to the left of N is equal to the sum of the integers to the right of N.
If there is no index that would make this happen, return -1.
For example:
Let's say you are given the array {1,2,3,4,3,2,1}:
Your function will return the index 3, because at the 3rd position of the array, the sum of left side
of the index ({1,2,3}) and the sum of the right side of the index ({3,2,1}) both equal 6.
Let's look at another one.
You are given the array {1,100,50,-51,1,1}:
Your function will return the index 1, because at the 1st position of the array, the sum of
left side of the index ({1}) and the sum of the right side of the index ({50,-51,1,1}) both equal 1.
Last one:
You are given the array {20,10,-80,10,10,15,35}
At index 0 the left side is {}
The right side is {10,-80,10,10,15,35}
They both are equal to 0 when added. (Empty arrays are equal to 0 in this problem)
Index 0 is the place where the left side and right side are equal.
Note: Please remember that in most programming/scripting languages the index of an array starts at 0.
Input:
An integer array of length 0 < arr < 1000. The numbers in the array can be any integer positive or negative.
Output:
The lowest index N where the side to the left of N is equal to the side to the right of N.
If you do not find an index that fits these rules, then you will return -1.
Note:
If you are given an array with multiple answers, return the lowest correct index.
"""
def find_even_index(arr):
for i in range(len(arr)):
if sum(arr[:i]) == sum(arr[i + 1 :]):
return i
else:
continue
return -1
| """
You are going to be given an array of integers. Your job is to take that array and find an index N
where the sum of the integers to the left of N is equal to the sum of the integers to the right of N.
If there is no index that would make this happen, return -1.
For example:
Let's say you are given the array {1,2,3,4,3,2,1}:
Your function will return the index 3, because at the 3rd position of the array, the sum of left side
of the index ({1,2,3}) and the sum of the right side of the index ({3,2,1}) both equal 6.
Let's look at another one.
You are given the array {1,100,50,-51,1,1}:
Your function will return the index 1, because at the 1st position of the array, the sum of
left side of the index ({1}) and the sum of the right side of the index ({50,-51,1,1}) both equal 1.
Last one:
You are given the array {20,10,-80,10,10,15,35}
At index 0 the left side is {}
The right side is {10,-80,10,10,15,35}
They both are equal to 0 when added. (Empty arrays are equal to 0 in this problem)
Index 0 is the place where the left side and right side are equal.
Note: Please remember that in most programming/scripting languages the index of an array starts at 0.
Input:
An integer array of length 0 < arr < 1000. The numbers in the array can be any integer positive or negative.
Output:
The lowest index N where the side to the left of N is equal to the side to the right of N.
If you do not find an index that fits these rules, then you will return -1.
Note:
If you are given an array with multiple answers, return the lowest correct index.
"""
def find_even_index(arr):
for i in range(len(arr)):
if sum(arr[:i]) == sum(arr[i + 1:]):
return i
else:
continue
return -1 |
f=open("/home/pirl/darknet/train.txt",'a')
for i in range(1,801):
#data = 'data/green_light/green_light%d.jpg\n' % i
#data = 'data/red_light/ red_light%d.jpg\n' % i
#data = 'data/yellow_light/yellow_light%d.jpg\n' % i
#data = 'data/60_speed/60_speed%d.jpg\n' % i
#data = 'data/30_speed/30_speed%d.jpg\n' % i
#data = 'data/Nright_sign/Nright_sign%d.jpg\n' % i
#data = 'data/right_sign/right_sign%d.jpg\n' % i
f.write(data)
f.close()
| f = open('/home/pirl/darknet/train.txt', 'a')
for i in range(1, 801):
f.write(data)
f.close() |
# -*- coding: utf-8 -*-
class Processador(object):
def __init__(self):
self.processo_em_execucao = None
| class Processador(object):
def __init__(self):
self.processo_em_execucao = None |
USER_LOCK = []
PROCESS_LOCK = []
def user_lock(userid):
if userid in USER_LOCK: return False
else:
USER_LOCK.append(userid)
return True
def user_unlock(userid):
if userid in USER_LOCK: USER_LOCK.remove(userid)
def user_check(userid):
return userid in USER_LOCK
def process_lock(pid):
if pid in PROCESS_LOCK: return False
else:
PROCESS_LOCK.append(pid)
return True
def process_unlock(pid):
if pid in PROCESS_LOCK: PROCESS_LOCK.remove(pid)
def process_check(pid):
return pid in PROCESS_LOCK
| user_lock = []
process_lock = []
def user_lock(userid):
if userid in USER_LOCK:
return False
else:
USER_LOCK.append(userid)
return True
def user_unlock(userid):
if userid in USER_LOCK:
USER_LOCK.remove(userid)
def user_check(userid):
return userid in USER_LOCK
def process_lock(pid):
if pid in PROCESS_LOCK:
return False
else:
PROCESS_LOCK.append(pid)
return True
def process_unlock(pid):
if pid in PROCESS_LOCK:
PROCESS_LOCK.remove(pid)
def process_check(pid):
return pid in PROCESS_LOCK |
#!/usr/bin/env python
# Use local host when running locally
# port = 'localhost:50051'
# Use simple_server_app when running inside docker
port = 'simple_server_app:50051'
streaming_rate = 0.1 | port = 'simple_server_app:50051'
streaming_rate = 0.1 |
#!/usr/bin/env python
def reverse(iterable):
"""Reverses the iterable.
Iterate through the collection with two pointers, one increasing from the
beginning of the collection and the other decreasing from the end of the
collection, and swap the items at the respective pointers. Iterations through
the collection are repeated until the pointer that is increasing is no longer
less than the pointer that is decreasing.
* O(n) time complexity
* O(1) space complexity
Args:
iterable: A collection that is iterable.
Raises:
TypeError: If iterable is not iterable.
"""
try:
_ = iter(iterable)
except TypeError:
raise TypeError('\'{}\' object is not iterable'.format(
type(iterable).__name__))
low = 0
high = len(iterable) - 1
while low < high:
iterable[low], iterable[high] = iterable[high], iterable[low]
low += 1
high -= 1
| def reverse(iterable):
"""Reverses the iterable.
Iterate through the collection with two pointers, one increasing from the
beginning of the collection and the other decreasing from the end of the
collection, and swap the items at the respective pointers. Iterations through
the collection are repeated until the pointer that is increasing is no longer
less than the pointer that is decreasing.
* O(n) time complexity
* O(1) space complexity
Args:
iterable: A collection that is iterable.
Raises:
TypeError: If iterable is not iterable.
"""
try:
_ = iter(iterable)
except TypeError:
raise type_error("'{}' object is not iterable".format(type(iterable).__name__))
low = 0
high = len(iterable) - 1
while low < high:
(iterable[low], iterable[high]) = (iterable[high], iterable[low])
low += 1
high -= 1 |
# the hardcoded key used in every mozi sample.
MOZI_XOR_KEY = b"\x4e\x66\x5a\x8f\x80\xc8\xac\x23\x8d\xac\x47\x06\xd5\x4f\x6f\x7e"
# the first 4 bytes of the XOR-ed config. It always begins with [ss].
MOZI_CONFIG_HEADER = b"\x15\x15\x29\xd2" # b"[ss]" ^ XOR_KEY[:4]
# the size of the Mozi config string
MOZI_CONFIG_TOTAL_SIZE = 524
# the size of the actual Mozi config
MOZI_CONFIG_SIZE = 428
# the first ECDSA384 signature, xored
MOZI_SIGNATURE_A = \
b"\x4C\xB3\x8F\x68\xC1\x26\x70\xEB\
\x9D\xC1\x68\x4E\xD8\x4B\x7D\x5F\
\x69\x5F\x9D\xCA\x8D\xE2\x7D\x63\
\xFF\xAD\x96\x8D\x18\x8B\x79\x1B\
\x38\x31\x9B\x12\x69\x73\xA9\x2E\
\xB6\x63\x29\x76\xAC\x2F\x9E\x94\xA1"
# the second ECDSA384 signature, xored
MOZI_SIGNATURE_B = \
b"\x4C\xA6\xFB\xCC\xF8\x9B\x12\x1F\
\x49\x64\x4D\x2F\x3C\x17\xD0\xB8\
\xE9\x7D\x24\x24\xF2\xDD\xB1\x47\
\xE9\x34\xD2\xC2\xBF\x07\xAC\x53\
\x22\x5F\xD8\x92\xFE\xED\x5F\xA3\
\xC9\x5B\x6A\x16\xBE\x84\x40\x77\x88"
# the magic UPX number that marks UPX data within the executable.
UPX_MAGIC = b"UPX!"
# name and size in bytes of the upx checksum
UPX_CHECKSUM = ("l_checksum", 4)
# name and size in bytes of the upx magic number
UPX_MAGIC_SIZE = ("l_magic", 4)
# name and size in bytes of the l_lsize field
UPX_LSIZE = ("l_lsize", 2)
# name and size in bytes of the l_version field
UPX_LVERSION = ("l_version", 1)
# name and size in bytes of the l_format field
UPX_LFORMAT = ("l_format", 1)
# name and size in bytes of the p_progid field
UPX_PPROGID = ("p_progid", 4)
# name and size in bytes of the p_filesize field
UPX_PFILESIZE = ("p_filesize", 4)
# name and size in bytes of the p_blocksize field
UPX_PBLOCKSIZE = ("p_blocksize", 4)
# the offset from the UPX trailer magic number to read the data from
# 6 doublewords (4 bytes) away from the start of the magic number
UPX_TRAILER_OFFSET = 6 * 4
# (name, has_suffix) e.g. [ss], [/ss]
# taken from https://blog.netlab.360.com/mozi-another-botnet-using-dht/
CONFIG_FIELDS = {
# declaration
"ss" : "bot role",
"cpu" : "cpu arch",
"nd" : "new DHT node",
"count" : "url to report to",
# control
"atk" : "ddos attack type",
"ver" : "verify",
"sv" : "update config",
"hp" : "DHT id prefix",
"dip" : "address to get new sample",
# subtasks
"dr" : "download and exec payload",
"ud" : "update bot",
"rn" : "execute command",
"idp" : "report bot info", # bot id, ip, port, file name, gateway, cpu arch
}
DHT_BOOTSTRAP_NODES = [
"dht.transmissionbt.com:6881",
"router.bittorrent.com:6881",
"router.utorrent.com:6881",
"bttracker.debian.org:6881",
"212.129.33.59:6881",
"82.221.103.244:6881",
"130.239.18.159:6881",
"87.98.162.88:6881",
] | mozi_xor_key = b'NfZ\x8f\x80\xc8\xac#\x8d\xacG\x06\xd5Oo~'
mozi_config_header = b'\x15\x15)\xd2'
mozi_config_total_size = 524
mozi_config_size = 428
mozi_signature_a = b'L\xb3\x8fh\xc1&p\xeb\x9d\xc1hN\xd8K}_i_\x9d\xca\x8d\xe2}c\xff\xad\x96\x8d\x18\x8by\x1b81\x9b\x12is\xa9.\xb6c)v\xac/\x9e\x94\xa1'
mozi_signature_b = b'L\xa6\xfb\xcc\xf8\x9b\x12\x1fIdM/<\x17\xd0\xb8\xe9}$$\xf2\xdd\xb1G\xe94\xd2\xc2\xbf\x07\xacS"_\xd8\x92\xfe\xed_\xa3\xc9[j\x16\xbe\x84@w\x88'
upx_magic = b'UPX!'
upx_checksum = ('l_checksum', 4)
upx_magic_size = ('l_magic', 4)
upx_lsize = ('l_lsize', 2)
upx_lversion = ('l_version', 1)
upx_lformat = ('l_format', 1)
upx_pprogid = ('p_progid', 4)
upx_pfilesize = ('p_filesize', 4)
upx_pblocksize = ('p_blocksize', 4)
upx_trailer_offset = 6 * 4
config_fields = {'ss': 'bot role', 'cpu': 'cpu arch', 'nd': 'new DHT node', 'count': 'url to report to', 'atk': 'ddos attack type', 'ver': 'verify', 'sv': 'update config', 'hp': 'DHT id prefix', 'dip': 'address to get new sample', 'dr': 'download and exec payload', 'ud': 'update bot', 'rn': 'execute command', 'idp': 'report bot info'}
dht_bootstrap_nodes = ['dht.transmissionbt.com:6881', 'router.bittorrent.com:6881', 'router.utorrent.com:6881', 'bttracker.debian.org:6881', '212.129.33.59:6881', '82.221.103.244:6881', '130.239.18.159:6881', '87.98.162.88:6881'] |
#!/usr/bin/python3
# maximizing_xor.py
# Author : Rajat Mhetre
# follow and drop me a line at @rajat_mhetre
def max_xor(l,r):
return max(x^y for x in range(l,r+1) for y in range(l,r+1))
if __name__ == '__main__':
l = int(input())
r = int(input())
print(max_xor(l,r))
| def max_xor(l, r):
return max((x ^ y for x in range(l, r + 1) for y in range(l, r + 1)))
if __name__ == '__main__':
l = int(input())
r = int(input())
print(max_xor(l, r)) |
def main():
combined_rect = set()
overlapped_rect = set()
f = open("input")
lines = f.readlines()
for line in lines:
id_, x, y, size_x, size_y = parse(line)
for coord in generate_coord(x, y, size_x, size_y):
if coord in combined_rect:
overlapped_rect.add(coord)
combined_rect.add(coord)
for line in lines:
id_, x, y, size_x, size_y = parse(line)
temp = set()
for coord in generate_coord(x, y, size_x, size_y):
temp.add(coord)
t = temp.intersection(overlapped_rect)
if not t:
print(id_)
def parse(line):
id_, _, start_point, size = line.split()
x, y = start_point.split(",")
y = y[:-1]
size_x, size_y = size.split("x")
return id_, int(x), int(y), int(size_x), int(size_y)
def generate_coord(x, y, size_x, size_y):
for x_ in range(x, x + size_x):
for y_ in range(y, y + size_y):
yield (x_, y_)
if __name__ == "__main__":
main()
| def main():
combined_rect = set()
overlapped_rect = set()
f = open('input')
lines = f.readlines()
for line in lines:
(id_, x, y, size_x, size_y) = parse(line)
for coord in generate_coord(x, y, size_x, size_y):
if coord in combined_rect:
overlapped_rect.add(coord)
combined_rect.add(coord)
for line in lines:
(id_, x, y, size_x, size_y) = parse(line)
temp = set()
for coord in generate_coord(x, y, size_x, size_y):
temp.add(coord)
t = temp.intersection(overlapped_rect)
if not t:
print(id_)
def parse(line):
(id_, _, start_point, size) = line.split()
(x, y) = start_point.split(',')
y = y[:-1]
(size_x, size_y) = size.split('x')
return (id_, int(x), int(y), int(size_x), int(size_y))
def generate_coord(x, y, size_x, size_y):
for x_ in range(x, x + size_x):
for y_ in range(y, y + size_y):
yield (x_, y_)
if __name__ == '__main__':
main() |
class B(object):
b:int =1
a:int =1
d:int =1
class C(object):
c:int =1
class A(B):
a:int = 1 #attr redefined in B
b:int = 1 #attr redefined in B
# this declaration will be ignore
class A(C):
a:int = 1 #ok,check attr in C
c:int = 1 #attr redefined
class D(A):
a:int = 1 #attr redefined
b:int = 1 #attr redefined
c:int = 1 #no problem
d:int = 1 #attr redefined in B | class B(object):
b: int = 1
a: int = 1
d: int = 1
class C(object):
c: int = 1
class A(B):
a: int = 1
b: int = 1
class A(C):
a: int = 1
c: int = 1
class D(A):
a: int = 1
b: int = 1
c: int = 1
d: int = 1 |
class Solution:
# O(n) time | O(n) space
def maxProfit(self, prices: List[int]) -> int:
n = len(prices)
if n <= 1: return 0
diff = [prices[i+1] - prices[i] for i in range(n-1)]
dp, dp_max = [0]*(n + 1), [0]*(n + 1)
for i in range(n-1):
dp[i] = diff[i] + max(dp_max[i-3], dp[i-1])
dp_max[i] = max(dp_max[i-1], dp[i])
return dp_max[-3] | class Solution:
def max_profit(self, prices: List[int]) -> int:
n = len(prices)
if n <= 1:
return 0
diff = [prices[i + 1] - prices[i] for i in range(n - 1)]
(dp, dp_max) = ([0] * (n + 1), [0] * (n + 1))
for i in range(n - 1):
dp[i] = diff[i] + max(dp_max[i - 3], dp[i - 1])
dp_max[i] = max(dp_max[i - 1], dp[i])
return dp_max[-3] |
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def findTarget(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: bool
"""
s = set([])
return self.dfs(root, s, k)
def dfs (self, root, set, target):
if not root:
return False
if target-root.val in set:
return True
set.add(root.val)
return self.dfs(root.left, set, target) or self.dfs(root.right,set, target)
| class Solution(object):
def find_target(self, root, k):
"""
:type root: TreeNode
:type k: int
:rtype: bool
"""
s = set([])
return self.dfs(root, s, k)
def dfs(self, root, set, target):
if not root:
return False
if target - root.val in set:
return True
set.add(root.val)
return self.dfs(root.left, set, target) or self.dfs(root.right, set, target) |
#coding=utf-8
# email
smtp_server = "smtp.exmail.qq.com"
from_addr = "test@qq.com"
mail_username = "test2@qq.com"
mail_password = "admin"
mail_port = 465
# sms
SmsUrl = ""
SmsPath = ""
AppCode = ""
SignName = "" | smtp_server = 'smtp.exmail.qq.com'
from_addr = 'test@qq.com'
mail_username = 'test2@qq.com'
mail_password = 'admin'
mail_port = 465
sms_url = ''
sms_path = ''
app_code = ''
sign_name = '' |
#
# PySNMP MIB module ChrComPmSonetSNT-P-Day-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ChrComPmSonetSNT-P-Day-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:20:38 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint, ConstraintsUnion, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ConstraintsUnion", "ValueRangeConstraint")
chrComIfifIndex, = mibBuilder.importSymbols("ChrComIfifTable-MIB", "chrComIfifIndex")
TruthValue, = mibBuilder.importSymbols("ChrTyp-MIB", "TruthValue")
chrComPmSonet, = mibBuilder.importSymbols("Chromatis-MIB", "chrComPmSonet")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, iso, TimeTicks, Bits, IpAddress, ObjectIdentity, Unsigned32, ModuleIdentity, MibIdentifier, Gauge32, Counter64, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "iso", "TimeTicks", "Bits", "IpAddress", "ObjectIdentity", "Unsigned32", "ModuleIdentity", "MibIdentifier", "Gauge32", "Counter64", "Counter32")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
chrComPmSonetSNT_P_DayTable = MibTable((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12), ).setLabel("chrComPmSonetSNT-P-DayTable")
if mibBuilder.loadTexts: chrComPmSonetSNT_P_DayTable.setStatus('current')
chrComPmSonetSNT_P_DayEntry = MibTableRow((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1), ).setLabel("chrComPmSonetSNT-P-DayEntry").setIndexNames((0, "ChrComIfifTable-MIB", "chrComIfifIndex"), (0, "ChrComPmSonetSNT-P-Day-MIB", "chrComPmSonetDayNumber"))
if mibBuilder.loadTexts: chrComPmSonetSNT_P_DayEntry.setStatus('current')
chrComPmSonetDayNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 2))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetDayNumber.setStatus('current')
chrComPmSonetSuspectedInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 2), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetSuspectedInterval.setStatus('current')
chrComPmSonetElapsedTime = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 3), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetElapsedTime.setStatus('current')
chrComPmSonetSuppressedIntrvls = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 4), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetSuppressedIntrvls.setStatus('current')
chrComPmSonetES = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 5), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetES.setStatus('current')
chrComPmSonetSES = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 6), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetSES.setStatus('current')
chrComPmSonetCV = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 7), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetCV.setStatus('current')
chrComPmSonetUAS = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 8), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetUAS.setStatus('current')
chrComPmSonetPS = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 9), Gauge32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetPS.setStatus('current')
chrComPmSonetThresholdProfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 10), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(0, 4294967295))).setMaxAccess("readonly")
if mibBuilder.loadTexts: chrComPmSonetThresholdProfIndex.setStatus('current')
chrComPmSonetResetPmCountersAction = MibTableColumn((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 11), TruthValue()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: chrComPmSonetResetPmCountersAction.setStatus('current')
mibBuilder.exportSymbols("ChrComPmSonetSNT-P-Day-MIB", chrComPmSonetSNT_P_DayTable=chrComPmSonetSNT_P_DayTable, chrComPmSonetResetPmCountersAction=chrComPmSonetResetPmCountersAction, chrComPmSonetThresholdProfIndex=chrComPmSonetThresholdProfIndex, chrComPmSonetES=chrComPmSonetES, chrComPmSonetPS=chrComPmSonetPS, chrComPmSonetSNT_P_DayEntry=chrComPmSonetSNT_P_DayEntry, chrComPmSonetSuppressedIntrvls=chrComPmSonetSuppressedIntrvls, chrComPmSonetElapsedTime=chrComPmSonetElapsedTime, chrComPmSonetDayNumber=chrComPmSonetDayNumber, chrComPmSonetSuspectedInterval=chrComPmSonetSuspectedInterval, chrComPmSonetCV=chrComPmSonetCV, chrComPmSonetSES=chrComPmSonetSES, chrComPmSonetUAS=chrComPmSonetUAS)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, single_value_constraint, constraints_union, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueRangeConstraint')
(chr_com_ifif_index,) = mibBuilder.importSymbols('ChrComIfifTable-MIB', 'chrComIfifIndex')
(truth_value,) = mibBuilder.importSymbols('ChrTyp-MIB', 'TruthValue')
(chr_com_pm_sonet,) = mibBuilder.importSymbols('Chromatis-MIB', 'chrComPmSonet')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, integer32, iso, time_ticks, bits, ip_address, object_identity, unsigned32, module_identity, mib_identifier, gauge32, counter64, counter32) = mibBuilder.importSymbols('SNMPv2-SMI', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Integer32', 'iso', 'TimeTicks', 'Bits', 'IpAddress', 'ObjectIdentity', 'Unsigned32', 'ModuleIdentity', 'MibIdentifier', 'Gauge32', 'Counter64', 'Counter32')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
chr_com_pm_sonet_snt_p__day_table = mib_table((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12)).setLabel('chrComPmSonetSNT-P-DayTable')
if mibBuilder.loadTexts:
chrComPmSonetSNT_P_DayTable.setStatus('current')
chr_com_pm_sonet_snt_p__day_entry = mib_table_row((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1)).setLabel('chrComPmSonetSNT-P-DayEntry').setIndexNames((0, 'ChrComIfifTable-MIB', 'chrComIfifIndex'), (0, 'ChrComPmSonetSNT-P-Day-MIB', 'chrComPmSonetDayNumber'))
if mibBuilder.loadTexts:
chrComPmSonetSNT_P_DayEntry.setStatus('current')
chr_com_pm_sonet_day_number = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 1), unsigned32().subtype(subtypeSpec=value_range_constraint(1, 2))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetDayNumber.setStatus('current')
chr_com_pm_sonet_suspected_interval = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 2), truth_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetSuspectedInterval.setStatus('current')
chr_com_pm_sonet_elapsed_time = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 3), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetElapsedTime.setStatus('current')
chr_com_pm_sonet_suppressed_intrvls = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 4), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetSuppressedIntrvls.setStatus('current')
chr_com_pm_sonet_es = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 5), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetES.setStatus('current')
chr_com_pm_sonet_ses = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 6), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetSES.setStatus('current')
chr_com_pm_sonet_cv = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 7), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetCV.setStatus('current')
chr_com_pm_sonet_uas = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 8), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetUAS.setStatus('current')
chr_com_pm_sonet_ps = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 9), gauge32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetPS.setStatus('current')
chr_com_pm_sonet_threshold_prof_index = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 10), unsigned32().subtype(subtypeSpec=value_range_constraint(0, 4294967295))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
chrComPmSonetThresholdProfIndex.setStatus('current')
chr_com_pm_sonet_reset_pm_counters_action = mib_table_column((1, 3, 6, 1, 4, 1, 3695, 1, 10, 2, 12, 1, 11), truth_value()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
chrComPmSonetResetPmCountersAction.setStatus('current')
mibBuilder.exportSymbols('ChrComPmSonetSNT-P-Day-MIB', chrComPmSonetSNT_P_DayTable=chrComPmSonetSNT_P_DayTable, chrComPmSonetResetPmCountersAction=chrComPmSonetResetPmCountersAction, chrComPmSonetThresholdProfIndex=chrComPmSonetThresholdProfIndex, chrComPmSonetES=chrComPmSonetES, chrComPmSonetPS=chrComPmSonetPS, chrComPmSonetSNT_P_DayEntry=chrComPmSonetSNT_P_DayEntry, chrComPmSonetSuppressedIntrvls=chrComPmSonetSuppressedIntrvls, chrComPmSonetElapsedTime=chrComPmSonetElapsedTime, chrComPmSonetDayNumber=chrComPmSonetDayNumber, chrComPmSonetSuspectedInterval=chrComPmSonetSuspectedInterval, chrComPmSonetCV=chrComPmSonetCV, chrComPmSonetSES=chrComPmSonetSES, chrComPmSonetUAS=chrComPmSonetUAS) |
#Class Inheritance
#Feline class
class Feline:
def __init__(self,name):
self.name = name
print('Creating a feline')
def meow(self):
print(f'{self.name}: meow')
def setName(self, name):
print(f'{self} setting name: {name}')
self.name = name
#Lion class
class Lion(Feline):
def roar(self):
print(f'{self.name} roar')
#Tiger class
class Tiger(Feline):
#override the contructor is a BAD idea
def __init__(self):
#Super alows is to access the parent
#if we forget this we will have a bad time later
super().__init__('No Name')
print('Creating a tiger')
def stalk(self):
#have to make sure name is set in the parent
#this is considered -LBYL (look before you leap)
#here we are dynamically adding the attribute
#If we did not init the super we will have to be careful
#if not hasattr(self,'name'): super().setName('No Name')
print(f'{self.name}: stalking')
def rename(self,name):
super().setName(name)
c = Feline('kitty')
print(c)
c.meow()
l = Lion('Leo')
print(l)
l.meow()
l.roar()
t = Tiger() #is a Feline, but with a different constructor
print(t)
t.stalk()
t.rename('Tony')
t.meow()
t.stalk() | class Feline:
def __init__(self, name):
self.name = name
print('Creating a feline')
def meow(self):
print(f'{self.name}: meow')
def set_name(self, name):
print(f'{self} setting name: {name}')
self.name = name
class Lion(Feline):
def roar(self):
print(f'{self.name} roar')
class Tiger(Feline):
def __init__(self):
super().__init__('No Name')
print('Creating a tiger')
def stalk(self):
print(f'{self.name}: stalking')
def rename(self, name):
super().setName(name)
c = feline('kitty')
print(c)
c.meow()
l = lion('Leo')
print(l)
l.meow()
l.roar()
t = tiger()
print(t)
t.stalk()
t.rename('Tony')
t.meow()
t.stalk() |
#snapshot parameters
snapshot_num = 77
galaxy_num = 0
galaxy_num_str = str(galaxy_num)
snapnum_str = '{:03d}'.format(snapshot_num)
hydro_dir = '/orange/narayanan/desika.narayanan/gizmo_runs/simba/m12_n256_active_boxes/output_m12n256_7/'
snapshot_name = 'snapshot_'+snapnum_str+'.hdf5'
#where the files should go
PD_output_dir = '/home/desika.narayanan/pd_git/tests/SKIRT/m12_extinction/'
Auto_TF_file = 'snap'+snapnum_str+'.logical'
Auto_dustdens_file = 'snap'+snapnum_str+'.dustdens'
#===============================================
#FILE I/O
#===============================================
inputfile = PD_output_dir+'/pd_skirt_comparison.'+snapnum_str+'.rtin'
outputfile = PD_output_dir+'/pd_skirt_comparison.'+snapnum_str+'.rtout'
#===============================================
#GRID POSITIONS
#===============================================
#x_cent=7791.04289063
#y_cent=11030.12925781
#z_cent=4567.8734375
x_cent = 5527.42349609
y_cent = 4680.46623047
z_cent = 10704.73
#x_cent = 5.00925088e+03
#y_cent = 1.22012878e+04
#z_cent = 8.88592731e+00
#x_cent = 10898.06515625
#y_cent = 10868.67308594
#z_cent = 4419.96082031
#===============================================
#CMB
#===============================================
TCMB = 2.73
| snapshot_num = 77
galaxy_num = 0
galaxy_num_str = str(galaxy_num)
snapnum_str = '{:03d}'.format(snapshot_num)
hydro_dir = '/orange/narayanan/desika.narayanan/gizmo_runs/simba/m12_n256_active_boxes/output_m12n256_7/'
snapshot_name = 'snapshot_' + snapnum_str + '.hdf5'
pd_output_dir = '/home/desika.narayanan/pd_git/tests/SKIRT/m12_extinction/'
auto_tf_file = 'snap' + snapnum_str + '.logical'
auto_dustdens_file = 'snap' + snapnum_str + '.dustdens'
inputfile = PD_output_dir + '/pd_skirt_comparison.' + snapnum_str + '.rtin'
outputfile = PD_output_dir + '/pd_skirt_comparison.' + snapnum_str + '.rtout'
x_cent = 5527.42349609
y_cent = 4680.46623047
z_cent = 10704.73
tcmb = 2.73 |
class Solution:
def combinationSum(self, candidates, target):
"""
:type candidates: List[int]
:type target: int
:rtype: List[List[int]]
"""
ret = []
candidates.sort()
def traverse(pos, tmp, left):
nonlocal candidates, ret
if left < 0:
return
if left == 0:
ret.append(tmp)
for i in range(len(candidates)):
if i < pos:
continue
traverse(i, tmp + [candidates[i]], left - candidates[i])
traverse(0, [], target)
return ret
| class Solution:
def combination_sum(self, candidates, target):
"""
:type candidates: List[int]
:type target: int
:rtype: List[List[int]]
"""
ret = []
candidates.sort()
def traverse(pos, tmp, left):
nonlocal candidates, ret
if left < 0:
return
if left == 0:
ret.append(tmp)
for i in range(len(candidates)):
if i < pos:
continue
traverse(i, tmp + [candidates[i]], left - candidates[i])
traverse(0, [], target)
return ret |
#!/usr/bin/env python3
################################################################
# From an imported list, this will sort and return a string
# pg 202
################################################################
def alphalist( orginal_list=[] ):
# Create working copy of list passed in
sorted_list = orginal_list.copy()
sorted_list.sort()
final_list = ''
for name in sorted_list:
final_list += name + ', '
# strip the ending comma and space
final_list = final_list[:-2]
# To return a list instead of a string, uncomment these lines and comment out the original return statement
# new_list = []
# splitOrig = final_list.split(', ')
# for item in splitOrig:
# new_list.append(item)
# return new_list
return final_list
# Call function
list = [ 'a', 'q', 'b']
new_list = alphalist(list)
print(new_list)
print('new list type = ')
print(type(new_list))
# preferred, single line
print('new list type = ',end='')
print(type(new_list))
| def alphalist(orginal_list=[]):
sorted_list = orginal_list.copy()
sorted_list.sort()
final_list = ''
for name in sorted_list:
final_list += name + ', '
final_list = final_list[:-2]
return final_list
list = ['a', 'q', 'b']
new_list = alphalist(list)
print(new_list)
print('new list type = ')
print(type(new_list))
print('new list type = ', end='')
print(type(new_list)) |
# -*- coding: utf-8 -*-
class Numbers:
def __init__(self, dct):
self.date = dct["date"]
self.numbers = dct["balls"]
self.stars = dct["stars"]
self.draw = dct["draw"]
def factory(dct):
return Numbers(dct)
def __repr__(self):
return f"date: {self.date}, draw: {self.draw}, numbers: {self.numbers}, stars: {self.stars}"
| class Numbers:
def __init__(self, dct):
self.date = dct['date']
self.numbers = dct['balls']
self.stars = dct['stars']
self.draw = dct['draw']
def factory(dct):
return numbers(dct)
def __repr__(self):
return f'date: {self.date}, draw: {self.draw}, numbers: {self.numbers}, stars: {self.stars}' |
# MIT License
# Copyright (c) 2021 David Rice
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""
Media Player and Announcement Board
Classes related to announcements
https://github.com/davidsmakerworks/media-display
TODO: Move announcement parsing to Announcement class
TODO: Better format to store announcements(?)
"""
class AnnouncementLine:
"""
Class representing one line of an announcement after it has
been parsed from JSON file
Properties:
text -- text of the line, or None if it is a blank line
size -- size of text or height of the blank line
color -- text color as a PyGame color object
center -- determines if line should be centered on the screen
"""
def __init__(self, text=None, size=0, color=None, center=False):
self.text = text
self.size = size
self.color = color
self.center = center
class Announcement:
"""
Class representing an announcement after it has been parsed from the
JSON file.
Properties:
start_date -- earliest date to show announcement
end_date -- latest date to show announcement
lines -- list of AnnouncementLine objects representing the individual
lines of the announcement
"""
def __init__(self, start_date, end_date, lines=None):
self.start_date = start_date
self.end_date = end_date
if lines:
self.lines = lines
else:
self.lines = []
if __name__ == '__main__':
print('This file should not be run directly. Run main.py instead.') | """
Media Player and Announcement Board
Classes related to announcements
https://github.com/davidsmakerworks/media-display
TODO: Move announcement parsing to Announcement class
TODO: Better format to store announcements(?)
"""
class Announcementline:
"""
Class representing one line of an announcement after it has
been parsed from JSON file
Properties:
text -- text of the line, or None if it is a blank line
size -- size of text or height of the blank line
color -- text color as a PyGame color object
center -- determines if line should be centered on the screen
"""
def __init__(self, text=None, size=0, color=None, center=False):
self.text = text
self.size = size
self.color = color
self.center = center
class Announcement:
"""
Class representing an announcement after it has been parsed from the
JSON file.
Properties:
start_date -- earliest date to show announcement
end_date -- latest date to show announcement
lines -- list of AnnouncementLine objects representing the individual
lines of the announcement
"""
def __init__(self, start_date, end_date, lines=None):
self.start_date = start_date
self.end_date = end_date
if lines:
self.lines = lines
else:
self.lines = []
if __name__ == '__main__':
print('This file should not be run directly. Run main.py instead.') |
#!/usr/bin/env python3
"""
This code is under Apache License 2.0
Written by B_Gameiro (Bernardo Bernardino Gameiro)
More in
SoloLearn: https://www.sololearn.com/Profile/8198571
GitHub: https://github.com/BGameiro76
Repl.it: https://repl.it/@B_Gameiro
Program display help menu
GUI in Python 3
Using Tkinter
"""
#======================
# Strings to use with the messages
#======================
Title = "Media Organizer GUI Help"
Message = "This app has the purpose of allowing the user to quickly access any app to display the different kinds of media in the computer." | """
This code is under Apache License 2.0
Written by B_Gameiro (Bernardo Bernardino Gameiro)
More in
SoloLearn: https://www.sololearn.com/Profile/8198571
GitHub: https://github.com/BGameiro76
Repl.it: https://repl.it/@B_Gameiro
Program display help menu
GUI in Python 3
Using Tkinter
"""
title = 'Media Organizer GUI Help'
message = 'This app has the purpose of allowing the user to quickly access any app to display the different kinds of media in the computer.' |
# Copyright 2017 mgIT GmbH All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Defines a rule for automatically updating deb_packages repository rules."""
_script_content = """
BASE=$(pwd)
WORKSPACE=$(dirname $(readlink WORKSPACE))
cd "$WORKSPACE"
$BASE/{update_deb_packages} {args} $@
"""
def _update_deb_packages_script_impl(ctx):
args = ctx.attr.args + ["--pgp-key=\"" + f.path + "\"" for f in ctx.files.pgp_keys] + ctx.attr.bzl_files
script_content = _script_content.format(update_deb_packages = ctx.file.update_deb_packages_exec.short_path, args = " ".join(args))
script_file = ctx.actions.declare_file(ctx.label.name + ".bash")
ctx.actions.write(script_file, script_content, True)
return [DefaultInfo(
files = depset([script_file]),
runfiles = ctx.runfiles([ctx.file.update_deb_packages_exec]),
executable = script_file,
)]
_update_deb_packages_script = rule(
_update_deb_packages_script_impl,
attrs = {
"args": attr.string_list(),
"bzl_files": attr.string_list(),
"pgp_keys": attr.label_list(),
"update_deb_packages_exec": attr.label(
allow_single_file = True,
executable = True,
cfg = "host",
),
},
)
def update_deb_packages(name, pgp_keys, **kwargs):
script_name = name + "_script"
_update_deb_packages_script(
name = script_name,
tags = ["manual"],
pgp_keys = pgp_keys,
update_deb_packages_exec = select({
"@bazel_tools//src/conditions:linux_aarch64": Label("@update_deb_packages_linux_arm64//file"),
"@bazel_tools//src/conditions:linux_x86_64": Label("@update_deb_packages_linux_amd64//file"),
"@bazel_tools//src/conditions:windows": Label("@update_deb_packages_windows_amd64//file"),
"@bazel_tools//src/conditions:darwin_x86_64": Label("@update_deb_packages_darwin_amd64//file"),
}),
**kwargs
)
native.sh_binary(
name = name,
srcs = [script_name],
data = ["//:WORKSPACE"] + pgp_keys,
tags = ["manual"],
)
| """Defines a rule for automatically updating deb_packages repository rules."""
_script_content = '\nBASE=$(pwd)\nWORKSPACE=$(dirname $(readlink WORKSPACE))\ncd "$WORKSPACE"\n$BASE/{update_deb_packages} {args} $@\n'
def _update_deb_packages_script_impl(ctx):
args = ctx.attr.args + ['--pgp-key="' + f.path + '"' for f in ctx.files.pgp_keys] + ctx.attr.bzl_files
script_content = _script_content.format(update_deb_packages=ctx.file.update_deb_packages_exec.short_path, args=' '.join(args))
script_file = ctx.actions.declare_file(ctx.label.name + '.bash')
ctx.actions.write(script_file, script_content, True)
return [default_info(files=depset([script_file]), runfiles=ctx.runfiles([ctx.file.update_deb_packages_exec]), executable=script_file)]
_update_deb_packages_script = rule(_update_deb_packages_script_impl, attrs={'args': attr.string_list(), 'bzl_files': attr.string_list(), 'pgp_keys': attr.label_list(), 'update_deb_packages_exec': attr.label(allow_single_file=True, executable=True, cfg='host')})
def update_deb_packages(name, pgp_keys, **kwargs):
script_name = name + '_script'
_update_deb_packages_script(name=script_name, tags=['manual'], pgp_keys=pgp_keys, update_deb_packages_exec=select({'@bazel_tools//src/conditions:linux_aarch64': label('@update_deb_packages_linux_arm64//file'), '@bazel_tools//src/conditions:linux_x86_64': label('@update_deb_packages_linux_amd64//file'), '@bazel_tools//src/conditions:windows': label('@update_deb_packages_windows_amd64//file'), '@bazel_tools//src/conditions:darwin_x86_64': label('@update_deb_packages_darwin_amd64//file')}), **kwargs)
native.sh_binary(name=name, srcs=[script_name], data=['//:WORKSPACE'] + pgp_keys, tags=['manual']) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.